trtc-sdk-v5 5.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/trtc.js ADDED
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e){try{return!!e()}catch(t){return!0}},i=!t((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),r=i,n=Function.prototype,o=n.call,a=r&&n.bind.bind(o,o),s=r?a:function(e){return function(){return o.apply(e,arguments)}},c=s,l=c({}.toString),d=c("".slice),u=function(e){return d(l(e),8,-1)},h=t,p=u,m=Object,_=s("".split),f=h((function(){return!m("z").propertyIsEnumerable(0)}))?function(e){return"String"==p(e)?_(e,""):m(e)}:m,g=function(e){return null==e},v=g,T=TypeError,S=function(e){if(v(e))throw T("Can't call method on "+e);return e},y=f,E=S,I=function(e){return y(E(e))},R=function(e){return e&&e.Math==Math&&e},A=R("object"==typeof globalThis&&globalThis)||R("object"==typeof window&&window)||R("object"==typeof self&&self)||R("object"==typeof e&&e)||function(){return this}()||Function("return this")(),C={},b={get exports(){return C},set exports(e){C=e}},k=A,w=Object.defineProperty,P=function(e,t){try{w(k,e,{value:t,configurable:!0,writable:!0})}catch(i){k[e]=t}return t},D=P,N="__core-js_shared__",O=A[N]||D(N,{}),M=O;(b.exports=function(e,t){return M[e]||(M[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.30.0",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.30.0/LICENSE",source:"https://github.com/zloirock/core-js"});var L,x,U=S,V=Object,F=function(e){return V(U(e))},j=F,B=s({}.hasOwnProperty),H=Object.hasOwn||function(e,t){return B(j(e),t)},G=s,W=0,J=Math.random(),z=G(1..toString),K=function(e){return"Symbol("+(void 0===e?"":e)+")_"+z(++W+J,36)},q="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Q=A,Y=q,X=Q.process,$=Q.Deno,Z=X&&X.versions||$&&$.version,ee=Z&&Z.v8;ee&&(x=(L=ee.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!x&&Y&&(!(L=Y.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=Y.match(/Chrome\/(\d+)/))&&(x=+L[1]);var te=x,ie=te,re=t,ne=!!Object.getOwnPropertySymbols&&!re((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ie&&ie<41})),oe=ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ae=C,se=H,ce=K,le=ne,de=oe,ue=A.Symbol,he=ae("wks"),pe=de?ue.for||ue:ue&&ue.withoutSetter||ce,me=function(e){return se(he,e)||(he[e]=le&&se(ue,e)?ue[e]:pe("Symbol."+e)),he[e]},_e="object"==typeof document&&document.all,fe={all:_e,IS_HTMLDDA:void 0===_e&&void 0!==_e},ge=fe.all,ve=fe.IS_HTMLDDA?function(e){return"function"==typeof e||e===ge}:function(e){return"function"==typeof e},Te=ve,Se=fe.all,ye=fe.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Te(e)||e===Se}:function(e){return"object"==typeof e?null!==e:Te(e)},Ee=ye,Ie=String,Re=TypeError,Ae=function(e){if(Ee(e))return e;throw Re(Ie(e)+" is not an object")},Ce={},be=!t((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),ke=be&&t((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),we={},Pe=ye,De=A.document,Ne=Pe(De)&&Pe(De.createElement),Oe=function(e){return Ne?De.createElement(e):{}},Me=Oe,Le=!be&&!t((function(){return 7!=Object.defineProperty(Me("div"),"a",{get:function(){return 7}}).a})),xe=i,Ue=Function.prototype.call,Ve=xe?Ue.bind(Ue):function(){return Ue.apply(Ue,arguments)},Fe=A,je=ve,Be=function(e){return je(e)?e:void 0},He=function(e,t){return arguments.length<2?Be(Fe[e]):Fe[e]&&Fe[e][t]},Ge=s({}.isPrototypeOf),We=He,Je=ve,ze=Ge,Ke=Object,qe=oe?function(e){return"symbol"==typeof e}:function(e){var t=We("Symbol");return Je(t)&&ze(t.prototype,Ke(e))},Qe=String,Ye=function(e){try{return Qe(e)}catch(t){return"Object"}},Xe=ve,$e=Ye,Ze=TypeError,et=function(e){if(Xe(e))return e;throw Ze($e(e)+" is not a function")},tt=et,it=g,rt=function(e,t){var i=e[t];return it(i)?void 0:tt(i)},nt=Ve,ot=ve,at=ye,st=TypeError,ct=Ve,lt=ye,dt=qe,ut=rt,ht=function(e,t){var i,r;if("string"===t&&ot(i=e.toString)&&!at(r=nt(i,e)))return r;if(ot(i=e.valueOf)&&!at(r=nt(i,e)))return r;if("string"!==t&&ot(i=e.toString)&&!at(r=nt(i,e)))return r;throw st("Can't convert object to primitive value")},pt=TypeError,mt=me("toPrimitive"),_t=function(e,t){if(!lt(e)||dt(e))return e;var i,r=ut(e,mt);if(r){if(void 0===t&&(t="default"),i=ct(r,e,t),!lt(i)||dt(i))return i;throw pt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ht(e,t)},ft=_t,gt=qe,vt=function(e){var t=ft(e,"string");return gt(t)?t:t+""},Tt=be,St=Le,yt=ke,Et=Ae,It=vt,Rt=TypeError,At=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,bt="enumerable",kt="configurable",wt="writable";we.f=Tt?yt?function(e,t,i){if(Et(e),t=It(t),Et(i),"function"==typeof e&&"prototype"===t&&"value"in i&&wt in i&&!i.writable){var r=Ct(e,t);r&&r.writable&&(e[t]=i.value,i={configurable:kt in i?i.configurable:r.configurable,enumerable:bt in i?i.enumerable:r.enumerable,writable:!1})}return At(e,t,i)}:At:function(e,t,i){if(Et(e),t=It(t),Et(i),St)try{return At(e,t,i)}catch(r){}if("get"in i||"set"in i)throw Rt("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Pt=Math.ceil,Dt=Math.floor,Nt=Math.trunc||function(e){var t=+e;return(t>0?Dt:Pt)(t)},Ot=Nt,Mt=function(e){var t=+e;return t!=t||0===t?0:Ot(t)},Lt=Mt,xt=Math.max,Ut=Math.min,Vt=function(e,t){var i=Lt(e);return i<0?xt(i+t,0):Ut(i,t)},Ft=Mt,jt=Math.min,Bt=function(e){return e>0?jt(Ft(e),9007199254740991):0},Ht=Bt,Gt=function(e){return Ht(e.length)},Wt=I,Jt=Vt,zt=Gt,Kt=function(e){return function(t,i,r){var n,o=Wt(t),a=zt(o),s=Jt(r,a);if(e&&i!=i){for(;a>s;)if((n=o[s++])!=n)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===i)return e||s||0;return!e&&-1}},qt={includes:Kt(!0),indexOf:Kt(!1)},Qt={},Yt=H,Xt=I,$t=qt.indexOf,Zt=Qt,ei=s([].push),ti=function(e,t){var i,r=Xt(e),n=0,o=[];for(i in r)!Yt(Zt,i)&&Yt(r,i)&&ei(o,i);for(;t.length>n;)Yt(r,i=t[n++])&&(~$t(o,i)||ei(o,i));return o},ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ri=ti,ni=ii,oi=Object.keys||function(e){return ri(e,ni)},ai=be,si=ke,ci=we,li=Ae,di=I,ui=oi;Ce.f=ai&&!si?Object.defineProperties:function(e,t){li(e);for(var i,r=di(t),n=ui(t),o=n.length,a=0;o>a;)ci.f(e,i=n[a++],r[i]);return e};var hi,pi=He("document","documentElement"),mi=K,_i=C("keys"),fi=function(e){return _i[e]||(_i[e]=mi(e))},gi=Ae,vi=Ce,Ti=ii,Si=Qt,yi=pi,Ei=Oe,Ii=fi("IE_PROTO"),Ri=function(){},Ai=function(e){return"<script>"+e+"</"+"script>"},Ci=function(e){e.write(Ai("")),e.close();var t=e.parentWindow.Object;return e=null,t},bi=function(){try{hi=new ActiveXObject("htmlfile")}catch(r){}var e,t;bi="undefined"!=typeof document?document.domain&&hi?Ci(hi):((t=Ei("iframe")).style.display="none",yi.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Ai("document.F=Object")),e.close(),e.F):Ci(hi);for(var i=Ti.length;i--;)delete bi.prototype[Ti[i]];return bi()};Si[Ii]=!0;var ki=Object.create||function(e,t){var i;return null!==e?(Ri.prototype=gi(e),i=new Ri,Ri.prototype=null,i[Ii]=e):i=bi(),void 0===t?i:vi.f(i,t)},wi=me,Pi=ki,Di=we.f,Ni=wi("unscopables"),Oi=Array.prototype;null==Oi[Ni]&&Di(Oi,Ni,{configurable:!0,value:Pi(null)});var Mi,Li,xi,Ui=function(e){Oi[Ni][e]=!0},Vi={},Fi=ve,ji=A.WeakMap,Bi=Fi(ji)&&/native code/.test(String(ji)),Hi=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Gi=we,Wi=Hi,Ji=be?function(e,t,i){return Gi.f(e,t,Wi(1,i))}:function(e,t,i){return e[t]=i,e},zi=Bi,Ki=A,qi=ye,Qi=Ji,Yi=H,Xi=O,$i=fi,Zi=Qt,er="Object already initialized",tr=Ki.TypeError,ir=Ki.WeakMap;if(zi||Xi.state){var rr=Xi.state||(Xi.state=new ir);rr.get=rr.get,rr.has=rr.has,rr.set=rr.set,Mi=function(e,t){if(rr.has(e))throw tr(er);return t.facade=e,rr.set(e,t),t},Li=function(e){return rr.get(e)||{}},xi=function(e){return rr.has(e)}}else{var nr=$i("state");Zi[nr]=!0,Mi=function(e,t){if(Yi(e,nr))throw tr(er);return t.facade=e,Qi(e,nr,t),t},Li=function(e){return Yi(e,nr)?e[nr]:{}},xi=function(e){return Yi(e,nr)}}var or={set:Mi,get:Li,has:xi,enforce:function(e){return xi(e)?Li(e):Mi(e,{})},getterFor:function(e){return function(t){var i;if(!qi(t)||(i=Li(t)).type!==e)throw tr("Incompatible receiver, "+e+" required");return i}}},ar={},sr={},cr={}.propertyIsEnumerable,lr=Object.getOwnPropertyDescriptor,dr=lr&&!cr.call({1:2},1);sr.f=dr?function(e){var t=lr(this,e);return!!t&&t.enumerable}:cr;var ur=be,hr=Ve,pr=sr,mr=Hi,_r=I,fr=vt,gr=H,vr=Le,Tr=Object.getOwnPropertyDescriptor;ar.f=ur?Tr:function(e,t){if(e=_r(e),t=fr(t),vr)try{return Tr(e,t)}catch(i){}if(gr(e,t))return mr(!hr(pr.f,e,t),e[t])};var Sr={},yr={get exports(){return Sr},set exports(e){Sr=e}},Er=be,Ir=H,Rr=Function.prototype,Ar=Er&&Object.getOwnPropertyDescriptor,Cr=Ir(Rr,"name"),br={EXISTS:Cr,PROPER:Cr&&"something"===function(){}.name,CONFIGURABLE:Cr&&(!Er||Er&&Ar(Rr,"name").configurable)},kr=ve,wr=O,Pr=s(Function.toString);kr(wr.inspectSource)||(wr.inspectSource=function(e){return Pr(e)});var Dr=wr.inspectSource,Nr=s,Or=t,Mr=ve,Lr=H,xr=be,Ur=br.CONFIGURABLE,Vr=Dr,Fr=or.enforce,jr=or.get,Br=String,Hr=Object.defineProperty,Gr=Nr("".slice),Wr=Nr("".replace),Jr=Nr([].join),zr=xr&&!Or((function(){return 8!==Hr((function(){}),"length",{value:8}).length})),Kr=String(String).split("String"),qr=yr.exports=function(e,t,i){"Symbol("===Gr(Br(t),0,7)&&(t="["+Wr(Br(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!Lr(e,"name")||Ur&&e.name!==t)&&(xr?Hr(e,"name",{value:t,configurable:!0}):e.name=t),zr&&i&&Lr(i,"arity")&&e.length!==i.arity&&Hr(e,"length",{value:i.arity});try{i&&Lr(i,"constructor")&&i.constructor?xr&&Hr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var r=Fr(e);return Lr(r,"source")||(r.source=Jr(Kr,"string"==typeof t?t:"")),e};Function.prototype.toString=qr((function(){return Mr(this)&&jr(this).source||Vr(this)}),"toString");var Qr=ve,Yr=we,Xr=Sr,$r=P,Zr=function(e,t,i,r){r||(r={});var n=r.enumerable,o=void 0!==r.name?r.name:t;if(Qr(i)&&Xr(i,o,r),r.global)n?e[t]=i:$r(t,i);else{try{r.unsafe?e[t]&&(n=!0):delete e[t]}catch(a){}n?e[t]=i:Yr.f(e,t,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},en={},tn=ti,rn=ii.concat("length","prototype");en.f=Object.getOwnPropertyNames||function(e){return tn(e,rn)};var nn={};nn.f=Object.getOwnPropertySymbols;var on,an,sn,cn=He,ln=en,dn=nn,un=Ae,hn=s([].concat),pn=cn("Reflect","ownKeys")||function(e){var t=ln.f(un(e)),i=dn.f;return i?hn(t,i(e)):t},mn=H,_n=pn,fn=ar,gn=we,vn=function(e,t,i){for(var r=_n(t),n=gn.f,o=fn.f,a=0;a<r.length;a++){var s=r[a];mn(e,s)||i&&mn(i,s)||n(e,s,o(t,s))}},Tn=t,Sn=ve,yn=/#|\.prototype\./,En=function(e,t){var i=Rn[In(e)];return i==Cn||i!=An&&(Sn(t)?Tn(t):!!t)},In=En.normalize=function(e){return String(e).replace(yn,".").toLowerCase()},Rn=En.data={},An=En.NATIVE="N",Cn=En.POLYFILL="P",bn=En,kn=A,wn=ar.f,Pn=Ji,Dn=Zr,Nn=P,On=vn,Mn=bn,Ln=function(e,t){var i,r,n,o,a,s=e.target,c=e.global,l=e.stat;if(i=c?kn:l?kn[s]||Nn(s,{}):(kn[s]||{}).prototype)for(r in t){if(o=t[r],n=e.dontCallGetSet?(a=wn(i,r))&&a.value:i[r],!Mn(c?r:s+(l?".":"#")+r,e.forced)&&void 0!==n){if(typeof o==typeof n)continue;On(o,n)}(e.sham||n&&n.sham)&&Pn(o,"sham",!0),Dn(i,r,o,e)}},xn=!t((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Un=H,Vn=ve,Fn=F,jn=xn,Bn=fi("IE_PROTO"),Hn=Object,Gn=Hn.prototype,Wn=jn?Hn.getPrototypeOf:function(e){var t=Fn(e);if(Un(t,Bn))return t[Bn];var i=t.constructor;return Vn(i)&&t instanceof i?i.prototype:t instanceof Hn?Gn:null},Jn=t,zn=ve,Kn=ye,qn=Wn,Qn=Zr,Yn=me("iterator"),Xn=!1;[].keys&&("next"in(sn=[].keys())?(an=qn(qn(sn)))!==Object.prototype&&(on=an):Xn=!0);var $n=!Kn(on)||Jn((function(){var e={};return on[Yn].call(e)!==e}));$n&&(on={}),zn(on[Yn])||Qn(on,Yn,(function(){return this}));var Zn={IteratorPrototype:on,BUGGY_SAFARI_ITERATORS:Xn},eo=we.f,to=H,io=me("toStringTag"),ro=function(e,t,i){e&&!i&&(e=e.prototype),e&&!to(e,io)&&eo(e,io,{configurable:!0,value:t})},no=Zn.IteratorPrototype,oo=ki,ao=Hi,so=ro,co=Vi,lo=function(){return this},uo=function(e,t,i,r){var n=t+" Iterator";return e.prototype=oo(no,{next:ao(+!r,i)}),so(e,n,!1),co[n]=lo,e},ho=s,po=et,mo=ve,_o=String,fo=TypeError,go=function(e,t,i){try{return ho(po(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(r){}},vo=Ae,To=function(e){if("object"==typeof e||mo(e))return e;throw fo("Can't set "+_o(e)+" as a prototype")},So=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=go(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(r){}return function(i,r){return vo(i),To(r),t?e(i,r):i.__proto__=r,i}}():void 0),yo=Ln,Eo=Ve,Io=ve,Ro=uo,Ao=Wn,Co=So,bo=ro,ko=Ji,wo=Zr,Po=Vi,Do=br.PROPER,No=br.CONFIGURABLE,Oo=Zn.IteratorPrototype,Mo=Zn.BUGGY_SAFARI_ITERATORS,Lo=me("iterator"),xo="keys",Uo="values",Vo="entries",Fo=function(){return this},jo=function(e,t,i,r,n,o,a){Ro(i,t,r);var s,c,l,d=function(e){if(e===n&&_)return _;if(!Mo&&e in p)return p[e];switch(e){case xo:case Uo:case Vo:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[Lo]||p["@@iterator"]||n&&p[n],_=!Mo&&m||d(n),f="Array"==t&&p.entries||m;if(f&&(s=Ao(f.call(new e)))!==Object.prototype&&s.next&&(Ao(s)!==Oo&&(Co?Co(s,Oo):Io(s[Lo])||wo(s,Lo,Fo)),bo(s,u,!0)),Do&&n==Uo&&m&&m.name!==Uo&&(No?ko(p,"name",Uo):(h=!0,_=function(){return Eo(m,this)})),n)if(c={values:d(Uo),keys:o?_:d(xo),entries:d(Vo)},a)for(l in c)(Mo||h||!(l in p))&&wo(p,l,c[l]);else yo({target:t,proto:!0,forced:Mo||h},c);return p[Lo]!==_&&wo(p,Lo,_,{name:n}),Po[t]=_,c},Bo=function(e,t){return{value:e,done:t}},Ho=I,Go=Ui,Wo=Vi,Jo=or,zo=we.f,Ko=jo,qo=Bo,Qo=be,Yo="Array Iterator",Xo=Jo.set,$o=Jo.getterFor(Yo),Zo=Ko(Array,"Array",(function(e,t){Xo(this,{type:Yo,target:Ho(e),index:0,kind:t})}),(function(){var e=$o(this),t=e.target,i=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,qo(void 0,!0)):qo("keys"==i?r:"values"==i?t[r]:[r,t[r]],!1)}),"values"),ea=Wo.Arguments=Wo.Array;if(Go("keys"),Go("values"),Go("entries"),Qo&&"values"!==ea.name)try{zo(ea,"name",{value:"values"})}catch(Vx){}var ta={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ia=Oe("span").classList,ra=ia&&ia.constructor&&ia.constructor.prototype,na=ra===Object.prototype?void 0:ra,oa=A,aa=ta,sa=na,ca=Zo,la=Ji,da=me,ua=da("iterator"),ha=da("toStringTag"),pa=ca.values,ma=function(e,t){if(e){if(e[ua]!==pa)try{la(e,ua,pa)}catch(Vx){e[ua]=pa}if(e[ha]||la(e,ha,t),aa[t])for(var i in ca)if(e[i]!==ca[i])try{la(e,i,ca[i])}catch(Vx){e[i]=ca[i]}}};for(var _a in aa)ma(oa[_a]&&oa[_a].prototype,_a);ma(sa,"DOMTokenList");var fa="undefined"!=typeof process&&"process"==u(process),ga=Sr,va=we,Ta=function(e,t,i){return i.get&&ga(i.get,t,{getter:!0}),i.set&&ga(i.set,t,{setter:!0}),va.f(e,t,i)},Sa=He,ya=Ta,Ea=be,Ia=me("species"),Ra=function(e){var t=Sa(e);Ea&&t&&!t[Ia]&&ya(t,Ia,{configurable:!0,get:function(){return this}})},Aa=Ge,Ca=TypeError,ba=function(e,t){if(Aa(t,e))return e;throw Ca("Incorrect invocation")},ka={};ka[me("toStringTag")]="z";var wa="[object z]"===String(ka),Pa=ve,Da=u,Na=me("toStringTag"),Oa=Object,Ma="Arguments"==Da(function(){return arguments}()),La=wa?Da:function(e){var t,i,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(Vx){}}(t=Oa(e),Na))?i:Ma?Da(t):"Object"==(r=Da(t))&&Pa(t.callee)?"Arguments":r},xa=s,Ua=t,Va=ve,Fa=La,ja=Dr,Ba=function(){},Ha=[],Ga=He("Reflect","construct"),Wa=/^\s*(?:class|function)\b/,Ja=xa(Wa.exec),za=!Wa.exec(Ba),Ka=function(e){if(!Va(e))return!1;try{return Ga(Ba,Ha,e),!0}catch(Vx){return!1}},qa=function(e){if(!Va(e))return!1;switch(Fa(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return za||!!Ja(Wa,ja(e))}catch(Vx){return!0}};qa.sham=!0;var Qa,Ya,Xa,$a,Za=!Ga||Ua((function(){var e;return Ka(Ka.call)||!Ka(Object)||!Ka((function(){e=!0}))||e}))?qa:Ka,es=Za,ts=Ye,is=TypeError,rs=function(e){if(es(e))return e;throw is(ts(e)+" is not a constructor")},ns=Ae,os=rs,as=g,ss=me("species"),cs=function(e,t){var i,r=ns(e).constructor;return void 0===r||as(i=ns(r)[ss])?t:os(i)},ls=i,ds=Function.prototype,us=ds.apply,hs=ds.call,ps="object"==typeof Reflect&&Reflect.apply||(ls?hs.bind(us):function(){return hs.apply(us,arguments)}),ms=u,_s=s,fs=function(e){if("Function"===ms(e))return _s(e)},gs=et,vs=i,Ts=fs(fs.bind),Ss=function(e,t){return gs(e),void 0===t?e:vs?Ts(e,t):function(){return e.apply(t,arguments)}},ys=s([].slice),Es=TypeError,Is=function(e,t){if(e<t)throw Es("Not enough arguments");return e},Rs=/(?:ipad|iphone|ipod).*applewebkit/i.test(q),As=A,Cs=ps,bs=Ss,ks=ve,ws=H,Ps=t,Ds=pi,Ns=ys,Os=Oe,Ms=Is,Ls=Rs,xs=fa,Us=As.setImmediate,Vs=As.clearImmediate,Fs=As.process,js=As.Dispatch,Bs=As.Function,Hs=As.MessageChannel,Gs=As.String,Ws=0,Js={},zs="onreadystatechange";Ps((function(){Qa=As.location}));var Ks=function(e){if(ws(Js,e)){var t=Js[e];delete Js[e],t()}},qs=function(e){return function(){Ks(e)}},Qs=function(e){Ks(e.data)},Ys=function(e){As.postMessage(Gs(e),Qa.protocol+"//"+Qa.host)};Us&&Vs||(Us=function(e){Ms(arguments.length,1);var t=ks(e)?e:Bs(e),i=Ns(arguments,1);return Js[++Ws]=function(){Cs(t,void 0,i)},Ya(Ws),Ws},Vs=function(e){delete Js[e]},xs?Ya=function(e){Fs.nextTick(qs(e))}:js&&js.now?Ya=function(e){js.now(qs(e))}:Hs&&!Ls?($a=(Xa=new Hs).port2,Xa.port1.onmessage=Qs,Ya=bs($a.postMessage,$a)):As.addEventListener&&ks(As.postMessage)&&!As.importScripts&&Qa&&"file:"!==Qa.protocol&&!Ps(Ys)?(Ya=Ys,As.addEventListener("message",Qs,!1)):Ya=zs in Os("script")?function(e){Ds.appendChild(Os("script")).onreadystatechange=function(){Ds.removeChild(this),Ks(e)}}:function(e){setTimeout(qs(e),0)});var Xs={set:Us,clear:Vs},$s=function(){this.head=null,this.tail=null};$s.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Zs,ec,tc,ic,rc,nc=$s,oc=/ipad|iphone|ipod/i.test(q)&&"undefined"!=typeof Pebble,ac=/web0s(?!.*chrome)/i.test(q),sc=A,cc=Ss,lc=ar.f,dc=Xs.set,uc=nc,hc=Rs,pc=oc,mc=ac,_c=fa,fc=sc.MutationObserver||sc.WebKitMutationObserver,gc=sc.document,vc=sc.process,Tc=sc.Promise,Sc=lc(sc,"queueMicrotask"),yc=Sc&&Sc.value;if(!yc){var Ec=new uc,Ic=function(){var e,t;for(_c&&(e=vc.domain)&&e.exit();t=Ec.get();)try{t()}catch(Vx){throw Ec.head&&Zs(),Vx}e&&e.enter()};hc||_c||mc||!fc||!gc?!pc&&Tc&&Tc.resolve?((ic=Tc.resolve(void 0)).constructor=Tc,rc=cc(ic.then,ic),Zs=function(){rc(Ic)}):_c?Zs=function(){vc.nextTick(Ic)}:(dc=cc(dc,sc),Zs=function(){dc(Ic)}):(ec=!0,tc=gc.createTextNode(""),new fc(Ic).observe(tc,{characterData:!0}),Zs=function(){tc.data=ec=!ec}),yc=function(e){Ec.head||Zs(),Ec.add(e)}}var Rc=yc,Ac=function(e){try{return{error:!1,value:e()}}catch(Vx){return{error:!0,value:Vx}}},Cc=A.Promise,bc="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,kc=!bc&&!fa&&"object"==typeof window&&"object"==typeof document,wc=A,Pc=Cc,Dc=ve,Nc=bn,Oc=Dr,Mc=me,Lc=kc,xc=bc,Uc=te;Pc&&Pc.prototype;var Vc=Mc("species"),Fc=!1,jc=Dc(wc.PromiseRejectionEvent),Bc=Nc("Promise",(function(){var e=Oc(Pc),t=e!==String(Pc);if(!t&&66===Uc)return!0;if(!Uc||Uc<51||!/native code/.test(e)){var i=new Pc((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[Vc]=r,!(Fc=i.then((function(){}))instanceof r))return!0}return!t&&(Lc||xc)&&!jc})),Hc={CONSTRUCTOR:Bc,REJECTION_EVENT:jc,SUBCLASSING:Fc},Gc={},Wc=et,Jc=TypeError,zc=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw Jc("Bad Promise constructor");t=e,i=r})),this.resolve=Wc(t),this.reject=Wc(i)};Gc.f=function(e){return new zc(e)};var Kc,qc,Qc,Yc=Ln,Xc=fa,$c=A,Zc=Ve,el=Zr,tl=So,il=ro,rl=Ra,nl=et,ol=ve,al=ye,sl=ba,cl=cs,ll=Xs.set,dl=Rc,ul=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(Vx){}},hl=Ac,pl=nc,ml=or,_l=Cc,fl=Gc,gl="Promise",vl=Hc.CONSTRUCTOR,Tl=Hc.REJECTION_EVENT,Sl=Hc.SUBCLASSING,yl=ml.getterFor(gl),El=ml.set,Il=_l&&_l.prototype,Rl=_l,Al=Il,Cl=$c.TypeError,bl=$c.document,kl=$c.process,wl=fl.f,Pl=wl,Dl=!!(bl&&bl.createEvent&&$c.dispatchEvent),Nl="unhandledrejection",Ol=function(e){var t;return!(!al(e)||!ol(t=e.then))&&t},Ml=function(e,t){var i,r,n,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Fl(t),t.rejection=1),!0===s?i=o:(d&&d.enter(),i=s(o),d&&(d.exit(),n=!0)),i===e.promise?l(Cl("Promise-chain cycle")):(r=Ol(i))?Zc(r,i,c,l):c(i)):l(o)}catch(Vx){d&&!n&&d.exit(),l(Vx)}},Ll=function(e,t){e.notified||(e.notified=!0,dl((function(){for(var i,r=e.reactions;i=r.get();)Ml(i,e);e.notified=!1,t&&!e.rejection&&Ul(e)})))},xl=function(e,t,i){var r,n;Dl?((r=bl.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),$c.dispatchEvent(r)):r={promise:t,reason:i},!Tl&&(n=$c["on"+e])?n(r):e===Nl&&ul("Unhandled promise rejection",i)},Ul=function(e){Zc(ll,$c,(function(){var t,i=e.facade,r=e.value;if(Vl(e)&&(t=hl((function(){Xc?kl.emit("unhandledRejection",r,i):xl(Nl,i,r)})),e.rejection=Xc||Vl(e)?2:1,t.error))throw t.value}))},Vl=function(e){return 1!==e.rejection&&!e.parent},Fl=function(e){Zc(ll,$c,(function(){var t=e.facade;Xc?kl.emit("rejectionHandled",t):xl("rejectionhandled",t,e.value)}))},jl=function(e,t,i){return function(r){e(t,r,i)}},Bl=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,Ll(e,!0))},Hl=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw Cl("Promise can't be resolved itself");var r=Ol(t);r?dl((function(){var i={done:!1};try{Zc(r,t,jl(Hl,i,e),jl(Bl,i,e))}catch(Vx){Bl(i,Vx,e)}})):(e.value=t,e.state=1,Ll(e,!1))}catch(Vx){Bl({done:!1},Vx,e)}}};if(vl&&(Al=(Rl=function(e){sl(this,Al),nl(e),Zc(Kc,this);var t=yl(this);try{e(jl(Hl,t),jl(Bl,t))}catch(Vx){Bl(t,Vx)}}).prototype,(Kc=function(e){El(this,{type:gl,done:!1,notified:!1,parent:!1,reactions:new pl,rejection:!1,state:0,value:void 0})}).prototype=el(Al,"then",(function(e,t){var i=yl(this),r=wl(cl(this,Rl));return i.parent=!0,r.ok=!ol(e)||e,r.fail=ol(t)&&t,r.domain=Xc?kl.domain:void 0,0==i.state?i.reactions.add(r):dl((function(){Ml(r,i)})),r.promise})),qc=function(){var e=new Kc,t=yl(e);this.promise=e,this.resolve=jl(Hl,t),this.reject=jl(Bl,t)},fl.f=wl=function(e){return e===Rl||undefined===e?new qc(e):Pl(e)},ol(_l)&&Il!==Object.prototype)){Qc=Il.then,Sl||el(Il,"then",(function(e,t){var i=this;return new Rl((function(e,t){Zc(Qc,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete Il.constructor}catch(Vx){}tl&&tl(Il,Al)}Yc({global:!0,constructor:!0,wrap:!0,forced:vl},{Promise:Rl}),il(Rl,gl,!1),rl(gl);var Gl=Vi,Wl=me("iterator"),Jl=Array.prototype,zl=function(e){return void 0!==e&&(Gl.Array===e||Jl[Wl]===e)},Kl=La,ql=rt,Ql=g,Yl=Vi,Xl=me("iterator"),$l=function(e){if(!Ql(e))return ql(e,Xl)||ql(e,"@@iterator")||Yl[Kl(e)]},Zl=Ve,ed=et,td=Ae,id=Ye,rd=$l,nd=TypeError,od=function(e,t){var i=arguments.length<2?rd(e):t;if(ed(i))return td(Zl(i,e));throw nd(id(e)+" is not iterable")},ad=Ve,sd=Ae,cd=rt,ld=function(e,t,i){var r,n;sd(e);try{if(!(r=cd(e,"return"))){if("throw"===t)throw i;return i}r=ad(r,e)}catch(Vx){n=!0,r=Vx}if("throw"===t)throw i;if(n)throw r;return sd(r),i},dd=Ss,ud=Ve,hd=Ae,pd=Ye,md=zl,_d=Gt,fd=Ge,gd=od,vd=$l,Td=ld,Sd=TypeError,yd=function(e,t){this.stopped=e,this.result=t},Ed=yd.prototype,Id=function(e,t,i){var r,n,o,a,s,c,l,d=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),m=!(!i||!i.INTERRUPTED),_=dd(t,d),f=function(e){return r&&Td(r,"normal",e),new yd(!0,e)},g=function(e){return u?(hd(e),m?_(e[0],e[1],f):_(e[0],e[1])):m?_(e,f):_(e)};if(h)r=e.iterator;else if(p)r=e;else{if(!(n=vd(e)))throw Sd(pd(e)+" is not iterable");if(md(n)){for(o=0,a=_d(e);a>o;o++)if((s=g(e[o]))&&fd(Ed,s))return s;return new yd(!1)}r=gd(e,n)}for(c=h?e.next:r.next;!(l=ud(c,r)).done;){try{s=g(l.value)}catch(Vx){Td(r,"throw",Vx)}if("object"==typeof s&&s&&fd(Ed,s))return s}return new yd(!1)},Rd=me("iterator"),Ad=!1;try{var Cd=0,bd={next:function(){return{done:!!Cd++}},return:function(){Ad=!0}};bd[Rd]=function(){return this},Array.from(bd,(function(){throw 2}))}catch(Vx){}var kd=function(e,t){if(!t&&!Ad)return!1;var i=!1;try{var r={};r[Rd]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(Vx){}return i},wd=Cc,Pd=Hc.CONSTRUCTOR||!kd((function(e){wd.all(e).then(void 0,(function(){}))})),Dd=Ve,Nd=et,Od=Gc,Md=Ac,Ld=Id;Ln({target:"Promise",stat:!0,forced:Pd},{all:function(e){var t=this,i=Od.f(t),r=i.resolve,n=i.reject,o=Md((function(){var i=Nd(t.resolve),o=[],a=0,s=1;Ld(e,(function(e){var c=a++,l=!1;s++,Dd(i,t,e).then((function(e){l||(l=!0,o[c]=e,--s||r(o))}),n)})),--s||r(o)}));return o.error&&n(o.value),i.promise}});var xd=Ln,Ud=Hc.CONSTRUCTOR,Vd=Cc,Fd=He,jd=ve,Bd=Zr,Hd=Vd&&Vd.prototype;if(xd({target:"Promise",proto:!0,forced:Ud,real:!0},{catch:function(e){return this.then(void 0,e)}}),jd(Vd)){var Gd=Fd("Promise").prototype.catch;Hd.catch!==Gd&&Bd(Hd,"catch",Gd,{unsafe:!0})}var Wd=Ve,Jd=et,zd=Gc,Kd=Ac,qd=Id;Ln({target:"Promise",stat:!0,forced:Pd},{race:function(e){var t=this,i=zd.f(t),r=i.reject,n=Kd((function(){var n=Jd(t.resolve);qd(e,(function(e){Wd(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var Qd=Ve,Yd=Gc;Ln({target:"Promise",stat:!0,forced:Hc.CONSTRUCTOR},{reject:function(e){var t=Yd.f(this);return Qd(t.reject,void 0,e),t.promise}});var Xd=Ae,$d=ye,Zd=Gc,eu=function(e,t){if(Xd(e),$d(t)&&t.constructor===e)return t;var i=Zd.f(e);return(0,i.resolve)(t),i.promise},tu=Ln,iu=Hc.CONSTRUCTOR,ru=eu;He("Promise"),tu({target:"Promise",stat:!0,forced:iu},{resolve:function(e){return ru(this,e)}});var nu=La,ou=String,au=function(e){if("Symbol"===nu(e))throw TypeError("Cannot convert a Symbol value to a string");return ou(e)},su=Ln,cu=be,lu=s,du=H,uu=ve,hu=Ge,pu=au,mu=Ta,_u=vn,fu=A.Symbol,gu=fu&&fu.prototype;if(cu&&uu(fu)&&(!("description"in gu)||void 0!==fu().description)){var vu={},Tu=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:pu(arguments[0]),t=hu(gu,this)?new fu(e):void 0===e?fu():fu(e);return""===e&&(vu[t]=!0),t};_u(Tu,fu),Tu.prototype=gu,gu.constructor=Tu;var Su="Symbol(test)"==String(fu("test")),yu=lu(gu.valueOf),Eu=lu(gu.toString),Iu=/^Symbol\((.*)\)[^)]+$/,Ru=lu("".replace),Au=lu("".slice);mu(gu,"description",{configurable:!0,get:function(){var e=yu(this);if(du(vu,e))return"";var t=Eu(e),i=Su?Au(t,7,-1):Ru(t,Iu,"$1");return""===i?void 0:i}}),su({global:!0,constructor:!0,forced:!0},{Symbol:Tu})}var Cu=Ae,bu=function(){var e=Cu(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},ku=t,wu=A.RegExp,Pu=ku((function(){var e=wu("a","y");return e.lastIndex=2,null!=e.exec("abcd")})),Du=Pu||ku((function(){return!wu("a","y").sticky})),Nu=Pu||ku((function(){var e=wu("^r","gy");return e.lastIndex=2,null!=e.exec("str")})),Ou={BROKEN_CARET:Nu,MISSED_STICKY:Du,UNSUPPORTED_Y:Pu},Mu=t,Lu=A.RegExp,xu=Mu((function(){var e=Lu(".","s");return!(e.dotAll&&e.exec("\n")&&"s"===e.flags)})),Uu=t,Vu=A.RegExp,Fu=Uu((function(){var e=Vu("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),ju=Ve,Bu=s,Hu=au,Gu=bu,Wu=Ou,Ju=ki,zu=or.get,Ku=xu,qu=Fu,Qu=C("native-string-replace",String.prototype.replace),Yu=RegExp.prototype.exec,Xu=Yu,$u=Bu("".charAt),Zu=Bu("".indexOf),eh=Bu("".replace),th=Bu("".slice),ih=function(){var e=/a/,t=/b*/g;return ju(Yu,e,"a"),ju(Yu,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),rh=Wu.BROKEN_CARET,nh=void 0!==/()??/.exec("")[1];(ih||nh||rh||Ku||qu)&&(Xu=function(e){var t,i,r,n,o,a,s,c=this,l=zu(c),d=Hu(e),u=l.raw;if(u)return u.lastIndex=c.lastIndex,t=ju(Xu,u,d),c.lastIndex=u.lastIndex,t;var h=l.groups,p=rh&&c.sticky,m=ju(Gu,c),_=c.source,f=0,g=d;if(p&&(m=eh(m,"y",""),-1===Zu(m,"g")&&(m+="g"),g=th(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==$u(d,c.lastIndex-1))&&(_="(?: "+_+")",g=" "+g,f++),i=new RegExp("^(?:"+_+")",m)),nh&&(i=new RegExp("^"+_+"$(?!\\s)",m)),ih&&(r=c.lastIndex),n=ju(Yu,p?i:c,g),p?n?(n.input=th(n.input,f),n[0]=th(n[0],f),n.index=c.lastIndex,c.lastIndex+=n[0].length):c.lastIndex=0:ih&&n&&(c.lastIndex=c.global?n.index+n[0].length:r),nh&&n&&n.length>1&&ju(Qu,n[0],i,(function(){for(o=1;o<arguments.length-2;o++)void 0===arguments[o]&&(n[o]=void 0)})),n&&h)for(n.groups=a=Ju(null),o=0;o<h.length;o++)a[(s=h[o])[0]]=n[s[1]];return n});var oh=Xu;Ln({target:"RegExp",proto:!0,forced:/./.exec!==oh},{exec:oh});var ah=et,sh=F,ch=f,lh=Gt,dh=TypeError,uh=function(e){return function(t,i,r,n){ah(i);var o=sh(t),a=ch(o),s=lh(o),c=e?s-1:0,l=e?-1:1;if(r<2)for(;;){if(c in a){n=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw dh("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=l)c in a&&(n=i(n,a[c],c,o));return n}},hh={left:uh(!1),right:uh(!0)},ph=t,mh=function(e,t){var i=[][e];return!!i&&ph((function(){i.call(null,t||function(){return 1},1)}))},_h=hh.left;Ln({target:"Array",proto:!0,forced:!fa&&te>79&&te<83||!mh("reduce")},{reduce:function(e){var t=arguments.length;return _h(this,e,t,t>1?arguments[1]:void 0)}});var fh=u,gh=Array.isArray||function(e){return"Array"==fh(e)},vh=gh,Th=Za,Sh=ye,yh=me("species"),Eh=Array,Ih=function(e){var t;return vh(e)&&(t=e.constructor,(Th(t)&&(t===Eh||vh(t.prototype))||Sh(t)&&null===(t=t[yh]))&&(t=void 0)),void 0===t?Eh:t},Rh=Ss,Ah=f,Ch=F,bh=Gt,kh=function(e,t){return new(Ih(e))(0===t?0:t)},wh=s([].push),Ph=function(e){var t=1==e,i=2==e,r=3==e,n=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,l,d,u){for(var h,p,m=Ch(c),_=Ah(m),f=Rh(l,d),g=bh(_),v=0,T=u||kh,S=t?T(c,g):i||a?T(c,0):void 0;g>v;v++)if((s||v in _)&&(p=f(h=_[v],v,m),e))if(t)S[v]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return v;case 2:wh(S,h)}else switch(e){case 4:return!1;case 7:wh(S,h)}return o?-1:r||n?n:S}},Dh={forEach:Ph(0),map:Ph(1),filter:Ph(2),some:Ph(3),every:Ph(4),find:Ph(5),findIndex:Ph(6),filterReject:Ph(7)},Nh=Dh.forEach,Oh=mh("forEach")?[].forEach:function(e){return Nh(this,e,arguments.length>1?arguments[1]:void 0)},Mh=A,Lh=ta,xh=na,Uh=Oh,Vh=Ji,Fh=function(e){if(e&&e.forEach!==Uh)try{Vh(e,"forEach",Uh)}catch(Vx){e.forEach=Uh}};for(var jh in Lh)Lh[jh]&&Fh(Mh[jh]&&Mh[jh].prototype);Fh(xh);var Bh=qt.includes,Hh=Ui;Ln({target:"Array",proto:!0,forced:t((function(){return!Array(1).includes()}))},{includes:function(e){return Bh(this,e,arguments.length>1?arguments[1]:void 0)}}),Hh("includes");var Gh=fs,Wh=Zr,Jh=oh,zh=t,Kh=me,qh=Ji,Qh=Kh("species"),Yh=RegExp.prototype,Xh=s,$h=Mt,Zh=au,ep=S,tp=Xh("".charAt),ip=Xh("".charCodeAt),rp=Xh("".slice),np=function(e){return function(t,i){var r,n,o=Zh(ep(t)),a=$h(i),s=o.length;return a<0||a>=s?e?"":void 0:(r=ip(o,a))<55296||r>56319||a+1===s||(n=ip(o,a+1))<56320||n>57343?e?tp(o,a):r:e?rp(o,a,a+2):n-56320+(r-55296<<10)+65536}},op={codeAt:np(!1),charAt:np(!0)},ap=op.charAt,sp=s,cp=F,lp=Math.floor,dp=sp("".charAt),up=sp("".replace),hp=sp("".slice),pp=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,mp=/\$([$&'`]|\d{1,2})/g,_p=Ve,fp=Ae,gp=ve,vp=u,Tp=oh,Sp=TypeError,yp=ps,Ep=Ve,Ip=s,Rp=function(e,t,i,r){var n=Kh(e),o=!zh((function(){var t={};return t[n]=function(){return 7},7!=""[e](t)})),a=o&&!zh((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[Qh]=function(){return i},i.flags="",i[n]=/./[n]),i.exec=function(){return t=!0,null},i[n](""),!t}));if(!o||!a||i){var s=Gh(/./[n]),c=t(n,""[e],(function(e,t,i,r,n){var a=Gh(e),c=t.exec;return c===Jh||c===Yh.exec?o&&!n?{done:!0,value:s(t,i,r)}:{done:!0,value:a(i,t,r)}:{done:!1}}));Wh(String.prototype,e,c[0]),Wh(Yh,n,c[1])}r&&qh(Yh[n],"sham",!0)},Ap=t,Cp=Ae,bp=ve,kp=g,wp=Mt,Pp=Bt,Dp=au,Np=S,Op=function(e,t,i){return t+(i?ap(e,t).length:1)},Mp=rt,Lp=function(e,t,i,r,n,o){var a=i+e.length,s=r.length,c=mp;return void 0!==n&&(n=cp(n),c=pp),up(o,c,(function(o,c){var l;switch(dp(c,0)){case"$":return"$";case"&":return e;case"`":return hp(t,0,i);case"'":return hp(t,a);case"<":l=n[hp(c,1,-1)];break;default:var d=+c;if(0===d)return o;if(d>s){var u=lp(d/10);return 0===u?o:u<=s?void 0===r[u-1]?dp(c,1):r[u-1]+dp(c,1):o}l=r[d-1]}return void 0===l?"":l}))},xp=function(e,t){var i=e.exec;if(gp(i)){var r=_p(i,e,t);return null!==r&&fp(r),r}if("RegExp"===vp(e))return _p(Tp,e,t);throw Sp("RegExp#exec called on incompatible receiver")},Up=me("replace"),Vp=Math.max,Fp=Math.min,jp=Ip([].concat),Bp=Ip([].push),Hp=Ip("".indexOf),Gp=Ip("".slice),Wp=function(e){return void 0===e?e:String(e)},Jp="$0"==="a".replace(/./,"$0"),zp=!!/./[Up]&&""===/./[Up]("a","$0"),Kp=!Ap((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));Rp("replace",(function(e,t,i){var r=zp?"$":"$0";return[function(e,i){var r=Np(this),n=kp(e)?void 0:Mp(e,Up);return n?Ep(n,e,r,i):Ep(t,Dp(r),e,i)},function(e,n){var o=Cp(this),a=Dp(e);if("string"==typeof n&&-1===Hp(n,r)&&-1===Hp(n,"$<")){var s=i(t,o,a,n);if(s.done)return s.value}var c=bp(n);c||(n=Dp(n));var l=o.global;if(l){var d=o.unicode;o.lastIndex=0}for(var u=[];;){var h=xp(o,a);if(null===h)break;if(Bp(u,h),!l)break;""===Dp(h[0])&&(o.lastIndex=Op(a,Pp(o.lastIndex),d))}for(var p="",m=0,_=0;_<u.length;_++){for(var f=Dp((h=u[_])[0]),g=Vp(Fp(wp(h.index),a.length),0),v=[],T=1;T<h.length;T++)Bp(v,Wp(h[T]));var S=h.groups;if(c){var y=jp([f],v,g,a);void 0!==S&&Bp(y,S);var E=Dp(yp(n,void 0,y))}else E=Lp(f,a,g,v,S,n);g>=m&&(p+=Gp(a,m,g)+E,m=g+f.length)}return p+Gp(a,m)}]}),!Kp||!Jp||zp);var qp=ve,Qp=ye,Yp=So,Xp=function(e,t,i){var r,n;return Yp&&qp(r=t.constructor)&&r!==i&&Qp(n=r.prototype)&&n!==i.prototype&&Yp(e,n),e},$p=ye,Zp=u,em=me("match"),tm=Ve,im=H,rm=Ge,nm=bu,om=RegExp.prototype,am=we.f,sm=be,cm=A,lm=s,dm=bn,um=Xp,hm=Ji,pm=en.f,mm=Ge,_m=function(e){var t;return $p(e)&&(void 0!==(t=e[em])?!!t:"RegExp"==Zp(e))},fm=au,gm=function(e){var t=e.flags;return void 0!==t||"flags"in om||im(e,"flags")||!rm(om,e)?t:tm(nm,e)},vm=Ou,Tm=function(e,t,i){i in e||am(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})},Sm=Zr,ym=t,Em=H,Im=or.enforce,Rm=Ra,Am=xu,Cm=Fu,bm=me("match"),km=cm.RegExp,wm=km.prototype,Pm=cm.SyntaxError,Dm=lm(wm.exec),Nm=lm("".charAt),Om=lm("".replace),Mm=lm("".indexOf),Lm=lm("".slice),xm=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Um=/a/g,Vm=/a/g,Fm=new km(Um)!==Um,jm=vm.MISSED_STICKY,Bm=vm.UNSUPPORTED_Y,Hm=sm&&(!Fm||jm||Am||Cm||ym((function(){return Vm[bm]=!1,km(Um)!=Um||km(Vm)==Vm||"/a/i"!=km(Um,"i")})));if(dm("RegExp",Hm)){for(var Gm=function(e,t){var i,r,n,o,a,s,c=mm(wm,this),l=_m(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===Gm)return e;if((l||mm(wm,e))&&(e=e.source,d&&(t=gm(h))),e=void 0===e?"":fm(e),t=void 0===t?"":fm(t),h=e,Am&&"dotAll"in Um&&(r=!!t&&Mm(t,"s")>-1)&&(t=Om(t,/s/g,"")),i=t,jm&&"sticky"in Um&&(n=!!t&&Mm(t,"y")>-1)&&Bm&&(t=Om(t,/y/g,"")),Cm&&(o=function(e){for(var t,i=e.length,r=0,n="",o=[],a={},s=!1,c=!1,l=0,d="";r<=i;r++){if("\\"===(t=Nm(e,r)))t+=Nm(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:Dm(xm,Lm(e,r+1))&&(r+=2,c=!0),n+=t,l++;continue;case">"===t&&c:if(""===d||Em(a,d))throw new Pm("Invalid capture group name");a[d]=!0,o[o.length]=[d,l],c=!1,d="";continue}c?d+=t:n+=t}return[n,o]}(e),e=o[0],u=o[1]),a=um(km(e,t),c?this:wm,Gm),(r||n||u.length)&&(s=Im(a),r&&(s.dotAll=!0,s.raw=Gm(function(e){for(var t,i=e.length,r=0,n="",o=!1;r<=i;r++)"\\"!==(t=Nm(e,r))?o||"."!==t?("["===t?o=!0:"]"===t&&(o=!1),n+=t):n+="[\\s\\S]":n+=t+Nm(e,++r);return n}(e),i)),n&&(s.sticky=!0),u.length&&(s.groups=u)),e!==h)try{hm(a,"source",""===h?"(?:)":h)}catch(Vx){}return a},Wm=pm(km),Jm=0;Wm.length>Jm;)Tm(Gm,km,Wm[Jm++]);wm.constructor=Gm,Gm.prototype=wm,Sm(cm,"RegExp",Gm,{constructor:!0})}Rm("RegExp");var zm="\t\n\v\f\r                 \u2028\u2029\ufeff",Km=S,qm=au,Qm=zm,Ym=s("".replace),Xm=RegExp("^["+Qm+"]+"),$m=RegExp("(^|[^"+Qm+"])["+Qm+"]+$"),Zm=function(e){return function(t){var i=qm(Km(t));return 1&e&&(i=Ym(i,Xm,"")),2&e&&(i=Ym(i,$m,"$1")),i}},e_={start:Zm(1),end:Zm(2),trim:Zm(3)},t_=br.PROPER,i_=t,r_=zm,n_=e_.trim;Ln({target:"String",proto:!0,forced:function(e){return i_((function(){return!!r_[e]()||"​…᠎"!=="​…᠎"[e]()||t_&&r_[e].name!==e}))}("trim")},{trim:function(){return n_(this)}});var o_=Ve;Ln({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return o_(URL.prototype.toString,this)}});var a_=Ln,s_=Cc,c_=t,l_=He,d_=ve,u_=cs,h_=eu,p_=Zr,m_=s_&&s_.prototype;if(a_({target:"Promise",proto:!0,real:!0,forced:!!s_&&c_((function(){m_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=u_(this,l_("Promise")),i=d_(e);return this.then(i?function(i){return h_(t,e()).then((function(){return i}))}:e,i?function(i){return h_(t,e()).then((function(){throw i}))}:e)}}),d_(s_)){var __=l_("Promise").prototype.finally;m_.finally!==__&&p_(m_,"finally",__,{unsafe:!0})}var f_=Mt,g_=au,v_=S,T_=RangeError,S_=s,y_=Bt,E_=au,I_=function(e){var t=g_(v_(this)),i="",r=f_(e);if(r<0||Infinity==r)throw T_("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(i+=t);return i},R_=S,A_=S_(I_),C_=S_("".slice),b_=Math.ceil,k_=function(e){return function(t,i,r){var n,o,a=E_(R_(t)),s=y_(i),c=a.length,l=void 0===r?" ":E_(r);return s<=c||""==l?a:((o=A_(l,b_((n=s-c)/l.length))).length>n&&(o=C_(o,0,n)),e?a+o:o+a)}},w_={start:k_(!1),end:k_(!0)},P_=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(q),D_=w_.start;Ln({target:"String",proto:!0,forced:P_},{padStart:function(e){return D_(this,e,arguments.length>1?arguments[1]:void 0)}});var N_=t,O_=be,M_=me("iterator"),L_=!N_((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,i="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),i+=r+e})),!t.size&&!O_||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[M_]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==i||"x"!==new URL("http://x",void 0).host})),x_=Zr,U_=function(e,t,i){for(var r in t)x_(e,r,t[r],i);return e},V_=vt,F_=we,j_=Hi,B_=function(e,t,i){var r=V_(t);r in e?F_.f(e,r,j_(0,i)):e[r]=i},H_=Vt,G_=Gt,W_=B_,J_=Array,z_=Math.max,K_=function(e,t,i){for(var r=G_(e),n=H_(t,r),o=H_(void 0===i?r:i,r),a=J_(z_(o-n,0)),s=0;n<o;n++,s++)W_(a,s,e[n]);return a.length=s,a},q_=K_,Q_=Math.floor,Y_=function(e,t){var i=e.length,r=Q_(i/2);return i<8?X_(e,t):$_(e,Y_(q_(e,0,r),t),Y_(q_(e,r),t),t)},X_=function(e,t){for(var i,r,n=e.length,o=1;o<n;){for(r=o,i=e[o];r&&t(e[r-1],i)>0;)e[r]=e[--r];r!==o++&&(e[r]=i)}return e},$_=function(e,t,i,r){for(var n=t.length,o=i.length,a=0,s=0;a<n||s<o;)e[a+s]=a<n&&s<o?r(t[a],i[s])<=0?t[a++]:i[s++]:a<n?t[a++]:i[s++];return e},Z_=Y_,ef=Ln,tf=A,rf=Ve,nf=s,of=be,af=L_,sf=Zr,cf=Ta,lf=U_,df=ro,uf=uo,hf=or,pf=ba,mf=ve,_f=H,ff=Ss,gf=La,vf=Ae,Tf=ye,Sf=au,yf=ki,Ef=Hi,If=od,Rf=$l,Af=Is,Cf=Z_,bf=me("iterator"),kf="URLSearchParams",wf="URLSearchParamsIterator",Pf=hf.set,Df=hf.getterFor(kf),Nf=hf.getterFor(wf),Of=Object.getOwnPropertyDescriptor,Mf=function(e){if(!of)return tf[e];var t=Of(tf,e);return t&&t.value},Lf=Mf("fetch"),xf=Mf("Request"),Uf=Mf("Headers"),Vf=xf&&xf.prototype,Ff=Uf&&Uf.prototype,jf=tf.RegExp,Bf=tf.TypeError,Hf=tf.decodeURIComponent,Gf=tf.encodeURIComponent,Wf=nf("".charAt),Jf=nf([].join),zf=nf([].push),Kf=nf("".replace),qf=nf([].shift),Qf=nf([].splice),Yf=nf("".split),Xf=nf("".slice),$f=/\+/g,Zf=Array(4),eg=function(e){return Zf[e-1]||(Zf[e-1]=jf("((?:%[\\da-f]{2}){"+e+"})","gi"))},tg=function(e){try{return Hf(e)}catch(Vx){return e}},ig=function(e){var t=Kf(e,$f," "),i=4;try{return Hf(t)}catch(Vx){for(;i;)t=Kf(t,eg(i--),tg);return t}},rg=/[!'()~]|%20/g,ng={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},og=function(e){return ng[e]},ag=function(e){return Kf(Gf(e),rg,og)},sg=uf((function(e,t){Pf(this,{type:wf,iterator:If(Df(e).entries),kind:t})}),"Iterator",(function(){var e=Nf(this),t=e.kind,i=e.iterator.next(),r=i.value;return i.done||(i.value="keys"===t?r.key:"values"===t?r.value:[r.key,r.value]),i}),!0),cg=function(e){this.entries=[],this.url=null,void 0!==e&&(Tf(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Wf(e,0)?Xf(e,1):e:Sf(e)))};cg.prototype={type:kf,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,r,n,o,a,s,c=Rf(e);if(c)for(i=(t=If(e,c)).next;!(r=rf(i,t)).done;){if(o=(n=If(vf(r.value))).next,(a=rf(o,n)).done||(s=rf(o,n)).done||!rf(o,n).done)throw Bf("Expected sequence with length 2");zf(this.entries,{key:Sf(a.value),value:Sf(s.value)})}else for(var l in e)_f(e,l)&&zf(this.entries,{key:l,value:Sf(e[l])})},parseQuery:function(e){if(e)for(var t,i,r=Yf(e,"&"),n=0;n<r.length;)(t=r[n++]).length&&(i=Yf(t,"="),zf(this.entries,{key:ig(qf(i)),value:ig(Jf(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],r=0;r<t.length;)e=t[r++],zf(i,ag(e.key)+"="+ag(e.value));return Jf(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var lg=function(){pf(this,dg);var e=arguments.length>0?arguments[0]:void 0,t=Pf(this,new cg(e));of||(this.length=t.entries.length)},dg=lg.prototype;if(lf(dg,{append:function(e,t){Af(arguments.length,2);var i=Df(this);zf(i.entries,{key:Sf(e),value:Sf(t)}),of||this.length++,i.updateURL()},delete:function(e){Af(arguments.length,1);for(var t=Df(this),i=t.entries,r=Sf(e),n=0;n<i.length;)i[n].key===r?Qf(i,n,1):n++;of||(this.length=i.length),t.updateURL()},get:function(e){Af(arguments.length,1);for(var t=Df(this).entries,i=Sf(e),r=0;r<t.length;r++)if(t[r].key===i)return t[r].value;return null},getAll:function(e){Af(arguments.length,1);for(var t=Df(this).entries,i=Sf(e),r=[],n=0;n<t.length;n++)t[n].key===i&&zf(r,t[n].value);return r},has:function(e){Af(arguments.length,1);for(var t=Df(this).entries,i=Sf(e),r=0;r<t.length;)if(t[r++].key===i)return!0;return!1},set:function(e,t){Af(arguments.length,1);for(var i,r=Df(this),n=r.entries,o=!1,a=Sf(e),s=Sf(t),c=0;c<n.length;c++)(i=n[c]).key===a&&(o?Qf(n,c--,1):(o=!0,i.value=s));o||zf(n,{key:a,value:s}),of||(this.length=n.length),r.updateURL()},sort:function(){var e=Df(this);Cf(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=Df(this).entries,r=ff(e,arguments.length>1?arguments[1]:void 0),n=0;n<i.length;)r((t=i[n++]).value,t.key,this)},keys:function(){return new sg(this,"keys")},values:function(){return new sg(this,"values")},entries:function(){return new sg(this,"entries")}},{enumerable:!0}),sf(dg,bf,dg.entries,{name:"entries"}),sf(dg,"toString",(function(){return Df(this).serialize()}),{enumerable:!0}),of&&cf(dg,"size",{get:function(){return Df(this).entries.length},configurable:!0,enumerable:!0}),df(lg,kf),ef({global:!0,constructor:!0,forced:!af},{URLSearchParams:lg}),!af&&mf(Uf)){var ug=nf(Ff.has),hg=nf(Ff.set),pg=function(e){if(Tf(e)){var t,i=e.body;if(gf(i)===kf)return t=e.headers?new Uf(e.headers):new Uf,ug(t,"content-type")||hg(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),yf(e,{body:Ef(0,Sf(i)),headers:Ef(0,t)})}return e};if(mf(Lf)&&ef({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Lf(e,arguments.length>1?pg(arguments[1]):{})}}),mf(xf)){var mg=function(e){return pf(this,Vf),new xf(e,arguments.length>1?pg(arguments[1]):{})};Vf.constructor=mg,mg.prototype=Vf,ef({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:mg})}}var _g={URLSearchParams:lg,getState:Df},fg=op.charAt,gg=au,vg=or,Tg=jo,Sg=Bo,yg="String Iterator",Eg=vg.set,Ig=vg.getterFor(yg);Tg(String,"String",(function(e){Eg(this,{type:yg,string:gg(e),index:0})}),(function(){var e,t=Ig(this),i=t.string,r=t.index;return r>=i.length?Sg(void 0,!0):(e=fg(i,r),t.index+=e.length,Sg(e,!1))}));var Rg,Ag=be,Cg=s,bg=Ve,kg=t,wg=oi,Pg=nn,Dg=sr,Ng=F,Og=f,Mg=Object.assign,Lg=Object.defineProperty,xg=Cg([].concat),Ug=!Mg||kg((function(){if(Ag&&1!==Mg({b:1},Mg(Lg({},"a",{enumerable:!0,get:function(){Lg(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol(),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!=Mg({},e)[i]||wg(Mg({},t)).join("")!=r}))?function(e,t){for(var i=Ng(e),r=arguments.length,n=1,o=Pg.f,a=Dg.f;r>n;)for(var s,c=Og(arguments[n++]),l=o?xg(wg(c),o(c)):wg(c),d=l.length,u=0;d>u;)s=l[u++],Ag&&!bg(a,c,s)||(i[s]=c[s]);return i}:Mg,Vg=Ae,Fg=ld,jg=Ss,Bg=Ve,Hg=F,Gg=function(e,t,i,r){try{return r?t(Vg(i)[0],i[1]):t(i)}catch(Vx){Fg(e,"throw",Vx)}},Wg=zl,Jg=Za,zg=Gt,Kg=B_,qg=od,Qg=$l,Yg=Array,Xg=s,$g=2147483647,Zg=/[^\0-\u007E]/,ev=/[.\u3002\uFF0E\uFF61]/g,tv="Overflow: input needs wider integers to process",iv=RangeError,rv=Xg(ev.exec),nv=Math.floor,ov=String.fromCharCode,av=Xg("".charCodeAt),sv=Xg([].join),cv=Xg([].push),lv=Xg("".replace),dv=Xg("".split),uv=Xg("".toLowerCase),hv=function(e){return e+22+75*(e<26)},pv=function(e,t,i){var r=0;for(e=i?nv(e/700):e>>1,e+=nv(e/t);e>455;)e=nv(e/35),r+=36;return nv(r+36*e/(e+38))},mv=function(e){var t=[];e=function(e){for(var t=[],i=0,r=e.length;i<r;){var n=av(e,i++);if(n>=55296&&n<=56319&&i<r){var o=av(e,i++);56320==(64512&o)?cv(t,((1023&n)<<10)+(1023&o)+65536):(cv(t,n),i--)}else cv(t,n)}return t}(e);var i,r,n=e.length,o=128,a=0,s=72;for(i=0;i<e.length;i++)(r=e[i])<128&&cv(t,ov(r));var c=t.length,l=c;for(c&&cv(t,"-");l<n;){var d=$g;for(i=0;i<e.length;i++)(r=e[i])>=o&&r<d&&(d=r);var u=l+1;if(d-o>nv(($g-a)/u))throw iv(tv);for(a+=(d-o)*u,o=d,i=0;i<e.length;i++){if((r=e[i])<o&&++a>$g)throw iv(tv);if(r==o){for(var h=a,p=36;;){var m=p<=s?1:p>=s+26?26:p-s;if(h<m)break;var _=h-m,f=36-m;cv(t,ov(hv(m+_%f))),h=nv(_/f),p+=36}cv(t,ov(hv(h))),s=pv(a,u,l==c),a=0,l++}}a++,o++}return sv(t,"")},_v=Ln,fv=be,gv=L_,vv=A,Tv=Ss,Sv=s,yv=Zr,Ev=Ta,Iv=ba,Rv=H,Av=Ug,Cv=function(e){var t=Hg(e),i=Jg(this),r=arguments.length,n=r>1?arguments[1]:void 0,o=void 0!==n;o&&(n=jg(n,r>2?arguments[2]:void 0));var a,s,c,l,d,u,h=Qg(t),p=0;if(!h||this===Yg&&Wg(h))for(a=zg(t),s=i?new this(a):Yg(a);a>p;p++)u=o?n(t[p],p):t[p],Kg(s,p,u);else for(d=(l=qg(t,h)).next,s=i?new this:[];!(c=Bg(d,l)).done;p++)u=o?Gg(l,n,[c.value,p],!0):c.value,Kg(s,p,u);return s.length=p,s},bv=K_,kv=op.codeAt,wv=function(e){var t,i,r=[],n=dv(lv(uv(e),ev,"."),".");for(t=0;t<n.length;t++)i=n[t],cv(r,rv(Zg,i)?"xn--"+mv(i):i);return sv(r,".")},Pv=au,Dv=ro,Nv=Is,Ov=_g,Mv=or,Lv=Mv.set,xv=Mv.getterFor("URL"),Uv=Ov.URLSearchParams,Vv=Ov.getState,Fv=vv.URL,jv=vv.TypeError,Bv=vv.parseInt,Hv=Math.floor,Gv=Math.pow,Wv=Sv("".charAt),Jv=Sv(/./.exec),zv=Sv([].join),Kv=Sv(1..toString),qv=Sv([].pop),Qv=Sv([].push),Yv=Sv("".replace),Xv=Sv([].shift),$v=Sv("".split),Zv=Sv("".slice),eT=Sv("".toLowerCase),tT=Sv([].unshift),iT="Invalid scheme",rT="Invalid host",nT="Invalid port",oT=/[a-z]/i,aT=/[\d+-.a-z]/i,sT=/\d/,cT=/^0x/i,lT=/^[0-7]+$/,dT=/^\d+$/,uT=/^[\da-f]+$/i,hT=/[\0\t\n\r #%/:<>?@[\\\]^|]/,pT=/[\0\t\n\r #/:<>?@[\\\]^|]/,mT=/^[\u0000-\u0020]+/,_T=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,fT=/[\t\n\r]/g,gT=function(e){var t,i,r,n;if("number"==typeof e){for(t=[],i=0;i<4;i++)tT(t,e%256),e=Hv(e/256);return zv(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,i=1,r=null,n=0,o=0;o<8;o++)0!==e[o]?(n>i&&(t=r,i=n),r=null,n=0):(null===r&&(r=o),++n);return n>i&&(t=r,i=n),t}(e),i=0;i<8;i++)n&&0===e[i]||(n&&(n=!1),r===i?(t+=i?":":"::",n=!0):(t+=Kv(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},vT={},TT=Av({},vT,{" ":1,'"':1,"<":1,">":1,"`":1}),ST=Av({},TT,{"#":1,"?":1,"{":1,"}":1}),yT=Av({},ST,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ET=function(e,t){var i=kv(e,0);return i>32&&i<127&&!Rv(t,e)?e:encodeURIComponent(e)},IT={ftp:21,file:null,http:80,https:443,ws:80,wss:443},RT=function(e,t){var i;return 2==e.length&&Jv(oT,Wv(e,0))&&(":"==(i=Wv(e,1))||!t&&"|"==i)},AT=function(e){var t;return e.length>1&&RT(Zv(e,0,2))&&(2==e.length||"/"===(t=Wv(e,2))||"\\"===t||"?"===t||"#"===t)},CT=function(e){return"."===e||"%2e"===eT(e)},bT={},kT={},wT={},PT={},DT={},NT={},OT={},MT={},LT={},xT={},UT={},VT={},FT={},jT={},BT={},HT={},GT={},WT={},JT={},zT={},KT={},qT=function(e,t,i){var r,n,o,a=Pv(e);if(t){if(n=this.parse(a))throw jv(n);this.searchParams=null}else{if(void 0!==i&&(r=new qT(i,!0)),n=this.parse(a,null,r))throw jv(n);(o=Vv(new Uv)).bindURL(this),this.searchParams=o}};qT.prototype={type:"URL",parse:function(e,t,i){var r,n,o,a,s,c=this,l=t||bT,d=0,u="",h=!1,p=!1,m=!1;for(e=Pv(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=Yv(e,mT,""),e=Yv(e,_T,"$1")),e=Yv(e,fT,""),r=Cv(e);d<=r.length;){switch(n=r[d],l){case bT:if(!n||!Jv(oT,n)){if(t)return iT;l=wT;continue}u+=eT(n),l=kT;break;case kT:if(n&&(Jv(aT,n)||"+"==n||"-"==n||"."==n))u+=eT(n);else{if(":"!=n){if(t)return iT;u="",l=wT,d=0;continue}if(t&&(c.isSpecial()!=Rv(IT,u)||"file"==u&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&IT[c.scheme]==c.port&&(c.port=null));u="","file"==c.scheme?l=jT:c.isSpecial()&&i&&i.scheme==c.scheme?l=PT:c.isSpecial()?l=MT:"/"==r[d+1]?(l=DT,d++):(c.cannotBeABaseURL=!0,Qv(c.path,""),l=JT)}break;case wT:if(!i||i.cannotBeABaseURL&&"#"!=n)return iT;if(i.cannotBeABaseURL&&"#"==n){c.scheme=i.scheme,c.path=bv(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,l=KT;break}l="file"==i.scheme?jT:NT;continue;case PT:if("/"!=n||"/"!=r[d+1]){l=NT;continue}l=LT,d++;break;case DT:if("/"==n){l=xT;break}l=WT;continue;case NT:if(c.scheme=i.scheme,n==Rg)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=bv(i.path),c.query=i.query;else if("/"==n||"\\"==n&&c.isSpecial())l=OT;else if("?"==n)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=bv(i.path),c.query="",l=zT;else{if("#"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=bv(i.path),c.path.length--,l=WT;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=bv(i.path),c.query=i.query,c.fragment="",l=KT}break;case OT:if(!c.isSpecial()||"/"!=n&&"\\"!=n){if("/"!=n){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,l=WT;continue}l=xT}else l=LT;break;case MT:if(l=LT,"/"!=n||"/"!=Wv(u,d+1))continue;d++;break;case LT:if("/"!=n&&"\\"!=n){l=xT;continue}break;case xT:if("@"==n){h&&(u="%40"+u),h=!0,o=Cv(u);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||m){var g=ET(f,yT);m?c.password+=g:c.username+=g}else m=!0}u=""}else if(n==Rg||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(h&&""==u)return"Invalid authority";d-=Cv(u).length+1,u="",l=UT}else u+=n;break;case UT:case VT:if(t&&"file"==c.scheme){l=HT;continue}if(":"!=n||p){if(n==Rg||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()){if(c.isSpecial()&&""==u)return rT;if(t&&""==u&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(u))return a;if(u="",l=GT,t)return;continue}"["==n?p=!0:"]"==n&&(p=!1),u+=n}else{if(""==u)return rT;if(a=c.parseHost(u))return a;if(u="",l=FT,t==VT)return}break;case FT:if(!Jv(sT,n)){if(n==Rg||"/"==n||"?"==n||"#"==n||"\\"==n&&c.isSpecial()||t){if(""!=u){var v=Bv(u,10);if(v>65535)return nT;c.port=c.isSpecial()&&v===IT[c.scheme]?null:v,u=""}if(t)return;l=GT;continue}return nT}u+=n;break;case jT:if(c.scheme="file","/"==n||"\\"==n)l=BT;else{if(!i||"file"!=i.scheme){l=WT;continue}if(n==Rg)c.host=i.host,c.path=bv(i.path),c.query=i.query;else if("?"==n)c.host=i.host,c.path=bv(i.path),c.query="",l=zT;else{if("#"!=n){AT(zv(bv(r,d),""))||(c.host=i.host,c.path=bv(i.path),c.shortenPath()),l=WT;continue}c.host=i.host,c.path=bv(i.path),c.query=i.query,c.fragment="",l=KT}}break;case BT:if("/"==n||"\\"==n){l=HT;break}i&&"file"==i.scheme&&!AT(zv(bv(r,d),""))&&(RT(i.path[0],!0)?Qv(c.path,i.path[0]):c.host=i.host),l=WT;continue;case HT:if(n==Rg||"/"==n||"\\"==n||"?"==n||"#"==n){if(!t&&RT(u))l=WT;else if(""==u){if(c.host="",t)return;l=GT}else{if(a=c.parseHost(u))return a;if("localhost"==c.host&&(c.host=""),t)return;u="",l=GT}continue}u+=n;break;case GT:if(c.isSpecial()){if(l=WT,"/"!=n&&"\\"!=n)continue}else if(t||"?"!=n)if(t||"#"!=n){if(n!=Rg&&(l=WT,"/"!=n))continue}else c.fragment="",l=KT;else c.query="",l=zT;break;case WT:if(n==Rg||"/"==n||"\\"==n&&c.isSpecial()||!t&&("?"==n||"#"==n)){if(".."===(s=eT(s=u))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==n||"\\"==n&&c.isSpecial()||Qv(c.path,"")):CT(u)?"/"==n||"\\"==n&&c.isSpecial()||Qv(c.path,""):("file"==c.scheme&&!c.path.length&&RT(u)&&(c.host&&(c.host=""),u=Wv(u,0)+":"),Qv(c.path,u)),u="","file"==c.scheme&&(n==Rg||"?"==n||"#"==n))for(;c.path.length>1&&""===c.path[0];)Xv(c.path);"?"==n?(c.query="",l=zT):"#"==n&&(c.fragment="",l=KT)}else u+=ET(n,ST);break;case JT:"?"==n?(c.query="",l=zT):"#"==n?(c.fragment="",l=KT):n!=Rg&&(c.path[0]+=ET(n,vT));break;case zT:t||"#"!=n?n!=Rg&&("'"==n&&c.isSpecial()?c.query+="%27":c.query+="#"==n?"%23":ET(n,vT)):(c.fragment="",l=KT);break;case KT:n!=Rg&&(c.fragment+=ET(n,TT))}d++}},parseHost:function(e){var t,i,r;if("["==Wv(e,0)){if("]"!=Wv(e,e.length-1))return rT;if(t=function(e){var t,i,r,n,o,a,s,c=[0,0,0,0,0,0,0,0],l=0,d=null,u=0,h=function(){return Wv(e,u)};if(":"==h()){if(":"!=Wv(e,1))return;u+=2,d=++l}for(;h();){if(8==l)return;if(":"!=h()){for(t=i=0;i<4&&Jv(uT,h());)t=16*t+Bv(h(),16),u++,i++;if("."==h()){if(0==i)return;if(u-=i,l>6)return;for(r=0;h();){if(n=null,r>0){if(!("."==h()&&r<4))return;u++}if(!Jv(sT,h()))return;for(;Jv(sT,h());){if(o=Bv(h(),10),null===n)n=o;else{if(0==n)return;n=10*n+o}if(n>255)return;u++}c[l]=256*c[l]+n,2!=++r&&4!=r||l++}if(4!=r)return;break}if(":"==h()){if(u++,!h())return}else if(h())return;c[l++]=t}else{if(null!==d)return;u++,d=++l}}if(null!==d)for(a=l-d,l=7;0!=l&&a>0;)s=c[l],c[l--]=c[d+a-1],c[d+--a]=s;else if(8!=l)return;return c}(Zv(e,1,-1)),!t)return rT;this.host=t}else if(this.isSpecial()){if(e=wv(e),Jv(hT,e))return rT;if(t=function(e){var t,i,r,n,o,a,s,c=$v(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],r=0;r<t;r++){if(""==(n=c[r]))return e;if(o=10,n.length>1&&"0"==Wv(n,0)&&(o=Jv(cT,n)?16:8,n=Zv(n,8==o?1:2)),""===n)a=0;else{if(!Jv(10==o?dT:8==o?lT:uT,n))return e;a=Bv(n,o)}Qv(i,a)}for(r=0;r<t;r++)if(a=i[r],r==t-1){if(a>=Gv(256,5-t))return null}else if(a>255)return null;for(s=qv(i),r=0;r<i.length;r++)s+=i[r]*Gv(256,3-r);return s}(e),null===t)return rT;this.host=t}else{if(Jv(pT,e))return rT;for(t="",i=Cv(e),r=0;r<i.length;r++)t+=ET(i[r],vT);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return Rv(IT,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&RT(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,r=e.password,n=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,l=t+":";return null!==n?(l+="//",e.includesCredentials()&&(l+=i+(r?":"+r:"")+"@"),l+=gT(n),null!==o&&(l+=":"+o)):"file"==t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+zv(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw jv(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new QT(e.path[0]).origin}catch(Vx){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+gT(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(Pv(e)+":",bT)},getUsername:function(){return this.username},setUsername:function(e){var t=Cv(Pv(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=ET(t[i],yT)}},getPassword:function(){return this.password},setPassword:function(e){var t=Cv(Pv(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=ET(t[i],yT)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?gT(e):gT(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,UT)},getHostname:function(){var e=this.host;return null===e?"":gT(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,VT)},getPort:function(){var e=this.port;return null===e?"":Pv(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=Pv(e))?this.port=null:this.parse(e,FT))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+zv(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,GT))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=Pv(e))?this.query=null:("?"==Wv(e,0)&&(e=Zv(e,1)),this.query="",this.parse(e,zT)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=Pv(e))?("#"==Wv(e,0)&&(e=Zv(e,1)),this.fragment="",this.parse(e,KT)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var QT=function(e){var t=Iv(this,YT),i=Nv(arguments.length,1)>1?arguments[1]:void 0,r=Lv(t,new qT(e,!1,i));fv||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},YT=QT.prototype,XT=function(e,t){return{get:function(){return xv(this)[e]()},set:t&&function(e){return xv(this)[t](e)},configurable:!0,enumerable:!0}};if(fv&&(Ev(YT,"href",XT("serialize","setHref")),Ev(YT,"origin",XT("getOrigin")),Ev(YT,"protocol",XT("getProtocol","setProtocol")),Ev(YT,"username",XT("getUsername","setUsername")),Ev(YT,"password",XT("getPassword","setPassword")),Ev(YT,"host",XT("getHost","setHost")),Ev(YT,"hostname",XT("getHostname","setHostname")),Ev(YT,"port",XT("getPort","setPort")),Ev(YT,"pathname",XT("getPathname","setPathname")),Ev(YT,"search",XT("getSearch","setSearch")),Ev(YT,"searchParams",XT("getSearchParams")),Ev(YT,"hash",XT("getHash","setHash"))),yv(YT,"toJSON",(function(){return xv(this).serialize()}),{enumerable:!0}),yv(YT,"toString",(function(){return xv(this).serialize()}),{enumerable:!0}),Fv){var $T=Fv.createObjectURL,ZT=Fv.revokeObjectURL;$T&&yv(QT,"createObjectURL",Tv($T,Fv)),ZT&&yv(QT,"revokeObjectURL",Tv(ZT,Fv))}Dv(QT,"URL"),_v({global:!0,constructor:!0,forced:!gv,sham:!fv},{URL:QT});var eS=Ye,tS=TypeError,iS=q.match(/firefox\/(\d+)/i),rS=!!iS&&+iS[1],nS=/MSIE|Trident/.test(q),oS=q.match(/AppleWebKit\/(\d+)\./),aS=!!oS&&+oS[1],sS=Ln,cS=s,lS=et,dS=F,uS=Gt,hS=function(e,t){if(!delete e[t])throw tS("Cannot delete property "+eS(t)+" of "+eS(e))},pS=au,mS=t,_S=Z_,fS=mh,gS=rS,vS=nS,TS=te,SS=aS,yS=[],ES=cS(yS.sort),IS=cS(yS.push),RS=mS((function(){yS.sort(void 0)})),AS=mS((function(){yS.sort(null)})),CS=fS("sort"),bS=!mS((function(){if(TS)return TS<70;if(!(gS&&gS>3)){if(vS)return!0;if(SS)return SS<603;var e,t,i,r,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(r=0;r<47;r++)yS.push({k:t+r,v:i})}for(yS.sort((function(e,t){return t.v-e.v})),r=0;r<yS.length;r++)t=yS[r].k.charAt(0),n.charAt(n.length-1)!==t&&(n+=t);return"DGBEFHACIJK"!==n}}));sS({target:"Array",proto:!0,forced:RS||!AS||!CS||!bS},{sort:function(e){void 0!==e&&lS(e);var t=dS(this);if(bS)return void 0===e?ES(t):ES(t,e);var i,r,n=[],o=uS(t);for(r=0;r<o;r++)r in t&&IS(n,t[r]);for(_S(n,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:pS(t)>pS(i)?1:-1}}(e)),i=uS(n),r=0;r<i;)t[r]=n[r++];for(;r<o;)hS(t,r++);return t}});var kS="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,wS=Mt,PS=Bt,DS=RangeError,NS=function(e){if(void 0===e)return 0;var t=wS(e),i=PS(t);if(t!==i)throw DS("Wrong length or index");return i},OS=Array,MS=Math.abs,LS=Math.pow,xS=Math.floor,US=Math.log,VS=Math.LN2,FS={pack:function(e,t,i){var r,n,o,a=OS(i),s=8*i-t-1,c=(1<<s)-1,l=c>>1,d=23===t?LS(2,-24)-LS(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=MS(e))!=e||Infinity===e?(n=e!=e?1:0,r=c):(r=xS(US(e)/VS),e*(o=LS(2,-r))<1&&(r--,o*=2),(e+=r+l>=1?d/o:d*LS(2,1-l))*o>=2&&(r++,o/=2),r+l>=c?(n=0,r=c):r+l>=1?(n=(e*o-1)*LS(2,t),r+=l):(n=e*LS(2,l-1)*LS(2,t),r=0));t>=8;)a[h++]=255&n,n/=256,t-=8;for(r=r<<t|n,s+=t;s>0;)a[h++]=255&r,r/=256,s-=8;return a[--h]|=128*u,a},unpack:function(e,t){var i,r=e.length,n=8*r-t-1,o=(1<<n)-1,a=o>>1,s=n-7,c=r-1,l=e[c--],d=127&l;for(l>>=7;s>0;)d=256*d+e[c--],s-=8;for(i=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)i=256*i+e[c--],s-=8;if(0===d)d=1-a;else{if(d===o)return i?NaN:l?-Infinity:Infinity;i+=LS(2,t),d-=a}return(l?-1:1)*i*LS(2,d-t)}},jS=F,BS=Vt,HS=Gt,GS=function(e){for(var t=jS(this),i=HS(t),r=arguments.length,n=BS(r>1?arguments[1]:void 0,i),o=r>2?arguments[2]:void 0,a=void 0===o?i:BS(o,i);a>n;)t[n++]=e;return t},WS=A,JS=s,zS=be,KS=kS,qS=br,QS=Ji,YS=Ta,XS=U_,$S=t,ZS=ba,ey=Mt,ty=Bt,iy=NS,ry=FS,ny=Wn,oy=So,ay=en.f,sy=GS,cy=K_,ly=ro,dy=or,uy=qS.PROPER,hy=qS.CONFIGURABLE,py="ArrayBuffer",my="DataView",_y="Wrong index",fy=dy.getterFor(py),gy=dy.getterFor(my),vy=dy.set,Ty=WS.ArrayBuffer,Sy=Ty,yy=Sy&&Sy.prototype,Ey=WS.DataView,Iy=Ey&&Ey.prototype,Ry=Object.prototype,Ay=WS.Array,Cy=WS.RangeError,by=JS(sy),ky=JS([].reverse),wy=ry.pack,Py=ry.unpack,Dy=function(e){return[255&e]},Ny=function(e){return[255&e,e>>8&255]},Oy=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},My=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Ly=function(e){return wy(e,23,4)},xy=function(e){return wy(e,52,8)},Uy=function(e,t,i){YS(e.prototype,t,{configurable:!0,get:function(){return i(this)[t]}})},Vy=function(e,t,i,r){var n=iy(i),o=gy(e);if(n+t>o.byteLength)throw Cy(_y);var a=o.bytes,s=n+o.byteOffset,c=cy(a,s,s+t);return r?c:ky(c)},Fy=function(e,t,i,r,n,o){var a=iy(i),s=gy(e);if(a+t>s.byteLength)throw Cy(_y);for(var c=s.bytes,l=a+s.byteOffset,d=r(+n),u=0;u<t;u++)c[l+u]=d[o?u:t-u-1]};if(KS){var jy=uy&&Ty.name!==py;if($S((function(){Ty(1)}))&&$S((function(){new Ty(-1)}))&&!$S((function(){return new Ty,new Ty(1.5),new Ty(NaN),1!=Ty.length||jy&&!hy})))jy&&hy&&QS(Ty,"name",py);else{(Sy=function(e){return ZS(this,yy),new Ty(iy(e))}).prototype=yy;for(var By,Hy=ay(Ty),Gy=0;Hy.length>Gy;)(By=Hy[Gy++])in Sy||QS(Sy,By,Ty[By]);yy.constructor=Sy}oy&&ny(Iy)!==Ry&&oy(Iy,Ry);var Wy=new Ey(new Sy(2)),Jy=JS(Iy.setInt8);Wy.setInt8(0,2147483648),Wy.setInt8(1,2147483649),!Wy.getInt8(0)&&Wy.getInt8(1)||XS(Iy,{setInt8:function(e,t){Jy(this,e,t<<24>>24)},setUint8:function(e,t){Jy(this,e,t<<24>>24)}},{unsafe:!0})}else yy=(Sy=function(e){ZS(this,yy);var t=iy(e);vy(this,{type:py,bytes:by(Ay(t),0),byteLength:t}),zS||(this.byteLength=t,this.detached=!1)}).prototype,Iy=(Ey=function(e,t,i){ZS(this,Iy),ZS(e,yy);var r=fy(e),n=r.byteLength,o=ey(t);if(o<0||o>n)throw Cy("Wrong offset");if(o+(i=void 0===i?n-o:ty(i))>n)throw Cy("Wrong length");vy(this,{type:my,buffer:e,byteLength:i,byteOffset:o,bytes:r.bytes}),zS||(this.buffer=e,this.byteLength=i,this.byteOffset=o)}).prototype,zS&&(Uy(Sy,"byteLength",fy),Uy(Ey,"buffer",gy),Uy(Ey,"byteLength",gy),Uy(Ey,"byteOffset",gy)),XS(Iy,{getInt8:function(e){return Vy(this,1,e)[0]<<24>>24},getUint8:function(e){return Vy(this,1,e)[0]},getInt16:function(e){var t=Vy(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Vy(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return My(Vy(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return My(Vy(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return Py(Vy(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return Py(Vy(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){Fy(this,1,e,Dy,t)},setUint8:function(e,t){Fy(this,1,e,Dy,t)},setInt16:function(e,t){Fy(this,2,e,Ny,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){Fy(this,2,e,Ny,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){Fy(this,4,e,Oy,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){Fy(this,4,e,Oy,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){Fy(this,4,e,Ly,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){Fy(this,8,e,xy,t,arguments.length>2?arguments[2]:void 0)}});ly(Sy,py),ly(Ey,my);var zy={ArrayBuffer:Sy,DataView:Ey},Ky=Ln,qy=fs,Qy=t,Yy=Ae,Xy=Vt,$y=Bt,Zy=cs,eE=zy.ArrayBuffer,tE=zy.DataView,iE=tE.prototype,rE=qy(eE.prototype.slice),nE=qy(iE.getUint8),oE=qy(iE.setUint8);Ky({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Qy((function(){return!new eE(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(rE&&void 0===t)return rE(Yy(this),e);for(var i=Yy(this).byteLength,r=Xy(e,i),n=Xy(void 0===t?i:t,i),o=new(Zy(this,eE))($y(n-r)),a=new tE(this),s=new tE(o),c=0;r<n;)oE(s,c++,nE(a,r++));return o}});var aE=Ln,sE=gh,cE=s([].reverse),lE=[1,2];aE({target:"Array",proto:!0,forced:String(lE)===String(lE.reverse())},{reverse:function(){return sE(this)&&(this.length=this.length),cE(this)}});var dE=Ra,uE="ArrayBuffer",hE=zy.ArrayBuffer;Ln({global:!0,constructor:!0,forced:A.ArrayBuffer!==hE},{ArrayBuffer:hE}),dE(uE);var pE,mE,_E,fE={},gE={get exports(){return fE},set exports(e){fE=e}},vE=kS,TE=be,SE=A,yE=ve,EE=ye,IE=H,RE=La,AE=Ye,CE=Ji,bE=Zr,kE=Ta,wE=Ge,PE=Wn,DE=So,NE=me,OE=K,ME=or.enforce,LE=or.get,xE=SE.Int8Array,UE=xE&&xE.prototype,VE=SE.Uint8ClampedArray,FE=VE&&VE.prototype,jE=xE&&PE(xE),BE=UE&&PE(UE),HE=Object.prototype,GE=SE.TypeError,WE=NE("toStringTag"),JE=OE("TYPED_ARRAY_TAG"),zE="TypedArrayConstructor",KE=vE&&!!DE&&"Opera"!==RE(SE.opera),qE=!1,QE={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},YE={BigInt64Array:8,BigUint64Array:8},XE=function(e){var t=PE(e);if(EE(t)){var i=LE(t);return i&&IE(i,zE)?i.TypedArrayConstructor:XE(t)}},$E=function(e){if(!EE(e))return!1;var t=RE(e);return IE(QE,t)||IE(YE,t)};for(pE in QE)(_E=(mE=SE[pE])&&mE.prototype)?ME(_E).TypedArrayConstructor=mE:KE=!1;for(pE in YE)(_E=(mE=SE[pE])&&mE.prototype)&&(ME(_E).TypedArrayConstructor=mE);if((!KE||!yE(jE)||jE===Function.prototype)&&(jE=function(){throw GE("Incorrect invocation")},KE))for(pE in QE)SE[pE]&&DE(SE[pE],jE);if((!KE||!BE||BE===HE)&&(BE=jE.prototype,KE))for(pE in QE)SE[pE]&&DE(SE[pE].prototype,BE);if(KE&&PE(FE)!==BE&&DE(FE,BE),TE&&!IE(BE,WE))for(pE in qE=!0,kE(BE,WE,{configurable:!0,get:function(){return EE(this)?this[JE]:void 0}}),QE)SE[pE]&&CE(SE[pE],JE,pE);var ZE={NATIVE_ARRAY_BUFFER_VIEWS:KE,TYPED_ARRAY_TAG:qE&&JE,aTypedArray:function(e){if($E(e))return e;throw GE("Target is not a typed array")},aTypedArrayConstructor:function(e){if(yE(e)&&(!DE||wE(jE,e)))return e;throw GE(AE(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,r){if(TE){if(i)for(var n in QE){var o=SE[n];if(o&&IE(o.prototype,e))try{delete o.prototype[e]}catch(Vx){try{o.prototype[e]=t}catch(a){}}}BE[e]&&!i||bE(BE,e,i?t:KE&&UE[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,i){var r,n;if(TE){if(DE){if(i)for(r in QE)if((n=SE[r])&&IE(n,e))try{delete n[e]}catch(Vx){}if(jE[e]&&!i)return;try{return bE(jE,e,i?t:KE&&jE[e]||t)}catch(Vx){}}for(r in QE)!(n=SE[r])||n[e]&&!i||bE(n,e,t)}},getTypedArrayConstructor:XE,isView:function(e){if(!EE(e))return!1;var t=RE(e);return"DataView"===t||IE(QE,t)||IE(YE,t)},isTypedArray:$E,TypedArray:jE,TypedArrayPrototype:BE},eI=A,tI=t,iI=kd,rI=ZE.NATIVE_ARRAY_BUFFER_VIEWS,nI=eI.ArrayBuffer,oI=eI.Int8Array,aI=!rI||!tI((function(){oI(1)}))||!tI((function(){new oI(-1)}))||!iI((function(e){new oI,new oI(null),new oI(1.5),new oI(e)}),!0)||tI((function(){return 1!==new oI(new nI(2),1,void 0).length})),sI=ye,cI=Math.floor,lI=Number.isInteger||function(e){return!sI(e)&&isFinite(e)&&cI(e)===e},dI=Mt,uI=RangeError,hI=function(e){var t=dI(e);if(t<0)throw uI("The argument can't be less than 0");return t},pI=RangeError,mI=function(e,t){var i=hI(e);if(i%t)throw pI("Wrong offset");return i},_I=La,fI=_t,gI=TypeError,vI=function(e){var t=fI(e,"number");if("number"==typeof t)throw gI("Can't convert number to bigint");return BigInt(t)},TI=Ss,SI=Ve,yI=rs,EI=F,II=Gt,RI=od,AI=$l,CI=zl,bI=function(e){var t=_I(e);return"BigInt64Array"==t||"BigUint64Array"==t},kI=ZE.aTypedArrayConstructor,wI=vI,PI=Ln,DI=A,NI=Ve,OI=be,MI=aI,LI=ZE,xI=zy,UI=ba,VI=Hi,FI=Ji,jI=lI,BI=Bt,HI=NS,GI=mI,WI=vt,JI=H,zI=La,KI=ye,qI=qe,QI=ki,YI=Ge,XI=So,$I=en.f,ZI=function(e){var t,i,r,n,o,a,s,c,l=yI(this),d=EI(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=AI(d);if(m&&!CI(m))for(c=(s=RI(d,m)).next,d=[];!(a=SI(c,s)).done;)d.push(a.value);for(p&&u>2&&(h=TI(h,arguments[2])),i=II(d),r=new(kI(l))(i),n=bI(r),t=0;i>t;t++)o=p?h(d[t],t):d[t],r[t]=n?wI(o):+o;return r},eR=Dh.forEach,tR=Ra,iR=Ta,rR=we,nR=ar,oR=Xp,aR=or.get,sR=or.set,cR=or.enforce,lR=rR.f,dR=nR.f,uR=Math.round,hR=DI.RangeError,pR=xI.ArrayBuffer,mR=pR.prototype,_R=xI.DataView,fR=LI.NATIVE_ARRAY_BUFFER_VIEWS,gR=LI.TYPED_ARRAY_TAG,vR=LI.TypedArray,TR=LI.TypedArrayPrototype,SR=LI.aTypedArrayConstructor,yR=LI.isTypedArray,ER="BYTES_PER_ELEMENT",IR="Wrong length",RR=function(e,t){SR(e);for(var i=0,r=t.length,n=new e(r);r>i;)n[i]=t[i++];return n},AR=function(e,t){iR(e,t,{configurable:!0,get:function(){return aR(this)[t]}})},CR=function(e){var t;return YI(mR,e)||"ArrayBuffer"==(t=zI(e))||"SharedArrayBuffer"==t},bR=function(e,t){return yR(e)&&!qI(t)&&t in e&&jI(+t)&&t>=0},kR=function(e,t){return t=WI(t),bR(e,t)?VI(2,e[t]):dR(e,t)},wR=function(e,t,i){return t=WI(t),!(bR(e,t)&&KI(i)&&JI(i,"value"))||JI(i,"get")||JI(i,"set")||i.configurable||JI(i,"writable")&&!i.writable||JI(i,"enumerable")&&!i.enumerable?lR(e,t,i):(e[t]=i.value,e)};OI?(fR||(nR.f=kR,rR.f=wR,AR(TR,"buffer"),AR(TR,"byteOffset"),AR(TR,"byteLength"),AR(TR,"length")),PI({target:"Object",stat:!0,forced:!fR},{getOwnPropertyDescriptor:kR,defineProperty:wR}),gE.exports=function(e,t,i){var r=e.match(/\d+/)[0]/8,n=e+(i?"Clamped":"")+"Array",o="get"+e,a="set"+e,s=DI[n],c=s,l=c&&c.prototype,d={},u=function(e,t){lR(e,t,{get:function(){return function(e,t){var i=aR(e);return i.view[o](t*r+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var o=aR(e);i&&(n=(n=uR(n))<0?0:n>255?255:255&n),o.view[a](t*r+o.byteOffset,n,!0)}(this,t,e)},enumerable:!0})};fR?MI&&(c=t((function(e,t,i,n){return UI(e,l),oR(KI(t)?CR(t)?void 0!==n?new s(t,GI(i,r),n):void 0!==i?new s(t,GI(i,r)):new s(t):yR(t)?RR(c,t):NI(ZI,c,t):new s(HI(t)),e,c)})),XI&&XI(c,vR),eR($I(s),(function(e){e in c||FI(c,e,s[e])})),c.prototype=l):(c=t((function(e,t,i,n){UI(e,l);var o,a,s,d=0,h=0;if(KI(t)){if(!CR(t))return yR(t)?RR(c,t):NI(ZI,c,t);o=t,h=GI(i,r);var p=t.byteLength;if(void 0===n){if(p%r)throw hR(IR);if((a=p-h)<0)throw hR(IR)}else if((a=BI(n)*r)+h>p)throw hR(IR);s=a/r}else s=HI(t),o=new pR(a=s*r);for(sR(e,{buffer:o,byteOffset:h,byteLength:a,length:s,view:new _R(o)});d<s;)u(e,d++)})),XI&&XI(c,vR),l=c.prototype=QI(TR)),l.constructor!==c&&FI(l,"constructor",c),cR(l).TypedArrayConstructor=c,gR&&FI(l,gR,n);var h=c!=s;d[n]=c,PI({global:!0,constructor:!0,forced:h,sham:!fR},d),ER in c||FI(c,ER,r),ER in l||FI(l,ER,r),tR(n)}):gE.exports=function(){},fE("Uint8",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var PR=GS,DR=vI,NR=La,OR=Ve,MR=t,LR=ZE.aTypedArray,xR=ZE.exportTypedArrayMethod,UR=s("".slice);xR("fill",(function(e){var t=arguments.length;LR(this);var i="Big"===UR(NR(this),0,3)?DR(e):+e;return OR(PR,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),MR((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var VR=A,FR=Ve,jR=ZE,BR=Gt,HR=mI,GR=F,WR=t,JR=VR.RangeError,zR=VR.Int8Array,KR=zR&&zR.prototype,qR=KR&&KR.set,QR=jR.aTypedArray,YR=jR.exportTypedArrayMethod,XR=!WR((function(){var e=new Uint8ClampedArray(2);return FR(qR,e,{length:1,0:3},1),3!==e[1]})),$R=XR&&jR.NATIVE_ARRAY_BUFFER_VIEWS&&WR((function(){var e=new zR(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));YR("set",(function(e){QR(this);var t=HR(arguments.length>1?arguments[1]:void 0,1),i=GR(e);if(XR)return FR(qR,this,i,t);var r=this.length,n=BR(i),o=0;if(n+t>r)throw JR("Wrong length");for(;o<n;)this[t+o]=i[o++]}),!XR||$R);var ZR=fs,eA=t,tA=et,iA=Z_,rA=rS,nA=nS,oA=te,aA=aS,sA=ZE.aTypedArray,cA=ZE.exportTypedArrayMethod,lA=A.Uint16Array,dA=lA&&ZR(lA.prototype.sort),uA=!(!dA||eA((function(){dA(new lA(2),null)}))&&eA((function(){dA(new lA(2),{})}))),hA=!!dA&&!eA((function(){if(oA)return oA<74;if(rA)return rA<67;if(nA)return!0;if(aA)return aA<602;var e,t,i=new lA(516),r=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,r[e]=e-2*t+3;for(dA(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==r[e])return!0}));cA("sort",(function(e){return void 0!==e&&tA(e),hA?dA(this,e):iA(sA(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?-1:t!=t?1:0===t&&0===i?1/t>0&&1/i<0?1:-1:t>i}}(e))}),!hA||uA);var pA=Object.create,mA=Object.defineProperty,_A=Object.defineProperties,fA=Object.getOwnPropertyDescriptor,gA=Object.getOwnPropertyDescriptors,vA=Object.getOwnPropertyNames,TA=Object.getOwnPropertySymbols,SA=Object.getPrototypeOf,yA=Object.prototype.hasOwnProperty,EA=Object.prototype.propertyIsEnumerable,IA=Reflect.get,RA=Math.pow,AA=(e,t,i)=>t in e?mA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,CA=(e,t)=>{for(var i in t||(t={}))yA.call(t,i)&&AA(e,i,t[i]);if(TA)for(var i of TA(t))EA.call(t,i)&&AA(e,i,t[i]);return e},bA=(e,t)=>_A(e,gA(t)),kA=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wA=(e,t)=>{for(var i in t)mA(e,i,{get:t[i],enumerable:!0})},PA=(e,t,i)=>(i=null!=e?pA(SA(e)):{},((e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of vA(t))!yA.call(e,n)&&n!==i&&mA(e,n,{get:()=>t[n],enumerable:!(r=fA(t,n))||r.enumerable});return e})(!t&&e&&e.__esModule?i:mA(i,"default",{value:e,enumerable:!0}),e)),DA=(e,t,i,r)=>{for(var n,o=r>1?void 0:r?fA(t,i):t,a=e.length-1;a>=0;a--)(n=e[a])&&(o=(r?n(t,i,o):n(o))||o);return r&&o&&mA(t,i,o),o},NA=(e,t,i)=>(AA(e,"symbol"!=typeof t?t+"":t,i),i),OA=(e,t,i)=>IA(SA(e),i,t),MA=(e,t,i)=>new Promise(((r,n)=>{var o=e=>{try{s(i.next(e))}catch(t){n(t)}},a=e=>{try{s(i.throw(e))}catch(t){n(t)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(o,a);s((i=i.apply(e,t)).next())})),LA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.extractVersion=n,e.wrapPeerConnectionEvent=function(e,t,i){if(e.RTCPeerConnection){var r=e.RTCPeerConnection.prototype,n=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return n.apply(this,arguments);var o=function(e){var t=i(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),n.apply(this,[e,o])};var o=r.removeEventListener;r.removeEventListener=function(e,i){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(i))return o.apply(this,arguments);var r=this._eventMap[t].get(i);return this._eventMap[t].delete(i),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,r])},Object.defineProperty(r,"on"+t,{get:function(){return this["_on"+t]},set:function(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})}},e.disableLog=function(e){return"boolean"!=typeof e?new Error("Argument type: "+(void 0===e?"undefined":t(e))+". Please use a boolean."):(i=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},e.disableWarnings=function(e){return"boolean"!=typeof e?new Error("Argument type: "+(void 0===e?"undefined":t(e))+". Please use a boolean."):(r=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},e.log=function(){if("object"===("undefined"==typeof window?"undefined":t(window))){if(i)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},e.deprecated=function(e,t){!r||console.warn(e+" is deprecated, please use "+t+" instead.")},e.detectBrowser=function(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var i=e.navigator;if(i.mozGetUserMedia)t.browser="firefox",t.version=n(i.userAgent,/Firefox\/(\d+)\./,1);else if(i.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection&&!e.RTCIceGatherer)t.browser="chrome",t.version=n(i.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(i.mediaDevices&&i.userAgent.match(/Edge\/(\d+).(\d+)$/))t.browser="edge",t.version=n(i.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!e.RTCPeerConnection||!i.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=n(i.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t},e.compactObject=function e(t){return o(t)?Object.keys(t).reduce((function(i,r){var n=o(t[r]),a=n?e(t[r]):t[r],s=n&&!Object.keys(a).length;return void 0===a||s?i:Object.assign(i,function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}({},r,a))}),{}):t},e.walkStats=a,e.filterStats=function(e,t,i){var r=i?"outbound-rtp":"inbound-rtp",n=new Map;if(null===t)return n;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(i){i.type===r&&i.trackId===t.id&&a(e,i,n)}))})),n};var i=!0,r=!0;function n(e,t,i){var r=e.match(t);return r&&r.length>=i&&parseInt(r[i],10)}function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function a(e,t,i){!t||i.has(t.id)||(i.set(t.id,t),Object.keys(t).forEach((function(r){r.endsWith("Id")?a(e,e.get(t[r]),i):r.endsWith("Ids")&&t[r].forEach((function(t){a(e,e.get(t),i)}))})))}})),xA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.shimGetUserMedia=function(e,r){var n=e&&e.navigator;if(n.mediaDevices){var o=function(e){if("object"!==(void 0===e?"undefined":t(e))||e.mandatory||e.optional)return e;var i={};return Object.keys(e).forEach((function(r){if("require"!==r&&"advanced"!==r&&"mediaSource"!==r){var n="object"===t(e[r])?e[r]:{ideal:e[r]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){i.optional=i.optional||[];var a={};"number"==typeof n.ideal?(a[o("min",r)]=n.ideal,i.optional.push(a),(a={})[o("max",r)]=n.ideal,i.optional.push(a)):(a[o("",r)]=n.ideal,i.optional.push(a))}void 0!==n.exact&&"number"!=typeof n.exact?(i.mandatory=i.mandatory||{},i.mandatory[o("",r)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(i.mandatory=i.mandatory||{},i.mandatory[o(e,r)]=n[e])}))}})),e.advanced&&(i.optional=(i.optional||[]).concat(e.advanced)),i},a=function(e,a){if(r.version>=61)return a(e);if((e=JSON.parse(JSON.stringify(e)))&&"object"===t(e.audio)){var s=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])};s((e=JSON.parse(JSON.stringify(e))).audio,"autoGainControl","googAutoGainControl"),s(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=o(e.audio)}if(e&&"object"===t(e.video)){var c=e.video.facingMode;c=c&&("object"===(void 0===c?"undefined":t(c))?c:{ideal:c});var l=r.version<66;if(c&&("user"===c.exact||"environment"===c.exact||"user"===c.ideal||"environment"===c.ideal)&&(!n.mediaDevices.getSupportedConstraints||!n.mediaDevices.getSupportedConstraints().facingMode||l)){delete e.video.facingMode;var d=void 0;if("environment"===c.exact||"environment"===c.ideal?d=["back","rear"]:("user"===c.exact||"user"===c.ideal)&&(d=["front"]),d)return n.mediaDevices.enumerateDevices().then((function(t){var r=(t=t.filter((function(e){return"videoinput"===e.kind}))).find((function(e){return d.some((function(t){return e.label.toLowerCase().includes(t)}))}));return!r&&t.length&&d.includes("back")&&(r=t[t.length-1]),r&&(e.video.deviceId=c.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=o(e.video),i("chrome: "+JSON.stringify(e)),a(e)}))}e.video=o(e.video)}return i("chrome: "+JSON.stringify(e)),a(e)},s=function(e){return r.version>=64?e:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};if(n.getUserMedia=function(e,t,i){a(e,(function(e){n.webkitGetUserMedia(e,t,(function(e){i&&i(s(e))}))}))}.bind(n),n.mediaDevices.getUserMedia){var c=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(e){return a(e,(function(e){return c(e).then((function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach((function(e){e.stop()})),new DOMException("","NotFoundError");return t}),(function(e){return Promise.reject(s(e))}))}))}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA()).log})),UA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=function(e,t){if((!e.navigator.mediaDevices||!("getDisplayMedia"in e.navigator.mediaDevices))&&e.navigator.mediaDevices){if("function"!=typeof t)return void console.error("shimGetDisplayMedia: getSourceId argument is not a function");e.navigator.mediaDevices.getDisplayMedia=function(i){return t(i).then((function(t){var r=i.video&&i.video.width,n=i.video&&i.video.height,o=i.video&&i.video.frameRate;return i.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},r&&(i.video.mandatory.maxWidth=r),n&&(i.video.mandatory.maxHeight=n),e.navigator.mediaDevices.getUserMedia(i)}))}}}})),VA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=e.shimGetUserMedia=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=xA();Object.defineProperty(e,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var r=UA();Object.defineProperty(e,"shimGetDisplayMedia",{enumerable:!0,get:function(){return r.shimGetDisplayMedia}}),e.shimMediaStream=function(e){e.MediaStream=e.MediaStream||e.webkitMediaStream},e.shimOnTrack=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=e)},enumerable:!0,configurable:!0});var i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var t=this;return this._ontrackpoly||(this._ontrackpoly=function(i){i.stream.addEventListener("addtrack",(function(r){var n=void 0;n=e.RTCPeerConnection.prototype.getReceivers?t.getReceivers().find((function(e){return e.track&&e.track.id===r.track.id})):{track:r.track};var o=new Event("track");o.track=r.track,o.receiver=n,o.transceiver={receiver:n},o.streams=[i.stream],t.dispatchEvent(o)})),i.stream.getTracks().forEach((function(r){var n=void 0;n=e.RTCPeerConnection.prototype.getReceivers?t.getReceivers().find((function(e){return e.track&&e.track.id===r.id})):{track:r};var o=new Event("track");o.track=r,o.receiver=n,o.transceiver={receiver:n},o.streams=[i.stream],t.dispatchEvent(o)}))},this.addEventListener("addstream",this._ontrackpoly)),i.apply(this,arguments)}}else n.wrapPeerConnectionEvent(e,"track",(function(e){return e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e}))},e.shimGetSendersWithDtmf=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var i=function(e,t){return{track:t,get dtmf(){return void 0===this._dtmf&&("audio"===t.kind?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,t){var n=r.apply(this,arguments);return n||(n=i(this,e),this._senders.push(n)),n};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){n.apply(this,arguments);var t=this._senders.indexOf(e);-1!==t&&this._senders.splice(t,1)}}var o=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){t._senders.push(i(t,e))}))};var a=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],a.apply(this,[e]),e.getTracks().forEach((function(e){var i=t._senders.find((function(t){return t.track===e}));i&&t._senders.splice(t._senders.indexOf(i),1)}))}}else if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var s=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=s.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}},e.shimGetStats=function(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,i=Array.prototype.slice.call(arguments),r=i[0],n=i[1],o=i[2];if(arguments.length>0&&"function"==typeof r)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof r))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var i={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){i[t]=e.stat(t)})),t[i.id]=i})),t},s=function(e){return new Map(Object.keys(e).map((function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){n(s(a(e)))};return t.apply(this,[c,r])}return new Promise((function(i,r){t.apply(e,[function(e){i(s(a(e)))},r])})).then(n,o)}}},e.shimSenderReceiverGetStats=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var i=e.RTCPeerConnection.prototype.getSenders;i&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=i.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return n.filterStats(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var o=e.RTCPeerConnection.prototype.getReceivers;o&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=o.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),n.wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){var e=this;return this._pc.getStats().then((function(t){return n.filterStats(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var a=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t=arguments[0],i=void 0,r=void 0,n=void 0;return this.getSenders().forEach((function(e){e.track===t&&(i?n=!0:i=e)})),this.getReceivers().forEach((function(e){return e.track===t&&(r?n=!0:r=e),e.track===t})),n||i&&r?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):i?i.getStats():r?r.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return a.apply(this,arguments)}}}},e.shimAddTrackRemoveTrackWithNative=a,e.shimAddTrackRemoveTrack=function(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return a(e);var i=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=i.apply(this);return this._reverseStreams=this._reverseStreams||{},t.map((function(t){return e._reverseStreams[t.id]}))};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var i=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){if(i.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};var n=e.RTCPeerConnection.prototype.removeStream;function s(e,t){var i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(n.id,"g"),r.id)})),new RTCSessionDescription({type:t.type,sdp:i})}function c(e,t){var i=t.sdp;return Object.keys(e._reverseStreams||[]).forEach((function(t){var r=e._reverseStreams[t],n=e._streams[r.id];i=i.replace(new RegExp(r.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:i})}e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},n.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,i){var r=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var n=[].slice.call(arguments,1);if(1!==n.length||!n[0].getTracks().find((function(e){return e===t})))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");var o=this.getSenders().find((function(e){return e.track===t}));if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var a=this._streams[i.id];if(a)a.addTrack(t),Promise.resolve().then((function(){r.dispatchEvent(new Event("negotiationneeded"))}));else{var s=new e.MediaStream([t]);this._streams[i.id]=s,this._reverseStreams[s.id]=i,this.addStream(s)}return this.getSenders().find((function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var i=e.RTCPeerConnection.prototype[t],r=o({},t,(function(){var e=this,t=arguments,r=arguments.length&&"function"==typeof arguments[0];return r?i.apply(this,[function(i){var r=s(e,i);t[0].apply(null,[r])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):i.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=r[t]}));var l=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),l.apply(this,arguments)):l.apply(this,arguments)};var d=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=d.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};var i=void 0;Object.keys(this._streams).forEach((function(r){t._streams[r].getTracks().find((function(t){return e.track===t}))&&(i=t._streams[r])})),i&&(1===i.getTracks().length?this.removeStream(this._reverseStreams[i.id]):i.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}},e.shimPeerConnection=function(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var i=e.RTCPeerConnection.prototype[t],r=o({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}))},e.fixNegotiationNeeded=function(e,t){n.wrapPeerConnectionEvent(e,"negotiationneeded",(function(e){var i=e.target;if(!(t.version<72||i.getConfiguration&&"plan-b"===i.getConfiguration().sdpSemantics)||"stable"===i.signalingState)return e}))};var n=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA());function o(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map((function(t){return e._shimmedLocalStreams[t][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,i){if(!i)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var r=t.apply(this,arguments);return this._shimmedLocalStreams[i.id]?-1===this._shimmedLocalStreams[i.id].indexOf(r)&&this._shimmedLocalStreams[i.id].push(r):this._shimmedLocalStreams[i.id]=[i,r],r};var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){if(t.getSenders().find((function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var r=this.getSenders();i.apply(this,arguments);var n=this.getSenders().filter((function(e){return-1===r.indexOf(e)}));this._shimmedLocalStreams[e.id]=[e].concat(n)};var r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach((function(i){var r=t._shimmedLocalStreams[i].indexOf(e);-1!==r&&t._shimmedLocalStreams[i].splice(r,1),1===t._shimmedLocalStreams[i].length&&delete t._shimmedLocalStreams[i]})),n.apply(this,arguments)}}})),FA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetUserMedia=function(e){var t=e&&e.navigator,i=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return i(e).catch((function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))}))}}})),jA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=function(e){"getDisplayMedia"in e.navigator&&(!e.navigator.mediaDevices||e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}})),BA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.filterIceServers=function(e,i){var r=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var i=e.urls||e.url;e.url&&!e.urls&&t.deprecated("RTCIceServer.url","RTCIceServer.urls");var n="string"==typeof i;return n&&(i=[i]),i=i.filter((function(e){if(0===e.indexOf("stun:"))return!1;var t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r})),delete e.url,e.urls=n?i[0]:i,!!i.length}}))};var t=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA())})),HA=kA(((e,t)=>{PA(XA());var i={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};i.localCName=i.generateIdentifier(),i.splitLines=function(e){return e.trim().split("\n").map((function(e){return e.trim()}))},i.splitSections=function(e){return e.split("\nm=").map((function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"}))},i.getDescription=function(e){var t=i.splitSections(e);return t&&t[0]},i.getMediaSections=function(e){var t=i.splitSections(e);return t.shift(),t},i.matchPrefix=function(e,t){return i.splitLines(e).filter((function(e){return 0===e.indexOf(t)}))},i.parseCandidate=function(e){for(var t,i={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:parseInt(t[1],10),protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],address:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":i.relatedAddress=t[r+1];break;case"rport":i.relatedPort=parseInt(t[r+1],10);break;case"tcptype":i.tcpType=t[r+1];break;case"ufrag":i.ufrag=t[r+1],i.usernameFragment=t[r+1];break;default:i[t[r]]=t[r+1]}return i},i.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var i=e.type;return t.push("typ"),t.push(i),"host"!==i&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),(e.usernameFragment||e.ufrag)&&(t.push("ufrag"),t.push(e.usernameFragment||e.ufrag)),"candidate:"+t.join(" ")},i.parseIceOptions=function(e){return e.substr(14).split(" ")},i.parseRtpMap=function(e){var t=e.substr(9).split(" "),i={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),i.name=t[0],i.clockRate=parseInt(t[1],10),i.channels=3===t.length?parseInt(t[2],10):1,i.numChannels=i.channels,i},i.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var i=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==i?"/"+i:"")+"\r\n"},i.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},i.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},i.parseFmtp=function(e){for(var t,i={},r=e.substr(e.indexOf(" ")+1).split(";"),n=0;n<r.length;n++)i[(t=r[n].trim().split("="))[0].trim()]=t[1];return i},i.writeFmtp=function(e){var t="",i=e.payloadType;if(void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach((function(t){e.parameters[t]?r.push(t+"="+e.parameters[t]):r.push(t)})),t+="a=fmtp:"+i+" "+r.join(";")+"\r\n"}return t},i.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},i.writeRtcpFb=function(e){var t="",i=e.payloadType;return void 0!==e.preferredPayloadType&&(i=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+i+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},i.parseSsrcMedia=function(e){var t=e.indexOf(" "),i={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(i.attribute=e.substr(t+1,r-t-1),i.value=e.substr(r+1)):i.attribute=e.substr(t+1),i},i.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},i.getMid=function(e){var t=i.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},i.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},i.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:i.matchPrefix(e+t,"a=fingerprint:").map(i.parseFingerprint)}},i.writeDtlsParameters=function(e,t){var i="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){i+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),i},i.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:parseInt(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:t.slice(3)}},i.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"==typeof e.keyParams?i.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},i.parseCryptoKeyParams=function(e){if(0!==e.indexOf("inline:"))return null;var t=e.substr(7).split("|");return{keyMethod:"inline",keySalt:t[0],lifeTime:t[1],mkiValue:t[2]?t[2].split(":")[0]:void 0,mkiLength:t[2]?t[2].split(":")[1]:void 0}},i.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},i.getCryptoParameters=function(e,t){return i.matchPrefix(e+t,"a=crypto:").map(i.parseCryptoLine)},i.getIceParameters=function(e,t){var r=i.matchPrefix(e+t,"a=ice-ufrag:")[0],n=i.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},i.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},i.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=i.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var o=r[n],a=i.matchPrefix(e,"a=rtpmap:"+o+" ")[0];if(a){var s=i.parseRtpMap(a),c=i.matchPrefix(e,"a=fmtp:"+o+" ");switch(s.parameters=c.length?i.parseFmtp(c[0]):{},s.rtcpFeedback=i.matchPrefix(e,"a=rtcp-fb:"+o+" ").map(i.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return i.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(i.parseExtmap(e))})),t},i.writeRtpDescription=function(e,t){var r="";r+="m="+e+" ",r+=t.codecs.length>0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=i.writeRtpMap(e),r+=i.writeFmtp(e),r+=i.writeRtcpFb(e)}));var n=0;return t.codecs.forEach((function(e){e.maxptime>n&&(n=e.maxptime)})),n>0&&(r+="a=maxptime:"+n+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=i.writeExtmap(e)})),r},i.parseRtpEncodingParameters=function(e){var t,r=[],n=i.parseRtpParameters(e),o=-1!==n.fecMechanisms.indexOf("RED"),a=-1!==n.fecMechanisms.indexOf("ULPFEC"),s=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,l=i.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));l.length>0&&l[0].length>1&&l[0][0]===c&&(t=l[0][1]),n.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var i={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(i.rtx={ssrc:t}),r.push(i),o&&((i=JSON.parse(JSON.stringify(i))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(i))}})),0===r.length&&c&&r.push({ssrc:c});var d=i.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},i.parseRtcpParameters=function(e){var t={},r=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var n=i.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=n.length>0,t.compound=0===n.length;var o=i.matchPrefix(e,"a=rtcp-mux");return t.mux=o.length>0,t},i.parseMsid=function(e){var t,r=i.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var n=i.matchPrefix(e,"a=ssrc:").map((function(e){return i.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return n.length>0?{stream:(t=n[0].value.split(" "))[0],track:t[1]}:void 0},i.parseSctpDescription=function(e){var t,r=i.parseMLine(e),n=i.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=parseInt(n[0].substr(19),10)),isNaN(t)&&(t=65536);var o=i.matchPrefix(e,"a=sctp-port:");if(o.length>0)return{port:parseInt(o[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(i.matchPrefix(e,"a=sctpmap:").length>0){var a=i.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},i.writeSctpDescription=function(e,t){var i=[];return i="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&i.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),i.join("")},i.generateSessionId=function(){return Math.random().toString().substr(2,21)},i.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||i.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},i.writeMediaSection=function(e,t,r,n){var o=i.writeRtpDescription(e.kind,t);if(o+=i.writeIceParameters(e.iceGatherer.getLocalParameters()),o+=i.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),o+="a=mid:"+e.mid+"\r\n",e.direction?o+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?o+="a=sendrecv\r\n":e.rtpSender?o+="a=sendonly\r\n":e.rtpReceiver?o+="a=recvonly\r\n":o+="a=inactive\r\n",e.rtpSender){var a="msid:"+n.id+" "+e.rtpSender.track.id+"\r\n";o+="a="+a,o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,o+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return o+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+i.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(o+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+i.localCName+"\r\n"),o},i.getDirection=function(e,t){for(var r=i.splitLines(e),n=0;n<r.length;n++)switch(r[n]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return r[n].substr(2)}return t?i.getDirection(t):"sendrecv"},i.getKind=function(e){return i.splitLines(e)[0].split(" ")[0].substr(2)},i.isRejected=function(e){return"0"===e.split(" ",2)[1]},i.parseMLine=function(e){var t=i.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:parseInt(t[1],10),protocol:t[2],fmt:t.slice(3).join(" ")}},i.parseOLine=function(e){var t=i.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:parseInt(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},i.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=i.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},"object"==typeof t&&(t.exports=i)})),GA=kA(((e,t)=>{PA(XA());var i=HA();function r(e,t,r,n,o){var a=i.writeRtpDescription(e.kind,t);if(a+=i.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=i.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":o||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(n?n.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+i.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+i.localCName+"\r\n"),a}function n(e,t){var i={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var i=0;i<t.length;i++)if(t[i].payloadType===e||t[i].preferredPayloadType===e)return t[i]},n=function(e,t,i,n){var o=r(e.parameters.apt,i),a=r(t.parameters.apt,n);return o&&a&&o.name.toLowerCase()===a.name.toLowerCase()};return e.codecs.forEach((function(r){for(var o=0;o<t.codecs.length;o++){var a=t.codecs[o];if(r.name.toLowerCase()===a.name.toLowerCase()&&r.clockRate===a.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&a.parameters.apt&&!n(r,a,e.codecs,t.codecs))continue;(a=JSON.parse(JSON.stringify(a))).numChannels=Math.min(r.numChannels,a.numChannels),i.codecs.push(a),a.rtcpFeedback=a.rtcpFeedback.filter((function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1}));break}}})),e.headerExtensions.forEach((function(e){for(var r=0;r<t.headerExtensions.length;r++){var n=t.headerExtensions[r];if(e.uri===n.uri){i.headerExtensions.push(n);break}}})),i}function o(e,t,i){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(i)}function a(e,t){var i=e.getRemoteCandidates().find((function(e){return t.foundation===e.foundation&&t.ip===e.ip&&t.port===e.port&&t.priority===e.priority&&t.protocol===e.protocol&&t.type===e.type}));return i||e.addRemoteCandidate(t),!i}function s(e,t){var i=new Error(t);return i.name=e,i.code={NotSupportedError:9,InvalidStateError:11,InvalidAccessError:15,TypeError:void 0,OperationError:void 0}[e],i}t.exports=function(e,t){function c(t,i){i.addTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("addtrack",{track:t}))}function l(t,i,r,n){var o=new Event("track");o.track=i,o.receiver=r,o.transceiver={receiver:r},o.streams=n,e.setTimeout((function(){t._dispatchEvent("track",o)}))}var d=function(r){var n=this,o=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach((function(e){n[e]=o[e].bind(o)})),this.canTrickleIceCandidates=null,this.needNegotiation=!1,this.localStreams=[],this.remoteStreams=[],this._localDescription=null,this._remoteDescription=null,this.signalingState="stable",this.iceConnectionState="new",this.connectionState="new",this.iceGatheringState="new",r=JSON.parse(JSON.stringify(r||{})),this.usingBundle="max-bundle"===r.bundlePolicy,"negotiate"===r.rtcpMuxPolicy)throw s("NotSupportedError","rtcpMuxPolicy 'negotiate' is not supported");switch(r.rtcpMuxPolicy||(r.rtcpMuxPolicy="require"),r.iceTransportPolicy){case"all":case"relay":break;default:r.iceTransportPolicy="all"}switch(r.bundlePolicy){case"balanced":case"max-compat":case"max-bundle":break;default:r.bundlePolicy="balanced"}if(r.iceServers=function(e,t){var i=!1;return(e=JSON.parse(JSON.stringify(e))).filter((function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var n="string"==typeof r;return n&&(r=[r]),r=r.filter((function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||i?0===e.indexOf("stun:")&&t>=14393&&-1===e.indexOf("?transport=udp"):(i=!0,!0)})),delete e.url,e.urls=n?r[0]:r,!!r.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=i.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var i=this.transceivers.length>0,r={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&i)r.iceTransport=this.transceivers[0].iceTransport,r.dtlsTransport=this.transceivers[0].dtlsTransport;else{var n=this._createIceAndDtlsTransports();r.iceTransport=n.iceTransport,r.dtlsTransport=n.dtlsTransport}return t||this.transceivers.push(r),r},d.prototype.addTrack=function(t,i){if(this._isClosed)throw s("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");if(this.transceivers.find((function(e){return e.track===t})))throw s("InvalidAccessError","Track already exists.");for(var r,n=0;n<this.transceivers.length;n++)!this.transceivers[n].track&&this.transceivers[n].kind===t.kind&&(r=this.transceivers[n]);return r||(r=this._createTransceiver(t.kind)),this._maybeFireNegotiationNeeded(),-1===this.localStreams.indexOf(i)&&this.localStreams.push(i),r.track=t,r.stream=i,r.rtpSender=new e.RTCRtpSender(t,r.dtlsTransport),r.rtpSender},d.prototype.addStream=function(e){var i=this;if(t>=15025)e.getTracks().forEach((function(t){i.addTrack(t,e)}));else{var r=e.clone();e.getTracks().forEach((function(e,t){var i=r.getTracks()[t];e.addEventListener("enabled",(function(e){i.enabled=e.enabled}))})),r.getTracks().forEach((function(e){i.addTrack(e,r)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw s("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var i=this.transceivers.find((function(e){return e.rtpSender===t}));if(!i)throw s("InvalidAccessError","Sender was not created by this connection.");var r=i.stream;i.rtpSender.stop(),i.rtpSender=null,i.track=null,i.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(r)&&this.localStreams.indexOf(r)>-1&&this.localStreams.splice(this.localStreams.indexOf(r),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var i=t.getSenders().find((function(t){return t.track===e}));i&&t.removeTrack(i)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,i){var r=this;if(i&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var n=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(n,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var i=!e.candidate||0===Object.keys(e.candidate).length;n.state=i?"completed":"gathering",null!==r.transceivers[t].bufferedCandidateEvents&&r.transceivers[t].bufferedCandidateEvents.push(e)},n.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),n},d.prototype._gather=function(t,r){var n=this,o=this.transceivers[r].iceGatherer;if(!o.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,o.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),o.onlocalcandidate=function(e){if(!(n.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)("new"===o.state||"gathering"===o.state)&&(o.state="completed");else{"new"===o.state&&(o.state="gathering"),s.component=1,s.ufrag=o.getLocalParameters().usernameFragment;var l=i.writeCandidate(s);a.candidate=Object.assign(a.candidate,i.parseCandidate(l)),a.candidate.candidate=l,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var d=i.getMediaSections(n._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",n._localDescription.sdp=i.getDescription(n._localDescription.sdp)+d.join("");var u=n.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==n.iceGatheringState&&(n.iceGatheringState="gathering",n._emitGatheringStateChange()),c||n._dispatchEvent("icecandidate",a),u&&(n._dispatchEvent("icecandidate",new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){o.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,i=new e.RTCIceTransport(null);i.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var r=new e.RTCDtlsTransport(i);return r.ondtlsstatechange=function(){t._updateConnectionState()},r.onerror=function(){Object.defineProperty(r,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:i,dtlsTransport:r}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var i=this.transceivers[e].iceTransport;i&&(delete i.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlsstatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,o){var a=n(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:i.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),o&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,r,a=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(s("TypeError",'Unsupported type "'+e.type+'"'));if(!o("setLocalDescription",e.type,a.signalingState)||a._isClosed)return Promise.reject(s("InvalidStateError","Can not set local "+e.type+" in state "+a.signalingState));if("offer"===e.type)t=i.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=i.parseRtpParameters(e);a.transceivers[t].localCapabilities=r})),a.transceivers.forEach((function(e,t){a._gather(e.mid,t)}));else if("answer"===e.type){t=i.splitSections(a._remoteDescription.sdp),r=t.shift();var c=i.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var o=a.transceivers[t],s=o.iceGatherer,l=o.iceTransport,d=o.dtlsTransport,u=o.localCapabilities,h=o.remoteCapabilities;if(!(i.isRejected(e)&&0===i.matchPrefix(e,"a=bundle-only").length)&&!o.rejected){var p=i.getIceParameters(e,r),m=i.getDtlsParameters(e,r);c&&(m.role="server"),(!a.usingBundle||0===t)&&(a._gather(o.mid,t),"new"===l.state&&l.start(s,p,c?"controlling":"controlled"),"new"===d.state&&d.start(m));var _=n(u,h);a._transceive(o,_.codecs.length>0,!1)}}))}return a._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?a._updateSignalingState("have-local-offer"):a._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(r){var d=this;if(-1===["offer","answer"].indexOf(r.type))return Promise.reject(s("TypeError",'Unsupported type "'+r.type+'"'));if(!o("setRemoteDescription",r.type,d.signalingState)||d._isClosed)return Promise.reject(s("InvalidStateError","Can not set remote "+r.type+" in state "+d.signalingState));var u={};d.remoteStreams.forEach((function(e){u[e.id]=e}));var h=[],p=i.splitSections(r.sdp),m=p.shift(),_=i.matchPrefix(m,"a=ice-lite").length>0,f=i.matchPrefix(m,"a=group:BUNDLE ").length>0;d.usingBundle=f;var g=i.matchPrefix(m,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!g&&g.substr(14).split(" ").indexOf("trickle")>=0,p.forEach((function(o,s){var l=i.splitLines(o),p=i.getKind(o),g=i.isRejected(o)&&0===i.matchPrefix(o,"a=bundle-only").length,v=l[0].substr(2).split(" ")[2],T=i.getDirection(o,m),S=i.parseMsid(o),y=i.getMid(o)||i.generateIdentifier();if(g||"application"===p&&("DTLS/SCTP"===v||"UDP/DTLS/SCTP"===v))d.transceivers[s]={mid:y,kind:p,protocol:v,rejected:!0};else{!g&&d.transceivers[s]&&d.transceivers[s].rejected&&(d.transceivers[s]=d._createTransceiver(p,!0));var E,I,R,A,C,b,k,w,P,D,N,O=i.parseRtpParameters(o);g||(D=i.getIceParameters(o,m),(N=i.getDtlsParameters(o,m)).role="client"),k=i.parseRtpEncodingParameters(o);var M=i.parseRtcpParameters(o),L=i.matchPrefix(o,"a=end-of-candidates",m).length>0,x=i.matchPrefix(o,"a=candidate:").map((function(e){return i.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===r.type||"answer"===r.type)&&!g&&f&&s>0&&d.transceivers[s]&&(d._disposeIceAndDtlsTransports(s),d.transceivers[s].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[s].iceTransport=d.transceivers[0].iceTransport,d.transceivers[s].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[s].rtpSender&&d.transceivers[s].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[s].rtpReceiver&&d.transceivers[s].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==r.type||g){if("answer"===r.type&&!g){I=(E=d.transceivers[s]).iceGatherer,R=E.iceTransport,A=E.dtlsTransport,C=E.rtpReceiver,b=E.sendEncodingParameters,w=E.localCapabilities,d.transceivers[s].recvEncodingParameters=k,d.transceivers[s].remoteCapabilities=O,d.transceivers[s].rtcpParameters=M,x.length&&"new"===R.state&&(!_&&!L||f&&0!==s?x.forEach((function(e){a(E.iceTransport,e)})):R.setRemoteCandidates(x)),(!f||0===s)&&("new"===R.state&&R.start(I,D,"controlling"),"new"===A.state&&A.start(N)),!n(E.localCapabilities,E.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&E.sendEncodingParameters[0].rtx&&delete E.sendEncodingParameters[0].rtx,d._transceive(E,"sendrecv"===T||"recvonly"===T,"sendrecv"===T||"sendonly"===T),!C||"sendrecv"!==T&&"sendonly"!==T?delete E.rtpReceiver:(P=C.track,S?(u[S.stream]||(u[S.stream]=new e.MediaStream),c(P,u[S.stream]),h.push([P,C,u[S.stream]])):(u.default||(u.default=new e.MediaStream),c(P,u.default),h.push([P,C,u.default])))}}else{(E=d.transceivers[s]||d._createTransceiver(p)).mid=y,E.iceGatherer||(E.iceGatherer=d._createIceGatherer(s,f)),x.length&&"new"===E.iceTransport.state&&(!L||f&&0!==s?x.forEach((function(e){a(E.iceTransport,e)})):E.iceTransport.setRemoteCandidates(x)),w=e.RTCRtpReceiver.getCapabilities(p),t<15019&&(w.codecs=w.codecs.filter((function(e){return"rtx"!==e.name}))),b=E.sendEncodingParameters||[{ssrc:1001*(2*s+2)}];var U,V=!1;if("sendrecv"===T||"sendonly"===T){if(V=!E.rtpReceiver,C=E.rtpReceiver||new e.RTCRtpReceiver(E.dtlsTransport,p),V)P=C.track,S&&"-"===S.stream||(S?(u[S.stream]||(u[S.stream]=new e.MediaStream,Object.defineProperty(u[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(P,"id",{get:function(){return S.track}}),U=u[S.stream]):(u.default||(u.default=new e.MediaStream),U=u.default)),U&&(c(P,U),E.associatedRemoteMediaStreams.push(U)),h.push([P,C,U])}else E.rtpReceiver&&E.rtpReceiver.track&&(E.associatedRemoteMediaStreams.forEach((function(t){var i=t.getTracks().find((function(e){return e.id===E.rtpReceiver.track.id}));i&&function(t,i){i.removeTrack(t),i.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(i,t)})),E.associatedRemoteMediaStreams=[]);E.localCapabilities=w,E.remoteCapabilities=O,E.rtpReceiver=C,E.rtcpParameters=M,E.sendEncodingParameters=b,E.recvEncodingParameters=k,d._transceive(d.transceivers[s],!1,V)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===r.type?"active":"passive"),d._remoteDescription={type:r.type,sdp:r.sdp},"offer"===r.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(u).forEach((function(t){var i=u[t];if(i.getTracks().length){if(-1===d.remoteStreams.indexOf(i)){d.remoteStreams.push(i);var r=new Event("addstream");r.stream=i,e.setTimeout((function(){d._dispatchEvent("addstream",r)}))}h.forEach((function(e){var t=e[0],r=e[1];i.id===e[2].id&&l(d,t,r,[i])}))}})),h.forEach((function(e){e[2]||l(d,e[0],e[1],[])})),e.setTimeout((function(){!d||!d.transceivers||d.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"!==this.signalingState||!0===this.needNegotiation||(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var i=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",i)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var i=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",i)}},d.prototype.createOffer=function(){var n=this;if(n._isClosed)return Promise.reject(s("InvalidStateError","Can not call createOffer after close"));var o=n.transceivers.filter((function(e){return"audio"===e.kind})).length,a=n.transceivers.filter((function(e){return"video"===e.kind})).length,c=arguments[0];if(c){if(c.mandatory||c.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==c.offerToReceiveAudio&&(o=!0===c.offerToReceiveAudio?1:!1===c.offerToReceiveAudio?0:c.offerToReceiveAudio),void 0!==c.offerToReceiveVideo&&(a=!0===c.offerToReceiveVideo?1:!1===c.offerToReceiveVideo?0:c.offerToReceiveVideo)}for(n.transceivers.forEach((function(e){"audio"===e.kind?--o<0&&(e.wantReceive=!1):"video"===e.kind&&(--a<0&&(e.wantReceive=!1))}));o>0||a>0;)o>0&&(n._createTransceiver("audio"),o--),a>0&&(n._createTransceiver("video"),a--);var l=i.writeSessionBoilerplate(n._sdpSessionId,n._sdpSessionVersion++);n.transceivers.forEach((function(r,o){var a=r.track,s=r.kind,c=r.mid||i.generateIdentifier();r.mid=c,r.iceGatherer||(r.iceGatherer=n._createIceGatherer(o,n.usingBundle));var l=e.RTCRtpSender.getCapabilities(s);t<15019&&(l.codecs=l.codecs.filter((function(e){return"rtx"!==e.name}))),l.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),r.remoteCapabilities&&r.remoteCapabilities.codecs&&r.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),l.headerExtensions.forEach((function(e){(r.remoteCapabilities&&r.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=r.sendEncodingParameters||[{ssrc:1001*(2*o+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),r.wantReceive&&(r.rtpReceiver=new e.RTCRtpReceiver(r.dtlsTransport,s)),r.localCapabilities=l,r.sendEncodingParameters=d})),"max-compat"!==n._config.bundlePolicy&&(l+="a=group:BUNDLE "+n.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),l+="a=ice-options:trickle\r\n",n.transceivers.forEach((function(e,t){l+=r(e,e.localCapabilities,"offer",e.stream,n._dtlsRole),l+="a=rtcp-rsize\r\n",e.iceGatherer&&"new"!==n.iceGatheringState&&(0===t||!n.usingBundle)&&(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,l+="a="+i.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(l+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:l});return Promise.resolve(d)},d.prototype.createAnswer=function(){var o=this;if(o._isClosed)return Promise.reject(s("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==o.signalingState&&"have-local-pranswer"!==o.signalingState)return Promise.reject(s("InvalidStateError","Can not call createAnswer in signalingState "+o.signalingState));var a=i.writeSessionBoilerplate(o._sdpSessionId,o._sdpSessionVersion++);o.usingBundle&&(a+="a=group:BUNDLE "+o.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var c=i.getMediaSections(o._remoteDescription.sdp).length;o.transceivers.forEach((function(e,i){if(!(i+1>c)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var s;if(e.stream)"audio"===e.kind?s=e.stream.getAudioTracks()[0]:"video"===e.kind&&(s=e.stream.getVideoTracks()[0]),s&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var l=n(e.localCapabilities,e.remoteCapabilities);!l.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=r(e,l,"answer",e.stream,o._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}));var l=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(l)},d.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(n,o){if(!r._remoteDescription)return o(s("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var c=e.sdpMLineIndex;if(e.sdpMid)for(var l=0;l<r.transceivers.length;l++)if(r.transceivers[l].mid===e.sdpMid){c=l;break}var d=r.transceivers[c];if(!d)return o(s("OperationError","Can not add ICE candidate"));if(d.rejected)return n();var u=Object.keys(e.candidate).length>0?i.parseCandidate(e.candidate):{};if("tcp"===u.protocol&&(0===u.port||9===u.port)||u.component&&1!==u.component)return n();if((0===c||c>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!a(d.iceTransport,u))return o(s("OperationError","Can not add ICE candidate"));var h=e.candidate.trim();0===h.indexOf("a=")&&(h=h.substr(2)),(t=i.getMediaSections(r._remoteDescription.sdp))[c]+="a="+(u.type?h:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=i.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var p=0;p<r.transceivers.length&&(r.transceivers[p].rejected||(r.transceivers[p].iceTransport.addRemoteCandidate({}),(t=i.getMediaSections(r._remoteDescription.sdp))[p]+="a=end-of-candidates\r\n",r._remoteDescription.sdp=i.getDescription(r._remoteDescription.sdp)+t.join(""),!r.usingBundle));p++);n()}))},d.prototype.getStats=function(t){if(t&&t instanceof e.MediaStreamTrack){var i=null;if(this.transceivers.forEach((function(e){e.rtpSender&&e.rtpSender.track===t?i=e.rtpSender:e.rtpReceiver&&e.rtpReceiver.track===t&&(i=e.rtpReceiver)})),!i)throw s("InvalidAccessError","Invalid selector.");return i.getStats()}var r=[];return this.transceivers.forEach((function(e){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach((function(t){e[t]&&r.push(e[t].getStats())}))})),Promise.all(r).then((function(e){var t=new Map;return e.forEach((function(e){e.forEach((function(e){t.set(e.id,e)}))})),t}))};["RTCRtpSender","RTCRtpReceiver","RTCIceGatherer","RTCIceTransport","RTCDtlsTransport"].forEach((function(t){var i=e[t];if(i&&i.prototype&&i.prototype.getStats){var r=i.prototype.getStats;i.prototype.getStats=function(){return r.apply(this).then((function(e){var t=new Map;return Object.keys(e).forEach((function(i){e[i].type=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type}(e[i]),t.set(i,e[i])})),t}))}}}));var u=["createOffer","createAnswer"];return u.forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[0]||"function"==typeof e[1]?t.apply(this,[arguments[2]]).then((function(t){"function"==typeof e[0]&&e[0].apply(null,[t])}),(function(t){"function"==typeof e[1]&&e[1].apply(null,[t])})):t.apply(this,arguments)}})),(u=["setLocalDescription","setRemoteDescription","addIceCandidate"]).forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]||"function"==typeof e[2]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)}),(function(t){"function"==typeof e[2]&&e[2].apply(null,[t])})):t.apply(this,arguments)}})),["getStats"].forEach((function(e){var t=d.prototype[e];d.prototype[e]=function(){var e=arguments;return"function"==typeof e[1]?t.apply(this,arguments).then((function(){"function"==typeof e[1]&&e[1].apply(null)})):t.apply(this,arguments)}})),d}})),WA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=e.shimGetUserMedia=void 0;var t=FA();Object.defineProperty(e,"shimGetUserMedia",{enumerable:!0,get:function(){return t.shimGetUserMedia}});var i=jA();Object.defineProperty(e,"shimGetDisplayMedia",{enumerable:!0,get:function(){return i.shimGetDisplayMedia}}),e.shimPeerConnection=function(e,t){if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){var i=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set:function(e){i.set.call(this,e);var t=new Event("enabled");t.enabled=e,this.dispatchEvent(t)}})}e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)&&Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get:function(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);var r=(0,s.default)(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=(0,o.filterIceServers)(e.iceServers,t.version),n.log("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype},e.shimReplaceTrack=function(e){e.RTCRtpSender&&!("replaceTrack"in e.RTCRtpSender.prototype)&&(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)};var r,n=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA()),o=BA(),a=GA(),s=(r=a)&&r.__esModule?r:{default:r}})),JA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.shimGetUserMedia=function(e,r){var n=e&&e.navigator,o=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){i.deprecated("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(e).then(t,r)},!(r.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){var a=function(e,t,i){t in e&&!(i in e)&&(e[i]=e[t],delete e[t])},s=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(e){return"object"===(void 0===e?"undefined":t(e))&&"object"===t(e.audio)&&(e=JSON.parse(JSON.stringify(e)),a(e.audio,"autoGainControl","mozAutoGainControl"),a(e.audio,"noiseSuppression","mozNoiseSuppression")),s(e)},o&&o.prototype.getSettings){var c=o.prototype.getSettings;o.prototype.getSettings=function(){var e=c.apply(this,arguments);return a(e,"mozAutoGainControl","autoGainControl"),a(e,"mozNoiseSuppression","noiseSuppression"),e}}if(o&&o.prototype.applyConstraints){var l=o.prototype.applyConstraints;o.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===(void 0===e?"undefined":t(e))&&(e=JSON.parse(JSON.stringify(e)),a(e,"autoGainControl","mozAutoGainControl"),a(e,"noiseSuppression","mozNoiseSuppression")),l.apply(this,[e])}}}};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA())})),zA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||!e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=function(i){if(!i||!i.video){var r=new DOMException("getDisplayMedia without video constraints is undefined");return r.name="NotFoundError",r.code=8,Promise.reject(r)}return!0===i.video?i.video={mediaSource:t}:i.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(i)})}})),KA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.shimGetDisplayMedia=e.shimGetUserMedia=void 0;var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=JA();Object.defineProperty(e,"shimGetUserMedia",{enumerable:!0,get:function(){return i.shimGetUserMedia}});var r=zA();Object.defineProperty(e,"shimGetDisplayMedia",{enumerable:!0,get:function(){return r.shimGetDisplayMedia}}),e.shimOnTrack=function(e){"object"===(void 0===e?"undefined":t(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},e.shimPeerConnection=function(e,i){if("object"===(void 0===e?"undefined":t(e))&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),i.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var i=e.RTCPeerConnection.prototype[t],r=function(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),i.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=r[t]}));var r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=Array.prototype.slice.call(arguments),t=e[0],o=e[1],a=e[2];return n.apply(this,[t||null]).then((function(e){if(i.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(t){if("TypeError"!==t.name)throw t;e.forEach((function(t,i){e.set(i,Object.assign({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}},e.shimSenderGetStats=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var i=e.RTCPeerConnection.prototype.getSenders;i&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=i.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t});var r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){var e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}},e.shimReceiverGetStats=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var i=e.RTCPeerConnection.prototype.getReceivers;i&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=i.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),n.wrapPeerConnectionEvent(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}},e.shimRemoveStream=function(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;n.deprecated("removeStream","removeTrack"),this.getSenders().forEach((function(i){i.track&&e.getTracks().includes(i.track)&&t.removeTrack(i)}))})},e.shimRTCDataChannel=function(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)},e.shimAddTransceiver=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection){var i=e.RTCPeerConnection.prototype.addTransceiver;i&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1],t=e&&"sendEncodings"in e;t&&e.sendEncodings.forEach((function(e){if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var r=i.apply(this,arguments);if(t){var n=r.sender,o=n.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===Object.keys(o.encodings[0]).length)&&(o.encodings=e.sendEncodings,n.sendEncodings=e.sendEncodings,this.setParametersPromises.push(n.setParameters(o).then((function(){delete n.sendEncodings})).catch((function(){delete n.sendEncodings}))))}return r})}},e.shimGetParameters=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCRtpSender){var i=e.RTCRtpSender.prototype.getParameters;i&&(e.RTCRtpSender.prototype.getParameters=function(){var e=i.apply(this,arguments);return"encodings"in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}},e.shimCreateOffer=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection){var i=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=this,t=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return i.apply(e,t)})).finally((function(){e.setParametersPromises=[]})):i.apply(this,arguments)}}},e.shimCreateAnswer=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection){var i=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=this,t=arguments;return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then((function(){return i.apply(e,t)})).finally((function(){e.setParametersPromises=[]})):i.apply(this,arguments)}}};var n=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA())})),qA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.shimLocalStreamsAPI=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){var i=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var t=this;this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return i.call(t,r,e)})),e.getVideoTracks().forEach((function(r){return i.call(t,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var t=this,r=arguments.length,n=Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return n&&n.forEach((function(e){t._localStreams?t._localStreams.includes(e)||t._localStreams.push(e):t._localStreams=[e]})),i.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._localStreams||(this._localStreams=[]);var i=this._localStreams.indexOf(e);if(-1!==i){this._localStreams.splice(i,1);var r=e.getTracks();this.getSenders().forEach((function(e){r.includes(e.track)&&t.removeTrack(e)}))}})}},e.shimRemoteStreamsAPI=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){var t=this;this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){e.streams.forEach((function(e){if(t._remoteStreams||(t._remoteStreams=[]),!t._remoteStreams.includes(e)){t._remoteStreams.push(e);var i=new Event("addstream");i.stream=e,t.dispatchEvent(i)}}))})}});var i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach((function(t){if(e._remoteStreams||(e._remoteStreams=[]),!(e._remoteStreams.indexOf(t)>=0)){e._remoteStreams.push(t);var i=new Event("addstream");i.stream=t,e.dispatchEvent(i)}}))}),i.apply(e,arguments)}}},e.shimCallbacksAPI=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.RTCPeerConnection){var i=e.RTCPeerConnection.prototype,r=i.createOffer,n=i.createAnswer,o=i.setLocalDescription,a=i.setRemoteDescription,s=i.addIceCandidate;i.createOffer=function(e,t){var i=arguments.length>=2?arguments[2]:arguments[0],n=r.apply(this,[i]);return t?(n.then(e,t),Promise.resolve()):n},i.createAnswer=function(e,t){var i=arguments.length>=2?arguments[2]:arguments[0],r=n.apply(this,[i]);return t?(r.then(e,t),Promise.resolve()):r};var c=function(e,t,i){var r=o.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r};i.setLocalDescription=c,c=function(e,t,i){var r=a.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},i.setRemoteDescription=c,c=function(e,t,i){var r=s.apply(this,[e]);return i?(r.then(t,i),Promise.resolve()):r},i.addIceCandidate=c}},e.shimGetUserMedia=function(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var i=t.mediaDevices,n=i.getUserMedia.bind(i);t.mediaDevices.getUserMedia=function(e){return n(r(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,i,r){t.mediaDevices.getUserMedia(e).then(i,r)}.bind(t))},e.shimConstraints=r,e.shimRTCIceServerUrls=function(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],o=0;o<e.iceServers.length;o++){var a=e.iceServers[o];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(i.deprecated("RTCIceServer.url","RTCIceServer.urls"),(a=JSON.parse(JSON.stringify(a))).urls=a.url,delete a.url,n.push(a)):n.push(e.iceServers[o])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&Object.defineProperty(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}},e.shimTrackEventTransceiver=function(e){"object"===(void 0===e?"undefined":t(e))&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})},e.shimCreateOfferLegacy=function(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=this.getTransceivers().find((function(e){return"audio"===e.receiver.track.kind}));!1===e.offerToReceiveAudio&&i?"sendrecv"===i.direction?i.setDirection?i.setDirection("sendonly"):i.direction="sendonly":"recvonly"===i.direction&&(i.setDirection?i.setDirection("inactive"):i.direction="inactive"):!0===e.offerToReceiveAudio&&!i&&this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var r=this.getTransceivers().find((function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0===e.offerToReceiveVideo&&!r&&this.addTransceiver("video")}return t.apply(this,arguments)}},e.shimAudioContext=function(e){"object"!==(void 0===e?"undefined":t(e))||e.AudioContext||(e.AudioContext=e.webkitAudioContext)};var i=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA());function r(e){return e&&void 0!==e.video?Object.assign({},e,{video:i.compactObject(e.video)}):e}})),QA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0});var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.shimRTCIceCandidate=function(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var i=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"===(void 0===e?"undefined":t(e))&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var r=new i(e),o=n.default.parseCandidate(e.candidate),a=Object.assign(r,o);return a.toJSON=function(){return{candidate:a.candidate,sdpMid:a.sdpMid,sdpMLineIndex:a.sdpMLineIndex,usernameFragment:a.usernameFragment}},a}return new i(e)},e.RTCIceCandidate.prototype=i.prototype,o.wrapPeerConnectionEvent(e,"icecandidate",(function(t){return t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}},e.shimMaxMessageSize=function(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var i=function(e){if(!e||!e.sdp)return!1;var t=n.default.splitSections(e.sdp);return t.shift(),t.some((function(e){var t=n.default.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")}))},r=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var i=parseInt(t[1],10);return i!=i?-1:i},o=function(e){var i=65536;return"firefox"===t.browser&&(i=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),i},a=function(e,i){var r=65536;"firefox"===t.browser&&57===t.version&&(r=65535);var o=n.default.matchPrefix(e.sdp,"a=max-message-size:");return o.length>0?r=parseInt(o[0].substr(19),10):"firefox"===t.browser&&-1!==i&&(r=2147483637),r},s=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),n=e.sdpSemantics;"plan-b"===n&&Object.defineProperty(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(i(arguments[0])){var c=r(arguments[0]),l=o(c),d=a(arguments[0],c),u=void 0;u=0===l&&0===d?Number.POSITIVE_INFINITY:0===l||0===d?Math.max(l,d):Math.min(l,d);var h={};Object.defineProperty(h,"maxMessageSize",{get:function(){return u}}),this._sctp=h}return s.apply(this,arguments)}}},e.shimSendThrowTypeError=function(e){if(!e.RTCPeerConnection||!("createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){var i=e.send;e.send=function(){var r=arguments[0],n=r.length||r.size||r.byteLength;if("open"===e.readyState&&t.sctp&&n>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return i.apply(e,arguments)}}var i=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=i.apply(this,arguments);return t(e,this),e},o.wrapPeerConnectionEvent(e,"datachannel",(function(e){return t(e.channel,e.target),e}))},e.shimConnectionState=function(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get:function(){return this._onconnectionstatechange||null},set:function(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach((function(e){var i=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=function(e){var t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;var i=new Event("connectionstatechange",e);t.dispatchEvent(i)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),i.apply(this,arguments)}}))}},e.removeExtmapAllowMixed=function(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71)&&!("safari"===t.browser&&t.version>=605)){var i=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){if(t&&t.sdp&&-1!==t.sdp.indexOf("\na=extmap-allow-mixed")){var r=t.sdp.split("\n").filter((function(e){return"a=extmap-allow-mixed"!==e.trim()})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:r}):t.sdp=r}return i.apply(this,arguments)}}},e.shimAddIceCandidateNullOrEmpty=function(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var i=e.RTCPeerConnection.prototype.addIceCandidate;!i||0===i.length||(e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?("chrome"===t.browser&&t.version<78||"firefox"===t.browser&&t.version<68||"safari"===t.browser)&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():i.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}};var i,r=HA(),n=(i=r)&&i.__esModule?i:{default:i},o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}(LA())})),YA=kA((e=>{PA(XA()),Object.defineProperty(e,"__esModule",{value:!0}),e.adapterFactory=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=e.window,c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0},l=t.log,d=t.detectBrowser(s),u={browserDetails:d,commonShim:a,extractVersion:t.extractVersion,disableLog:t.disableLog,disableWarnings:t.disableWarnings};switch(d.browser){case"chrome":if(!i||!i.shimPeerConnection||!c.shimChrome)return l("Chrome shim is not included in this adapter release."),u;if(null===d.version)return l("Chrome shim can not determine version, not shimming."),u;l("adapter.js shimming chrome."),u.browserShim=i,a.shimAddIceCandidateNullOrEmpty(s,d),i.shimGetUserMedia(s,d),i.shimMediaStream(s,d),i.shimPeerConnection(s,d),i.shimOnTrack(s,d),i.shimAddTrackRemoveTrack(s,d),i.shimGetSendersWithDtmf(s,d),i.shimGetStats(s,d),i.shimSenderReceiverGetStats(s,d),i.fixNegotiationNeeded(s,d),a.shimRTCIceCandidate(s,d),a.shimConnectionState(s,d),a.shimMaxMessageSize(s,d),a.shimSendThrowTypeError(s,d),a.removeExtmapAllowMixed(s,d);break;case"firefox":if(!n||!n.shimPeerConnection||!c.shimFirefox)return l("Firefox shim is not included in this adapter release."),u;l("adapter.js shimming firefox."),u.browserShim=n,a.shimAddIceCandidateNullOrEmpty(s,d),n.shimGetUserMedia(s,d),n.shimPeerConnection(s,d),n.shimOnTrack(s,d),n.shimRemoveStream(s,d),n.shimSenderGetStats(s,d),n.shimReceiverGetStats(s,d),n.shimRTCDataChannel(s,d),n.shimAddTransceiver(s,d),n.shimGetParameters(s,d),n.shimCreateOffer(s,d),n.shimCreateAnswer(s,d),a.shimRTCIceCandidate(s,d),a.shimConnectionState(s,d),a.shimMaxMessageSize(s,d),a.shimSendThrowTypeError(s,d);break;case"edge":if(!r||!r.shimPeerConnection||!c.shimEdge)return l("MS edge shim is not included in this adapter release."),u;l("adapter.js shimming edge."),u.browserShim=r,r.shimGetUserMedia(s,d),r.shimGetDisplayMedia(s,d),r.shimPeerConnection(s,d),r.shimReplaceTrack(s,d),a.shimMaxMessageSize(s,d),a.shimSendThrowTypeError(s,d);break;case"safari":if(!o||!c.shimSafari)return l("Safari shim is not included in this adapter release."),u;l("adapter.js shimming safari."),u.browserShim=o,a.shimAddIceCandidateNullOrEmpty(s,d),o.shimRTCIceServerUrls(s,d),o.shimCreateOfferLegacy(s,d),o.shimCallbacksAPI(s,d),o.shimLocalStreamsAPI(s,d),o.shimRemoteStreamsAPI(s,d),o.shimTrackEventTransceiver(s,d),o.shimGetUserMedia(s,d),o.shimAudioContext(s,d),a.shimRTCIceCandidate(s,d),a.shimMaxMessageSize(s,d),a.shimSendThrowTypeError(s,d),a.removeExtmapAllowMixed(s,d);break;default:l("Unsupported browser!")}return u};var t=s(LA()),i=s(VA()),r=s(WA()),n=s(KA()),o=s(qA()),a=s(QA());function s(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}})),XA=kA((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=(0,YA().adapterFactory)({window:"undefined"==typeof window?void 0:window});e.default=t})),$A=kA(((e,t)=>{PA(XA());var i=Object.prototype.hasOwnProperty,r="~";function n(){}function o(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new o(i,n||e,a),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)i.call(e,t)&&n.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,o=i.length,a=new Array(o);n<o;n++)a[n]=i[n].fn;return a},c.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,n,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,l,d=this._events[s],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,n),!0;case 5:return d.fn.call(d.context,t,i,n,o),!0;case 6:return d.fn.call(d.context,t,i,n,o,a),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,n);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,n){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn===t&&(!n||a.once)&&(!i||a.context===i)&&s(this,o);else{for(var c=0,l=[],d=a.length;c<d;c++)(a[c].fn!==t||n&&!a[c].once||i&&a[c].context!==i)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l:s(this,o)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),ZA=kA(((e,t)=>{PA(XA());var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),eC=kA((e=>{PA(XA());var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var n=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:n&&!i[e.name]&&(i[e.name]={});var o=e.push?{}:n?i[e.name]:i;(function(e,i,r,n){if(n&&!r)i[n]=t(e[1]);else for(var o=0;o<r.length;o+=1)null!=e[o+1]&&(i[r[o]]=t(e[o+1]))})(r.match(e.reg),o,e.names,e.name),e.push&&i[e.push].push(o)},r=ZA(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},o=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach((function(e){var t=e[0],n=e.slice(2);"m"===t&&(o.push({rtp:[],fmtp:[]}),a=o[o.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(n))return i(c,a,n)}})),t.media=o,t};var o=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),n=0;n<r.length;n+=3)i.push({component:r[n],ip:r[n+1],port:r[n+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(o,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),tC=kA(((e,t)=>{PA(XA());var i=ZA(),r=/%[sdv%]/g,n=function(e){var t=1,i=arguments,n=i.length;return e.replace(r,(function(e){if(t>=n)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},o=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var o=0;o<t.names.length;o+=1){var a=t.names[o];t.name?r.push(i[t.name][a]):r.push(i[t.names[o]])}else r.push(i[t.name]);return n.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,n=t.innerOrder||s,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))})),e.media.forEach((function(e){c.push(o("m",i.m[0],e)),n.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(o(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(o(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),iC=kA((e=>{PA(XA());var t=eC(),i=tC();e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),rC=kA(((e,t)=>{PA(XA()),function(e){function i(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i}function r(e,t,r,n,o,a){return i(function(e,t){return e<<t|e>>>32-t}(i(i(t,e),i(n,a)),o),r)}function n(e,t,i,n,o,a,s){return r(t&i|~t&n,e,t,o,a,s)}function o(e,t,i,n,o,a,s){return r(t&n|i&~n,e,t,o,a,s)}function a(e,t,i,n,o,a,s){return r(t^i^n,e,t,o,a,s)}function s(e,t,i,n,o,a,s){return r(i^(t|~n),e,t,o,a,s)}function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var r,c,l,d,u,h=1732584193,p=-271733879,m=-1732584194,_=271733878;for(r=0;r<e.length;r+=16)c=h,l=p,d=m,u=_,h=n(h,p,m,_,e[r],7,-680876936),_=n(_,h,p,m,e[r+1],12,-389564586),m=n(m,_,h,p,e[r+2],17,606105819),p=n(p,m,_,h,e[r+3],22,-1044525330),h=n(h,p,m,_,e[r+4],7,-176418897),_=n(_,h,p,m,e[r+5],12,1200080426),m=n(m,_,h,p,e[r+6],17,-1473231341),p=n(p,m,_,h,e[r+7],22,-45705983),h=n(h,p,m,_,e[r+8],7,1770035416),_=n(_,h,p,m,e[r+9],12,-1958414417),m=n(m,_,h,p,e[r+10],17,-42063),p=n(p,m,_,h,e[r+11],22,-1990404162),h=n(h,p,m,_,e[r+12],7,1804603682),_=n(_,h,p,m,e[r+13],12,-40341101),m=n(m,_,h,p,e[r+14],17,-1502002290),h=o(h,p=n(p,m,_,h,e[r+15],22,1236535329),m,_,e[r+1],5,-165796510),_=o(_,h,p,m,e[r+6],9,-1069501632),m=o(m,_,h,p,e[r+11],14,643717713),p=o(p,m,_,h,e[r],20,-373897302),h=o(h,p,m,_,e[r+5],5,-701558691),_=o(_,h,p,m,e[r+10],9,38016083),m=o(m,_,h,p,e[r+15],14,-660478335),p=o(p,m,_,h,e[r+4],20,-405537848),h=o(h,p,m,_,e[r+9],5,568446438),_=o(_,h,p,m,e[r+14],9,-1019803690),m=o(m,_,h,p,e[r+3],14,-187363961),p=o(p,m,_,h,e[r+8],20,1163531501),h=o(h,p,m,_,e[r+13],5,-1444681467),_=o(_,h,p,m,e[r+2],9,-51403784),m=o(m,_,h,p,e[r+7],14,1735328473),h=a(h,p=o(p,m,_,h,e[r+12],20,-1926607734),m,_,e[r+5],4,-378558),_=a(_,h,p,m,e[r+8],11,-2022574463),m=a(m,_,h,p,e[r+11],16,1839030562),p=a(p,m,_,h,e[r+14],23,-35309556),h=a(h,p,m,_,e[r+1],4,-1530992060),_=a(_,h,p,m,e[r+4],11,1272893353),m=a(m,_,h,p,e[r+7],16,-155497632),p=a(p,m,_,h,e[r+10],23,-1094730640),h=a(h,p,m,_,e[r+13],4,681279174),_=a(_,h,p,m,e[r],11,-358537222),m=a(m,_,h,p,e[r+3],16,-722521979),p=a(p,m,_,h,e[r+6],23,76029189),h=a(h,p,m,_,e[r+9],4,-640364487),_=a(_,h,p,m,e[r+12],11,-421815835),m=a(m,_,h,p,e[r+15],16,530742520),h=s(h,p=a(p,m,_,h,e[r+2],23,-995338651),m,_,e[r],6,-198630844),_=s(_,h,p,m,e[r+7],10,1126891415),m=s(m,_,h,p,e[r+14],15,-1416354905),p=s(p,m,_,h,e[r+5],21,-57434055),h=s(h,p,m,_,e[r+12],6,1700485571),_=s(_,h,p,m,e[r+3],10,-1894986606),m=s(m,_,h,p,e[r+10],15,-1051523),p=s(p,m,_,h,e[r+1],21,-2054922799),h=s(h,p,m,_,e[r+8],6,1873313359),_=s(_,h,p,m,e[r+15],10,-30611744),m=s(m,_,h,p,e[r+6],15,-1560198380),p=s(p,m,_,h,e[r+13],21,1309151649),h=s(h,p,m,_,e[r+4],6,-145523070),_=s(_,h,p,m,e[r+11],10,-1120210379),m=s(m,_,h,p,e[r+2],15,718787259),p=s(p,m,_,h,e[r+9],21,-343485551),h=i(h,c),p=i(p,l),m=i(m,d),_=i(_,u);return[h,p,m,_]}function l(e){var t,i="",r=32*e.length;for(t=0;t<r;t+=8)i+=String.fromCharCode(e[t>>5]>>>t%32&255);return i}function d(e){var t,i=[];for(i[(e.length>>2)-1]=void 0,t=0;t<i.length;t+=1)i[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)i[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return i}function u(e){var t,i,r="0123456789abcdef",n="";for(i=0;i<e.length;i+=1)t=e.charCodeAt(i),n+=r.charAt(t>>>4&15)+r.charAt(15&t);return n}function h(e){return unescape(encodeURIComponent(e))}function p(e){return function(e){return l(c(d(e),8*e.length))}(h(e))}function m(e,t){return function(e,t){var i,r,n=d(e),o=[],a=[];for(o[15]=a[15]=void 0,n.length>16&&(n=c(n,8*e.length)),i=0;i<16;i+=1)o[i]=909522486^n[i],a[i]=1549556828^n[i];return r=c(o.concat(d(t)),512+8*t.length),l(c(a.concat(r),640))}(h(e),h(t))}function _(e,t,i){return t?i?m(t,e):function(e,t){return u(m(e,t))}(t,e):i?p(e):function(e){return u(p(e))}(e)}"function"==typeof define&&define.amd?define((function(){return _})):"object"==typeof t&&t.exports?t.exports=_:e.md5=_}(e)}));PA(XA()),PA(XA()),PA(XA(),1),PA(XA(),1);var nC="4.15.00.1600",oC="5.0.0";var aC,sC="undefined"!=typeof importScripts,cC="undefined"!=typeof registerProcessor,lC="",dC="web.sdk.qcloud.com",uC="web.sdk.tencent.cn",hC="web.sdk.cloud.tencent.cn",pC="https://console.cloud.tencent.com/trtc",mC="https://".concat(dC,"/trtc/webrtc/doc"),_C="".concat(mC,"/zh-cn/"),fC="jssdk_log",gC="jssdk_new_endreport",vC="qcloud",TC="trtc",SC="webrtc",yC=((aC=yC||{})[aC.TRACE=0]="TRACE",aC[aC.DEBUG=1]="DEBUG",aC[aC.INFO=2]="INFO",aC[aC.WARN=3]="WARN",aC[aC.ERROR=4]="ERROR",aC[aC.NONE=5]="NONE",aC),EC={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5},IC={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:192},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},RC={"120p":{width:160,height:120,frameRate:15,bitrate:200},"180p":{width:320,height:180,frameRate:15,bitrate:350},"240p":{width:320,height:240,frameRate:15,bitrate:400},"360p":{width:640,height:360,frameRate:15,bitrate:800},"480p":{width:640,height:480,frameRate:15,bitrate:900},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},AC={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},CC="canvas",bC="audio",kC="video",wC="screen",PC="small",DC="big",NC="auxiliary",OC="smallVideo",MC="user",LC="environment",xC="mute",UC="unmute",VC="ended",FC="playing",jC="pause",BC="error",HC="loadeddata",GC="audioinput",WC="videoinput",JC="main",zC="backup",KC="subscribe",qC="unsubscribe",QC="inactive",YC="sendonly",XC="recvonly",$C="wss://trtc.rtc.qq.com",ZC="wss://webrtc.qq.com",eb="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",tb=JC,ib=NC,rb="unknown",nb="new",ob="connecting",ab="failed",sb="closed",cb="disconnected",lb="connected",db="completed",ub=1/0;function hb(){return ub}var pb="rejoin",mb="iceConnectionState",_b="load-worklet",fb="unified-plan",gb="plan-b",vb={MANUAL:"manual",PRESET_LAYOUT:"preset-layout"},Tb={REMOTE:"$PLACE_HOLDER_REMOTE$"},Sb={IT_AUDIO_VIDEO:0,IT_PICTURE:2,IT_CANVAS:3,IT_PURE_AUDIO:4,IT_PURE_VIDEO:5},yb="string",Eb="number",Ib="boolean",Rb="array",Ab="object",Cb="schedule.rtc.qq.com",bb="schedule.rtc.qcloud.com",kb="schedule.rtc.tencentcloud.com",wb="schedule-ecdn.rtc.tencentcloud.com",Pb="default",Db=Pb,Nb=["normal leave","timeout leave","kick","role change"],Ob=2e3,Mb="ric",Lb="raf",xb="timeout";PA(XA(),1),PA(XA(),1);(new Date).getTime();var Ub=0,Vb=function(){return(new Date).getTime()+Ub},Fb=function(){let e=new Date;return e.setTime(Vb()),e.toLocaleString()},jb={};wA(jb,{bytes2ms:()=>tP,catchEmitterError:()=>kP,copyProperties:()=>eP,deepMerge:()=>VP,fibonacci:()=>cP,formatedTime:()=>BP,getAudioContext:()=>RP,getConstructorName:()=>EP,getContainerFromElement:()=>FP,getEnv:()=>zw,getGainAudioContext:()=>AP,getInternalVersion:()=>PP,getLoggerUrl:()=>qw,getMuteStateFromFlag:()=>OP,getNetworkQuality:()=>MP,getNetworkType:()=>Xw,getOSType:()=>Yw,getReconnectionTimeout:()=>lP,getSysInfo:()=>$w,getTerminalType:()=>Qw,getTurnServer:()=>LP,getValueType:()=>dP,glog:()=>oP,ipv4ToUint32:()=>xP,isArray:()=>gP,isArrayOrObject:()=>UP,isAudioWorkletSupported:()=>IP,isBoolean:()=>_P,isConstructor:()=>yP,isEmpty:()=>NP,isFunction:()=>uP,isLangChinese:()=>aP,isMediaStreamTrack:()=>vP,isNumber:()=>mP,isObject:()=>fP,isOverseaSdkAppId:()=>Kw,isPlainObject:()=>sP,isPromise:()=>SP,isRemoteTrack:()=>TP,isString:()=>pP,isUndefined:()=>hP,ms2bytes:()=>rP,ms2samples:()=>nP,performanceNow:()=>bP,promiseAny:()=>CP,samples2ms:()=>iP,tryCatchFunction:()=>Zw}),PA(XA(),1),PA(XA(),1);var Bb="undefined"!=typeof navigator?null==navigator?void 0:navigator.userAgent:"",Hb=e=>new RegExp(e,"i").test(Bb),Gb=e=>{if(Hb(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=Bb.match(t);if(i&&i[1])return i[1]}return""},Wb=e=>{if(Hb(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=Bb.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},Jb=/AppleWebKit\/([\d.]+)/i.exec(Bb);Jb&&parseFloat(Jb[1]);var zb=Hb("iPad"),Kb="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&Hb("Macintosh"),qb=Hb("iPhone")&&!zb,Qb=Hb("iPod"),Yb=qb||zb||Qb||Kb,Xb=Hb("Android");!function(){if(Xb){let e=Bb.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}}();Xb&&Hb("webkit");var $b=Hb("Firefox"),Zb=Gb("Firefox"),ek=Wb("Firefox"),tk=Hb("Edge"),ik=Gb("Edge"),rk=Hb("Edg"),nk=Gb("Edg"),ok=Wb("Edg"),ak=Hb("SogouMobileBrowser"),sk=Gb("SogouMobileBrowser"),ck=Hb("MetaSr\\s"),lk=Gb("MetaSr\\s"),dk=Hb("TBS"),uk=Gb("TBS"),hk=Hb("XWEB"),pk=Gb("XWEB");Hb("MSIE\\s8\\.0");var mk=Hb("MSIE\\/\\d+");!function(){if(mk){let e=/MSIE\s(\d+)\.\d/.exec(Bb),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(Bb)&&/rv:11.0/.test(Bb)&&(t=11),t}}();var _k=Hb("(micromessenger|webbrowser)"),fk=Gb("MicroMessenger"),gk=!dk&&Hb("MQQBrowser")&&Hb("COVC"),vk=!dk&&Hb("MQQBrowser")&&!Hb("COVC"),Tk=vk||gk?Gb("MQQBrowser"):"",Sk=!dk&&Hb(" QQBrowser"),yk=Gb(" QQBrowser"),Ek=!dk&&Hb("QQBrowserLite"),Ik=Gb("QQBrowserLite"),Rk=!dk&&Hb("MQBHD"),Ak=Gb("MQBHD"),Ck=Hb("Windows"),bk=!Yb&&Hb("MAC OS X"),kk=!Xb&&Hb("Linux");Hb("MicroMessenger");var wk=Hb("UCBrowser");Hb("Electron");var Pk=Hb("MiuiBrowser"),Dk=Gb("MiuiBrowser"),Nk=Hb("HuaweiBrowser");Hb("Huawei");var Ok=Gb("HuaweiBrowser"),Mk=Hb("SamsungBrowser"),Lk=Gb("SamsungBrowser"),xk=Hb("HeyTapBrowser"),Uk=Gb("HeyTapBrowser"),Vk=Hb("VivoBrowser"),Fk=Gb("VivoBrowser"),jk=()=>Wb("Chrome"),Bk=Hb("Chrome"),Hk=!tk&&!ck&&!ak&&!dk&&!hk&&!rk&&!Sk&&!Pk&&!Nk&&!Mk&&!xk&&!Vk&&Bk,Gk=jk(),Wk=Gb("Chrome"),Jk=!Bk&&!vk&&!gk&&!Ek&&!Rk&&Hb("Safari"),zk=Gb("Safari");/Android.*(wv|.0.0.0)/.test(Bb);var Kk=(()=>{if(Kb)return zk;if(Yb){let e=Bb.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})(),qk="15.1"===zk,Qk="15.1"===Kk;(()=>{let e=Number(Kk.split(".")[0])})();var Yk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Xk=(()=>{let e;return()=>{if(hP(e))try{e=!!window.localStorage}catch(HO){QP.warn(HO),e=!1}return e}})(),$k=function(){let e=new Map([[$b,["Firefox",Zb]],[rk,["Edg",nk]],[Hk,["Chrome",Wk]],[Jk,["Safari",zk]],[dk,["TBS",uk]],[hk,["XWEB",pk]],[_k&&qb,["WeChat",fk]],[Sk,["QQ(Win)",yk]],[vk,["QQ(Mobile)",Tk]],[gk,["QQ(Mobile X5)",Tk]],[Ek,["QQ(Mac)",Ik]],[Rk,["QQ(iPad)",Ak]],[Pk,["MI",Dk]],[Nk,["HW",Ok]],[Mk,["Samsung",Lk]],[xk,["OPPO",Uk]],[Vk,["VIVO",Fk]],[tk,["EDGE",ik]],[ak,["SogouMobile",sk]],[ck,["Sogou",lk]]]),t="unknown",i="unknown";return e.has(!0)&&([t,i]=e.get(!0)),{name:t,version:i}}();PA(XA(),1),PA(XA(),1),PA(XA(),1);var Zk=1e8,ew="API_CALL_TIMEOUT",tw="SIGNAL_CHANNEL_RECONNECTION_FAILED",iw="SIGNAL_CHANNEL_SETUP_FAILED",rw="ERROR_MESSAGE",nw="DOWNLINK_RECONNECTION_FAILED",ow="EXCHANGE_SDP_FAILED",aw="UPLINK_RECONNECTION_FAILED",sw="INVALID_PURE_AUDIO",cw="INVALID_STREAMID",lw="INVALID_USER_DEFINE_RECORDID",dw="INVALID_USER_DEFINE_PUSH_ARGS",uw="INVALID_JOIN",hw="JOIN_ROOM_TIMEOUT",pw="JOIN_ROOM_FAILED",mw="REJOIN_ROOM_FAILED",_w="INVALID_DESTROY",fw="SUBSCRIBE_FAILED",gw="SWITCH_ROLE_TIMEOUT",vw="SWITCH_ROLE_FAILED",Tw="INVALID_OPERATION_START_PUBLISH_CDN",Sw="INVALID_OPERATION_STOP_PUBLISH_CDN",yw="START_PUBLISH_CDN_FAILED",Ew="STOP_PUBLISH_CDN_FAILED",Iw="REPEAT_JOIN",Rw="CLIENT_DESTROYED",Aw="START_MIX_TRANSCODE_FAILED",Cw="STOP_MIX_TRANSCODE_FAILED",bw="MIX_TRANSCODE_NOT_STARTED",kw="PLAY_FAILED",ww="NOT_SUPPORTED_HTTP",Pw="NOT_SUPPORTED_WEBRTC",Dw="NOT_SUPPORTED_H264ENCODE",Nw="NOT_SUPPORTED_H264DECODE",Ow="MICROPHONE_NOT_FOUND",Mw="CAMERA_NOT_FOUND",Lw="SIGNAL_RESPONSE_FAILED",xw="CATCH_HANDLER_ERROR",Uw="CONNECTION_CLOSED",Vw="CONNECTION_ABORTED",Fw="API_CALL_ABORTED",jw={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="";return a=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(dP(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(dP(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,fnName:r,value:n}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(n,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:i}=e;return"Failed to join room - ".concat(t," code: ").concat(i)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:"no permission to publish() under live/".concat("audience",', please call switchRole("',"anchor",'") firstly before publish().'),INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:i,streamType:r}=e;return"failed to subscribe ".concat(i," ").concat(r," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as ".concat("anchor"," or ","audience","."),INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},PLAY_FAILED:e=>"".concat(e.media," play failed,browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone and the configuration on TRTC.createStream.",CAMERA_NOT_FOUND:"no camera detected, please check your camera and the configuration on TRTC.createStream.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:i}=e;return"an error was caught on ".concat(t,".on('").concat(i,"', handler), please check your code on 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"[".concat(e,"] is calling client.join api or has already joined room, please avoid repeated join."),CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled, to enable SEI: TRTC.createClient({ enableSEI: true })",SEI_EMPTY:"buffer cannot be empty",SEI_OVERSIZE:e=>"buffer size(".concat(e,") is over 1000 Bytes"),SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:i,timesInSecond:r,maxSizeInSecond:n}=e;return"api ".concat(i," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(n," bytes"):r," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")};function Bw(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}PA(XA());var Hw={AVOID_REPEATED_CALL:e=>"前一个 ".concat(e.name,"() 调用正在进行中, 请避免重复调用。"),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"调用 ".concat(r,"() 方法的时候 '").concat(t||i.name,"' 是必须的参数, 收到的值为: ").concat(n,"。")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="";return a=Array.isArray(i.type)?i.type.join("|"):i.type,"调用 ".concat(r,"() 方法的时候 '").concat(o,"' 必须是 ").concat(a," 类型, 收到的类型是: ").concat(Bw(n),"。")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"调用 ".concat(r,"() 的时候 '").concat(t||i.name,"' 不能是 '").concat(n,"'。")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="".concat(i.instanceOf.name||i.instanceOf);return"调用 ".concat(r,"() 的时候 '").concat(o,"' 原型必须是 ").concat(a," , 收到的是: ").concat(Bw(n),"。")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"调用 ".concat(r,"() 的时候 '").concat(t||i.name,"' 必须是 ").concat(i.values.join("|")," 的其中一种, 收到的是: ").concat(n,"。")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," 超时。"),SIGNAL_CHANNEL_RECONNECTION_FAILED:"信令通道重连失败,请检查你的网络。",SIGNAL_CHANNEL_SETUP_FAILED:e=>"信令通道建立失败: (错误码: ".concat(e.errorCode,", 错误信息: ").concat(e.errorMsg," })。"),ERROR_MESSAGE(e){let t="".concat(e.type," 失败。");return e.message&&(t="".concat(t,": ").concat(e.message,"。")),t},SUBSCRIPTION_TIMEOUT:"远程服务器不响应订阅行为。",EXCHANGE_SDP_TIMEOUT:"交换 sdp 超时,请刷新网络重试。",DOWNLINK_RECONNECTION_FAILED:"下行重连失败,请检查您的网络并重新加入房间。",EXCHANGE_SDP_FAILED:e=>"交换 SDP 失败,原因 ".concat(e.errMsg,"。"),REPLACE_TRACK_INVALID:"LocalStream 发布之后才可以调用 replaceTrack。",UPDATE_OFFER_TIMEOUT:"更新 offer 超时,请刷新网络重试。",UPLINK_RECONNECTION_FAILED:"上行重连失败,请检查您的网络并重新推流。",INVALID_RECORDID:"recordId 必须是数字。",INVALID_PURE_AUDIO:"pureAudioPushMode 必须是数字1或2。",INVALID_STREAMID:"streamId 必须是 64 字节以内的字符串,并且不能为空。",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId 必须是包含 (a-zA-Z)、(0-9)、下划线和连字符的字符串字面量,64 个字节以内,且不为空。",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs 必须是 256 字节以内的字符串文字,并且不能为空。",INVALID_PROXY:"代理服务器 url 必须以“wss://”开头。",INVALID_JOIN:"join() 方法不能被重复调用。",INVALID_ROOMID_STRING:e=>"当 useStringRoomId 为 true 时,'".concat(e,"' 必须是合法字符串。"),INVALID_ROOMID_INTEGER:e=>"当 useStringRoomId 为 false 时,'".concat(e,"' 必须是合法整数在区间[1, 4294967294]。"),INVALID_SIGNAL_CHANNEL:"SignalChannel 还未初始化好。",JOIN_ROOM_TIMEOUT:"进房超时。",JOIN_ROOM_FAILED:e=>"进房失败,原因:".concat(e.error,"。"),REJOIN_ROOM_FAILED:e=>"重进房: ".concat(e.roomId," 失败,请检查网络状况。"),INVALID_LEAVE:"请在调用 destroy() 方法之前调用 leave()。",INVALID_PUBLISH:"请在调用 publish() 方法之前调用 join()。",INVALID_UNPUBLISH:"还没有被 publish。",INVALID_AUDIENCE:"在观众模式下不允许调用 publish(),请先切换成主播模式。",INVALID_INITIALIZE:"无法发布 stream,原因:localStream 未初始化、正在切换设备、已经调用 localStream.close() 关闭采集",INVALID_DUPLICATE_PUBLISHING:"重复发布,请先 unpublish 之后,再重新 publish。",INVALID_SUBSCRIBE_UNDEFINED:"stream 参数是 undefined 或者 null。",INVALID_SUBSCRIBE_LOCAL:"stream 参数不能为本地流。",INVALID_REMOTE_STREAM:"remoteStream 不存在,已被远端 client 取消发布。",SUBSCRIBE_FAILED(e){let t="订阅流失败,原因: ";return e.message.includes("REMOTE_STREAM_NOT_EXIST")?t+="远端用户已取消推流,无法订阅该远端流。":t+="".concat(e.message,"。"),t},INVALID_ROLE:"只有直播模式才可以进行角色切换。",INVALID_PARAMETER_SWITCH_ROLE:"role 只能设置为 anchor 或者 audience。",INVALID_OPERATION_SWITCH_ROLE:"请在使用 switchRole() 方法前先进房。",SWITCH_ROLE_TIMEOUT:"切换角色超时。",SWITCH_ROLE_FAILED:e=>"切换角色失败。错误码: ".concat(e.code," 错误信息: ").concat(e.message,"。"),CLIENT_BANNED:e=>"您被动退房了,原因为:".concat(e.reason,"。"),INVALID_OPERATION_START_PUBLISH_CDN:"请在进房前或者进房并成功发布本地流后调用 startPublishCDNStream() 方法。",INVALID_OPERATION_STOP_PUBLISH_CDN:"在调用 stopPublishCDNStream() 方法前需要先 startPublishCDNStream()。",INVALID_STREAM_ID:e=>"'".concat(e,"' 只能由大小写字母(a-zA-z), 数字(0-9), 连字符和下划线组成"),START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream 调用失败,错误信息: ".concat(e.message,"。"),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream 调用失败,错误信息: ".concat(e.message,"。"),START_MIX_TRANSCODE:"调用 startMixTranscode() 方法前需要先调用 join()。",STOP_MIX_TRANSCODE:"调用 stopMixTranscode 之前需要调用 startMixTranscode。",INVALID_AUDIO_VOLUME:"interval 必须是数字。",ENABLE_SMALL_STREAM_PUBLISHED:"发布 localStream 之后不允许开启小流。",DISABLE_SMALL_STREAM_PUBLISHED:"发布 localStream 之后不允许关闭小流。",NOT_SUPPORTED_SMALL_STREAM:"您的浏览器不支持开启小流。",INVALID_SMALL_STREAM_PROFILE:"小流参数不合法。",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream 不合法。",REMOTE_NOT_PUBLISH_SMALL_STREAM:"远端用户没有发布小流。",INVALID_SWITCH_DEVICE:"当前的流不可以调用 switchDevice。",INVALID_SWITCH_DEVICE_PUBLISHING:"发布本地流时不能切换设备。",INVALID_REPLACE_TRACK:"client.publish 接口尚未调用完成,请等其调用完成后再调用 replaceTrack 接口。",INVALID_INITIALIZE_LOCAL_STREAM:"本地流还没有初始化。",INVALID_ADD_TRACK_REPETITIVE:"前一个 addTrack 正在进行,请避免重复调用。",INVALID_ADD_TRACK_REMOVING:"track 在移动的时候不能添加新的 track。",INVALID_ADD_TRACK_PUBLISHING:"在发布本地流的时候不能添加新的 track。",INVALID_STREAM_INITIALIZED:"您的本地流还没有初始化。",INVALID_ADD_TRACK_NUMBER:"一条流最多有一个音频轨道和一个视频轨道。",INVALID_REMOVE_AUDIO_TRACK:"remove audio track 是不允许的。",INVALID_REMOVE_AUDIO_ADDING:"当一个 track 被 addTrack 的时候不能对流进行 removeTrack 操作。",INVALID_REMOVE_AUDIO_ON:"前一次调用的 removeTrack 正在进行中,请避免重复操作。",INVALID_REMOVE_TRACK_PUBLISHING:"发布流的过程中不能进行 removeTrack 操作。",INVALID_REMOVE_TRACK_NOT_PUBLISHING:"被 remove 的 track 没有被发布。",INVALID_REMOVE_TRACK_NUMBER:"不支持移除唯一的视频轨道,请使用 replaceTrack 或者 muteVideo 方法。",INVALID_REPLACE_TRACK_NO_TRACK:e=>"LocalStream 没有 ".concat(e.kind," track,无法进行替换。"),START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode 调用失败,错误信息: ".concat(e.message,"。"),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode 调用失败,错误信息: ".concat(e.message,"。"),MIX_TRANSCODE_NOT_STARTED:"还没有开始 mixTranscode。",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r}=e;return"'当调用 ".concat(r,"() 函数时,要求参数 ").concat(t||i.name,"' 必须大于等于0")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' 应该是 (0, 30] 区间内的整数。",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' 应该是 [1, 8] 区间内的整数。",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' 应该是 [32, 192] 区间内的整数。",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' 是必传的,且要求为 [1 ,15] 之间的整数。"),MIX_PARAMS_NOT_SELF:"'config.mixUsers' 必须包含发起混流的用户信息。",MIX_PARAMS_USER_STREAM:"输出流的 'config.videoWidth' 和 'config.videoHeight' 应该容纳所有混入流。",INVALID_PLAY:"play() 被重复调用,请先 stop(),然后再重新调用 play。",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"在调用 ".concat(i,"() 时,document 对象中找不到 ").concat(t," 对应的元素,请检查。")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,type:i,fnName:r}=e;return"在调用 ".concat(r,"() 方法时,").concat(t," 参数对应的 HTML 标签元素必须是 HTMLElement 实例,您传入的是:").concat(i,"。")},PLAY_FAILED:e=>"".concat(e.media," 播放被中断,浏览器异常原因:").concat(e.error.toString()),INVALID_USERID:"userId 不能为空格。",INVALID_CREATE_STREAM_SOURCE:"createStream() 生成 LocalStream 可以使用 audio & video 或 audioSource & videoSource 创建,但不能混合使用。",INVALID_CREATE_STREAM_SCREEN:"screen 和 video 不能同时为 true。",INVALID_CREATE_STREAM_AUDIO:"audio 和 screenAudio 不能同时为 true。",INVALID_CREATE_STREAM_SCREEN_AUDIO:"screen 为 true 时,不能设置 screenAudio。",NOT_SUPPORTED_HTTP:"由于浏览器安全策略限制,不支持在 http 协议下使用采集、推流等能力,请使用 https 协议。",NOT_SUPPORTED_WEBRTC:"当前浏览器或环境不完全支持 WebRTC 能力,请检查浏览器版本和页面访问协议是否满足条件。",NOT_SUPPORTED_PROFILE:"您的浏览器不支持 setVideoProfile 方法。请检查浏览器版本是否满足条件。",NOT_SUPPORTED_MEDIA:"当前浏览器或环境不支持 navigator.mediaDevices,请检查浏览器版本和页面访问协议是否满足条件。",NOT_SUPPORTED_H264ENCODE:"当前的设备或环境不支持 H264 编码,不支持 H264 格式进行推流。",NOT_SUPPORTED_H264DECODE:"当前的设备或环境不支持 H264 解码,不支持 H264 格式进行拉流。",NOT_SUPPORTED_TRACK:e=>"您的浏览器不支持 ".concat(e,"Track 方法。"),NOT_SUPPORTED_REPLACE_TRACK:"您的浏览器不支持 replaceTrack 方法,请使用 switchDevice 或者 addTrack。",NOT_SUPPORTED_CAPTURE:"您当前的浏览器不支持屏幕分享,请检查浏览器版本和页面访问协议是否满足条件。",NOT_SUPPORTED_AUX:"您当前的浏览器不支持推辅流,请检查浏览器版本是否满足条件(Chrome 69+, Safari 11+, Firefox 59+)。",MICROPHONE_NOT_FOUND:"未检测到麦克风,请检查您的麦克风和 TRTC.createStream 上的配置。",CAMERA_NOT_FOUND:"未检测到摄像头,请检查您的摄像头和 TRTC.createStream 上的配置。",CATCH_HANDLER_ERROR:e=>{let{name:t,event:i}=e;return" 在 ".concat(t,".on('").concat(i,"', handler) 事件中捕获到业务侧错误,请根据下述错误信息,检查您在 handler 中的业务代码。")},REPEAT_JOIN:e=>"用户 [".concat(e,"] 正在调用进房接口或者已经在房间内,请勿重复创建相同 userId 的 client 进入同一个房间。"),CLIENT_DESTROYED:e=>{let{funName:t}=e;return"client 已经被销毁,调用 ".concat(t,"() 方法失败。")},API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"中断订阅用户 ".concat(e.userId," 的 ").concat(e.streamType," stream, 原因: 在您订阅过程中,远端用户 ").concat(e.userId," 取消了推流,您可以在下次远端推流时再进行订阅。"):"中断接口调用, 原因: ".concat(e.message,"。"),t},SEI_BEFORE_PUBLISH:"当前 client 没有推 localStream(主流,非屏幕分享流),无法调用 client.sendSEIMessage() 接口。"},Gw={INVALID_USER_DEFINE_RECORDID:"TRTC.html#createClient",INVALID_PROXY:"Client.html#setProxyServer",INVALID_JOIN:"Client.html#join",INVALID_ROOMID_STRING:"Client.html#join",INVALID_ROOMID_INTEGER:"Client.html#join",INVALID_PUBLISH:"Client.html#publish",INVALID_UNPUBLISH:"Client.html#unpublish",INVALID_AUDIENCE:"Client.html#switchRole",INVALID_INITIALIZE:"Client.html#publish",INVALID_DUPLICATE_PUBLISHING:"Client.html#publish",INVALID_SUBSCRIBE_UNDEFINED:"Client.html#subscribe",INVALID_SUBSCRIBE_LOCAL:"Client.html#subscribe",INVALID_REMOTE_STREAM:"Client.html#subscribe",INVALID_ROLE:"Client.html#switchRole",INVALID_PARAMETER_SWITCH_ROLE:"Client.html#switchRole",INVALID_OPERATION_SWITCH_ROLE:"Client.html#switchRole",CLIENT_BANNED:"module-ClientEvent.html#.CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"Client.html#startPublishCDNStream",INVALID_OPERATION_STOP_PUBLISH_CDN:"Client.html#stopPublishCDNStream",START_MIX_TRANSCODE:"Client.html#startMixTranscode",STOP_MIX_TRANSCODE:"Client.html#stopMixTranscode",INVALID_AUDIO_VOLUME:"Client.html#enableAudioVolumeEvaluation",ENABLE_SMALL_STREAM_PUBLISHED:"Client.html#enableSmallStream",DISABLE_SMALL_STREAM_PUBLISHED:"Client.html#disableSmallStream",NOT_SUPPORTED_SMALL_STREAM:"tutorial-27-advanced-small-stream.html#h2-4",INVALID_SMALL_STREAM_PROFILE:"Client.html#setSmallStreamProfile",REMOTE_NOT_PUBLISH_SMALL_STREAM:"Client.html#setRemoteVideoStreamType",INVALID_SWITCH_DEVICE:"LocalStream.html#switchDevice",INVALID_SWITCH_DEVICE_PUBLISHING:"LocalStream.html#switchDevice",INVALID_REPLACE_TRACK:"LocalStream.html#replaceTrack",INVALID_INITIALIZE_LOCAL_STREAM:"LocalStream.html#replaceTrack",INVALID_ADD_TRACK_REPETITIVE:"LocalStream.html#addTrack",INVALID_ADD_TRACK_REMOVING:"LocalStream.html#addTrack",INVALID_ADD_TRACK_PUBLISHING:"LocalStream.html#addTrack",INVALID_STREAM_INITIALIZED:"LocalStream.html#addTrack",INVALID_ADD_TRACK_NUMBER:"LocalStream.html#addTrack",INVALID_REMOVE_AUDIO_TRACK:"LocalStream.html#removeTrack",INVALID_REMOVE_AUDIO_ADDING:"LocalStream.html#removeTrack",INVALID_REMOVE_AUDIO_ON:"LocalStream.html#removeTrack",INVALID_REMOVE_TRACK_PUBLISHING:"LocalStream.html#removeTrack",INVALID_REMOVE_TRACK_NOT_PUBLISHING:"LocalStream.html#removeTrack",INVALID_REMOVE_TRACK_NUMBER:"LocalStream.html#removeTrack",INVALID_REMOVE_TRACK_NOT_PUBLISHED:"LocalStream.html#removeTrack",START_MIX_TRANSCODE_TIMEOUT:"Client.html#startMixTranscode",START_MIX_TRANSCODE_FAILED:"Client.html#startMixTranscode",STOP_MIX_TRANSCODE_FAILED:"Client.html#stopMixTranscode",MIX_TRANSCODE_NOT_STARTED:"Client.html#startMixTranscode",MIX_PARAMS_VIDEO_FRAMERATE:"Client.html#startMixTranscode",MIX_PARAMS_VIDEO_GOP:"Client.html#startMixTranscode",MIX_PARAMS_AUDIO_BITRATE:"Client.html#startMixTranscode",MIX_PARAMS_USER_Z_ORDER:"Client.html#startMixTranscode",MIX_PARAMS_NOT_SELF:"Client.html#startMixTranscode",MIX_PARAMS_USER_STREAM:"Client.html#startMixTranscode",INVALID_PLAY:"Stream.html#play",PLAY_FAILED:"Stream.html#play",INVALID_USERID:"TRTC.html#createClient",INVALID_CREATE_STREAM_SOURCE:"TRTC.html#createStream",INVALID_CREATE_STREAM_SCREEN:"TRTC.html#createStream",INVALID_CREATE_STREAM_AUDIO:"TRTC.html#createStream",INVALID_CREATE_STREAM_SCREEN_AUDIO:"TRTC.html#createStream",NOT_SUPPORTED_HTTP:"tutorial-05-info-browser.html#h2-2",NOT_SUPPORTED_WEBRTC:"tutorial-05-info-browser.html",NOT_SUPPORTED_TRTC:"tutorial-05-info-browser.html",NOT_SUPPORTED_PROFILE:"tutorial-23-advanced-support-detection.html",NOT_SUPPORTED_MEDIA:"tutorial-05-info-browser.html",NOT_SUPPORTED_H264ENCODE:"tutorial-23-advanced-support-detection.html",NOT_SUPPORTED_H264DECODE:"tutorial-23-advanced-support-detection.html",NOT_SUPPORTED_TRACK:"LocalStream.html#addTrack",NOT_SUPPORTED_REPLACE_TRACK:"LocalStream.html#replaceTrack",NOT_SUPPORTED_CAPTURE:"tutorial-05-info-browser.html",MICROPHONE_NOT_FOUND:"TRTC.html#createStream",CAMERA_NOT_FOUND:"TRTC.html#createStream",SUBSCRIBE_FAILED:"Client.html#subscribe",API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Client.html#subscribe":"module-ErrorCode.html#.API_CALL_ABORTED",t}};"undefined"!=typeof window&&(window.TRTC_ERROR_INFO=Hw,window.TRTC_ERROR_LINK=Gw);var Ww=(e,t)=>t?"".concat(mC,"/").concat(e,"/").concat(t):"".concat(mC,"/").concat(e,"/index.html");function Jw(e){let{key:t,data:i,link:r,addDocLink:n=!0}=e,o="",a="",s="";uP(jw[t])?o=jw[t](i):pP(jw[t])&&(o=jw[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=(()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=localStorage.getItem("trtc_error_assistance");if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let i=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:i,TRTC_ERROR_LINK:r}}return{}})();r?s="".concat(r.className,".html#").concat(r.fnName):l&&l[t]&&(uP(l[t])?s=l[t](i):pP(l[t])&&(s=l[t]));let d=o;return aP()&&(c&&c[t]&&(uP(c[t])?a=c[t](i):pP(c[t])&&(a=c[t])),a&&(d=n?"".concat(a,"\n请查看文档: ").concat(Ww("zh-cn",s),"\n\n"):"".concat(a,"\n\n"),d+=o)),n&&(d+=" \nRefer to: ".concat(Ww("en",s),"\n")),d}var zw=function(){return new URLSearchParams(location.search).get("trtc_env")||""},Kw=e=>Number(e)<14e8,qw=function(e,t){let i;i=lC||(Kw(e)?"https://videoapi-sgp.im.qcloud.com":"https://yun.tim.qq.com");let r=Math.floor(Math.random()*RA(2,31));return"".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)};function Qw(){return Xb?4:qb?2:zb?3:bk?12:Ck?5:kk?13:1}function Yw(){return Xb?"Android":qb?"iPhone":zb?"iPad":bk?"Mac":Ck?"Windows":kk?"Linux":"unknown"}function Xw(){let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let r=t&&t.type&&t.type.toLowerCase(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();"slow-2"===n&&(n="2g");let o=i||"unknown";if(r)switch(r){case"cellular":case"wimax":o=n||"unknown";break;case"wifi":o="wifi";break;case"ethernet":o="wired";break;default:o="unknown"}return o}var $w=function(e){return{AbilityOption:{AVLimit:e,GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:String(navigator.platform),uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:Qw(),uint32_device_type:0,str_os_verion:Yw(),uint32_link_type:1,str_client_version:nC,uint32_net_type:EC[Xw()],ua:navigator.userAgent,version:""}}}};function Zw(e){let{fn:t,context:i}=e;return function(){try{for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];let o=t.apply(i||this,r);return SP(o)?o.catch((e=>QP.error("".concat(t.name,"() error observed ").concat(e)))):o}catch(o){QP.error("".concat(t.name,"() error observed ").concat(o))}}}function eP(e,t){for(let i of Reflect.ownKeys(t))if("constructor"!==i&&"prototype"!==i&&"name"!==i){let r=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,r)}return e}function tP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3;return iP(e/4,t)}function iP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3;return 1e3*e/t}function rP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3;return 4*nP(e,t)}function nP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3;return e*t/1e3}var oP="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},aP=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},sP=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};function cP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?i:cP(e-1,i,t+i)}function lP(e){return e>8?3e4:1e3*cP(e)}function dP(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var uP=e=>"function"==typeof e,hP=e=>void 0===e,pP=e=>"string"==typeof e,mP=e=>"number"==typeof e,_P=e=>"boolean"==typeof e,fP=e=>"object"===dP(e),gP=e=>"array"===dP(e),vP=e=>dP(e)==="MediaStreamTrack".toLowerCase(),TP=e=>e.isRemote,SP=e=>"promise"===dP(e),yP=e=>uP(e)&&e.prototype.constructor===e,EP=e=>yP(e)?e.prototype.constructor.name:"";"undefined"!=typeof window&&(window.AudioContext=window.AudioContext||window.webkitAudioContext||window.mozAudioContext);var IP="undefined"!=typeof AudioWorkletNode,RP=()=>new window.AudioContext,AP=(()=>{let e;return()=>{if(e)return e;e=new window.AudioContext;return e.onstatechange=()=>{QP.info("gain context state: ".concat(e.state)),"suspended"===e.state?(e.resume(),document.addEventListener("click",e.resume)):"interrupted"===e.state?e.resume():document.removeEventListener("click",e.resume)},e}})();function CP(e){return new Promise(((t,i)=>{let r=[];e.forEach((n=>{n.then(t).catch((t=>{r.push(t),r.length===e.length&&i(r)}))}))}))}function bP(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var kP=(e,t)=>{let{emit:i}=e;return e.emit=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{return i.apply(e,n)}catch(QO){let i=Jw({key:xw,data:{name:t,event:n[0]},addDocLink:!1});return QP.warn("".concat(i,"\n\n").concat(QO.stack)),!1}},e},wP=e=>+e<10?"0".concat(e):e,PP=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let i=t.split("."),r=wP(i[1])+wP(i[2]);return i[1]-15>0&&(i[1]="15"),i[2]-15>0&&(i[2]="15"),"".concat(i.join("."),".").concat(r)},DP=Object.prototype.hasOwnProperty;function NP(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(sP(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(DP.call(e,t))return!1;return!0}return!1}function OP(e,t){return{userId:t,hasAudio:!!(8&e),hasVideo:!!(1&e),hasAuxiliary:!!(4&e),hasSmall:!!(2&e),audioMuted:!!(64&e),videoMuted:!!(16&e),audioAvailable:!(!(8&e)||64&e),videoAvailable:!(!(1&e)||16&e)}}function MP(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}function LP(e){let t={urls:"turn:".concat(e.url)};return!hP(e.username)&&!hP(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",hP(e.credentialType)||(t.credentialType=e.credentialType)),t}function xP(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!pP(e))return 0;let i=e.split(".");return t?(Number(i[0])<<24|Number(i[1])<<16|Number(i[2])<<8|Number(i[3]))>>>0:(Number(i[3])<<24|Number(i[2])<<16|Number(i[1])<<8|Number(i[0]))>>>0}var UP=function(e){return gP(e)||fP(e)},VP=function(e,t,i,r){if(!UP(e)||!UP(t))return 0;let n,o=0,a=Object.keys(t);for(let s=0,c=a.length;s<c;s++)if(n=a[s],!(hP(t[n])||i&&i.includes(n)))if(UP(e[n])&&UP(t[n]))o+=VP(e[n],t[n],i,r);else{if(r&&r.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=t[n],o+=1)}return o},FP=e=>pP(e)?document.getElementById(e):e,jP=new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}),BP=()=>jP.format(new Date);function HP(e){let{url:t,body:i,method:r,timeout:n}=e,o=new XMLHttpRequest;return new Promise(((e,a)=>{o.onreadystatechange=()=>{if(4===o.readyState)if(o.status>=200&&o.status<300)try{let t=JSON.parse(o.response);e({data:t})}catch(t){e({data:o.response})}else a({status:o.status,statusText:o.statusText||"request failed!"})},o.timeout=n||5e3,o.open(r||"POST",t,!0),o.send(i)}))}PA(XA(),1),PA(XA(),1);var GP=function(e){let{retryFunction:t,settings:i,onError:r,onRetrying:n,onRetryFailed:o,context:a}=e;return function(){for(var e=arguments.length,s=new Array(e),c=0;c<e;c++)s[c]=arguments[c];let{retries:l=5,timeout:d=1e3}=i,u=0,h=-1,p=0,m=(e,i)=>MA(this,null,(function*(){let c=a||this;try{let i=yield t.apply(c,s);u=0,e(i)}catch(_){let t=()=>{clearTimeout(h),u=0,p=2,i(_)},a=()=>{2!==p&&u<(uP(l)?l():l)?(u++,p=1,uP(n)&&n.call(this,u,t),h=window.setTimeout((()=>{h=-1,m(e,i)}),uP(d)?d(u):d)):(t(),uP(o)&&o.call(this,_))};uP(r)?r.call(c,_,a,i):a()}}));return new Promise(m)}};PA(XA(),1);PA(XA(),1);var WP=new(PA($A(),1).default);PA(XA(),1);var JP,zP=((JP=zP||{}).ROOM_DESTROY="1",JP.JOIN_START="21",JP.JOIN_SCHEDULE_SUCCESS="22",JP.JOIN_SIGNAL_CONNECTION_START="23",JP.JOIN_SIGNAL_CONNECTION_END="24",JP.JOIN_SEND_CMD="25",JP.JOIN_RECEIVED_CMD_RES="26",JP.JOIN_SUCCESS="27",JP.JOIN_FAILED="28",JP.LEAVE_START="51",JP.LEAVE_SEND_CMD="52",JP.LEAVE_SUCCESS="53",JP.PUBLISH_START="61",JP.SEND_FIRST_VIDEO_FRAME="62",JP.SUBSCRIBE_START="81",JP.SUBSCRIBE_SUCCESS="82",JP.UNSUBSCRIBE_SUCCESS="83",JP.LOCAL_TRACK_CAPTURE_START="101",JP.LOCAL_TRACK_CAPTURE_SUCCESS="102",JP.LOCAL_TRACK_CAPTURE_FAILED="103",JP.LOCAL_TRACK_PUBLISHED="104",JP.LOCAL_TRACK_UNPUBLISHED="105",JP.LOCAL_TRACK_REPLACED="106",JP.SWITCH_DEVICE_SUCCESS="107",JP.TRACK_MUTED="108",JP.TRACK_UNMUTED="109",JP.REMOTE_TRACK_SUBSCRIBED="110",JP.REMOTE_TRACK_UNSUBSCRIBED="111",JP.PLAY_TRACK_START="151",JP.PLAYER_STATE_CHANGED="152",JP.VIDEO_LOADED_DATA="153",JP.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",JP.WORKLET_LOADED_SUCCESS="155",JP.WORKLET_LOADED_FAILED="156",JP.SIGNAL_CONNECTION_STATE_CHANGED="201",JP.PEER_CONNECTION_STATE_CHANGED="202",JP.HEARTBEAT_REPORT="251",JP.RECEIVED_PUBLISHED_USER_LIST="252",JP.REMOTE_PUBLISH_STATE_CHANGED="253",JP.AUDIO_LEVEL_INTERVAL="260",JP.NETWORK_QUALITY="261",JP.API_SUCCESS_RATE="262",JP),KP=zP,qP=!(Yb||Xb),QP=new class{constructor(){NA(this,"_isEnableUploadLog",!0),NA(this,"_localJoinedUser",new Map),NA(this,"_queue",[]),NA(this,"_timeoutId",-1),NA(this,"_logLevel",1),NA(this,"_logLevelToUpload",2),!sC&&!cC&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){WP.on(KP.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;(null==(i=null==t?void 0:t.config)?void 0:i.logLevelToUpload)&&yC[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),WP.on(KP.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),WP.once(KP.JOIN_FAILED,(()=>{this.startUpload()})),WP.on(KP.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),2e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:r,sdkAppId:n}=t;e.map.has(r)?e.map.get(r).logs.push(i):e.map.set(r,{userId:r,sdkAppId:n,logs:[i]})}));else if(pP(i.userId)&&mP(i.sdkAppId)){let{userId:t,sdkAppId:r}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:r,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return MA(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:r,logs:n}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:Fb(),sdkAppId:String(r),userId:i,version:oC,log:n.map((e=>e.log)).join("\n")}),r),n.forEach((e=>e.uploaded=!0))}}catch(QO){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t){return GP({retryFunction:()=>HP({url:qw(t,fC),body:e,timeout:5e3}),settings:{retries:3,timeout:1e3},onError:(e,t)=>{t()}})()}getPrefix(e){let t=new Date;t.setTime(Vb());let i=String(t.getMilliseconds());return"padStart"in String.prototype&&(i=i.toString().padStart(3,"0")),"[".concat(t.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(i,"] <").concat(yC[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){hP(yC[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(pP(e))return e;try{return JSON.stringify(e)}catch(t){return""}}log(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var o;if(t.unshift(this.getPrefix(e)),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push({log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:r,sdkAppId:n,forAllJoinedClients:i}),e<this._logLevel)return;let a=(null==(o=yC[e])?void 0:o.toLowerCase())||"info";qP?console[a]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...t):console[a](...t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){return new class{constructor(e){NA(this,"userId"),NA(this,"id"),NA(this,"sdkAppId"),NA(this,"type"),NA(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.isLocal=!_P(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id,"|").concat(this.userId,"]")),QP.log(e,t,hP(this.userId)||NP(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}}(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;yC[t]&&(this._logLevelToUpload=t)}},YP=!0,XP=PA($A());PA(XA());var $P={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed"},ZP={};wA(ZP,{HTTPS_API:()=>TD,IS_GET_CAPABILITIES_SUPPORTED:()=>UD,IS_GET_SETTINGS_SUPPORTED:()=>xD,IS_SEI_SUPPORTED:()=>VD,basis:()=>GD,checkSystemRequirementsInternal:()=>fD,decodeSupportStatus:()=>_D,encodeSupportStatus:()=>mD,getBrowserInfo:()=>sD,getDisplayResolution:()=>ID,getOSName:()=>ED,isAddTransceiverSupported:()=>ND,isBrowserSupported:()=>cD,isGetReceiversSupported:()=>wD,isGetSendersSupported:()=>PD,isGetTransceiversSupported:()=>DD,isGetUserMediaSupported:()=>RD,isMediaDevicesSupported:()=>dD,isMediaSessionSupported:()=>BD,isMediaStreamTrackProcessorSupported:()=>pD,isReplaceTrackSupported:()=>MD,isScreenCaptureApiAvailable:()=>vD,isSelectedCandidatePair:()=>SD,isSetParametersSupported:()=>LD,isSmallStreamAPISupported:()=>CD,isSmallStreamSupported:()=>bD,isStopTransceiverSupported:()=>OD,isTRTCSupported:()=>gD,isUnifiedPlanDefault:()=>kD,isUsedInHttpProtocol:()=>hD,isWebAudioSupported:()=>AD,isWebCodecSupported:()=>jD,isWebCodecsSupported:()=>lD,isWebRTCSupported:()=>FD,isWebTransportSupported:()=>HD}),PA(XA(),1),PA(XA(),1),PA(XA(),1);var eD,tD=((eD=tD||{})[eD.INVALID_PARAMETER=4096]="INVALID_PARAMETER",eD[eD.INVALID_OPERATION=4097]="INVALID_OPERATION",eD[eD.NOT_SUPPORTED=4098]="NOT_SUPPORTED",eD[eD.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",eD[eD.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",eD[eD.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",eD[eD.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",eD[eD.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",eD[eD.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",eD[eD.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",eD[eD.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",eD[eD.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",eD[eD.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",eD[eD.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",eD[eD.CLIENT_BANNED=16448]="CLIENT_BANNED",eD[eD.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",eD[eD.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",eD[eD.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",eD[eD.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",eD[eD.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",eD[eD.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",eD[eD.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",eD[eD.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",eD[eD.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",eD[eD.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",eD[eD.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",eD[eD.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",eD[eD.API_CALL_ABORTED=16461]="API_CALL_ABORTED",eD[eD.UNKNOWN=65535]="UNKNOWN",eD),iD=tD,rD=class extends Error{constructor(e){let{name:t="RtcError",message:i,code:r=iD.UNKNOWN,extraCode:n=0,constraint:o}=e,a="<".concat(function(e){for(let t in iD)if(iD[t]===e)return t;return"UNKNOWN"}(r)," 0x").concat(r.toString(16),">"),s="".concat(i).concat(o?" constraint: ".concat(o):"").concat(null!=i&&i.includes(a)?"":" ".concat(a));super(s),NA(this,"code"),NA(this,"extraCode"),NA(this,"message"),NA(this,"originMessage"),NA(this,"name"),NA(this,"constraint"),this.code=r,this.extraCode=n,this.name=t,this.message=s,this.constraint=o,this.originMessage=i}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},nD=rD,oD={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},aD=new Map([[$b,["Firefox",Zb]],[rk,["Edg",nk]],[Hk,["Chrome",Wk]],[Jk,["Safari",zk]],[dk,["TBS",uk]],[hk,["XWEB",pk]],[_k&&qb,["WeChat",fk]],[Sk,["QQ(Win)",yk]],[vk,["QQ(Mobile)",Tk]],[gk,["QQ(Mobile X5)",Tk]],[Ek,["QQ(Mac)",Ik]],[Rk,["QQ(iPad)",Ak]],[Pk,["MI",Dk]],[Nk,["HW",Ok]],[Mk,["Samsung",Lk]],[xk,["OPPO",Uk]],[Vk,["VIVO",Fk]],[tk,["EDGE",ik]],[ak,["SogouMobile",sk]],[ck,["Sogou",lk]]]);function sD(){let e=aD.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var cD=function(){return!(wk||tk||rk&&ok<80||$b&&ek<56)},lD=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},dD=function(){if(!navigator.mediaDevices)return QP.error(jw.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},uD=!1;function hD(){return"http:"===location.protocol&&!Yk&&!uD&&(uD=!0,QP.warn(Jw({key:ww})),!0)}var pD=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},mD=function(){return MA(this,null,(function*(){if(oD.detail.isH264EncodeSupported||oD.detail.isVp8EncodeSupported)return{isH264EncodeSupported:oD.detail.isH264EncodeSupported,isVp8EncodeSupported:oD.detail.isVp8EncodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection,n=document.createElement(CC);n.getContext("2d");let o=n.captureStream(0);return r.addTrack(o.getVideoTracks()[0],o),e=yield r.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),oD.detail.isH264EncodeSupported=t,oD.detail.isVp8EncodeSupported=i,{isH264EncodeSupported:oD.detail.isH264EncodeSupported,isVp8EncodeSupported:oD.detail.isVp8EncodeSupported}}catch(r){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},_D=function(){return MA(this,null,(function*(){if(oD.detail.isH264DecodeSupported&&oD.detail.isVp8DecodeSupported)return{isH264DecodeSupported:oD.detail.isH264DecodeSupported,isVp8DecodeSupported:oD.detail.isVp8DecodeSupported};let e,t=!1,i=!1;try{let r=new RTCPeerConnection;return e=yield r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(i=!0),r.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:i}}catch(r){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},fD=function(){return MA(this,null,(function*(){if(oD.result)return oD;let e=cD(),t=FD(),i=lD(),r=dD(),{isH264EncodeSupported:n,isVp8EncodeSupported:o}=yield mD(),{isH264DecodeSupported:a,isVp8DecodeSupported:s}=yield _D();return oD.result=e&&t&&r&&(n||o)&&(a||s),oD.detail.isBrowserSupported=e,oD.detail.isWebRTCSupported=t,oD.detail.isWebCodecsSupported=i,oD.detail.isMediaDevicesSupported=r,oD.detail.isScreenShareSupported=vD(),oD.detail.isSmallStreamSupported=bD(),oD.detail.isH264EncodeSupported=n,oD.detail.isVp8EncodeSupported=o,oD.detail.isH264DecodeSupported=a,oD.detail.isVp8DecodeSupported=s,oD.result||QP.error("".concat(navigator.userAgent," isBrowserSupported: ").concat(e,"isWebCodecsSupported: ").concat(i," isMediaSupported: ").concat(r," isH264EncodeSupported: ").concat(n," isVp8EncodeSupported: ").concat(o," isH264DecodeSupported: ").concat(a," isVp8DecodeSupported: ").concat(s," ")),oD}))},gD=function(){return oD.result},vD=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},TD=(e,t,i)=>{"http:"===location.protocol&&!Yk&&(e[t]=()=>{throw new nD({code:iD.INVALID_OPERATION,message:jw.NOT_SUPPORTED_HTTP})})},SD=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(_P(e.selected)&&!e.selected)},yD=new Map([[Xb,"Android"],[Yb,"iOS"],[Ck,"Windows"],[bk,"MacOS"],[kk,"Linux"]]),ED=function(){return yD.get(!0)?yD.get(!0):"unknown"};function ID(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",i=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(i)}return e}function RD(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function AD(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let i=0;i<t.length;i++)if(t[i]in window){e.isSupported=!0;break}return e.isSupported}function CD(){return"captureStream"in HTMLCanvasElement.prototype}function bD(){return!(_k||Yb||Gk&&Gk<63)&&!(!cD()||!CD())}var kD=function(){if(hP(window.RTCRtpTransceiver)||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:fb}),e.addTransceiver(bC),t=!0}catch(i){}return null==e||e.close(),t};function wD(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function PD(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function DD(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function ND(){return"RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype}function OD(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}function MD(){return"RTCRtpSender"in window&&"replaceTrack"in window.RTCRtpSender.prototype}function LD(){return"RTCRtpSender"in window&&"setParameters"in window.RTCRtpSender.prototype&&PD()}var xD=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,UD=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,VD="RTCRtpSender"in window&&"createEncodedStreams"in window.RTCRtpSender.prototype&&jk()>=86,FD=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function jD(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return hP(window.AudioDecoder)||(e.AudioDecoder=!0),hP(window.AudioEncoder)||(e.AudioEncoder=!0),hP(window.VideoDecoder)||(e.VideoDecoder=!0),hP(window.VideoEncoder)||(e.VideoEncoder=!0),hP(window.ImageDecoder)||(e.ImageDecoder=!0),e}function BD(){return"mediaSession"in navigator&&!hP(navigator.mediaSession.setActionHandler)}function HD(){return!hP(window.WebTransport)}function GD(){let e={browser:"".concat($k.name,"/").concat($k.version),os:ED(),displayResolution:ID(),isScreenShareSupported:vD(),isWebRTCSupported:FD(),isGetUserMediaSupported:RD(),isWebAudioSupported:AD(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:jD(),isMediaSessionSupported:BD(),isWebTransportSupported:HD()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}PA(XA(),1),PA(XA(),1);var WD=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))};PA(XA(),1);var JD=new class{constructor(){NA(this,"_prefix","TRTC"),NA(this,"_queue",new Map),this.checkStorage()}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){Xk()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix)){let t=JSON.parse(localStorage.getItem(e));if(t&&t.expiresIn<Date.now())return!0}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(Xk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(HO){QP.warn(HO)}}getItem(e){if(!Xk())return null;try{let t=JSON.parse(localStorage.getItem(this.getRealKey(e)));return t&&t.expiresIn>=Date.now()?t.value:null}catch(t){QP.warn(t)}}setItem(e,t){if(Xk())try{let i={expiresIn:Date.now()+6048e5,value:t};this._queue.set(this.getRealKey(e),i)}catch(i){QP.warn(i)}}deleteItem(e){if(!Xk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(t){return QP.warn(t),!1}}clear(){if(Xk())try{localStorage.clear()}catch(HO){QP.warn(HO)}}};PA(XA(),1),PA(XA(),1);var zD=PA($A(),1),KD=Symbol("instance"),qD=Symbol("abortCtrl"),QD=Symbol("cacheResult"),YD=class{constructor(e,t,i){NA(this,"oldState"),NA(this,"newState"),NA(this,"action"),NA(this,"error"),this.oldState=e,this.newState=t,this.action=i}toString(){return"".concat(this.action,"ing")}},XD=class extends Error{constructor(e,t,i){super(t),NA(this,"state"),NA(this,"message"),NA(this,"cause"),this.state=e,this.message=t,this.cause=i}},$D=new Map,ZD=Object.getPrototypeOf(MA(void 0,null,(function*(){}))).constructor;function eN(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let a=i.action||n;if(!i.context){let i=$D.get(r)||[];$D.has(r)||$D.set(r,i),i.push({from:e,to:t,action:a})}let s=o.value;o.value=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return MA(this,null,(function*(){var r;let o=this;if(i.context&&(o=aN.get("function"==typeof i.context?i.context.call(this,...n):i.context)),o.state===t)return o[QD];let c=null;if(Array.isArray(e)?0==e.length?o[qD]&&(o[qD].aborted=!0):("string"!=typeof o.state||!e.includes(o.state))&&(c=new XD(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not in from config"))):e!==o.state&&(c=new XD(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not from ").concat(e))),c){if(!i.fail){if(i.ignoreError)return c;throw c}i.fail.call(this,c)}let l=o.state;iN.call(o,new YD(l,t,a));let d={aborted:!1};o[qD]=d;try{let e=s.apply(this,n);return o[QD]=e instanceof ZD?yield e:e,d.aborted||(o[qD]=void 0,iN.call(o,t),null==(r=i.success)||r.call(this,o[QD])),o[QD]}catch(u){let e=u instanceof Error?u.message:String(u);if(iN.call(o,l,e),!i.fail){if(i.ignoreError)return u;throw u}i.fail.call(this,new XD(o._state,"action '".concat(a,"' failed :").concat(e),u instanceof Error?u:new Error(e)))}}))}}}var tN="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function iN(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(aN.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t})}var rN,nN,oN=class extends zD.default{constructor(e,t,i){super(),NA(this,"name"),NA(this,"groupName"),NA(this,"_state",oN.INIT),NA(this,rN),NA(this,nN),this.name=e,this.groupName=t,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[KD];r?this.name=r.name+"-"+r.count++:i[KD]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=$D.get(e)||[],i=new Set,r=[],n=[],o=new Set,a=Object.getPrototypeOf(e);$D.has(a)&&(a.stateDiagram.forEach((e=>i.add(e))),a.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let s=[...i];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:o}}),s}static get(e){let t;return"string"==typeof e?(t=oN.instances.get(e),t||oN.instances.set(e,t=new oN(e,void 0,Object.create(oN.prototype)))):(t=oN.instances2.get(e),t||oN.instances2.set(e,t=new oN(e.constructor.name,void 0,Object.create(oN.prototype)))),t}static getState(e){var t;return null==(t=oN.get(e))?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};tN(oN.UPDATEAFSM,CA({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){iN.call(this,e)}},aN=oN;rN=QD,nN=qD,NA(aN,"STATECHANGED","stateChanged"),NA(aN,"UPDATEAFSM","updateAFSM"),NA(aN,"INIT","[*]"),NA(aN,"ON","on"),NA(aN,"OFF","off"),NA(aN,"instances",new Map),NA(aN,"instances2",new WeakMap),PA(XA(),1),PA(XA(),1),PA(XA(),1),PA(XA(),1),PA(XA(),1);var sN=(null==window?void 0:window.requestIdleCallback)||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},cN=(null==window?void 0:window.cancelIdleCallback)||function(e){clearTimeout(e)},lN=(null==window?void 0:window.cancelAnimationFrame)||(null==window?void 0:window.mozCancelAnimationFrame),dN=class{static generateTaskID(){return this.currentTaskID++}static run(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:xb,t=arguments.length>1?arguments[1]:void 0,i=arguments.length>2?arguments[2]:void 0;i=CA("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:e===Mb?{delay:1e4,count:0}:e===Lb?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},i),fP(t)&&(i=CA(CA({},i),t)),uP(e)&&(t=e,e=xb);let r=CA({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},i);return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}static interval(e){return e.intervalID=setInterval((()=>{e.callback(),e.loopCount+=1,this.isBreakLoop(e)}),e.delay)}static timeout(e){let t=()=>{if(e.callback(),e.loopCount+=1,!this.isBreakLoop(e))return e.timeoutID=setTimeout(t,e.delay)};return e.timeoutID=setTimeout(t,e.delay)}static ric(e){let t,i=bP(),r=()=>{if(t=bP()-i,t>=e.delay&&(i=bP()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),!this.isBreakLoop(e))return e.ricID=sN(r,{timeout:e.delay})};return e.ricID=sN(r,{timeout:e.delay})}static raf(e){e.delay=(1e3/e.fps).toFixed(2);let t,i=bP(),r=()=>document.hidden&&e.backgroundTask?(t=bP()-i,i=bP(),e.callback(),e.loopCount+=1,this.isBreakLoop(e)?void 0:e.timeoutID=setTimeout(r,e.delay-Math.floor(t%e.delay))):(t=bP()-i,t>=e.delay&&(i=bP()-Math.floor(t%e.delay),e.callback(),e.loopCount+=1),this.isBreakLoop(e)?void 0:e.rafID=requestAnimationFrame(r));if(e.rafID=requestAnimationFrame(r),e.backgroundTask){let t=()=>{if(document.hidden){let t=bP()-i;t>=e.delay?r():e.timeoutID=setTimeout(r,e.delay-t)}};document.addEventListener("visibilitychange",t),e.onVisibilitychange=t,document.hidden&&t()}return e.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:i,rafID:r,ricID:n,onVisibilitychange:o}=this.taskMap.get(e);return t&&clearInterval(t),i&&clearTimeout(i),r&&lN(r),n&&cN(n),o&&document.removeEventListener("visibilitychange",o),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.taskMap.has(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};dN.taskMap=new Map,dN.currentTaskID=1;var uN=dN;PA(XA(),1);var hN="connection-state-changed",pN={LOADED_DATA:HC,PLAYER_STATE_CHANGED:"player-state-changed"};PA(XA(),1),PA(XA(),1);var mN=new class{constructor(){this._roomIdMap=new Map,"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:oC,env:vC,browserVersion:$k.name+$k.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:i,userId:r,roomId:n}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=i,this._configs.userId=r,this._roomIdMap.set(r,String(n))}logSuccessEvent(e){Yk||!QP.isAbleToUpload||this._configs.env===vC&&this.uploadEventToKibana(bA(CA({},e),{result:"success"}))}logFailedEvent(e){if(Yk||!QP.isAbleToUpload)return;let{eventType:t,code:i,error:r,userId:n}=e,o={roomId:this._roomIdMap.get(n||this._configs.userId),userId:n,eventType:t,result:"failed",code:i||r.extraCode||r.code||iD.UNKNOWN};this._configs.env===vC&&this.uploadEventToKibana(bA(CA({},o),{error:r}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:i,error:r}=e,n={timestamp:Fb(),sdkAppId:this._configs.sdkAppId,userId:i||this._configs.userId,version:oC,log:t};r&&(n.errorInfo=r.message),this.sendRequest(qw(this._configs.sdkAppId,fC),n)}sendRequest(e,t){QP.isAbleToUpload?HP({url:e,body:JSON.stringify(t)}).catch((()=>{})):setTimeout((()=>{this.sendRequest(e,t)}),1e3)}},_N="trtc_autoplay",fN="".concat(_N,"_mask"),gN="".concat(_N,"_wrapper"),vN="".concat(_N,"_header"),TN="".concat(_N,"_content"),SN="".concat(_N,"_action_wrapper"),yN="".concat(_N,"_question"),EN="".concat(_N,"_collapse"),IN="".concat(_N,"_action_confirm"),RN="".concat(_N,"_detail"),AN="#2473E8",CN="dialog",bN="".concat(CN,"-show"),kN="".concat(CN,"-1"),wN="".concat(CN,"-2"),PN=!1,DN=()=>!!document.querySelector(".".concat(gN)),NN="".concat(mC,"/").concat(aP()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),ON="<br><a href='".concat(NN,"' target='_blank'>").concat(aP()?"其他方案?":"Any other solution?","</a>"),MN="".concat(aP()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(ON):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(ON)),LN=class{constructor(){if(NA(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),NA(this,"_dialogNode",null),NA(this,"_bodyPosition",""),NA(this,"_showDetail",!1),NA(this,"_isCollapseClicked",!1),NA(this,"_isQuestionClicked",!1),aP()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!PN){let e=document.createElement("style");e.innerHTML=".".concat(fN,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(fN," div:not(.").concat(SN,"){display:block !important;}.").concat(gN,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(gN," a{color:").concat(AN,";}.").concat(vN,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(TN,"{margin:8px 0;}.").concat(SN,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(EN,"{margin-right:auto;cursor:pointer}.").concat(yN,"{height:100%;line-height:16px;cursor:pointer;}.").concat(IN,"{margin-left:8px;color:#fff;background:").concat(AN,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(IN,":hover{opacity:0.9;}.").concat(EN,",.").concat(IN,",.").concat(TN,",.").concat(yN,"{font-size:14px;}@media screen and (max-width:750px){.").concat(gN,"{width:80vw;}}"),document.head.appendChild(e),PN=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(fN,"\"><div class='").concat(gN,"'><div class='").concat(vN,"'>").concat(location.host,"</div><div class='").concat(TN,"'>").concat(this.content,"</div><div class='").concat(RN,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(MN,"</div><div class='").concat(SN,"'></div></div></div>").trim();let t=document.createElement("button");t.className=IN,t.innerText=aP()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let i=document.createElement("div");i.className=yN,i.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',i.onclick=this.onQuestionClick.bind(this);let r=document.createElement("div");r.className=EN,r.innerText="".concat(aP()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);let n=e.content.firstChild,o=n.querySelector(".".concat(SN));return o.appendChild(r),o.appendChild(i),o.appendChild(t),n}addDiaLog(){DN()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(gN)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",QP.info("show autoplay dialog"),mN.uploadEvent({log:bN}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){QP.warn("confirm clicked, try resume stream"),WP.emit(KP.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(RN));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||mN.uploadEvent({log:kN}),this._isCollapseClicked=!0}onQuestionClick(){window.open(NN,"_blank"),this._isQuestionClicked||mN.uploadEvent({log:wN}),this._isQuestionClicked=!0}},xN={};wA(xN,{create:()=>VN,remove:()=>FN}),PA(XA(),1);var UN=new WeakMap;function VN(e,t){UN.has(e)||UN.set(e,[]);let i=UN.get(e),r={add:(e,n)=>("addEventListener"in t?(i.push(t.removeEventListener.bind(t,e,n)),t.addEventListener(e,n)):(i.push(t.off.bind(t,e,n)),t.on(e,n)),r)};return r}function FN(e){let t=UN.get(e);t&&(t.forEach((e=>e())),UN.delete(e))}var jN=class extends aN{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,NA(this,"id"),NA(this,"element",null),NA(this,"container",null),NA(this,"mediaStream",new MediaStream),NA(this,"track"),NA(this,"attr"),NA(this,"muted"),NA(this,"_log"),NA(this,"_pausedRetryCount"),NA(this,"_isElementPlayingFired",!1),NA(this,"_interval"),this.id=e.id,this._log=e.log,this.track=e.track,this.container=e.container,this.muted=e.muted,this._pausedRetryCount=5,this._state="STOPPED",this.bindTrackEvents()}get isPlaying(){return"PLAYING"===this._state}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setTrack(e){if(e!==this.track&&(this.unbindTrackEvents(),this.track=e,null!==e&&(this.bindTrackEvents(),this.element))){let t=new MediaStream;t.addTrack(e),this.element.srcObject=t}}setContainer(e){this.container=e,this.track&&this.element&&this.container&&this.container.appendChild(this.element)}play(){return MA(this,null,(function*(){if(this.element&&this.element.parentElement!==this.container&&this.container&&this.container.append(this.element),!this.isPlaying)try{this.bindAutoPlayEvent(),yield this.element.play()}catch(e){let t=Jw({key:kw,data:{media:this.kind,error:e}});if(this._log.warn(t),t.includes("NotAllowedError"))throw new nD({code:iD.PLAY_NOT_ALLOWED,message:t})}}))}stop(){this.unbindEvents(),this._isElementPlayingFired=!1,this.element&&(this.container&&this.container.removeChild(this.element),this.element.srcObject=null,this.element=null),this.handleStopped(VC),this._interval>0&&uN.clearTask(this._interval)}resume(){return this.isPlaying?Promise.resolve():Qk?this.replay():(this._log.info("resume"),this.play().catch((()=>{})))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}setRect(e,t){this.element&&(this.element.style.width="".concat(e,"px"),this.element.style.height="".concat(t,"px"))}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);VN(this.element,this.element).add(FC,e).add(VC,e).add(jC,e).add(BC,e).add(HC,e)}}bindTrackEvents(){if(this.track){let e=this.handleTrackEvent.bind(this);null==xN||xN.create(this.track,this.track).add(VC,e).add(xC,e).add(UC,e),this.track.readyState===VC&&this.handleTrackEvent({type:VC}),this.track.muted&&this.handleTrackEvent({type:xC})}}bindAutoPlayEvent(){WP.on(KP.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){this.track&&FN(this.track)}unbindEvents(){this.element&&FN(this.element),this.unbindTrackEvents(),WP.off(KP.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){var t;switch(e.type){case FC:this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(FC),this._interval&&(uN.clearTask(this._interval),this._interval=-1);break;case VC:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(VC);break;case jC:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(jC);let e=this.container&&document.getElementById(this.container.id);e||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id));let i=jk();this._pausedRetryCount>0&&(this.kind===kC&&!DN()||this.kind===bC&&(mP(i)&&i<=70||!e))&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),Yb&&(this._interval=uN.run(xb,(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case BC:if(this.element&&this.element.error){let e="".concat(ED(),"/").concat($k.name,"/").concat($k.version);this._log.error("".concat(this.kind," player error observed. code: ").concat(this.element.error.code," message: ").concat(this.element.error.message," deviceInfo: ").concat(e))}break;case HC:this.kind===kC&&this.emit(pN.LOADED_DATA)}}handleTrackEvent(e){switch(e.type){case VC:this._log.info("".concat(this.kind," track is ended")),this.handleStopped(VC);break;case xC:this._log.info("".concat(this.kind," track is unable to provide media output")),this.handlePaused(xC);break;case UC:this._log.info("".concat(this.kind," track is able to provide media output")),this._isElementPlayingFired&&this.handlePlaying(UC)}}handlePlaying(e){this.emit(pN.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(pN.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}handleStopped(e){this.emit(pN.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};DA([eN([],"PLAYING")],jN.prototype,"handlePlaying",1),DA([eN("PLAYING","STOPPED",{ignoreError:!0})],jN.prototype,"handlePaused",1),DA([eN([],"STOPPED")],jN.prototype,"handleStopped",1);var BN=class extends jN{constructor(e){super(e,kC),NA(this,"mirror"),NA(this,"objectFit"),hP(e.mirror)||(this.mirror=e.mirror),hP(e.objectFit)||(this.objectFit=e.objectFit)}initializeElement(){var e;let t=document.createElement(kC);if(this.track){let e=new MediaStream;e.addTrack(this.track),t.srcObject=e}t.muted=!0;let i="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");this.mirror&&(i+="transform: scaleX(-1);"),t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",i),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),null==(e=this.container)||e.appendChild(t),this.element=t,this.bindElementEvents()}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}setMirror(e){this.element&&(this.element.style.transform=e?"scaleX(-1)":""),this.mirror=e}setObjectFit(e){this.element&&(this.element.style.objectFit="".concat(e)),this.objectFit=e}play(){return this.element||this.initializeElement(),super.play()}getVideoFrame(){if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}};PA(XA(),1),PA(XA(),1),PA(XA(),1);var HN,GN,WN=!1,JN=class{constructor(e){NA(this,"context_"),NA(this,"blob_"),this.context_=e.context,this.blob_=new Blob(["class VolumeMeter extends AudioWorkletProcessor{constructor(){super();this.volume=0;this.intervalTime=200;this.tick=this.intervalTime;this.isStop=false;this.port.onmessage=event=>{const{data}=event;switch(data.name){case'setIntervalTime':this.intervalTime=data.intervalTime;break;case'stop':this.isStop=true;break}}}process(inputs){const input=inputs[0];if(this.isStop){return false}if(input.length>0){const firstChannel=input[0];let sum=0;let rms;for(let i=0;i<firstChannel.length;++i){sum+=firstChannel[i]*firstChannel[i]}rms=Math.sqrt(sum/firstChannel.length);this.volume=Math.max(rms,this.volume*0.95);this.tick-=firstChannel.length;if(this.tick<0){this.tick+=(this.intervalTime/1000)*sampleRate;this.port.postMessage({volume:this.volume})}}return true}}registerProcessor('volume-meter',VolumeMeter);"],{type:"application/javascript"}),this.addModuleToContext()}addModuleToContext(){return MA(this,null,(function*(){try{yield this.context_.audioWorklet.addModule(URL.createObjectURL(this.blob_)),QP.info("worklet addModule success"),WP.emit(KP.WORKLET_LOADED_SUCCESS),WN=!0}catch(HO){QP.info("worklet addModule catch error. ".concat(HO.message)),WP.emit(KP.WORKLET_LOADED_FAILED)}}))}get initWorkletSuccess(){return WN}},zN=0,KN=class{constructor(e){NA(this,"_volume"),NA(this,"_log"),NA(this,"_track"),NA(this,"_stream"),NA(this,"_audioCtx"),NA(this,"_destination"),NA(this,"_streamSource"),NA(this,"_scriptProcessorNode"),NA(this,"_audioWorkletNode"),NA(this,"_interval");let{track:t,log:i}=e;this._volume=0,this._log=i,this._track=t,HN||(HN=RP()),this._audioCtx=HN,this._destination=this._audioCtx.destination;let r=new MediaStream;r.addTrack(this._track),this._streamSource=this._audioCtx.createMediaStreamSource(r),this._audioWorkletNode=null,this._scriptProcessorNode=null,this._interval=200,WP.on(KP.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this),IP?(WP.on(KP.WORKLET_LOADED_SUCCESS,this.initAudioWorklet,this),WP.on(KP.WORKLET_LOADED_FAILED,this.initScriptProcessor,this),this.preload()):this.initScriptProcessor(),zN+=1}preload(){GN?GN.initWorkletSuccess&&this.initAudioWorklet():GN=new JN({context:HN})}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(this._audioCtx,"volume-meter"),this._audioWorkletNode.port.onmessage=e=>{this._volume=e.data.volume||0},this._streamSource.connect(this._audioWorkletNode).connect(this._destination),this.handleAudioLevelInterval({interval:this._interval})}catch(HO){mN.logFailedEvent({userId:this._log.userId,eventType:_b}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=this._audioCtx.createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=e=>{let t=e.inputBuffer.getChannelData(0),i=0;for(let r=0;r<t.length;++r)i+=t[r]*t[r];this._volume=Math.sqrt(i/t.length)||0},this._streamSource.connect(this._scriptProcessorNode),this._scriptProcessorNode.connect(this._destination)}catch(HO){this._log.error("volumeMeter init script processor error: ".concat(HO))}}destroy(){this._streamSource&&this._streamSource.disconnect(),this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null,this._scriptProcessorNode.disconnect()),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null,this._audioWorkletNode.disconnect()),this._audioWorkletNode=null,this._scriptProcessorNode=null,this._audioCtx=null,WP.off(KP.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this),WP.off(KP.WORKLET_LOADED_SUCCESS,this.initAudioWorklet,this),WP.off(KP.WORKLET_LOADED_FAILED,this.initScriptProcessor,this),zN>0&&(zN-=1),0===zN&&(null==HN||HN.close(),HN=null,GN=null)}resume(){null==HN||HN.resume()}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}handleAudioLevelInterval(e){var t;let{interval:i}=e;this._interval=i,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:i})}},qN=class extends jN{constructor(e){super(e,bC),NA(this,"_volumeMeter"),NA(this,"gainedTrack"),NA(this,"_outputDeviceId"),NA(this,"_volume",1),e.gainedTrack&&(this.gainedTrack=e.gainedTrack),this._outputDeviceId=e.outputDeviceId,this.track&&this.initVolumeMeter(this.track)}setTrack(e){this.track!==e&&(this._volumeMeter&&(this._volumeMeter.destroy(),this._volumeMeter=null),null!==e&&this.initVolumeMeter(e)),super.setTrack(e)}initVolumeMeter(e){this._volumeMeter=new KN({track:this.gainedTrack||e,log:this._log})}initializeElement(){if(("15.2"===Kk||"15.3"===Kk||"15.4"===Kk)&&this.muted)return void this._log.info("audioElement is muted.");let e=document.createElement(bC);if(this.gainedTrack||this.track){let t=new MediaStream;t.addTrack(this.gainedTrack||this.track),e.srcObject=t}e.muted=this.muted,e.setAttribute("id","audio_".concat(this.id)),e.setAttribute("autoplay","autoplay"),e.setAttribute("playsinline","playsinline"),this.element=e,this.bindElementEvents()}play(){return MA(this,null,(function*(){this.element||this.initializeElement(),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),!this._volumeMeter&&this.track&&this.initVolumeMeter(this.track),this.setVolume(this._volume),yield OA(qN.prototype,this,"play").call(this)}))}stop(){this._volumeMeter&&(this._volumeMeter.destroy(),this._volumeMeter=null),super.stop()}resume(){return MA(this,null,(function*(){yield OA(qN.prototype,this,"resume").call(this),this._volumeMeter&&this._volumeMeter.resume()}))}setSinkId(e){return MA(this,null,(function*(){this._outputDeviceId!==e&&(this.element&&(yield this.element.setSinkId(e)),this._outputDeviceId=e)}))}setVolume(e){!this.element||(this.element.volume=e,this._volume=e)}getAudioLevel(){var e;return(null==(e=this._volumeMeter)?void 0:e.getCalculatedVolume())||0}getInternalAudioLevel(){var e;return null==(e=this._volumeMeter)?void 0:e.getInternalAudioLevel()}},QN=class extends aN{constructor(e){let{userId:t,sdkAppId:i,mediaType:r}=e;super(),NA(this,"id",WD()),NA(this,"userId"),NA(this,"isRemote"),NA(this,"mediaType"),NA(this,"room"),NA(this,"user"),NA(this,"_log"),NA(this,"isPlayCalled"),NA(this,"mediaTrack",null),NA(this,"mediaStream"),NA(this,"container",null),NA(this,"playerMuted",!1),NA(this,"abortCtrl"),NA(this,"audioOutputDeviceId"),NA(this,"audioVolume"),NA(this,"objectFit","cover"),NA(this,"mirror",!1),NA(this,"gain"),NA(this,"isScreen",!1),hP(t)||(this.userId=t),this.mediaType=r,this._log=QP.createLogger({id:"".concat(this.kind[0],"t"),userId:t,sdkAppId:i,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof mO}),this.initPlayer()}get log(){return this._log||QP}get kind(){return 1===this.mediaType?bC:kC}get muted(){return!(!this.mediaTrack||this.mediaTrack.enabled)}get strMediaType(){return 4===this.mediaType?kC:2===this.mediaType?wC:bC}uninstallEvents(){}play(e,t){return MA(this,null,(function*(){if(this.mediaTrack){if(this._log.info("play with options: ".concat(JSON.stringify(t))),this.isPlayCalled)return t&&!hP(t.muted)&&this.setPlayerMute(t.muted),t&&!hP(t.objectFit)&&(this.objectFit=t.objectFit),this.isScreen?this.mirror=!1:t&&!hP(t.mirror)&&(this.mirror=t.mirror),void(this.kind===kC&&(this.player.setObjectFit(this.objectFit),this.player.setMirror(this.mirror),this.container!==e&&e&&(this.container=e,this.player.setContainer(e))));(!this.isRemote||this.kind===kC)&&(this.playerMuted=!0),t&&!hP(t.muted)&&(this.playerMuted=t.muted),t&&!hP(t.objectFit)&&(this.objectFit=t.objectFit),this.isScreen?this.mirror=!1:(this.isRemote||(this.mirror=!0),t&&!hP(t.mirror)&&(this.mirror=t.mirror)),this.player.setMuted(this.playerMuted),this.kind===kC&&(this.player.setObjectFit(this.objectFit),this.player.setMirror(this.mirror)),this.isPlayCalled=!0,e&&(this.container=e,this.player.setContainer(e)),WP.emit(KP.PLAY_TRACK_START,{track:this});try{yield this.player.play()}catch(QO){if(this.room&&this.room.enableAutoPlayDialog)new LN;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0),document.removeEventListener("touchstart",e,!0)}))};document.addEventListener("click",e,!0),document.addEventListener("touchstart",e,!0)}throw this.emit("error",QO),QO}}}))}initPlayer(){var e;this.log.info("create ".concat(this.kind,"Player")),this.kind===bC?this.player=new qN({id:this.userId||this.id,track:this.mediaTrack,gainedTrack:null==(e=this.gain)?void 0:e.audioTrack,container:this.container||null,muted:this.playerMuted,outputDeviceId:this.audioOutputDeviceId,log:this.log}):(this.player=new BN({id:this.userId||this.id,track:this.mediaTrack,container:this.container||null,muted:this.playerMuted,objectFit:this.objectFit,mirror:this.mirror,log:this.log}),this.player.on(pN.LOADED_DATA,(()=>{WP.emit(KP.VIDEO_LOADED_DATA,{track:this})}))),this.player.on(pN.PLAYER_STATE_CHANGED,(e=>{WP.emit(KP.PLAYER_STATE_CHANGED,CA({track:this},e)),this.emit("player-state-changed",e)}))}setAudioOutput(e){return MA(this,null,(function*(){var t;this.audioOutputDeviceId=e,yield null==(t=this.player)?void 0:t.setSinkId(e)}))}setAudioVolume(e){var t;this.audioVolume=e,this.log.info("setAudioVolume to ".concat(e)),null==(t=this.player)||t.setVolume(e)}getAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getAudioLevel())||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){!this.isPlayCalled||(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(),this.player.setContainer(null)),this.container=null)}resume(){return MA(this,null,(function*(){var e;!this.isPlayCalled||(yield null==(e=this.player)?void 0:e.resume())}))}close(){var e;this.log.info("close"),this.isPlayCalled&&this.stop(),!this.isRemote&&(null==(e=this.mediaTrack)||e.stop(),this.mediaTrack=null,this.uninstallEvents())}setMute(e){return!!this.mediaTrack&&(this.mediaTrack.enabled=!e,this.emit(e?"mute":"unmute",this),WP.emit(e?KP.TRACK_MUTED:KP.TRACK_UNMUTED,{track:this}),!0)}setPlayerMute(e){this.playerMuted=e,this.player.setMuted(e)}setMediaStream(e){e!==this.mediaStream&&(this.mediaStream=e)}setMediaStreamTrack(e){this.mediaStream||(this.mediaStream=new MediaStream),this.mediaTrack&&this.mediaStream.removeTrack(this.mediaTrack);let t=this.mediaTrack;this.mediaTrack=e,this.mediaTrack&&(this.mediaTrack.enabled=!this.muted,this.mediaStream.addTrack(this.mediaTrack),this.isRemote||this.player.setTrack(this.mediaTrack)),this.updatePlayingState(!!e),this.emit("media-track-changed",this.mediaTrack,t)}setMediaType(e){this.mediaType=e}updatePlayingState(e){!this.isPlayCalled||e&&!this.player.isStopped||!e&&this.player.isStopped||this.isPlayCalled&&this.player.isStopped===e&&(this.log.info("playing state updated, ".concat(e?"play":"stop"," ").concat(this.kind)),e&&this.player.isStopped&&this.player.play(),!e&&!this.player.isStopped&&this.player.stop())}};DA([eN([],aN.INIT)],QN.prototype,"close",1),PA(XA(),1),PA(XA(),1);var YN=Object.prototype.hasOwnProperty;var XN=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(sP(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(YN.call(e,t))return!1;return!0}return!1};PA(XA(),1);var $N=PA($A(),1),ZN=e=>t=>t.deviceId===e,eO=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";NA(this,"kind"),NA(this,"type"),NA(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let i=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));t&&(i.forEach((e=>{if(e.deviceId&&!this.devices.find(ZN(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Added");QP.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!i.find(ZN(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Removed");QP.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=i}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},tO=class extends $N.EventEmitter{constructor(){super(),NA(this,"audioInputs",new eO(bC)),NA(this,"videoInputs",new eO(kC)),NA(this,"audioOutputs",new eO(bC,"Output")),this.init(),navigator.mediaDevices&&navigator.mediaDevices.addEventListener("devicechange",this.update.bind(this))}init(){rO().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return MA(this,null,(function*(){let e=yield rO();return this.audioInputs.update(e,this),this.videoInputs.update(e,this),this.audioOutputs.update(e,this),this}))}},iO=cC||sC?null:new tO;function rO(){return MA(this,null,(function*(){return hD()||!dD()?[]:(yield navigator.mediaDevices.enumerateDevices()).map(((e,t)=>{let i={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&sO.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(i.getCapabilities=()=>e.getCapabilities()),i}))}))}function nO(){return iO.update().then((e=>e.audioInputs.devices))}function oO(){return iO.update().then((e=>e.videoInputs.devices))}function aO(){return MA(this,null,(function*(){return iO.update().then((e=>e.audioOutputs.devices))}))}var sO=new Set;function cO(e,t){return MA(this,null,(function*(){let i=(yield nO()).find((e=>e.deviceId===Pb));return(null==i?void 0:i.groupId)===e&&i.label===t}))}var lO=GP({retryFunction:function(e){return MA(this,null,(function*(){let t,i,r=yield function(e){return MA(this,null,(function*(){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression};if(e.audio)if(XN(e.microphoneId)){t=CA({sampleRate:e.sampleRate,channelCount:e.channelCount},t);let i=(yield nO()).filter((e=>{let{deviceId:t}=e;return t.length>0}));i.length>0&&(t.deviceId={exact:i[0].deviceId})}else t=CA({deviceId:e.useExact?{exact:e.microphoneId}:e.microphoneId,sampleRate:e.sampleRate,channelCount:e.channelCount},t);else t=!1;let i={},r={ideal:e.width,max:e.width},n={ideal:e.height,max:e.height};return $b&&bk&&e.width*e.height<101376&&(r=e.width,n=e.height),i=!hP(e.facingMode)&&e.video?{facingMode:e.facingMode,width:r,height:n,frameRate:e.frameRate}:!XN(e.cameraId)&&e.video?{deviceId:e.useExact?{exact:e.cameraId}:e.cameraId,width:r,height:n,frameRate:e.frameRate}:!!e.video&&(!!hP(e.width)||{width:r,height:n,frameRate:e.frameRate}),{audio:t,video:i}}))}(e);QP.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),r.audio&&(t=yield nO(),QP.info("microphones: ".concat(JSON.stringify(t)))),r.video&&(i=yield oO(),QP.info("cameras: ".concat(JSON.stringify(i))));try{return yield navigator.mediaDevices.getUserMedia(r)}catch(QO){if("NotFoundError"===QO.name){if(i&&0===i.length)throw new nD({code:iD.DEVICE_NOT_FOUND,message:Jw({key:Mw})});if(t&&0===t.length)throw new nD({code:iD.DEVICE_NOT_FOUND,message:Jw({key:Ow})})}throw new nD({code:iD.INITIALIZE_FAILED,name:QO.name,message:QO.message,constraint:QO.constraint})}}))},settings:{retries:3,timeout:500},onError:(e,t,i)=>{"NotReadableError"===e.name?t():i(e)},onRetrying:e=>{QP.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))}});var dO=lO;function uO(e){return pO(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return MA(this,null,(function*(){return yield e.apply(this,r),t.apply(this,r)}))}))}function hO(e){return pO(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return MA(this,null,(function*(){return e.call(this,t.apply(this,r))}))}))}function pO(e){return function(t,i,r){return r.value=e(r.value,i),r}}PA(XA(),1);var mO=class extends QN{constructor(e){super({mediaType:e}),NA(this,"isRemote",!1),NA(this,"deviceId"),NA(this,"groupId",""),NA(this,"label",""),NA(this,"_isRecapturing",!1),NA(this,"_lastRecaptureTime",0),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this)}installTrackEvent(e){e.addEventListener(xC,this.onTrackMuted),e.addEventListener(VC,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===VC&&this.onTrackEnded()}uninstallTrackEvent(e){e.removeEventListener(xC,this.onTrackMuted),e.removeEventListener(VC,this.onTrackEnded)}setStateToCapture(){}capture(e){return MA(this,null,(function*(){try{let t;WP.emit(KP.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(t=new MediaStream,t.addTrack(e.customSource)):t=yield dO(e);let i=t.getTracks()[0];return this.setMediaStream(t),this.setMediaStreamTrack(i),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),WP.emit(KP.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this}),t}catch(t){throw WP.emit(KP.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:t}),this.log.error("getUserMedia error observed ".concat(t)),t}}))}setMediaStreamTrack(e){this.state===aN.INIT&&this.setStateToCapture(),this.mediaTrack&&this.uninstallTrackEvent(this.mediaTrack),super.setMediaStreamTrack(e),e&&this.installTrackEvent(e)}setPublishStarting(){}setPublishStarted(){}setPublishStopped(e,t){}publish(e){this.room=e,this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),WP.emit(KP.LOCAL_TRACK_PUBLISHED,{track:this}),this.setPublishStarted()}unpublish(){this.room=void 0,2===this.mediaType&&(this.mediaType=4),WP.emit(KP.LOCAL_TRACK_UNPUBLISHED,{track:this}),this.setPublishStopped("api-call")}get isPublishing(){return"publish"===this.state}updateDeviceIdInUse(){return MA(this,null,(function*(){if(this.mediaTrack&&xD){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings();(yield function(e){return MA(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:i,oldGroupId:r,oldLabel:n,kind:o}=e;return function*(){return t===i&&(o!==bC||t!==Pb||(yield cO(r,n)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=this.mediaTrack.label,t&&(this.groupId=t),rO().then((t=>{let i=t.find((t=>t.deviceId===e));i&&this.emit("2",i)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===bC&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(GC);return!!sO.has(i)}(this.mediaTrack)||this.kind===kC&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(WC);return!!sO.has(i)}(this.mediaTrack)||this._isRecapturing||e&&(bk&&Jk||Yb&&Number(Kk)>=15.1))}onTrackMuted(){if(this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<Ob)return void setTimeout((()=>this.onTrackMuted()),Ob);setTimeout((()=>{var e;(null==(e=this.mediaTrack)?void 0:e.muted)&&"visible"===document.visibilityState&&this.recapture(this.deviceId)}),5e3)}}onTrackEnded(){if(this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<Ob)return void setTimeout((()=>this.onTrackEnded()),Ob);this.recapture(this.deviceId)}}recapture(e){return MA(this,null,(function*(){var t;if(this._isRecapturing||!this.mediaTrack)return;let i;return this.log.warn("recapture trying"),null==(t=this.mediaTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now(),("audio"===this.kind?yield nO():yield oO()).find((t=>t.deviceId===e))&&(i=e),this.capture({deviceId:i,useExact:!0}).then((()=>{var e;return null==(e=this.room)?void 0:e.replaceTrack(this)})).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e)}))}))}};DA([eN(aN.INIT,"capture")],mO.prototype,"setStateToCapture",1),DA([eN("capture","publish_starting",{success(){this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"})}})],mO.prototype,"setPublishStarting",1),DA([eN("publish_starting","publish",{success(){this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"})}})],mO.prototype,"setPublishStarted",1),DA([pO((e=>function(t,i){e.call(this,t,i),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"publish_starting"===this.state.oldState?"starting":"started",reason:t,error:i})})),eN(["publish","publish_starting"],"capture",{ignoreError:!0})],mO.prototype,"setPublishStopped",1),PA(XA(),1);var _O=class extends mO{constructor(){super(1),NA(this,"mediaType",1),NA(this,"volume",0),NA(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),NA(this,"playerMuted",!0)}getAudioLevel(){return this.volume||super.getAudioLevel()}capture(){let{deviceId:e,useExact:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.capture({video:!1,audio:!0,microphoneId:e,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExact:t})}switchDevice(e){return MA(this,null,(function*(){if(this.mediaStream&&this.mediaTrack){if(this.deviceId===e){if(e!==Pb)return;if(yield cO(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExact:!0}),this.room&&(yield this.room.replaceTrack(this)),WP.emit(KP.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(t){throw this.log.error("switch microphone failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}}))}listenDeviceChange(){iO&&!iO.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&iO.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return MA(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e)));let t=yield nO();t[0]?this.recapture(t[0].deviceId):iO.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){return MA(this,null,(function*(){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}))}close(){iO.off("audioInputAdded",this.handleMicrophoneAdded,this),iO.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}};PA(XA(),1);var fO=class extends mO{constructor(){super(4),NA(this,"mediaType",4),NA(this,"profile",{width:640,height:480,frameRate:15,bitrate:900}),NA(this,"states",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0}),NA(this,"small"),NA(this,"facingMode"),NA(this,"_canvas"),NA(this,"_canvasInterval"),NA(this,"canvasTrack")}capture(){let{deviceId:e,facingMode:t,useExact:i=!1,customSource:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return super.capture({audio:!1,video:!0,facingMode:t||this.facingMode,cameraId:e,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExact:i,customSource:r})}genCanvasTrack(){if(this.canvasTrack||!this.mediaTrack)return;this.log.info("gen canvas track");let{width:e,height:t,frameRate:i}=this.mediaTrack.getSettings();this._canvas=document.createElement("canvas");let r=this._canvas.getContext("2d");e&&t&&(this._canvas.width=e,this._canvas.height=t),this._canvasInterval=uN.run(Lb,(()=>{if(!this._canvas)return;if(this.mediaTrack){let e=this.mediaTrack.getSettings();(e.width!==this._canvas.width||e.height!==this._canvas.height)&&(this._canvas.width=e.width,this._canvas.height=e.height)}let e=this.player.getElement();e&&(null==r||r.drawImage(e,0,0,this._canvas.width,this._canvas.height))}),{fps:Math.max(15,i||0)});let n=this._canvas.captureStream();this.canvasTrack=n.getVideoTracks()[0]}destoryCanvasTrack(){this._canvasInterval&&(uN.clearTask(this._canvasInterval),this._canvasInterval=void 0,this._canvas=void 0,this.canvasTrack=void 0)}setProfile(e){var t;if(!e)return;let i=e.bitrate&&e.bitrate!==this.profile.bitrate;return super.setProfile(e),null==(t=this.mediaTrack)?void 0:t.applyConstraints({width:e.width,height:e.height,frameRate:e.frameRate}).then((()=>{if(i&&this.room&&this.room.setBandWidth)return this.room.setBandWidth({bandwidth:e.bitrate,type:kC,videoType:DC})}))}switchDevice(e){return MA(this,null,(function*(){try{if(!this.mediaStream||this.deviceId===e||this.facingMode===e)return;(e===MC||e===LC)&&(this.facingMode=e,e=void 0),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExact:!0}),this.room&&(yield this.room.replaceTrack(this)),WP.emit(KP.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(t){throw this.log.error("switch camera failed ".concat(t)),this.deviceId&&this.recapture(this.deviceId),t}}))}listenDeviceChange(){iO&&!iO.listeners("audioInputRemoved").includes(this.handleCameraRemoved)&&iO.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return MA(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e)));let t=yield oO();t[0]?this.recapture(t[0].deviceId):iO.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return MA(this,null,(function*(){this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}))}close(){iO.off("videoInputAdded",this.handleCameraAdded,this),iO.off("videoInputRemoved",this.handleCameraRemoved,this),this.destoryCanvasTrack(),super.close()}};PA(XA(),1),PA(XA(),1);function gO(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return hP(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}function vO(e){let t={systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},i={width:Jk?{max:e.width}:{ideal:e.width,max:e.width},height:Jk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:"monitor"};if(t.video=i,!hP(e.systemAudio)){let{echoCancellation:i=!0,noiseSuppression:r=!1,autoGainControl:n=!1}=e;t.audio={echoCancellation:i,noiseSuppression:r,autoGainControl:n,sampleRate:48e3}}return t}var TO=function(e){return MA(this,null,(function*(){let t=null;if(Hk&&Gk<74||Jk){let i=vO(e);QP.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let r=yield navigator.mediaDevices.getDisplayMedia(i);if(e.systemAudio)return QP.warn("Your browser not support capture system audio"),r;if(e.audio){let i=gO(e);return QP.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),r.addTrack(t.getAudioTracks()[0]),r}return r}if(e.systemAudio){let t=vO(e);return QP.info("getDisplayMedia with constraints: ".concat(JSON.stringify(t))),yield navigator.mediaDevices.getDisplayMedia(t)}let i=vO(e);QP.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let r=yield navigator.mediaDevices.getDisplayMedia(i);if(e.audio){let i=gO(e);return QP.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),r.addTrack(t.getAudioTracks()[0]),r}return r}))},SO=class extends fO{constructor(){super(),NA(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),NA(this,"objectFit","contain"),NA(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(){return MA(this,arguments,(function(){var e=this;let{systemAudio:t=!1,autoGainControl:i,echoCancellation:r,noiseSuppression:n,audioTrack:o,videoTrack:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){try{let s;return a||o?(s=new MediaStream,a&&s.addTrack(a),o&&s.addTrack(o)):s=yield TO({audio:!1,systemAudio:t,width:e.profile.width,height:e.profile.height,frameRate:e.profile.frameRate,autoGainControl:i,echoCancellation:r,noiseSuppression:n}),e.setMediaStream(s),e.setMediaStreamTrack(s.getVideoTracks()[0]),s}catch(s){throw e.log.error("getDisplayMedia error observed ".concat(s)),s instanceof nD?s:new nD({code:iD.INITIALIZE_FAILED,name:s.name,message:s.message})}}()}))}switchDevice(e){return MA(this,null,(function*(){throw new Error("Method not implemented.")}))}};PA(XA(),1);var yO=class extends _O{constructor(){super(),this._log.id="s-".concat(this._log.id)}setScreenAudioTrack(e,t){this.setMediaStream(t),this.setMediaStreamTrack(e)}};PA(XA(),1),PA(XA(),1);var EO=PA($A(),1),IO=["abort","canplay","canplaythrough","durationchange","emptied","ended","error","interruptbegin","interruptend","loadedmetadata","loadstart","mozaudioavailable","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting"],RO=class extends EO.default{constructor(e){super(),NA(this,"audioContext"),NA(this,"destination"),NA(this,"source",null),NA(this,"audio"),NA(this,"id"),this.audioContext=RP(),this.initAudioContext(),this.destination=this.audioContext.createMediaStreamDestination(),this.audio=document.createElement("audio"),this.audio.crossOrigin="anonymous",this.audio.src=e.url,"boolean"==typeof e.loop&&(this.audio.loop=e.loop),e.volume&&this.setVolume(e.volume),e.id&&(this.id=e.id),this.source=this.audioContext.createMediaElementSource(this.audio),this.source.connect(this.destination),IO.forEach((e=>{this.audio.addEventListener(e,this.handleAudio.bind(this))}))}initAudioContext(){let e=this.audioContext,t=()=>{"suspended"===e.state?(e.resume(),document.addEventListener("click",t)):"interrupted"===e.state?e.resume():document.removeEventListener("click",t)};document.addEventListener("click",t),e.onstatechange=()=>{QP.info("audioSource context state: ".concat(e.state)),t()}}destroy(){var e,t;null==(e=this.source)||e.disconnect(),null==(t=this.destination)||t.disconnect(),this.audio&&(IO.forEach((e=>{this.audio.removeEventListener(e,this.handleAudio.bind(this))})),this.audio.pause(),this.audio.removeAttribute("src"),this.audio.removeAttribute("srcObject"),this.audio.load()),this.audioContext.close().then((()=>{this.source=null,this.destination=null,this.audioContext=null}))}handleAudio(e){this.emit(e.type,e)}getStream(){var e;return(null==(e=this.destination)?void 0:e.stream)||null}play(){this.audio&&this.audio.play().then((()=>{})).catch((e=>{this.emit("error",e)}))}pause(){this.audio&&this.audio.pause()}resume(){this.audio&&(this.audio.pause(),this.audio.currentTime=0)}stop(){this.audio&&(this.audio.pause(),this.audio.currentTime=0)}setPosition(e){e<0&&e>this.duration()?QP.error("Time beyond song duration."):this.audio&&(this.audio.currentTime=e)}getPosition(){if(this.audio)return this.audio.currentTime}setVolume(e){if(e>1&&e<0)throw new Error("音量超出限制");this.audio&&(this.audio.volume=e)}getVolume(){if(this.audio)return this.audio.volume}setPlayBackRate(e){if(e>8&&e<0)throw new Error("速率超出限制");this.audio&&(this.audio.playbackRate=e)}getPlayBackRate(){if(this.audio)return this.audio.playbackRate}duration(){return this.audio&&this.audio.duration||0}loop(e){if(void 0===e)return this.audio&&this.audio.loop;this.audio&&"boolean"==typeof e&&(this.audio.loop=e)}};PA(XA(),1),PA(XA(),1);var AO=class extends QN{constructor(e,t,i){super({userId:t.userId,sdkAppId:e.sdkAppId,mediaType:i}),this.room=e,this.user=t,NA(this,"userId"),NA(this,"tinyId"),NA(this,"isRemote",!0),this.tinyId=t.tinyId,this.userId=t.userId}play(e,t){return this.hasFlag?super.play(e,t):(this.isPlayCalled=!0,this.container=e,e&&this.player.setContainer(e),Promise.resolve())}setMute(e){return this.hasFlag&&super.setMute(e)}setMediaStreamTrack(e){super.setMediaStreamTrack(e),this.mediaTrack&&this.hasFlag&&this.isSubscribed&&this.player.setTrack(this.mediaTrack)}get isSubscribed(){return this.state===AO.STATE_SUBSCRIBE}get streamType(){return 0==(2&this.mediaType)?"main":"auxiliary"}subscribe(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.mediaTrack&&this.hasFlag&&this.player.setTrack(this.mediaTrack),this.updatePlayingState(!0),e&&WP.emit(KP.REMOTE_TRACK_SUBSCRIBED,{track:this})}unsubscribe(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.player.setTrack(null),this.updatePlayingState(!1),e&&WP.emit(KP.REMOTE_TRACK_UNSUBSCRIBED,{track:this}),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}onFlagChanged(){this.updatePlayingState(this.hasFlag),this.mediaTrack&&this.hasFlag&&this.player.setTrack(this.mediaTrack)}},CO=AO;NA(CO,"STATE_SUBSCRIBE","subscribe"),DA([eN(aN.INIT,CO.STATE_SUBSCRIBE)],CO.prototype,"subscribe",1),DA([eN(CO.STATE_SUBSCRIBE,aN.INIT)],CO.prototype,"unsubscribe",1);var bO=class extends CO{constructor(e,t){super(e,t,1),NA(this,"volume",0),NA(this,"mediaType",1),NA(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0})}getAudioLevel(){return this.volume||super.getAudioLevel()}get hasFlag(){return this.user.muteState.hasAudio&&!this.user.muteState.audioMuted}isFlagChanged(e){let t=e.hasAudio&&!e.audioMuted;return this.hasFlag||(this.volume=0),this.hasFlag!==t}};PA(XA(),1);var kO=class extends CO{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),NA(this,"mediaType",4),NA(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0})}changeType(e){this.room.changeType(e,this.user)}get hasFlag(){return this.user.muteState.hasVideo&&!this.user.muteState.videoMuted}isFlagChanged(e){let t=e.hasVideo&&!e.videoMuted;return this.hasFlag!==t}},wO=class extends kO{constructor(e,t){super(e,t,2),NA(this,"mediaType",2),NA(this,"objectFit","contain")}get hasFlag(){return this.user.muteState.hasAuxiliary}isFlagChanged(e){let t=e.hasAuxiliary;return this.hasFlag!==t}};function PO(){}PA(XA(),1),PA(XA()),PA(XA());var DO=e=>e(),NO=1,OO=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new VO(e,this,this.streamId++);return FO.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},MO=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=PO,this.error=PO,this.next=PO,this.dispose=PO,this.subscribe=PO,this.doDefer()}subscribe(e){return e instanceof OO?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(DO),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},LO=class extends MO{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}};function xO(e,t,i){if("undefined"!=typeof __FASTRX_DEVTOOLS__){let r=Object.defineProperties(Object.setPrototypeOf(e,OO.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:i,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});FO.create(r);for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t&&t instanceof OO&&FO.addSource(r,t)}return r}return e}function UO(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var VO=class extends LO{constructor(e,t,i){super(e),this.source=t,this.id=i,this.sourceId=e.sourceId,this.defer((()=>{FO.defer(this.source,this.id)}))}next(e){FO.next(this.source,this.id,e),this.sink.next(e)}complete(){FO.complete(this.source,this.id),this.sink.complete()}error(e){FO.complete(this.source,this.id,e),this.sink.error(e)}},FO={addSource(e,t){UO("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,i){UO("next",{id:e.id,streamId:t,data:i&&i.toString()})},subscribe(e,t){let{id:i,end:r}=e;UO("subscribe",{id:i,end:r,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,i){UO("complete",{id:e.id,streamId:t,err:i?i.toString():null})},defer(e,t){UO("defer",{id:e.id,streamId:t})},pipe(e){UO("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){UO("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=NO++),UO("create",{name:e.toString(),id:e.id})}};PA(XA()),PA(XA());var jO=class extends MO{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}};PA(XA()),PA(XA()),PA(XA());var BO,HO,GO=(BO=class extends LO{constructor(e,t,i){super(e),this.mapper=t,this.thisArg=i}next(e){super.next(this.mapper.call(this.thisArg,e))}},HO="map",function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return e=>{if(e instanceof OO){let i=xO((r=>{let n=new BO(r,...t);n.sourceId=i.id,n.subscribe(e)}),HO,arguments);return i.source=e,FO.pipe(i),i}return i=>e(new BO(i,...t))}});PA(XA()),function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];i.reduce(((e,t)=>t(e)),e)}(function(e){return xO((t=>{let i=0,r=setInterval((()=>t.next(i++)),e);return t.defer((()=>{clearInterval(r)})),"interval"}),"interval",arguments)}(250),GO((()=>performance.now())),function(){return e=>{let t=new jO(e);if(e instanceof OO){let i=xO((e=>{t.add(e)}),"share",arguments);return t.sourceId=i.id,i.source=e,FO.pipe(i),i}return xO(t.add.bind(t),"share",arguments)}}()),PA(XA(),1);var WO=new Map;function JO(e,t){let i=bA(CA({},t),{timestamp:Vb()});WO.has(e)?WO.get(e).push(i):WO.set(e,[i])}WP.on(KP.JOIN_SUCCESS,(e=>{let{room:t}=e;JO(t.userId,{eventId:32788,eventDesc:"join room"})})),WP.on(KP.LEAVE_START,(e=>{let{room:t}=e;JO(t.userId,{eventId:32789,eventDesc:"leave room"})})),WP.on(KP.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;t.room&&JO(t.room.userId,{eventId:t.kind===bC?32769:32768,eventDesc:"publish ".concat(t.kind)})})),WP.on(KP.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;t.room&&JO(t.room.userId,{eventId:t.kind===bC?32771:32770,eventDesc:"unpublish ".concat(t.kind)})})),WP.on(KP.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===bC?JO(t.room.userId,{eventId:t.isRemote?32785:32772,eventDesc:"mute audio",remoteUserId:t.isRemote?t.userId:void 0}):JO(t.room.userId,{eventId:t.isRemote?32784:32773,eventDesc:"mute video",remoteUserId:t.isRemote?t.userId:void 0}))})),WP.on(KP.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===bC?JO(t.room.userId,{eventId:t.isRemote?32787:32774,eventDesc:"unmute audio",remoteUserId:t.isRemote?t.userId:void 0}):JO(t.room.userId,{eventId:t.isRemote?32786:32775,eventDesc:"unmute video",remoteUserId:t.isRemote?t.userId:void 0}))})),WP.on(KP.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;1===t.mediaType&&JO(t.room.userId,{eventId:32777,eventDesc:"".concat(KC," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&JO(t.room.userId,{eventId:32776,eventDesc:"".concat(KC," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&JO(t.room.userId,{eventId:32803,eventDesc:"".concat(KC," ").concat(OC),remoteUserId:t.userId})})),WP.on(KP.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;1===t.mediaType&&JO(t.room.userId,{eventId:32779,eventDesc:"".concat(qC," ").concat(t.kind),remoteUserId:t.userId}),4===t.mediaType&&JO(t.room.userId,{eventId:32778,eventDesc:"".concat(qC," ").concat(t.kind),remoteUserId:t.userId}),8===t.mediaType&&JO(t.room.userId,{eventId:32804,eventDesc:"".concat(qC," ").concat(OC),remoteUserId:t.userId})})),WP.on(KP.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&JO(t.room.userId,{eventId:t.kind===kC?32780:32781,eventDesc:"switch ".concat(t.kind===kC?"camera":"microphone")})})),WP.on(KP.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&JO(t.room.userId,{eventId:t.kind===kC?32782:32783,eventDesc:"replace ".concat(t.kind)})})),WP.on(KP.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o}=e;switch(o){case"CONNECTED":"RECONNECTING"===n?(t=32795,i="signal reconnected"):(t=32791,i="signal connected");break;case"DISCONNECTED":"RECONNECTING"===n?(t=32796,i="signal reconnect fail"):(t=32790,i="signal disconnected");break;case"RECONNECTING":t=32794,i="signal reconnecting"}t&&i&&JO(r.userId,{eventId:t,eventDesc:i})})),WP.on(KP.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,i,{room:r,prevState:n,state:o,remoteUserId:a}=e,s=!!a,c=s?"downlink":"uplink";switch(o){case"CONNECTED":"RECONNECTING"===n?(t=s?32801:32798,i="".concat(c," reconnected")):(t=s?32793:32792,i="".concat(c," connected"));break;case"DISCONNECTED":"RECONNECTING"===n&&(t=s?32802:32799,i="".concat(c," reconnect fail"));break;case"RECONNECTING":t=s?32800:32797,i="".concat(c," reconnecting")}t&&i&&JO(r.userId,{eventId:t,eventDesc:i,remoteUserId:a})})),PA(XA(),1),PA(XA(),1);var zO=PA($A(),1),KO=class extends zO.EventEmitter{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"userId";super(),this.mySelfId=e,this._log=t,this.key=i,NA(this,"userMap",new Map),NA(this,"remotePublishedUserMap",new Map)}getPublishedUser(e){return this.remotePublishedUserMap.get(e)}addUser(e){let t=e[this.key],{userId:i,tinyId:r,role:n}=e;if(this.userMap.has(t))return;let o={userId:i,tinyId:r,role:20===n?"anchor":"audience"};this.userMap.set(t,o),this.emit("1",o)}deleteUser(e,t){let i=this.userMap.get(e);if(!i)return;let r="peer leave [".concat(e,"]");hP(t)||(r+=":".concat(Nb[t])),this._log.info(r);let n=this.remotePublishedUserMap.get(e);if(n){let t=n.muteState;n.flag=0,this.emit("5",n.userId),this.deleteRemotePublishedUser(e),this.emit("6",{prevMuteState:t,muteState:n.muteState,flag:0})}this.userMap.delete(e),this.emit("2",i.userId)}setUserList(e){this.userMap.forEach((t=>{e.findIndex((e=>e[this.key]===t[this.key]))<0&&this.deleteUser(t[this.key],0)})),e.forEach((e=>{!this.userMap.has(e[this.key])&&e[this.key]!==this.mySelfId&&this.addUser(e)}))}addRemotePublishedUser(e){this.remotePublishedUserMap.has(e[this.key])||this.remotePublishedUserMap.set(e[this.key],e)}deleteRemotePublishedUser(e){!this.remotePublishedUserMap.has(e)||this.remotePublishedUserMap.delete(e)}setRemotePublishedUserList(e){this.remotePublishedUserMap.forEach((t=>{let i=t[this.key];if(e.findIndex((e=>e[this.key]===t[this.key]))<0){this._log.info("remote [".concat(i,"] unpublish"));let e=t.muteState;t.flag=0,this.emit("5",t.userId),this.deleteRemotePublishedUser(i),this.emit("6",{prevMuteState:e,muteState:t.muteState,flag:0})}})),e.forEach((e=>{var t;let i=e[this.key];if(i===this.mySelfId)return;let{flag:r,userId:n,tinyId:o}=e,a=OP(r,n),s=null==(t=this.remotePublishedUserMap.get(i))?void 0:t.muteState;if(s){let e=this.remotePublishedUserMap.get(i);e&&e.flag!==r&&(e.flag=r,this._log.info("remote publish updated: ".concat(JSON.stringify(e.muteState))),this.emit("6",{prevMuteState:s,muteState:a,flag:r}))}else this._log.info("remote publish. state: ".concat(JSON.stringify(a))),this.addUser({userId:n,tinyId:o,role:20}),this.emit("3",e),this.emit("6",{prevMuteState:OP(0,n),muteState:a,flag:r})}))}clear(){this.userMap.clear(),this.remotePublishedUserMap.clear()}};PA(XA());var qO={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear"};PA(XA()),PA(XA(),1);var QO,YO=((QO=YO||{})[QO.Idle=0]="Idle",QO[QO.Start=1]="Start",QO[QO.Update=2]="Update",QO[QO.Stop=3]="Stop",QO),XO=class extends Error{};function $O(e,t){let i=[];return VP(i,e),VP(i,t),i}var ZO=class{constructor(e,t){this.instance=e,this.group=t,this.currentArgs=[],this.state=0,this.started=!1,this.abortStart=!1,this.ops=[],this.startSame=()=>!0,this.mergeUpdate=$O;let i=ZO.instances.get(e);i?i.set(t,this):ZO.instances.set(e,new Map([[t,this]]))}static get(e,t){let i=ZO.instances.get(e);return i&&i.get(t)||new ZO(e,t)}action(e,t,i){var r=this;let n=this.resolve.bind(this),o=this.reject.bind(this),a=function(){for(var i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];return r.state=e,r.currentArgs=a,t(...a).then(n,o)};switch(this.state){case 0:return this.started&&1===e?Promise.reject(new XO("already started")):this.started||2!==e?a(...i):Promise.reject(new XO("not started"));case 1:if(3===e&&this.abortStart)return a(...i);default:return new Promise(((t,r)=>{let n={type:e,action(){return a(...this.args).then(t,r)},args:i,resolve:t,reject:r},o=this.cacheOp(n);o?n.reject(o):this.ops.push(n)}))}}cacheOp(e){if(this.empty)switch(this.state){case 1:case 2:if(1===e.type)return new XO("already start");break;case 3:if(1!==e.type)return new XO("".concat(YO[e.type]," not allowed when stopping"))}else switch(e.type){case 3:if(this.rejectOther(),3===this.state)return new XO("already stop");break;case 2:switch(this.lastOpType){case 2:e.args=this.mergeUpdate(this.lastOp.args,e.args),this.abortLast("merge");break;case 3:return new XO("".concat(YO[e.type]," not allowed after stop"))}break;case 1:switch(this.lastOpType){case 2:return new XO("".concat(YO[e.type]," not allowed after update"));case 1:this.abortLast("duplicate start");break;case 3:if(this.startSame(this.currentArgs,e.args))return this.abortLast("keep start"),new XO("already start")}}}rejectOther(){let e=new XO("keep stop");for(;!this.empty;)this.ops.shift().reject(e)}resolve(e){return 1===this.state?this.started=!0:3===this.state&&(this.started=!1),this.empty?this.state=0:this.ops.shift().action(),e}reject(e){throw!this.empty&&1===this.state&&this.ops.shift().reject(new XO("start failed")),this.empty?this.state=0:this.ops.shift().action(),e}abortLast(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ignore";this.ops.pop().reject(new XO(e))}get empty(){return 0===this.ops.length}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}},eM=ZO;eM.instances=new WeakMap,PA(XA()),PA(XA());var tM,iM={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},rM=((tM=rM||{})[tM.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",tM[tM.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",tM[tM.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",tM[tM.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",tM[tM.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",tM[tM.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",tM[tM.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",tM[tM.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",tM[tM.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",tM[tM.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",tM[tM.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",tM[tM.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",tM[tM.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",tM[tM.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",tM[tM.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",tM[tM.MIX_PARAMS_USER_Z_ORDER=5015]="MIX_PARAMS_USER_Z_ORDER",tM[tM.MIX_PARAMS_VIDEO_FRAMERATE=5016]="MIX_PARAMS_VIDEO_FRAMERATE",tM[tM.MIX_PARAMS_VIDEO_GOP=5017]="MIX_PARAMS_VIDEO_GOP",tM[tM.MIX_PARAMS_AUDIO_BITRATE=5018]="MIX_PARAMS_AUDIO_BITRATE",tM[tM.MIX_PARAMS_NOT_SELF=5019]="MIX_PARAMS_NOT_SELF",tM[tM.MIX_PARAMS_USER_STREAM=5020]="MIX_PARAMS_USER_STREAM",tM[tM.INVALID_OPERATION=5100]="INVALID_OPERATION",tM[tM.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",tM[tM.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",tM[tM.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",tM[tM.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",tM[tM.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",tM[tM.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",tM[tM.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",tM[tM.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",tM[tM.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",tM[tM.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",tM[tM.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",tM[tM.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",tM[tM.DEVICE_ERROR=5300]="DEVICE_ERROR",tM[tM.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",tM[tM.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",tM[tM.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",tM[tM.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",tM[tM.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",tM[tM.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",tM[tM.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",tM[tM.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",tM[tM.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",tM[tM.SERVER_ERROR=5400]="SERVER_ERROR",tM[tM.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",tM[tM.OPERATION_FAILED=5500]="OPERATION_FAILED",tM[tM.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",tM[tM.REJOIN_FAILED=5502]="REJOIN_FAILED",tM[tM.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",tM[tM.OPERATION_ABORT=5998]="OPERATION_ABORT",tM[tM.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",tM);PA(XA());var nM={INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="";return a=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(o,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(dP(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' cannot be '").concat(n,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:n}=e,o="".concat(t||i.name),a="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(o,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(dP(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:n}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(n,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,value:r}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,value:r}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(r,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be validate string when useStringRoomId is true.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294] when useStringRoomId is false.")},INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},MIX_PARAMS_USER_Z_ORDER(e){let{key:t}=e;return"'".concat(t,"' is required and must be between 1 and 15.")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not exist.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") did not publish ").concat(i.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture and publish streams, please use the https protocol.",NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",DEVICE_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server exception").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"NotFoundError, no ".concat(i," detected, please check your device and the configuration on '").concat(t,"'").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"NotAllowedError, you have disabled ".concat(i," access, please allow the current application to use the ").concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"NotReadableError, the ".concat(i," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(i,", and it is recommended to turn on the ").concat(i," after the user interacts with the page").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:i=oM(t),error:r}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:i}=e;return"‘".concat(t,"’ failed, reason: ").concat(null==i?void 0:i.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},SERVER_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server error: ").concat(null==i?void 0:i.toString(),", please check the SDK documentation.")},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' throw unknown exception").concat(i?", error: ".concat(i.toString(),"."):".")}};function oM(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var aM=class extends Error{constructor(e){let t,{code:i,extraCode:r,message:n="",messageParams:o,fnName:a="",originError:s}=e;t=n||function(e){let t,{code:i,params:r,enableDocLink:n=!1}=e,o="",s=rM[i];try{t=nM[s]}catch(a){t=nM.UNKNOWN_ERROR}return uP(t)?o=t(r):pP(t)&&(o=t),n&&(o+=" doc:"),o}({code:r||i,params:CA({fnName:a,error:s},o)}),super(t),NA(this,"name","RtcError"),NA(this,"code"),NA(this,"extraCode"),NA(this,"functionName"),NA(this,"message"),NA(this,"originError"),this.name=rM[i],this.code=i,this.extraCode=r,this.functionName=a,this.originError=s,this.message=t}static convertFrom(e,t,i){let r=e;if(e instanceof nD){let{stack:n}=e,o={code:iM.UNKNOWN_ERROR,fnName:t,originError:e};switch(e.getCode()){case iD.INVALID_PARAMETER:o.code=iM.INVALID_PARAMETER;break;case iD.INVALID_OPERATION:o.code=iM.INVALID_OPERATION;break;case iD.NOT_SUPPORTED:case iD.NOT_SUPPORTED_H264:o.code=iM.ENV_NOT_SUPPORTED,e.getCode()===iD.NOT_SUPPORTED_H264&&(o.extraCode=e.message.includes(jw.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case iD.DEVICE_NOT_FOUND:case iD.DEVICE_AUTO_RECOVER_FAILED:o.code=iM.DEVICE_ERROR;break;case iD.JOIN_ROOM_FAILED:o.messageParams={fnParams:i};case iD.SERVER_TIMEOUT:case iD.SWITCH_ROLE_FAILED:o.code=iM.SERVER_ERROR,o.extraCode=e.getExtraCode();break;case iD.API_CALL_ABORTED:o.code=iM.OPERATION_ABORT;break;case iD.INITIALIZE_FAILED:o.code=5300,o.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(e.name);break;case iD.UNKNOWN:break;default:o.code=iM.OPERATION_FAILED}r=new aM(o),n&&(r.stack+=n.substr(n.indexOf("\n")))}else r=new aM({code:iM.UNKNOWN_ERROR,fnName:t,originError:e});return r}};var sM=aM,cM=(e,t)=>{if(t instanceof XO){let{stack:i}=t;t=new sM({code:iM.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),i&&(t.stack+=i.substr(i.indexOf("\n")))}throw t};function lM(e,t){return pO(((i,r)=>function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];let s=eM.get(this,"string"==typeof e?e:e(...o));return t&&(s.startSame=t.bind(this)),s.action(1,i.bind(this),o).catch(cM.bind(null,r))}))}function dM(e,t){return pO(((i,r)=>function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];let s=eM.get(this,"string"==typeof e?e:e(...o));return t&&(s.mergeUpdate=t.bind(this)),s.action(2,i.bind(this),o).catch(cM.bind(null,r))}))}function uM(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return pO(((i,r)=>function(){for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];let s=eM.get(this,"string"==typeof e?e:e(...o));return s.abortStart=t,s.action(3,i.bind(this),o).catch(cM.bind(null,r))}))}function hM(e){return pO(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];let o=eM.get(this,"string"==typeof e?e:e(...r));return o.started=!1,t.call(this,...r)}))}PA(XA()),PA(XA());var pM="enterRoom",mM={type:Ab,properties:{cameraId:{type:yb},useFrontCamera:{type:Ib},fillMode:{type:yb,values:["contain","cover","fill"]},mirror:{type:Ib},small:{properties:{width:{type:Eb},height:{type:Eb},frameRate:{type:Eb},bitrate:{type:Eb}}},videoTrack:{instanceOf:MediaStreamTrack}}},_M={type:Ab,properties:{systemAudio:{type:Ib},fillMode:{type:yb,values:["contain","cover","fill"]},profile:{type:[yb,Ab],properties:{width:{type:Eb},height:{type:Eb},frameRate:{type:Eb},bitrate:{type:Eb}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},fM={type:[yb,HTMLElement,null],validate(e,t,i){if(pP(e)){let r=document.getElementById(e);if(!r)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5009,fnName:i,messageParams:{key:t}});if(!(r instanceof HTMLElement))throw new sM({code:iM.INVALID_PARAMETER,extraCode:5010,fnName:i,messageParams:{key:t,type:dP(r)}})}}},gM={name:"userId",required:!0,type:yb},vM={type:Ab,properties:{microphoneId:{type:yb},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:Eb,min:0,max:100},earMonitorVolume:{type:Eb,min:0,max:100},echoCancellation:{type:Ib},autoGainControl:{type:Ib},noiseSuppression:{type:Ib}}};function TM(e,t,i,r){if(!/^[A-Za-z\d_-]*$/.test(e))throw new sM({code:iM.INVALID_PARAMETER,extraCode:5011,fnName:i,messageParams:{key:t}})}function SM(e,t,i,r){if(pP(e)){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new sM({code:iM.INVALID_PARAMETER,extraCode:5012,fnName:i,messageParams:{key:t}})}else if(!(/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new sM({code:iM.INVALID_PARAMETER,extraCode:5013,fnName:i,messageParams:{key:t}})}function yM(e,t){if(!e)throw new sM({code:iM.INVALID_OPERATION,extraCode:5101,fnName:t})}function EM(e,t,i){if(!e)throw new sM({code:iM.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:i}})}var IM={type:Eb,notLessThanZero:!0},RM={enterRoom:{name:"EnterRoomConfig",type:Ab,required:!0,validate(e,t){if(this._room.isJoined)throw new sM({code:iM.INVALID_OPERATION,extraCode:5104,fnName:pM})},properties:{sdkAppId:{required:!0,type:Eb,allowEmpty:!1},userId:{required:!0,type:yb,allowEmpty:!1},userSig:{required:!0,type:yb,allowEmpty:!1},scene:{type:yb,values:["live","rtc"]},role:{type:yb,values:["audience","anchor"]},roomId:{required:!0,type:[yb,Eb],validate:SM},proxy:{type:[Ab,yb],properties:{websocketProxy:{type:yb},turnServer:{type:[Ab,Rb],properties:{url:{required:!0,type:yb},username:{type:yb},credential:{type:yb},credentialType:{type:yb,values:["password"]}}},loggerProxy:{type:yb},webtransportProxy:{type:yb}}},enableAutoPlayDialog:{type:Ib},streamId:{type:yb},userDefineRecordId:{type:yb}}},startLocalVideo:{name:"LocalVideoConfig",type:Ab,properties:{view:fM,publish:{type:Ib},option:mM}},updateLocalVideo:{name:"updateLocalVideoConfig",type:Ab,required:!0,properties:{view:bA(CA({},fM),{required:!1}),publish:{type:Ib},mute:{type:Ib},option:mM}},startLocalAudio:{name:"LocalAudioConfig",type:Ab,properties:{publish:{type:Ib},option:vM}},updateLocalAudio:{name:"updateLocalAudioConfig",type:Ab,required:!0,properties:{publish:{type:Ib},mute:{type:Ib},option:vM}},startScreenShare:{name:"ScreenShareConfig",type:Ab,properties:{view:fM,publish:{type:Ib},option:_M}},updateScreenShare:{name:"updateScreenShareConfig",type:Ab,required:!0,properties:{view:fM,publish:{type:Ib},option:_M}},muteRemoteAudio:[gM,{name:"mute",required:!0,type:Ib}],setRemoteAudioVolume:[gM,{name:"volume",required:!0,type:Eb,min:0,max:100}],startRemoteVideo:{name:"startRemoteVideoConfig",type:Ab,required:!0,properties:{view:fM,userId:{type:yb,required:!0},streamType:{values:["main","sub"],required:!0},option:{type:Ab,properties:{fillMode:{type:yb,values:["contain","cover","fill"]},mirror:{type:Ib}}}},validate(e,t,i){yM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(EM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new sM({code:iM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:Ab,required:!0,properties:{view:bA(CA({},fM),{required:!1}),userId:{type:yb,required:!0},streamType:{values:["main","sub"],required:!0},option:{type:Ab,properties:{fillMode:{type:yb,values:["contain","cover","fill"]},mirror:{type:Ib}}}},validate(e,t,i){yM(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(EM(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new sM({code:iM.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:Ab,required:!0,properties:{userId:{type:yb,required:!0},streamType:{values:["main","sub"]}},validate(e,t,i){if("*"!==e.userId&&hP(e.streamType))throw new sM({code:iM.INVALID_PARAMETER,extraCode:5014,fnName:i})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,i){yM(this._room.isJoined,i)}},enableAudioVolumeEvaluation:[{name:"interval",type:Eb},{name:"enableInBackground",type:Ib}],startMixTranscode:{name:"config",required:!0,type:Ab,properties:{mode:{type:yb,values:["preset-layout","manual"]},streamId:{type:yb,validate:TM},videoWidth:IM,videoHeight:IM,videoBitrate:bA(CA({},IM),{allowEmpty:!1}),videoFramerate:{type:Eb,validate(e,t,i,r){if(e<=0||e>30)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5016,fnName:i})}},videoGop:{type:Eb,validate(e,t,i,r){if(e<1||e>8)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5017,fnName:i})}},audioSampleRate:IM,audioBitrate:{type:Eb,validate(e,t,i,r){if(e<32||e>192)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5018,fnName:i})}},audioChannels:{type:Eb,values:[1,2]},backgroundColor:{type:Eb},backgroundImage:{type:yb},mixUsers:{required:!0,type:Rb,arrayItem:{require:!0,type:Ab,properties:{userId:{required:!0,type:yb},roomId:{type:[yb,Eb],validate:SM},pureAudio:{type:Ib},width:IM,height:IM,locationX:IM,locationY:IM,zOrder:{type:Eb},streamType:{values:["main","sub"]},renderMode:{type:Eb,values:[0,1,2,4]}}}}},validate(e,t,i,r){let n=0,o=0,{mixUsers:a}=e,s=[];if(a.forEach(((e,t)=>{if(s.push(e.userId),!e.pureAudio){if(!e.zOrder||e.zOrder<1||e>15)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5015,fnName:i,messageParams:{key:"config.mixUsers[".concat(t,"].zOrder")}});e.width+e.locationX>n&&(n=e.width+e.locationX),e.height+e.locationY>o&&(o=e.height+e.locationY)}})),s.indexOf(this._room.userId)<0)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5019,fnName:i});if(e.videoWidth<n||e.videoHeight<o)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5020,fnName:i})}},startPublishCDNStream:{name:"options",required:!1,properties:{streamId:{type:yb,validate:TM},streamType:{values:["main","sub"]},appId:{type:Eb,allowEmpty:!1},bizId:{type:Eb,allowEmpty:!1},url:{type:yb,allowEmpty:!1}}}},AM={TRTC:RM};function CM(e){return"sub"===e?"auxiliary":"main"}function bM(e){return e===qO.QOS_PREFERENCE_CLEAR?"detail":e===qO.QOS_PREFERENCE_SMOOTH?"motion":""}PA(XA());function kM(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return pO(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{PM.call(this,t,n,i,this._name)}catch(QO){return Promise.reject(QO)}return e.apply(this,n)}))}function wM(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return pO(((e,i)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];try{PM.call(this,t,n,i,this._name)}catch(QO){throw QO}return e.apply(this,n)}))}function PM(e,t,i,r){if(gP(e))for(let n=0;n<e.length;n++)DM.call(this,{rule:e[n],value:t[n],key:e[n].name,fnName:i,className:r});else DM.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:r})}function DM(e){let{rule:t,value:i,key:r,fnName:n,className:o}=e;function a(e){return{code:iM.INVALID_PARAMETER,extraCode:e,fnName:n,messageParams:{key:r,rule:t,value:i}}}if(hP(i)){if(t.required)throw new sM(a(5001));if(hP(t.defaultValue))return;i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let r=0;r<t.type.length;r++)null===t.type[r]&&null===i&&(e=!0),uP(t.type[r])&&i instanceof t.type[r]&&(e=!0),pP(t.type[r])&&dP(i)===t.type[r].toLowerCase()&&(e=!0);if(!e)throw new sM({code:iM.INVALID_PARAMETER,extraCode:5002,fnName:n,messageParams:{key:r,rule:{type:t.type.map((e=>yP(e)?EP(e):pP(e)?e:dP(e)))},value:i}})}else if(!hP(t.type)&&dP(i)!==t.type)throw new sM(a(5002));if(!1===t.allowEmpty){let e=mP(i)&&(0===i||Number.isNaN(i)),t=pP(i)&&""===i.trim();if(e||t)throw new sM(a(5003))}if(t.notLessThanZero&&mP(i)&&i<0)throw new sM(a(5006));if(!hP(t.min)&&mP(i)&&i<t.min)throw new sM(a(5007));if(!hP(t.max)&&mP(i)&&i>t.max)throw new sM(a(5008));if(pP(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new sM(a(5004))}else if(uP(t.instanceOf)&&!(i instanceof t.instanceOf))throw new sM(a(5004));if(t.values&&!t.values.includes(i))throw new sM(a(5005));let{properties:s}=t;sP(s)&&fP(i)&&Object.keys(s).forEach((e=>{DM.call(this,{rule:s[e],value:i&&i[e],key:"".concat(e),fnName:n,className:o})}));let{arrayItem:c}=t;sP(c)&&gP(i)&&i.forEach(((e,t)=>{DM.call(this,{rule:c,value:e,key:"".concat(r,"[").concat(t,"]"),fnName:n,className:o})})),uP(t.validate)&&t.validate.call(this,i,r,n,o,this)}function NM(){return pO(((e,t)=>function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];let o=this._log||loggerManager;r.length>0?o.info("".concat(t,"() ").concat(JSON.stringify(r,((e,t)=>{if(t===r||e in r)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(dP(t)):(JSON.stringify(t),t)}catch(aC){return"type:".concat(dP(t))}})))):o.info("".concat(t,"()"));try{let i=e.apply(this,r),n=bP();return SP(i)?i.then((e=>(o.info("".concat(t,"() success")),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:t,cost:bP()-n}),e))).catch((e=>{throw e=sM.convertFrom.call(this,e,t,1===r.length?r[0]:r),o.error("".concat(t,"() failed ").concat(e)),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:t,error:e}),e})):(WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:t,cost:bP()-n}),i)}catch(QO){throw QO=sM.convertFrom.call(this,QO,t),o.error("".concat(t,"() failed ").concat(QO)),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:t,error:QO}),QO}}))}PA(XA()),PA(XA()),PA(XA(),1);var OM=new WeakMap;var MM=0,LM=new Set,xM=null;!function(e){oC=e;let[t,i,r]=e.split(".").map((e=>parseInt(e,10)));nC="".concat(t,".").concat(Math.min(15,i),".").concat(Math.min(15,r),".").concat(i.toString().padStart(2,"0")).concat(r.toString().padStart(2,"0"))}("5.0.0-beta");var UM=class extends XP.EventEmitter{constructor(e,t){super(),NA(this,"_room"),NA(this,"_eventListened",new Set),NA(this,"_localVideoTrack",null),NA(this,"_localAudioTrack",null),NA(this,"_localScreenTrack",null),NA(this,"_localScreenAudioTrack",null),NA(this,"_localVideoConfig",null),NA(this,"_localScreenConfig",null),NA(this,"_localAudioConfig",null),NA(this,"_remoteVideoConfigMap",new Map),NA(this,"_remoteAudioConfigMap",new Map),NA(this,"_remoteAudioMuteMap",new Map),NA(this,"_log",QP.createLogger({id:"t".concat(MM)})),this._room=new e(CA({logger:this._log,frameWorkType:UM.frameWorkType},t)),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),this.emit($P.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this.on($P.REMOTE_AUDIO_UNAVAILABLE,(e=>{let{userId:t}=e;this._stopRemoteAudio({userId:t},!1).catch((()=>{}))})),this.on($P.REMOTE_VIDEO_UNAVAILABLE,(e=>{let{userId:t,streamType:i}=e;this._stopRemoteVideo({userId:t,streamType:i},!1).catch((()=>{}))})),VN(iO,iO).add("audioInputAdded",(e=>{this.emit($P.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit($P.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit($P.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit($P.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>MA(this,null,(function*(){if(this.emit($P.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),xM&&xM.deviceId===Db){let e=(yield aO()).find((e=>e.deviceId===Db));e&&xM.groupId!==e.groupId&&(xM=e,this.emit($P.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>MA(this,null,(function*(){this.emit($P.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield aO())[0];t&&xM&&(xM.deviceId===e.deviceId||xM.deviceId===Db&&xM.groupId!==t.groupId)&&(xM=t,this.emit($P.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))})))),kP(this,"trtc")}static create(){}static _create(e,t){MM+=1,function(){var e;YP&&(YP=!1,5!==QP.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(_C,"index.html")),console.info("* Changelog: https://cloud.tencent.com/document/product/647/38958"),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),QP.info("TRTC Web SDK Version:",oC),QP.info("UA:",navigator.userAgent),QP.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")))}();let i=new UM(e,t);return LM.add(i),xM?i.emit($P.DEVICE_CHANGED,{type:"speaker",action:"active",device:xM}):aO().then((e=>{e[0]&&(xM=e[0],i.emit($P.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]}))})),i}enterRoom(e){return MA(this,null,(function*(){var t,i;let{scene:r="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:o=!0,autoReceiveVideo:a=!0}=e;e.proxy&&(this._room.setProxyServer(e.proxy),!pP(e.proxy)&&e.proxy.turnServer&&(null==(i=(t=this._room).setTurnServer)||i.call(t,e.proxy.turnServer,e.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=o,this._room.autoReceiveVideo=a;let s={sdkAppId:e.sdkAppId,userId:e.userId,userSig:e.userSig,privateMapKey:e.privateMapKey||null,role:"audience"===e.role?21:20,roomId:0,strRoomId:"",businessInfo:e.businessInfo||null,streamId:e.streamId||null,userDefineRecordId:e.userDefineRecordId||null};pP(e.roomId)?(s.strRoomId=e.roomId,this._room.useStringRoomId=!0):s.roomId=e.roomId,VN(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit($P.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit($P.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{this._exitRoom().then((()=>{this.emit($P.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().then((()=>{this.emit($P.ERROR,sM.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit($P.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this.emit($P.NETWORK_QUALITY,e)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{VN(t,t).add("player-state-changed",(i=>{let r=bA(CA({},i),{userId:e.userId});t.kind===kC&&(r.streamType=CM(t.streamType)),this.emit(t.kind===bC?$P.AUDIO_PLAY_STATE_CHANGED:$P.VIDEO_PLAY_STATE_CHANGED,r)})).add("error",(e=>{e.getCode()===iD.PLAY_NOT_ALLOWED&&this.emit($P.AUTOPLAY_FAILED)}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{FN(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:i}=e,{userId:r}=i;this._room.remotePublishedUserMap.get(r);let n=t.audioAvailable,o=t.videoAvailable,{audioAvailable:a,videoAvailable:s}=i;a||this._remoteAudioConfigMap.delete(r),s||this._remoteVideoConfigMap.delete("".concat(r,"_","main")),i.hasAuxiliary||this._remoteVideoConfigMap.delete("".concat(r,"_","sub")),n!==a&&this.emit(a?$P.REMOTE_AUDIO_AVAILABLE:$P.REMOTE_AUDIO_UNAVAILABLE,{userId:r}),o!==s&&this.emit(s?$P.REMOTE_VIDEO_AVAILABLE:$P.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"main"}),t.hasAuxiliary!==i.hasAuxiliary&&this.emit(i.hasAuxiliary?$P.REMOTE_VIDEO_AVAILABLE:$P.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"sub"})})).add("firewall-restriction",(()=>{this.emit($P.ERROR,new sM({code:iM.OPERATION_FAILED,extraCode:5501}))})),this._handleReceiveMode(),yield this._room.join(s,r,UM.frameWorkType),this._checkTrackToPublish()}))}exitRoom(){return MA(this,null,(function*(){return yield this._exitRoom()}))}switchRole(e){return MA(this,null,(function*(){yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){FN(iO),this.removeAllListeners(),this._room.destroy(),LM.delete(this),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare()}startLocalAudio(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:i=!0,option:r}=t,n=new _O,o={},a={muted:!0};r&&(hP(r.microphoneId)?hP(r.audioTrack)||(o.customSource=r.audioTrack):o.deviceId=r.microphoneId,hP(r.captureVolume),hP(r.profile)||(pP(r.profile)?IC[r.profile]&&n.setProfile(IC[r.profile]):n.setProfile(r.profile)),mP(r.earMonitorVolume)&&(a.muted=!(r.earMonitorVolume>0),a.volume=r.earMonitorVolume),hP(r.echoCancellation)||(n.profile.echoCancellation=r.echoCancellation),hP(r.noiseSuppression)||(n.profile.noiseSuppression=r.noiseSuppression),hP(r.autoGainControl)||(n.profile.autoGainControl=r.autoGainControl)),n.on("5",(t=>{e.emit($P.ERROR,new sM({code:iM.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),n.on("2",(t=>{e.emit($P.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),n.on("4",(t=>{let i;t.error&&(i=sM.convertFrom(t.error)),e.emit($P.PUBLISH_STATE_CHANGED,bA(CA({},t),{error:i}))})),yield n.capture(o),VN(n,n).add("player-state-changed",(t=>{e.emit($P.AUDIO_PLAY_STATE_CHANGED,bA(CA({},t),{userId:""}))})),yield e._updateAudioPlayOption({playOption:a,track:n}),i&&e._room.isJoined&&e._room.publish(n).catch((()=>{})),e._localAudioTrack=n,e._localAudioConfig=bA(CA({},t),{publish:i})}()}))}updateLocalAudio(e){return MA(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:i,option:r}=e,n={};r&&(r.microphoneId?yield this._localAudioTrack.switchDevice(r.microphoneId):hP(r.audioTrack)||(this._localAudioTrack.setMediaStreamTrack(r.audioTrack),yield this._room.replaceTrack(this._localAudioTrack)),hP(r.captureVolume),hP(r.earMonitorVolume)||(n.muted=!(r.earMonitorVolume>0),n.volume=r.earMonitorVolume)),yield this._updateAudioPlayOption({playOption:n,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),this._room.isJoined&&!hP(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack)),hP(i)||this._localAudioTrack.setMute(i),VP(this._localAudioConfig,e)}))}stopLocalAudio(){return MA(this,null,(function*(){!this._localAudioTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack)),this._localAudioTrack.stop(),this._localAudioTrack.close(),FN(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:r=!0,option:n}=t,o=new fO,a={},s={};if(n&&(n.cameraId?a.deviceId=n.cameraId:hP(n.useFrontCamera)?hP(n.videoTrack)||(a.customSource=n.videoTrack):a.facingMode=n.useFrontCamera?MC:LC,hP(n.profile)||(pP(n.profile)?RC[n.profile]&&o.setProfile(RC[n.profile]):o.setProfile(n.profile)),hP(n.fillMode)||(s.objectFit=n.fillMode),hP(n.mirror)||(s.mirror=n.mirror),hP(n.small)||(bD()?pP(n.small)?o.small=RC[n.small]:o.small=n.small:e._log.warn("small stream is not supported"))),o.on("5",(t=>{e.emit($P.ERROR,new sM({code:iM.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),o.on("2",(t=>{e.emit($P.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),o.on("4",(t=>{let i;t.error&&(i=sM.convertFrom(t.error)),e.emit($P.PUBLISH_STATE_CHANGED,bA(CA({},t),{error:i}))})),yield o.capture(a),(null==n?void 0:n.qosPreference)&&o.mediaTrack){let e=bM(n.qosPreference);o.mediaTrack.contentHint=e}VN(o,o).add("player-state-changed",(t=>{e.emit($P.VIDEO_PLAY_STATE_CHANGED,bA(CA({},t),{userId:"",streamType:"main"}))})),yield e._updateVideoPlayOption({view:i,playOption:s,track:o}),r&&e._room.isJoined&&e._room.publish(o).catch((()=>{})),e._localVideoTrack=o,e._localVideoConfig=bA(CA({},t),{view:i,publish:r})}()}))}updateLocalVideo(e){return MA(this,null,(function*(){if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:t,publish:i,mute:r,option:n}=e,o={};if(n&&(n.cameraId?yield this._localVideoTrack.switchDevice(n.cameraId):hP(n.useFrontCamera)?hP(n.videoTrack)||(this._localVideoTrack.setMediaStreamTrack(n.videoTrack),yield this._room.replaceTrack(this._localVideoTrack)):yield this._localVideoTrack.switchDevice(n.useFrontCamera?MC:LC),hP(n.profile)||(pP(n.profile)?RC[n.profile]&&this._localVideoTrack.setProfile(RC[n.profile]):this._localVideoTrack.setProfile(n.profile)),hP(n.fillMode)||(o.objectFit=n.fillMode),hP(n.mirror)||(o.mirror=n.mirror),n.qosPreference&&this._localVideoTrack.mediaTrack)){let e=bM(n.qosPreference);this._localVideoTrack.mediaTrack.contentHint=e}yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),this._room.isJoined&&!hP(i)&&(i&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._localVideoConfig.publish&&!i&&this._room.unpublish(this._localVideoTrack).catch((()=>{}))),hP(r)||this._localVideoTrack.setMute(r),VP(this._localVideoConfig,e)}))}stopLocalVideo(){return MA(this,null,(function*(){!this._localVideoTrack||(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack)),this._localVideoTrack.stop(),this._localVideoTrack.close(),FN(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:i=null,publish:r=!0,option:n}=t,o=new SO;o.on("4",(t=>{let i;t.error&&(i=sM.convertFrom(t.error)),e.emit($P.PUBLISH_STATE_CHANGED,bA(CA({},t),{error:i}))}));let a=null;o.setMediaType(2);let s={},c={};n&&(hP(n.profile)||(pP(n.profile)?AC[n.profile]&&o.setProfile(AC[n.profile]):o.setProfile(n.profile)),n.systemAudio&&(s.systemAudio=!0,s.echoCancellation=n.echoCancellation,s.noiseSuppression=n.noiseSuppression,s.autoGainControl=n.autoGainControl),hP(n.fillMode)||(c.objectFit=n.fillMode),n.videoTrack&&(s.videoTrack=n.videoTrack),n.audioTrack&&(s.audioTrack=n.audioTrack));let l=yield o.capture(s);if(null!=n&&n.qosPreference){let e=bM(n.qosPreference);o.mediaTrack.contentHint=e}if(o.mediaTrack.addEventListener(VC,(()=>{e._stopScreenShare(),e.emit($P.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(a=new yO,a.setScreenAudioTrack(l.getAudioTracks()[0],l)),VN(o,o).add("player-state-changed",(t=>{e.emit($P.VIDEO_PLAY_STATE_CHANGED,bA(CA({},t),{userId:"",streamType:"sub"}))})),yield e._updateVideoPlayOption({view:i,playOption:c,track:o}),r&&e._room.isJoined){let t=[o];a&&t.push(a),e._room.publish(...t).catch((()=>{}))}e._localScreenTrack=o,e._localScreenAudioTrack=a,e._localScreenConfig=bA(CA({},t),{view:i,publish:r})}()}))}updateScreenShare(e){return MA(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:i,option:r}=e,n={};if(r&&(hP(r.fillMode)||(n.objectFit=r.fillMode),r.qosPreference)){let e=bM(r.qosPreference);this._localScreenTrack.mediaTrack.contentHint=e}yield this._updateVideoPlayOption({view:t,playOption:n,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),this._room.isJoined&&!hP(i)&&(i&&!this._localScreenConfig.publish&&this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenConfig.publish&&!i&&this._room.unpublish(this._localScreenTrack)),VP(this._localScreenConfig,e)}))}stopScreenShare(){return MA(this,null,(function*(){return yield this._stopScreenShare()}))}usePlugin(){}startPlugin(e,t){return MA(this,null,(function*(){var i;"RTCAudioMixer"===e&&(this._room.startPlugin("RTCAudioMixer",t),this._room.isJoined&&this._localAudioTrack&&this._room.isMainStreamPublished&&(yield null==(i=this._room)?void 0:i.publish(this._localAudioTrack)))}))}updatePlugin(e,t){}stopPlugin(e,t){return MA(this,null,(function*(){"RTCAudioMixer"===e&&this._room.stopPlugin("RTCAudioMixer",t)}))}startRemoteVideo(e){return MA(this,null,(function*(){let{view:t,userId:i,streamType:r,option:n}=e,o="".concat(i,"_").concat(r);if(this._remoteVideoConfigMap.has(o))return void this._log.warn("remote video has already started. userId:".concat(i,", streamType:").concat(r));let a=this._room.remotePublishedUserMap.get(i);if(!a)return;let s={},c="main"===r?a.remoteVideoTrack:a.remoteAuxiliaryTrack;n&&(hP(n.fillMode)||(s.objectFit=n.fillMode),hP(n.mirror)||(s.mirror=n.mirror),"main"===r&&!hP(n.small)&&this._room.changeType(n.small,c.user)),yield this._room.subscribe(c),yield this._updateVideoPlayOption({view:t,playOption:s,track:c}),this._remoteVideoConfigMap.set(o,e)}))}updateRemoteVideo(e){return MA(this,null,(function*(){let{view:t,userId:i,streamType:r,option:n}=e,o="".concat(i,"_").concat(r);if(!this._remoteVideoConfigMap.has(o)||!this._room.remotePublishedUserMap.has(i))return;let a={};n&&(hP(n.fillMode)||(a.objectFit=n.fillMode),hP(n.mirror)||(a.mirror=n.mirror));let s=null,c=this._room.remotePublishedUserMap.get(i);"main"===r&&(null==c?void 0:c.muteState.hasVideo)&&(s=c.remoteVideoTrack),"sub"===r&&(null==c?void 0:c.muteState.hasAuxiliary)&&(s=c.remoteAuxiliaryTrack);let l=this._remoteVideoConfigMap.get(o);s&&("main"===r&&n&&!hP(n.small)&&this._room.changeType(n.small,s.user),yield this._updateVideoPlayOption({view:t,playOption:a,track:s,prevConfig:l})),VP(l,e)}))}stopRemoteVideo(e){return MA(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return MA(this,null,(function*(){let i=[],r=this._room.remotePublishedUserMap.get(e.userId);if(r){let{muteState:t,remoteVideoTrack:n,remoteAuxiliaryTrack:o}=r;t.hasVideo&&"main"===e.streamType&&i.push(n),t.hasAuxiliary&&"sub"===e.streamType&&i.push(o)}for(let e of i)t&&(yield this._room.unsubscribe(e)),e.stop(),this._remoteVideoConfigMap.delete("".concat(e.userId,"_").concat(CM(e.streamType)))}))}muteRemoteAudio(e,t){return MA(this,null,(function*(){if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):yield this._startRemoteAudio({userId:e});this._remoteAudioMuteMap.set(e,t)}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let i of e)this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}else if(e){let i=this._room.remotePublishedUserMap.get(e);i&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}startMixTranscode(e){let t=CA({},e);return t.mixUsers=e.mixUsers.map((e=>{let t=CA({},e);return hP(e.streamType)||(t.streamType=CM(e.streamType)),t})),this._room.startMixTranscode(t)}stopMixTranscode(){return this._room.stopMixTranscode()}startPublishCDNStream(e){let t=CA({},e);return hP(e.streamType)||(t.streamType=CM(e.streamType)),this._room.startPublishCDNStream(t)}stopPublishCDNStream(){return this._room.stopPublishCDNStream()}on(e,t,i){return super.on(e,t,i),this._eventListened.add(e),this}off(e,t,i){return"*"===e?(this._eventListened.clear(),this.removeAllListeners()):super.off(e,t,i),this}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:i="main"}=e;if(""===t){if("main"===i&&this._localVideoTrack)return this._localVideoTrack.mediaTrack;if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.mediaTrack}else{let e=this._room.remotePublishedUserMap.get(t);if(e)return"main"===i?e.remoteVideoTrack.mediaTrack:e.remoteAuxiliaryTrack.mediaTrack}return null}getAudioTrack(e){if(e){let t=this._room.remotePublishedUserMap.get(e);if(t)return t.remoteAudioTrack.mediaTrack}else if(this._localAudioTrack)return this._localAudioTrack.mediaTrack;return null}setCurrentSpeaker(e){var t;null==(t=this._localAudioTrack)||t.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}_startRemoteAudio(e){return MA(this,null,(function*(){let{userId:t,option:i}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let n={};i&&(hP(i.volume)||(n.volume=i.volume));let o=r.remoteAudioTrack;yield this._room.subscribe(o),yield this._updateAudioPlayOption({playOption:n,track:o}),this._remoteAudioConfigMap.set(t,e)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return MA(this,null,(function*(){let i=this._room.remotePublishedUserMap.get(e.userId);null!=i&&i.muteState.hasAudio&&(t&&(yield this._room.unsubscribe(i.remoteAudioTrack)),i.remoteAudioTrack.stop()),this._remoteAudioConfigMap.delete("".concat(e.userId))}))}_updateVideoPlayOption(e){return MA(this,arguments,(function(e){let{view:t,playOption:i,track:r,prevConfig:n}=e;return function*(){if(hP(t)&&n&&n.view&&!NP(i)){let e=FP(n.view);e&&(yield r.play(e,i))}if(!hP(t)){let e=FP(t);e?yield r.play(e,i):r.stop()}}()}))}_updateAudioPlayOption(e){return MA(this,arguments,(function(e){let{playOption:t={},track:i,prevConfig:r}=e;return function*(){i.isPlayCalled||(yield i.play(null,t)),hP(t.muted)||i.setPlayerMute(t.muted),hP(t.volume)||i.setAudioVolume(t.volume/100)}()}))}_checkTrackToPublish(){var e,t,i;let r=[];if((null==(e=this._localAudioConfig)?void 0:e.publish)&&this._localAudioTrack&&r.push(this._localAudioTrack),(null==(t=this._localVideoConfig)?void 0:t.publish)&&this._localVideoTrack&&r.push(this._localVideoTrack),null!=(i=this._localScreenConfig)&&i.publish&&(this._localScreenTrack&&r.push(this._localScreenTrack),this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack)),0!==r.length)return this._room.publish(...r).catch((()=>{}))}_handleReceiveMode(){this._room.autoReceiveAudio&&VN(this,this).add($P.REMOTE_AUDIO_AVAILABLE,(e=>MA(this,[e],(function(e){var t=this;let{userId:i}=e;return function*(){if(t._remoteAudioMuteMap.get("*")||t._remoteAudioMuteMap.get(i))return;let e=t._room.remotePublishedUserMap.get(i);e&&(yield t._room.subscribe(e.remoteAudioTrack).catch((()=>{})),yield t._updateAudioPlayOption({track:e.remoteAudioTrack}).catch((()=>{})),t._remoteAudioConfigMap.set(i,{userId:i}))}()})))),this._room.autoReceiveVideo&&VN(this,this).add($P.REMOTE_VIDEO_AVAILABLE,(e=>{let{userId:t,streamType:i}=e,r=this._room.remotePublishedUserMap.get(t);r&&("main"===i?this._room.subscribe(r.remoteVideoTrack).catch((()=>{})):"sub"===i&&this._room.subscribe(r.remoteAuxiliaryTrack).catch((()=>{})))}))}_exitRoom(){return MA(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),[...this._remoteAudioConfigMap.keys()].forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",i=e.split("_".concat(t))[0];i&&this._stopRemoteVideo({userId:i,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._room.remotePublishedUserMap.forEach((e=>{FN(e.remoteAudioTrack),FN(e.remoteVideoTrack),FN(e.remoteAuxiliaryTrack)})),FN(this)}))}_stopScreenShare(){return MA(this,null,(function*(){var e,t,i;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t)}this._localScreenTrack.stop(),this._localScreenTrack.close(),null==(t=this._localScreenAudioTrack)||t.stop(),null==(i=this._localScreenAudioTrack)||i.close(),FN(this._localScreenTrack),this._localScreenTrack=null,this._localScreenAudioTrack=null,this._localScreenConfig=null}}))}static setLogLevel(e,t){QP.setLogLevel(e),hP(t)||(t?QP.enableUploadLog():QP.disableUploadLog())}static isSupported(){return fD()}static getCameraList(){return oO()}static getMicrophoneList(){return nO()}static getSpeakerList(){return aO()}static setCurrentSpeaker(e){return MA(this,null,(function*(){(yield aO()).forEach((t=>{t.deviceId===e&&(LM.forEach((i=>{i.setCurrentSpeaker(e),i.emit($P.DEVICE_CHANGED,{type:"speaker",action:"active",device:t})})),xM=t)}))}))}},VM=UM;NA(VM,"_loggerManager",QP),NA(VM,"EVENT",$P),NA(VM,"ERROR_CODE",iM),NA(VM,"TYPE",qO),NA(VM,"frameWorkType",30),DA([kM(AM.TRTC.enterRoom),lM("room",((e,t)=>{let[i]=e,[r]=t;return i.roomId===r.roomId&&i.userId===r.userId&&i.sdkAppId===r.sdkAppId})),pO((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t).catch((e=>{throw FN(this),e}))})),NM()],VM.prototype,"enterRoom",1),DA([uM("room"),NM()],VM.prototype,"exitRoom",1),DA([kM(AM.TRTC.switchRole),dM("room",((e,t)=>t)),NM()],VM.prototype,"switchRole",1),DA([NM()],VM.prototype,"destroy",1),DA([kM(AM.TRTC.startLocalAudio),lM("audio",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)===(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)})),NM()],VM.prototype,"startLocalAudio",1),DA([kM(AM.TRTC.updateLocalAudio),dM("audio"),NM()],VM.prototype,"updateLocalAudio",1),DA([uM("audio"),NM()],VM.prototype,"stopLocalAudio",1),DA([kM(AM.TRTC.startLocalVideo),lM("video",((e,t)=>{let[i]=e,[r]=t;var n,o;return(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)===(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)})),NM()],VM.prototype,"startLocalVideo",1),DA([kM(AM.TRTC.updateLocalVideo),dM("video"),NM()],VM.prototype,"updateLocalVideo",1),DA([uM("video"),NM()],VM.prototype,"stopLocalVideo",1),DA([kM(AM.TRTC.startScreenShare),lM("screen",(()=>!0)),NM()],VM.prototype,"startScreenShare",1),DA([kM(AM.TRTC.updateScreenShare),dM("screen"),NM()],VM.prototype,"updateScreenShare",1),DA([uM("screen"),NM()],VM.prototype,"stopScreenShare",1),DA([kM(AM.TRTC.startRemoteVideo),lM((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),NM()],VM.prototype,"startRemoteVideo",1),DA([kM(AM.TRTC.updateRemoteVideo),dM((e=>"v".concat(e.userId).concat(e.streamType))),NM()],VM.prototype,"updateRemoteVideo",1),DA([kM(AM.TRTC.stopRemoteVideo),pO((e=>function(t){return MA(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_","main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_","sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),uM((e=>"v".concat(e.userId).concat(e.streamType)),!0),NM()],VM.prototype,"stopRemoteVideo",1),DA([hM((e=>"v".concat(e.userId).concat(e.streamType)))],VM.prototype,"_stopRemoteVideo",1),DA([kM(...AM.TRTC.muteRemoteAudio),NM()],VM.prototype,"muteRemoteAudio",1),DA([wM(...AM.TRTC.setRemoteAudioVolume),function(e,t){return pO(((i,r)=>function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];var a,s;let c=null==(a=OM.get(this))?void 0:a.get(t(...n));c&&c>0&&clearTimeout(c);let l=window.setTimeout((()=>{i.apply(this,n)}),e);OM.has(this)?null==(s=OM.get(this))||s.set(t(...n),l):OM.set(this,new Map([[t(...n),l]]))}))}(200,(e=>e)),NM()],VM.prototype,"setRemoteAudioVolume",1),DA([wM(...AM.TRTC.enableAudioVolumeEvaluation)],VM.prototype,"enableAudioVolumeEvaluation",1),DA([kM(AM.TRTC.startMixTranscode)],VM.prototype,"startMixTranscode",1),DA([lM((e=>"a".concat(e.userId)),(()=>!0))],VM.prototype,"_startRemoteAudio",1),DA([pO((e=>function(t){return MA(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(bA(CA({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),uM((e=>"a".concat(e.userId)))],VM.prototype,"_stopRemoteAudio",1),DA([hM("room")],VM.prototype,"_exitRoom",1);var FM=VM;PA(XA()),PA(XA(),1);function jM(){return MA(this,null,(function*(){let e,t;try{let t=yield nO();e=t&&t.length}catch(u){}try{let e=yield oO();t=e&&e.length}catch(u){}let i={microphone:e,camera:t},{isH264EncodeSupported:r,isVp8EncodeSupported:n,isH264DecodeSupported:o,isVp8DecodeSupported:a}=this.checkSystemResult.detail,s=ZP.basis(),c={webRTC:s.isWebRTCSupported,getUserMedia:s.isGetUserMediaSupported,webSocket:s.isWebSocketsSupported,screenShare:s.isScreenShareSupported,webAudio:s.isWebAudioSupported,h264Encode:r,h264Decode:o,vp8Encode:n,vp8Decode:a},l={browser:s.browser,os:s.os,trtc:c,devices:i},d={isWebCodecSupported:s.isWebCodecSupported,isMediaSessionSupported:s.isMediaSessionSupported,isWebTransportSupported:s.isWebTransportSupported};mN.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),mN.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(d)),userId:this.userId})}))}PA(XA(),1);PA(XA());var BM=PA($A());PA(XA());var HM="1",GM="5",WM="2",JM="3",zM="4",KM="DISCONNECTED",qM="CONNECTING",QM="CONNECTED",YM={CLIENT_BANNED:9,CHANNEL_SETUP_RESULT:19,CHANNEL_RECONNECT_RESULT:514,JOIN_ROOM_RESULT:20,PEER_JOIN:4134,PEER_LEAVE:4135,STREAM_ADDED:16,STREAM_REMOVED:18,UPLINK_NETWORK_STATS:22,UPDATE_REMOTE_MUTE_STAT:23,PUBLISH_RESULT:4098,PUBLISH_STATE_CHANGE_RESULT:4112,UNPUBLISH_RESULT:4100,SUBSCRIBE_RESULT:4102,UNSUBSCRIBE_RESULT:4104,SUBSCRIBE_CHANGE_RESULT:4106,MUTE_RESULT:4108,UPDATE_OFFER_RESULT:4128,START_PUBLISH_TENCENT_CDN_RES:1286,STOP_PUBLISH_TENCENT_CDN_RES:1288,START_PUBLISH_GIVEN_CDN_RES:777,STOP_PUBLISH_GIVEN_CDN_RES:779,START_MIX_TRANSCODE_RES:781,STOP_MIX_TRANSCODE_RES:783,USER_LIST_RES:4137,SWITCH_ROLE_RES:4110,UPDATE_CONSTRAINT_CONFIG_RES:772,REBUILD_PEER_CONNECTION_RES:4150},XM=[YM.UPDATE_REMOTE_MUTE_STAT,YM.UPLINK_NETWORK_STATS,YM.USER_LIST_RES,YM.MUTE_RESULT],$M={CLIENT_BANNED:"client-banned",CHANNEL_SETUP_RESULT:"channel-setup-result",CHANNEL_RECONNECT_RESULT:"channel-reconnect-result",JOIN_ROOM_RESULT:"join-room-result",PEER_JOIN:"peer-join",PEER_LEAVE:"peer-leave",STREAM_ADDED:"stream-added",STREAM_REMOVED:"stream-removed",UPLINK_NETWORK_STATS:"uplink-network-stats",UPDATE_REMOTE_MUTE_STAT:"update-remote-mute-stat",PUBLISH_RESULT:"publish-result",PUBLISH_STATE_CHANGE_RESULT:"publish-state-change-result",UNPUBLISH_RESULT:"unpublish-result",SUBSCRIBE_RESULT:"subscribe-result",SUBSCRIBE_CHANGE_RESULT:"subscribe-change-result",UNSUBSCRIBE_RESULT:"unsubscribe-result",UPDATE_OFFER_RESULT:"update-offer-result",START_PUBLISH_TENCENT_CDN_RES:"start-publish-tencent-cdn-res",STOP_PUBLISH_TENCENT_CDN_RES:"stop-publish-tencent-cdn-res",START_PUBLISH_GIVEN_CDN_RES:"start-publish-given-cdn-res",STOP_PUBLISH_GIVEN_CDN_RES:"stop-publish-given-cdn-res",START_MIX_TRANSCODE_RES:"start-mix-transcode-res",STOP_MIX_TRANSCODE_RES:"stop-mix-transcode-res",USER_LIST_RES:"user-list-res",SWITCH_ROLE_RES:"switch_role_res",MUTE_RESULT:"mute-result",UPDATE_CONSTRAINT_CONFIG_RES:"update-contraint-config-res",REBUILD_PEER_CONNECTION_RES:"rebuild-pc-res"},ZM="publish_change",eL="join",tL="leave",iL="quality_report",rL="mute_uplink",nL="publish",oL="publish_state_change",aL="unpublish",sL="subscribe",cL="unsubscribe",lL="subscribe_change",dL="start_publishing",uL="stop_publishing",hL="start_push_user_cdn",pL="stop_push_user_cdn",mL="start_mcu_mix",_L="stop_mcu_mix",fL="get_user_list",gL="change_role",vL="update_constraint_config";PA(XA()),PA(XA());var TL=PA($A());PA(XA());var SL=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-2,i=[],r=0;for(let o=e;o<=t;o++){let e=this.dataView.getInt8(o);switch(e){case 0:case 1:case 2:case 3:2===r&&(i.push(3),r=0),0==e?r++:r=0,i.push(e);break;default:r=0,i.push(e)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}removePreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-1,i=[],r=0;for(let o=e;o<=t;o++)switch(this.dataView.getInt8(o)){case 0:r++,i.push(this.dataView.getInt8(o));break;case 3:2!==r&&i.push(this.dataView.getInt8(o)),r=0;break;default:i.push(this.dataView.getInt8(o)),r=0}let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=n}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let n=6;n<this.dataView.buffer.byteLength;n++){let i=this.dataView.getUint8(n);if(t++,255!==i){e+=i;break}e+=255}let i=new ArrayBuffer(e),r=new DataView(i);for(let n=0;n<i.byteLength;n++,t++)r.setInt8(n,this.dataView.getInt8(t));return r}},yL=class{constructor(e,t,i){this._isUplink=i,this._connection=e,this._log=t,this._seiMessageList=[],this._seiPayloadType=243,this._mainVideoSenderOrReceiver=null,this._mainVideoAbortController=null,this._abortMap=new Map,this.onSEIMessage=null}get isRunning(){return!!this._mainVideoAbortController}start(e){this._mainVideoSenderOrReceiver=e;let t=e.createEncodedStreams(),i=t.readable,r=t.writable,n=new TransformStream({transform:this._isUplink?this.encodeVideoFrame.bind(this):this.decodeVideoFrame.bind(this)});this._mainVideoAbortController=new AbortController,i.pipeThrough(n).pipeTo(r,{signal:this._mainVideoAbortController.signal}).catch((()=>{}))}restart(e){this.stop(),this.start(e)}stop(){var e;null==(e=this._mainVideoAbortController)||e.abort(),this._mainVideoAbortController=null}destroy(){this.stop(),this._abortMap.forEach((e=>e.abort())),this._abortMap.clear(),this._log=null,this.onSEIMessage=null,this._mainVideoSenderOrReceiver=null,this._connection=null}handleEncodedStreams(){try{let e=this._connection.getPeerConnection();this.clearUnusedSenderOrReceiver(e),this._isUplink?e.getSenders().forEach(((e,t)=>{if(1===t){if(e===this._mainVideoSenderOrReceiver)return;this.isRunning?this.restart(e):this.start(e)}else{if(this._abortMap.has(e))return;this.pipeSenderOrReceiver(e)}})):e.getReceivers().forEach(((e,t)=>{var i;this._abortMap.has(e)||e===this._mainVideoSenderOrReceiver||(1===t&&(null==(i=e.track)?void 0:i.kind)===kC?this.isRunning?this.restart(e):this.start(e):this.pipeSenderOrReceiver(e))}))}catch(HO){this._log.warn(HO)}}pipeSenderOrReceiver(e){let{readable:t,writable:i}=e.createEncodedStreams(),r=new AbortController;this._abortMap.set(e,r),t.pipeTo(i,{signal:r.signal}).catch((()=>{}))}clearUnusedSenderOrReceiver(e){this._abortMap.forEach(((t,i)=>{(this._isUplink?e.getSenders():e.getReceivers()).find((e=>e===i))||(t.abort(),this._abortMap.delete(i))}))}push(e,t){t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e)}hasSEI(e){let t=new DataView(e);return 1===t.getInt32(0)&&6===t.getInt8(4)}isEmptyFrame(e){return"empty"===e.type||0===e.data.byteLength}getNaluCount(e){let t=0,i=0,r=new DataView(e);for(let n=0;n<e.byteLength;n++)switch(r.getUint8(n)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}encodeVideoFrame(e,t){try{if(this._connection.isH264&&this._seiMessageList.length>0&&!this.isEmptyFrame(e)){let t=9-this.getNaluCount(e.data);if(t<=0)return;let i=this._seiMessageList.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),r=i.reduce(((e,t)=>e+t.dataView.byteLength),0),n=new ArrayBuffer(r+e.data.byteLength),o=new DataView(n),a=new DataView(e.data),s=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)o.setInt8(s++,i[e].dataView.getInt8(t));for(let c=0;c<e.data.byteLength;c++)o.setInt8(s++,a.getInt8(c));e.data=n,this._log.debug("".concat(i.length," sei sent"))}}catch(i){this._log.warn(i)}t.enqueue(e)}decodeVideoFrame(e,t){try{if(this._connection.isH264&&!this.isEmptyFrame(e)&&this.hasSEI(e.data)){let t=[],i=new DataView(e.data),r=0,n=-1,o=-1;for(let a=0;a<e.data.byteLength;a++){let s=i.getUint8(a);if(0===s)r++;else if(1===s){if(2===r||3===r){let s=a-r;if(-1===n?n=s:-1===o&&(o=s,t.push(new SL(new DataView(i.buffer.slice(n,o)))),n=s,o=-1),6!==i.getUint8(a+1)){e.data=new DataView(i.buffer.slice(s)).buffer;break}}r=0}else r=0}this._log.debug("".concat(t.length," sei received")),uP(this.onSEIMessage)&&t.reverse().forEach((e=>{this.onSEIMessage({seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer})}))}}catch(i){this._log.warn(i)}t.enqueue(e)}encodeSEINalu(e){let t=e.byteLength,i=parseInt(t/255),r=t%255,n=[];n.push(0,0,0,1,6,this._seiPayloadType);for(let a=0;a<i;a++)n.push(255);n.push(r);let o=new DataView(e);return n.push(...new Uint8Array(o.buffer)),n.push(128),new SL(new DataView(new Uint8Array(n).buffer),!0)}},EL=0,IL=!1,RL=new Set,AL=!1,CL=class{constructor(e){NA(this,"userId"),NA(this,"tinyId"),NA(this,"_sdpSemantics"),NA(this,"_isUplink"),NA(this,"_room"),NA(this,"_log"),NA(this,"_signalChannel"),NA(this,"_isErrorObserved",!1),NA(this,"_waitForPeerConnectionConnectedPromise"),NA(this,"_waitForPeerConnectionConnectedPromiseReject",null),NA(this,"_peerConnection",null),NA(this,"_emitter",new TL.default),NA(this,"_currentState","DISCONNECTED"),NA(this,"_isReconnecting",!1),NA(this,"_reconnectionCount",0),NA(this,"_reconnectionTimer",-1),NA(this,"_isFirstConnection",!0),NA(this,"_prevTime",-1),NA(this,"_enableSEI"),NA(this,"_sei"),NA(this,"_localAddress"),NA(this,"_remoteAddress"),this.userId=e.userId,this.tinyId=e.tinyId,this._room=e.room,this._sdpSemantics=e.room.sdpSemantics,this._isUplink=e.isUplink,this._log=QP.createLogger({id:"n",userId:this.userId,sdkAppId:this._room.sdkAppId,isLocal:this._isUplink}),this._signalChannel=e.signalChannel,this._enableSEI=e.enableSEI,this._enableSEI&&VD&&(this._sei=new yL(this,this._log,this._isUplink))}beforeConnect(){this._prevTime<0&&(this._prevTime=bP())}afterConnect(e){return MA(this,null,(function*(){try{yield e,this._isFirstConnection?(this._isFirstConnection=!1,WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionConnect",cost:Math.min(bP()-this._prevTime,3e4)})):this._isReconnecting&&WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionReconnect",cost:bP()-this._prevTime}),this._prevTime=-1}catch(t){throw this._isFirstConnection?(this._isFirstConnection=!1,WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionConnect",error:t})):this._isReconnecting&&this._reconnectionCount>=3&&WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"PeerConnectionReconnect",error:t}),t}}))}initialize(){let e={encodedInsertableStreams:this._enableSEI&&VD,iceServers:this._room.getIceServers(),iceTransportPolicy:this._room.getIceTransportPolicy(),sdpSemantics:this._sdpSemantics,bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",tcpCandidatePolicy:"disable",IceTransportsType:"nohost"};this._peerConnection=new RTCPeerConnection(e),this._peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this)}close(){this._log.info("close connection"),this.closePeerConnection(),this._sei&&(this._sei.destroy(),this._sei=null),RL.delete(this)}closePeerConnection(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this._peerConnection&&(this._log.info("close pc"),this._peerConnection.onconnectionstatechange=null,this._peerConnection.close(),this._peerConnection=null,e&&this.emitConnectionStateChangedEvent("DISCONNECTED")),this._waitForPeerConnectionConnectedPromiseReject&&this._waitForPeerConnectionConnectedPromiseReject(new nD({code:iD.API_CALL_ABORTED,message:"connection closed"}))}getDTLSTransportState(){if(!this._peerConnection)return rb;let e=null;if(this._isUplink){if(!PD()||0===this._peerConnection.getSenders().length)return rb;e=this._peerConnection.getSenders()[0].transport}else{if(!wD()||0===this._peerConnection.getReceivers().length)return rb;e=this._peerConnection.getReceivers()[0].transport}return e?e.state:rb}onConnectionStateChange(e){let t=this._peerConnection.iceConnectionState,i=this.getDTLSTransportState();if(this._log.info("connectionState: ".concat(e.target.connectionState,", ICE: ").concat(t,", DTLS: ").concat(i)),e.target.connectionState===ob&&this.emitConnectionStateChangedEvent("CONNECTING"),e.target.connectionState===ab||e.target.connectionState===sb){let r="connection ".concat(e.target.connectionState,". ICE Transport state: ").concat(t,", DTLS Transport state: ").concat(i),n=new nD({message:r,code:iD.ICE_TRANSPORT_ERROR});this.emitConnectionStateChangedEvent("DISCONNECTED"),this.startReconnection(),this._isErrorObserved||this._emitter.emit("error",n)}(e.target.connectionState===lb||e.target.connectionState===db)&&(this.logSelectedCandidate(),mN.logSuccessEvent({userId:this._room.userId,eventType:mb}),this.emitConnectionStateChangedEvent("CONNECTED"))}emitConnectionStateChangedEvent(e){return e!==this._currentState&&("CONNECTED"===e?(EL=0,IL=!1,AL=!0,RL.add(this)):RL.delete(this),WP.emit(KP.PEER_CONNECTION_STATE_CHANGED,{room:this._room,prevState:this._currentState,state:e,remoteUserId:this._isUplink?void 0:this.userId}),this._emitter.emit("connection-state-changed",{prevState:this._currentState,state:e}),this._currentState=e,!0)}getPeerConnection(){return this._peerConnection}getRoom(){return this._room}getUserId(){return this.userId}getTinyId(){return this.tinyId}logSelectedCandidate(){return MA(this,null,(function*(){if(!this._peerConnection)return;let e=yield this._peerConnection.getStats();for(let[,t]of e)if(SD(t)){let i=e.get(t.localCandidateId),r=e.get(t.remoteCandidateId);i&&(this._log.info("local candidate: ".concat(i.candidateType," ").concat(i.protocol,":").concat(i.ip||i.address,":").concat(i.port," ").concat(i.networkType||""," ").concat("relay"===i.candidateType?"relayProtocol:".concat(i.relayProtocol):"")),this._localAddress="".concat(i.ip||i.address,":").concat(i.port)),r&&(this._log.info("remote candidate: ".concat(r.candidateType," ").concat(r.protocol,":").concat(r.ip||r.address,":").concat(r.port)),this._remoteAddress="".concat(r.protocol,":").concat(r.ip||r.address));break}}))}getCurrentState(){return this._currentState}waitForPeerConnectionConnected(){return this._waitForPeerConnectionConnectedPromise||(this._waitForPeerConnectionConnectedPromise=new Promise(((e,t)=>{if("CONNECTED"===this._currentState)return e();this._waitForPeerConnectionConnectedPromiseReject=t;let i=t=>{"CONNECTED"===t.state&&(clearTimeout(o),n(),e())},r=e=>{let{room:i}=e;i===this._room&&(clearTimeout(o),n(),t(new nD({code:iD.API_CALL_ABORTED,message:Jw({key:Vw,data:"leave room"})})))},n=()=>{WP.off(KP.LEAVE_SUCCESS,r,this),this._emitter.off("connection-state-changed",i,this)},o=setTimeout((()=>{n();let e=new nD({code:iD.API_CALL_TIMEOUT,message:"connection timeout"});EL+=1,(e=>EL>2&&!IL&&0===RL.size&&e)(this._signalChannel.isConnected)&&(this._log.warn("firewall restrition"),IL=!0,this._emitter.emit("firewall-restriction")),t(e)}),1e4);WP.on(KP.LEAVE_SUCCESS,r,this),this._emitter.on("connection-state-changed",i,this)})),this._waitForPeerConnectionConnectedPromise=this._waitForPeerConnectionConnectedPromise.finally((()=>{this._waitForPeerConnectionConnectedPromise=null,this._waitForPeerConnectionConnectedPromiseReject=null}))),this._waitForPeerConnectionConnectedPromise}getReconnectionCount(){return this._reconnectionCount}startReconnection(){this._isReconnecting=!0,this.reconnect()}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}stopReconnection(){this._log.info("stop reconnection"),this._isReconnecting=!1,this._reconnectionCount=0,this.clearReconnectionTimer(),this._signalChannel.off(JM,this.reconnect,this)}beforeReconnect(){if(-1!==this._reconnectionTimer)return this._log.warn("reconnect() is reconnecting, ignore"),-1;if(this._reconnectionCount>=hb()){this._log.warn("SDK has tried reconnect for ".concat(this._reconnectionCount," times, but all failed, please check your network")),this.stopReconnection();let e=new nD({code:this._isUplink?iD.UPLINK_RECONNECTION_FAILED:iD.DOWNLINK_RECONNECTION_FAILED,message:Jw({key:this._isUplink?aw:nw})});return this.emitConnectionStateChangedEvent("DISCONNECTED"),this._emitter.emit("error",e),-1}return this._signalChannel.isConnected?(this._reconnectionCount+=1,this._log.warn("reconnect() trying [".concat(this._reconnectionCount,"]")),1):(this._log.warn("reconnect() signal channel is not connected, suspend reconnection until signal is connected"),this._signalChannel.once(JM,this.reconnect,this),-1)}on(e,t,i){this._emitter.on(e,t,i)}off(e,t,i){this._emitter.off(e,t,i)}getIsReconnecting(){return this._isReconnecting}get isH264(){var e,t;return!(null==(t=null==(e=this._peerConnection)?void 0:e.remoteDescription)||!t.sdp.includes("H264"))}};PA(XA());var bL=PA(iC()),kL=function(e){return bL.default.parse(e)},wL=function(e){return bL.default.write(e)};function PL(e){return Object.keys(e).filter((t=>e[t]))}PA(XA());var DL=class extends CL{constructor(e){super(bA(CA({},e),{isUplink:!1})),NA(this,"_flag",0),NA(this,"role","anchor"),NA(this,"remoteAudioTrack"),NA(this,"remoteVideoTrack"),NA(this,"remoteAuxiliaryTrack"),NA(this,"ssrc",{audio:0,video:0,auxiliary:0}),NA(this,"_isSDPExchanging",!1),this.flag=e.flag,this.remoteAudioTrack=new bO(this._room,this),this.remoteVideoTrack=new kO(this._room,this),this.remoteAuxiliaryTrack=new wO(this._room,this)}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return OP(this.flag,this.userId)}get flag(){return this._flag}set flag(e){var t,i,r;e!==this._flag&&(this._flag=e,null==(t=this.remoteAudioTrack)||t.onFlagChanged(),null==(i=this.remoteVideoTrack)||i.onFlagChanged(),null==(r=this.remoteAuxiliaryTrack)||r.onFlagChanged())}get hasMainStream(){return this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall}get hasAuxStream(){return this.muteState.hasAuxiliary}get isMainStreamSubscribed(){return(this.subscribeState.audio||this.subscribeState.video||this.subscribeState.smallVideo)&&(this.muteState.hasAudio||this.muteState.hasVideo||this.muteState.hasSmall)}get isAuxStreamSubscribed(){return this.subscribeState.auxiliary&&this.muteState.hasAuxiliary}get isSmallStreamSubscribed(){return this.subscribeState.smallVideo&&this.muteState.hasSmall}get isBigStreamSubscribed(){return this.subscribeState.video&&this.muteState.hasVideo}isStreamUnpublished(e){return e===JC?!this.muteState.hasAudio&&!this.muteState.hasVideo:!this.muteState.hasAuxiliary}initialize(){super.initialize(),this.installEvents(),this._peerConnection.ontrack=this.onTrack.bind(this)}close(){super.close(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this.remoteAudioTrack.close(),this.remoteVideoTrack.close(),this.remoteAuxiliaryTrack.close(),this.uninstallEvents()}installEvents(){}uninstallEvents(){this._emitter.removeAllListeners()}emitConnectionStateChangedEvent(e){var t,i;let r=this._currentState,n=super.emitConnectionStateChangedEvent(e);return n&&r!==e&&(null==(t=this.remoteVideoTrack)||t.emit("connection-state-changed",{prevState:r,state:e}),null==(i=this.remoteAuxiliaryTrack)||i.emit("connection-state-changed",{prevState:r,state:e})),n}onTrack(e){let t=e.streams[0],{track:i}=e,r=t.id===eb?JC:NC;this._log.debug("ontrack ".concat(r," ").concat(i.kind));let n=bC;i.kind===kC&&(n=r===JC?kC:NC);let o=this.remoteAudioTrack;n===kC?o=this.remoteVideoTrack:n===NC&&(o=this.remoteAuxiliaryTrack),o.setMediaStream(t),o.setMediaStreamTrack(i)}addRRTRLine(e){let t=e.split("\r\n"),i=new Map;t.forEach(((e,r)=>{/^a=rtcp-fb:/.test(e)&&t[r+1]&&!/^a=rtcp-fb:/.test(t[r+1])&&i.set(r+1,"".concat(e.match(/^a=rtcp-fb:\d+/)[0]," rrtr"))}));let r=[...i];for(let n=0;n<r.length;n++){let[e,i]=r[n];t.splice(e+n,0,i)}return t.join("\r\n")}addSPSDescription(e){let t=kL(e);return t.media.forEach((e=>{e.type===kC&&e.fmtp.forEach((e=>{e.config+=";sps-pps-idr-in-keyframe=1"}))})),wL(t)}removeSDESDescription(e){let t=["urn:ietf:params:rtp-hdrext:sdes:mid","urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id","urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id"],i=kL(e);return i.media.forEach((e=>{!e.ext||(e.ext=e.ext.filter((e=>!t.includes(e.uri))))})),wL(i)}isSubscriptionStateNotChanged(e){return JSON.stringify(e)===JSON.stringify(this.subscribeState)}isSubscribeSmall(e){return hP(e.smallVideo)&&!this.subscribeState.smallVideo}subscribe(e,t){return MA(this,null,(function*(){var i,r;try{if(((null==(i=this._peerConnection)?void 0:i.connectionState)===nb||(null==(r=this._peerConnection)?void 0:r.connectionState)===ob)&&(yield this.waitForPeerConnectionConnected()),this.isSubscriptionStateNotChanged(e))return void(this._peerConnection||(this.initialize(),yield this.connect(e)));if(this._peerConnection||this._isSDPExchanging){let t="subscribe_change";Object.values(e).find((e=>!0===e))||(t="unsubscribe"),yield this.sendSubscription(t,e)}else this.initialize(),yield this.connect(e)}catch(aC){throw this._room.isJoined&&this.isStreamUnpublished(t)?(this._log.warn("".concat(aC.message," ").concat(JSON.stringify(this.muteState))),new nD({code:iD.REMOTE_STREAM_NOT_EXIST,message:"remote user ".concat(this.userId," unpublished stream")})):aC}}))}unsubscribe(e){return MA(this,arguments,(function(e){var t=this;let{remoteTracks:i,streamType:r}=e;return function*(){if("CONNECTED"===t._currentState&&("main"===r&&!t.isMainStreamSubscribed||"auxiliary"===r&&!t.isAuxStreamSubscribed))return void t._log.info("".concat(r," stream already unsubscribed"));let e=CA({},t.subscribeState);i.forEach((t=>{switch(t.mediaType){case 1:e.audio=!1;break;case 4:e.video=!1;break;case 8:e.smallVideo=!1;break;case 2:e.auxiliary=!1}}));let n="subscribe_change";Object.values(e).find((e=>!0===e))||(n="unsubscribe"),t._log.info("".concat("unsubscribe"===n?n:"subscribe"," ").concat(r," [").concat(PL(e),"]")),yield t.sendSubscription(n,e),"unsubscribe"===n&&(t.remoteAudioTrack.setMediaStreamTrack(null),t.remoteVideoTrack.setMediaStreamTrack(null),t.remoteAuxiliaryTrack.setMediaStreamTrack(null),t.closePeerConnection(),t.emitConnectionStateChangedEvent("DISCONNECTED"))}()}))}sendSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.subscribeState,i={srcTinyId:this.tinyId,srcUserId:this.userId},r=cL,n=$M.UNSUBSCRIBE_RESULT;return"subscribe_change"===e&&(i={audio:t.audio,bigVideo:t.video,auxVideo:t.auxiliary,smallVideo:t.smallVideo,srcTinyId:this.tinyId},r=lL,n=$M.SUBSCRIBE_CHANGE_RESULT),this._signalChannel.sendWaitForResponse({command:r,data:i,responseCommand:n,timeout:1e4}).then((t=>{let{data:i}=t;if(0!==i.code){let t=new nD({code:i.code,message:Jw({key:rw,data:{type:e,message:i.message}})});throw this._log.error(t),t}}))}connect(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.subscribeState;return function*(){try{yield e.exchangeSDP(t),yield e.waitForPeerConnectionConnected()}catch(i){throw e.closePeerConnection(!0),i}}()}))}exchangeSDP(e){return MA(this,null,(function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer");let{type:t,sdp:i}=this._peerConnection.localDescription,r={type:t,sdp:i,srcUserId:this.userId,srcTinyId:this.tinyId,audio:e.audio,bigVideo:e.video,auxVideo:e.auxiliary,smallVideo:e.smallVideo},n=yield this._signalChannel.sendWaitForResponse({command:sL,commandDesc:"exchange sdp",data:r,responseCommand:$M.SUBSCRIBE_RESULT,timeout:1e4});if(!this._peerConnection){let e=new nD({code:iD.INVALID_OPERATION,message:Jw({key:Uw})});throw this._log.warn(e),e}yield this.onSubscribeResult(n),this._isSDPExchanging=!1}catch(t){throw this._isSDPExchanging=!1,t}}))}createOffer(){return MA(this,null,(function*(){let e={voiceActivityDetection:!1};ND()&&this._sdpSemantics===fb?(this._peerConnection.addTransceiver(bC,{direction:XC}),this._peerConnection.addTransceiver(kC,{direction:XC}),this._peerConnection.addTransceiver(kC,{direction:XC})):(e.offerToReceiveAudio=!0,e.offerToReceiveVideo=!0);let t=yield this._peerConnection.createOffer(e);if(t.sdp){let{isH264DecodeSupported:e}=yield _D();e||(this._log.warn("remove h264 desc from sdp"),t.sdp=function(e){let t=kL(e);return t.media.forEach((e=>{var t,i;if(e.type===kC){let r=new Set;e.rtp.forEach((e=>{let{payload:t,codec:i}=e;return"H264"===i&&r.add(t)})),e.fmtp.forEach((e=>{let{payload:t,config:i}=e,n=i.match(/apt=(\d+)/);n&&n[1]&&r.has(Number(n[1]))&&r.add(t)}));let n=e=>{let{payload:t}=e;return!r.has(t)};e.rtp=e.rtp.filter(n),e.rtcpFb=null==(t=e.rtcpFb)?void 0:t.filter(n),e.fmtp=e.fmtp.filter(n),e.payloads=null==(i=e.payloads)?void 0:i.split(" ").filter((e=>!r.has(Number(e)))).join(" ")}})),wL(t)}(t.sdp)),t.sdp=this.addRRTRLine(t.sdp),t.sdp=this.addSPSDescription(t.sdp),t.sdp=function(e){let t=kL(e);return t.media.forEach((e=>{e.type===bC&&e.fmtp.forEach((e=>{e.config+=";sprop-stereo=1;stereo=1"}))})),wL(t)}(t.sdp),this._sdpSemantics===fb&&(t.sdp=this.removeSDESDescription(t.sdp))}yield this._peerConnection.setLocalDescription(t)}))}onSubscribeResult(e){return MA(this,null,(function*(){let{code:t,message:i=""}=e&&e.data||{},{type:r,sdp:n}=e&&e.data&&e.data.data||{};if(1028===t)throw new nD({code:iD.NOT_SUPPORTED_H264,message:Jw({key:Nw})});try{if(0!==t)throw new nD({code:t,message:Jw({key:ow,data:{errMsg:i}})});this._log.debug("accept remote answer: ".concat(n)),yield this._peerConnection.setRemoteDescription({type:r,sdp:n}),this.updateSSRC(n)}catch(o){throw this._log.error(o),o}}))}updateSSRC(e){try{kL(e).media.forEach((e=>{if(e.ssrcs)if(e.type===bC){let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(eb)}));t&&(this.ssrc.audio=Number(t.id))}else{let t=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes(eb)})),i=e.ssrcs.find((e=>{var t;return null==(t=e.value)?void 0:t.includes("224d130c-7b5c-415b-aaa2-79c2eb5a6df2")}));t&&(this.ssrc.video=Number(t.id)),i&&(this.ssrc.auxiliary=Number(i.id))}}))}catch(t){}}getSubscribeState(){return this.subscribeState}getMainStreamVideoTrackId(){return this.remoteVideoTrack&&this.remoteVideoTrack.mediaTrack?this.remoteVideoTrack.mediaTrack.id:""}getAuxStreamVideoTrackId(){return this.remoteAuxiliaryTrack&&this.remoteAuxiliaryTrack.mediaTrack?this.remoteAuxiliaryTrack.mediaTrack.id:""}reconnect(){return MA(this,null,(function*(){if(!(OA(DL.prototype,this,"beforeReconnect").call(this)<0))try{this.closePeerConnection(),this.initialize(),yield this.connect(),this.stopReconnection(),this._log.warn("reconnect() success")}catch(e){let t=lP(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}getIsReconnecting(){return this._isReconnecting}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}getCurrentState(){return this._currentState}setDelay(e){let{audioDelay:t,videoDelay:i}=e;this.remoteAudioTrack.stat.end2EndDelay=t,this.remoteVideoTrack.stat.end2EndDelay=i}},NL=DL;DA([hO(CL.prototype.afterConnect),uO(CL.prototype.beforeConnect)],NL.prototype,"connect",1);var OL=NL;PA(XA()),PA(XA(),1);var ML=new Map;PA(XA()),PA(XA());var LL=new Blob(["let width,height,offscreen,ctx;onmessage=function(e){const{action,data}=e.data;switch(action){case'render':offscreen=data.canvas;width=offscreen.width;height=offscreen.height;ctx=offscreen.getContext('2d');draw(data.readable,data.writable);break}};function draw(readable,writable){const transformer=new TransformStream({async transform(cameraFrame,controller){ctx.drawImage(cameraFrame,0,0,width,height);const frame=new VideoFrame(offscreen,{timestamp:cameraFrame.timestamp});cameraFrame.close();controller.enqueue(frame)}});readable.pipeThrough(transformer).pipeTo(writable)}"],{type:"application/javascript"}),xL=class{constructor(e){NA(this,"width"),NA(this,"height"),NA(this,"canvas"),NA(this,"offscreen"),NA(this,"smallGenerator"),NA(this,"smallWritable"),NA(this,"bigProcessor"),NA(this,"bigReadable"),NA(this,"worker");let{videoTrack:t}=e;this.width=void 0,this.height=void 0,this.canvas=null,this.offscreen=null,this.smallGenerator=new MediaStreamTrackGenerator({kind:"video"}),this.smallWritable=this.smallGenerator.writable,this.bigProcessor=new MediaStreamTrackProcessor({track:t}),this.bigReadable=this.bigProcessor.readable,this.initWorker()}initWorker(){try{this.worker=new Worker(URL.createObjectURL(LL)),QP.info("init worker processor success")}catch(HO){QP.warn("init worker processor failed. ".concat(HO.error))}}setCanvasRect(e,t){this.width=e,this.height=t,this.canvas=document.createElement("canvas"),this.canvas.width=e,this.canvas.height=t,this.offscreen=this.canvas.transferControlToOffscreen(),this.worker.postMessage({action:"render",data:{canvas:this.offscreen,readable:this.bigReadable,writable:this.smallWritable}},[this.offscreen,this.bigReadable,this.smallWritable])}generateVideoTrack(){let e=new MediaStream([this.smallGenerator]);return null==e?void 0:e.getTracks()[0]}destroy(){this.worker.terminate()}};PA(XA());var UL=class{constructor(e){NA(this,"_player"),NA(this,"_canvas"),NA(this,"_canvasCtx"),this._player=e,this._canvas=document.createElement("canvas"),this._canvasCtx=this._canvas.getContext("2d")}setCanvasRect(e,t){!this._canvas||(this._canvas.width=e,this._canvas.height=t)}drawVideoToCanvas(){let e=this._player.getElement();this._canvas&&this._canvasCtx&&e&&this._canvasCtx.drawImage(e,0,0,this._canvas.width,this._canvas.height)}generateVideoTrack(e){return this._canvas.captureStream(e).getVideoTracks()[0]}generateStreamFromTrack(e){let t=new MediaStream;return t.addTrack(e),t}destroy(){var e;null==(e=this._player)||e.stop(),this._canvas&&(this._canvas.width=0,this._canvas.height=0,this._canvas=null,this._canvasCtx=null)}get canvas(){return this._canvas}get canvasCtx(){return this._canvasCtx}get canDrawVideoToCanvas(){if(this._player){let e=this._player.getElement();if(e)return e.readyState===e.HAVE_ENOUGH_DATA}return!1}},VL=class{constructor(e){NA(this,"_player"),NA(this,"_processor"),NA(this,"_initOffscreenSuccess"),NA(this,"_localVideoTrack"),NA(this,"_interval"),this._localVideoTrack=e,this._player=e.player,this._processor=null,this._initOffscreenSuccess=!1}initialize(){return MA(this,null,(function*(){if(pD()&&(null==navigator?void 0:navigator.hardwareConcurrency)>=6)try{yield this.initOffscreen(),this._initOffscreenSuccess=!0,QP.info("Initialize VideoGenerator successfully!")}catch(HO){this.initCanvas()}else this.initCanvas()}))}generateSmallVideoTrack(e){let t,i=this.getSmallVideoProfile(e);return this._initOffscreenSuccess?(this._processor.setCanvasRect(i.width,i.height),t=this._processor.generateVideoTrack(i.frameRate)):(this._processor.setCanvasRect(i.width,i.height),this._player.setRect(i.width,i.height),t=this._processor.generateVideoTrack(i.frameRate),this._interval=uN.run(Lb,this.render.bind(this),{fps:i.frameRate})),t}render(){this._processor instanceof UL&&this._processor.drawVideoToCanvas()}destroy(){uN.clearTask(this._interval),this._processor&&this._processor.destroy()}initOffscreen(){this._processor=new xL({videoTrack:this._localVideoTrack.mediaTrack})}initCanvas(){this._player=new BN({track:this._localVideoTrack.mediaTrack,muted:!0,objectFit:"cover",mirror:!1,container:null,id:"video-player",log:this._localVideoTrack.log}),this._player.play().then((()=>{QP.info("VideoGenerator: play local video success")})).catch((()=>{QP.error("VideoGenerator: Failed to play local video")})),this._processor=new UL(this._player)}getSmallVideoProfile(e){let t=this._localVideoTrack.mediaTrack,i=this._localVideoTrack.profile;if(xD){let e=t.getSettings();e&&e.width&&e.height&&(i.width=e.width,i.height=e.height)}let r,n=i.width*i.height,o=e.width*e.height;return QP.info("big res: ".concat(i.width,"*").concat(i.height," small res: ").concat(e.width,"*").concat(e.height," ")),n>o?r=n/o:(QP.warn("Small stream resolution is larger than big stream, which is invalid. big: ".concat(i.width," * ").concat(i.height," small: ").concat(e.width," * ").concat(e.height)),r=n/19200),{width:i.width/Math.sqrt(r),height:i.height/Math.sqrt(r),frameRate:e.frameRate}}},FL={voiceActivityDetection:!1},jL=class extends CL{constructor(e){super(bA(CA({},e),{isUplink:!0})),NA(this,"localMainAudioTrack",null),NA(this,"localMainVideoTrack",null),NA(this,"localAuxAudioTrack",null),NA(this,"localAuxVideoTrack",null),NA(this,"ssrc",{audio:0,video:0,small:0,auxiliary:0}),NA(this,"_mixedAudioTrack",null),NA(this,"_isSDPExchanging",!1),NA(this,"_isPublishingAux",!1),NA(this,"_publishingLocalAudioTrack"),NA(this,"_publishingLocalVideoTrack"),NA(this,"_mediaSettings",{videoCodec:"",videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioCodec:"opus",audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0,auxVideoWidth:0,auxVideoHeight:0,auxVideoFps:0,auxVideoBps:0}),NA(this,"_smallGenerator"),NA(this,"_audioManager"),this._audioManager=e.audioManager,this._smallGenerator=null}get isMainStreamPublished(){return!(!this.localMainAudioTrack&&!this.localMainVideoTrack)}get isAuxStreamPublished(){return!(!this.localAuxVideoTrack&&!this.localAuxAudioTrack)}get publishState(){var e,t,i,r;let n={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};if(this._peerConnection){let o=this._peerConnection.getSenders();o&&(DD()?(n.audio=!(null==(e=o[0])||!e.track),n.bigVideo=!(null==(t=o[1])||!t.track),n.smallVideo=!(null==(i=o[2])||!i.track),n.auxVideo=!(null==(r=o[3])||!r.track)):o.forEach((e=>{e.track&&(e.track.kind===bC?n.audio=!0:(n.bigVideo=!0,this._smallGenerator&&(n.smallVideo=!0)))})))}return n}initialize(){super.initialize(),this.installEvents()}reset(){this._isReconnecting&&this.stopReconnection(),this.closePeerConnection(),this.uninstallEvents(),this.localMainVideoTrack&&this.localMainVideoTrack.canvasTrack&&this.localMainVideoTrack.destoryCanvasTrack()}close(){super.close(),this.reset(),this.emitConnectionStateChangedEvent("DISCONNECTED"),this._smallGenerator&&(this._smallGenerator.destroy(),this._smallGenerator=null)}installEvents(){this._emitter.listeners("connection-state-changed").includes(this.handleConnectionStateChange)||this._emitter.on("connection-state-changed",this.handleConnectionStateChange,this)}uninstallEvents(){this._emitter.off("connection-state-changed",this.handleConnectionStateChange,this)}emitConnectionStateChangedEvent(e,t){var i,r,n;let o=this._currentState,a=super.emitConnectionStateChangedEvent(e);return a&&o!==e&&(t?t.emit("connection-state-changed",{prevState:o,state:e}):(null==(i=this.localMainVideoTrack)||i.emit("connection-state-changed",{prevState:o,state:e}),null==(r=this.localAuxVideoTrack)||r.emit("connection-state-changed",{prevState:o,state:e}),null==(n=this._publishingLocalVideoTrack)||n.emit("connection-state-changed",{prevState:o,state:e}))),a}publish(e){return MA(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,isAuxiliary:n}=e;return function*(){var e;let o;return t._peerConnection||t.initialize(),i&&(t._publishingLocalAudioTrack=i),r&&(t._publishingLocalVideoTrack=r),t._isPublishingAux=n,r&&!n&&r.small&&(t._smallGenerator=new VL(r),yield t._smallGenerator.initialize(),o=t._smallGenerator.generateSmallVideoTrack(r.small)),t.updateMediaSettings(),ND()?yield t.publishByTransceiver({localAudioTrack:i,localVideoTrack:r,smallTrack:o,isAuxiliary:n}):yield t.publishByAddTrack({localAudioTrack:i,localVideoTrack:r,smallTrack:o}),t._publishingLocalAudioTrack=null,t._publishingLocalVideoTrack=null,t._isPublishingAux=!1,n?(r&&(t.localAuxVideoTrack=r),i&&(t.localAuxAudioTrack=i)):(r&&(t.localMainVideoTrack=r),i&&(t.localMainAudioTrack=i)),null==(e=t._sei)||e.handleEncodedStreams(),t.installTrackMuteEvents(i,r),t.sendMutedFlag(),{localAudioTrack:i,localVideoTrack:r}}()}))}publishByTransceiver(e){return MA(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n,isAuxiliary:o}=e;return function*(){var e,a;t._log.info("publish by transceiver");let s=new MediaStream;r&&Qk&&qk&&r.genCanvasTrack();let c=(null==r?void 0:r.canvasTrack)||(null==r?void 0:r.mediaTrack),l=null!=(e=t._audioManager)&&e.isNeedToUseDestination()?null==(a=t._audioManager)?void 0:a.mediaStreamTrack:null==i?void 0:i.mediaTrack;l&&s.addTrack(l),c&&s.addTrack(c);let d=t._peerConnection.getTransceivers();if(0===d.length)t._peerConnection.addTransceiver(l||bC,{direction:YC,streams:[s]}),t._peerConnection.addTransceiver(o?kC:c||kC,{direction:YC,streams:[s]}),t._peerConnection.addTransceiver(n||kC,{direction:YC,streams:[s]}),t._peerConnection.addTransceiver(o&&c||kC,{direction:YC,streams:[s]}),yield t.connect();else{let e=[];if(l&&(d[0].sender.track?yield d[0].sender.replaceTrack(l):(yield d[0].sender.replaceTrack(l),e.push(0)),yield t.setBandwidth({bandwidth:(null==i?void 0:i.profile.bitrate)||40,type:bC})),c){let i=o?3:1;yield d[i].sender.replaceTrack(c),yield t.setBandwidth({bandwidth:r.profile.bitrate,type:kC,videoType:o?NC:DC}),e.push(i),n&&(yield d[2].sender.replaceTrack(n),yield t.setBandwidth({bandwidth:r.small.bitrate,type:kC,videoType:PC}),e.push(2))}yield t.setTransceiverDirection(YC,e),yield t.doPublishChange(),null==r||r.emit("connection-state-changed",{prevState:"DISCONNECTED",state:"CONNECTING"}),null==r||r.emit("connection-state-changed",{prevState:"CONNECTING",state:"CONNECTED"})}}()}))}publishByAddTrack(e){return MA(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r,smallTrack:n}=e;return function*(){var e;t._log.info("publish by addtrack");let o=null==r?void 0:r.mediaTrack,a=null!=i&&i.mediaTrack?null==(e=t._audioManager)?void 0:e.mediaStreamTrack:null;if(t._peerConnection&&"new"!==t._peerConnection.connectionState)return a&&(yield t.addTrack(a,i)),void(o&&(yield t.addTrack(o,r)));let s=new MediaStream;if(a&&s.addTrack(a),o&&s.addTrack(o),a&&t._peerConnection.addTrack(a,s),o&&(t._peerConnection.addTrack(o,s),n)){let e=new MediaStream;e.addTrack(n),t._peerConnection.addTrack(n,e)}yield t.connect()}()}))}installTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.on("mute",this.sendMutedFlag,this),null==e||e.on("unmute",this.sendMutedFlag,this))}))}uninstallTrackMuteEvents(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{e&&(null==e||e.off("mute",this.sendMutedFlag,this),null==e||e.off("unmute",this.sendMutedFlag,this))}))}unpublish(e){return MA(this,arguments,(function(e){var t=this;let{localAudioTrack:i,localVideoTrack:r}=e;return function*(){var e,n,o,a;if(!DD()){if(i&&i.mediaTrack&&!r&&t.localMainVideoTrack)return yield t.removeTrack(i.mediaTrack,i),void(t.localMainAudioTrack=null);if(r&&r.mediaTrack&&!i&&t.localMainAudioTrack)return yield t.removeTrack(r.mediaTrack,r),void(t.localMainVideoTrack=null);let e=yield t.doUnpublish();return t.uninstallTrackMuteEvents(i,r),t.emitConnectionStateChangedEvent("DISCONNECTED",r),e}let s=r&&r===t.localAuxVideoTrack,c=null==i?void 0:i.mediaTrack,l=null==r?void 0:r.mediaTrack,d=t._peerConnection.getSenders(),u=[];if(c)if(null!=(e=t._audioManager)&&e.isNeedToUseDestination()){if((null==(n=t._audioManager)?void 0:n.hasAudioTrack)&&t._audioManager.hasMusic&&(t._audioManager.destroyAllMusic(),yield d[0].replaceTrack(null)),t._audioManager.hasAudioTrack&&t._audioManager.hasScreenAudioTrack){let e=s?null==(o=t.localMainAudioTrack)?void 0:o.mediaTrack:null==(a=t.localAuxAudioTrack)?void 0:a.mediaTrack;yield d[0].replaceTrack(e||null)}}else yield d[0].replaceTrack(null),u.push(0),t.localMainAudioTrack=null;l&&(s?(yield d[3].replaceTrack(null),t.localAuxVideoTrack=null,t._mediaSettings=bA(CA({},t._mediaSettings),{auxVideoBps:0,auxVideoFps:0,auxVideoWidth:0,auxVideoHeight:0}),u.push(3)):(yield d[1].replaceTrack(null),yield d[2].replaceTrack(null),t.localMainVideoTrack=null,t._mediaSettings=bA(CA({},t._mediaSettings),{videoWidth:0,videoHeight:0,videoBps:0,videoFps:0,audioFs:0,audioChannel:0,audioBps:0,smallVideoWidth:0,smallVideoHeight:0,smallVideoFps:0,smallVideoBps:0}),u.push(1,2))),t.isMainStreamPublished||t.isAuxStreamPublished?(yield t.setTransceiverDirection(QC,u),yield t.doPublishChange(!1)):yield t.doUnpublish(),t.uninstallTrackMuteEvents(i,r),null==r||r.emit("connection-state-changed",{prevState:t._currentState,state:"DISCONNECTED"})}()}))}doPublishChange(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return MA(this,null,(function*(){let t={state:this.publishState,constraintConfig:this._mediaSettings},i=yield this._signalChannel.sendWaitForResponse({command:oL,data:t,responseCommand:$M.PUBLISH_STATE_CHANGE_RESULT,enableLog:e});this.checkPublishResultCode(i.data.code,i.data.message)}))}doUnpublish(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._signalChannel.sendWaitForResponse({command:aL,commandDesc:"unpublish",responseCommand:$M.UNPUBLISH_RESULT,enableLog:e}).catch((e=>{if(e.getCode()===iD.API_CALL_TIMEOUT)return Promise.resolve();throw e}))}updateMediaSettings(){let{detail:{isH264EncodeSupported:e,isVp8EncodeSupported:t}}=this._room.checkSystemResult;e?this._mediaSettings.videoCodec="H264":t&&(this._mediaSettings.videoCodec="VP8");let i=this._publishingLocalAudioTrack||this.localMainAudioTrack||this.localAuxAudioTrack,{localMainVideoTrack:r,localAuxVideoTrack:n}=this;if(this._publishingLocalVideoTrack&&(this._isPublishingAux?n=this._publishingLocalVideoTrack:r=this._publishingLocalVideoTrack),xD){if(i&&i.mediaTrack){let e=i.mediaTrack.getSettings();this._mediaSettings.audioChannel=e.channelCount||1,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=e.sampleRate||0}if(r&&r.mediaTrack){let e=r.mediaTrack.getSettings();this._mediaSettings.videoWidth=e.width||0,this._mediaSettings.videoHeight=e.height||0,this._mediaSettings.videoFps=e.frameRate||0,this._mediaSettings.videoBps=1e3*r.profile.bitrate,r.small&&(this._mediaSettings.smallVideoWidth=r.small.width,this._mediaSettings.smallVideoHeight=r.small.height,this._mediaSettings.smallVideoFps=r.small.frameRate,this._mediaSettings.smallVideoBps=1e3*r.small.bitrate)}if(n&&n.mediaTrack){let e=n.mediaTrack.getSettings();this._mediaSettings.auxVideoWidth=e.width||0,this._mediaSettings.auxVideoHeight=e.height||0,this._mediaSettings.auxVideoFps=e.frameRate||0,this._mediaSettings.auxVideoBps=1e3*n.profile.bitrate}}else i&&i.mediaTrack&&(this._mediaSettings.audioChannel=i.profile.channelCount,this._mediaSettings.audioBps=1e3*i.profile.bitrate,this._mediaSettings.audioFs=i.profile.sampleRate),r&&r.mediaTrack&&(this._mediaSettings.videoWidth=r.profile.width,this._mediaSettings.videoHeight=r.profile.height,this._mediaSettings.videoFps=r.profile.frameRate,this._mediaSettings.videoBps=1e3*r.profile.bitrate);this._log.info("updateMediaSettings: ".concat(JSON.stringify(this._mediaSettings)))}sendMediaSettings(){this.updateMediaSettings(),this._signalChannel.sendWaitForResponse({command:vL,data:this._mediaSettings,responseCommand:$M.UPDATE_CONSTRAINT_CONFIG_RES}).then((e=>{0!==e.data.code&&this._log.warn(e.data.message)})).catch(this._log.warn)}addTrack(e,t){return MA(this,null,(function*(){var i;if(!this._peerConnection)return;let r=t===this.localAuxAudioTrack||t===this.localAuxVideoTrack;this._log.info("is adding ".concat(e.kind," track to current published local ").concat(r?NC:JC," stream")),null==(i=this._sei)||i.handleEncodedStreams(),DD()?yield this.addTrackByTransceiver(e,r):yield this.addTrackBySender(e,t)}))}addTrackByTransceiver(e,t){return MA(this,null,(function*(){var i;let r=this._peerConnection.getTransceivers();if(e.kind===bC)r[0].sender.track?(this.mixAudioTrack(r[0].sender.track,e),yield r[0].sender.replaceTrack(this._mixedAudioTrack)):yield r[0].sender.replaceTrack(e);else{let n=t?3:1;if(yield r[n].sender.replaceTrack(e),1===n&&(null==(i=this.localMainVideoTrack)?void 0:i.small)){this._smallGenerator=new VL(this.localMainVideoTrack),yield this._smallGenerator.initialize();let e=this._smallGenerator.generateSmallVideoTrack(this.localMainVideoTrack.small);yield r[2].sender.replaceTrack(e)}r[n].direction===QC&&(yield this.setTransceiverDirection(YC,[n]))}this.updateMediaSettings(),yield this.doPublishChange()}))}addTrackBySender(e,t){return MA(this,null,(function*(){DD()&&this._peerConnection.getTransceivers().findIndex((e=>"stopped"===e.direction))>=0&&(this._log.warn("transceiver is stopping, negotiate sdp first"),yield this.updateOffer("remove",e));let i=this._peerConnection.getSenders().find((t=>t.track&&t.track.kind===e.kind));if(i&&i.track){this._log.warn("sender already exists, remove sender first");let e=i.track;this.removeSender(i),yield this.updateOffer("remove",e)}let{mediaStream:r}=t;if(this._peerConnection.addTrack(e,r),e.kind===kC&&t instanceof fO&&t.small){this._smallGenerator=new VL(t),yield this._smallGenerator.initialize();let e=this._smallGenerator.generateSmallVideoTrack(t.small),i=new MediaStream;i.addTrack(e),this._peerConnection.addTrack(e,i)}yield this.updateOffer("add",e)}))}isNeedToResetOfferOrder(){if(this._sdpSemantics===gb||!this._peerConnection||!this._peerConnection.localDescription)return!1;let{sdp:e}=this._peerConnection.localDescription,t=kL(e);for(let i=0;i<t.media.length;i++)if(0===Number(t.media[i].mid)&&t.media[i].type===kC)return!0;return!1}removeSender(e){let t=null;DD()&&(t=this._peerConnection.getTransceivers().find((t=>t.sender&&t.sender.track===e.track))),this._peerConnection.removeTrack(e),t&&uP(t.stop)&&(this._log.info("stop transceiver"),t.stop())}removeTrack(e,t){return MA(this,null,(function*(){if(!this._peerConnection)return;let i=t===this.localAuxAudioTrack||t===this.localAuxVideoTrack;this._log.info("is removing ".concat(e.kind," track from current published local ").concat(i?NC:JC," stream")),DD()?yield this.removeTrackByTransceiver(e,i):yield this.removeTrackBySender(e)}))}removeTrackByTransceiver(e,t){return MA(this,null,(function*(){var i,r;let n=this._peerConnection.getTransceivers();if(e.kind===bC)if(this._mixedAudioTrack){let e=t?null==(i=this.localMainAudioTrack)?void 0:i.mediaTrack:null==(r=this.localAuxAudioTrack)?void 0:r.mediaTrack;yield n[0].sender.replaceTrack(e||null),this.destroyMixedAudioTrack()}else yield n[0].sender.replaceTrack(null);else{let e=t?3:1;yield n[e].sender.replaceTrack(null),1===e&&this._smallGenerator&&(this._smallGenerator.destroy(),this._smallGenerator=null,yield n[2].sender.replaceTrack(null)),yield this.setTransceiverDirection(QC,[e])}this.updateMediaSettings(),yield this.doPublishChange()}))}setTransceiverDirection(e,t){return MA(this,null,(function*(){if(!$b)return;let i=!1,r=!1;this._log.info("setting transceiver ".concat(t.join(",")," direction to ").concat(e));let n=this._peerConnection.getTransceivers();if(t.forEach((t=>{n[t].direction!==e&&(n[t].direction=e,i=!0)})),i){this._log.info("updating offer");let e=yield this._peerConnection.createOffer();yield this._peerConnection.setLocalDescription(e)}let o=-1,a=this._peerConnection.remoteDescription.sdp.split("\r\n").map((i=>{if(i.match(new RegExp("a=(".concat(QC,"|").concat(XC,"|").concat(YC,")")))&&o++,t.includes(o)){if(e===QC&&i.includes("a=".concat(XC)))return r=!0,"a=".concat(e);if(e===YC&&i.includes("a=".concat(QC)))return r=!0,"a=".concat(XC)}return i})).join("\r\n");r&&(this._log.info("updating answer"),yield this._peerConnection.setRemoteDescription({type:"answer",sdp:a}))}))}removeTrackBySender(e){return MA(this,null,(function*(){var t,i;if(e.kind===kC&&this.isNeedToResetOfferOrder()&&this.localMainAudioTrack)return this.reset(),this.initialize(),null==(i=null==(t=this.localMainVideoTrack)?void 0:t.mediaStream)||i.removeTrack(e),void(yield this.publish({localAudioTrack:this.localMainAudioTrack,isAuxiliary:!1}));let r=this._peerConnection.getSenders().find((t=>t.track===e));r&&(this.removeSender(r),e.kind===kC&&this._smallGenerator&&(this._smallGenerator.destroy(),this._smallGenerator=null,this._peerConnection.getSenders().forEach((e=>{e.track&&e.track.kind===kC&&this.removeSender(e)})))),yield this.updateOffer("remove",e)}))}replaceTrack(e,t){return MA(this,null,(function*(){var i,r,n;let o=null==(i=this._peerConnection)?void 0:i.getSenders();if(!o||0===o.length)return;let a=t===this.localAuxAudioTrack||t===this.localAuxVideoTrack;if(this._log.info("is replacing ".concat(e.kind," track on ").concat(a?NC:JC," stream")),e.kind===bC&&o[0])if(this._mixedAudioTrack&&(null==(r=this.localMainAudioTrack)?void 0:r.mediaTrack)&&(null==(n=this.localAuxAudioTrack)?void 0:n.mediaTrack)){this.destroyMixedAudioTrack();let t=a?this.localMainAudioTrack.mediaTrack:this.localAuxAudioTrack.mediaTrack;this.mixAudioTrack(e,t),yield o[0].replaceTrack(this._mixedAudioTrack)}else yield o[0].replaceTrack(e);if(e.kind===kC){if(!a&&o[1]&&(yield o[1].replaceTrack(e),this._smallGenerator&&o[2])){this._log.info("replacing smallVideo"),this._smallGenerator.destroy(),this._smallGenerator=new VL(this.localMainVideoTrack),yield this._smallGenerator.initialize();let e=this._smallGenerator.generateSmallVideoTrack(this._room.smallStreamConfig);yield o[2].replaceTrack(e)}a&&o[3]&&(yield o[3].replaceTrack(e))}}))}updateOffer(e,t){return MA(this,null,(function*(){try{let i=yield this._peerConnection.createOffer(FL);$b&&i.sdp&&(i.sdp=this.setSDPDirection(i.sdp,"sendrecv")),yield this._peerConnection.setLocalDescription(i);let r=this.updateMediaSettings(),n={action:e,trackId:t.id,kind:t.kind===kC?"bigVideo":t.kind,type:"offer",sdp:this._peerConnection.localDescription.sdp,constraintConfig:r,state:this.publishState};this._log.info("createOffer success, sending updated offer to remote server"),this._log.debug("updatedOffer: ".concat(n.sdp));let o=yield this._signalChannel.sendWaitForResponse({command:ZM,data:n,responseCommand:$M.UPDATE_OFFER_RESULT,timeout:1e4,commandDesc:"update offer"}),{code:a,message:s}=o.data;0!==a&&this.checkPublishResultCode(a,s),yield this.acceptAnswer(o.data.data),i.sdp&&this.updateSSRC(i.sdp)}catch(QO){throw this._log.error(QO),QO}}))}setBandwidth(e){return MA(this,arguments,(function(e){var t=this;let{bandwidth:i,type:r,videoType:n,sdp:o}=e;return function*(){if(!LD())return o?r===kC?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i):void 0;let e=0;r===kC&&(e=n===PC?2:n===NC?3:1);let a=t._peerConnection.getSenders()[e];if(a){let e=a.getParameters();(!e.encodings||0===e.encodings.length)&&(e.encodings=[{}]),e.encodings[0].maxBitrate=1e3*i;try{return yield a.setParameters(e),t._log.info("".concat(n||"").concat(r," bandwidth ").concat(i," kbps")),o}catch(s){if(t._log.info("failed to set bandwidth by setting maxBitrate: ".concat(s)),o)return r===kC?t.updateVideoBandwidthRestriction(o,i,n):t.updateAudioBandwidthRestriction(o,i)}}return o}()}))}updateVideoBandwidthRestriction(e,t,i){let r="AS";$b&&(r="TIAS",t*=1e3);let n=0,o=-1;return i===PC?n=1:i===NC&&(n=2),e=e.replace(/m=video (.*)\r\nc=IN (.*)\r\n/g,(e=>(o+=1,o===n?"".concat(e,"b=").concat(r,":").concat(t,"\r\n"):e)))}updateAudioBandwidthRestriction(e,t){let i="AS";return $b&&(i="TIAS",t*=1e3),e=e.replace(/m=audio (.*)\r\nc=IN (.*)\r\n/,"m=audio $1\r\nc=IN $2\r\nb=".concat(i,":").concat(t,"\r\n"))}removeBandwidthRestriction(e){return e.replace(/b=AS:.*\r\n/,"").replace(/b=TIAS:.*\r\n/,"")}removeVideoOrientation(e){return e.replace(/urn:3gpp:video-orientation/,"")}connect(){return MA(this,null,(function*(){try{yield this.exchangeSDP(),yield this.waitForPeerConnectionConnected()}catch(e){throw this.closePeerConnection(!0),this.uninstallEvents(),e}}))}exchangeSDP(){return MA(this,null,(function*(){try{this._isSDPExchanging=!0,yield this.createOffer(),this._log.info("createOffer success, sending offer to remote server"),yield this.doExchangeSDP(),this._isSDPExchanging=!1}catch(e){throw this._isSDPExchanging=!1,e}}))}createOffer(){return MA(this,null,(function*(){try{let e=yield this._peerConnection.createOffer(FL);yield this._peerConnection.setLocalDescription(e),e.sdp&&this.updateSSRC(e.sdp)}catch(e){throw e}}))}doExchangeSDP(){let e={command:nL,responseCommand:$M.PUBLISH_RESULT,data:{type:this._peerConnection.localDescription.type,sdp:this.removeVideoOrientation(this._peerConnection.localDescription.sdp),screen:this.localMainVideoTrack instanceof SO||this.localAuxVideoTrack instanceof SO,state:this.publishState,constraintConfig:this._mediaSettings},enableLog:!1};return this._log.debug("sending sdp offer: ".concat(e.data.sdp)),this._signalChannel.sendWaitForResponse(e).then((e=>{let{code:t,message:i,data:r}=e.data;return 0===t?this.acceptAnswer(r):this.checkPublishResultCode(t,i)}))}setSDPDirection(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"all",r=kL(e);return r.media.forEach((e=>{("all"===i||e.type===i)&&(e.direction=t)})),wL(r)}acceptAnswer(e){return MA(this,null,(function*(){var t,i,r,n,o;try{let a;if(this._publishingLocalAudioTrack||this._publishingLocalVideoTrack||this.isMainStreamPublished){let e=(null==(t=this._publishingLocalVideoTrack)?void 0:t.profile.bitrate)||(null==(i=this.localMainVideoTrack)?void 0:i.profile.bitrate),o=(null==(r=this._publishingLocalAudioTrack)?void 0:r.profile.bitrate)||(null==(n=this.localMainAudioTrack)?void 0:n.profile.bitrate);if(e){let t=this._isPublishingAux?NC:DC;a=yield this.setBandwidth({bandwidth:e,type:kC,sdp:a,videoType:t})}o&&(a=yield this.setBandwidth({bandwidth:o,type:bC,sdp:a}))}if(a=this.removeVideoOrientation(e.sdp),null!=(o=this._publishingLocalVideoTrack)&&o.small){let{smallStreamConfig:e}=this._room;a=yield this.setBandwidth({bandwidth:e.bitrate,type:kC,videoType:PC,sdp:a})}let s={type:e.type,sdp:a};yield this._peerConnection.setRemoteDescription(s),this._log.debug("accepted answer: ".concat(a))}catch(a){throw this._log.error("failed to accept remote answer ".concat(a)),a}}))}sendMutedFlag(e){var t,i,r;if(e===this.localAuxAudioTrack||e===this.localAuxVideoTrack)return;let n={audio:!(null==(t=this.localMainAudioTrack)||!t.muted),bigVideo:!(null==(i=this.localMainVideoTrack)||!i.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)};this._log.info("send muted state: ".concat(JSON.stringify(n))),this._signalChannel.send(rL,n)}getIsReconnecting(){return this._isReconnecting}reconnect(){return MA(this,null,(function*(){if(!(OA(jL.prototype,this,"beforeReconnect").call(this)<0))try{yield this._signalChannel.sendWaitForResponse({command:aL,responseCommand:$M.UNPUBLISH_RESULT,enableLog:!1}),this.closePeerConnection(),this.initialize(),this.isMainStreamPublished&&(yield this.publish({localAudioTrack:this.localMainAudioTrack,localVideoTrack:this.localMainVideoTrack,isAuxiliary:!1})),this.isAuxStreamPublished&&(yield this.publish({localAudioTrack:this.localAuxAudioTrack,localVideoTrack:this.localAuxVideoTrack,isAuxiliary:!0})),this._log.warn("reconnect() uplink reconnect successfully"),this.stopReconnection()}catch(e){let t=lP(this._reconnectionCount);this._log.warn("reconnect() timeout, try again after ".concat(t/1e3,"s")),this._reconnectionTimer=setTimeout((()=>{this.clearReconnectionTimer(),this.reconnect()}),t)}}))}handleConnectionStateChange(e){"CONNECTED"===e.state&&(this.localMainVideoTrack||this._publishingLocalVideoTrack&&!this._isPublishingAux)&&WP.emit(KP.SEND_FIRST_VIDEO_FRAME,{room:this._room})}updateSSRC(e){try{kL(e).media.forEach(((e,t)=>{if(e.type===bC){let t=e.ssrcs&&e.ssrcs[0];t&&(this.ssrc.audio=Number(t.id))}else{if(this._sdpSemantics===gb&&e.ssrcGroups)return void e.ssrcGroups.forEach(((e,t)=>{let i=Number(e.ssrcs.split(" ")[0]);0===t?this.ssrc.video=i:1===t&&(this.ssrc.small=i)}));let i=e.ssrcs&&e.ssrcs[0];if(!i)return;switch(t){case 1:this.ssrc.video=Number(i.id);break;case 2:this.ssrc.small=Number(i.id);break;case 3:this.ssrc.auxiliary=Number(i.id)}}}))}catch(t){}}getVideoTrackId(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:kC;if(this._peerConnection){let t=this._peerConnection.getSenders();if(e===NC&&t[3]&&t[3].track)return t[3].track.id;if(e===kC&&t[1]&&t[1].track)return t[1].track.id}if(this.localMainVideoTrack&&e===kC){let e=this.localMainVideoTrack.mediaTrack;if(e)return e.id}if(this.localAuxVideoTrack&&e===NC){let e=this.localAuxVideoTrack.mediaTrack;if(e)return e.id}return""}getSSRC(){return this.ssrc}checkPublishResultCode(e,t){if(0!==e)throw 1028===e?(this._log.error(jw.NOT_SUPPORTED_H264ENCODE),new nD({code:iD.NOT_SUPPORTED_H264,message:Jw({key:Dw})})):new nD({code:iD.UNKNOWN,message:Jw({key:Lw,data:{signalResponse:$M.PUBLISH_RESULT,code:e,message:t}})})}sendSEI(e,t){var i;null==(i=this._sei)||i.push(e,t)}mixAudioTrack(e,t){this._log.info("mix audio track"),this._mixedAudioTrack=function(e){let t=RP(),i=t.createMediaStreamDestination(),r=[];e.forEach((e=>{let n=new MediaStream;n.addTrack(e);let o=t.createMediaStreamSource(n);o.connect(i),r.push(o)}));let n=i.stream.getAudioTracks()[0];return ML.set(n,{destination:i,track:n,mediaStreamSourceList:r}),n}([e,t])}destroyMixedAudioTrack(){this._mixedAudioTrack&&(this._log.info("destroy audio track"),function(e){if(ML.has(e)){let{destination:t,track:i,mediaStreamSourceList:r}=ML.get(e);i.stop(),t.disconnect(),r.forEach((e=>{e.disconnect()})),ML.delete(e)}}(this._mixedAudioTrack),this._mixedAudioTrack=null)}},BL=jL;DA([hO(CL.prototype.afterConnect),uO(CL.prototype.beforeConnect)],BL.prototype,"connect",1);var HL=BL;PA(XA());PA(XA());var GL=PA($A()),WL=class extends GL.default{constructor(e){let{signalChannel:t,room:i}=e;super(),NA(this,"_room"),NA(this,"_signalChannel"),NA(this,"_log"),NA(this,"_uplinkRTT",0),NA(this,"_uplinkLoss",0),NA(this,"_downlinkRTT",0),NA(this,"_downlinkLoss",0),NA(this,"_downlinkPrevStatMap",new Map),NA(this,"_downlinkLossAndRTTMap",new Map),NA(this,"_interval",-1),NA(this,"_uplinkNetworkQuality",0),NA(this,"_downlinkNetworkQuality",0),this._room=i,this._signalChannel=t,this._log=QP.createLogger({id:"q",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.initialize()}get uplinkNetworkQuality(){return this._uplinkNetworkQuality}set uplinkNetworkQuality(e){e!==this._uplinkNetworkQuality&&this._log.info("uplink network quality change ".concat(this.uplinkNetworkQuality," -> ").concat(e,", rtt: ").concat(this._uplinkRTT,", loss: ").concat(this._uplinkLoss)),this._uplinkNetworkQuality=e}get downlinkNetworkQuality(){return this._downlinkNetworkQuality}set downlinkNetworkQuality(e){if(e!==this._downlinkNetworkQuality){let{rtt:t,loss:i}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._log.info("downlink network quality change ".concat(this.downlinkNetworkQuality," -> ").concat(e,", rtt: ").concat(t,", loss: ").concat(i))}this._downlinkNetworkQuality=e}initialize(){this._signalChannel.on($M.UPLINK_NETWORK_STATS,(e=>{this.handleUplinkNetworkQuality(e)})),this._signalChannel.on(WM,this.handleSignalConnectionStateChange.bind(this)),this.start()}handleUplinkNetworkQuality(e){var t,i;if(0!==e.data.code)return;let r=e.data.data;if(r.delay&&this.updateDelay(r.delay),!this._room.uplinkConnection)return this.uplinkNetworkQuality=0,this._uplinkLoss=0,void(this._uplinkRTT=0);let n=null==(i=null==(t=this._room)?void 0:t.uplinkConnection)?void 0:i.getPeerConnection();if(n&&this.isPeerConnectionDisconnected(n))return this.uplinkNetworkQuality=6,this._uplinkLoss=0,void(this._uplinkRTT=0);let o=r.expectAudPkg+r.expectVidPkg,a=r.recvAudPkg+r.recvVidPkg,s=o-a;0===o&&0===a||(this._uplinkLoss=s<=0?0:Math.round(s/o*100),this._uplinkRTT=r.rtt,this.uplinkNetworkQuality=this.getNetworkQuality(this._uplinkLoss,this._uplinkRTT))}handleDownlinkNetworkQuality(){return MA(this,null,(function*(){if(0===this._room.remotePublishedUserMap.size)return void(this.downlinkNetworkQuality=0);let e=[...this._room.remotePublishedUserMap.values()],t=e.filter((e=>{var t;return(null==(t=e.getPeerConnection())?void 0:t.connectionState)===lb}));if(e.filter((e=>this.isPeerConnectionDisconnected(e.getPeerConnection()))).length===e.length)return void(this.downlinkNetworkQuality=6);for(let n=0;n<t.length;n++){let e=t[n].getPeerConnection();if(!e)return;let{rtt:i,totalPacketsLost:r,totalPacketsReceived:o}=yield this.getStat(e);if(!this._downlinkPrevStatMap.has(e)){this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o});continue}let a=0,s=this._downlinkPrevStatMap.get(e),c=r-s.totalPacketsLost,l=o-s.totalPacketsReceived;a=c<=0||l<0?0:Math.round(c/(c+l)*100),this._downlinkPrevStatMap.set(e,{totalPacketsLost:r,totalPacketsReceived:o}),this._downlinkLossAndRTTMap.set(e,{rtt:i,loss:a,userId:t[n].getUserId(),audioDelay:t[n].remoteAudioTrack.stat.end2EndDelay,videoDelay:t[n].remoteVideoTrack.stat.end2EndDelay})}if([...this._downlinkPrevStatMap.keys()].forEach((e=>{this.isPeerConnectionDisconnected(e)&&(this._downlinkPrevStatMap.delete(e),this._downlinkLossAndRTTMap.delete(e))})),0===this._downlinkLossAndRTTMap.size)return;let{rtt:i,loss:r}=this.getAverageLossAndRTT([...this._downlinkLossAndRTTMap.values()]);this._downlinkRTT=i,this._downlinkLoss=r,this.downlinkNetworkQuality=this.getNetworkQuality(r,i)}))}getStat(e){return MA(this,null,(function*(){let t={rtt:0,totalPacketsLost:0,totalPacketsReceived:0};if(!e||!wD())return t;let i=e.getReceivers();try{for(let e=0;e<i.length;e++)(yield i[e].getStats()).forEach((e=>{"candidate-pair"===e.type&&mP(e.currentRoundTripTime)&&(t.rtt=Math.round(1e3*e.currentRoundTripTime)),"inbound-rtp"===e.type&&(e.mediaType===bC||e.mediaType===kC)&&(t.totalPacketsLost+=e.packetsLost,t.totalPacketsReceived+=e.packetsReceived)}));return t}catch(r){return t}}))}getAverageLossAndRTT(e){let t={rtt:0,loss:0};return Array.isArray(e)&&e.length>0&&(e.forEach((e=>{t.rtt+=e.rtt,t.loss+=e.loss})),Object.keys(t).forEach((i=>{t[i]=Math.round(t[i]/e.length)}))),t}getNetworkQuality(e,t){return e>50||t>500?5:e>30||t>350?4:e>20||t>200?3:e>10||t>100?2:e>=0||t>=0?1:0}handleSignalConnectionStateChange(e){e.state===KM?(this._uplinkRTT=0,this._uplinkLoss=0,this.uplinkNetworkQuality=6):e.state===QM&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}handleUplinkConnectionStateChange(e){let{state:t}=e;"DISCONNECTED"===t?(this._uplinkLoss=0,this._uplinkRTT=0,this.uplinkNetworkQuality=6):"CONNECTED"===t&&6===this.uplinkNetworkQuality&&(this.uplinkNetworkQuality=5)}isPeerConnectionDisconnected(e){return!(!e||e.connectionState!==cb&&e.connectionState!==ab&&e.connectionState!==sb)}setUplinkConnection(e){this._room.uplinkConnection=e,this._room.uplinkConnection?this._room.uplinkConnection.on(hN,this.handleUplinkConnectionStateChange.bind(this)):(this.uplinkNetworkQuality=0,this._uplinkRTT=0,this._uplinkLoss=0)}start(){-1===this._interval?(this._log.debug("start network quality calculating"),this._interval=uN.run(Mb,(()=>{this.handleDownlinkNetworkQuality();let e=[...this._downlinkLossAndRTTMap.values()];WP.emit(KP.NETWORK_QUALITY,{room:this._room,uplink:{rtt:this._uplinkRTT,loss:this._uplinkLoss},downlinks:e}),this.emit(WL.EVENT_NETWORK_QUALITY,{uplinkNetworkQuality:this.uplinkNetworkQuality,downlinkNetworkQuality:this.downlinkNetworkQuality,uplinkRTT:this._uplinkRTT,uplinkLoss:this._uplinkLoss,downlinkRTT:this._downlinkRTT,downlinkLoss:this._downlinkLoss,downlinkInfo:e})}),{delay:2e3})):this._log.info("network quality calculating is already started")}stop(){this._log.info("stop network quality calculating"),-1!==this._interval&&(uN.clearTask(this._interval),this._interval=-1),this._downlinkLossAndRTTMap.clear(),this._downlinkPrevStatMap.clear()}updateDelay(e){let{tinyIdToUserIdMap:t}=this._room;e.forEach((e=>{let{srcTinyId:i,videoDelay:r,audioDelay:n}=e,o=t.get(i);if(o){let e=this._room.remotePublishedUserMap.get(o);null==e||e.setDelay({videoDelay:r,audioDelay:n})}}))}},JL=WL;NA(JL,"EVENT_NETWORK_QUALITY","0"),PA(XA(),1),PA(XA(),1),PA(XA(),1);var zL=new WeakMap;function KL(e){let{settings:t={retries:5,timeout:2e3},onError:i,onRetrying:r,onRetryFailed:n}=e;return function(e,o,a){let s=GP({retryFunction:a.value,settings:t,onError(t,r,n){i&&i.call(this,t,(()=>{var i;null!=(i=zL.get(e))&&i.has(o)?r():n(t)}),n)},onRetrying:(t,i)=>{var n;uP(r)&&r(t,i),null!=(n=zL.get(e))&&n.has(o)&&(zL.get(e).get(o).stopRetry=i)},onRetryFailed:n});return a.value=function(){let t=zL.get(e);for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return t?t.set(o,{args:r}):zL.set(e,new Map([[o,{args:r}]])),s.apply(this,r).finally((()=>{var t;return null==(t=zL.get(e))?void 0:t.delete(o)}))},a}}function qL(e){let{fnName:t,callback:i,validateArgs:r=!0}=e;return function(e,n,o){let a=o.value;return o.value=function(){for(var n,o,s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];if(null!=(n=zL.get(e))&&n.has(t)){let{stopRetry:n,args:a}=zL.get(e).get(t),s=!0;if(r)for(let e of a)if(!c.find((t=>t===e))){s=!1;break}s&&(i&&i.apply(this,c),n&&n(),null==(o=zL.get(e))||o.delete(t))}return a.apply(this,c)},o}}var QL=class{constructor(e){NA(this,"_frameWorkType"),NA(this,"_component"),NA(this,"_room"),NA(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0}),NA(this,"_keyPrefix"),NA(this,"_log"),NA(this,"_intervalId"),NA(this,"_firstPublishedUserList"),NA(this,"_networkQuality"),NA(this,"_basicInfo"),NA(this,"_pathJoinRoom"),NA(this,"_pathLeaveRoom"),NA(this,"_pathMainVideoMap"),NA(this,"_pathMainAudioMap"),NA(this,"_pathAuxiliaryMap"),NA(this,"_remoteStreamStatMap"),NA(this,"_localStreamStat"),NA(this,"_apiSuccessRateMap",new Map),NA(this,"_eventMap",new Map),this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this._room=e.room,this._keyPrefix="key_point",this._log=QP.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&uP(this[e])&&(this[e]=Zw({fn:this[e],context:this}))})),this.initData(),this.installEvents(),this._intervalId=uN.run(Mb,this.setStorage.bind(this),{delay:2e4})}get _storageKey(){return"".concat(this._keyPrefix,"_").concat(this._room.userId)}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:oC,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:EC[Xw()],uint32_framework:this._frameWorkType,uint32_component:this._component},this._pathJoinRoom={uint64_start_time:0,uint64_init_audio_start_time:0,uint64_init_audio_end_time:0,uint64_init_camera_start_time:0,uint64_init_camera_end_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_init_audio_ret:0,int32_init_camera_ret:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,this._apiSuccessRateMap.clear()}addEvent(e,t){return this._eventMap.set(e,t),WP.on(e,t),this}installEvents(){this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(KP.JOIN_START,this.handleJoinStart).addEvent(KP.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(KP.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(KP.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(KP.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(KP.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(KP.JOIN_FAILED,this.handleJoinFailed).addEvent(KP.LEAVE_START,this.handleLeaveStart).addEvent(KP.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(KP.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(KP.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(KP.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(KP.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(KP.PUBLISH_START,this.handlePublishStart).addEvent(KP.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(KP.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(KP.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(KP.PLAY_TRACK_START,this.handlePlayStart).addEvent(KP.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(KP.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,type:r}=e;!TP(t)||!this.hitTest(t.room)||"PLAYING"===i&&(r===bC?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(KP.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(KP.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(KP.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(KP.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let n=i.hasAudio||i.hasVideo||i.hasSmall,o=i.hasAuxiliary,a=r.hasAudio||r.hasVideo||r.hasSmall,s=r.hasAuxiliary;!n&&a&&this.handleRemoteStreamAdded(r.userId,"main"),!o&&s&&this.handleRemoteStreamAdded(r.userId,"auxiliary")})).addEvent(KP.API_SUCCESS_RATE,this.handleAPISuccessRate)}uninstallEvents(){this._eventMap.forEach(((e,t)=>WP.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),uN.clearTask(this._intervalId)}handleJoinStart(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now(),this.checkStorage())}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:i}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),i&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=i instanceof nD?Number(i.getExtraCode()||i.getCode()):iD.UNKNOWN,this._pathJoinRoom.int32_end_ret=2))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=3))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=3),this.report())}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;!this.hitTest(t)||0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleRemoteStreamAdded(e,t){var i;let r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){let n={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:bA(CA({},$L),{msg_user_info:new ZL({userId:e,tinyId:null==(i=this._room.remotePublishedUserMap.get(e))?void 0:i.tinyId,role:20})})};n.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,n)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:i,streamType:r,subscribeState:n}=e;if(!this.hitTest(t))return;let{userId:o,tinyId:a,role:s}=i,c=new ZL({userId:o,tinyId:a,role:"anchor"===s?20:21}),l=Date.now(),d="".concat(o,"_").concat(r),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=l),"main"===r?(i.muteState.hasVideo&&(n.video||n.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:o,sendSubscribeCMDTime:l}),i.muteState.hasAudio&&n.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:o,sendSubscribeCMDTime:l})):i.muteState.hasAuxiliary&&n.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:i,streamType:r}=e;if(this.hitTest(t)){let e="".concat(i.userId,"_").concat(r),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!TP(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(i);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!TP(t)||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(i);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=Date.now(),r=this._pathMainVideoMap.get(t),n=this._remoteStreamStatMap.get(t);if(r&&(0===r.statsToReport.uint64_render_first_frame_time&&(r.statsToReport.uint64_render_first_frame_time=i),n)){let{statsToReport:e,playStreamTime:t,subscribedTime:o}=n;0===e.uint32_video_render_first&&t-o<=100&&(e.uint32_video_render_first=i-r.sendSubscribeCMDTime)}let o=this._pathAuxiliaryMap.get(t);if(o&&n){let{statsToReport:e,playStreamTime:t,subscribedTime:r}=n;0===e.uint32_video_render_first&&t-r<=100&&(e.uint32_video_render_first=i-o.sendSubscribeCMDTime)}}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainAudioMap.get(t);i&&0===i.statsToReport.uint64_play_first_frame_time&&(i.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:i,userId:r,videoDelay:n,audioDelay:o}=e,a=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(a)a.totalRTT+=t,a.totalLoss+=i,n&&(a.totalVideoDelay=(a.totalVideoDelay||0)+n,a.videoDelayCount=(a.videoDelayCount||0)+1),o&&(a.totalAudioDelay=(a.totalAudioDelay||0)+o,a.audioDelayCount=(a.audioDelayCount||0)+1),a.count++;else{let e,a,s,c;n&&(a=n,s=1),o&&(e=o,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(r,{totalRTT:t,totalLoss:i,count:1,totalAudioDelay:e,totalVideoDelay:a,audioDelayCount:c,videoDelayCount:s})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_up_stream_info:t,msg_down_stream_info:i}=e.report;if(t.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:i,uint32_video_width:r,uint32_video_height:n}=t.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=i,this._localStreamStat.totalVideoWidth+=r,this._localStreamStat.totalVideoHeight+=n,this._localStreamStat.videoCount++}if(t.msg_audio_status){let{uint32_audio_level:e}=t.msg_audio_status;Math.floor(e/Zk*100)>0&&(this._localStreamStat.totalAudioLevel+=e/Zk,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:i,msg_video_status:r}=e,n=t.str_identifier,o=this._room.remotePublishedUserMap.get(n);if(r.forEach((e=>{let t=2===e.uint32_video_stream_type,i=7===e.uint32_video_stream_type,r="".concat(n,"_").concat(t?"main":"auxiliary"),a=this._remoteStreamStatMap.get(r);if(a&&(t&&(null==o?void 0:o.remoteVideoTrack.isSubscribed)||i&&(null==o?void 0:o.remoteAuxiliaryTrack))){a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height);let i=t?o.remoteVideoTrack:o.remoteAuxiliaryTrack;i.stat.jitterBufferDelay&&(a.videoJitterBufferDelay=i.stat.jitterBufferDelay),i.stat.framesReceived&&(a.statsToReport.uint32_video_consume_render_rate=Math.floor(i.stat.framesDecoded/i.stat.framesReceived*RA(10,6)))}})),i){let e="".concat(n,"_","main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&(null==o?void 0:o.remoteAudioTrack.isSubscribed)&&(t.totalAudioBitrate+=i.uint32_audio_codec_bitrate,t.audioCount++,o.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=o.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(i.uint32_audio_level/Zk*100)>0&&(t.totalAudioLevel+=i.uint32_audio_level/Zk,t.audioLevelCount++))}}))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&0===this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&0===this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&0===this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&0===this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:i}=e,r=i instanceof nD?i.getExtraCode()||i.getCode():{NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5}[i.name]||iD.UNKNOWN;1===t.mediaType&&0===this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&0===this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleAPISuccessRate(e){let{room:t,apiName:i,error:r,cost:n}=e;if(!this.hitTest(t))return;let o=ex[i],a={uint32_function_request_type:o,uint32_avg_value:0,uint32_max_value:0,uint32_request_count:1,uint32_success_count:0,msg_error_code:[]};if(r){let{code:e,extraCode:t}=r;mN.uploadEvent({log:"stat-".concat(i,"-failed-").concat(t||e||iD.UNKNOWN),userId:this._room.userId,error:r});let n={int32_error_code:t||e,error_count:1};a.msg_error_code.push(n)}else mP(n)&&(a.uint32_avg_value=n,a.uint32_max_value=n,a.uint32_success_count=1);let s=this._apiSuccessRateMap.get(o);s?(s.uint32_success_count+a.uint32_success_count>0&&(s.uint32_avg_value=(s.uint32_avg_value*s.uint32_success_count+a.uint32_avg_value)/(s.uint32_success_count+a.uint32_success_count)),s.uint32_max_value=Math.max(s.uint32_max_value,a.uint32_max_value),s.uint32_request_count+=1,s.uint32_success_count=s.uint32_success_count+a.uint32_success_count,a.msg_error_code.forEach((e=>{let t=s.msg_error_code.find((t=>t.int32_error_code===e.int32_error_code));t?t.error_count+=1:s.msg_error_code.push(e)}))):this._apiSuccessRateMap.set(o,a)}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&1&t.flag))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&8&t.flag))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&4&t.flag))>=0}hitTest(e){return e===this._room}checkStorage(){return MA(this,null,(function*(){try{let e=JD.getItem(this._storageKey);e&&(yield this.upload(e),JD.deleteItem(this._storageKey))}catch(HO){this._log.warn(HO)}}))}setStorage(){this.prepareReport();let e=this.getReportData();0!==e.msg_path_enter_room.uint64_start_time&&JD.setItem(this._storageKey,e)}prepareReport(){if(this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:i}=e,r=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(r){let{totalLoss:t,count:i,audioDelayCount:n,videoDelayCount:o,totalAudioDelay:a,totalVideoDelay:s}=r;e.statsToReport.uint32_avg_down_loss=Math.floor(t/i),n&&a&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(a/n),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),o&&s&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/o))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:n}=this._room;n&&(e.statsToReport.uint32_audio_play_time=n.getDuration(t,bC),e.statsToReport.uint32_video_play_time=n.getDuration(t,kC)),e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,XL);let{badCaseDetector:o}=this._room,{dataFreeze:a,count:s}=o.getDataFreezeDuration(t),{renderFreeze:c}=o.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=s,e.statsToReport.uint32_video_block_time=Math.min(a,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),o.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0,(0===e.subscribeStartTime||e.subscribeStartTime-e.streamAddedTime>100||0===e.playStreamTime)&&(this._pathMainAudioMap.delete(t),this._pathMainVideoMap.delete(t),e.statsToReport.uint32_video_render_first=0)})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>XL&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+XL):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>XL&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+XL):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>XL&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+XL)}getReportData(){return{uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new ZL({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:xP(this._signalInfo.relayIp),uint32_client_ip:xP(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(2147483648*Math.random()),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:xP(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,msg_function_request_stats:[...this._apiSuccessRateMap.values()]}}report(){return MA(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),JD.deleteItem(this._storageKey),this.initData()}catch(HO){this._log.warn(HO)}}))}upload(e){return MA(this,null,(function*(){if(0===e.msg_path_enter_room.uint64_start_time||[dC,uC,hC].findIndex((e=>e===location.host))>=0)return;let t=Number(this._room.sdkAppId),i=qw(t,gC),r=yield HP({url:i,body:JSON.stringify(e)});if("ok"!==r.data)throw"key point upload failed: ".concat(r.data)}))}};DA([KL({settings:{timeout:500,retries:3}})],QL.prototype,"upload",1);var YL,XL=5e3,$L={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_render_first:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},ZL=class{constructor(e){NA(this,"str_identifier"),NA(this,"str_tinyid"),NA(this,"uint32_role"),this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},ex=((YL=ex||{})[YL.enterRoom=50001]="enterRoom",YL[YL.exitRoom=50002]="exitRoom",YL[YL.switchRole=50003]="switchRole",YL[YL.destroy=50004]="destroy",YL[YL.startLocalAudio=50005]="startLocalAudio",YL[YL.updateLocalAudio=50006]="updateLocalAudio",YL[YL.stopLocalAudio=50007]="stopLocalAudio",YL[YL.startLocalVideo=50008]="startLocalVideo",YL[YL.updateLocalVideo=50009]="updateLocalVideo",YL[YL.stopLocalVideo=50010]="stopLocalVideo",YL[YL.startScreenShare=50011]="startScreenShare",YL[YL.updateScreenShare=50012]="updateScreenShare",YL[YL.stopScreenShare=50013]="stopScreenShare",YL[YL.enableAudioVolumeEvaluation=50014]="enableAudioVolumeEvaluation",YL[YL.startRemoteVideo=50015]="startRemoteVideo",YL[YL.updateRemoteVideo=50016]="updateRemoteVideo",YL[YL.stopRemoteVideo=50017]="stopRemoteVideo",YL[YL.muteRemoteAudio=50018]="muteRemoteAudio",YL[YL.setRemoteAudioVolume=50019]="setRemoteAudioVolume",YL[YL.startMixTranscode=50020]="startMixTranscode",YL[YL.stopMixTranscode=50021]="stopMixTranscode",YL[YL.startPublishCDNStream=50022]="startPublishCDNStream",YL[YL.stopPublishCDNStream=50023]="stopPublishCDNStream",YL[YL.PeerConnectionConnect=50024]="PeerConnectionConnect",YL[YL.PeerConnectionReconnect=50025]="PeerConnectionReconnect",YL[YL.WebsocketConnect=50026]="WebsocketConnect",YL[YL.WebsocketReconnect=50027]="WebsocketReconnect",YL[YL.schedule=50028]="schedule",YL),tx=QL;PA(XA(),1),PA(XA(),1);var ix=class{constructor(){NA(this,"_startTime"),NA(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=bP())}stop(){0===this._endTime&&(this._endTime=bP())}getDuration(){return 0===this._endTime?bP()-this._startTime:this._endTime-this._startTime}get endTime(){return this._endTime}},rx=class{constructor(e){NA(this,"_room",null),NA(this,"_durationMap"),NA(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(KP.SUBSCRIBE_SUCCESS,this.handleSubscribed).set(KP.UNSUBSCRIBE_SUCCESS,this.handleStreamStopped).set(KP.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;var n;let{userId:o}=r;if(!this.hitTest(t))return;i.hasAudio&&!r.hasAudio&&this.stopDurationItem("".concat(o,"_","main"),bC),i.hasVideo&&!r.hasVideo&&this.stopDurationItem("".concat(o,"_","main"),kC),i.hasAuxiliary&&!r.hasAuxiliary&&this.stopDurationItem("".concat(o,"_","auxiliary"),kC);let a=null==(n=this._room)?void 0:n.remotePublishedUserMap.get(o);!a||(!i.hasAudio&&r.hasAudio&&a.remoteAudioTrack.isSubscribed&&this.addDuractionItem(o,bC,"main"),!i.hasVideo&&r.hasVideo&&a.remoteVideoTrack.isSubscribed&&this.addDuractionItem(o,kC,"main"),!i.hasAuxiliary&&r.hasAuxiliary&&a.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(o,kC,"auxiliary"))})),this._eventMap.forEach(((e,t)=>WP.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>WP.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);if(r.muteState.hasAudio&&"main"===i)if(r.remoteAudioTrack.isSubscribed){let e=new ix,t=this._durationMap.get(o);t?this.isRecording(t.audio)||t.audio.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[e],video:[]})}else this.stopDurationItem(o,bC);if(r.muteState.hasVideo||r.muteState.hasAuxiliary)if(r.remoteVideoTrack.isSubscribed||r.remoteAuxiliaryTrack.isSubscribed){let e=new ix,t=this._durationMap.get(o);t?this.isRecording(t.video)||t.video.push(e):this._durationMap.set(o,{userId:n,type:i,audio:[],video:[e]})}else this.stopDurationItem(o,kC)}handleStreamStopped(e){let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDurationItem(o,bC),this.stopDurationItem(o,kC)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,i){let r="".concat(e,"_").concat(i),n=new ix,o=this._durationMap.get(r);o?this.isRecording(o[t])||o[t].push(n):this._durationMap.set(r,{userId:e,type:i,audio:t===bC?[n]:[],video:t===bC?[]:[n]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let i=this._durationMap.get(e)[t].find((e=>0===e.endTime));i&&i.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}};PA(XA(),1);var nx=class{constructor(e){NA(this,"_room"),NA(this,"_renderFreezeMap",new Map),NA(this,"_isVideoPlayingEventFiredMap",new Map),NA(this,"_dataFreezeMap",new Map),NA(this,"_monitorFreezeData",new Map),NA(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}installEvents(){this._eventMap.set(KP.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(KP.PLAY_TRACK_START,this.onPlayTrackStart).set(KP.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:n}=r,o="".concat(n,"_").concat(i);this.stopDataFreeze({key:o,userId:n,type:i})})).set(KP.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let{userId:n}=r;if(i.hasVideo&&!r.hasVideo){let e="main",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}if(i.hasAuxiliary&&!r.hasAuxiliary){let e="auxiliary",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:n,type:e})}})).set(KP.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,reason:r,type:n}=e;if(TP(t)&&this.hitTest(t.room)&&n===kC){if("PLAYING"===i){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}r===xC?this.onVideoTrackMuted(t):r===UC&&this.onVideoTrackUnmuted(t)}})).set(KP.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>WP.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>WP.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i),n=this._dataFreezeMap.get(r),o=new ix;n?n.durationItemList.push(o):this._dataFreezeMap.set(r,{userId:t,type:i,durationItemList:[o],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i);this.stopDataFreeze({key:r,userId:t,type:i})}onHearBeatReport(e){let{room:t,report:i}=e;!this.hitTest(t)||i.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:i,muteState:r}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&r.hasVideo&&!r.videoMuted&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&r.hasAuxiliary&&this.handleRenderFreeze({userId:i,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:i,type:r}=e,n=this._dataFreezeMap.get(t);if(!n||!n.isFreezing())return;let o=n.durationItemList[n.durationItemList.length-1];o.stop();let a=o.getDuration();a>500?this._monitorFreezeData.set(t,{userId:i,type:r,duration:a}):n.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let i=t.getDuration();return e+Math.min(i,5e3)}),0)}handleRenderFreeze(e){return MA(this,arguments,(function(e){var t=this;let{userId:i,fps:r,type:n}=e;return function*(){let e="".concat(i,"_").concat(n),o=t._renderFreezeMap.get(e);if(r<=2){let r=bP();o&&!o.isFreeze&&(o.freezeTimeline.push({startTime:r,endTime:0}),o.isFreeze=!0),o||t._renderFreezeMap.set(e,{userId:i,type:n,isFreeze:!0,freezeTimeline:[{startTime:r,endTime:0}],renderFreezeTotal:0})}else if(o&&o.isFreeze){o.isFreeze=!1;let e=o.freezeTimeline.pop();if(e){e.endTime=bP();let t=e.endTime-e.startTime;o.freezeTimeline.push(e),o.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!TP(t)||!this.hitTest(t.room)||t.kind!==kC||t.hasFlag)return;let i="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(i)||this._isVideoPlayingEventFiredMap.set(i,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},i=this._dataFreezeMap.get(e);if(i){if(i.isFreezing()){let e=i.durationItemList[i.durationItemList.length-1];e.stop(),e.getDuration()<500&&i.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(i.durationItemList),t.count=i.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),i=0,r=0;if(t)if(t.isFreeze){let e=bP()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;i=t.renderFreezeTotal+Math.min(e,5e3),r=t.freezeTimeline.length}else i=t.renderFreezeTotal;return{renderFreeze:i,count:r}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}};PA(XA(),1);var ox=PA(rC(),1),ax=class{constructor(e){NA(this,"_room"),NA(this,"_log"),NA(this,"_config",null),NA(this,"_data"),NA(this,"_remoteVideoTrackMap",new Map),this._room=e,this._log=QP.createLogger({id:"mix",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),this.installEvents()}get isPresetLayoutMode(){return this._config&&this._config.mode===vb.PRESET_LAYOUT}get isMixing(){return!!this._data}installEvents(){WP.on(KP.REMOTE_TRACK_SUBSCRIBED,this.onSubscribed,this),WP.on(KP.REMOTE_TRACK_UNSUBSCRIBED,this.onUnSubscribed,this),WP.on(KP.REMOTE_PUBLISH_STATE_CHANGED,this.onRemotePublishedChanged,this)}uninstallEvents(){WP.off(KP.REMOTE_TRACK_SUBSCRIBED,this.onSubscribed,this),WP.off(KP.REMOTE_TRACK_UNSUBSCRIBED,this.onUnSubscribed,this),WP.off(KP.REMOTE_PUBLISH_STATE_CHANGED,this.onRemotePublishedChanged,this)}reset(){this.uninstallEvents(),this._config=null}onSubscribed(e){let{track:t}=e;t.room!==this._room||t.kind!==kC||(this._remoteVideoTrackMap.set("".concat(t.userId,"_").concat(t.streamType),!1),this.isMixing&&this.hasAvailablePlaceHolder()&&this._config&&this.startMixTranscode(this._config))}onUnSubscribed(e){let{track:t}=e;t.room!==this._room||t.kind!==kC||this.handleRemoteTrackUnavailable("".concat(t.userId,"_").concat(t.streamType))}onRemotePublishedChanged(e){let{room:t,prevMuteState:i,muteState:r}=e;t===this._room&&(i.hasVideo&&!r.hasVideo&&this.handleRemoteTrackUnavailable("".concat(r.userId,"_","main")),i.hasAuxiliary&&!r.hasAuxiliary&&this.handleRemoteTrackUnavailable("".concat(r.userId,"_","auxiliary")))}handleRemoteTrackUnavailable(e){if(this._remoteVideoTrackMap.has(e)){let t=this._remoteVideoTrackMap.get(e);this._remoteVideoTrackMap.delete(e),this.isMixing&&this.isPresetLayoutMode&&t&&this._config&&this.startMixTranscode(this._config)}}startMixTranscode(e){return MA(this,null,(function*(){try{this.resetIsUsedFlag(),this._config=e;let t=this.getInputParam(e),i=this.getOutputParam(e),r=this.getOutputSessionId({config:e,roomId:this._room.roomId,userId:this._room.userId});this.isMixing&&this._data&&r!==this._data.outputSessionId&&(this._log.info("startMixTranscode() streamId changed, stop mixing before start"),yield this.doStopMixTranscode()),yield this.doStartMixTranscode({outputSessionId:r,inputParam:t,outputParam:i})}catch(t){throw this.resetIsUsedFlag(),t}}))}doStartMixTranscode(e){return MA(this,arguments,(function(e){var t=this;let{outputSessionId:i,inputParam:r,outputParam:n}=e;return function*(){let e={roomId:String(t._room.roomId),mcuRequestTime:Date.now(),outputSessionId:i,inputParam:r,outputParam:n};t._log.info("startMixTranscode: ".concat(JSON.stringify(e)));let o=yield t._room.sendStartMixTranscode(e),{code:a}=o.data,{message:s}=o.data;if(0!==a)throw-102083===a&&(s="Please enable relayed-push in ".concat(pC," and try later, refer to ").concat(_C,"tutorial-26-advanced-publish-cdn-stream.html")),t._log.error("startMixTranscode failed, errCode: ".concat(a," errMsg: ").concat(s)),new nD({code:iD.START_MIX_TRANSCODE_FAILED,message:Jw({key:Aw,data:{message:s},link:{className:"Client",fnName:"startMixTranscode"}})});t._data=e}()}))}reStartMixTranscode(){!this.isMixing||this._config&&this.startMixTranscode(this._config)}stopMixTranscode(){return MA(this,null,(function*(){if(!this.isMixing)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:bw})});yield this.doStopMixTranscode(),this.resetIsUsedFlag()}))}doStopMixTranscode(){return MA(this,null,(function*(){let e={mcuRequestTime:Date.now(),outputSessionId:this._data.outputSessionId,streamType:this._data.outputParam.streamType};this._log.info("stopMixTranscode: ".concat(JSON.stringify(e)));let t=yield this._room.sendStopMixTranscode(e),{code:i,message:r}=t.data;if(0!==i)throw this._log.error("stopMixTranscode failed, errCode: ".concat(i," errMsg: ").concat(r)),new nD({code:iD.STOP_MIX_TRANSCODE_FAILED,message:Jw({key:Cw,data:{message:r},link:{className:"Client",fnName:"stopMixTranscode"}})});this._data=void 0}))}getOutputSessionId(e){let{config:t,userId:i,roomId:r}=e;return pP(t.streamId)&&t.streamId.length>0?t.streamId:(0,ox.default)("".concat(r,"_").concat(i,"_main"))}getInputParam(e){let t=e.mixUsers.map((e=>({userId:e.userId,roomId:String(e.roomId||this._room.roomId),width:e.width||0,height:e.height||0,locationX:e.locationX||0,locationY:e.locationY||0,zOrder:e.zOrder,streamType:hP(e.streamType)||e.streamType!==ib?0:1,inputType:e.pureAudio?Sb.IT_PURE_AUDIO:Sb.IT_AUDIO_VIDEO,renderMode:e.renderMode||0})));return e.mode===vb.PRESET_LAYOUT&&(t.forEach((e=>{if(e.userId===Tb.REMOTE){let t=[...this._remoteVideoTrackMap.entries()].find((e=>{let[,t]=e;return!t}));if(t){let[i]=t,r=i.split("_");e.userId=r.slice(0,r.length-1).join("_"),e.streamType="auxiliary"===r.splice(-1)[0]?1:0,this._remoteVideoTrackMap.set(i,!0)}}})),t=t.filter((e=>e.userId!==Tb.REMOTE))),t}getOutputParam(e){let t=e.streamId||"";return{streamId:t,streamType:t.length>0?1:0,width:hP(e.videoWidth)?640:e.videoWidth,height:hP(e.videoHeight)?480:e.videoHeight,videoBps:e.videoBitrate||0,fps:e.videoFramerate||15,gop:e.videoGOP||2,audioSampleRate:e.audioSampleRate||48e3,audioBps:e.audioBitrate||64,audioChannels:e.audioChannels||1,backgroundColor:e.backgroundColor||0,backgroundImg:e.backgroundImage||"",extraInfo:"",videoCodec:2,audioCodec:0}}hasAvailablePlaceHolder(){var e,t;return!(!this.isPresetLayoutMode||(null==(e=this._data)?void 0:e.inputParam.length)===(null==(t=this._config)?void 0:t.mixUsers.length))}resetIsUsedFlag(){this._remoteVideoTrackMap.forEach(((e,t)=>{this._remoteVideoTrackMap.set(t,!1)}))}};PA(XA(),1);var sx=PA(rC(),1);function cx(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:JC;return t=Kw(e)?i===JC?kb:wb:i===JC?Cb:bb,"https://".concat(t,"/api/v1/config")}function lx(e,t,i){return new Promise(((r,n)=>{HP({url:e,body:t,timeout:i.timeout}).then((e=>{0===e.data.code?r(e.data.data):n({code:e.data.code,message:e.data.msg})})).catch(n)}))}PA(XA(),1);var dx=(e,t)=>GP({retryFunction:lx,settings:{retries:3,timeout:0},onError:t,onRetrying:e});function ux(e,t,i){return new Promise(((r,n)=>{let o=null;CP([dx((e=>t.count[0]=e+1),((e,i)=>{t.msg[0]=e.message,o||i()}))(cx(i,JC),e,{get timeout(){return 1e3*cP(2+t.count[0])}}),dx((e=>t.count[1]=e+1),((e,i)=>{t.msg[1]=e.message,o||i()}))(cx(i,zC),e,{get timeout(){return 1e3*cP(2+t.count[1])}})]).then((e=>{o=e,r(o)})).catch(n)}))}var hx=0,px=class extends aN{constructor(e){super("room"),this.seq=hx++,this.role="anchor",this.localTracks=new Set,this.enableAutoPlayDialog=!0,this.autoReceiveAudio=!0,this.autoReceiveVideo=!0,this.scheduleResult={domains:null,iceServers:null,iceTransportPolicy:null},this._log=QP.createLogger({id:"r".concat(this.seq)}),this._joinedTimestamp=0,this._isDestroyed=!1,this.useStringRoomId=!!e.useStringRoomId,_P(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),_P(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),_P(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this.keyPointManager=new tx({room:this,frameWorkType:e.frameWorkType,component:e.component}),this.callDurationCalculator=new rx({room:this}),this.badCaseDetector=new nx({room:this}),this.mixTranscodeManager=new ax(this),this.publishCDNManager=new class{constructor(e){NA(this,"_room"),NA(this,"_publishTencentMainStreamObj",{params:null,streamId:void 0,isPublishing:!1}),NA(this,"_publishTencentAuxStreamObj",{params:null,streamId:void 0,isPublishing:!1}),NA(this,"_publishGivenCDNData",null),NA(this,"_isPublishingGivenCDN",!1),this._room=e}get _isPublishingTencentCDN(){return this._publishTencentMainStreamObj.isPublishing||this._publishTencentAuxStreamObj.isPublishing}generatePublishCDNStreamId(e,t){if(!e){let e="".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertStreamType(t));return/^[A-Za-z\d_-]*$/.test(e)||(e=(0,sx.default)(e)),"".concat(this._room.sdkAppId,"_").concat(e)}return e}convertStreamType(e){return"main"===e?e:"aux"}generatePublishCDNSessionId(e){return(0,sx.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertStreamType(e)))}startPublishCDN(e){return MA(this,null,(function*(){let{streamId:t="",streamType:i="main",appId:r,bizId:n,url:o}=e;yield this.startPublishTencentCDN({streamId:t,streamType:i}),r&&n&&o&&(yield this.startPublishGivenCDN({streamType:i,appId:r,bizId:n,url:o}))}))}stopPublishCDN(){return MA(this,null,(function*(){if(!this._isPublishingTencentCDN)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:Sw})});yield this.stopPublishTencentCDN(),this._isPublishingGivenCDN&&(yield this.stopPublishGivenCDN())}))}startPublishTencentCDN(e){return MA(this,null,(function*(){if("auxiliary"===e.streamType?(this._publishTencentAuxStreamObj.params=e,this._publishTencentAuxStreamObj.isPublishing=!0):(this._publishTencentMainStreamObj.params=e,this._publishTencentMainStreamObj.isPublishing=!0),!this._room.isJoined)return;let t=this.generatePublishCDNStreamId(e.streamId,e.streamType),i=this.generatePublishCDNSessionId(e.streamType),r="auxiliary"===e.streamType?1:0,n={requestTime:Date.now(),sessionId:i,streamId:t,streamType:r};yield this.doStartPublishTencentCDN(n,e.streamType)}))}doStartPublishTencentCDN(e,t){return MA(this,null,(function*(){try{QP.info("startPublishTencentCDN: ".concat(JSON.stringify(e)));let i=yield this._room.sendStartPublishCDN(e,!0),{code:r}=i.data,{message:n}=i.data;if(0!==r)throw"auxiliary"===t?this._publishTencentAuxStreamObj.isPublishing=!1:this._publishTencentMainStreamObj.isPublishing=!1,-102083===r&&(n="Please enable relayed-push in ".concat(pC," and try later, refer to ").concat(_C,"tutorial-26-advanced-publish-cdn-stream.html")),QP.error("startPublishTencentCDN failed, errCode: ".concat(r,", errMsg: ").concat(n)),new nD({code:iD.START_PUBLISH_CDN_FAILED,message:Jw({key:yw,data:{message:n},link:{className:"Client",fnName:"startPublishCDNStream"}})});"auxiliary"===t?this._publishTencentAuxStreamObj.streamId=e.streamId:this._publishTencentMainStreamObj.streamId=e.streamId}catch(i){throw"auxiliary"===t?this._publishTencentAuxStreamObj.isPublishing=!1:this._publishTencentMainStreamObj.isPublishing=!1,i}}))}resetPublishTencentParam(e){"main"===e&&(this._publishTencentMainStreamObj={params:null,streamId:void 0,isPublishing:!1}),"auxiliary"===e&&(this._publishTencentAuxStreamObj={params:null,streamId:void 0,isPublishing:!1})}stopPublishTencentCDN(){return MA(this,null,(function*(){if(!this._room.isJoined)return this.resetPublishTencentParam("main"),void this.resetPublishTencentParam("auxiliary");this._publishTencentMainStreamObj.isPublishing&&(yield this.doStopPublishTencentCDN("main")),this._publishTencentAuxStreamObj.isPublishing&&(yield this.doStopPublishTencentCDN("auxiliary"))}))}doStopPublishTencentCDN(e){return MA(this,null,(function*(){let t={requestTime:Date.now(),sessionId:(0,sx.default)("".concat(this._room.roomId,"_").concat(this._room.userId,"_").concat(this.convertStreamType(e)))};QP.info("stopPublishTencentCDN: ".concat(JSON.stringify(t)));let i=yield this._room.sendStopPublishCDN(t,!0),{code:r,message:n}=i.data;if(0===r)this.resetPublishTencentParam(e);else{if(-102069!==r)throw QP.error("stopPublishTencentCDN failed, errCode: ".concat(r," errMsg: ").concat(n)),new nD({code:iD.STOP_PUBLISH_CDN_FAILED,message:Jw({key:Ew,data:{message:n},link:{className:"Client",fnName:"stopPublishCDNStream"}})});QP.warn("stopPublishTencentCDN failed, can not stopPublishTencentCDN in auto relayed-push mode"),this.resetPublishTencentParam(e)}}))}startPublishGivenCDN(e){return MA(this,null,(function*(){let t="main"===e.streamType?this._publishTencentMainStreamObj.streamId:this._publishTencentAuxStreamObj.streamId,i={pushRequestTime:Date.now(),pushAppId:e.appId,pushBizId:e.bizId,pushCdnUrl:e.url,pushStreamType:this.convertStreamType(e.streamType),pushStreamId:t};if(QP.info("startPublishGivenCDN: ".concat(JSON.stringify(i))),this._publishGivenCDNData=i,this._isPublishingGivenCDN=!0,this._room.isJoined)try{let e=yield this._room.sendStartPublishCDN(i,!1),{code:t,message:r}=e.data;if(0!==t)throw QP.error("startPublishGivenCDN failed, errCode: ".concat(t,", errMsg: ").concat(r)),this._publishGivenCDNData=null,this._isPublishingGivenCDN=!1,new nD({code:iD.START_PUBLISH_CDN_FAILED,message:Jw({key:yw,data:{message:r},link:{className:"Client",fnName:"startPublishCDNStream"}})})}catch(QO){throw this._publishGivenCDNData=null,this._isPublishingGivenCDN=!1,QO}}))}stopPublishGivenCDN(){return MA(this,null,(function*(){if(!this._room.isJoined||!this._publishGivenCDNData)return this._publishGivenCDNData=null,void(this._isPublishingGivenCDN=!1);let{pushAppId:e,pushBizId:t,pushCdnUrl:i,pushStreamType:r}=this._publishGivenCDNData,n={pushRequestTime:Date.now(),pushAppId:e,pushBizId:t,pushCdnUrl:i,pushStreamType:r};QP.info("stopPublishGivenCDN: ".concat(JSON.stringify(n)));let o=yield this._room.sendStopPublishCDN(n,!1),{code:a,message:s}=o.data;if(0!==a)throw QP.error("stopPublishGivenCDN failed, errCode: ".concat(a," errMsg: ").concat(s)),new nD({code:iD.STOP_PUBLISH_CDN_FAILED,message:Jw({key:Ew,data:{message:s},link:{className:"Client",fnName:"stopPublishCDNStream"}})});this._publishGivenCDNData=null,this._isPublishingGivenCDN=!1}))}handleCDNConfigForJoinData(e){let t,i=e;if(this._publishTencentMainStreamObj.isPublishing||this._publishTencentAuxStreamObj.isPublishing){let e={};pP(i)&&(e=JSON.parse(i)),e.Str_uc_params||(e.Str_uc_params={}),this._publishTencentMainStreamObj.isPublishing&&(this._publishTencentMainStreamObj.streamId?e.Str_uc_params.userdefine_streamid_main=this._publishTencentMainStreamObj.streamId:this._publishTencentMainStreamObj.params&&(e.Str_uc_params.userdefine_streamid_main=this.generatePublishCDNStreamId(this._publishTencentMainStreamObj.params.streamId,"main"))),this._publishTencentAuxStreamObj.isPublishing&&(this._publishTencentAuxStreamObj.streamId?e.Str_uc_params.userdefine_streamid_aux=this._publishTencentAuxStreamObj.streamId:this._publishTencentAuxStreamObj.params&&(e.Str_uc_params.userdefine_streamid_aux=this.generatePublishCDNStreamId(this._publishTencentAuxStreamObj.params.streamId,"auxiliary"))),i=JSON.stringify(e)}if(this._isPublishingGivenCDN&&this._publishGivenCDNData){let{pushAppId:e,pushBizId:i,pushCdnUrl:r,pushStreamType:n,pushStreamId:o}=this._publishGivenCDNData;t={pushRequestTime:Date.now(),pushAppId:e,pushBizId:i,pushCdnUrl:r,pushStreamType:n,pushStreamId:o}}return{bussinessInfo:i,pushUserCdnInfo:t}}reset(){this.resetPublishTencentParam("main"),this.resetPublishTencentParam("auxiliary"),this._publishGivenCDNData=null,this._isPublishingGivenCDN=!1}}(this)}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}getLogger(){return this._log}get isJoined(){return"joined"===this.state}addTrack(e){return MA(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return MA(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return MA(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}getRemoteAudioStats(){return MA(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return MA(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let i of this.quality.downlinkInfo)t.downlinksRTT[i.userId]=i.rtt;return t}))}getRemoteVideoStats(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let i={};return e.remotePublishedUserMap.forEach((e=>{let r="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;i[e.userId]=r.stat})),i}()}))}checkDestroy(){if(this._isDestroyed)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:Rw,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(jw.INVALID_DESTROY),new nD({code:iD.INVALID_OPERATION,message:Jw({key:_w})});this._log.info("destroy room"),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this._isDestroyed=!0,WP.emit(KP.ROOM_DESTROY,{room:this})}startMixTranscode(e){return this.mixTranscodeManager.startMixTranscode(e)}stopMixTranscode(){return this.mixTranscodeManager.stopMixTranscode()}startPublishCDNStream(){return MA(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){if(e._log.info("startPublishCDNStream with params: ".concat(JSON.stringify(t),"; isJoined: ").concat(e.isJoined,"; hasMainStream: ").concat(e.isMainStreamPublished,"; hasAuxStream: ").concat(!!e.isAuxStreamPublished,";")),e.isJoined){if("main"===t.streamType&&!e.isMainStreamPublished)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:Tw})});if("auxiliary"===t.streamType&&!e.isAuxStreamPublished)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:Tw})})}yield e.publishCDNManager.startPublishCDN(t)}()}))}stopPublishCDNStream(){return this.publishCDNManager.stopPublishCDN()}schedule(e,t,i){return MA(this,null,(function*(){var r;let n=bP();try{let o=yield function(e){return MA(this,arguments,(function(e){let{userId:t,sdkAppId:i,useStringRoomId:r,roomId:n,userSig:o,version:a,frameWorkType:s}=e;return function*(){let e={delta:0,count:[1,1],msg:[]};try{let c=new FormData;c.append("userId",String(t)),c.append("sdkAppId",String(i)),c.append("isStrGroupId",String(r)),c.append("groupId",String(n)),c.append("sdkVersion",a),c.append("userSig",String(o)),c.append("frameWorkType",String(s));let l=bP(),d=yield ux(c,e,i);return e.delta=bP()-l,d}catch(c){let e=gP(c)?c[0]:c,t=mP(e.code)?e.code:0,i="get websocket url failed: ".concat(e.message.includes("timeout")?"timeout":e.message),r=new nD({code:iD.SCHEDULE_FAILED,extraCode:t,message:Jw({key:pw,data:{error:i,code:t}})});throw QP.error(r),r}}()}))}({userId:this.userId,sdkAppId:this.sdkAppId,roomId:e,useStringRoomId:this.useStringRoomId,version:i,userSig:this.userSig,frameWorkType:t});this._log.info("schedule: ".concat(JSON.stringify(o))),this.scheduleResult=CA(CA({},this.scheduleResult),o),mP(null==(r=o.config)?void 0:r.retryCount)&&function(e){ub=e}(o.config.retryCount),WP.emit(KP.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult}),WP.emit(KP.API_SUCCESS_RATE,{room:this,apiName:"schedule",cost:bP()-n})}catch(o){throw WP.emit(KP.API_SUCCESS_RATE,{room:this,apiName:"schedule",error:o}),o}}))}};PA(XA(),1);var mx=new WeakMap,_x=new WeakMap;PA(XA(),1);var fx=PA($A(),1),gx=Symbol("instance"),vx=Symbol("abortCtrl"),Tx=Symbol("cacheResult"),Sx=class{constructor(e,t,i){NA(this,"oldState"),NA(this,"newState"),NA(this,"action"),NA(this,"error"),this.oldState=e,this.newState=t,this.action=i}toString(){return"".concat(this.action,"ing")}},yx=class extends Error{constructor(e,t,i){super(t),NA(this,"state"),NA(this,"message"),NA(this,"cause"),this.state=e,this.message=t,this.cause=i}},Ex=new Map,Ix=Object.getPrototypeOf(MA(void 0,null,(function*(){}))).constructor;function Rx(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,n,o)=>{let a=i.action||n;if(!i.context){let i=Ex.get(r)||[];Ex.has(r)||Ex.set(r,i),i.push({from:e,to:t,action:a})}let s=o.value;o.value=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return MA(this,null,(function*(){var r;let o=this;if(i.context&&(o=Px.get("function"==typeof i.context?i.context.call(this,...n):i.context)),o.state===t)return o[Tx];let c=null;if(Array.isArray(e)?0==e.length?o[vx]&&(o[vx].aborted=!0):("string"!=typeof o.state||!e.includes(o.state))&&(c=new yx(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not in from config"))):e!==o.state&&(c=new yx(o._state,"".concat(o.name," ").concat(a," to ").concat(t," failed: current state ").concat(o._state," not from ").concat(e))),c){if(!i.fail){if(i.ignoreError)return c;throw c}i.fail.call(this,c)}let l=o.state;Cx.call(o,new Sx(l,t,a));let d={aborted:!1};o[vx]=d;try{let e=s.apply(this,n);return o[Tx]=e instanceof Ix?yield e:e,d.aborted||(o[vx]=void 0,Cx.call(o,t),null==(r=i.success)||r.call(this,o[Tx])),o[Tx]}catch(u){let e=u instanceof Error?u.message:String(u);if(Cx.call(o,l,e),!i.fail){if(i.ignoreError)return u;throw u}i.fail.call(this,new yx(o._state,"action '".concat(a,"' failed :").concat(e),u instanceof Error?u:new Error(e)))}}))}}}var Ax="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function Cx(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(Px.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t})}var bx,kx,wx=class extends fx.default{constructor(e,t,i){super(),NA(this,"name"),NA(this,"groupName"),NA(this,"_state",wx.INIT),NA(this,bx),NA(this,kx),this.name=e,this.groupName=t,e||(e=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),t||(this.groupName=this.constructor.name);let r=i[gx];r?this.name=r.name+"-"+r.count++:i[gx]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Ex.get(e)||[],i=new Set,r=[],n=[],o=new Set,a=Object.getPrototypeOf(e);Ex.has(a)&&(a.stateDiagram.forEach((e=>i.add(e))),a.allStates.forEach((e=>o.add(e)))),t.forEach((e=>{let{from:t,to:i,action:o}=e;"string"==typeof t?r.push({from:t,to:i,action:o}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:o})})):n.push({to:i,action:o})})),r.forEach((e=>{let{from:t,to:r,action:n}=e;o.add(t),o.add(r),o.add(n+"ing"),i.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),i.add("".concat(n,"ing --\x3e ").concat(r," : ").concat(n," 🟢")),i.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))})),n.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),o.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let s=[...i];return Object.defineProperty(this,"stateDiagram",{value:s}),s}static get(e){let t;return"string"==typeof e?(t=wx.instances.get(e),t||wx.instances.set(e,t=new wx(e,void 0,Object.create(wx.prototype)))):(t=wx.instances2.get(e),t||wx.instances2.set(e,t=new wx(e.constructor.name,void 0,Object.create(wx.prototype)))),t}static getState(e){var t;return null==(t=wx.get(e))?void 0:t.state}updateDevTools(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Ax(wx.UPDATEAFSM,CA({name:this.name,group:this.groupName},e))}get state(){return this._state}set state(e){Cx.call(this,e)}},Px=wx;bx=Tx,kx=vx,NA(Px,"STATECHANGED","stateChanged"),NA(Px,"UPDATEAFSM","updateAFSM"),NA(Px,"INIT","[*]"),NA(Px,"ON","on"),NA(Px,"OFF","off"),NA(Px,"instances",new Map),NA(Px,"instances2",new WeakMap);var{isString:Dx,isPlainObject:Nx,isUndefined:Ox,getNetworkType:Mx,getTerminalType:Lx,isEmpty:xx}=jb,Ux=class extends px{constructor(e){super(e),this.privateMapKey="",this._heartbeat=-1,this._lastHeartBeatTime=-1,this._joinTimeout=-1,this._firstPublishedList=null,this._joinReject=null,this._isPublishing=!1,this._isRelayChanged=!1,this.uplinkConnection=null,this._changeBigSmallRecords=new Map,this._networkQuality=null,this._networkType=Mx(),this._turnServers=[],this._syncUserListInterval=-1,this._smallStreamConfig={bitrate:100,frameRate:15,height:120,width:160},this.enableSEI=!1,this._enableAudioVolumeEvaluation=!1,this._audioVolumeIntervalId=null,this._enableMultiAuxStream=!1,this._pureAudioPushMode=!1,this.audioManager=null,this._stats=new class{constructor(e,t){NA(this,"_log"),NA(this,"_prevReportTime"),NA(this,"_prevReport",{}),NA(this,"_prevEncoderImplementation"),NA(this,"_prevQualityLimitationReason"),NA(this,"_prevDecoderImplementationMap",new Map),this._log=t,this._prevReportTime=0,this._prevEncoderImplementation="",this._prevQualityLimitationReason=""}get statInterval(){return 0===this._prevReportTime?2:(Date.now()-this._prevReportTime)/1e3}getSenderStats(e){return MA(this,null,(function*(){var t;let i={audio:{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0},video:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},small:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},auxiliary:{bytesSent:0,packetsSent:0,framesEncoded:0,frameWidth:0,frameHeight:0,framesSent:0,fpsCapture:0},rtt:0},r=e.getPeerConnection(),n=e.getSSRC();if(r)try{(yield r.getStats()).forEach((t=>{if("outbound-rtp"===t.type)if(t.mediaType===kC){if(!$b&&hP(t.trackId))return;t.ssrc===n.video&&!hP(t.encoderImplementation)&&this._prevEncoderImplementation!==t.encoderImplementation&&(this._log.info("encoderImplementation change to ".concat(t.encoderImplementation)),this._prevEncoderImplementation=t.encoderImplementation),t.ssrc===n.video&&!hP(t.qualityLimitationReason)&&this._prevQualityLimitationReason!==t.qualityLimitationReason&&(this._log.info("qualityLimitationReason change to ".concat(t.qualityLimitationReason)),this._prevQualityLimitationReason=t.qualityLimitationReason);let e=kC;t.ssrc===n.small?e=PC:t.ssrc===n.auxiliary&&(e=NC),i[e].bytesSent=t.bytesSent,i[e].packetsSent=t.packetsSent,i[e].framesEncoded=t.framesEncoded}else t.mediaType===bC&&(i.audio.bytesSent=t.bytesSent,i.audio.packetsSent=t.packetsSent);else"candidate-pair"===t.type?SD(t)&&mP(t.currentRoundTripTime)&&(i.rtt=Math.floor(1e3*t.currentRoundTripTime)):"media-source"===t.type&&(t.kind===bC?(i.audio.audioLevel=t.audioLevel||0,i.audio.totalAudioEnergy=t.totalAudioEnergy||0):t.kind===kC&&(t.trackIdentifier===e.getVideoTrackId(kC)?i.video.fpsCapture=t.framesPerSecond:t.trackIdentifier===e.getVideoTrackId(NC)?i.auxiliary.fpsCapture=t.framesPerSecond:i.small.fpsCapture=t.framesPerSecond));if(hP(t.audioLevel)||(i.audio.audioLevel=t.audioLevel||0),!hP(t.frameWidth)){let r=PC;t.trackIdentifier===e.getVideoTrackId(kC)||t.ssrc===n.video?r=kC:(t.trackIdentifier===e.getVideoTrackId(NC)||t.ssrc===n.auxiliary)&&(r=NC),i[r].frameWidth=t.frameWidth,i[r].frameHeight=t.frameHeight,i[r].framesSent=t.framesSent}})),0===i.audio.audioLevel&&(i.audio.audioLevel=(null==(t=e.localMainAudioTrack)?void 0:t.getInternalAudioLevel())||0)}catch(aC){this._log.warn("failed to getStats on sender connection ".concat(aC))}return i}))}getReceiverStats(e){return MA(this,null,(function*(){let t={tinyId:e.tinyId,userId:e.userId,rtt:0,hasAudio:!1,hasVideo:!1,hasAuxiliary:!1,audio:{bytesReceived:0,packetsReceived:0,packetsLost:0,jitter:0,audioLevel:0,totalAudioEnergy:0,insertedSamplesForDeceleration:0,removedSamplesForAcceleration:0},video:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0},auxiliary:{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,fpsDecoded:0}},i=e.getPeerConnection();if(i)try{let{ssrc:r}=e,{muteState:n}=e;(yield i.getStats()).forEach((i=>{if("inbound-rtp"===i.type){if(i.mediaType===bC&&i.ssrc===r.audio&&n.hasAudio){t.audio.packetsReceived=i.packetsReceived,t.audio.bytesReceived=i.bytesReceived,t.audio.packetsLost=i.packetsLost,i.insertedSamplesForDeceleration&&(t.audio.insertedSamplesForDeceleration=i.insertedSamplesForDeceleration),i.removedSamplesForAcceleration&&(t.audio.removedSamplesForAcceleration=i.removedSamplesForAcceleration);let{remoteAudioTrack:r}=e;r.stat.packetsReceived=i.packetsReceived,r.stat.bytesReceived=i.bytesReceived,r.stat.packetsLost=i.packetsLost,i.jitterBufferDelay&&(r.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)),t.hasAudio=!0}else if(i.mediaType===kC){if($b&&0===i.bytesReceived)return;let o;i.ssrc===r.video&&n.hasVideo&&(t.video.packetsReceived=i.packetsReceived,t.video.bytesReceived=i.bytesReceived,t.video.packetsLost=i.packetsLost,t.video.framesReceived=i.framesReceived,t.video.framesDecoded=i.framesDecoded,t.video.fpsDecoded=i.framesPerSecond,t.hasVideo=!0,o=e.remoteVideoTrack,i.decoderImplementation&&(!this._prevDecoderImplementationMap.has(t.userId)||this._prevDecoderImplementationMap.get(t.userId)!==i.decoderImplementation)&&(this._log.info("".concat(t.userId," decoderImplementation change to ").concat(i.decoderImplementation)),this._prevDecoderImplementationMap.set(t.userId,i.decoderImplementation))),i.ssrc===r.auxiliary&&n.hasAuxiliary&&(t.auxiliary.packetsReceived=i.packetsReceived,t.auxiliary.bytesReceived=i.bytesReceived,t.auxiliary.packetsLost=i.packetsLost,t.auxiliary.framesReceived=i.framesReceived,t.auxiliary.framesDecoded=i.framesDecoded,t.auxiliary.fpsDecoded=i.framesPerSecond,o=e.remoteAuxiliaryTrack,t.hasAuxiliary=!0),o&&(o.stat.packetsReceived=i.packetsReceived,o.stat.bytesReceived=i.bytesReceived,o.stat.packetsLost=i.packetsLost,o.stat.framesReceived=i.framesReceived,o.stat.framesDecoded=i.framesDecoded,i.jitterBufferDelay&&(o.stat.jitterBufferDelay=Math.floor(i.jitterBufferDelay/i.jitterBufferEmittedCount*1e3)))}}else"candidate-pair"===i.type&&SD(i)&&mP(i.currentRoundTripTime)&&(t.rtt=Math.floor(1e3*i.currentRoundTripTime));hP(i.frameWidth)||((i.trackIdentifier===e.getMainStreamVideoTrackId()||i.ssrc===r.video)&&(t.video.frameWidth=i.frameWidth,t.video.frameHeight=i.frameHeight,e.remoteVideoTrack.stat.frameWidth=i.frameWidth,e.remoteVideoTrack.stat.frameHeight=i.frameHeight),(i.trackIdentifier===e.getAuxStreamVideoTrackId()||i.ssrc===r.auxiliary)&&(t.auxiliary.frameWidth=i.frameWidth,t.auxiliary.frameHeight=i.frameHeight,e.remoteAuxiliaryTrack.stat.frameWidth=i.frameWidth,e.remoteAuxiliaryTrack.stat.frameHeight=i.frameHeight)),hP(i.audioLevel)||(t.audio.audioLevel=i.audioLevel||0,t.audio.totalAudioEnergy=i.totalAudioEnergy||0)})),0===t.audio.audioLevel&&(t.audio.audioLevel=e.remoteAudioTrack.getInternalAudioLevel()||0)}catch(QO){this._log.warn("failed to getStats on receiver connection ".concat(QO))}return t}))}getStats(e,t){return MA(this,null,(function*(){let i={};e&&(i=yield this.getSenderStats(e));let r=[];for(let[e,n]of t){let e=yield this.getReceiverStats(n);r.push(e)}return{senderStats:i,receiverStats:r}}))}getDifferenceValue(e,t){if(XN(e))return t;let i=t-e;return i<0?0:i}prepareReport(e){let{stats:t,report:i,freezeMap:r}=e;if(!XN(t.senderStats)){let e={uint32_audio_level:t.senderStats.audio.audioLevel*Zk,uint32_audio_energy:1e6*t.senderStats.audio.totalAudioEnergy,uint32_audio_codec_bitrate:t.senderStats.audio.bytesSent},r=[],n={uint32_video_stream_type:2,uint32_video_codec_fps:t.senderStats.video.framesSent,uint32_video_capture_fps:t.senderStats.video.fpsCapture,uint32_video_width:t.senderStats.video.frameWidth,uint32_video_height:t.senderStats.video.frameHeight,uint32_video_codec_bitrate:t.senderStats.video.bytesSent,uint32_video_enc_fps:t.senderStats.video.framesEncoded};if(r.push(n),t.senderStats.small.bytesSent){let e={uint32_video_stream_type:3,uint32_video_codec_fps:t.senderStats.small.framesSent||0,uint32_video_capture_fps:t.senderStats.small.fpsCapture||0,uint32_video_width:t.senderStats.small.frameWidth||0,uint32_video_height:t.senderStats.small.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.small.bytesSent,uint32_video_enc_fps:t.senderStats.small.framesEncoded||0};r.push(e)}if(t.senderStats.auxiliary.bytesSent){let e={uint32_video_stream_type:7,uint32_video_codec_fps:t.senderStats.auxiliary.framesSent||0,uint32_video_capture_fps:t.senderStats.auxiliary.fpsCapture||0,uint32_video_width:t.senderStats.auxiliary.frameWidth||0,uint32_video_height:t.senderStats.auxiliary.frameHeight||0,uint32_video_codec_bitrate:t.senderStats.auxiliary.bytesSent,uint32_video_enc_fps:t.senderStats.auxiliary.framesEncoded||0};r.push(e)}let o={uint32_bitrate:0,uint32_lost:0,uint32_rtt:t.senderStats.rtt};i.msg_up_stream_info={msg_audio_status:e,msg_video_status:r,msg_network_status:o}}let{statInterval:n}=this;i.msg_down_stream_info=[],t.receiverStats.forEach((e=>{let t={msg_user_info:{str_identifier:e.userId,uint64_tinyid:e.tinyId},msg_network_status:{uint32_rtt:e.rtt,uint32_bitrate:0,uint32_lost:0},msg_audio_status:{},msg_video_status:[]};if(e.hasAudio){let i={uint32_audio_codec_bitrate:e.audio.bytesReceived,uint32_audio_total_bitrate:e.audio.bytesReceived,uint32_audio_level:1e8*e.audio.audioLevel,uint32_audio_energy:1e6*e.audio.totalAudioEnergy,uint32_audio_receive:e.audio.packetsReceived,uint32_audio_origin_lost:e.audio.packetsLost};t.msg_audio_status=i}if(e.hasVideo){let i=r.get("".concat(e.userId,"_").concat(tb)),n=i?i.duration:0,o={uint32_video_stream_type:2,uint32_video_receive_fps:e.video.framesReceived,uint32_video_width:e.video.frameWidth,uint32_video_height:e.video.frameHeight,uint32_video_codec_bitrate:e.video.bytesReceived,uint32_video_receive:e.video.packetsReceived,uint32_video_origin_lost:e.video.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.video.framesDecoded};t.msg_video_status.push(o)}if(e.hasAuxiliary){let i=r.get("".concat(e.userId,"_").concat(ib)),n=i?i.duration:0,o={uint32_video_stream_type:7,uint32_video_receive_fps:e.auxiliary.framesReceived,uint32_video_width:e.auxiliary.frameWidth,uint32_video_height:e.auxiliary.frameHeight,uint32_video_codec_bitrate:e.auxiliary.bytesReceived,uint32_video_receive:e.auxiliary.packetsReceived+e.auxiliary.packetsLost,uint32_video_origin_lost:e.auxiliary.packetsLost,uint32_video_block_time:n,uint32_video_dec_fps:e.auxiliary.framesDecoded};t.msg_video_status.push(o)}i.msg_down_stream_info.push(t)}));let o=this._prevReport;if(this._prevReport=JSON.parse(JSON.stringify(i)),i.msg_up_stream_info.msg_audio_status&&o.msg_up_stream_info.msg_audio_status){let e=o.msg_up_stream_info.msg_audio_status,t=i.msg_up_stream_info.msg_audio_status,r=this.getDifferenceValue(e.uint32_audio_codec_bitrate,t.uint32_audio_codec_bitrate);t.uint32_audio_codec_bitrate=Math.round(8*r/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=t.uint32_audio_codec_bitrate}let a=o.msg_up_stream_info.msg_video_status;i.msg_up_stream_info.msg_video_status.forEach((e=>{let t=a.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type));if(!t||0===t.uint32_video_codec_bitrate)return e.uint32_video_codec_bitrate=0,e.uint32_video_enc_fps=0,void(e.uint32_video_codec_fps=0);let r=t.uint32_video_codec_bitrate,o=t.uint32_video_enc_fps,s=t.uint32_video_codec_fps,c=this.getDifferenceValue(r,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*c/n),i.msg_up_stream_info.msg_network_status.uint32_bitrate+=e.uint32_video_codec_bitrate,e.uint32_video_enc_fps=Math.round(this.getDifferenceValue(o,e.uint32_video_enc_fps)/n),e.uint32_video_codec_fps=Math.round(this.getDifferenceValue(s,e.uint32_video_codec_fps)/n)}));let s=i.msg_down_stream_info,c=o.msg_down_stream_info;return s.forEach((e=>{let t=c.find((t=>t.msg_user_info.uint64_tinyid===e.msg_user_info.uint64_tinyid));if(t){if(e.msg_audio_status&&t.msg_audio_status){let i=e.msg_audio_status,r=t.msg_audio_status;i.uint32_audio_origin_lost=this.getDifferenceValue(r.uint32_audio_origin_lost,i.uint32_audio_origin_lost),i.uint32_audio_receive=this.getDifferenceValue(r.uint32_audio_receive,i.uint32_audio_receive),i.uint32_audio_receive+=i.uint32_audio_origin_lost;let o=this.getDifferenceValue(r.uint32_audio_codec_bitrate,i.uint32_audio_codec_bitrate);i.uint32_audio_codec_bitrate=Math.round(8*o/n),i.uint32_audio_total_bitrate=Math.round(8*o/n)}if(e.msg_video_status&&t.msg_video_status){let i=t.msg_video_status;e.msg_video_status=e.msg_video_status.filter((e=>i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)))),e.msg_video_status.forEach((e=>{let t=i.find((t=>t.uint32_video_stream_type===e.uint32_video_stream_type)),r=t.uint32_video_receive,o=t.uint32_video_origin_lost,a=t.uint32_video_codec_bitrate,s=t.uint32_video_receive_fps,c=t.uint32_video_dec_fps;e.uint32_video_origin_lost=this.getDifferenceValue(o,e.uint32_video_origin_lost),e.uint32_video_receive=this.getDifferenceValue(r,e.uint32_video_receive)+e.uint32_video_origin_lost;let l=this.getDifferenceValue(a,e.uint32_video_codec_bitrate);e.uint32_video_codec_bitrate=Math.round(8*l/n);let d=this.getDifferenceValue(s,e.uint32_video_receive_fps);e.uint32_video_receive_fps=Math.round(d/n),e.uint32_video_dec_fps=Math.round(this.getDifferenceValue(c,e.uint32_video_dec_fps)/n)}))}}})),i}getStatsReport(e){return MA(this,arguments,(function(e){var t=this;let{uplinkConnection:i,downlinkConnections:r,freezeMap:n}=e;return function*(){let e={msg_up_stream_info:{msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_level:0,uint32_audio_energy:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_codec_fps:0,uint32_video_capture_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_final_lost:0,uint32_video_enc_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}},msg_down_stream_info:[{msg_user_info:{str_identifier:"",uint64_tinyid:0},msg_audio_status:{uint32_audio_format:0,uint32_audio_sample_rate:0,uint32_audio_codec_bitrate:0,uint32_audio_total_bitrate:0,uint32_audio_level:0,uint32_audio_energy:0,uint32_audio_receive:0,uint32_audio_origin_lost:0,uint32_audio_final_lost:0},msg_video_status:[{uint32_video_stream_type:0,uint32_video_receive_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_codec_bitrate:0,uint32_video_receive:0,uint32_video_origin_lost:0,uint32_video_block_time:0,uint32_video_dec_fps:0}],msg_network_status:{uint32_bitrate:0,uint32_rtt:0,uint32_lost:0}}]},o=yield t.getStats(i,r);return"{}"===JSON.stringify(t._prevReport)&&(t._prevReport=JSON.parse(JSON.stringify(e))),t.prepareReport({stats:o,report:e,freezeMap:n}),t._prevReportTime=Date.now(),e}()}))}reset(){this._prevReportTime=0,this._prevReport={},this._prevEncoderImplementation="",this._prevQualityLimitationReason="",this._prevDecoderImplementationMap=new Map}}(this,this._log),this.userManager=new KO(this.userId,this._log),this._version=oC,this.sdpSemantics=gb,Ox(e.sdpSemantics)?ZP.isUnifiedPlanDefault()&&(this.sdpSemantics=fb):this.sdpSemantics=e.sdpSemantics,this._log.info("sdpSemantics: ".concat(this.sdpSemantics,", netType: ").concat(this._networkType)),this.audioManager=new class{constructor(e){let{log:t}=e;NA(this,"audioContext",null),NA(this,"destination",null),NA(this,"localAudioTrack",null),NA(this,"localScreenAudioTrack",null),NA(this,"audioTrackStreamSource",null),NA(this,"screenAudioTrackStreamSource",null),NA(this,"musicList",[]),NA(this,"hasMusic",!1),NA(this,"mixedMusicMap",new Map),NA(this,"cacheMusicMap",new Map),NA(this,"_log"),this._log=t,this.initAudioContext()}get hasScreenAudioTrack(){return null!==this.localScreenAudioTrack}get hasAudioTrack(){return null!==this.localAudioTrack}isNeedToUseDestination(){return this.hasMusic&&this.localAudioTrack||this.localAudioTrack&&this.localScreenAudioTrack}get mediaStreamTrack(){var e,t;return this.isNeedToUseDestination()?this.destination.stream.getAudioTracks()[0]:(null==(e=this.localAudioTrack)?void 0:e.mediaTrack)||(null==(t=this.localScreenAudioTrack)?void 0:t.mediaTrack)}addMusicSource(e){return MA(this,null,(function*(){this.initAudioContext();let t,{id:i,url:r,loop:n,volume:o}=e;if(this.mixedMusicMap.has(i))return;t=this.cacheMusicMap.has(i)?this.cacheMusicMap.get(i).audioSource:new RO(e);let{stream:a}=t.destination,s=document.createElement("audio");s.srcObject=a,t.play(),yield s.play(),this._log.info("start mix audio ".concat(i," success."));let c=this.audioContext.createMediaStreamSource(a),l=this.audioContext.createGain();c.connect(l),l.connect(this.destination),this.musicList.push(i),this.mixedMusicMap.set(i,{audioSource:t,streamSource:c,gainNode:l,audioPlayer:s}),this.cacheMusicMap.set(i,{audioSource:t}),this.hasMusic=!0}))}addAudioTrack(e){this.initAudioContext(),null!=e&&e.mediaStream&&this.localAudioTrack!==e&&(this.localAudioTrack=e,this.audioTrackStreamSource=this.audioContext.createMediaStreamSource(e.mediaStream),this.audioTrackStreamSource.connect(this.destination))}addScreenAudioTrack(e){this.initAudioContext(),null!=e&&e.mediaStream&&this.localScreenAudioTrack!==e&&(this.localScreenAudioTrack=e,this.screenAudioTrackStreamSource=this.audioContext.createMediaStreamSource(e.mediaStream),this.screenAudioTrackStreamSource.connect(this.destination))}removeAudioTrackSource(e){var t,i;"main"===e&&(null==(t=this.audioTrackStreamSource)||t.disconnect(),this.audioTrackStreamSource=null,this.localAudioTrack=null),"screen"===e&&(null==(i=this.screenAudioTrackStreamSource)||i.disconnect(),this.screenAudioTrackStreamSource=null,this.localScreenAudioTrack=null)}removeMusicSource(e){let{id:t}=e;if(this.mixedMusicMap.has(t)){let{audioSource:e,streamSource:i,gainNode:r,audioPlayer:n}=this.mixedMusicMap.get(t);i.disconnect(),r.disconnect(),n.pause(),n.srcObject=null,e.stop(),this.mixedMusicMap.delete(t),this.musicList=this.musicList.filter((e=>e!==t)),0===this.musicList.length&&(this.hasMusic=!1)}}destroyAllMusic(){this.musicList.forEach((e=>{this.removeMusicSource({id:e})}))}initAudioContext(){if(this.audioContext)return;this.audioContext=RP(),this.destination=this.audioContext.createMediaStreamDestination();let e=this.audioContext,t=()=>{"suspended"===e.state?(e.resume(),document.addEventListener("click",t)):"interrupted"===e.state?e.resume():document.removeEventListener("click",t)};document.addEventListener("click",t),e.onstatechange=()=>{QP.info("audioManager context state: ".concat(e.state)),t()}}destroy(){this.removeAudioTrackSource("main"),this.removeAudioTrackSource("aux"),this.audioContext.close()}}({log:this._log}),e.iceTransportPolicy&&(this._iceTransportPolicy=e.iceTransportPolicy),this._enableMultiAuxStream=!Ox(e.enableMultiAuxStream)&&e.enableMultiAuxStream,this.enableSEI=e.enableSEI,this._initBusinessInfo(e)}get isMainStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isMainStreamPublished)}get isMainAudioPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.localMainAudioTrack)}get isAuxStreamPublished(){var e;return!(null==(e=this.uplinkConnection)||!e.isAuxStreamPublished)}get hasAuxStream(){return[...this.remotePublishedUserMap.values()].findIndex((e=>e.muteState.hasAuxiliary))>=0}get userMap(){return this.userManager.userMap}get remotePublishedUserMap(){return this.userManager.remotePublishedUserMap}get tinyIdToUserIdMap(){return new Map([...this.remotePublishedUserMap.values()].map((e=>[e.tinyId,e.userId])))}join(e,t,i){return MA(this,null,(function*(){return this.userManager.mySelfId=this.userId,this.userManager.on("1",(e=>{this.emit("peer-join",e)})),this.userManager.on("2",(e=>{this.closeDownLinkConnection(e),this.emit("peer-leave",e)})),this.userManager.on("3",this.createDownlinkConnection,this),this.userManager.on("5",this.closeDownLinkConnection,this),this.userManager.on("6",(e=>{var t=((e,t)=>{var i={};for(var r in e)yA.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&TA)for(var r of TA(e))t.indexOf(r)<0&&EA.call(e,r)&&(i[r]=e[r]);return i})(e,[]);!this.isJoined||(WP.emit(KP.REMOTE_PUBLISH_STATE_CHANGED,CA({room:this},t)),this.emit("remote-publish-state-changed",CA({},t)))})),String(e.roomId||e.strRoomId),this._joinOptions=e,new Promise(((t,i)=>MA(this,null,(function*(){this._joinReject=i;try{this.checkDestroy(),yield this.initialize(),yield this.doJoin(e),t()}catch(r){this.reset(),i(r)}this._joinReject=null}))))}))}afterJoin(e){return MA(this,null,(function*(){yield e,this._firstPublishedList&&this.onPublishedUserList({data:{userList:this._firstPublishedList}})}))}doJoin(e){return new Promise(((t,i)=>{var r;Ox(e.role)||(this.role=20===e.role?"anchor":"audience"),Ox(e.privateMapKey)||(this.privateMapKey=e.privateMapKey);let n={roomId:String(e.roomId||e.strRoomId),useStringRoomId:this.useStringRoomId,privateMapKey:this.privateMapKey,trtcRole:"anchor"===this.role?20:21,trtcScene:"live"===this.scene?2:1,sdpSemantics:this.sdpSemantics,version:this._version,ua:navigator&&navigator.userAgent||"",terminalType:Lx(),netType:EC[this._networkType],bussinessInfo:this._businessInfo},{bussinessInfo:o,pushUserCdnInfo:a}=this.publishCDNManager.handleCDNConfigForJoinData(this._businessInfo);Object.assign(n,{bussinessInfo:o,pushUserCdnInfo:a}),this._log.debug("join room signal data: ".concat(JSON.stringify(n)));let s=5e3;(null==(r=this.scheduleResult.config)?void 0:r.enterRoomTimeout)&&this.scheduleResult.config.enterRoomTimeout>=1&&(s=1e3*this.scheduleResult.config.enterRoomTimeout),this._joinTimeout=window.setTimeout((()=>{this._log.error("join room timeout observed"),i(new nD({code:iD.JOIN_ROOM_FAILED,message:Jw({key:hw})}))}),s),WP.emit(KP.JOIN_SEND_CMD,{room:this}),this._signalChannel.once(GM,(e=>{this.clearJoinTimeout(),WP.emit(KP.JOIN_SIGNAL_CONNECTION_END,{room:this,error:e}),i(e)})),this._signalChannel.send(eL,n),this._signalChannel.once($M.JOIN_ROOM_RESULT,(e=>{this.clearJoinTimeout();let{code:r,message:n,data:o}=e.data;WP.emit(KP.JOIN_RECEIVED_CMD_RES,{room:this,code:r}),0===r?(this._log.info("Join room success, start heartbeat"),this.startHeartbeat(),this.syncUserList(),this.startSyncUserListInterval(),this._firstPublishedList=o.publishers,t()):(this._log.error("Join room failed result: ".concat(r," error: ").concat(n)),i(new nD({code:iD.JOIN_ROOM_FAILED,extraCode:r,message:Jw({key:pw,data:{error:n,code:r}})})))}))}))}reJoin(){return MA(this,null,(function*(){if(this.isJoined)try{this._log.warn("reJoin pending: ".concat(this._joinOptions.roomId)),this._signalChannel.close(),yield this._signalChannel.connect(),yield this.doJoin(bA(CA({},this._joinOptions),{role:"anchor"===this.role?20:21,privateMapKey:this.privateMapKey})),this._log.warn("reJoin success"),mN.logSuccessEvent({userId:this.userId,eventType:pb}),this.checkConnectionsToReconnect(),this.uplinkConnection&&!this.uplinkConnection.getIsReconnecting()&&this.uplinkConnection.startReconnection(),this.mixTranscodeManager.reStartMixTranscode()}catch(e){this._log.warn("reJoin fail ".concat(e)),this.reset(),mN.logFailedEvent({userId:this.userId,eventType:pb,error:e}),this.emit("error",new nD({code:iD.JOIN_ROOM_FAILED,message:Jw({key:mw,data:{roomId:this._joinOptions.roomId}})}))}else this._log.warn("reJoin abort")}))}initialize(){this._log.info("setup signal channel");let{mainUrl:e,backupUrl:t}=this.getSignalChannelUrl();return this._signalChannel=new class{constructor(e){NA(this,"_room"),NA(this,"_sdkAppId"),NA(this,"_userId"),NA(this,"_userSig"),NA(this,"_url"),NA(this,"_backupUrl"),NA(this,"_urlWithParam"),NA(this,"_backupUrlWithParam"),NA(this,"_socketInUse"),NA(this,"_socket"),NA(this,"_backupSocket"),NA(this,"_backupTimer",-1),NA(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0}),NA(this,"_currentState",KM),NA(this,"_reconnectionCount",0),NA(this,"_reconnectionTimer",-1),NA(this,"_seq",0),NA(this,"_log"),NA(this,"_emitter"),NA(this,"_lastMessageTime",-1),NA(this,"_prevTime",-1),this._room=e.room,this._sdkAppId=e.sdkAppId,this._userId=e.userId,this._userSig=e.userSig,this._url=e.url,this._backupUrl=e.backupUrl;let t="?sdkAppId=".concat(encodeURIComponent(this._sdkAppId),"&userId=").concat(encodeURIComponent(this._userId),"&userSig=").concat(encodeURIComponent(this._userSig));this._urlWithParam="".concat(this._url).concat(t),this._backupUrlWithParam="".concat(this._backupUrl).concat(t),this._seq=0,this._log=QP.createLogger({id:"ws",userId:this._userId,sdkAppId:this._sdkAppId}),this._emitter=new BM.default}get isConnected(){return this._currentState===QM}get isConnecting(){return this._currentState===qM}get isOnline(){return this._currentState===QM&&Date.now()-this._lastMessageTime<12e3}connect(){return new Promise(((e,t)=>{this._prevTime<0&&(this._prevTime=bP()),this._log.info("connect to ".concat(this._url)),this.emitConnectionStateChanged(qM),this._socket=new WebSocket(this._urlWithParam),this.bindSocket(this._socket),this._backupTimer=setTimeout((()=>{this.isConnected||(this._log.info("trying to connect to backupUrl"),this.tryConnectBackup())}),5e3),this.once(JM,e),this.once(zM,t)}))}tryConnectBackup(){this._backupSocket||(this.unbindAndCloseSocket(JC),this._log.debug("try to connect to url: ".concat(this._backupUrlWithParam)),this._backupSocket=new WebSocket(this._backupUrlWithParam),this.bindSocket(this._backupSocket))}bindSocket(e){e.onopen=this.onopen.bind(this),e.onclose=this.onclose.bind(this),e.onerror=this.onerror.bind(this),e.onmessage=this.onmessage.bind(this)}unbindSocket(e){this.clearBackupTimer(),e.onopen=()=>{},e.onclose=()=>{},e.onerror=()=>{},e.onmessage=()=>{}}unbindAndCloseSocket(t){if(t===JC){if(this._socket){this.unbindSocket(this._socket);try{this._socket.close(1e3)}catch(e){}this._socket=null}}else if(this._backupSocket){this.unbindSocket(this._backupSocket);try{this._backupSocket.close(1e3)}catch(e){}this._backupSocket=null}}clearBackupTimer(){-1!==this._backupTimer&&(clearTimeout(this._backupTimer),this._backupTimer=-1)}clearReconnectionTimer(){-1!==this._reconnectionTimer&&(clearTimeout(this._reconnectionTimer),this._reconnectionTimer=-1)}onopen(e){this.isConnected||(this.isReconnecting&&!this._signalInfo.tinyId&&this.stopReconnection(),this.clearBackupTimer(),e.target===this._socket?(this.unbindAndCloseSocket(zC),this._socketInUse=this._socket):(this.unbindAndCloseSocket(JC),this._socketInUse=this._backupSocket),this.emitConnectionStateChanged(QM),this._emitter.emit(JM))}onclose(e){let{url:t}=e.target,i=e.target===this._socketInUse;this._log.info("websocket[".concat(t," InUse: ").concat(i,"] is closed with code: ").concat(e.code)),e.target===this._socketInUse&&(this.emitConnectionStateChanged(KM),(!e.wasClean||1e3!==e.code)&&(this._log.warn("onclose code:".concat(e.code," reason:").concat(e.reason)),this._log.warn("close current websocket and schedule a reconnect timeout"),this._socketInUse.onclose=()=>{},this._socketInUse.close(4011),this._socket=null,this._backupSocket=null,this._socketInUse=null,this.reconnect(JC)))}onerror(e){let{url:t}=e.target;this._log.error("websocket[".concat(t,"] error observed")),this.isConnected?e.target===this._socketInUse&&(this.unbindAndCloseSocket(JC),this.unbindAndCloseSocket(zC),this._socketInUse=null,this.reconnect(JC)):(this.isReconnecting||WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"WebsocketConnect",error:new Error("ws onerror")}),e.target==this._socket?(this.unbindAndCloseSocket(JC),this.reconnect(zC)):(this.unbindAndCloseSocket(zC),this.reconnect(JC)))}onmessage(e){if(!this.isConnected)return;this._lastMessageTime=Date.now();let t=JSON.parse(e.data),{cmd:i,data:r}=t,n=Object.values(YM),o=Object.keys(YM)[n.indexOf(i)],a=$M[o];switch(XM.includes(i)||(this._log.debug("received msg: ".concat(e.data)),this._log.info("Received event: [ ".concat(a||"unknown cmd: ".concat(i)," ]"))),i){case YM.CHANNEL_SETUP_RESULT:if(0===t.code)this._signalInfo.clientIp=r.clientIp,this._signalInfo.signalIp=r.signalInnerIp,this._signalInfo.tinyId=t.tinyId,r.svrTime&&function(e){Ub=e-(new Date).getTime();let t=new Date;t.setTime(e),QP.info("baseTime from server: ".concat(t," offset: ").concat(Ub))}(r.svrTime),this._log.info("ChannelSetup Success"),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"WebsocketConnect",cost:bP()-this._prevTime}),this._prevTime=-1,this._emitter.emit(HM,{signalInfo:this._signalInfo});else{let e=new nD({code:iD.SIGNAL_CHANNEL_SETUP_FAILED,extraCode:t.code,message:Jw({key:iw,data:{errorCode:t.code,errorMsg:t.message}})});this._log.error("".concat(t.code,", ").concat(t.message)),this.close(),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"WebsocketConnect",error:e}),this._emitter.emit(GM,e)}break;case YM.JOIN_ROOM_RESULT:0===t.code&&(this._signalInfo.relayIp=r.relayOuterIp,this._signalInfo.relayInnerIp=r.relayInnerIp,this._signalInfo.relayPort=r.relayPort,this._log.info("signalIp:".concat(this._signalInfo.signalIp," clientIp:").concat(this._signalInfo.clientIp," relayIp: ").concat(this._signalInfo.relayIp))),this._emitter.emit(a,{data:t});break;case YM.CHANNEL_RECONNECT_RESULT:0===t.code?(this._log.warn("reconnect success"),this.stopReconnection(),WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"WebsocketReconnect",cost:bP()-this._prevTime}),this._prevTime=-1,this._room.syncUserList(),this._room.checkConnectionsToReconnect()):(this._log.warn("reconnect failed, ".concat(t.code," ").concat(t.message)),this._room.reJoin());break;default:this._emitter.emit(a,{data:t})}}reconnect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:JC;if(this.isReconnecting)return;if(this._reconnectionCount>=30){this._log.warn("SDK has tried reconnect signal channel for ".concat(30," times, but all failed. please check your network"));let e=new nD({code:iD.SIGNAL_CHANNEL_RECONNECTION_FAILED,message:Jw({key:tw})});return WP.emit(KP.API_SUCCESS_RATE,{room:this._room,apiName:"WebsocketReconnect",error:e}),void this._emitter.emit(zM,e)}this._reconnectionCount++,this._log.warn("reconnect ".concat(e," [").concat(this._reconnectionCount,"/").concat(30,"]"));let t=this.getReconnectionUrl(e);this.emitConnectionStateChanged(qM),this._prevTime<0&&(this._prevTime=bP()),e===JC?(this._socket=new WebSocket(t),this.bindSocket(this._socket)):(this._backupSocket=new WebSocket(t),this.bindSocket(this._backupSocket));let i=lP(this._reconnectionCount);this._reconnectionTimer=setTimeout((()=>{this._log.warn("reconnect ".concat(e," timeout(").concat(i/1e3,"s), try again")),this.clearReconnectionTimer(),this.unbindAndCloseSocket(JC),this.unbindAndCloseSocket(zC),this.reconnect(e===JC?zC:JC)}),i)}get isReconnecting(){return-1!==this._reconnectionTimer}getReconnectionUrl(e){let t=e===JC?this._urlWithParam:this._backupUrlWithParam;if(this._signalInfo.tinyId&&-1===t.indexOf("&rc=1")){let{roomId:e,useStringRoomId:i}=this._room;t+="&rc=1&relayInnerIp=".concat(this._signalInfo.relayInnerIp,"&relayOuterIp=").concat(this._signalInfo.relayIp,"&relayPort=").concat(this._signalInfo.relayPort,"&roomId=").concat(e,"&useStringRoomId=").concat(i)}return t}send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isConnected){let i={cmd:e,data:t,userId:this._userId,tinyId:this._signalInfo.tinyId,seq:++this._seq};return this._socketInUse.send(JSON.stringify(i)),i.seq}}sendWaitForResponse(e){let{command:t,data:i,timeout:r=5e3,responseCommand:n,commandDesc:o,enableLog:a=!0}=e;return new Promise(((e,s)=>{let c=setTimeout((()=>{this.off(n,l);let e=new nD({code:iD.API_CALL_TIMEOUT,message:Jw({key:ew,data:{commandDesc:o,command:t}})});a&&this._log.warn(e),s(e)}),r),l=t=>{t.data.seq===d&&(clearTimeout(c),this.off(n,l),e(t))};this.on(n,l);let d=this.send(t,i)}))}sendWaitForResponseWithRetry(e){let{commandDesc:t,command:i,retries:r=0,retryTimeout:n=0}=e;return GP({retryFunction:this.sendWaitForResponse,onRetrying:e=>{this._log.warn("".concat(t||i," timeout observed, retrying [").concat(e,"/").concat(r,"]"))},settings:{retries:r,timeout:n},context:this})(e)}getCurrentState(){return this._currentState}getSignalInfo(){return this._signalInfo}stopReconnection(){this.isReconnecting&&(this._reconnectionCount=0,this.clearReconnectionTimer())}close(){this._log.info("close SignalChannel"),this.clearBackupTimer(),this.stopReconnection(),this._signalInfo={tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0},this._socketInUse=null,this.unbindAndCloseSocket(JC),this.unbindAndCloseSocket(zC),this.emitConnectionStateChanged(KM)}on(e,t,i){this._emitter.on(e,t,i)}removeListener(e,t,i){this._emitter.removeListener(e,t,i)}once(e,t,i){this._emitter.once(e,t,i)}off(e,t,i){this._emitter.off(e,t,i)}emitConnectionStateChanged(e){e!==this._currentState&&(this._log.info("".concat(this._currentState," -> ").concat(e)),this._emitter.emit(WM,{prevState:this._currentState,state:e}),this._currentState=e)}}({sdkAppId:this.sdkAppId,userId:this.userId,userSig:this.userSig,url:e,backupUrl:t,room:this}),this._networkQuality||(this._networkQuality=new JL({signalChannel:this._signalChannel,room:this}),this._networkQuality.on(JL.EVENT_NETWORK_QUALITY,(e=>{this.emit("network-quality",e)}))),this._signalChannel.on(WM,(e=>{WP.emit(KP.SIGNAL_CONNECTION_STATE_CHANGED,CA({room:this},e)),this.emit("signal-connection-state-changed",e)})),this._signalChannel.on(zM,(e=>{this.reset(),this.emit("error",e)})),this._signalChannel.once(HM,(e=>{this.tinyId=e.signalInfo.tinyId,WP.emit(KP.JOIN_SIGNAL_CONNECTION_END,{room:this})})),this._signalChannel.on($M.PEER_JOIN,(e=>{let{srcTinyId:t,userId:i,role:r}=e.data.data;this.userManager.addUser({userId:i,tinyId:t,role:r})})),this._signalChannel.on($M.PEER_LEAVE,(e=>{let{userId:t,reason:i=0}=e.data.data;this.userManager.deleteUser(t,i)})),this._signalChannel.on($M.UPDATE_REMOTE_MUTE_STAT,(e=>{Date.now()-this._lastHeartBeatTime>=1e4&&this.doHeartbeat(),this.onPublishedUserList(e.data)})),this._signalChannel.on($M.CLIENT_BANNED,(e=>{let t=e.data.data,{reason:i}=t;if(mN.uploadEvent({log:"stat-banned:".concat(i),userId:this.userId}),"user_time_out"===i)return this._log.warn("".concat(i," last heart beat time: ").concat(this._lastHeartBeatTime," interval: ").concat(Date.now()-this._lastHeartBeatTime,", visibility: ").concat(document.visibilityState)),void this.reJoin();this._log["kick"===i?"error":"info"]("user was banned because of [".concat(i,"]")),this.reset(),this.emit("banned",{reason:i})})),WP.emit(KP.JOIN_SIGNAL_CONNECTION_START,{room:this}),this._signalChannel.connect()}leave(){return MA(this,null,(function*(){try{yield this.doHeartbeat()}catch(e){}WP.emit(KP.LEAVE_SEND_CMD,{room:this}),this._log.info("leave() => leaving room"),this._signalChannel.send(tL),this.reset()}))}clearNetworkQuality(){this._networkQuality&&(this._networkQuality.stop(),this._networkQuality=null)}closeConnections(){this.remotePublishedUserMap.forEach((e=>{this.closeDownLinkConnection(e.userId)}))}clearJoinTimeout(){clearTimeout(this._joinTimeout),this._joinTimeout=-1}startHeartbeat(){-1===this._heartbeat&&(this._heartbeat=uN.run(Mb,this.doHeartbeat.bind(this),{delay:2e3}))}stopHeartbeat(){-1!==this._heartbeat&&(this._log.info("stopHeartbeat"),uN.clearTask(this._heartbeat),this._heartbeat=-1,this._lastHeartBeatTime=-1)}doHeartbeat(){return MA(this,null,(function*(){var e;let t=this.badCaseDetector.getMonitorFreeze(),i=yield this._stats.getStatsReport({uplinkConnection:this.uplinkConnection,downlinkConnections:this.remotePublishedUserMap,freezeMap:t});if(this.badCaseDetector.resetMonitor(),null==(e=this._signalChannel)||!e.isConnected)return;let r=this._signalChannel.isConnected?function(e){if(WO.has(e)){let t=WO.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,str_event_json:e.eventDesc})));return WO.delete(e),t}return[]}(this.userId):[],n=CA({str_sdk_version:nC,uint64_datetime:(new Date).getTime(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyId},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:EC[this._networkType]},msg_event_msg:r,str_acc_ip:this.getSignalInfo().relayIp,str_client_ip:this.getSignalInfo().clientIp},i);WP.emit(KP.HEARTBEAT_REPORT,{room:this,report:n}),this._signalChannel.send(iL,n);let o=Date.now();this._lastHeartBeatTime>0&&o-this._lastHeartBeatTime>1e4&&this._log.warn("heartbeat took ".concat(o-this._lastHeartBeatTime)),this._signalChannel.isConnected&&(this._lastHeartBeatTime=o),!this._isRelayChanged&&this.isRelayMaybeFailed()&&(this.reJoin(),this._isRelayChanged=!0)}))}onPublishedUserList(e){let t=e.data.userList.map((e=>{let{userId:t,srcTinyId:i,flag:r}=e,n=this.remotePublishedUserMap.get(t);return n&&this._changeBigSmallRecords.has(t)&&this.checkSubscribeBigSmallVideo(n),{userId:t,tinyId:i,flag:r}}));WP.emit(KP.RECEIVED_PUBLISHED_USER_LIST,{room:this,publishedUserList:t}),this.userManager.setRemotePublishedUserList(t)}closeUplink(){this.uplinkConnection&&(this.localTracks.size>0&&this.uplinkConnection.doUnpublish(),this.uplinkConnection.close(),this.uplinkConnection=null),this.localTracks.forEach((e=>e.unpublish())),this.localTracks.clear()}createDownlinkConnection(e){let{userId:t,tinyId:i,flag:r}=e,n=new OL({userId:t,tinyId:i,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,flag:r});this.userManager.addRemotePublishedUser(n),this.installDownlinkEvents(n,t),this.emit("remote-published",n)}closeDownLinkConnection(e){let t=this.remotePublishedUserMap.get(e);t&&(t.getIsReconnecting()&&t.stopReconnection(),t.close(),this.emit("remote-unpublished",t))}installDownlinkEvents(e,t){e.on("error",(e=>{let i=e.getCode();i!==iD.ICE_TRANSPORT_ERROR&&(i===iD.DOWNLINK_RECONNECTION_FAILED&&this.closeDownLinkConnection(t),this.emit("error",e))})),e.on("connection-state-changed",(t=>{this.emit("media-connection-state-changed",bA(CA({},t),{userId:e.userId}))})),e.on("firewall-restriction",(()=>{this.emit("firewall-restriction")}))}startSyncUserListInterval(){-1===this._syncUserListInterval&&(this._syncUserListInterval=uN.run(Mb,this.syncUserList.bind(this)))}stopSyncUserListInterval(){uN.clearTask(this._syncUserListInterval),this._syncUserListInterval=-1}syncUserList(){return this.getUserList().then((e=>{this.userManager.setUserList(e)})).catch((e=>{this._log.debug("sync user list failed: ".concat(e))}))}getUserList(){var e;return null!=(e=this._signalChannel)&&e.isConnected?this._signalChannel.sendWaitForResponse({command:fL,responseCommand:$M.USER_LIST_RES,enableLog:!1,timeout:2e3}).then((e=>{let{data:t}=e,{code:i,message:r}=t;if(0===i)return(t.data&&t.data.userList||[]).map((e=>{let{userId:t,srcTinyId:i,role:r}=e;return{userId:t,tinyId:i,role:r}}));throw Jw({key:Lw,data:{signalResponse:$M.USER_LIST_RES,code:i,message:r}})})):Promise.reject("not connected")}getAllConnections(){let e=[...this.remotePublishedUserMap.values()];return this.uplinkConnection&&e.push(this.uplinkConnection),e}isRelayMaybeFailed(){if(!this._signalChannel.isOnline||!AL)return!1;let e=this.getAllConnections();if(0===e.length)return!1;for(let t=0;t<e.length;t++)if(e[t].getReconnectionCount()<6)return!1;return!0}checkConnectionsToReconnect(){this.getAllConnections().forEach((e=>{if(!e.getIsReconnecting()){let t=e.getPeerConnection();t&&t.connectionState===sb&&(this._log.warn("[".concat(e.getUserId(),"] pc is closed but not reconnect")),e.startReconnection())}}))}destroy(){this._isDestroyed||(super.destroy(),this._joinReject&&(this._joinReject(new nD({code:iD.INVALID_OPERATION,message:Jw({key:Rw,data:{funName:"join"}})})),this.clearJoinTimeout(),this.reset()),this.removeAllListeners())}switchRole(e){return MA(this,null,(function*(){this.role!==e&&("audience"===e&&this.uplinkConnection&&this.closeUplink(),yield this.doSwitchRole(e))}))}doSwitchRole(e){let t={command:gL,data:{role:"anchor"===e?20:21,privateMapKey:this.privateMapKey},responseCommand:$M.SWITCH_ROLE_RES,retries:1};return this._log.info("switchRole signal data: ".concat(JSON.stringify(t.data))),this._signalChannel.sendWaitForResponseWithRetry(t).then((t=>{let{code:i,message:r}=t.data;if(0!==i)throw new nD({code:iD.SWITCH_ROLE_FAILED,message:Jw({key:vw,data:{message:r,code:i}})});this.role=e})).catch((e=>{throw e instanceof nD&&e.getCode()===iD.API_CALL_TIMEOUT&&(e=new nD({code:iD.SWITCH_ROLE_FAILED,message:Jw({key:gw})})),this._log.error(e),e}))}publish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MA(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role)return;WP.emit(KP.PUBLISH_START,{room:this});let e={},i={};this._isPublishing=!0,t.forEach((t=>{!t.mediaTrack||(t instanceof _O&&(t instanceof yO?(i.audio=t,this.audioManager.addScreenAudioTrack(t)):(e.audio=t,this.audioManager.addAudioTrack(t))),t instanceof fO&&(t instanceof SO&&2===t.mediaType?i.video=t:e.video=t),t.setPublishStarting())}));try{let r=xx(e),n=xx(i);(!r||!n)&&!this.uplinkConnection&&(this.uplinkConnection=new HL({userId:this.userId,tinyId:this.tinyId,room:this,signalChannel:this._signalChannel,enableSEI:this.enableSEI,audioManager:this.audioManager}),this.uplinkConnection.on("connection-state-changed",(e=>{this.emit("media-connection-state-changed",bA(CA({},e),{userId:this.userId}))})),this.uplinkConnection.on("firewall-restriction",(()=>{this.emit("firewall-restriction")})),this.uplinkConnection.on("error",(e=>{let t=e.getCode();t!==iD.ICE_TRANSPORT_ERROR&&(t===iD.UPLINK_RECONNECTION_FAILED&&this.closeUplink(),this.emit("error",e))}))),r||(this._log.info("publish() => main stream"),yield this.uplinkConnection.publish({localAudioTrack:e.audio,localVideoTrack:e.video,isAuxiliary:!1}),this._log.info("main stream is published")),n||(this._log.info("publish() => aux stream"),yield this.uplinkConnection.publish({localAudioTrack:i.audio,localVideoTrack:i.video,isAuxiliary:!0}),this._log.info("aux stream is published")),this._isPublishing=!1,t.forEach((e=>{!e.mediaTrack||(this.localTracks.add(e),e.publish(this))}))}catch(r){throw t.forEach((e=>{let t="error";r.message.includes("timeout")?t="timeout":r.code===iD.API_CALL_ABORTED&&(t="api-call"),e.setPublishStopped(t,"error"===t?r:void 0)})),this._isPublishing=!1,r}}))}unpublish(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MA(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||!this.isMainStreamPublished&&!this.isAuxStreamPublished||!this.uplinkConnection)return;let e={},i={};t.forEach((t=>{!t.mediaTrack||(t instanceof _O&&(t instanceof yO?i.audio=t:e.audio=t),t instanceof fO&&(t instanceof SO&&2===t.mediaType?i.video=t:e.video=t))}));try{xx(e)||(this._log.info("unpublish() => main stream"),yield this.uplinkConnection.unpublish({localAudioTrack:e.audio,localVideoTrack:e.video})),xx(i)||(this._log.info("unpublish() => aux stream"),yield this.uplinkConnection.unpublish({localAudioTrack:i.audio,localVideoTrack:i.video}))}catch(r){}t.forEach((e=>{!e.mediaTrack||(e.unpublish(),this.localTracks.delete(e))})),0===this.localTracks.size&&this.closeUplink()}))}addTrack(e){return this.uplinkConnection&&e.mediaTrack?(e.setPublishStarting(),this.uplinkConnection.addTrack(e.mediaTrack,e).then((t=>(e.publish(this),t)))):Promise.resolve()}removeTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.removeTrack(e.mediaTrack,e).then((t=>(e.unpublish(),t))):Promise.resolve()}replaceTrack(e){return this.uplinkConnection&&e.mediaTrack?this.uplinkConnection.replaceTrack(e.mediaTrack,e).then((t=>{WP.emit(KP.LOCAL_TRACK_REPLACED,{track:e})})):Promise.resolve()}setBandWidth(e){return MA(this,null,(function*(){!this.uplinkConnection||(yield this.uplinkConnection.setBandwidth(e),yield this.uplinkConnection.sendMediaSettings())}))}subscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MA(this,null,(function*(){let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";try{let n=CA({},i.subscribeState);t.forEach((e=>{switch(e.mediaType){case 1:n.audio=!0;break;case 4:n.video=!0;break;case 2:n.auxiliary=!0}}));let o=this._changeBigSmallRecords.get(e);o&&o.options.smallVideo&&i.muteState.hasSmall&&n.video&&(n.video=!1,n.smallVideo=!0),WP.emit(KP.SUBSCRIBE_START,{room:this,streamType:r,remotePublishedUser:i,subscribeState:n}),this._log.info("subscribe() => ".concat(r," [").concat(PL(n),"] prev: [").concat(PL(i.subscribeState),"]")),yield i.subscribe(n,r),i.remoteVideoTrack.setMediaType(n.smallVideo?8:4),t.forEach((e=>e.subscribe())),WP.emit(KP.SUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}catch(aC){let i=aC instanceof nD?aC.getCode():iD.UNKNOWN,n=aC;throw aC instanceof nD?i===iD.REMOTE_STREAM_NOT_EXIST&&(n=new nD({code:iD.API_CALL_ABORTED,message:Jw({key:Fw,data:{message:aC.message,userId:e,streamType:r}})}),this._log.warn(n)):(n=new nD({code:i,message:Jw({key:fw,data:{message:aC.message,userId:e,streamType:r}})}),this._log.error(n)),n}}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MA(this,null,(function*(){let{userId:e}=t[0],i=this.remotePublishedUserMap.get(e);if(!i)return;let r=t.find((e=>2===e.mediaType))?"auxiliary":"main";this._log.info("unsubscribe() => ".concat(r)),yield i.unsubscribe({remoteTracks:t,streamType:r}),t.forEach((e=>{e.unsubscribe(),8===e.mediaType&&e.setMediaType(4)})),WP.emit(KP.UNSUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:i})}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1?arguments[1]:void 0;if(e<=0)return this._enableAudioVolumeEvaluation=!1,uN.clearTask(this._audioVolumeIntervalId),void(this._audioVolumeIntervalId=null);e=Math.floor(Math.max(e,100)),WP.emit(KP.AUDIO_LEVEL_INTERVAL,{interval:e}),this._audioVolumeIntervalId&&(uN.clearTask(this._audioVolumeIntervalId),this._audioVolumeIntervalId=null),this._enableAudioVolumeEvaluation=!0,this._audioVolumeIntervalId=uN.run(Lb,(()=>{var e,t;let i=[];if(null!=(e=this.uplinkConnection)&&e.localMainAudioTrack){let e=Math.floor(100*this.uplinkConnection.localMainAudioTrack.getAudioLevel());i.push({userId:"",volume:e})}null==(t=this.remotePublishedUserMap)||t.forEach((e=>{if(e.muteState.hasAudio){let t=Math.floor(100*e.remoteAudioTrack.getAudioLevel());i.push({userId:e.userId,volume:t})}})),this.emit("audio-volume",i)}),{fps:1e3/e,backgroundTask:t})}getLocalAudioStats(){return MA(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0},this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t.audio.bytesSent,packetsSent:t.audio.packetsSent}}return e}))}getLocalVideoStats(){return MA(this,null,(function*(){let e={};if(e[this.userId]={bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0},this.uplinkConnection){let{video:{bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:a}}=yield this._stats.getSenderStats(this.uplinkConnection);e[this.userId]={bytesSent:t,packetsSent:i,framesEncoded:r,framesSent:n,frameWidth:o,frameHeight:a}}return e}))}getTransportStats(){return MA(this,null,(function*(){let e={rtt:0,downlinksRTT:{}};if(this.uplinkConnection){let t=yield this._stats.getSenderStats(this.uplinkConnection);e.rtt=t.rtt}for(let[,t]of this.remotePublishedUserMap){let i=yield this._stats.getReceiverStats(t);e.downlinksRTT[i.userId]=i.rtt}return e}))}getRemoteVideoStats(e){return MA(this,null,(function*(){let t={};for(let[i,r]of this.remotePublishedUserMap)"main"===e&&r.muteState.hasVideo&&(t[i]=r.remoteVideoTrack.stat),"auxiliary"===e&&r.muteState.hasAuxiliary&&(t[i]=r.remoteAuxiliaryTrack.stat);return t}))}getRemoteAudioStats(){return MA(this,null,(function*(){let e={};for(let[t,i]of this.remotePublishedUserMap)i.muteState.hasAudio&&(e[t]=i.remoteAudioTrack.stat);return e}))}setProxyServer(e){if(Dx(e)){if(!e.startsWith("wss://"))throw new nD({code:iD.INVALID_PARAMETER,message:"invalid websocket url"});this.proxy_ws=e}else if(Nx(e)){let{websocketProxy:t,loggerProxy:i}=e;t&&(this.proxy_ws=t),i&&(e=>{lC=e})(i)}}setTurnServer(e,t){this._log.info("set turn server: ".concat(JSON.stringify(e)," ").concat(t||""));let i=[];Array.isArray(e)?e.forEach((e=>i.push(jb.getTurnServer(e)))):jb.isPlainObject(e)&&i.push(jb.getTurnServer(e)),this._turnServers=i,t&&(this._iceTransportPolicy=t)}sendStartMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:mL,data:e,timeout:5e3,responseCommand:$M.START_MIX_TRANSCODE_RES,commandDesc:"startMixTranscode"})}sendStopMixTranscode(e){return this._signalChannel.sendWaitForResponse({command:_L,data:e,timeout:5e3,responseCommand:$M.STOP_MIX_TRANSCODE_RES,commandDesc:"stopMixTranscode"})}sendStartPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?dL:hL,data:e,timeout:5e3,responseCommand:t?$M.START_PUBLISH_TENCENT_CDN_RES:$M.START_PUBLISH_GIVEN_CDN_RES,commandDesc:"startPublishCDN"})}sendStopPublishCDN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this._signalChannel.sendWaitForResponse({command:t?uL:pL,data:e,timeout:5e3,responseCommand:t?$M.STOP_PUBLISH_TENCENT_CDN_RES:$M.STOP_PUBLISH_GIVEN_CDN_RES,commandDesc:"stopPublishCDN"})}getIceServers(){return 0===this._turnServers.length&&this.scheduleResult.iceServers?this.scheduleResult.iceServers:this._turnServers}getIceTransportPolicy(){return this._iceTransportPolicy||this.scheduleResult.iceTransportPolicy||"all"}getLogger(){return this._log}enableAIVoice(){throw new Error("Method not implemented.")}getSignalChannelUrl(){let e={mainUrl:"",backupUrl:""},t=jb.getEnv();return t?(e.mainUrl="wss://".concat(t,".rtc.qq.com"),e.backupUrl=e.mainUrl):this.proxy_ws?(e.mainUrl=this.proxy_ws,e.backupUrl=e.mainUrl):Array.isArray(this.scheduleResult.domains)&&this.scheduleResult.domains.length>0&&(e.mainUrl="wss://".concat(this.scheduleResult.domains[0]),e.backupUrl=e.mainUrl,this.scheduleResult.domains[1]&&(e.backupUrl="wss://".concat(this.scheduleResult.domains[1]))),e}getSignalInfo(){var e;return(null==(e=this._signalChannel)?void 0:e.getSignalInfo())||{}}reset(){this.mixTranscodeManager.reset(),this.publishCDNManager.reset(),this.stopSyncUserListInterval(),this.stopHeartbeat(),this.closeConnections(),this.clearNetworkQuality(),this.closeUplink(),this._signalChannel&&(this._log.info("destroying SignalChannel"),this._signalChannel.close()),this._stats.reset(),this.userManager.clear(),this.userManager.removeAllListeners()}checkSubscribeBigSmallVideo(e){return MA(this,null,(function*(){let t=null==e?void 0:e.muteState.hasSmall,i=null==e?void 0:e.muteState.hasVideo;if(!t&&!i||!e.isBigStreamSubscribed&&!e.isSmallStreamSubscribed)return;let r=e.getUserId(),n=this._changeBigSmallRecords.get(r)||{},o=e.getSubscribeState(),{options:a,isSubscribing:s,reSubscribeCount:c}=n;if(a.video&&o.video||a.smallVideo&&o.smallVideo&&t||s)return;let l={audio:o.audio,auxiliary:o.auxiliary,video:a.video,smallVideo:a.smallVideo};if(t&&e.isBigStreamSubscribed||e.isSmallStreamSubscribed)try{a&&!s&&c>=1&&(n.isSubscribing=!0,n.reSubscribeCount=c-1,!t&&e.isSmallStreamSubscribed&&(l.video=!0,l.smallVideo=!1),yield null==e?void 0:e.subscribe(l,"main"),e.remoteVideoTrack.setMediaType(l.smallVideo?8:4),this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video successfully. count ").concat(10-n.reSubscribeCount,".")),n.isSubscribing=!1,n.reSubscribeCount=10)}catch(d){this._log.info("change [".concat(r,"] to ").concat(l.smallVideo?"small":"big"," video failed. count ").concat(10-n.reSubscribeCount,".")),n.isSubscribing=!1,0===c&&this._changeBigSmallRecords.delete(r)}}))}changeType(e,t){let i={options:{video:!e,smallVideo:e},isSubscribing:!1,reSubscribeCount:10};this._changeBigSmallRecords.set(t.userId,i),this._log.info("set [".concat(t.userId,"] video prefer type: ").concat(e?"small":"big"))}get smallStreamConfig(){return this._smallStreamConfig}_initBusinessInfo(e){this._businessInfo=e.businessInfo;let t={};if(Dx(e.businessInfo)&&(t=JSON.parse(e.businessInfo)),!Ox(e.pureAudioPushMode)){if(!Number.isInteger(Number(e.pureAudioPushMode)))throw new nD({code:iD.INVALID_PARAMETER,message:Jw({key:sw})});this._pureAudioPushMode=e.pureAudioPushMode,t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.pure_audio_push_mod=this._pureAudioPushMode}if(!Ox(e.streamId)){if(!(Dx(e.streamId)&&String(e.streamId)&&String(e.streamId).length<=64))throw new nD({code:iD.INVALID_PARAMETER,message:Jw({key:cw})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_streamid_main=e.streamId}if(!Ox(e.userDefineRecordId)){let i=/^[A-Za-z0-9_-]{1,64}$/gi;if(null===e.userDefineRecordId.match(i))throw new nD({code:iD.INVALID_PARAMETER,message:Jw({key:lw})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_record_id=e.userDefineRecordId}if(!Ox(e.userDefinePushArgs)){if(!(Dx(e.userDefinePushArgs)&&String(e.userDefinePushArgs)&&String(e.userDefinePushArgs).length<=256))throw new nD({code:iD.INVALID_PARAMETER,message:Jw({key:dw})});t.Str_uc_params||(t.Str_uc_params={}),t.Str_uc_params.userdefine_push_args=e.userDefinePushArgs}xx(t)||(this._businessInfo=JSON.stringify(t))}startPlugin(e,t){return MA(this,null,(function*(){var i;"RTCAudioMixer"===e&&(yield null==(i=this.audioManager)?void 0:i.addMusicSource(t))}))}stopPlugin(e,t){return MA(this,null,(function*(){var i;"RTCAudioMixer"===e&&(null==(i=this.audioManager)||i.removeMusicSource(t))}))}};return DA([hO(Ux.prototype.afterJoin),Rx(["left",Px.INIT],"joined"),pO((e=>{let t=new class{constructor(){this._set=new Set,WP.on(KP.LEAVE_SUCCESS,this.delete,this)}add(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,i||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}delete(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,t.roomId||i,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}getKey(e,t,i,r){return"".concat(i,"_").concat(t,"_").concat(e,"_").concat(r)}isJoined(e){let{userId:t,roomId:i,sdkAppId:r,room:n}=e;return"rtc"!==n.scene&&this._set.has(this.getKey(t,i,r,n.useStringRoomId))}};return function(i,r,n){return MA(this,null,(function*(){let o=String(i.roomId||i.strRoomId);if(this.userId=i.userId,this.sdkAppId=i.sdkAppId,this.userSig=i.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,i.privateMapKey=i.privateMapKey||"",this.isJoined)throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:uw})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:o,sdkAppId:this.sdkAppId,room:this}))throw new nD({code:iD.INVALID_OPERATION,message:Jw({key:Iw,data:this.userId})});t.add({room:this,roomId:o}),this._log.info("Join() => joining room: ".concat(o," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),this.role=21===i.role?"audience":"anchor",WP.emit(KP.JOIN_START,{room:this,roomId:o}),this.checkSystemResult=yield ZP.checkSystemRequirementsInternal(),this.checkDestroy();let a=jb.getEnv();a||(a=vC,this.proxy_ws&&(this.proxy_ws.startsWith($C)?a=TC:this.proxy_ws.startsWith(ZC)&&(a=SC))),mN.setConfig({env:a,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:o}),jM.call(this);let{isH264EncodeSupported:s,isVp8EncodeSupported:c}=this.checkSystemResult.detail;if(!ZP.isWebRTCSupported()||!s&&!c)throw new nD({code:iD.NOT_SUPPORTED,message:Jw({key:Pw})});try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&(yield this.schedule(o,n,oC)),console.log("scheduleResult",this.scheduleResult);let t=yield e.call(this,i,r,n);return this.roomId=o,this._joinedTimestamp=jb.performanceNow(),WP.emit(KP.JOIN_SUCCESS,{room:this}),t}catch(l){throw t.delete({room:this,roomId:o}),WP.emit(KP.JOIN_FAILED,{room:this,error:l}),l}}))}}))],Ux.prototype,"join",1),DA([Rx("joined","left",{ignoreError:!0}),pO((e=>function(){return MA(this,null,(function*(){WP.emit(KP.LEAVE_START,{room:this}),yield e.call(this),WP.emit(KP.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))})),function(e,t,i){let r=i.value;return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return mx.delete(this),r.apply(this,t)},i},qL({fnName:"publish",validateArgs:!1}),qL({fnName:"unsubscribe",validateArgs:!1})],Ux.prototype,"leave",1),DA([function(e,t,i){let r=i.value,n=e=>{let{fn:t,args:i,context:r,resolve:o,reject:a}=e;t.apply(r,i).then(o,a).finally((()=>{let e=mx.get(r);e&&(e.shift(),e[0]&&n(CA({},e[0])))}))};return i.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(mx.has(this)){let o=mx.get(this),{length:a}=o;o.push({fn:r,args:t,context:this,resolve:e,reject:i}),0===a&&n({fn:r,args:t,context:this,resolve:e,reject:i})}else mx.set(this,[{fn:r,args:t,context:this,resolve:e,reject:i}]),n({fn:r,args:t,context:this,resolve:e,reject:i})}))},i},KL({settings:{retries:hb,timeout:e=>lP(e)},onError(e,t,i){var r;null!=(r=e.message)&&r.includes("timeout")?(this._log.warn("publish timeout"),t()):(this._log.error("publish failed: ".concat(e)),i(e))}})],Ux.prototype,"publish",1),DA([qL({fnName:"publish",callback(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];null==(e=this.uplinkConnection)||e.close(),this.uplinkConnection=null,i.forEach((e=>e.setPublishStopped("api-call")))}})],Ux.prototype,"unpublish",1),DA([function(e){return function(t,i,r){let n=r.value,o=t=>mP(e)?t[e]:e(...t),a=e=>{let{fn:t,args:i,context:r,resolve:n,reject:s}=e;t.apply(r,i).then(n,s).finally((()=>{if(_x.has(r)&&_x.get(r).has(o(i))){let e=_x.get(r).get(o(i));e.shift(),e[0]&&a(CA({},e[0]))}}))};return r.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return new Promise(((e,i)=>{if(_x.has(this))if(_x.get(this).has(o(t))){let r=_x.get(this).get(o(t)),{length:s}=r;r.push({fn:n,args:t,context:this,resolve:e,reject:i}),0===s&&a({fn:n,args:t,context:this,resolve:e,reject:i})}else _x.get(this).set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),a({fn:n,args:t,context:this,resolve:e,reject:i});else{let r=new Map;r.set(o(t),[{fn:n,args:t,context:this,resolve:e,reject:i}]),_x.set(this,r),a({fn:n,args:t,context:this,resolve:e,reject:i})}}))},r}}((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId})),KL({settings:{retries:hb,timeout:e=>lP(e)},onError(e,t,i){e.message.includes("timeout")?(this._log.warn("subscribe timeout"),t()):(this._log.error("subscribe failed: ".concat(e)),i(e))}})],Ux.prototype,"subscribe",1),DA([qL({fnName:"subscribe",callback(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];t.forEach((e=>{var t;null==(t=this.remotePublishedUserMap.get(e.userId))||t.closePeerConnection()}))}})],Ux.prototype,"unsubscribe",1),FM.create=()=>FM._create(Ux),FM}));