@byteplus/rtc 4.54.9 → 4.54.11

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/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Copyright (c) 2020 The BytePlusRTC project authors. All Rights Reserved.
3
3
  * @brief BytePlusRTC Advance API
4
- * version: 4.54.9
4
+ * version: 4.54.11
5
5
  */
6
- !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).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,p=h.call,v=l&&h.bind.bind(p,p),_=l?v:function(e){return function(){return p.apply(e,arguments)}},f=_,m=f({}.toString),y=f("".slice),g=function(e){return y(m(e),8,-1)},S=g,b=_,E=function(e){if("Function"===S(e))return b(e)},T="object"==typeof document&&document.all,k={all:T,IS_HTMLDDA:void 0===T&&void 0!==T},I=k.all,R=k.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},C=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),w=o,x=Function.prototype.call,O=w?x.bind(x):function(){return x.apply(x,arguments)},D={},P={}.propertyIsEnumerable,M=Object.getOwnPropertyDescriptor,N=M&&!P.call({1:2},1);D.f=N?function(e){var t=M(this,e);return!!t&&t.enumerable}:P;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=g,j=Object,G=E("".split),H=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?G(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=H,Y=W,J=function(e){return q(Y(e))},Q=R,Z=k.all,$=k.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,pe=he&&he.v8;pe&&(U=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var ve=U,_e=ve,fe=i,me=!!Object.getOwnPropertySymbols&&!fe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&_e&&_e<41})),ye=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ge=oe,Se=R,be=ae,Ee=Object,Te=ye?function(e){return"symbol"==typeof e}:function(e){var t=ge("Symbol");return Se(t)&&be(t.prototype,Ee(e))},ke=String,Ie=function(e){try{return ke(e)}catch(t){return"Object"}},Re=R,Ae=Ie,Ce=TypeError,we=function(e){if(Re(e))return e;throw Ce(Ae(e)+" is not a function")},xe=we,Oe=z,De=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},Pe=O,Me=R,Ne=$,Le=TypeError,Ue={exports:{}},Ve=n,Fe=Object.defineProperty,Be=function(e,t){try{Fe(Ve,e,{value:t,configurable:!0,writable:!0})}catch(r){Ve[e]=t}return t},je="__core-js_shared__",Ge=n[je]||Be(je,{}),He=Ge;(Ue.exports=function(e,t){return He[e]||(He[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ye,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,pt=$,vt=Te,_t=De,ft=function(e,t){var r,n;if("string"===t&&Me(r=e.toString)&&!Ne(n=Pe(r,e)))return n;if(Me(r=e.valueOf)&&!Ne(n=Pe(r,e)))return n;if("string"!==t&&Me(r=e.toString)&&!Ne(n=Pe(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,yt=lt("toPrimitive"),gt=function(e,t){if(!pt(e)||vt(e))return e;var r,n=_t(e,yt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!pt(r)||vt(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ft(e,t)},St=Te,bt=function(e){var t=gt(e,"string");return St(t)?t:t+""},Et=$,Tt=n.document,kt=Et(Tt)&&Et(Tt.createElement),It=function(e){return kt?Tt.createElement(e):{}},Rt=It,At=!C&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),Ct=C,wt=O,xt=D,Ot=V,Dt=J,Pt=bt,Mt=Ye,Nt=At,Lt=Object.getOwnPropertyDescriptor;A.f=Ct?Lt:function(e,t){if(e=Dt(e),t=Pt(t),Nt)try{return Lt(e,t)}catch(r){}if(Mt(e,t))return Ot(!wt(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Gt[jt(e)];return r==zt||r!=Ht&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Gt=Bt.data={},Ht=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=we,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=C&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=C,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Jt,vr=V,_r=C?function(e,t,r){return pr.f(e,t,vr(1,r))}:function(e,t,r){return e[t]=r,e},fr=n,mr=d,yr=E,gr=R,Sr=A.f,br=Kt,Er=ee,Tr=Yt,kr=_r,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?fr:h?fr[d]:(fr[d]||{}).prototype,_=l?Er:Er[d]||kr(Er,d,{})[d],f=_.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ir(v,i),a=_[i],r&&(s=e.dontCallGetSet?(u=Sr(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?Tr(o,fr):e.wrap&&r?Rr(o):p&&gr(o)?yr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&kr(c,"sham",!0),kr(_,i,c),p&&(Ir(Er,n=d+"Prototype")||kr(Er,n,{}),kr(Er[n],i,o),e.real&&f&&!f[i]&&kr(f,i,o)))},Cr=Math.ceil,wr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?wr:Cr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Dr=Or,Pr=Math.max,Mr=Math.min,Nr=function(e,t){var r=Dr(e);return r<0?Pr(r+t,0):Mr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Gr=Nr,Hr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Hr(o),s=Gr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=g,hn=lt("toStringTag"),pn=Object,vn="Arguments"==ln(function(){return arguments}()),_n=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),hn))?r:vn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},fn=_n,mn=String,yn=function(e){if("Symbol"===fn(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},gn={},Sn=C,bn=Qt,En=Jt,Tn=tr,kn=J,In=rn;gn.f=Sn&&!bn?Object.defineProperties:function(e,t){Tn(e);for(var r,n=kn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),Cn=Ue.exports,wn=et,xn=Cn("keys"),On=function(e){return xn[e]||(xn[e]=wn(e))},Dn=tr,Pn=gn,Mn=$r,Nn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Gn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Gn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Mn.length;r--;)delete Gn.prototype[Mn[r]];return Gn()};Nn[Vn]=!0;var Hn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Dn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Gn(),void 0===t?r:Pn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=g,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=_r,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},pi=lt;hi.f=pi;var vi,_i,fi,mi=ee,yi=Ye,gi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});yi(t,e)||Si(t,e,{value:gi.f(e)})},Ei=O,Ti=oe,ki=lt,Ii=li,Ri=function(){var e=Ti("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=ki("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=_n,Ci=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},wi=cn,xi=Jt.f,Oi=_r,Di=Ye,Pi=Ci,Mi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Di(i,Mi)||xi(i,Mi,{configurable:!0,value:t}),n&&!wi&&Oi(i,"toString",Pi)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Gi=_r,Hi=Ye,zi=Ge,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,vi=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},_i=function(e){return Ji.get(e)||{}},fi=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,vi=function(e,t){if(Hi(e,Qi))throw qi(Wi);return t.facade=e,Gi(e,Qi,t),t},_i=function(e){return Hi(e,Qi)?e[Qi]:{}},fi=function(e){return Hi(e,Qi)}}var Zi={set:vi,get:_i,has:fi,enforce:function(e){return fi(e)?_i(e):vi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=_i(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=g,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=Ge,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=_n,uo=io,lo=function(){},ho=[],po=oe("Reflect","construct"),vo=/^\s*(?:class|function)\b/,_o=oo(vo.exec),fo=!vo.exec(lo),mo=function(e){if(!so(e))return!1;try{return po(lo,ho,e),!0}catch(t){return!1}},yo=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return fo||!!_o(vo,uo(e))}catch(t){return!0}};yo.sham=!0;var go=!po||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?yo:mo,So=eo,bo=go,Eo=$,To=lt("species"),ko=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===ko||So(t.prototype))||Eo(t)&&null===(t=t[To]))&&(t=void 0)),void 0===t?ko:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,Co=H,wo=Xe,xo=Br,Oo=Ro,Do=E([].push),Po=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=wo(c),_=Co(v),f=Ao(u,d),m=xo(_),y=0,g=l||Oo,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in _)&&(p=f(h=_[y],y,v),e))if(t)S[y]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Do(S,h)}else switch(e){case 4:return!1;case 7:Do(S,h)}return o?-1:n||i?i:S}},Mo={forEach:Po(0),map:Po(1),filter:Po(2),some:Po(3),every:Po(4),find:Po(5),findIndex:Po(6),filterReject:Po(7)},No=Ar,Lo=n,Uo=O,Vo=E,Fo=C,Bo=me,jo=i,Go=Ye,Ho=ae,zo=tr,Ko=J,Xo=bt,Wo=yn,qo=V,Yo=Hn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=gn,na=D,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Ni,pa=Zi,va=Mo.forEach,_a=On("hidden"),fa="Symbol",ma=pa.set,ya=pa.getterFor(fa),ga=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,Ta=Lo.QObject,ka=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,Ca=Vo([].push),wa=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Da=!Ta||!Ta.prototype||!Ta.prototype.findChild,Pa=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=ka(ga,t);n&&delete ga[t],Ia(e,t,r),n&&e!==ga&&Ia(ga,t,n)}:Ia,Ma=function(e,t){var r=wa[e]=Yo(ba);return ma(r,{type:fa,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ga&&Na(xa,t,r),zo(e);var n=Xo(t);return zo(r),Go(wa,n)?(r.enumerable?(Go(e,_a)&&e[_a][n]&&(e[_a][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Go(e,_a)||Ia(e,_a,qo(1,{})),e[_a][n]=!0),Pa(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return va(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ga&&Go(wa,t)&&!Go(xa,t))&&(!(r||!Go(this,t)||!Go(wa,t)||Go(this,_a)&&this[_a][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ga||!Go(wa,n)||Go(xa,n)){var i=ka(r,n);return!i||!Go(wa,n)||Go(r,_a)&&r[_a][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return va(t,(function(e){Go(wa,e)||Go(aa,e)||Ca(r,e)})),r},Ba=function(e){var t=e===ga,r=Ra(t?xa:Ko(e)),n=[];return va(r,(function(e){!Go(wa,e)||t&&!Go(ga,e)||Ca(n,wa[e])})),n};Bo||(Sa=function(){if(Ho(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ga&&Uo(r,xa,e),Go(this,_a)&&Go(this[_a],t)&&(this[_a][t]=!1),Pa(this,t,qo(1,e))};return Fo&&Da&&Pa(ga,t,{configurable:!0,set:r}),Ma(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ya(this).tag})),ia(Sa,"withoutSetter",(function(e){return Ma(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Ma(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ya(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),va(Jo(Oa),(function(e){da(e)})),No({target:fa,stat:!0,forced:!Bo},{useSetter:function(){Da=!0},useSimple:function(){Da=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(e),t)},defineProperty:Na,defineProperties:La,getOwnPropertyDescriptor:Va}),No({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,fa),aa[_a]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ga=Ar,Ha=oe,za=Ye,Ka=yn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ga({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ha("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=Te,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=Te,ps=rs,vs=me,_s=is("JSON","stringify"),fs=ss(/./.exec),ms=ss("".charAt),ys=ss("".charCodeAt),gs=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,Ts=/^[\uDC00-\uDFFF]$/,ks=!vs||cs((function(){var e=is("Symbol")();return"[null]"!=_s([e])||"{}"!=_s({a:e})||"{}"!=_s(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==_s("\udf06\ud834")||'"\\udead"'!==_s("\udead")})),Rs=function(e,t){var r=ps(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(_s,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return fs(Es,e)&&!fs(Ts,i)||fs(Ts,e)&&!fs(Es,n)?"\\u"+Ss(ys(e,0),16):e};_s&&ns({target:"JSON",stat:!0,arity:3,forced:ks||Is},{stringify:function(e,t,r){var n=ps(arguments),i=os(ks?Rs:_s,null,n);return Is&&"string"==typeof i?gs(i,bs,As):i}});var Cs=ui,ws=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){Cs.f(1)}))},{getOwnPropertySymbols:function(e){var t=Cs.f;return t?t(ws(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ds=ve,Ps=lt("species"),Ms=function(e){return Ds>=51||!Os((function(){var t=[];return(t.constructor={})[Ps]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Mo.filter;Ar({target:"Array",proto:!0,forced:!Ms("filter")},{filter:function(e){return Ns(this,e,arguments.length>1?arguments[1]:void 0)}});var Ls=ee,Us=function(e){return Ls[e+"Prototype"]},Vs=Us("Array").filter,Fs=ae,Bs=Vs,js=Array.prototype,Gs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Hs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=C,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Hs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Hs.exports,rc={},nc=C,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,pc=uc,vc=On("IE_PROTO"),_c=Object,fc=_c.prototype,mc=pc?_c.getPrototypeOf:function(e){var t=hc(e);if(dc(t,vc))return t[vc];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof _c?fc:null},yc=i,gc=R,Sc=$,bc=Hn,Ec=mc,Tc=li,kc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||yc((function(){var e={};return Zs[kc].call(e)!==e}));gc((Zs=Rc?{}:bc(Zs))[kc])||Tc(Zs,kc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},Cc=Ac.IteratorPrototype,wc=Hn,xc=V,Oc=Ni,Dc=rc,Pc=function(){return this},Mc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=wc(Cc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Dc[i]=Pc,e},Nc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Nc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Gc=Ar,Hc=O,zc=cc,Kc=Mc,Xc=mc,Wc=Ni,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&_)return _;if(!Zc&&e in p)return p[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[$c]||p["@@iterator"]||i&&p[i],_=!Zc&&v||d(i),f="Array"==t&&p.entries||v;if(f&&(s=Xc(f.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&v&&v.name!==tu&&(h=!0,_=function(){return Hc(v,this)}),i)if(c={values:d(tu),keys:o?_:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in p))&&qc(p,u,c[u]);else Gc({target:t,proto:!0,forced:Zc||h},c);return a&&p[$c]!==_&&qc(p,$c,_,{name:i}),Yc[t]=_,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",pu=uu.set,vu=uu.getterFor(hu);du(Array,"Array",(function(e,t){pu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=vu(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var _u={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},fu=n,mu=_n,yu=_r,gu=rc,Su=lt("toStringTag");for(var bu in _u){var Eu=fu[bu],Tu=Eu&&Eu.prototype;Tu&&mu(Tu)!==Su&&yu(Tu,Su,bu),gu[bu]=gu.Array}var ku=i,Iu=function(e,t){var r=[][e];return!!r&&ku((function(){r.call(null,t||function(){return 1},1)}))},Ru=Mo.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var Cu=Us("Array").forEach,wu=_n,xu=Ye,Ou=ae,Du=Cu,Pu=Array.prototype,Mu={DOMTokenList:!0,NodeList:!0},Nu=function(e){var t=e.forEach;return e===Pu||Ou(Pu,e)&&t===Pu.forEach||xu(Mu,wu(e))?Du:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Gu=ju,Hu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!C},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Hu(e),i=zu.f,o=Gu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=C,Ju=gn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=C,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,pd=Xe,vd=Br,_d=cd,fd=Qn,md=Ro,yd=Ms,gd=ve,Sd=lt("isConcatSpreadable"),bd=gd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=yd("concat"),Td=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=pd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(Td(o=-1===t?a:arguments[t]))for(i=vd(o),_d(c+i),r=0;r<i;r++,c++)r in o&&fd(s,c,o[r]);else _d(c+1),fd(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var kd=Ri;bi("toPrimitive"),kd();var Id=oe,Rd=Ni;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var Cd=Ad,wd=E,xd=Or,Od=yn,Dd=W,Pd=wd("".charAt),Md=wd("".charCodeAt),Nd=wd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Dd(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Md(o,a))<55296||n>56319||a+1===s||(i=Md(o,a+1))<56320||i>57343?e?Pd(o,a):n:e?Nd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=yn,Bd=Zi,jd=iu,Gd=ou,Hd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Hd);jd(String,"String",(function(e){zd(this,{type:Hd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Gd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Gd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof Cd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof Cd&&e.constructor===Cd&&e!==Cd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Gs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Nu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),pl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(pl||{}),vl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(vl||{}),_l=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(_l||{}),fl=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(fl||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),yl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yl||{}),gl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(gl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),Tl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(Tl||{}),kl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(kl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),Cl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(Cl||{}),wl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(wl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:pl,USER_ONLINE_STATUS:vl,PublicStreamType:_l,PublicInterpolationMode:fl,SubscribeFallbackOption:ml,RemoteUserPriority:yl,NetworkQuality:gl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:Tl,AAC_PROFILE:kl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:Cl,ForwardStreamError:wl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Dl=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Dl||{}),Pl=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Pl||{}),Ml=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Dl,AudioMixingState:Pl},Symbol.toStringTag,{value:"Module"})),Nl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Nl||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!C},{create:Hn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Gl=mc,Hl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Gl(1)})),sham:!Hl},{getPrototypeOf:function(e){return Gl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=_r,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=_n,ch=De,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},ph=O,vh=we,_h=tr,fh=Ie,mh=hh,yh=TypeError,gh=function(e,t){var r=arguments.length<2?mh(e):t;if(vh(r))return _h(ph(r,e));throw yh(fh(e)+" is not iterable")},Sh=O,bh=tr,Eh=De,Th=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},kh=Yt,Ih=O,Rh=tr,Ah=Ie,Ch=ah,wh=Br,xh=ae,Oh=gh,Dh=hh,Ph=Th,Mh=TypeError,Nh=function(e,t){this.stopped=e,this.result=t},Lh=Nh.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),_=kh(t,d),f=function(e){return n&&Ph(n,"normal",e),new Nh(!0,e)},m=function(e){return l?(Rh(e),v?_(e[0],e[1],f):_(e[0],e[1])):v?_(e,f):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Dh(e)))throw Mh(Ah(e)+" is not iterable");if(Ch(i)){for(o=0,a=wh(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Nh(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(y){Ph(n,"throw",y)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Nh(!1)},Vh=yn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Gh=ae,Hh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Hn,Wh=_r,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ep=lt("toStringTag"),tp=Error,rp=[].push,np=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Gh(ip,this);zh?r=zh(tp(),i?Hh(this):ip):(r=i?this:Xh(ip),Wh(r,ep,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rp,{that:o}),Wh(r,"errors",o),r};zh?zh(np,tp):Kh(np,tp,{name:!0});var ip=np.prototype=Xh(tp.prototype,{constructor:qh(1,np),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:np});var op,ap,sp,cp,up="process"==g(n.process),dp=oe,lp=Jt,hp=C,pp=lt("species"),vp=function(e){var t=dp(e),r=lp.f;hp&&t&&!t[pp]&&r(t,pp,{configurable:!0,get:function(){return this}})},_p=ae,fp=TypeError,mp=function(e,t){if(_p(t,e))return e;throw fp("Incorrect invocation")},yp=go,gp=Ie,Sp=TypeError,bp=function(e){if(yp(e))return e;throw Sp(gp(e)+" is not a constructor")},Ep=tr,Tp=bp,kp=z,Ip=lt("species"),Rp=function(e,t){var r,n=Ep(e).constructor;return void 0===n||kp(r=Ep(n)[Ip])?t:Tp(r)},Ap=TypeError,Cp=function(e,t){if(e<t)throw Ap("Not enough arguments");return e},wp=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xp=n,Op=d,Dp=Yt,Pp=R,Mp=Ye,Np=i,Lp=An,Up=rs,Vp=It,Fp=Cp,Bp=wp,jp=up,Gp=xp.setImmediate,Hp=xp.clearImmediate,zp=xp.process,Kp=xp.Dispatch,Xp=xp.Function,Wp=xp.MessageChannel,qp=xp.String,Yp=0,Jp={},Qp="onreadystatechange";try{op=xp.location}catch(FW){}var Zp=function(e){if(Mp(Jp,e)){var t=Jp[e];delete Jp[e],t()}},$p=function(e){return function(){Zp(e)}},ev=function(e){Zp(e.data)},tv=function(e){xp.postMessage(qp(e),op.protocol+"//"+op.host)};Gp&&Hp||(Gp=function(e){Fp(arguments.length,1);var t=Pp(e)?e:Xp(e),r=Up(arguments,1);return Jp[++Yp]=function(){Op(t,void 0,r)},ap(Yp),Yp},Hp=function(e){delete Jp[e]},jp?ap=function(e){zp.nextTick($p(e))}:Kp&&Kp.now?ap=function(e){Kp.now($p(e))}:Wp&&!Bp?(cp=(sp=new Wp).port2,sp.port1.onmessage=ev,ap=Dp(cp.postMessage,cp)):xp.addEventListener&&Pp(xp.postMessage)&&!xp.importScripts&&op&&"file:"!==op.protocol&&!Np(tv)?(ap=tv,xp.addEventListener("message",ev,!1)):ap=Qp in Vp("script")?function(e){Lp.appendChild(Vp("script")).onreadystatechange=function(){Lp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rv,nv,iv,ov,av,sv,cv,uv,dv={set:Gp,clear:Hp},lv=n,hv=/ipad|iphone|ipod/i.test(se)&&void 0!==lv.Pebble,pv=/web0s(?!.*chrome)/i.test(se),vv=n,_v=Yt,fv=A.f,mv=dv.set,yv=wp,gv=hv,Sv=pv,bv=up,Ev=vv.MutationObserver||vv.WebKitMutationObserver,Tv=vv.document,kv=vv.process,Iv=vv.Promise,Rv=fv(vv,"queueMicrotask"),Av=Rv&&Rv.value;Av||(rv=function(){var e,t;for(bv&&(e=kv.domain)&&e.exit();nv;){t=nv.fn,nv=nv.next;try{t()}catch(FW){throw nv?ov():iv=void 0,FW}}iv=void 0,e&&e.enter()},yv||bv||Sv||!Ev||!Tv?!gv&&Iv&&Iv.resolve?((cv=Iv.resolve(void 0)).constructor=Iv,uv=_v(cv.then,cv),ov=function(){uv(rv)}):bv?ov=function(){kv.nextTick(rv)}:(mv=_v(mv,vv),ov=function(){mv(rv)}):(av=!0,sv=Tv.createTextNode(""),new Ev(rv).observe(sv,{characterData:!0}),ov=function(){sv.data=av=!av}));var Cv=Av||function(e){var t={fn:e,next:void 0};iv&&(iv.next=t),nv||(nv=t,ov()),iv=t},wv=n,xv=function(e){try{return{error:!1,value:e()}}catch(FW){return{error:!0,value:FW}}},Ov=function(){this.head=null,this.tail=null};Ov.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Dv=Ov,Pv=n.Promise,Mv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Nv=!Mv&&!up&&"object"==typeof window&&"object"==typeof document,Lv=n,Uv=Pv,Vv=R,Fv=Kt,Bv=io,jv=lt,Gv=Nv,Hv=Mv,zv=ve,Kv=Uv&&Uv.prototype,Xv=jv("species"),Wv=!1,qv=Vv(Lv.PromiseRejectionEvent),Yv={CONSTRUCTOR:Fv("Promise",(function(){var e=Bv(Uv),t=e!==String(Uv);if(!t&&66===zv)return!0;if(!Kv.catch||!Kv.finally)return!0;if(!zv||zv<51||!/native code/.test(e)){var r=new Uv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Xv]=n,!(Wv=r.then((function(){}))instanceof n))return!0}return!t&&(Gv||Hv)&&!qv})),REJECTION_EVENT:qv,SUBCLASSING:Wv},Jv={},Qv=we,Zv=TypeError,$v=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Zv("Bad Promise constructor");t=e,r=n})),this.resolve=Qv(t),this.reject=Qv(r)};Jv.f=function(e){return new $v(e)};var e_,t_,r_=Ar,n_=up,i_=n,o_=O,a_=li,s_=Ni,c_=vp,u_=we,d_=R,l_=$,h_=mp,p_=Rp,v_=dv.set,__=Cv,f_=function(e,t){var r=wv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},m_=xv,y_=Dv,g_=Zi,S_=Pv,b_=Yv,E_=Jv,T_="Promise",k_=b_.CONSTRUCTOR,I_=b_.REJECTION_EVENT,R_=g_.getterFor(T_),A_=g_.set,C_=S_&&S_.prototype,w_=S_,x_=C_,O_=i_.TypeError,D_=i_.document,P_=i_.process,M_=E_.f,N_=M_,L_=!!(D_&&D_.createEvent&&i_.dispatchEvent),U_="unhandledrejection",V_=function(e){var t;return!(!l_(e)||!d_(t=e.then))&&t},F_=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&z_(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(O_("Promise-chain cycle")):(n=V_(r))?o_(n,r,c,u):c(r)):u(o)}catch(FW){d&&!i&&d.exit(),u(FW)}},B_=function(e,t){e.notified||(e.notified=!0,__((function(){for(var r,n=e.reactions;r=n.get();)F_(r,e);e.notified=!1,t&&!e.rejection&&G_(e)})))},j_=function(e,t,r){var n,i;L_?((n=D_.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),i_.dispatchEvent(n)):n={promise:t,reason:r},!I_&&(i=i_["on"+e])?i(n):e===U_&&f_("Unhandled promise rejection",r)},G_=function(e){o_(v_,i_,(function(){var t,r=e.facade,n=e.value;if(H_(e)&&(t=m_((function(){n_?P_.emit("unhandledRejection",n,r):j_(U_,r,n)})),e.rejection=n_||H_(e)?2:1,t.error))throw t.value}))},H_=function(e){return 1!==e.rejection&&!e.parent},z_=function(e){o_(v_,i_,(function(){var t=e.facade;n_?P_.emit("rejectionHandled",t):j_("rejectionhandled",t,e.value)}))},K_=function(e,t,r){return function(n){e(t,n,r)}},X_=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,B_(e,!0))},W_=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw O_("Promise can't be resolved itself");var n=V_(t);n?__((function(){var r={done:!1};try{o_(n,t,K_(W_,r,e),K_(X_,r,e))}catch(FW){X_(r,FW,e)}})):(e.value=t,e.state=1,B_(e,!1))}catch(FW){X_({done:!1},FW,e)}}};k_&&(x_=(w_=function(e){h_(this,x_),u_(e),o_(e_,this);var t=R_(this);try{e(K_(W_,t),K_(X_,t))}catch(FW){X_(t,FW)}}).prototype,(e_=function(e){A_(this,{type:T_,done:!1,notified:!1,parent:!1,reactions:new y_,rejection:!1,state:0,value:void 0})}).prototype=a_(x_,"then",(function(e,t){var r=R_(this),n=M_(p_(this,w_));return r.parent=!0,n.ok=!d_(e)||e,n.fail=d_(t)&&t,n.domain=n_?P_.domain:void 0,0==r.state?r.reactions.add(n):__((function(){F_(n,r)})),n.promise})),t_=function(){var e=new e_,t=R_(e);this.promise=e,this.resolve=K_(W_,t),this.reject=K_(X_,t)},E_.f=M_=function(e){return e===w_||undefined===e?new t_(e):N_(e)}),r_({global:!0,constructor:!0,wrap:!0,forced:k_},{Promise:w_}),s_(w_,T_,!1,!0),c_(T_);var q_=lt("iterator"),Y_=!1;try{var J_=0,Q_={next:function(){return{done:!!J_++}},return:function(){Y_=!0}};Q_[q_]=function(){return this},Array.from(Q_,(function(){throw 2}))}catch(FW){}var Z_=function(e,t){if(!t&&!Y_)return!1;var r=!1;try{var n={};n[q_]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(FW){}return r},$_=Pv,ef=Yv.CONSTRUCTOR||!Z_((function(e){$_.all(e).then(void 0,(function(){}))})),tf=O,rf=we,nf=Jv,of=xv,af=Uh;Ar({target:"Promise",stat:!0,forced:ef},{all:function(e){var t=this,r=nf.f(t),n=r.resolve,i=r.reject,o=of((function(){var r=rf(t.resolve),o=[],a=0,s=1;af(e,(function(e){var c=a++,u=!1;s++,tf(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var sf=Ar,cf=Yv.CONSTRUCTOR;Pv&&Pv.prototype,sf({target:"Promise",proto:!0,forced:cf,real:!0},{catch:function(e){return this.then(void 0,e)}});var uf=O,df=we,lf=Jv,hf=xv,pf=Uh;Ar({target:"Promise",stat:!0,forced:ef},{race:function(e){var t=this,r=lf.f(t),n=r.reject,i=hf((function(){var i=df(t.resolve);pf(e,(function(e){uf(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var vf=O,_f=Jv;Ar({target:"Promise",stat:!0,forced:Yv.CONSTRUCTOR},{reject:function(e){var t=_f.f(this);return vf(t.reject,void 0,e),t.promise}});var ff=tr,mf=$,yf=Jv,gf=function(e,t){if(ff(e),mf(t)&&t.constructor===e)return t;var r=yf.f(e);return(0,r.resolve)(t),r.promise},Sf=Ar,bf=Pv,Ef=Yv.CONSTRUCTOR,Tf=gf,kf=oe("Promise"),If=!Ef;Sf({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Tf(If&&this===kf?bf:this,e)}});var Rf=O,Af=we,Cf=Jv,wf=xv,xf=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=Cf.f(t),n=r.resolve,i=r.reject,o=wf((function(){var r=Af(t.resolve),i=[],o=0,a=1;xf(e,(function(e){var s=o++,c=!1;a++,Rf(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var Of=O,Df=we,Pf=oe,Mf=Jv,Nf=xv,Lf=Uh,Uf="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=Pf("AggregateError"),n=Mf.f(t),i=n.resolve,o=n.reject,a=Nf((function(){var n=Df(t.resolve),a=[],s=0,c=1,u=!1;Lf(e,(function(e){var d=s++,l=!1;c++,Of(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,Uf)))}))})),--c||o(new r(a,Uf))}));return a.error&&o(a.value),n.promise}});var Vf=Ar,Ff=Pv,Bf=i,jf=oe,Gf=R,Hf=Rp,zf=gf,Kf=Ff&&Ff.prototype;Vf({target:"Promise",proto:!0,real:!0,forced:!!Ff&&Bf((function(){Kf.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hf(this,jf("Promise")),r=Gf(e);return this.then(r?function(r){return zf(t,e()).then((function(){return r}))}:e,r?function(r){return zf(t,e()).then((function(){throw r}))}:e)}});var Xf=ee.Promise,Wf=Jv,qf=xv;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Wf.f(this),r=qf(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Yf=Xf,Jf=Ar,Qf=eo,Zf=E([].reverse),$f=[1,2];Jf({target:"Array",proto:!0,forced:String($f)===String($f.reverse())},{reverse:function(){return Qf(this)&&(this.length=this.length),Zf(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=go,cm=$,um=Nr,dm=Br,lm=J,hm=Qn,pm=lt,vm=rs,_m=Ms("slice"),fm=pm("species"),mm=Array,ym=Math.max;om({target:"Array",proto:!0,forced:!_m},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[fm]))&&(r=void 0),r===mm||void 0===r))return vm(o,s,c);for(n=new(void 0===r?mm:r)(ym(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var gm=Us("Array").slice,Sm=ae,bm=gm,Em=Array.prototype,Tm=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function km(){km=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof Cd?Cd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new k(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var _={};c(_,o,(function(){return this}));var f=zl&&zl(zl(I([])));f&&f!==t&&r.call(f,o)&&(_=f);var m=v.prototype=h.prototype=Bl(_);function y(e){var t;Nu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],Nu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Yf);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,k.prototype={constructor:k,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Nu(t=this.tryEntries).call(t,T),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+Tm(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(FW){return void r(FW)}s.done?t(c):Yf.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Yf((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,Cm=ae,wm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||Cm(xm,e)&&t===xm.concat?wm:t},Dm=ee,Pm=d;Dm.JSON||(Dm.JSON={stringify:JSON.stringify});var Mm=function(e,t,r){return Pm(Dm.JSON.stringify,null,arguments)},Nm=Mm,Lm=Mo.map;Ar({target:"Array",proto:!0,forced:!Ms("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Gm="\t\n\v\f\r                 \u2028\u2029\ufeff",Hm=W,zm=yn,Km=E("".replace),Xm="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Hm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,ey=yn,ty=Jm.trim,ry=Gm,ny=Qm.parseInt,iy=Qm.Symbol,oy=iy&&iy.iterator,ay=/^[+-]?0x/i,sy=$m(ay.exec),cy=8!==ny(ry+"08")||22!==ny(ry+"0x16")||oy&&!Zm((function(){ny(Object(oy))}))?function(e,t){var r=ty(ey(e));return ny(r,t>>>0||(sy(ay,r)?16:10))}:ny;Ar({global:!0,forced:parseInt!=cy},{parseInt:cy});var uy=ee.parseInt,dy={exports:{}},ly=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hy=i,py=$,vy=g,_y=ly,fy=Object.isExtensible,my=hy((function(){fy(1)}))||_y?function(e){return!!py(e)&&((!_y||"ArrayBuffer"!=vy(e))&&(!fy||fy(e)))}:fy,yy=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),gy=Ar,Sy=E,by=Xr,Ey=$,Ty=Ye,ky=Jt.f,Iy=zn,Ry=Wn,Ay=my,Cy=yy,wy=!1,xy=et("meta"),Oy=0,Dy=function(e){ky(e,xy,{value:{objectID:"O"+Oy++,weakData:{}}})},Py=dy.exports={enable:function(){Py.enable=function(){},wy=!0;var e=Iy.f,t=Sy([].splice),r={};r[xy]=1,e(r).length&&(Iy.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xy){t(n,i,1);break}return n},gy({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ry.f}))},fastKey:function(e,t){if(!Ey(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!Ty(e,xy)){if(!Ay(e))return"F";if(!t)return"E";Dy(e)}return e[xy].objectID},getWeakData:function(e,t){if(!Ty(e,xy)){if(!Ay(e))return!0;if(!t)return!1;Dy(e)}return e[xy].weakData},onFreeze:function(e){return Cy&&wy&&Ay(e)&&!Ty(e,xy)&&Dy(e),e}};by[xy]=!0;var My=Ar,Ny=n,Ly=dy.exports,Uy=i,Vy=_r,Fy=Uh,By=mp,jy=R,Gy=$,Hy=Ni,zy=Jt.f,Ky=Mo.forEach,Xy=C,Wy=Zi.set,qy=Zi.getterFor,Yy=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Ny[e],c=s&&s.prototype,u={};if(Xy&&jy(s)&&(o||c.forEach&&!Uy((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wy(By(t,d),{type:e,collection:new s}),null!=r&&Fy(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qy(e);Ky(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vy(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Gy(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zy(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Ly.enable();return Hy(n,e,!1,!0),u[e]=n,My({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jy=li,Qy=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jy(e,n,t[n],r);return e},Zy=Jt.f,$y=Hn,eg=Qy,tg=Yt,rg=mp,ng=z,ig=Uh,og=iu,ag=ou,sg=vp,cg=C,ug=dy.exports.fastKey,dg=Zi.set,lg=Zi.getterFor,hg={getConstructor:function(e,t,r,n){var i=e((function(e,i){rg(e,o),dg(e,{type:t,index:$y(null),first:void 0,last:void 0,size:0}),cg||(e.size=0),ng(i)||ig(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=lg(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=ug(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=ug(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return eg(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=tg(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),eg(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cg&&Zy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=lg(t),o=lg(n);og(e,t,(function(e,t){dg(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ag("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ag(void 0,!0))}),r?"entries":"values",!r,!0),sg(t)}};Yy("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var pg=ee.Map,vg=Yt,_g=O,fg=we,mg=bp,yg=z,gg=Uh,Sg=[].push,bg=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return mg(this),(t=void 0!==a)&&fg(a),yg(e)?new this:(r=[],t?(n=0,i=vg(a,o>2?arguments[2]:void 0),gg(e,(function(e){_g(Sg,r,i(e,n++))}))):gg(e,Sg,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:bg});var Eg=rs,Tg=function(){return new this(Eg(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:Tg});var kg=O,Ig=we,Rg=tr,Ag=function(){for(var e,t=Rg(this),r=Ig(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=kg(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var Cg=O,wg=we,xg=tr,Og=function(e,t){var r,n,i=xg(this),o=wg(i.get),a=wg(i.has),s=wg(i.set);return Cg(a,i,e)?(r=Cg(o,i,e),"update"in t&&(r=t.update(r,e,i),Cg(s,i,e,r)),r):(n=t.insert(e,i),Cg(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Og});var Dg=gh,Pg=tr,Mg=Yt,Ng=Dg,Lg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Pg(this),r=Ng(t),n=Mg(e,arguments.length>1?arguments[1]:void 0);return!Lg(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Ug=oe,Vg=Yt,Fg=O,Bg=we,jg=tr,Gg=Rp,Hg=Dg,zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jg(this),r=Hg(t),n=Vg(e,arguments.length>1?arguments[1]:void 0),i=new(Gg(t,Ug("Map"))),o=Bg(i.set);return zg(r,(function(e,r){n(r,e,t)&&Fg(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Kg=tr,Xg=Yt,Wg=Dg,qg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Kg(this),r=Wg(t),n=Xg(e,arguments.length>1?arguments[1]:void 0);return qg(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yg=tr,Jg=Yt,Qg=Dg,Zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yg(this),r=Qg(t),n=Jg(e,arguments.length>1?arguments[1]:void 0);return Zg(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $g=Ar,eS=O,tS=we,rS=gh,nS=Uh,iS=E([].push);$g({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Dg,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=we;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,pS=Dg,vS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return vS(pS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var _S=oe,fS=Yt,mS=O,yS=we,gS=tr,SS=Rp,bS=Dg,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=gS(this),r=bS(t),n=fS(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,_S("Map"))),o=yS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var TS=oe,kS=Yt,IS=O,RS=we,AS=tr,CS=Rp,wS=Dg,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=wS(t),n=kS(e,arguments.length>1?arguments[1]:void 0),i=new(CS(t,TS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=we,DS=tr,PS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=DS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)PS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var MS=tr,NS=we,LS=Dg,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=MS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(NS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Dg,GS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return GS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var HS=O,zS=tr,KS=we,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=HS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?HS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return HS(o,r,e,t(c,e,r)),r}});var WS=O,qS=we,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=pg,eb=we,tb=Xe,rb=H,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=ve,cb=up;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,pb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},vb=C,_b=E,fb=O,mb=i,yb=rn,gb=ui,Sb=D,bb=Xe,Eb=H,Tb=Object.assign,kb=Object.defineProperty,Ib=_b([].concat),Rb=!Tb||mb((function(){if(vb&&1!==Tb({b:1},Tb(kb({},"a",{enumerable:!0,get:function(){kb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=Tb({},e)[r]||yb(Tb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=gb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(yb(c),o(c)):yb(c),d=u.length,l=0;d>l;)s=u[l++],vb&&!fb(a,c,s)||(r[s]=c[s]);return r}:Tb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var Cb=ee.Object.assign,wb=$,xb=g,Ob=lt("match"),Db=function(e){var t;return wb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Pb=TypeError,Mb=function(e){if(Db(e))throw Pb("The method doesn't accept regular expressions");return e},Nb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Nb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=yn,jb=Mb,Gb=W,Hb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Hb("endsWith")},{endsWith:function(e){var t=Bb(Gb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&uy(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"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})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?pb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:Cb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Mo.find,pE="find",vE=!0;pE in[]&&Array(1).find((function(){vE=!1})),lE({target:"Array",proto:!0,forced:vE},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var _E=Us("Array").find,fE=ae,mE=_E,yE=Array.prototype,gE=function(e){var t=e.find;return e===yE||fE(yE,e)&&t===yE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,TE=E([].indexOf),kE=!!TE&&1/TE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:kE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return kE?TE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,CE=RE,wE=Array.prototype,xE=function(e){var t=e.indexOf;return e===wE||AE(wE,e)&&t===wE.indexOf?CE:t},OE=C,DE=eo,PE=TypeError,ME=Object.getOwnPropertyDescriptor,NE=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(FW){return FW instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Nr,GE=Or,HE=Br,zE=NE?function(e,t){if(DE(e)&&!ME(e,"length").writable)throw PE("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ms("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=HE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(GE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,eT=ZE,tT=Array.prototype,rT=function(e){var t=e.splice;return e===tT||$E(tT,e)&&t===tT.splice?eT:t},nT=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nT(this,e,arguments.length>1?arguments[1]:void 0)}});var iT=Us("Array").includes,oT=Ar,aT=Mb,sT=W,cT=yn,uT=Lb,dT=E("".indexOf);oT({target:"String",proto:!0,forced:!uT("includes")},{includes:function(e){return!!~dT(cT(sT(this)),cT(aT(e)),arguments.length>1?arguments[1]:void 0)}});var lT=Us("String").includes,hT=ae,pT=iT,vT=lT,_T=Array.prototype,fT=String.prototype,mT=function(e){var t=e.includes;return e===_T||hT(_T,e)&&t===_T.includes?pT:"string"==typeof e||e===fT||hT(fT,e)&&t===fT.includes?vT:t},yT=iE;function gT(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+Tm(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Nm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Nm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Gs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=gE(t).call(t,(function(e){return s.some((function(t){var r;return mT(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mT(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),yT("chrome: "+Nm(e)),i(e)}));e.video=n(e.video)}return yT("chrome: "+Nm(e)),i(e)},o=function(e){return t.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(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(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 Yf.reject(o(e))}))}))}}}}function ST(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function ET(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=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(){var e;return this._senders=this._senders||[],Tm(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rT(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=gE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rT(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(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}})}}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=Tm(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Yf((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function kT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});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 dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(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 dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Yf.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Yf.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function IT(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(gE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Gs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rT(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function RT(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return IT(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(gE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=Tm([]).call(arguments,1);if(1!==s.length||!gE(n=s[0].getTracks()).call(n,(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 c=gE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Yf.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return gE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=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||{},an(this._streams).forEach((function(n){var i;gE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function AT(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function CT(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var wT=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:ST,shimOnTrack:bT,shimGetSendersWithDtmf:ET,shimGetStats:TT,shimSenderReceiverGetStats:kT,shimAddTrackRemoveTrackWithNative:IT,shimAddTrackRemoveTrack:RT,shimPeerConnection:AT,fixNegotiationNeeded:CT,shimGetUserMedia:gT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xT=ee.Array.isArray;function OT(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var DT=hh,PT=tr,MT=Th,NT=Yt,LT=O,UT=Xe,VT=function(e,t,r,n){try{return n?t(PT(r)[0],r[1]):t(r)}catch(FW){MT(e,"throw",FW)}},FT=ah,BT=go,jT=Br,GT=Qn,HT=gh,zT=hh,KT=Array,XT=function(e){var t=UT(e),r=BT(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=NT(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zT(t),p=0;if(!h||this===KT&&FT(h))for(a=jT(t),s=r?new this(a):KT(a);a>p;p++)l=o?i(t[p],p):t[p],GT(s,p,l);else for(d=(u=HT(t,h)).next,s=r?new this:[];!(c=LT(d,u)).done;p++)l=o?VT(u,i,[c.value,p],!0):c.value,GT(s,p,l);return s.length=p,s},WT=XT;Ar({target:"Array",stat:!0,forced:!Z_((function(e){Array.from(e)}))},{from:WT});var qT=ee.Array.from;function YT(e,t){var r;if(e){if("string"==typeof e)return OT(e,t);var n=Tm(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qT(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?OT(e,t):void 0}}function JT(e){return function(e){if(xT(e))return OT(e)}(e)||function(e){if(void 0!==Cd&&null!=DT(e)||null!=e["@@iterator"])return qT(e)}(e)||YT(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var QT=n,ZT=i,$T=yn,ek=Jm.trim,tk=E("".charAt),rk=QT.parseFloat,nk=QT.Symbol,ik=nk&&nk.iterator,ok=1/rk("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||ik&&!ZT((function(){rk(Object(ik))}))?function(e){var t=ek($T(e)),r=rk(t);return 0===r&&"-"==tk(t,0)?-0:r}:rk;Ar({global:!0,forced:parseFloat!=ok},{parseFloat:ok});var ak=ee.parseFloat;function sk(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Nm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Nm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function ck(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uk(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[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=Tm(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,Cb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});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):Yf.resolve(new $S)}}}function lk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hk(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mT(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function pk(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function vk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=JT(e)).length>0;r&&e.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&&!(ak(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(ak(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function _k(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function fk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var yk=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:ck,shimPeerConnection:uk,shimSenderGetStats:dk,shimReceiverGetStats:lk,shimRemoveStream:hk,shimRTCDataChannel:pk,shimAddTransceiver:vk,shimGetParameters:_k,shimCreateOffer:fk,shimCreateAnswer:mk,shimGetUserMedia:sk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Yf.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function gk(e){if("object"===Wd(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 t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mT(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mT(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rT(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mT(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function Sk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(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){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mT(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=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){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Yf.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Yf.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.addIceCandidate=s}}function Ek(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(Tk(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Tk(e){return e&&void 0!==e.video?Cb({},e,{video:cE(e.video)}):e}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Nm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function Ik(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function Rk(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=gE(r=this.getTransceivers()).call(r,(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",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=gE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function Ak(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Ck=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:gk,shimRemoteStreamsAPI:Sk,shimCallbacksAPI:bk,shimGetUserMedia:Ek,shimConstraints:Tk,shimRTCIceServerUrls:kk,shimTrackEventTransceiver:Ik,shimCreateOfferLegacy:Rk,shimAudioContext:Ak},Symbol.toStringTag,{value:"Module"})),wk=cc.PROPER,xk=i,Ok=Gm,Dk=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xk((function(){return!!Ok[e]()||"​…᠎"!=="​…᠎"[e]()||wk&&Ok[e].name!==e}))}("trim")},{trim:function(){return Dk(this)}});var Pk,Mk,Nk=Us("String").trim,Lk=ae,Uk=Nk,Vk=String.prototype,Fk=function(e){var t=e.trim;return"string"==typeof e||e===Vk||Lk(Vk,e)&&t===Vk.trim?Uk:t},Bk={exports:{}};Pk=Bk,(Mk={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=Mk.generateIdentifier(),Mk.splitLines=function(e){var t;return jm(t=Fk(e).call(e).split("\n")).call(t,(function(e){return Fk(e).call(e)}))},Mk.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return Fk(r=t>0?"m="+e:e).call(r)+"\r\n"}))},Mk.getDescription=function(e){var t=Mk.splitSections(e);return t&&t[0]},Mk.getMediaSections=function(e){var t=Mk.splitSections(e);return t.shift(),t},Mk.matchPrefix=function(e,t){var r;return Gs(r=Mk.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},Mk.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:uy(t[3],10),ip:t[4],address:t[4],port:uy(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=uy(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},Mk.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&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(" ")},Mk.parseIceOptions=function(e){return e.substr(14).split(" ")},Mk.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:uy(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=uy(t[1],10),r.channels=3===t.length?uy(t[2],10):1,r.numChannels=r.channels,r},Mk.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},Mk.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:uy(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},Mk.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},Mk.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=Fk(o=n[i]).call(o).split("="),r[Fk(a=t[0]).call(a)]=t[1]}return r},Mk.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&an(e.parameters).length){var n=[];an(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},Mk.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},Mk.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},Mk.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:uy(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},Mk.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return uy(e,10)}))}},Mk.getMid=function(e){var t=Mk.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},Mk.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},Mk.getDtlsParameters=function(e,t){var r=Mk.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,Mk.parseFingerprint)}},Mk.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},Mk.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:uy(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:Tm(t).call(t,3)}},Mk.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?Mk.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},Mk.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"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}},Mk.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},Mk.getCryptoParameters=function(e,t){var r=Mk.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,Mk.parseCryptoLine)},Mk.getIceParameters=function(e,t){var r=Mk.matchPrefix(e+t,"a=ice-ufrag:")[0],n=Mk.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},Mk.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},Mk.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=Mk.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=Mk.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=Mk.parseRtpMap(o),c=Mk.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?Mk.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=Mk.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,Mk.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return Mk.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(Mk.parseExtmap(e))})),t},Mk.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=Mk.writeRtpMap(e),n+=Mk.writeFmtp(e),n+=Mk.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){n+=Mk.writeExtmap(e)})),n},Mk.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=Mk.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Gs(n=jm(i=Mk.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return Mk.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=jm(o=Mk.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return uy(e,10)}))}));p.length>0&&p[0].length>1&&p[0][0]===h&&(a=p[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:uy(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Nm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,_,f=Mk.matchPrefix(e,"b=");return f.length&&(f=0===xE(v=f[0]).call(v,"b=TIAS:")?uy(f[0].substr(7),10):0===xE(_=f[0]).call(_,"b=AS:")?1e3*uy(f[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=f}))),s},Mk.parseRtcpParameters=function(e){var t,r,n={},i=Gs(t=jm(r=Mk.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return Mk.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=Mk.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=Mk.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},Mk.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},Mk.parseMsid=function(e){var t,r,n,i=Mk.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Gs(t=jm(r=Mk.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return Mk.parseSsrcMedia(e)}))).call(t,(function(e){return"msid"===e.attribute}));return o.length>0?{stream:(n=o[0].value.split(" "))[0],track:n[1]}:void 0},Mk.parseSctpDescription=function(e){var t,r=Mk.parseMLine(e),n=Mk.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=uy(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=Mk.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:uy(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=Mk.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:uy(a[0],10),protocol:a[1],maxMessageSize:t}}},Mk.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},Mk.generateSessionId=function(){return Math.random().toString().substr(2,21)},Mk.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||Mk.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},Mk.getDirection=function(e,t){for(var r=Mk.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?Mk.getDirection(t):"sendrecv"},Mk.getKind=function(e){return Mk.splitLines(e)[0].split(" ")[0].substr(2)},Mk.isRejected=function(e){return"0"===e.split(" ",2)[1]},Mk.parseMLine=function(e){var t=Mk.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:uy(t[1],10),protocol:t[2],fmt:Tm(t).call(t,3).join(" ")}},Mk.parseOLine=function(e){var t=Mk.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:uy(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},Mk.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=Mk.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},Pk.exports=Mk;var jk=Bk.exports,Gk=e({__proto__:null,default:jk},[Bk.exports]);function Hk(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Nm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jk.parseCandidate(e.candidate),o=Cb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zk(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jk.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function Kk(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jk.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jk.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=uy(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jk.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=uy(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function Xk(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function Wk(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(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 r=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 r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qk(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Gs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==Fk(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function Yk(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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?Yf.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Yf.resolve())})}}function Jk(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var Qk=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:Hk,shimRTCIceCandidateRelayProtocol:zk,shimMaxMessageSize:Kk,shimSendThrowTypeError:Xk,shimConnectionState:Wk,removeExtmapAllowMixed:qk,shimAddIceCandidateNullOrEmpty:Yk,shimParameterlessSetLocalDescription:Jk},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:Qk,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:Gk};switch(i.browser){case"chrome":if(!wT||!AT||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=wT,Yk(t,i),Jk(t),gT(t,i),ST(t),AT(t,i),bT(t),RT(t,i),ET(t),TT(t),kT(t),CT(t,i),Hk(t),zk(t),Wk(t),Kk(t,i),Xk(t),qk(t,i);break;case"firefox":if(!yk||!uk||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=yk,Yk(t,i),Jk(t),sk(t,i),uk(t,i),ck(t),hk(t),dk(t),lk(t),pk(t),vk(t),_k(t),fk(t),mk(t),Hk(t),Wk(t),Kk(t,i),Xk(t);break;case"safari":if(!Ck||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=Ck,Yk(t,i),Jk(t),kk(t),Rk(t),bk(t),gk(t),Sk(t),Ik(t),Ek(t),Ak(t),Hk(t),zk(t),Kk(t,i),Xk(t),qk(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var Zk=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=Zk.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $k(e,t){var r=void 0!==Cd&&DT(e)||e["@@iterator"];if(!r){if(xT(e)||(r=YT(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xT(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==Cd&&DT(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||YT(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=we,pI=$,vI=Ye,_I=rs,fI=o,mI=Function,yI=lI([].concat),gI=lI([].join),SI={},bI=function(e,t,r){if(!vI(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+gI(n,",")+")")}return SI[t](e,r)},EI=fI?mI.bind:function(e){var t=hI(this),r=t.prototype,n=_I(arguments,1),i=function(){var r=yI(n,_I(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return pI(r)&&(i.prototype=r),i},TI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==TI},{bind:TI});var kI=Us("Function").bind,II=ae,RI=kI,AI=Function.prototype,CI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function wI(e){var t;return(wI=Kl?CI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=wI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=CI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function DI(e,t){var r;return(DI=Kl?CI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function PI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&DI(e,t)}var MI=Ar,NI=d,LI=EI,UI=bp,VI=tr,FI=$,BI=Hn,jI=i,GI=oe("Reflect","construct"),HI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(GI((function(){}),[],e)instanceof e)})),XI=!jI((function(){GI((function(){}))})),WI=KI||XI;MI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return GI(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return NI(zI,n,t),new(NI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:HI),a=NI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function JI(e){var t=function(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=wI(e);if(t){var i=wI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return YI(this,r)}}var QI=Us("Array").values,ZI=_n,$I=Ye,eR=ae,tR=QI,rR=Array.prototype,nR={DOMTokenList:!0,NodeList:!0},iR=function(e){var t=e.values;return e===rR||eR(rR,e)&&t===rR.values||$I(nR,ZI(e))?tR:t},oR=ni,aR=Math.floor,sR=function(e,t){var r=e.length,n=aR(r/2);return r<8?cR(e,t):uR(e,sR(oR(e,0,n),t),sR(oR(e,n),t),t)},cR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},uR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},dR=sR,lR=se.match(/firefox\/(\d+)/i),hR=!!lR&&+lR[1],pR=/MSIE|Trident/.test(se),vR=se.match(/AppleWebKit\/(\d+)\./),_R=!!vR&&+vR[1],fR=Ar,mR=E,yR=we,gR=Xe,SR=Br,bR=VE,ER=yn,TR=i,kR=dR,IR=Iu,RR=hR,AR=pR,CR=ve,wR=_R,xR=[],OR=mR(xR.sort),DR=mR(xR.push),PR=TR((function(){xR.sort(void 0)})),MR=TR((function(){xR.sort(null)})),NR=IR("sort"),LR=!TR((function(){if(CR)return CR<70;if(!(RR&&RR>3)){if(AR)return!0;if(wR)return wR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)xR.push({k:t+n,v:r})}for(xR.sort((function(e,t){return t.v-e.v})),n=0;n<xR.length;n++)t=xR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));fR({target:"Array",proto:!0,forced:PR||!MR||!NR||!LR},{sort:function(e){void 0!==e&&yR(e);var t=gR(this);if(LR)return void 0===e?OR(t):OR(t,e);var r,n,i=[],o=SR(t);for(n=0;n<o;n++)n in t&&DR(i,t[n]);for(kR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:ER(t)>ER(r)?1:-1}}(e)),r=SR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)bR(t,n++);return t}});var UR=Us("Array").sort,VR=ae,FR=UR,BR=Array.prototype,jR=function(e){var t=e.sort;return e===BR||VR(BR,e)&&t===BR.sort?FR:t},GR=Ar,HR=Mo.findIndex,zR="findIndex",KR=!0;zR in[]&&Array(1).findIndex((function(){KR=!1})),GR({target:"Array",proto:!0,forced:KR},{findIndex:function(e){return HR(this,e,arguments.length>1?arguments[1]:void 0)}});var XR=Us("Array").findIndex,WR=ae,qR=XR,YR=Array.prototype,JR=function(e){var t=e.findIndex;return e===YR||WR(YR,e)&&t===YR.findIndex?qR:t},QR=Ar,ZR=E;A.f;var $R=Vr,eA=yn,tA=Mb,rA=W,nA=Lb,iA=ZR("".startsWith),oA=ZR("".slice),aA=Math.min;QR({target:"String",proto:!0,forced:!nA("startsWith")},{startsWith:function(e){var t=eA(rA(this));tA(e);var r=$R(aA(arguments.length>1?arguments[1]:void 0,t.length)),n=eA(e);return iA?iA(t,n,r):oA(t,r,r+n.length)===n}});var sA=Us("String").startsWith,cA=ae,uA=sA,dA=String.prototype,lA=function(e){var t=e.startsWith;return"string"==typeof e||e===dA||cA(dA,e)&&t===dA.startsWith?uA:t},hA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(hA||{}),pA=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(pA||{}),vA=Ul((function e(t,r,n){Vl(this,e),Jd(this,"code",void 0),Jd(this,"message",void 0),Jd(this,"error",void 0),this.code=t,this.message=r,this.error=n})),_A=C,fA=E,mA=rn,yA=J,gA=fA(D.f),SA=fA([].push),bA=function(e){return function(t){for(var r,n=yA(t),i=mA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],_A&&!gA(n,r)||SA(s,e?[r,n[r]]:n[r]);return s}},EA={entries:bA(!0),values:bA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return EA(e)}});var TA=ee.Object.entries,kA=Or,IA=yn,RA=W,AA=RangeError,CA=E,wA=Vr,xA=yn,OA=function(e){var t=IA(RA(this)),r="",n=kA(e);if(n<0||n==1/0)throw AA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},DA=W,PA=CA(OA),MA=CA("".slice),NA=Math.ceil,LA=function(e){return function(t,r,n){var i,o,a=xA(DA(t)),s=wA(r),c=a.length,u=void 0===n?" ":xA(n);return s<=c||""==u?a:((o=PA(u,NA((i=s-c)/u.length))).length>i&&(o=MA(o,0,i)),e?a+o:o+a)}},UA={start:LA(!1),end:LA(!0)},VA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),FA=UA.end;Ar({target:"String",proto:!0,forced:VA},{padEnd:function(e){return FA(this,e,arguments.length>1?arguments[1]:void 0)}});var BA=Us("String").padEnd,jA=ae,GA=BA,HA=String.prototype,zA=function(e){var t=e.padEnd;return"string"==typeof e||e===HA||jA(HA,e)&&t===HA.padEnd?GA:t},KA=cy;Ar({target:"Number",stat:!0,forced:Number.parseInt!=KA},{parseInt:KA});var XA=ee.Number.parseInt,WA=Math.log,qA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return WA(e)*qA}});var YA,JA=ee.Math.log10,QA=new Uint8Array(16);function ZA(){if(!YA&&!(YA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return YA(QA)}var $A=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function eC(e){return"string"==typeof e&&$A.test(e)}for(var tC=[],rC=0;rC<256;++rC)tC.push((rC+256).toString(16).substr(1));function nC(e,t,r){var n=(e=e||{}).random||(e.rng||ZA)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(tC[e[t+0]]+tC[e[t+1]]+tC[e[t+2]]+tC[e[t+3]]+"-"+tC[e[t+4]]+tC[e[t+5]]+"-"+tC[e[t+6]]+tC[e[t+7]]+"-"+tC[e[t+8]]+tC[e[t+9]]+"-"+tC[e[t+10]]+tC[e[t+11]]+tC[e[t+12]]+tC[e[t+13]]+tC[e[t+14]]+tC[e[t+15]]).toLowerCase();if(!eC(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var iC=function(){return"undefined"==typeof window},oC=function(){return nC()},aC=function(e){return"number"==typeof e},sC=function(e){var t;return mT(t=Function.prototype.toString.call(e)).call(t,"[native code]")},cC={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=Tm(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(cC);var uC={},dC={},lC={},hC=cC;function pC(e){for(var t=e.length;--t>=0;)e[t]=0}var vC=256,_C=286,fC=30,mC=15,yC=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],gC=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],SC=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bC=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],EC=new Array(576);pC(EC);var TC=new Array(60);pC(TC);var kC=new Array(512);pC(kC);var IC=new Array(256);pC(IC);var RC=new Array(29);pC(RC);var AC,CC,wC,xC=new Array(fC);function OC(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function DC(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function PC(e){return e<256?kC[e]:kC[256+(e>>>7)]}function MC(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function NC(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,MC(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function LC(e,t,r){NC(e,r[2*t],r[2*t+1])}function UC(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function VC(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=mC;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=UC(o[s]++,s))}}function FC(e){var t;for(t=0;t<_C;t++)e.dyn_ltree[2*t]=0;for(t=0;t<fC;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function BC(e){e.bi_valid>8?MC(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function jC(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function GC(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&jC(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!jC(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function HC(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?LC(e,i,t):(LC(e,(o=IC[i])+vC+1,t),0!==(a=yC[o])&&NC(e,i-=RC[o],a),LC(e,o=PC(--n),r),0!==(a=gC[o])&&NC(e,n-=xC[o],a))}while(s<e.last_lit);LC(e,256,t)}function zC(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)GC(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],GC(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,GC(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,_=0;for(o=0;o<=mC;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,_++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==_){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,_-=2}while(_>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),VC(o,u,e.bl_count)}function KC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function XC(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{LC(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(LC(e,i,e.bl_tree),s--),LC(e,16,e.bl_tree),NC(e,s-3,2)):s<=10?(LC(e,17,e.bl_tree),NC(e,s-3,3)):(LC(e,18,e.bl_tree),NC(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}pC(xC);var WC=!1;function qC(e,t,r,n){NC(e,0+(n?1:0),3),function(e,t,r,n){BC(e),n&&(MC(e,r),MC(e,~r)),hC.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}lC._tr_init=function(e){WC||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(RC[n]=r,e=0;e<1<<yC[n];e++)IC[r++]=n;for(IC[r-1]=n,i=0,n=0;n<16;n++)for(xC[n]=i,e=0;e<1<<gC[n];e++)kC[i++]=n;for(i>>=7;n<fC;n++)for(xC[n]=i<<7,e=0;e<1<<gC[n]-7;e++)kC[256+i++]=n;for(t=0;t<=mC;t++)o[t]=0;for(e=0;e<=143;)EC[2*e+1]=8,e++,o[8]++;for(;e<=255;)EC[2*e+1]=9,e++,o[9]++;for(;e<=279;)EC[2*e+1]=7,e++,o[7]++;for(;e<=287;)EC[2*e+1]=8,e++,o[8]++;for(VC(EC,287,o),e=0;e<fC;e++)TC[2*e+1]=5,TC[2*e]=UC(e,5);AC=new OC(EC,yC,257,_C,mC),CC=new OC(TC,gC,0,fC,mC),wC=new OC(new Array(0),SC,0,19,7)}(),WC=!0),e.l_desc=new DC(e.dyn_ltree,AC),e.d_desc=new DC(e.dyn_dtree,CC),e.bl_desc=new DC(e.bl_tree,wC),e.bi_buf=0,e.bi_valid=0,FC(e)},lC._tr_stored_block=qC,lC._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<vC;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),zC(e,e.l_desc),zC(e,e.d_desc),a=function(e){var t;for(KC(e,e.dyn_ltree,e.l_desc.max_code),KC(e,e.dyn_dtree,e.d_desc.max_code),zC(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*bC[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?qC(e,t,r,n):4===e.strategy||o===i?(NC(e,2+(n?1:0),3),HC(e,EC,TC)):(NC(e,4+(n?1:0),3),function(e,t,r,n){var i;for(NC(e,t-257,5),NC(e,r-1,5),NC(e,n-4,4),i=0;i<n;i++)NC(e,e.bl_tree[2*bC[i]+1],3);XC(e,e.dyn_ltree,t-1),XC(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),HC(e,e.dyn_ltree,e.dyn_dtree)),FC(e),n&&BC(e)},lC._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(IC[r]+vC+1)]++,e.dyn_dtree[2*PC(t)]++),e.last_lit===e.lit_bufsize-1},lC._tr_align=function(e){NC(e,2,3),LC(e,256,EC),function(e){16===e.bi_valid?(MC(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var YC=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var JC=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var QC,ZC=function(e,t,r,n){var i=JC,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},$C={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},ew=cC,tw=lC,rw=YC,nw=ZC,iw=$C,ow=-2,aw=258,sw=262,cw=103,uw=113,dw=666;function lw(e,t){return e.msg=iw[t],t}function hw(e){return(e<<1)-(e>4?9:0)}function pw(e){for(var t=e.length;--t>=0;)e[t]=0}function vw(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(ew.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function _w(e,t){tw._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,vw(e.strm)}function fw(e,t){e.pending_buf[e.pending++]=t}function mw(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function yw(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-sw?e.strstart-(e.w_size-sw):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+aw,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=aw-(h-o),o=h-aw,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function gw(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-sw)){ew.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,ew.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=rw(a.adler,s,d,c):2===a.state.wrap&&(a.adler=nw(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<sw&&0!==e.strm.avail_in)}function Sw(e,t){for(var r,n;;){if(e.lookahead<sw){if(gw(e),e.lookahead<sw&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-sw&&(e.match_length=yw(e,r)),e.match_length>=3)if(n=tw._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=tw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(_w(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_w(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_w(e,!1),0===e.strm.avail_out)?1:2}function bw(e,t){for(var r,n,i;;){if(e.lookahead<sw){if(gw(e),e.lookahead<sw&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-sw&&(e.match_length=yw(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=tw._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(_w(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=tw._tr_tally(e,0,e.window[e.strstart-1]))&&_w(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tw._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_w(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_w(e,!1),0===e.strm.avail_out)?1:2}function Ew(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function Tw(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new ew.Buf16(1146),this.dyn_dtree=new ew.Buf16(122),this.bl_tree=new ew.Buf16(78),pw(this.dyn_ltree),pw(this.dyn_dtree),pw(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new ew.Buf16(16),this.heap=new ew.Buf16(573),pw(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new ew.Buf16(573),pw(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function kw(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:uw,e.adler=2===t.wrap?0:1,t.last_flush=0,tw._tr_init(t),0):lw(e,ow)}function Iw(e){var t,r=kw(e);return 0===r&&((t=e.state).window_size=2*t.w_size,pw(t.head),t.max_lazy_match=QC[t.level].max_lazy,t.good_match=QC[t.level].good_length,t.nice_match=QC[t.level].nice_length,t.max_chain_length=QC[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function Rw(e,t,r,n,i,o){if(!e)return ow;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return lw(e,ow);8===n&&(n=9);var s=new Tw;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new ew.Buf8(2*s.w_size),s.head=new ew.Buf16(s.hash_size),s.prev=new ew.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new ew.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,Iw(e)}QC=[new Ew(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(gw(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,_w(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-sw&&(_w(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_w(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_w(e,!1),e.strm.avail_out),1)})),new Ew(4,4,8,4,Sw),new Ew(4,5,16,8,Sw),new Ew(4,6,32,32,Sw),new Ew(4,4,16,16,bw),new Ew(8,16,32,32,bw),new Ew(8,16,128,128,bw),new Ew(8,32,128,256,bw),new Ew(32,128,258,1024,bw),new Ew(32,258,258,4096,bw)],dC.deflateInit=function(e,t){return Rw(e,t,8,15,8,0)},dC.deflateInit2=Rw,dC.deflateReset=Iw,dC.deflateResetKeep=kw,dC.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?ow:(e.state.gzhead=t,0):ow},dC.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?lw(e,ow):ow;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===dw&&4!==t)return lw(e,0===e.avail_out?-5:ow);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,fw(n,31),fw(n,139),fw(n,8),n.gzhead?(fw(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),fw(n,255&n.gzhead.time),fw(n,n.gzhead.time>>8&255),fw(n,n.gzhead.time>>16&255),fw(n,n.gzhead.time>>24&255),fw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),fw(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(fw(n,255&n.gzhead.extra.length),fw(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=nw(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(fw(n,0),fw(n,0),fw(n,0),fw(n,0),fw(n,0),fw(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),fw(n,3),n.status=uw);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=uw,mw(n,a),0!==n.strstart&&(mw(n,e.adler>>>16),mw(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),vw(e),i=n.pending,n.pending!==n.pending_buf_size));)fw(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),vw(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,fw(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),vw(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,fw(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nw(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=cw)}else n.status=cw;if(n.status===cw&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&vw(e),n.pending+2<=n.pending_buf_size&&(fw(n,255&e.adler),fw(n,e.adler>>8&255),e.adler=0,n.status=uw)):n.status=uw),0!==n.pending){if(vw(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&hw(t)<=hw(r)&&4!==t)return lw(e,-5);if(n.status===dw&&0!==e.avail_in)return lw(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==dw){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(gw(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=tw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(_w(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_w(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_w(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=aw){if(gw(e),e.lookahead<=aw&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+aw;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=aw-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=tw._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tw._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(_w(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_w(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_w(e,!1),0===e.strm.avail_out)?1:2}(n,t):QC[n.level].func(n,t);if(3!==s&&4!==s||(n.status=dw),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?tw._tr_align(n):5!==t&&(tw._tr_stored_block(n,0,0,!1),3===t&&(pw(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),vw(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(fw(n,255&e.adler),fw(n,e.adler>>8&255),fw(n,e.adler>>16&255),fw(n,e.adler>>24&255),fw(n,255&e.total_in),fw(n,e.total_in>>8&255),fw(n,e.total_in>>16&255),fw(n,e.total_in>>24&255)):(mw(n,e.adler>>>16),mw(n,65535&e.adler)),vw(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},dC.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==cw&&t!==uw&&t!==dw?lw(e,ow):(e.state=null,t===uw?lw(e,-3):0):ow},dC.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return ow;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return ow;for(1===o&&(e.adler=rw(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(pw(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new ew.Buf8(r.w_size),ew.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,gw(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,gw(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},dC.deflateInfo="pako deflate (from Nodeca project)";var Aw={},Cw=cC,ww=!0,xw=!0;try{String.fromCharCode.apply(null,[0])}catch(BW){ww=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(BW){xw=!1}for(var Ow=new Cw.Buf8(256),Dw=0;Dw<256;Dw++)Ow[Dw]=Dw>=252?6:Dw>=248?5:Dw>=240?4:Dw>=224?3:Dw>=192?2:1;function Pw(e,t){if(t<65534&&(e.subarray&&xw||!e.subarray&&ww))return String.fromCharCode.apply(null,Cw.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}Ow[254]=Ow[254]=1,Aw.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new Cw.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},Aw.buf2binstring=function(e){return Pw(e,e.length)},Aw.binstring2buf=function(e){for(var t=new Cw.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},Aw.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=Ow[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return Pw(s,n)},Aw.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+Ow[e[r]]>t?r:t};var Mw=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Nw=dC,Lw=cC,Uw=Aw,Vw=$C,Fw=Mw,Bw=Object.prototype.toString;function jw(e){if(!(this instanceof jw))return new jw(e);this.options=Lw.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fw,this.strm.avail_out=0;var r=Nw.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(Vw[r]);if(t.header&&Nw.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?Uw.string2buf(t.dictionary):"[object ArrayBuffer]"===Bw.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=Nw.deflateSetDictionary(this.strm,n)))throw new Error(Vw[r]);this._dict_set=!0}}function Gw(e,t){var r=new jw(t);if(r.push(e,!0),r.err)throw r.msg||Vw[r.err];return r.result}jw.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=Uw.string2buf(e):"[object ArrayBuffer]"===Bw.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new Lw.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=Nw.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(Uw.buf2binstring(Lw.shrinkBuf(i.output,i.next_out))):this.onData(Lw.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=Nw.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},jw.prototype.onData=function(e){this.chunks.push(e)},jw.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Lw.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},uC.Deflate=jw,uC.deflate=Gw,uC.deflateRaw=function(e,t){return(t=t||{}).raw=!0,Gw(e,t)},uC.gzip=function(e,t){return(t=t||{}).gzip=!0,Gw(e,t)};var Hw={},zw=tr,Kw=O,Xw=Ye,Ww=ae,qw=function(){var e=zw(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},Yw=RegExp.prototype,Jw=ae,Qw=function(e){var t=e.flags;return void 0!==t||"flags"in Yw||Xw(e,"flags")||!Ww(Yw,e)?t:Kw(qw,e)},Zw=RegExp.prototype,$w=function(e){return e===Zw||Jw(Zw,e)?Qw(e):e.flags},ex={},tx=cC,rx=15,nx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],ix=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],ox=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],ax=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],sx=cC,cx=YC,ux=ZC,dx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,v=r.bits,_=r.lencode,f=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=_[p&m];t:for(;;){if(p>>>=S=g>>>24,v-=S,0===(S=g>>>16&255))R[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=_[(65535&g)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=f[p&y];r:for(;;){if(p>>>=S=g>>>24,v-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=f[(65535&g)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&g,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=0,k=h,0===l){if(T+=u-S,S<b){b-=S;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}}else if(l<S){if(T+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[T++]}while(--S);if(T=0,l<b){b-=S=l;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}}}else if(T+=l-S,S<b){b-=S;do{R[o++]=h[T++]}while(--S);T=o-E,k=R}for(;b>2;)R[o++]=k[T++],R[o++]=k[T++],R[o++]=k[T++],b-=3;b&&(R[o++]=k[T++],b>1&&(R[o++]=k[T++]))}else{T=o-E;do{R[o++]=R[T++],R[o++]=R[T++],R[o++]=R[T++],b-=3}while(b>2);b&&(R[o++]=R[T++],b>1&&(R[o++]=R[T++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},lx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,_,f,m=s.bits,y=0,g=0,S=0,b=0,E=0,T=0,k=0,I=0,R=0,A=0,C=null,w=0,x=new tx.Buf16(16),O=new tx.Buf16(16),D=null,P=0;for(y=0;y<=rx;y++)x[y]=0;for(g=0;g<n;g++)x[t[r+g]]++;for(E=m,b=rx;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,y=1;y<=rx;y++)if(I<<=1,(I-=x[y])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,y=1;y<rx;y++)O[y+1]=O[y]+x[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[O[t[r+g]]++]=g);if(0===e?(C=D=a,p=19):1===e?(C=nx,w-=257,D=ix,P-=257,p=256):(C=ox,D=ax,p=-1),A=0,g=0,y=S,h=o,T=E,k=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=y-k,a[g]<p?(_=0,f=a[g]):a[g]>p?(_=D[P+a[g]],f=C[w+a[g]]):(_=96,f=0),c=1<<y-k,S=u=1<<T;do{i[h+(A>>k)+(u-=c)]=v<<24|_<<16|f|0}while(0!==u);for(c=1<<y-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0==--x[y]){if(y===b)break;y=t[r+a[g]]}if(y>E&&(A&l)!==d){for(0===k&&(k=E),h+=S,I=1<<(T=y-k);T+k<b&&!((I-=x[T+k])<=0);)T++,I<<=1;if(R+=1<<T,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|T<<16|h-o|0}}return 0!==A&&(i[h+A]=y-k<<24|64<<16|0),s.bits=E,0},hx=-2,px=12,vx=30;function _x(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function fx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new sx.Buf16(320),this.work=new sx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function mx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new sx.Buf32(852),t.distcode=t.distdyn=new sx.Buf32(592),t.sane=1,t.back=-1,0):hx}function yx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,mx(e)):hx}function gx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?hx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,yx(e))):hx}function Sx(e,t){var r,n;return e?(n=new fx,e.state=n,n.window=null,0!==(r=gx(e,t))&&(e.state=null),r):hx}var bx,Ex,Tx=!0;function kx(e){if(Tx){var t;for(bx=new sx.Buf32(512),Ex=new sx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(lx(1,e.lens,0,288,bx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;lx(2,e.lens,0,32,Ex,0,e.work,{bits:5}),Tx=!1}e.lencode=bx,e.lenbits=9,e.distcode=Ex,e.distbits=5}function Ix(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new sx.Buf8(o.wsize)),n>=o.wsize?(sx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),sx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(sx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}ex.inflateReset=yx,ex.inflateReset2=gx,ex.inflateResetKeep=mx,ex.inflateInit=function(e){return Sx(e,15)},ex.inflateInit2=Sx,ex.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R=0,A=new sx.Buf8(4),C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return hx;(r=e.state).mode===px&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,T=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=vx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=vx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=vx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:px,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&$w(r))){e.msg="unknown compression method",r.mode=vx;break}if(57344&$w(r)){e.msg="unknown header flags set",r.mode=vx;break}r.head&&(r.head.text=u>>8&1),512&$w(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&$w(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=ux(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&$w(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&$w(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&$w(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&$w(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),sx.arraySet(r.head.extra,n,o,p,E)),512&$w(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&$w(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&$w(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&$w(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&$w(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&$w(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=vx;break}u=0,d=0}r.head&&(r.head.hcrc=$w(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=px;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=_x(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=px;case px:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(kx(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=vx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=vx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(p=r.length){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;sx.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=px;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=vx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[C[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,k={bits:r.lenbits},T=lx(0,r.lens,0,19,r.lencode,0,r.work,k),r.lenbits=k.bits,T){e.msg="invalid code lengths set",r.mode=vx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=f,d-=f,r.lens[r.have++]=y;else{if(16===y){for(I=f+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=f,d-=f,0===r.have){e.msg="invalid bit length repeat",r.mode=vx;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=f+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,p=3+(7&(u>>>=f)),u>>>=3,d-=3}else{for(I=f+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,p=11+(127&(u>>>=f)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=vx;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===vx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=vx;break}if(r.lenbits=9,k={bits:r.lenbits},T=lx(1,r.lens,0,r.nlen,r.lencode,0,r.work,k),r.lenbits=k.bits,T){e.msg="invalid literal/lengths set",r.mode=vx;break}if(r.distbits=6,r.distcode=r.distdyn,k={bits:r.distbits},T=lx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,k),r.distbits=k.bits,T){e.msg="invalid distances set",r.mode=vx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,dx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===px&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=f,S=m,b=y;m=(R=r.lencode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=f,d-=f,r.back+=f,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=px;break}if(64&m){e.msg="invalid literal/length code",r.mode=vx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=f,S=m,b=y;m=(R=r.distcode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=f,d-=f,r.back+=f,64&m){e.msg="invalid distance code",r.mode=vx;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=vx;break}r.mode=25;case 25:if(0===c)break e;if(p=h-c,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=vx;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),_=r.window}else _=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=_[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=$w(r)?ux(r.check,i,h,a-h):cx(r.check,i,h,a-h)),h=c,($w(r)?u:_x(u))!==r.check){e.msg="incorrect data check",r.mode=vx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&$w(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=vx;break}u=0,d=0}r.mode=29;case 29:T=1;break e;case vx:T=-3;break e;case 31:return-4;default:return hx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<vx&&(r.mode<27||4!==t))&&Ix(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=$w(r)?ux(r.check,i,h,e.next_out-h):cx(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===px?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===T&&(T=-5),T},ex.inflateEnd=function(e){if(!e||!e.state)return hx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},ex.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?hx:(r.head=t,t.done=!1,0):hx},ex.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?hx:11===r.mode&&cx(1,t,n,0)!==r.check?-3:Ix(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):hx},ex.inflateInfo="pako inflate (from Nodeca project)";var Rx={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var Ax=ex,Cx=cC,wx=Aw,xx=Rx,Ox=$C,Dx=Mw,Px=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},Mx=Object.prototype.toString;function Nx(e){if(!(this instanceof Nx))return new Nx(e);this.options=Cx.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Dx,this.strm.avail_out=0;var r=Ax.inflateInit2(this.strm,t.windowBits);if(r!==xx.Z_OK)throw new Error(Ox[r]);if(this.header=new Px,Ax.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=wx.string2buf(t.dictionary):"[object ArrayBuffer]"===Mx.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ax.inflateSetDictionary(this.strm,t.dictionary))!==xx.Z_OK))throw new Error(Ox[r])}function Lx(e,t){var r=new Nx(t);if(r.push(e,!0),r.err)throw r.msg||Ox[r.err];return r.result}Nx.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?xx.Z_FINISH:xx.Z_NO_FLUSH,"string"==typeof e?s.input=wx.binstring2buf(e):"[object ArrayBuffer]"===Mx.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new Cx.Buf8(c),s.next_out=0,s.avail_out=c),(r=Ax.inflate(s,xx.Z_NO_FLUSH))===xx.Z_NEED_DICT&&u&&(r=Ax.inflateSetDictionary(this.strm,u)),r===xx.Z_BUF_ERROR&&!0===d&&(r=xx.Z_OK,d=!1),r!==xx.Z_STREAM_END&&r!==xx.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==xx.Z_STREAM_END&&(0!==s.avail_in||n!==xx.Z_FINISH&&n!==xx.Z_SYNC_FLUSH)||("string"===this.options.to?(i=wx.utf8border(s.output,s.next_out),o=s.next_out-i,a=wx.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&Cx.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(Cx.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==xx.Z_STREAM_END);return r===xx.Z_STREAM_END&&(n=xx.Z_FINISH),n===xx.Z_FINISH?(r=Ax.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===xx.Z_OK):n!==xx.Z_SYNC_FLUSH||(this.onEnd(xx.Z_OK),s.avail_out=0,!0)},Nx.prototype.onData=function(e){this.chunks.push(e)},Nx.prototype.onEnd=function(e){e===xx.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Cx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},Hw.Inflate=Nx,Hw.inflate=Lx,Hw.inflateRaw=function(e,t){return(t=t||{}).raw=!0,Lx(e,t)},Hw.ungzip=Lx;var Ux={};(0,cC.assign)(Ux,uC,Hw,Rx);var Vx,Fx=Ux,Bx="BytePlusRTC",jx=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Gx=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!iC()&&jx()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?jx().open(Bx,r):jx().open(Bx);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(km().mark((function e(t){var r,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Yf((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Yf((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Yf((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(Gx,"db",void 0),Jd(Gx,"state","init");var Hx={product_line:"rtc",report_version:"5",os:"web",user_agent:iC()?"":null===(Vx=navigator)||void 0===Vx?void 0:Vx.userAgent,platform:"web",product:"webrtc",app_state:"active"},zx="ReportErrorBuffer",Kx=function(){function e(){Vl(this,e),Jd(this,"_buffer",new Gx(zx))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,zx);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(zx);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),Xx=function(){function e(){var t=this;Vl(this,e),Jd(this,"report_common",Hx),Jd(this,"dataBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),iC()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t._send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=Cb(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new Kx,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this._send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this._send()))}},{key:"_unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"_send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rT(r=this.dataBuffer).call(r,0,Wx(this.dataBuffer,5e5)),header:Zd(Zd({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(FW){n=FW}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i._sucSend()}else if(setTimeout((function(){var e,t;xO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i._send(e);else i._unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(JT(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!iC()&&mT(n=location.search).call(n,"_rtc_debug_"))a.send(Nm(o));else{var s=Fx.gzip(Nm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"_sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this._send.bind(this),2e3)}},{key:"_errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e._send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(km().mark((function e(){var t,r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function Wx(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Nm(e[n]).length)>t)return n-1;return e.length}var qx=new Xx,Yx=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Nm(i)});(qx.push(o),iC())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=Cb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),Jx=UA.start;Ar({target:"String",proto:!0,forced:VA},{padStart:function(e){return Jx(this,e,arguments.length>1?arguments[1]:void 0)}});var Qx,Zx=Us("String").padStart,$x=ae,eO=Zx,tO=String.prototype,rO=function(e){var t=e.padStart;return"string"==typeof e||e===tO||$x(tO,e)&&t===tO.padStart?eO:t},nO=Us("Array").keys,iO=_n,oO=Ye,aO=ae,sO=nO,cO=Array.prototype,uO={DOMTokenList:!0,NodeList:!0},dO=function(e){var t=e.keys;return e===cO||aO(cO,e)&&t===cO.keys||oO(uO,iO(e))?sO:t},lO="@byted/ve-rtc",hO="@byted/ve-rtc-cache-size",pO=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!iC()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(lO);try{localStorage.removeItem(hO)}catch(FW){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(hO);if(t)this.cachedSize=+t;else iR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(FW){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(hO,"".concat(this.cachedSize))}catch(FW){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(lO,e).objectStore(lO)}},{key:"set",value:function(e){var t=this;return new Yf((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Om(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Yf((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Yf((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return dO(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),vO=new pO,_O="[VERTC]",fO=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],mO="undefined"!=typeof window&&mT(Qx=window.location.search).call(Qx,"_rtc_debug_"),yO=function(){function e(t,r,n){Vl(this,e),Jd(this,"_indent",void 0),Jd(this,"_module",void 0),Jd(this,"_id",void 0),this._module=t,this._indent=r}return Ul(e,[{key:"print",value:function(e){for(var t,r,n,i,o,a,s,c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];var l=u.shift();try{var h,p,v,_,f=Om(h=[]).call(h,u),m="".concat(l).replace(/\%o/gi,(function(){var e=f.shift();return Nm(e)}));vO.set(Om(p=Om(v=Om(_="".concat(_O,"[").concat(this._module,".")).call(_,e,"] ")).call(v,m," ")).call(p,jm(f).call(f,(function(e){return Nm(e)})).join(", ")))}catch(FW){}if(mO){for(var y="",g=0;g<this._indent;g++)y+=" ";(t=console).log.apply(t,Om(r=[Om(n=Om(i=Om(o=Om(a=Om(s="%c".concat(gO(),"-")).call(s,_O)).call(a,y,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,l),"color:".concat(fO[this._indent],";")]).call(r,u))}}}]),e}(),gO=function(){var e,t=new Date;return t.toTimeString().split(" ")[0]+":"+rO(e=t.getMilliseconds().toString()).call(e,3,"0")},SO=new yO("MessageReportor",1),bO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(SO.print("reportP2PMsg",r.type,Nm(r)),null===(t=PO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(SO.print("reportOne2ManyMsg",r.type,Nm(r)),null===(t=PO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",SO.print("reportMsgRecv",t.type,Nm(t)),null===(n=PO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(bO,"config",void 0);var EO=new $S,TO={_cache:EO,setConfig:function(e){SO.print("setConfig","get config: "+Nm(e)),bO.config=e},setRtsSessionId:function(e,t){var r=EO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=EO.get(e)||new bO(e);return EO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=EO.get(e);t&&(t.destroy(),EO.delete(e))},setRoomId:function(e,t){var r=EO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=EO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=EO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&aC(t.report_msg_id)&&(null===(n=EO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&aC(t.report_msg_id)){var n,i,o=EO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=EO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&aC(t.report_msg_id)){var n,i=EO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&aC(t.report_msg_id)){var n,i,o=EO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&aC(t.report_msg_id)){var n,i=EO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&aC(t.report_msg_id)){var n,i=EO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},kO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=PO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mT(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),IO=function(e){qx.setCommonStats(e)},RO=function(e){qx.setUrl(e)},AO=new Yx("global"),CO=function(e,t,r){AO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},wO=function(e,t,r){AO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},xO=function(e,t,r){AO.report("rtc_error",{message:e,error_code:t},r)},OO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;AO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},DO=new $S,PO=function(e){return DO.get(e)};function MO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=PO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=PO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Nm(UO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return NO(u,r,[e||{}]),e})).catch((function(e){throw NO(u,r,e.message,e.code),e})):(NO(u,r,[l||{}]),l)}}}}var NO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Nm(Array.isArray(r)?UO(r):r)};o&&(a.room_id=o),null===(n=PO(e))||void 0===n||n.report("rtc_sdk_callback",a)},LO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=PO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function UO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),p=jm(c=qT({length:5})).call(c,(function(e,t){return h.getUint8(t)})),v=jm(u=jm(d=qT({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,JT(p),["..."],JT(v))}else s=qT(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mT(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var _={};for(var f in t)_[f]=e(t[f]);return _}return t}))}var VO=function(e){var t,r=PO(e.engineId),n={keys:dO(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Nm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(km().mark((function e(t,r){var i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Nm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Yf((function(e){(function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Nm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},FO={exports:{}},BO=n;Ar({global:!0,forced:BO.globalThis!==BO},{globalThis:BO});var jO=n,GO={exports:{}};!function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==jO&&jO.crypto&&(n=jO.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=require("crypto")}catch(f){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(f){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(f){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=Tm(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=uy(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Om(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=rT(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new _.HMAC.init(e,r).finalize(t)}}});var _=a.algo={};return a}(Math),n)}(GO),function(e,t){var r;e.exports=(r=GO.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(FO);var HO=FO.exports,zO={exports:{}},KO={exports:{}};!function(e,t){var r;e.exports=(r=GO.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=xE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(KO);var XO={exports:{}};!function(e,t){var r;e.exports=(r=GO.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],_=e[t+4],f=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],T=e[t+12],k=e[t+13],I=e[t+14],R=e[t+15],A=o[0],C=o[1],w=o[2],x=o[3];A=u(A,C,w,x,a,7,s[0]),x=u(x,A,C,w,c,12,s[1]),w=u(w,x,A,C,p,17,s[2]),C=u(C,w,x,A,v,22,s[3]),A=u(A,C,w,x,_,7,s[4]),x=u(x,A,C,w,f,12,s[5]),w=u(w,x,A,C,m,17,s[6]),C=u(C,w,x,A,y,22,s[7]),A=u(A,C,w,x,g,7,s[8]),x=u(x,A,C,w,S,12,s[9]),w=u(w,x,A,C,b,17,s[10]),C=u(C,w,x,A,E,22,s[11]),A=u(A,C,w,x,T,7,s[12]),x=u(x,A,C,w,k,12,s[13]),w=u(w,x,A,C,I,17,s[14]),A=d(A,C=u(C,w,x,A,R,22,s[15]),w,x,c,5,s[16]),x=d(x,A,C,w,m,9,s[17]),w=d(w,x,A,C,E,14,s[18]),C=d(C,w,x,A,a,20,s[19]),A=d(A,C,w,x,f,5,s[20]),x=d(x,A,C,w,b,9,s[21]),w=d(w,x,A,C,R,14,s[22]),C=d(C,w,x,A,_,20,s[23]),A=d(A,C,w,x,S,5,s[24]),x=d(x,A,C,w,I,9,s[25]),w=d(w,x,A,C,v,14,s[26]),C=d(C,w,x,A,g,20,s[27]),A=d(A,C,w,x,k,5,s[28]),x=d(x,A,C,w,p,9,s[29]),w=d(w,x,A,C,y,14,s[30]),A=l(A,C=d(C,w,x,A,T,20,s[31]),w,x,f,4,s[32]),x=l(x,A,C,w,g,11,s[33]),w=l(w,x,A,C,E,16,s[34]),C=l(C,w,x,A,I,23,s[35]),A=l(A,C,w,x,c,4,s[36]),x=l(x,A,C,w,_,11,s[37]),w=l(w,x,A,C,y,16,s[38]),C=l(C,w,x,A,b,23,s[39]),A=l(A,C,w,x,k,4,s[40]),x=l(x,A,C,w,a,11,s[41]),w=l(w,x,A,C,v,16,s[42]),C=l(C,w,x,A,m,23,s[43]),A=l(A,C,w,x,S,4,s[44]),x=l(x,A,C,w,T,11,s[45]),w=l(w,x,A,C,R,16,s[46]),A=h(A,C=l(C,w,x,A,p,23,s[47]),w,x,a,6,s[48]),x=h(x,A,C,w,y,10,s[49]),w=h(w,x,A,C,I,15,s[50]),C=h(C,w,x,A,f,21,s[51]),A=h(A,C,w,x,T,6,s[52]),x=h(x,A,C,w,v,10,s[53]),w=h(w,x,A,C,b,15,s[54]),C=h(C,w,x,A,c,21,s[55]),A=h(A,C,w,x,g,6,s[56]),x=h(x,A,C,w,R,10,s[57]),w=h(w,x,A,C,m,15,s[58]),C=h(C,w,x,A,k,21,s[59]),A=h(A,C,w,x,_,6,s[60]),x=h(x,A,C,w,E,10,s[61]),w=h(w,x,A,C,p,15,s[62]),C=h(C,w,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+C|0,o[2]=o[2]+w|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(XO);var WO={exports:{}},qO={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=GO.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}(qO);var YO={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=GO.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Om(t=this._oKey.clone()).call(t,n))}})))}(YO),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=GO.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Om(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(WO);var JO={exports:{}};!function(e,t){var r;e.exports=void((r=GO.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=Tm(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=Tm(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Om(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var _=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Om(t=Om(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(Tm(n).call(n,2,4)),rT(n).call(n,0,4),r.sigBytes-=16),_.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:f}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return _.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(Tm(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,_.create({key:s,iv:c,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(JO),function(e,t){var r;e.exports=(r=GO.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var _=e[r],f=e[_],m=e[f],y=257*e[v]^16843008*v;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*f^257*_^16843008*r,d[v]=y<<24|y>>>8,l[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,p[v]=y,r?(r=_^e[e[e[m^_]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],_=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var _=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],f=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=_,d=f,l=m,h=y}_=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],f=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=_,e[t+1]=f,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(_)}(),r.AES)}(zO);var QO={exports:{}};!function(e,t){e.exports=GO.exports.enc.Hex}(QO);var ZO=QO.exports,$O={exports:{}};!function(e,t){var r,n,i;e.exports=((i=GO.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=Tm(i).call(i,0),this._iv=void 0);var a=Tm(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}($O);var eD=$O.exports,tD={exports:{}};!function(e,t){var r;e.exports=((r=GO.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(tD);var rD=tD.exports,nD=new TextDecoder,iD=new TextEncoder,oD=function(){return nC()},aD=function(){return Date.now()};function sD(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var cD=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Gs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=TA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return nD.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return iD.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Yf((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function uD(){for(var e,t,r=(+zA(e=Tm(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=zA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rT(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return XA(r+e.join(""),2)}))}var dD=function(){return Math.floor(65535*Math.random())};function lD(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var hD,pD,vD,_D,fD,mD,yD,gD,SD=function(){var e=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),bD=function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function ED(e){return+Math.max(-127,10*JA(Math.pow(e/255,2))).toFixed(2)}function TD(e){return(e&ul.AUDIO)===ul.AUDIO}function kD(e){return(e&ul.VIDEO)===ul.VIDEO}function ID(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=ID(e[r]):lA(r).call(r,"_")||(t[r]=e[r])})),t}function RD(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function AD(e){return null==e?"undefined | null":"string"==typeof e?e:Nm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function CD(e){return void 0===e}function wD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function xD(e){console.warn("[RTC WebSDK]: "+e)}function OD(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function DD(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function PD(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function MD(e,t,r){var n=ND(e),i=ND(t),o=ND(r);return function(e){for(var t=e.toString(ZO),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=uy(t.substr(n,2),16);return r}(zO.exports.encrypt(n,i,{iv:o,mode:eD,padding:rD}).ciphertext)}function ND(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return HO.create(t,e.length)}var LD=function(){return"undefined"==typeof window},UD=LD()?"":window.navigator.userAgent;function VD(){var e="none";return LD()||(null!==UD.match("Firefox")?e="mozilla":null!==UD.match("Chrome")?(e="chrome-stable",null!==UD.match("Electron")&&(e="electron")):(null!==UD.match("Safari")||null!==UD.match("AppleWebKit"))&&(e="safari")),e}var FD="mozilla"===VD(),BD="safari"===VD(),jD="chrome-stable"===VD(),GD=!LD()&&/CriOS/i.test(UD),HD=!LD()&&/Edg\//i.test(UD),zD=!LD()&&/EdgA/i.test(UD),KD=!LD()&&/EdgiOS/i.test(UD),XD=HD||zD||KD;!LD()&&/(iPhone|iPod)/i.exec(UD);var WD=!LD()&&(!!/(iPad)/i.exec(UD)||/Macintosh/i.test(UD)&&"ontouchend"in document),qD=!LD()&&/Macintosh/i.test(UD),YD=!LD()&&/MicroMessenger/i.test(UD),JD=!LD()&&mT(hD=UD.toLowerCase()).call(hD,"mobile");!LD()&&/SM-\w+/i.test(UD);var QD=!LD()&&!!/(iPhone|iPad|iPod)/i.exec(UD),ZD=!LD()&&/Android/i.test(UD),$D=!LD()&&/Windows/i.test(UD),eP=0,tP=!LD()&&(null===(pD=UD.match(/version\/(\d+)/i))||void 0===pD?void 0:pD[1]);BD&&tP&&(eP=+tP);var rP=!LD()&&(null===(vD=UD.match(/Firefox\/(\d+)/i))||void 0===vD?void 0:vD[1]);FD&&rP&&(eP=+rP);var nP=eP,iP=eP,oP=null!==(_D=!LD()&&(null===(fD=UD.match(/ ([\d_]+) like Mac OS X/i))||void 0===fD||null===(mD=fD[1])||void 0===mD?void 0:jm(yD=mD.split("_")).call(yD,(function(e){return uy(e)}))))&&void 0!==_D?_D:[],aP=0,sP=!LD()&&(null===(gD=UD.match(/Chrome\/(\d+)/i))||void 0===gD?void 0:gD[1]);sP&&(aP=+sP);var cP=aP,uP="BytePlus",dP="RTC_DEVICE_ID",lP="RTC_ACCESS_NODE",hP="RTC_ACCESS_URLS",pP="ENGINE_WEB_CONFIG",vP="SERVER_CONFIG",_P=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Nm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),fP=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"_accessVersion","v2"),n}return Ul(r,[{key:"getDeviceId",value:function(){if(LD())return"";var e=this.get(dP);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return IO({device_id:e}),this.set(dP,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(Om(t=Om(r="".concat(lP,"_").concat(e,"-")).call(r,uP,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(Om(n=Om(i="".concat(lP,"_").concat(e,"-")).call(i,uP,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n,i=this.getAccessNode(e),o=this.getTtl(Om(r=Om(n="".concat(lP,"_").concat(e,"-")).call(n,uP,"-")).call(r,this._accessVersion));Array.isArray(i)&&i.length>0&&((i=Gs(i).call(i,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,i,o||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t,r;this.delete(Om(t=Om(r="".concat(lP,"_").concat(e,"-")).call(r,uP,"-")).call(t,this._accessVersion))}},{key:"getAccessUrls",value:function(){return this.get("".concat(hP,"-").concat(uP))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(hP,"-").concat(uP),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(hP,"-").concat(uP))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(pP);return(null==a||null===(i=gE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(pP)||[];return(a=Gs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(pP,Tm(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(vP);return(null==n||null===(t=gE(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(vP)||[];return(n=Gs(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(vP,Tm(n).call(n,-5))}}}]),r}(_P),mP=new fP,yP=new yO("JoinRoomConfig",0),gP=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return gE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Nm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){yP.print("_report",this.toString()),LO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(gP,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var SP="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function bP(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var EP="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",TP="rtc.rtcplus.com".split(","),kP={VERSION:"4.54.9",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(SP).call(SP,bP),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:EP,CONFIG_REQUEST_DOMAINS:TP,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:gP.DEFAULT_CONF,ENABLE_FALLBACK_HANDLER:!1};function IP(e,t){var r;if(CO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return gP.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(kP.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,bP));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(kP.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===pl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===pl.domestic?EP:"string"==typeof t?t:void 0;n&&(kP.LOG_SERVER_URL=n,RO(n))}else if("OVERSEA"===e)return IO({extra_is_oversea:t?"1":"0"}),void(kP.OVERSEA=t);"DEVICE_ID"===e&&mP.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&qx.enableErrorBuffer(),kP[e]=t}else IO({product:t});else IO({platform:t})}}function RP(e){return"DEVICE_ID"===e?mP.getDeviceId():kP[e]}function AP(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||fl.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var CP={width:640,height:480,frameRate:15,maxKbps:600},wP={width:1920,height:1080,frameRate:15,maxKbps:3e3};function xP(e,t){if("boolean"!=typeof e)throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function OP(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new vA(hA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function DP(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new vA(hA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!VP(e,i,o))throw new vA(hA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function PP(e,t,r){var n;if(!mT(r).call(r,e))throw new vA(hA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Nm(r)))}function MP(e){if(!(e instanceof MediaStreamTrack))throw new vA(hA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function NP(e,t){if(FP(e))throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function LP(e,t){if(!(e instanceof ArrayBuffer))throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function UP(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=an(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function VP(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function FP(e){return null==e}function BP(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function jP(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function GP(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function HP(e){NP(e,"userInfo"),jP(e.userId),FP(e.extraInfo)||DP(e.extraInfo,"userInfo.extraInfo",1,200)}function zP(e){NP(e,"roomConfig"),xP(e.isAutoPublish,"roomConfig.isAutoPublish"),xP(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),xP(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),FP(e.roomProfileType)||PP(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function KP(e){NP(e,"videoPlayerOption")}function XP(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new vA(hA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:cD.str2ab(Nm(e)))||void 0===t?void 0:t.byteLength)>1024*r)throw new vA(hA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function WP(e){var t,r=RP("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mT(r).call(r,e))||!mT(t=[Nl.onRemoteStreamStats,Nl.onLocalStreamStats,Nl.onAudioVolumeIndication,Nl.onLocalAudioPropertiesReport,Nl.onRemoteAudioPropertiesReport]).call(t,e)}function qP(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new vA(hA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function YP(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new vA(hA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function JP(e){var t,r=$k(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;OP(null==n?void 0:n.maxKbps,"maxKbps"),YP(null==n?void 0:n.width,"width"),YP(null==n?void 0:n.height,"height"),YP(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function QP(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return OP(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var ZP={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||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 a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?Tm(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){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,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(ZP);var $P=ZP.exports,eM=new yO("VERTC",0),tM=function(e){PI(r,e);var t=JI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(wI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(FW){return eM.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,FW),console.error(FW),Boolean(t)}}}]),r}(ZP.exports.EventEmitter),rM=O,nM=tr,iM=$,oM=nI,aM=Jt,sM=A,cM=mc,uM=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=aM.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=sM.f(nM(t),r);if(!c){if(iM(o=cM(t)))return e(o,r,n,s);c=uM(0)}if(oM(c)){if(!1===c.writable||!iM(s))return!1;if(i=sM.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,aM.f(s,r,i)}else aM.f(s,r,uM(0,n))}else{if(void 0===(a=c.set))return!1;rM(a,s,n)}return!0}});var dM=ee.Reflect.set,lM=hi.f("asyncIterator");function hM(e){var t,r,n,i=2;for(void 0!==Cd&&(r=lM,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new pM(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function pM(e){function t(e){if(Object(e)!==e)return Yf.reject(new TypeError(e+" is not an object."));var t=e.done;return Yf.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(pM=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Yf.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Yf.reject(e):t(r.apply(this.s,arguments))}},new pM(e)}var vM=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yy("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var _M=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:bg}),Ar({target:"Set",stat:!0,forced:!0},{of:Tg});var fM=O,mM=we,yM=tr,gM=function(){for(var e=yM(this),t=mM(e.add),r=0,n=arguments.length;r<n;r++)fM(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:gM}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var SM=gh,bM=tr,EM=Yt,TM=SM,kM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=bM(this),r=TM(t),n=EM(e,arguments.length>1?arguments[1]:void 0);return!kM(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var IM=oe,RM=O,AM=we,CM=tr,wM=Rp,xM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=CM(this),r=new(wM(t,IM("Set")))(t),n=AM(r.delete);return xM(e,(function(e){RM(n,r,e)})),r}});var OM=oe,DM=O,PM=we,MM=tr,NM=Yt,LM=Rp,UM=SM,VM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=MM(this),r=UM(t),n=NM(e,arguments.length>1?arguments[1]:void 0),i=new(LM(t,OM("Set"))),o=PM(i.add);return VM(r,(function(e){n(e,e,t)&&DM(o,i,e)}),{IS_ITERATOR:!0}),i}});var FM=tr,BM=Yt,jM=SM,GM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=FM(this),r=jM(t),n=BM(e,arguments.length>1?arguments[1]:void 0);return GM(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var HM=oe,zM=O,KM=we,XM=tr,WM=Rp,qM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=XM(this),r=new(WM(t,HM("Set"))),n=KM(t.has),i=KM(r.add);return qM(e,(function(e){zM(n,t,e)&&zM(i,r,e)})),r}});var YM=O,JM=we,QM=tr,ZM=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=QM(this),r=JM(t.has);return!ZM(e,(function(e,n){if(!0===YM(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $M=oe,eN=O,tN=we,rN=R,nN=tr,iN=gh,oN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=iN(this),r=nN(e),n=r.has;return rN(n)||(r=new($M("Set"))(e),n=tN(r.has)),!oN(t,(function(e,t){if(!1===eN(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var aN=O,sN=we,cN=tr,uN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=cN(this),r=sN(t.has);return!uN(e,(function(e,n){if(!1===aN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var dN=Ar,lN=tr,hN=yn,pN=SM,vN=Uh,_N=E([].join),fN=[].push;dN({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=lN(this),r=pN(t),n=void 0===e?",":hN(e),i=[];return vN(r,fN,{that:i,IS_ITERATOR:!0}),_N(i,n)}});var mN=oe,yN=Yt,gN=O,SN=we,bN=tr,EN=Rp,TN=SM,kN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=bN(this),r=TN(t),n=yN(e,arguments.length>1?arguments[1]:void 0),i=new(EN(t,mN("Set"))),o=SN(i.add);return kN(r,(function(e){gN(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var IN=we,RN=tr,AN=SM,CN=Uh,wN=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=RN(this),r=AN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(IN(e),CN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw wN("Reduce of empty set with no initial value");return i}});var xN=tr,ON=Yt,DN=SM,PN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=xN(this),r=DN(t),n=ON(e,arguments.length>1?arguments[1]:void 0);return PN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var MN=oe,NN=O,LN=we,UN=tr,VN=Rp,FN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=UN(this),r=new(VN(t,MN("Set")))(t),n=LN(r.delete),i=LN(r.add);return FN(e,(function(e){NN(n,r,e)||NN(i,r,e)})),r}});var BN=oe,jN=we,GN=tr,HN=Rp,zN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=GN(this),r=new(HN(t,BN("Set")))(t);return zN(e,jN(r.add),{that:r}),r}});var KN=_M,XN=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!LD()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,tL();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,eL();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),WN=function(){var e=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,tL();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,eL();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,nL();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,rL();case 16:e.t1=e.sent;case 17:if(!e.t1){e.next=19;break}t.push("vp8");case 19:return e.abrupt("return",t);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qN=function(){var e=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,WN();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),YN={};function JN(e){var t,r=!1,n=$k(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mT(i).call(i,"level-asymmetry-allowed=1")&&mT(i).call(i,"packetization-mode=1")&&mT(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mT(o).call(o,u)&&(a=!0)}return!a}return!1}var QN=function(){var e=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection({sdpSemantics:"unified-plan"})).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ZN=function(){var e=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QN("sendonly");case 2:if(r=e.sent,!mT(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QN("sendonly");case 6:r=e.sent;case 7:return YN.h264encode=JN(r),YN.vp8encode=xE(r).call(r,"vp8")>-1,e.abrupt("return",YN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$N=function(){var e=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QN("recvonly");case 2:if(r=e.sent,!mT(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QN("recvonly");case 6:r=e.sent;case 7:return YN.h264decode=JN(r),YN.vp8decode=xE(r).call(r,"vp8")>-1,e.abrupt("return",YN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eL=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.h264encode){e.next=9;break}return e.prev=1,e.next=4,ZN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),tL=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.h264decode){e.next=9;break}return e.prev=1,e.next=4,$N();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),rL=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.vp8encode){e.next=9;break}return e.prev=1,e.next=4,ZN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),nL=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.vp8decode){e.next=9;break}return e.prev=1,e.next=4,$N();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),iL=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},oL=function(){return qD?jD&&cP>=70||FD&&iP>=80||BD&&nP>=14:$D?jD&&cP>=70||FD&&iP>=80:QD?oP[0]>=14:!!ZD&&(jD&&cP>=86)},aL=jD&&cP<=114,sL=new $S,cL=function(){var e=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,r){var n=RP("STATS_SCALLBACK_SUPPORT");if(jD&&void 0===window.InstallTrigger&&aL&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mT(hL).call(hL,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Gs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(FW){r(FW)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uL=function(){var e=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(lL.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(lL.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(lL.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(lL.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,_=s,f=_.localCertificateId,m=_.remoteCertificateId,y=_.selectedCandidatePairId;null===(p=o.get(lL.certificate))||void 0===p||p.forEach((function(e){(e.id===f||e.id===m)&&t.add(e)})),null===(v=o.get(lL.candidatePair))||void 0===v||v.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,b=c,E=b.localCandidateId,T=b.remoteCandidateId;null===(g=o.get(lL.localCandidate))||void 0===g||g.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(lL.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===T&&t.add(e)}))}}))},o.get(lL.mediaSource)?null===(s=o.get(lL.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new KN;r.add(e);var n=[];null===(t=o.get(lL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qT(r)})):o.get(lL.track)&&(null===(c=o.get(lL.track))||void 0===c||c.forEach((function(e){var t,r=new KN;r.add(e);var n=[];null===(t=o.get(lL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qT(r)}))),null===(r=o.get(lL.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new KN;r.add(e),null===(t=o.get(lL.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(lL.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qT(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),dL=function(){var e=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!FD&&!BD){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=sL.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:uL(t),extraStatsPromise:cL(t)},sL.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),lL=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(lL||{}),hL=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],pL={},vL={},_L={exports:{}},fL=_L.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"]}]};an(fL).forEach((function(e){fL[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=_L.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Gs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=Tm(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return pb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return pb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(vL);var mL=_L.exports,yL=/%[sdv%]/g,gL=function(e){var t=1,r=arguments,n=r.length;return e.replace(yL,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},SL=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return gL.apply(null,n)},bL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],EL=["i","c","b","a"],TL=vL,kL=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||bL,n=t.innerOrder||EL,i=[];return r.forEach((function(t){mL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(SL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(SL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(SL("m",mL.m[0],e)),n.forEach((function(t){mL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(SL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(SL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};pL.write=kL,pL.parse=TL.parse,pL.parseParams=TL.parseParams,pL.parseFmtpConfig=TL.parseFmtpConfig,pL.parsePayloads=TL.parsePayloads,pL.parseRemoteCandidates=TL.parseRemoteCandidates,pL.parseImageAttributes=TL.parseImageAttributes,pL.parseSimulcastStreamList=TL.parseSimulcastStreamList;var IL=Xe,RL=Nr,AL=Br,CL=function(e){for(var t=IL(this),r=AL(t),n=arguments.length,i=RL(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:RL(o,r);a>i;)t[i++]=e;return t};Ar({target:"Array",proto:!0},{fill:CL});var wL=Us("Array").fill,xL=ae,OL=wL,DL=Array.prototype,PL=function(e){var t=e.fill;return e===DL||xL(DL,e)&&t===DL.fill?OL:t},ML=new yO("FirefoxHandler",3),NL=Math.pow(2,32),LL="kp34Za0H+aVf862l",UL="o/i14u9pJrxRKAsu";function VL(e){return e>NL-18?(ML.print("generateAllSsrc","reset start id",e),VL(e=e-NL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var FL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:UL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},BL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=pb(s).call(s,(function(t,r){return Om(t).call(t,FL(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function jL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var GL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,pL.write(i)};function HL(e){return zL.apply(this,arguments)}function zL(){return(zL=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,XL(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=KL(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KL(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var XL=function(){var e=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,cD.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=sD(Uint8Array,n,i,o,a),e.next=15,cD.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),WL=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(WL||{});function qL(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=DD(n);c.byteLength;var u=MD(DD(o),DD(i).subarray(0,16),DD(n).subarray(0,16));u.byteLength;var d=new Uint8Array(pb(t=an(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=sD(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=sD(Uint8Array,h,PL(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[PD(h),PD(sD(Uint8Array,r,c.subarray(0,20)))]}var YL=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$k(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mT(o=c.config).call(o,"level-asymmetry-allowed=1")&&mT(a=c.config).call(a,"packetization-mode=1")&&mT(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rT(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rT(h=e.rtp).call(h,u,1)[0]);break}}var p=[];e.rtp.forEach((function(e){return p.push(e.payload)})),e.payloads=p.join(" ")}},JL=new yO("BasicHandler",3),QL=function(e){PI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*NL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=PO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){JL.print("destroy",this.peerConnectionId||""),OI(wI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),JL.print("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=Tm(a=Tm(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=OD(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:OD(e.frameRate)||15,maxkbps:e.maxKbps||600}})),JL.print("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},CP);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],_={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[_],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!FD&&i){var f,m,y=function(e){for(var t=0,r=e.width*e.height,n=0;n<vM.length;n++)if(r>=vM[n].totalPixels){t=n;break}if(0===t)return vM[t].maxLayers;var i=vM[t-1].totalPixels;return(i-r)/(i-vM[t].totalPixels)<.1?vM[t-1].maxLayers:vM[t].maxLayers}(h);if(JL.print("simulcast() ","maxLayers: %o",y),y>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:v.maxKbps}),c,u,y),null!==(f=this._context)&&void 0!==f&&null!==(m=f.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}JL.print("publish videoTransceiverInit videoDescriptions","",c,u);var g=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Dl.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(g=null==n?void 0:n.mixedAudioTrack),g=o&&g?g:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Nm({aTrack:AD(g),vTrack:AD(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(FW){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:g,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;JL.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void JL.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Nm(c.encodings))}catch(FW){}}}else JL.print("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return dL(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mT(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mT(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=gE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,JT(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(ZP.exports.EventEmitter),ZL=E,$L=Qy,eU=dy.exports.getWeakData,tU=mp,rU=tr,nU=z,iU=$,oU=Uh,aU=Ye,sU=Zi.set,cU=Zi.getterFor,uU=Mo.find,dU=Mo.findIndex,lU=ZL([].splice),hU=0,pU=function(e){return e.frozen||(e.frozen=new vU)},vU=function(){this.entries=[]},_U=function(e,t){return uU(e.entries,(function(e){return e[0]===t}))};vU.prototype={get:function(e){var t=_U(this,e);if(t)return t[1]},has:function(e){return!!_U(this,e)},set:function(e,t){var r=_U(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=dU(this.entries,(function(t){return t[0]===e}));return~t&&lU(this.entries,t,1),!!~t}};var fU,mU={getConstructor:function(e,t,r,n){var i=e((function(e,i){tU(e,o),sU(e,{type:t,id:hU++,frozen:void 0}),nU(i)||oU(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=cU(t),s=function(e,t,r){var n=a(e),i=eU(rU(t),!0);return!0===i?pU(n).set(t,r):i[n.id]=r,e};return $L(o,{delete:function(e){var t=a(this);if(!iU(e))return!1;var r=eU(e);return!0===r?pU(t).delete(e):r&&aU(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!iU(e))return!1;var r=eU(e);return!0===r?pU(t).has(e):r&&aU(r,t.id)}}),$L(o,r?{get:function(e){var t=a(this);if(iU(e)){var r=eU(e);return!0===r?pU(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},yU=n,gU=E,SU=Qy,bU=dy.exports,EU=Yy,TU=mU,kU=$,IU=my,RU=Zi.enforce,AU=Vi,CU=!yU.ActiveXObject&&"ActiveXObject"in yU,wU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},xU=EU("WeakMap",wU,TU);if(AU&&CU){fU=TU.getConstructor(wU,"WeakMap",!0),bU.enable();var OU=xU.prototype,DU=gU(OU.delete),PU=gU(OU.has),MU=gU(OU.get),NU=gU(OU.set);SU(OU,{delete:function(e){if(kU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),DU(this,e)||t.frozen.delete(e)}return DU(this,e)},has:function(e){if(kU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),PU(this,e)||t.frozen.has(e)}return PU(this,e)},get:function(e){if(kU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),PU(this,e)?MU(this,e):t.frozen.get(e)}return MU(this,e)},set:function(e,t){if(kU(e)&&!IU(e)){var r=RU(this);r.frozen||(r.frozen=new fU),PU(this,e)?NU(this,e,t):r.frozen.set(e,t)}else NU(this,e,t);return this}})}var LU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Og}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:bg}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:Tg}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ag}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var UU=LU,VU=function(e){PI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=JI(p);function p(){var e,t,r;return Vl(this,p),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!LD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!LD()&&r.refreshDevices(),r}return Ul(p,[{key:"refreshDevices",value:(l=Rm(km().mark((function e(){var t,r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!FD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(km().mark((function e(){var t,r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!FD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Gs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qT(Om(t=[]).call(t,JT(iR(r=this.deviceMap.audioinput).call(r)),JT(iR(n=this.deviceMap.videoinput).call(n)),JT(iR(i=this.deviceMap.audiooutput).call(i)))),(JD||WD)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mT(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mT(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;gE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mT(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mT(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Gs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Gs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c=this,u=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>0&&void 0!==u[0]?u[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,c.isGrantedMicrophonePermission=!0),i&&(a.video=!0,c.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(Om(t=[]).call(t,JT(iR(r=this.deviceMap.audioinput).call(r)),JT(iR(n=this.deviceMap.videoinput).call(n)),JT(iR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(iR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(iR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qT(iR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",gE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}(tM),FU=new VU;!LD()&&(window.__rtc_dd__=FU);var BU=new yO("InternalEventBus",1),jU=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(jU||{}),GU=function(e){PI(r,e);var t=JI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;BU.print(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(wI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(ZP.exports.EventEmitter),HU=new GU,zU=new yO("AudioContext",1),KU=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;LD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,zU.print("currentTime resume"),OO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,zU.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),OO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;zU.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(QD||WD)&&("running"===e._previousState&&"interrupted"===e._currentState&&HU.emit(jU.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&HU.emit(jU.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),XU=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=WU.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),WU=new KU,qU=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(qU||{}),YU=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(JR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return gE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$k(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),JU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(JU||{}),QU=new yO("VERTC",0),ZU=new UU,$U=function(e){PI(r,e);var t=JI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&oL()&&!RP("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=WU.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!oL()||RP("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==nP)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(tM),eV=function(e){PI(n,e);var t,r=JI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}($U),tV=function(e){PI(r,e);var t=JI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}($U),rV=function(e){PI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return QU.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,FD&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mT(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(eV),nV=function(e){PI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Dl.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new XU(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return QU.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(eV),iV=function(e){PI(r,e);var t=JI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(tV),oV=function(e){PI(r,e);var t=JI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new XU(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(tV),aV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(nV),sV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(rV),cV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(rV),uV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(nV),dV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(rV),lV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(nV),hV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(rV),pV=function(e){PI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(nV);function vV(e,t){return _V.apply(this,arguments)}function _V(){return(_V=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new sV(t,oD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fV(e,t){return mV.apply(this,arguments)}function mV(){return(mV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new dV(t,oD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yV(e,t){return gV.apply(this,arguments)}function gV(){return(gV=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=PO(r.id),e.prev=2,QU.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=aD(),FD&&(t.frameRate={ideal:30,max:30}),e.next=9,FU.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:aD()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_VIDEO_TRACK_FAILED,Om(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 17:return u=i.getVideoTracks()[0],ZU.set(u,i),d=new sV(u,oD()),e.next=22,d.generatePreProcessingTrack(r);case 22:return e.abrupt("return",d);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).apply(this,arguments)}function SV(e,t){return bV.apply(this,arguments)}function bV(){return(bV=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QU.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=PO(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=aD(),(c=r.getPluginByName(qU.PRE_PROCESSING,"RTCAIAnsExtension"))&&(c.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,FU.getUserMedia({audio:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:aD()-s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_AUDIO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getAudioTracks()[0],ZU.set(d,i),l=new aV(d,oD()),e.next=23,l.generatePreProcessingTrack(r);case 23:return e.abrupt("return",l);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function EV(){return TV.apply(this,arguments)}function TV(){return TV=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,QU.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=PO(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=aD(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!BD||16!==nP))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:aD()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 18:return s=i.getVideoTracks()[0],c=new dV(s,oD()),e.next=22,c.generatePreProcessingTrack(r);case 22:if(!(u=i.getAudioTracks()[0])){e.next=28;break}return d=new lV(u,oD()),e.next=27,d.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[c,d]);case 28:return e.abrupt("return",[c,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),TV.apply(this,arguments)}function kV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oD();return new oV(e,t)}function IV(e,t){return RV.apply(this,arguments)}function RV(){return(RV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new cV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function AV(e,t){return CV.apply(this,arguments)}function CV(){return(CV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new uV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function wV(e,t){return xV.apply(this,arguments)}function xV(){return(xV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new hV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function OV(e,t){return DV.apply(this,arguments)}function DV(){return(DV=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new pV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var PV=nV,MV=oV,NV=function(e){return e[e.NONE=0]="NONE",e}(NV||{}),LV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a,s,c=new Uint8Array(Tm(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var u={header:c,body:new Uint8Array(Tm(s=t.buffer).call(s,i+c.byteLength,o)),type:-1};e.analyseNal(u),u.type<=9&&0!==u.type&&r.push(u),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i,o,a=new Uint8Array(Tm(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(Tm(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var c={header:a,body:s,type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}}]),e}(),UV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),VV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(VV||{}),FV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),BV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),jV=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function GV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function HV(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var zV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?FV:BV,s=GV(e.byteLength+a.byteLength),c=jV(e);return new Uint8Array(Om(t=[]).call(t,JT(n),JT(i),JT(o),JT(s),JT(a),JT(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=Tm(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(HV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=BV.byteLength&&i>=BV.byteLength&&Tm(t).call(t,r,r+BV.byteLength).toString()===BV.toString()?(r+=BV.byteLength,o=1):t.byteLength>=BV.byteLength&&i>=BV.byteLength&&Tm(t).call(t,r,r+FV.byteLength).toString()===FV.toString()&&(r+=FV.byteLength,o=0),{type:o,payload:Tm(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(HV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(HV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,Tm(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$k(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=GV(o),c=GV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=pb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return pb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),KV=new yO("Stats",3),XV=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=PO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(KV.print("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,LO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){KV.print("destroy","invoke"),LO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),WV=function(e){PI(i,e);var t,r,n=JI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){KV.print("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(km().mark((function e(){var t,r,n,i,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(km().mark((function t(){var r;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,_=u.audioTrack,f={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},_&&(f.playback_volume=_.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,_=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,T=e.requestsSent,k=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,C=e.ip,w=e.address,x=e.networkType,O=e.port,D=e.protocol,P=e.nackCount,M=e.retransmittedBytesSent,N=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,f.bytes=i,f.packetsSent=r,f.nackCount=P,f.ssrc=U,f.retransmitted_bytes_sent=M,f.retransmitted_packets_sent=N,c.retransmittedBytesSent=M,c.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(c.packetsLost=n,f.packetsLost=n,f.net_jitter=1e3*R,s.rtt=1e3*a,f.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,f.codecName=l):"media-source"===t&&void 0!==d?(f.audio_level=d?-10*JA(Math.pow(d,2)):d,f.volume=255*d,f.total_audio_energy=V,f.totalInputDuration=F):"ssrc"===t&&"audio"===B?f.send_level=L:"candidate-pair"===t?(f.ice_available_incoming_bitrate=h,f.ice_available_outgoing_bitrate=p,f.ice_bytes_received=v,f.ice_bytes_sent=i,f.ice_nominated=+_,f.ice_pair_id=m,f.ice_pair_rtt=y,f.ice_pair_state=g,f.ice_pair_writable=S,f.recv_ping_requests=b,f.recv_ping_responses=E,f.sent_ping_requests_before_first_response=T,f.sent_ping_requests_total=T+(k||0),f.sent_ping_responses=I):"local-candidate"===t?(f.local_candidate_type=A,f.local_ip=C||w,f.local_network_type=x,f.local_port=O,f.protocol=D):"remote-candidate"===t&&(f.remote_candidate_type=A,f.remote_ip=C||w,f.remote_port=O);var G=RP("STATS_SCALLBACK_SUPPORT");aL&&G||"media-source"===t&&(f.send_level=d)})),void 0===f.volume&&void 0!==n&&(f.volume=n,f.audio_level=n?-10*JA(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,f.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-y.timestamp,f.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,f.mediaBitratebps=Math.round(1e3*s.sendKBitrate),f.bandwidth=Math.round(f.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(f.retransmitBitratebps=(c.retransmittedBytesSent-y.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,f.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,f.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",f),s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,f.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,_=e.firCount,f=e.targetBitrate,m=e.roundTripTime,y=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,T=e.googAvailableReceiveBandwidth,k=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,C=e.googFrameRateInput,w=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,D=e.nominated,P=e.id,M=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,G=e.nackCount,H=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=G||h.nackCount||0,h.pli_count=H||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==g&&((!n.encodedFrameWidth||g>n.encodedFrameWidth)&&(n.encodedFrameWidth=g),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=g)):"track"===t?(n.encodedFrameWidth=g,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=g):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=y,h.codecName=y):"candidate-pair"===t?(h.ice_available_incoming_bitrate=w,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=+D,h.ice_pair_id=P,h.ice_pair_rtt=M,h.ice_pair_state=N,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=T,h.available_send_bandwidth=k,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=+k):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=C,h.orignal_input_Framerate=+C,h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var _e=RP("STATS_SCALLBACK_SUPPORT");if(!aL||!_e){var fe=r.video,me=i.timestamp-fe.timestamp;if("outbound-rtp"===t){var ye=s-fe.bytesSent,ge=u-fe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ye-ge)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ge/me),h.targetEncBitratebps=f,h.transmit_bitrate=Math.round(1e3*(s-fe.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=_+H}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=+pe,h.frame_input=ve)}})),(_=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-_.timestamp,h.stats_interval=n.statsInterval,f=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,jR(f).call(f,(function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,m=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var g=_.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(y||0),g){var S=(a-g.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-g.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var T=void 0!==c?c-g.framesSent:s-g.framesEncoded,k=1e3*T/n.statsInterval;h.sim_sent_framerate.push(Math.round(k));var I=(u-g.packetsLost)/(d-g.packetsSent);n._retransmittedRate=(f-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-g.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=T,n.sentFrameRate=k,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(y=this._stream)||void 0===y?void 0:y.vendorCode)||0,h.pc_session_id=null===(g=this.handler)||void 0===g?void 0:g.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-_.framesSent:i.framesEncoded-_.framesEncoded,n.sentKBitrate=(i.bytesSent-_.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-_.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-_.packetsLost)/(i.packetsSent-_.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-_.retransmittedPacketsSent)/(i.packetsSent-_.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(T=this.handler)||void 0===T?void 0:T.peerConnectionId,null===(k=this._monitor)||void 0===k||k.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(XV),qV=function(e){PI(o,e);var t,r,n,i=JI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(km().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,_,f,m,y,g=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return KV.print("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],_=0,f=aD(),this._setAudioStallCount=function(){if(kP.AUDIO_STALL&&g._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;f=aD();var r={isStall:!1,counted:!1,diff:0},n=.5*g._audioStallInterval;g._audioStallCount=Rm(km().mark((function i(){var o,a,s,u,d,p,m,y,S,b,E,T,k,I,R,A,C,w,x,O;return km().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),f=aD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 7:if(!u||d){i.next=13;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),f=aD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 13:return y=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=17,g.handler.getStats(y,!0);case 17:if(b=i.sent,E=Date.now(),T=aD(),!((k=T-f)<n)){i.next=24;break}return v.push({diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(k,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 24:if(R=b.length,A=gE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=29;break}return v.push({diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 29:return C=A.concealedSamples,w=A.totalSamplesReceived,O=w-t,(x=C-e)>=0&&O>=0&&x>=g._audioStallRatio*O?(v.push({concealed:x,received:O,diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=k:(h=h+r.diff+k,l++),r.counted=!0):k>=200?(h+=k,l++,r.counted=!0):(r.counted=!1,r.diff=k),r.isStall=!0):(v.push({concealed:x,received:O,diff:k,start:f,end:T,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=C,t=w,f=T,_++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 38:case"end":return i.stop()}}),i)}))),p=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g._audioStallCount&&g._setAudioStallCount&&g._setAudioStallCount(),!g._audioStallCount){e.next=6;break}return e.next=4,g._audioStallCount();case 4:g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(km().mark((function e(){var t,r,n,i,o,a,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,g.getRemoteAudioStats(i,s,null===(n=g._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],_=0,e.next=11,g.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Rm(km().mark((function e(){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(f=aD(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)),g._timer&&clearTimeout(g._timer),g._destroyed||(g._timer=setTimeout(y,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){KV.print("unsubscribe","invoke"),OI(wI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,_=h.isScreen,f=h.audioMid,m=h.subMediaType,y=h._attributes,g=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!_,direction:"down",stream_id:p,stream_user_id:v,vid:f,audio_mux:g,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:TD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:y.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:y.localaudio&&y.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,_=e.silentConcealedSamples,f=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,T=e.totalAudioEnergy,k=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,C=e.availableIncomingBitrate,w=e.availableOutgoingBitrate,O=e.bytesSent,D=e.nominated,P=e.id,M=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,G=e.audioOutputLevel,H=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=y,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=_,b.concealedSamples=v,d.concealmentEvents=f,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*N,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*JA(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*JA(Math.pow(n/255,2)):n),void 0!==T&&(b.total_audio_energy=T),void 0!==k&&(b.totalAudioDuration=k);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=C,b.ice_available_outgoing_bitrate=w,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=+D,b.ice_pair_id=P,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=g,b.ice_pair_writable=M,b.recv_ping_requests=H,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===g&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*JA(Math.pow(n/255,2)):n):(b.audio_level=E?-10*JA(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=T,b.totalAudioDuration=k):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=G,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(T=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(k={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-T.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-T.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-T.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==T.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,C=I.stall_list,w=I.stats_count,k.stall_list=C,k.stats_count=w,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-T.packetsLost)/(l.packetsReceived-T.packetsReceived+(l.packetsLost-T.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-T.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-T.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-T.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,k),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,_=l.subMediaType,f=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:kD(_)?"mute_state_off":"mute_state_on",remote_user_capture_state:f.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:f.localvideo&&f.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((y=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,_=e.availableIncomingBitrate,f=e.availableOutgoingBitrate,y=e.bytesSent,g=e.nominated,S=e.id,E=e.currentRoundTripTime,T=e.state,k=e.writable,I=e.candidateType,R=e.ip,A=e.address,C=e.networkType,w=e.port,x=e.nackCount,O=e.pliCount,D=e.protocol,P=e.requestsReceived,M=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,G=e.totalDecodeTime,H=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=G,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=H,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=_,m.ice_available_outgoing_bitrate=f,m.ice_bytes_received=a,m.ice_bytes_sent=y,m.ice_nominated=+g,m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=T,m.ice_pair_writable=k,m.recv_ping_requests=P,m.recv_ping_responses=M,m.sent_ping_requests_before_first_response=N,m.sent_ping_requests_total=N+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=C,m.local_port=w,m.protocol=D):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=w)})),(g=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-g.packetsLost)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),g.totalDecodeTime&&g.framesDecoded&&d.framesDecoded!==g.framesDecoded&&(m.decode_elapse_per_frame=+((d.totalDecodeTime-g.totalDecodeTime)/(d.framesDecoded-g.framesDecoded)*1e3).toFixed(2)),u._retransmittedRate=(d.nackCount-g.nackCount)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-g.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-g.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-g.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-g.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(wI(o.prototype),"destroy",this).call(this),OI(wI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(XV);Jd(qV,"audioStallInterval",void 0),Jd(qV,"audioStallRatio",void 0);var YV,JV,QV=new yO("Stream",0),ZV=function(e){PI(r,e);var t=JI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Yf((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(tM),$V=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}($V||{}),eF=function(e){PI(r,e);var t=JI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[CP]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new WV(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(iL()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=zV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rT(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else QV.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else QV.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){LO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(wI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(ZV),tF=function(e){PI(r,e);var t=JI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=NV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new qV(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=oC()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){LV.getNalunits(new UV(t.data)).forEach((function(t){if(t.sei){var r=zV.decodeSeiBody(t.body);r&&r.type!==VV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else QV.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else QV.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;LO(this.engineId,"Stream.ontrack",Nm({uid:this.userId,streamId:this.streamId,streams:pb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Nm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Nm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Nm({track:AD(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Nm({track:AD(o.track)}))})),track:AD(e.track)}),0,this.streamId||"")}catch(FW){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mT(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;QV.print("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),LO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(wI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=kV(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oD();return new iV(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(ZV),rF=new yO("queue",4),nF=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(nF||{}),iF=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(iF||{}),oF=(Jd(YV={},"publish","unpublish"),Jd(YV,"subscribe","unsubscribe"),Jd(YV,"pushtrack","removetrack"),YV),aF=(Jd(JV={},"publish",0),Jd(JV,"subscribe",0),Jd(JV,"pushtrack",0),Jd(JV,"unpublish",1),Jd(JV,"unsubscribe",1),Jd(JV,"removetrack",1),JV),sF=function(e){PI(r,e);var t=JI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Gs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==oF[t.action]||(n=t.streamId,rF.print("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;jD&&cP>=86&&cP<=92&&(t=Math.min(this._queue.length,5));for(var r=aF[this._queue[0].action],n=1;n<t;n++){var i;if(aF[this._queue[n].action]!==r)return{sdpStrategy:r,items:rT(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rT(e=this._queue).call(e,0,t)}}}]),r}($P),cF="object"==typeof global&&global&&global.Object===Object&&global,uF="object"==typeof self&&self&&self.Object===Object&&self,dF=cF||uF||Function("return this")(),lF=dF.Symbol,hF=Object.prototype,pF=hF.hasOwnProperty,vF=hF.toString,_F=lF?lF.toStringTag:void 0;var fF=Object.prototype.toString;var mF=lF?lF.toStringTag:void 0;function yF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":mF&&mF in Object(e)?function(e){var t=pF.call(e,_F),r=e[_F];try{e[_F]=void 0;var n=!0}catch(o){}var i=vF.call(e);return n&&(t?e[_F]=r:delete e[_F]),i}(e):function(e){return fF.call(e)}(e)}function gF(e){return null!=e&&"object"==typeof e}var SF=Array.isArray;function bF(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function EF(e){return e}function TF(e){if(!bF(e))return!1;var t=yF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var kF,IF=dF["__core-js_shared__"],RF=(kF=/[^.]+$/.exec(IF&&IF.keys&&IF.keys.IE_PROTO||""))?"Symbol(src)_1."+kF:"";var AF=Function.prototype.toString;function CF(e){if(null!=e){try{return AF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var wF=/^\[object .+?Constructor\]$/,xF=Function.prototype,OF=Object.prototype,DF=xF.toString,PF=OF.hasOwnProperty,MF=RegExp("^"+DF.call(PF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function NF(e){return!(!bF(e)||(t=e,RF&&RF in t))&&(TF(e)?MF:wF).test(CF(e));var t}function LF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return NF(r)?r:void 0}var UF=LF(dF,"WeakMap"),VF=Object.create,FF=function(){function e(){}return function(t){if(!bF(t))return{};if(VF)return VF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function BF(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var jF=Date.now;var GF,HF,zF,KF=function(){try{var e=LF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),XF=KF,WF=XF?function(e,t){return XF(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:EF,qF=(GF=WF,HF=0,zF=0,function(){var e=jF(),t=16-(e-zF);if(zF=e,t>0){if(++HF>=800)return arguments[0]}else HF=0;return GF.apply(void 0,arguments)}),YF=qF;var JF=/^(?:0|[1-9]\d*)$/;function QF(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&JF.test(e))&&e>-1&&e%1==0&&e<t}function ZF(e,t,r){"__proto__"==t&&XF?XF(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function $F(e,t){return e===t||e!=e&&t!=t}var eB=Object.prototype.hasOwnProperty;function tB(e,t,r){var n=e[t];eB.call(e,t)&&$F(n,r)&&(void 0!==r||t in e)||ZF(e,t,r)}function rB(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?ZF(r,s,c):tB(r,s,c)}return r}var nB=Math.max;function iB(e,t){return YF(function(e,t,r){return t=nB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=nB(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),BF(e,this,s)}}(e,t,EF),e+"")}function oB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function aB(e){return null!=e&&oB(e.length)&&!TF(e)}var sB=Object.prototype;function cB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||sB)}function uB(e){return gF(e)&&"[object Arguments]"==yF(e)}var dB=Object.prototype,lB=dB.hasOwnProperty,hB=dB.propertyIsEnumerable,pB=uB(function(){return arguments}())?uB:function(e){return gF(e)&&lB.call(e,"callee")&&!hB.call(e,"callee")},vB=pB;var _B="object"==typeof exports&&exports&&!exports.nodeType&&exports,fB=_B&&"object"==typeof module&&module&&!module.nodeType&&module,mB=fB&&fB.exports===_B?dF.Buffer:void 0,yB=(mB?mB.isBuffer:void 0)||function(){return!1},gB={};function SB(e){return function(t){return e(t)}}gB["[object Float32Array]"]=gB["[object Float64Array]"]=gB["[object Int8Array]"]=gB["[object Int16Array]"]=gB["[object Int32Array]"]=gB["[object Uint8Array]"]=gB["[object Uint8ClampedArray]"]=gB["[object Uint16Array]"]=gB["[object Uint32Array]"]=!0,gB["[object Arguments]"]=gB["[object Array]"]=gB["[object ArrayBuffer]"]=gB["[object Boolean]"]=gB["[object DataView]"]=gB["[object Date]"]=gB["[object Error]"]=gB["[object Function]"]=gB["[object Map]"]=gB["[object Number]"]=gB["[object Object]"]=gB["[object RegExp]"]=gB["[object Set]"]=gB["[object String]"]=gB["[object WeakMap]"]=!1;var bB="object"==typeof exports&&exports&&!exports.nodeType&&exports,EB=bB&&"object"==typeof module&&module&&!module.nodeType&&module,TB=EB&&EB.exports===bB&&cF.process,kB=function(){try{var e=EB&&EB.require&&EB.require("util").types;return e||TB&&TB.binding&&TB.binding("util")}catch(t){}}(),IB=kB&&kB.isTypedArray,RB=IB?SB(IB):function(e){return gF(e)&&oB(e.length)&&!!gB[yF(e)]},AB=Object.prototype.hasOwnProperty;function CB(e,t){var r=SF(e),n=!r&&vB(e),i=!r&&!n&&yB(e),o=!r&&!n&&!i&&RB(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!AB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||QF(u,c))||s.push(u);return s}function wB(e,t){return function(r){return e(t(r))}}var xB=wB(Object.keys,Object),OB=Object.prototype.hasOwnProperty;function DB(e){return aB(e)?CB(e):function(e){if(!cB(e))return xB(e);var t=[];for(var r in Object(e))OB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var PB=Object.prototype.hasOwnProperty;function MB(e){if(!bF(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=cB(e),r=[];for(var n in e)("constructor"!=n||!t&&PB.call(e,n))&&r.push(n);return r}function NB(e){return aB(e)?CB(e,!0):MB(e)}var LB,UB=(LB=function(e,t){rB(t,NB(t),e)},iB((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=LB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!bF(r))return!1;var n=typeof t;return!!("number"==n?aB(r)&&QF(t,r.length):"string"==n&&t in r)&&$F(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&LB(e,a,r,i)}return e}))),VB=LF(Object,"create");var FB=Object.prototype.hasOwnProperty;var BB=Object.prototype.hasOwnProperty;function jB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function GB(e,t){for(var r=e.length;r--;)if($F(e[r][0],t))return r;return-1}jB.prototype.clear=function(){this.__data__=VB?VB(null):{},this.size=0},jB.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},jB.prototype.get=function(e){var t=this.__data__;if(VB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return FB.call(t,e)?t[e]:void 0},jB.prototype.has=function(e){var t=this.__data__;return VB?void 0!==t[e]:BB.call(t,e)},jB.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=VB&&void 0===t?"__lodash_hash_undefined__":t,this};var HB=Array.prototype.splice;function zB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}zB.prototype.clear=function(){this.__data__=[],this.size=0},zB.prototype.delete=function(e){var t=this.__data__,r=GB(t,e);return!(r<0)&&(r==t.length-1?t.pop():HB.call(t,r,1),--this.size,!0)},zB.prototype.get=function(e){var t=this.__data__,r=GB(t,e);return r<0?void 0:t[r][1]},zB.prototype.has=function(e){return GB(this.__data__,e)>-1},zB.prototype.set=function(e,t){var r=this.__data__,n=GB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var KB=LF(dF,"Map");function XB(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function WB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function qB(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}WB.prototype.clear=function(){this.size=0,this.__data__={hash:new jB,map:new(KB||zB),string:new jB}},WB.prototype.delete=function(e){var t=XB(this,e).delete(e);return this.size-=t?1:0,t},WB.prototype.get=function(e){return XB(this,e).get(e)},WB.prototype.has=function(e){return XB(this,e).has(e)},WB.prototype.set=function(e,t){var r=XB(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var YB=wB(Object.getPrototypeOf,Object);function JB(e){var t=this.__data__=new zB(e);this.size=t.size}JB.prototype.clear=function(){this.__data__=new zB,this.size=0},JB.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},JB.prototype.get=function(e){return this.__data__.get(e)},JB.prototype.has=function(e){return this.__data__.has(e)},JB.prototype.set=function(e,t){var r=this.__data__;if(r instanceof zB){var n=r.__data__;if(!KB||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new WB(n)}return r.set(e,t),this.size=r.size,this};var QB="object"==typeof exports&&exports&&!exports.nodeType&&exports,ZB=QB&&"object"==typeof module&&module&&!module.nodeType&&module,$B=ZB&&ZB.exports===QB?dF.Buffer:void 0,ej=$B?$B.allocUnsafe:void 0;function tj(){return[]}var rj=Object.prototype.propertyIsEnumerable,nj=Object.getOwnPropertySymbols,ij=nj?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(nj(e),(function(t){return rj.call(e,t)})))}:tj;var oj=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)qB(t,ij(e)),e=YB(e);return t}:tj;function aj(e,t,r){var n=t(e);return SF(e)?n:qB(n,r(e))}function sj(e){return aj(e,DB,ij)}function cj(e){return aj(e,NB,oj)}var uj=LF(dF,"DataView"),dj=LF(dF,"Promise"),lj=LF(dF,"Set"),hj="[object Map]",pj="[object Promise]",vj="[object Set]",_j="[object WeakMap]",fj="[object DataView]",mj=CF(uj),yj=CF(KB),gj=CF(dj),Sj=CF(lj),bj=CF(UF),Ej=yF;(uj&&Ej(new uj(new ArrayBuffer(1)))!=fj||KB&&Ej(new KB)!=hj||dj&&Ej(dj.resolve())!=pj||lj&&Ej(new lj)!=vj||UF&&Ej(new UF)!=_j)&&(Ej=function(e){var t=yF(e),r="[object Object]"==t?e.constructor:void 0,n=r?CF(r):"";if(n)switch(n){case mj:return fj;case yj:return hj;case gj:return pj;case Sj:return vj;case bj:return _j}return t});var Tj=Ej,kj=Object.prototype.hasOwnProperty;var Ij=dF.Uint8Array;function Rj(e){var t=new e.constructor(e.byteLength);return new Ij(t).set(new Ij(e)),t}var Aj=/\w*$/;var Cj=lF?lF.prototype:void 0,wj=Cj?Cj.valueOf:void 0;function xj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return Rj(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?Rj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?Rj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,Aj.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,wj?Object(wj.call(n)):{}}}var Oj=kB&&kB.isMap,Dj=Oj?SB(Oj):function(e){return gF(e)&&"[object Map]"==Tj(e)};var Pj=kB&&kB.isSet,Mj=Pj?SB(Pj):function(e){return gF(e)&&"[object Set]"==Tj(e)},Nj="[object Arguments]",Lj="[object Function]",Uj="[object Object]",Vj={};function Fj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!bF(e))return e;var d=SF(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&kj.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=Tj(e),h=l==Lj||"[object GeneratorFunction]"==l;if(yB(e))return function(e,t){if(t)return e.slice();var r=e.length,n=ej?ej(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==Uj||l==Nj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||cB(e)?{}:FF(YB(e))}(e),!s)return c?function(e,t){return rB(e,oj(e),t)}(e,function(e,t){return e&&rB(t,NB(t),e)}(a,e)):function(e,t){return rB(e,ij(e),t)}(e,function(e,t){return e&&rB(t,DB(t),e)}(a,e))}else{if(!Vj[l])return i?e:{};a=xj(e,l,s)}}o||(o=new JB);var p=o.get(e);if(p)return p;o.set(e,a),Mj(e)?e.forEach((function(n){a.add(Fj(n,t,r,n,e,o))})):Dj(e)&&e.forEach((function(n,i){a.set(i,Fj(n,t,r,i,e,o))}));var v=d?void 0:(u?c?cj:sj:c?NB:DB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),tB(a,i,Fj(n,t,r,i,e,o))})),a}Vj[Nj]=Vj["[object Array]"]=Vj["[object ArrayBuffer]"]=Vj["[object DataView]"]=Vj["[object Boolean]"]=Vj["[object Date]"]=Vj["[object Float32Array]"]=Vj["[object Float64Array]"]=Vj["[object Int8Array]"]=Vj["[object Int16Array]"]=Vj["[object Int32Array]"]=Vj["[object Map]"]=Vj["[object Number]"]=Vj[Uj]=Vj["[object RegExp]"]=Vj["[object Set]"]=Vj["[object String]"]=Vj["[object Symbol]"]=Vj["[object Uint8Array]"]=Vj["[object Uint8ClampedArray]"]=Vj["[object Uint16Array]"]=Vj["[object Uint32Array]"]=!0,Vj["[object Error]"]=Vj[Lj]=Vj["[object WeakMap]"]=!1;function Bj(e){return Fj(e,5)}function jj(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function Gj(e){return null==e?[]:jj(e,DB(e))}var Hj,zj,Kj=new yO("ChromeHandler",3),Xj=iL(),Wj=function(e){PI(u,e);var t,r,n,i,o,a,s,c=JI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new sF,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(Kj.print("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(wI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N,L,U,V,F;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(wI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,_=h.audioTransceiverInit,f=h.videoTransceiverInit,m=VL(this._nextSsrc),this._nextSsrc=m.next,y="".concat(this._mid++),g="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:FL(d.id,"audio",m.audio,LL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(Kj.print("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(T=BL(d.id,m,{cname:LL}),k=T.ssrcs,I=T.ssrcGroups,b.ssrcs=k,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=JR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(w=rT(C=S.rtp).call(C,A,1),x=eI(w,1),O=x[0],S.rtp.unshift(O)),D=[],S.rtp.forEach((function(e){return D.push(e.payload)})),S.payloads=D.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&YL(b,null===(P=this._context)||void 0===P||null===(M=P.serverConfig)||void 0===M?void 0:M.videoCodec),(BD||QD)&&Array.isArray(b.ext)&&(b.ext=Gs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mT(t).call(t,"video-orientation"))}))),(L=null==S?void 0:gE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=gE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||BD||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:GL(this.peer._offerSession,S,b),audioMid:y,videoMid:g,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:_,videoTransceiverInit:f,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N,L,U,V=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Kj.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=Zd(Zd({},Bj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),d&&(v=Zd(Zd({},Bj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,f={track:"video",init:{direction:"recvonly"}}),m=GL(this.peer._offerSession,p,v),y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return y=VL(this._nextSsrc),this._nextSsrc=y.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",y.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(T="".concat(t.streamId)).call(T,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},BL(t.streamId,y,{flexfec:this._enableSubFlexfec})),C=new Yf((function(e){V._sdpQueue.enqueue({action:iF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:_,videoTransceiverInit:f,signalingAck:{sdp:pL.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){Kj.print("subscribe()","sub success"),e(0)}})})),e.next=31,C;case 31:null===(I=y)||void 0===I||delete I.next;case 32:return(w=null===(n=p)||void 0===n?void 0:gE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(D=null===(x=p)||void 0===x?void 0:gE(O=x.fmtp).call(O,(function(e){return e.payload===w.payload})))&&this._context&&(D.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&cP>=86&&null!=(L=null===(P=v)||void 0===P?void 0:Gs(M=P.rtp).call(M,(function(e){return"H264"===e.codec})))&&L.length&&null!==(N=v)&&void 0!==N&&N.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){gE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:_,videoTransceiverInit:f,allSsrc:y,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Kj.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return Kj.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),Kj.print("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==nF.ADD){e.next=15;break}return e.delegateYield(km().mark((function e(){var t,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},f.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=hM(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof tF;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var p,v={},_={},m=pL.parse(d.sdp);Array.isArray(m.media)&&jR(p=m.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(v=n).mid=e:(_=n).mid=r}));var y,g=l.streamId;if(s===iF.publish&&(g=null===(y=l.stream)||void 0===y?void 0:y.id),!f._mlinesCache[g])return"break";var S=eI(f._mlinesCache[g],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=f._peerConnection.addTransceiver(c.track,c.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({audioStreamTrack:AD(c.track)}));var T=f._inactiveMlineIndex.shift();T||(T=f.peer._offerMlines.length),f.peer._offerMlines[T]=Zd({},b),f.peer._answerMlines[T]=v,Xj&&l.initAudioEncodedTransform()}if(u&&E){var k,I;l.videoTransceiver=f._peerConnection.addTransceiver(u.track,u.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({videoStreamTrack:AD(u.track)}));var R,A,C=f._inactiveMlineIndex.shift();C||(C=f.peer._offerMlines.length),f.peer._offerMlines[C]=Zd({},E),s===iF.publish&&null!==(k=f._context)&&void 0!==k&&null!==(I=k.serverConfig)&&void 0!==I&&I.videoCodec&&YL(_,null===(R=f._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),f.peer._answerMlines[C]=_,Xj&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete f._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:_={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;_[t]=t,n!==iF.removetrack&&(_[r]=r),_[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return _[e.mid]&&(e=jL(e),f._inactiveMlineIndex.push(t)),e})),jR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=jm(v=this.peer._answerMlines).call(v,(function(e){return _[e.mid]&&(e=jL(e)),e}));case 20:return e.next=22,this.peer.getOriginRTCPeerConnection().createOffer();case 22:return e.next=24,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 24:try{a.forEach((function(e){return e()}))}catch(FW){}Kj.print("dequeue","loop"),e.next=31;break;case 28:e.prev=28,e.t1=e.catch(6),Kj.print("dequeue","unknown error: %o",e.t1);case 31:return e.prev=31,this.dequeue(),e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[6,28,31,34]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=pL.parse(r),i=[],n.media=Gs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Gs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:pL.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){if(e.icePwd=t.peer._offerIce.icePwd,e.iceUfrag=t.peer._offerIce.iceUfrag,"audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Gs(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=Gs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,SD(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new vA(hA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(QL),qj=new yO("FirefoxHandler",3),Yj=function(e){PI(d,e);var t,r,n,i,o,a,s,c,u=JI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_,f,m=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(wI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:aD()-u}),(h=pL.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(pL.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,_=null,f=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=_=e)||void 0===t?void 0:gE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&_.fmtp){var i,o,a=gE(i=_.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&YL(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),f=e}return e})),this.addBitrateLimit(f,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(pL.write(h));case 21:return e.abrupt("return",{partialSdp:GL(h,_,f,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return _=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-v}),(f=pL.parse(_.sdp)).media=null===(n=f.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=f.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(pL.write(f),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=VL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},BL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(k=m)||void 0===k||delete k.next;case 36:return e.abrupt("return",{partialSdp:GL(f,h,p,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==iF.unpublish&&i!==iF.unsubscribe&&i!==iF.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return qj.print("already set remote"),e.abrupt("return","");case 8:return o=pL.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=pL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof eF&&iP<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Gs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Gs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Gs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Gs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=pL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})),iP>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Gs(n).call(n,(function(e){var t;return!mT(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(pL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(km().mark((function e(){var t,r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=pL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Gs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:pL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(km().mark((function e(t,r,n){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=pL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=jL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=pL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(pL.write(u));case 17:return e.next=19,this.setRemoteDescription(pL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(QL),Jj=new yO("FallbackHandler",3),Qj=function(e){PI(d,e);var t,r,n,i,o,a,s,c,u=JI(d);function d(e,t){var r;return Vl(this,d),Jd(tI(r=u.call(this,e,t)),"name","fallback"),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jj.print("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return Ul(d,[{key:"publish",value:(c=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=OI(wI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:aD()-c}),l=pL.parse(u.sdp),e.next=12,this.setLocalDescription(u.sdp);case 12:return h=t.audioTransceiver.mid,p=t.videoTransceiver.mid,v=null,_=null,l.media=null===(r=l.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===p&&(_=e),e})),iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:GL(l,v,_,!1),audioMid:h,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Jj.print("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-h}),v=pL.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,_=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return _=VL(this._nextSsrc),this._nextSsrc=_.next,T=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Om(f=Om(m="".concat(t.streamId)).call(m,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(f,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",_.audio)}),k=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call(g,t.streamId,"-video")},BL(t.streamId,_,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([T,k],t);case 33:null===(E=_)||void 0===E||delete E.next;case 34:return iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:GL(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:_,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==iF.unpublish&&i!==iF.unsubscribe&&i!==iF.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return Jj.print("already set remote"),e.abrupt("return","");case 8:return o=pL.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=pL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=pL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(pL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(km().mark((function e(){var t,r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=pL.parse(null===(t=this._peerConnection.localDescription)||void 0===t?void 0:t.sdp),this.createAVMlineOfferTpl(null===(r=this._peerConnection.localDescription)||void 0===r?void 0:r.sdp),o=[],i.media=Gs(n=i.media).call(n,(function(e){return"recvonly"===e.direction&&(e.mid=e.mid+1,o.push("".concat(e.mid)),!0)})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:pL.write(i),semantics:"unified-plan",type:"incroffer"});case 6:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(km().mark((function e(t,r,n){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Jj.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Jj.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=pL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=jL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=pL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(pL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(QL),Zj=function(e,t){return e.enableFallbackHandler?new Qj(e,t):FD?new Yj(e,t):new Wj(e,t)},$j=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}($j||{}),eG=function(e){return e.PushLimitWarn="PushLimitWarn",e}(eG||{}),tG=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(tG||{}),rG=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(rG||{}),nG=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(nG||{}),iG=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(iG||{}),oG=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(oG||{}),aG=new yO("Locker",2),sG=1,cG=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Yf.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=sG++,t&&(this.name=t),aG.print(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,aG.print(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Yf((function(e){r=function(){var t,r;n.locks-=1,aG.print(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),uG=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(uG||{}),dG=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(dG||{}),lG=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(lG||{}),hG=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(hG||{}),pG=(Jd(Hj={},bl.communication,[0]),Jd(Hj,bl.chat,[0]),Jd(Hj,bl.chatRoom,[1,"IES_chatroom"]),Jd(Hj,bl.coHost,[1,"IES_PK"]),Jd(Hj,bl.meeting,[16]),Jd(Hj,bl.classRoom,[0]),Hj),vG=iL(),_G=function(e){PI(s,e);var t,r,n,i,o,a=JI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",oD()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(km().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(wI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),vG&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=aD(),d=pL.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=p._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&YL(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(BD||QD)&&Array.isArray(e.ext)&&(e.ext=Gs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mT(t).call(t,"video-orientation"))}))),BD||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:gE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=gE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=p._context)&&void 0!==d&&d.audioProfileManager&&(l.config=p._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:pL.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:aD()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:aD()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),vG&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=aD(),i=pL.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:gE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:gE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:pL.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==iF.publish&&t.action!==iF.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=aD(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:aD()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:aD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==iF.unpublish&&t.action!==iF.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(wI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(QL),fG=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e}(fG||{}),mG={start_interval:100,multiplier:2,max_interval:3e4},yG=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",mG),Jd(this,"initTs",aD())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),gG=new yO("ICERequest",4),SG=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",oD()),Jd(this,"_retryLimiter",new yG),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=PO(t.id)}var t,r,n,i;return Ul(e,[{key:"getICENode",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gG.print("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new vA(hA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return gG.print("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&gG.print("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Yf((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(JR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();gG.print("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(n=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,n){var i=mP.getAccessNode(r._ctx.appId);i?(gG.print("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(r=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&mP.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&mP.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),mP.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=mP.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=kP.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=kP.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=oD(),o={appID:this._ctx.appId,deviceID:mP.getDeviceId(),connectSessionID:i,os:"web",sdkVersion:kP.VERSION,isOversea:kP.OVERSEA,expectedAddr:RP("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Nm({requireICEUfragV2:!0})},r&&(o.feedbackInfo=r,delete o.expectedAddr),a=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Nm(o),elapse:0,type:"request",host:t.join(","),config_id:i,group_config_id:this._groupConfigId}),s=jm(t).call(t,function(){var e=Rm(km().mark((function e(t,r){var n,i,a,s,u;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=new AbortController,c._abortControllers.push(i),e.prev=2,e.next=5,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Nm(o),signal:i.signal});case 5:a=e.sent,e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(2),sC(fetch)||null===(s=c._monitor)||void 0===s||s.report("rtc_error",{error_code:fG.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 12:if(c._abortControllers=Gs(n=c._abortControllers).call(n,(function(e){return e!==i})),200===a.status){e.next=15;break}throw{message:a.statusText,code:a.status};case 15:return e.next=17,a.json();case 17:if(200===(u=e.sent).code){e.next=20;break}throw u;case 20:if(0!==u.nodes.length){e.next=22;break}throw{code:u.code,message:Nm(u)};case 22:return e.abrupt("return",{url:t,result:u});case 23:case"end":return e.stop()}}),e,null,[[2,8]])})));return function(t,r){return e.apply(this,arguments)}}()),e.abrupt("return",bD(s).then((function(e){var t,r=e.result,n=e.url;return null===(t=c._monitor)||void 0===t||t.report("rtc_get_access",{error_code:200,message:Nm(r),elapse:Date.now()-a,type:"response",host:n,config_id:i,group_config_id:c._groupConfigId}),r})).catch((function(e){var r,n,o,s;throw null===(r=c._monitor)||void 0===r||r.report("rtc_get_access",{error_code:+((null===(n=e[0])||void 0===n?void 0:n.code)||(null===(o=e[0])||void 0===o?void 0:o.server_code)),message:null===(s=e[0])||void 0===s?void 0:s.message,elapse:Date.now()-a,type:"response",host:t.join(","),config_id:i,group_config_id:c._groupConfigId},{error:Nm(e)}),e})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),bG={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan",encodedInsertableStreams:!!iL()||void 0},EG=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(EG||{}),TG=0,kG=function(e){PI(s,e);var t,r,n,i,o,a=JI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this)),"uuid",(TG++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new yO("PeerConnection_".concat(r.uuid),4)),r._ctx=e,r._groupConnectionId=t,r._monitor=PO(e.id),r._ctx.enableFallbackHandler&&r._logger.print("ctor","PeerConnection running in fallback mode"),r._pc=new RTCPeerConnection(bG),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(s,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(o=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=6,this._genIceInfo(t);case 6:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,FD&&iP<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=14,this._pc.createOffer();case 14:if((o=e.sent).sdp){e.next=17;break}throw new vA(hA.NOT_SUPPORTED,"create offer sdp failed.");case 17:if(a=pL.parse(o.sdp),this._peerConnectionId=i.iceUfrag||"",(s=!n.iceUfrag&&!n.icePwd)&&((l="renomination"===(null===(c=a.media[0])||void 0===c?void 0:c.iceOptions))||(delete n.iceOptions,delete i.iceOptions),delete n.iceUfrag,delete n.icePwd,h=qL({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=a.media[0])||void 0===u?void 0:u.icePwd,options:(d={},Jd(d,WL.kICEConfigTypeSrtpDtlsType,!0),Jd(d,WL.kICEConfigTypeRenominationType,l),d)}),p=eI(h,2),v=p[0],_=p[1],this._peerConnectionId=_,i.iceUfrag=v,this._logger.print("use serverUfrag v2",Nm({dtls:!0,renomination:l}))),f=eI(a.media,1),m=f[0],this._offerIce.fingerprint=a.fingerprint||m.fingerprint,!FD&&!this._ctx.enableFallbackHandler){e.next=39;break}if(a.media=jm(y=a.media).call(y,(function(e){var t,r,n=Zd(Zd({},e),b._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Gs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Gs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(S=Zd({},a)).fingerprint=this._answerIce.fingerprint,S.media=jm(g=S.media).call(g,(function(e){return delete(e=Zd(Zd({},e),b._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=33;break}return e.next=31,this.setLocalDescription(o.sdp);case 31:e.next=35;break;case 33:return e.next=35,this.setLocalDescription(pL.write(a));case 35:return e.next=37,this.setRemoteDescription(pL.write(S));case 37:e.next=48;break;case 39:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),s&&(this._offerIce.iceUfrag=m.iceUfrag,this._offerIce.icePwd=m.icePwd),this._offerMlines=[Zd(Zd(Zd({},m),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},m),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 48:return e.next=50,new Yf((function(e,t){b._connectReject=t,b._dc.onopen=function(){b._print("connect","dataChannel open"),b._reportRtcInvokeStatus("es.dc.open",""),e(""),delete b._connectReject},b._dc.onerror=function(e){var t,r;b._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),b._reportRtcInvokeStatus("es.dc.error",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),b.emit("disconnect","dc onerror"),delete b._connectReject},b._dc.onclose=function(e){var t;b._reportRtcInvokeStatus("es.dc.close",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onclose",code:1}),b.emit("disconnect","dc onclose"),delete b._connectReject},b._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==b._pc.iceConnectionState&&"closed"!==b._pc.iceConnectionState&&"failed"!==b._pc.connectionState||(null===(t=b._connectReject)||void 0===t||t.call(b,{message:Om(r="pc.connectionstatechange -> ".concat(b._pc.connectionState,", ice -> ")).call(r,b._pc.iceConnectionState),code:2}),delete b._connectReject)})),setTimeout((function(){var e;null===(e=b._connectReject)||void 0===e||e.call(b,{code:4,message:"connect timeout"}),delete b._connectReject}),8e3)}));case 50:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 52:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=aD(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:aD()-n}),e.next=11,this.setLocalDescription(pL.write(this._offerSession),t);case 11:return e.next=13,this.setRemoteDescription(pL.write(this._answerSession),t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=aD(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:aD()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=aD(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(wI(s.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,HL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).print.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Nm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new vA(hA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new vA(hA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),s}(tM);function IG(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var RG=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(RG||{}),AG=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(AG||{}),CG=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.EXCEED_QPS=5]="EXCEED_QPS",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(CG||{}),wG=(Jd(zj={},0,[0,"success"]),Jd(zj,1,[hA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(zj,2,[hA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(zj,3,[hA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(zj,4,[hA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(zj,5,[hA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(zj,17,[hA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(zj,18,[hA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(zj,100,[hA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(zj,105,[hA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(zj,106,[hA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(zj,1e3,[hA.USER_MESSAGE_UNKNOWN,"unknown."]),zj),xG=["msg"],OG=new yO("DataChannelSignaling",3),DG=[],PG=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(PG||{}),MG=function(e){PI(a,e);var t,r,n,i,o=JI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=PO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new vA(hA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Nm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Yf((function(n,a){var s,c=i._genHeader(r);c.id=uD();var u=c.id.join("-"),d="customMessage"===e;d&&TO.samplingOne2ManyMsg(i.id,+c.id.join(""),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new vA(hA.TIME_OUT,"".concat(e," message time out"))),d&&TO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&TO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&TO.updateOne2ManyMsgAck(i.id,t,e.code)}}),OG.print("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=IG(t,xG),o=n instanceof ArrayBuffer,e.t0=this,e.t1=TO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:RG.SEND,type:AG.P2P,err:CG.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,cD.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return lD(e.msg)?this._rttIds[e.id]=e.id:e.dir===RG.SEND&&OG.print("_sendP2PMessage [DC Signaling p2p >>]",Nm(e)),new Yf((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:uD()}));if(e.dir===RG.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new vA(hA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),TO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),TO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),TO.updateP2PMsgAck(t.id,e,r.err);var o=eI(wG[r.err]||[hA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===hA.NOT_CONNECTED_YET&&(s.code=hA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new vA(hA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=cD.str2ab(Nm([e,r])),s=sD(Uint8Array,Om(n=[i,o]).call(n,JT(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?TO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&TO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qT(Tm(t).call(t,2,r))}return{header:o,data:Tm(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return+e}))});mT(DG).call(DG,t)||OG.print("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new Fx.Inflate).push(o,!0),o=s.result),c=cD.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(km().mark((function e(t,r,n,i,o){var a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mT(DG).call(DG,u)||OG.print("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===tG.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,cD.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===tG.ON_CUSTOM_MESSAGE&&TO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===RG.FEEDBACK||lD(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:OG.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===RG.SEND?6:e.t0===RG.FEEDBACK?46:48;break;case 6:if(u=Date.now(),lD(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,_=d.from,f=""===p?l?tG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:tG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?tG.USER_BINARY_MESSAGE_RECEIVED:tG.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=tG.ON_CUSTOM_MESSAGE,e.t3=_,e.t4=l,!l){e.next=21;break}return e.next=18,cD.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=f,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,cD.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:RG.FEEDBACK,msg:""})),TO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(_){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(_){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(_){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){OG.print("_handleHandler","dataChannel close",e)},r=function(e){OG.print("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),OG.print("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===CG.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(ZP.exports.EventEmitter),NG=new yO("ConnectionManager",3),LG=function(e){PI(o,e);var t,r,n,i=JI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,NG.print("constructor","invoke"),t.id=e.id,t._monitor=PO(t.id),t._getAccessManager=new SG(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;NG.print("connect","invoke");try{kG.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Yf.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:NG.print("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Nm(t),reason:Nm(a)}),mP.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(km().mark((function e(t){var r,n=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],NG.print("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){NG.print("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new vA(hA.OPERATION_CANCEL,"destroy")),OI(wI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){NG.print("_startIceConnect","invoke");var n=oC();this._preIceStartTime=aD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(km().mark((function e(i){var o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=Bj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new kG(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new MG(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(NG.print("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=Bj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(NG.print("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(NG.print("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==EG.DESTROY&&t.code!==hA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),NG.print("connect","remove cache node"),mP.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(NG.print("connect","establish peerConnection failed"),this._checkBrowserUA(),aD()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),NG.print("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:fG.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;NG.print("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=oC();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(NG.print("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(NG.print("_onConnectEnded","use tcp only"),LO(this._ctx.id,"connected_with_tcp_only",Nm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(tM),UG=ad,VG=tc,FG=function(e,t,r,n){for(var i,o=n>1?void 0:n?VG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&UG(t,r,o),o},BG=new yO("MediaServerClient",2),jG=6e4,GG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(GG||{}),HG=function(e,t){BG.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},zG=function(e){PI(k,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T=JI(k);function k(e){var t;return Vl(this,k),Jd(tI(t=T.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),BG.print("constructor","invoke"),t.id=e.id,t._monitor=PO(t.id),t._pubSubLock=new cG("pubSubLock"),t._joinLeaveLock=new cG("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new LG(e),t._addConnectHandler(),t}return Ul(k,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[tG.ON_ADD_STREAM,tG.ON_ADD_STREAM_LIST,tG.ON_REMOVE_STREAM,tG.ON_REMOVE_STREAM_LIST,tG.USER_CONNECTION,tG.USER_CONNECTION_LIST,tG.USER_DISCONNECTION,tG.USER_DISCONNECTION_LIST,tG.ON_UPDATE_STREAM_ATTRIBUTES,tG.ON_UPDATE_ROOM_ATTRIBUTES,tG.ON_PUSH_TRACK,tG.ON_REMOVE_TRACK,tG.ON_CUSTOM_MESSAGE,tG.USER_MESSAGE_RECEIVED,tG.USER_BINARY_MESSAGE_RECEIVED,tG.POST_PROCESSING_MESSAGE,tG.ON_USER_TOKEN_WILL_EXPIRE,tG.STREAM_CONTROL_MESSAGE,tG.ON_UPDATE_USER_ATTRIBUTES,tG.ON_SPEAKER_CHANGE,rG.RSCP,rG.RTT,tG.ON_STREAM_FAILED,tG.ON_NOTIFY_RECONNECT,rG.SSC,tG.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(tG.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(tG.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(nG.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.print("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Yf((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Yf.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,y=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.length>0&&void 0!==y[0]&&y[0],BG.print("_callJoinRoom","invoke"),e.t0=cD.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,WN();case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=kP.VERSION,e.t9=mP.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=pG[this._roomProfile]?pG[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Nm({requireICEUfragV2:!0}),n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},Yf.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=27,o=r?"reconnected":"joinRoom",e.next=31,this._joinRoomWithRetry(o,n);case 31:a=e.sent,BG.print("join","send join message success"),s=a.config||{},c=s.engine_WEB,this._authorization=n.Authorization,mP.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(FD||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(p=a.config)||void 0===p||null===(v=p.vendor_param)||void 0===v?void 0:v.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),qV.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=47;break;case 44:e.prev=44,e.t19=e.catch(27),(null===e.t19||void 0===e.t19?void 0:e.t19.code)>=700&&(null===e.t19||void 0===e.t19?void 0:e.t19.code)<800?this._joinRoomFailed("token_error",hA.INVALID_TOKEN):(null===e.t19||void 0===e.t19?void 0:e.t19.code)===hA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(f="joinRoom timeout, retry with tcp only",BG.print("join",f),this.safeEmit(uG.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(f,!0)):e.t19.code===hA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||"signaling_error");case 47:case"end":return e.stop()}}),e,this,[[27,44]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=aD(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return k=new kG(this._context,""),t.vendorHandler=new _G(this._context,k),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:T=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){N.emit(nG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:N._clientId})})),k.once("disconnect",Rm(km().mark((function e(){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=N._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return BG.print("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),N.unpublish(t),N.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(I=this._handler)||void 0===I?void 0:I.publish(t);case 22:T=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),T){e.next=26;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,eL();case 29:if(e.sent){e.next=32;break}throw new vA(hA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=T.audioMid,a=T.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof cV),extaudio:!!(n instanceof uV)},R={attributes:Zd({videoDescriptions:T.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:T.type,sdp:T.partialSdp,semantics:T.semantics},peerConnectionMode:null===(l=T)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(A=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(p=h.serverConfig)||void 0===p?void 0:p.simulcastOnDemand)&&(null===(v=T.subVideoDescriptions)||void 0===v?void 0:v.length))&&(R.attributes.subVideoDescriptions=T.subVideoDescriptions),null!==(_=T)&&void 0!==_&&_.peerConnectionId&&(R.peerConnectionId=T.peerConnectionId),e.next=41,null===(f=this._dataChannelSignal)||void 0===f?void 0:f.sendSignaling("publish",R);case 41:if(200===(null==(C=e.sent)?void 0:C.code)){e.next=44;break}throw new vA(hA.PUBLISH_FAILED,(null==C?void 0:C.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==C?void 0:C.relayMessage.type,sequence_id:(null==C||null===(y=C.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==C||null===(g=C.relayMessage)||void 0===g?void 0:g.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),w=new Yf((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:iF.publish,streamId:C.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=T)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=T)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==C||null===(u=C.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==C||null===(d=C.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=T)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){BG.print("publish()","publish success"),e(0)}})})),"chrome"!==(null===(b=this.handler)||void 0===b?void 0:b.name)){e.next=49;break}return e.next=49,w;case 49:return A&&this.emit(rG.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=C.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=T.subVideoDescriptions,null===(E=this._monitor)||void 0===E||E.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 58:return e.prev=58,e.t0=e.catch(7),e.t0 instanceof Error?null===(O=this._monitor)||void 0===O||O.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(D="".concat(e.t0.name,": ")).call(D,e.t0.message)}):e.t0 instanceof vA&&(null===(P=this._monitor)||void 0===P||P.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(M="".concat(e.t0.code,": ")).call(M,e.t0.message)})),e.next=63,null===(x=s)||void 0===x?void 0:x.rollback(t.stream.id,t);case 63:throw e.t0;case 64:case"end":return e.stop()}}),e,this,[[7,58]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:BG.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=t.vendorHandler||this.handler,u=null==o?void 0:o.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),s&&d?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(d):null===(h=t.videoTransceiver)||void 0===h||h.sender.replaceTrack(null),null==c||c.updateMaxBitrate(t),a&&u?(v=o.mixType,(_=o.mixedAudioTrack)&&v!==Dl.PLAYOUT&&!0===u.enabled&&(u=_),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(u)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),LO(this.id,"MediaClient.updatePubTrack(audio)","null"));try{LO(this.id,"MediaClient.updatePubTrack",Nm({audioStreamTrack:AD(u),videoStreamTrack:AD(d)}))}catch(FW){}for(y={},g=0,S=TA(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof cV),extaudio:!!(o instanceof uV)});g<S.length;g++)b=eI(S[g],2),E=b[0],(T=b[1])!==dI(t.pubAttributes,E)&&dM(y,E,T);if(an(y).length){e.next=14;break}return e.abrupt("return");case 14:return t.observer&&(k=t.observer,I=y.audiostream,R=y.videostream,A=y.localaudio,C=y.localvideo,w=y.extaudio,x=y.extvideo,void 0!==C?void 0!==x?k.setPushVideo(x):k.setEnableVideo(C):void 0!==R&&k.setUnmuteVideo(R),void 0!==A?void 0!==w?k.setPushAudio(w):k.setEnableAudio(A):void 0!==I&&k.setUnmuteAudio(I)),t.pubAttributes=m,O={roomId:this._roomId,streamId:t.streamId,attributes:y},e.next=19,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",O);case 19:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=22;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==D?void 0:D.message)||"update track failed");case 22:if("chrome"===(null===(n=this.handler)||void 0===n?void 0:n.name)){e.next=25;break}return e.next=25,null==c?void 0:c.setCurrentDescription();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(y=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new vA(hA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new vA(hA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.print("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:iF.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(f=Rm(km().mark((function e(t,r,n){var i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf(function(){var e=Rm(km().mark((function e(o,a){var s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==$V.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,hG.SUB).then(o,a));case 2:if(t.streamState!==$V.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),BG.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if(BG.print("subscribe()","mediaType: %o",r),HG("subscribe()",t),t.streamState=$V.SUB_ING,c=!1,u=!1,TD(r)&&(u=!0),kD(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=$V.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=aD(),l=t.subVideo,h=[],p=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),jG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(BG.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p&&h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),jG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(BG.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",v),i._ontrackCallbackMap.set(t,v),_=i._handler,e.prev=28,null!==(f=i._context.serverConfig)&&void 0!==f&&f.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new kG(i._context,""),t.vendorHandler=new _G(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(_=t.vendorHandler).on("ontrack",v),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,_.on("ice_state",(function(e){i.emit(nG.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(km().mark((function e(){var r,n,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=_)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return BG.print("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(uG.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(_),U){e.next=48;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,G={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},H={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(y=U)||void 0===y?void 0:y.partialSdp,semantics:null===(g=U)||void 0===g?void 0:g.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:G},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(H.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(H.config.fallbackOption=K),X.has(t.userId)&&(H.config.priority=X.get(t.userId)),null!==(T=U)&&void 0!==T&&T.allSsrc&&(H.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(k=i._dataChannelSignal)||void 0===k?void 0:k.sendSignaling("subscribe",H);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new vA(hA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,BG.print("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=$V.SUB_ED,t.subLayer=G,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sequenceId)||0,message:null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=_)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=_)||void 0===O?void 0:O.handleAck({action:iF.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(D=U)||void 0===D?void 0:D.audioTransceiverInit,videoTransceiverInit:null===(P=U)||void 0===P?void 0:P.videoTransceiverInit,signalingAck:{sdp:null==W||null===(M=W.relayMessage)||void 0===M?void 0:M.sdp,sequenceId:null==W||null===(N=W.relayMessage)||void 0===N?void 0:N.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Yf.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),_),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=$V.INIT,e.next=90,null===(Z=_)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){BG.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else BG.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(_=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"updateUserAttributes",value:(v=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubTrack",value:(p=Rm(km().mark((function e(t,r,n){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return BG.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(km().mark((function e(t,r){var n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return BG.print("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("updateSubTrack()","mediaType: %o",r),HG("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return BG.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===hG.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),BG.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&BG.print("updateSubTrack","mediaType no change"),s=!1,c=!1,TD(a)&&(c=!0),kD(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return BG.print("subscribe4pushTrack()","streamInfo: %o",r),HG("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Yf((function(e,r){var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),jG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(BG.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:iF.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Yf.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HG("unsubscribe4removeTrack()",t),BG.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return BG.print("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:iF.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(km().mark((function e(t,r){var n,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],HG("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!kD(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==NV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,hG.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(km().mark((function e(t,r){var n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,hG.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=$V.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:iF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),BG.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HG("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==$V.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(km().mark((function e(){var t,r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(BG.print("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Yf.reject(new vA(hA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=aD(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,WN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=kP.VERSION,e.t8=mP.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Yf((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),jG);t.on("ontrack",(function r(i){"video"===i.mediaType&&(BG.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Yf((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),jG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&(BG.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),_=null==h?void 0:h.relayMessage,f=_.sequenceId,m=_.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=f,t.streamState=$V.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:iF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:f},stream:t});case 44:return e.next=46,Yf.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return y.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return HG("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=$V.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:iF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;BG.print("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Yf((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new yG,a.code>=500&&a.code<600&&aD()-r.initTs<6e4){var s,c=r.getRetryDelay();return BG.print("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.connectionState="connected",BG.print("connectStateChange","connected"),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=Zj(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",BG.print("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(uG.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",BG.print("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",BG.print("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(uG.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=aD(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:aD()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new vA(t||hA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:cD.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),k}(tM);function KG(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var r,i,o,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new vA(hA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function XG(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var t,r,i,o,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}FG([function(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var t,r,i,o,a=this,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Yf(function(){var e=Rm(km().mark((function e(t,i){var s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new vA(hA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],zG.prototype,"join",1),FG([XG,KG],zG.prototype,"publish",1),FG([XG,KG],zG.prototype,"updatePubTrack",1),FG([XG,KG],zG.prototype,"unpublish",1),FG([XG,KG],zG.prototype,"subscribe",1),FG([KG],zG.prototype,"controlMessage",1),FG([KG],zG.prototype,"updateUserAttributes",1),FG([KG],zG.prototype,"updateSubTrack",1),FG([KG],zG.prototype,"updateSubTrackLayer",1),FG([KG],zG.prototype,"updateSubPriority",1),FG([XG,KG],zG.prototype,"subscribe4pushTrack",1),FG([XG,KG],zG.prototype,"unsubscribe4removeTrack",1),FG([XG,KG],zG.prototype,"unsubscribe",1),FG([KG],zG.prototype,"handleRemoveStream",1),FG([XG],zG.prototype,"subscribePublicStream",1),FG([XG],zG.prototype,"unsubscribePublicStream",1);var WG,qG=function(){var e=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,y;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=gE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,dL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==_?void 0:_.bytesReceived,framesReceived:null==_?void 0:_.framesReceived,packetsReceived:null==_?void 0:_.packetsReceived,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),YG=function(){var e=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,y;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=gE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,dL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==_?void 0:_.bytesSent,framesSent:null==_?void 0:_.framesSent,packetsSent:null==_?void 0:_.packetsSent,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),JG=new yO("RecvFrameObserver",0),QG=function(e){PI(a,e);var t,r,n,i,o=JI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",dD()),Jd(tI(r),"_videoEventSessionId",dD()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=PO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){qG("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),JG.print("rtcFirstFrameRecv",Nm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){qG("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),JG.print("rtcFirstFrameRecv",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,JG.print("rtcFirstFrameRecv",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,_,f,m,y;if(1!==this._videoFirstFrameState)return;var g={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,JG.print("rtcFirstFrameRecv",Nm(g)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",g),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),JG.print("rtcFirstFrameRecv",Nm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,T=b.startTime,xE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),k={event_type:"recv_end",media_type:t,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:T,result:!0,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),JG.print("rtcFirstFrameRecv",Nm(k)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",k),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a,s,c,u,d,l;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,dL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a,s,c,u,d,l;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,dL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(km().mark((function e(){var t=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(km().mark((function e(){var t,r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,dL(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=gE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=gE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(ZP.exports.EventEmitter),ZG=new yO("SendFrameObserver",0),$G=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",dD()),Jd(this,"_videoEventSessionId",dD()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=PO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var u={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){YG("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),ZG.print("rtcFirstFrameSend",Nm(u)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",u),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var d,l,h,p,v,_;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var f={event_type:"begin_send",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),type:t,start:null===(l=this._currentVideoSend)||void 0===l?void 0:l.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){YG("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),ZG.print("rtcFirstFrameSend",Nm(f)),null===(_=this._monitor)||void 0===_||_.report("rtc_first_frame",f),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c;if(1!==this._audioFirstFrameState)return;var u={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,ZG.print("rtcFirstFrameSend",Nm(u)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",u),this._audioFirstFrameState=2}else if("video"===e){var d,l,h,p,v,_,f;if(1!==this._videoFirstFrameState)return;var m={event_type:"sent_end",media_type:e,start:null===(d=this._currentVideoSend)||void 0===d?void 0:d.startTime,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(h=this._currentVideoSend)||void 0===h?void 0:h.type,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(_=this._handler)||void 0===_?void 0:_.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,ZG.print("rtcFirstFrameSend",Nm(m)),null===(f=this._monitor)||void 0===f||f.report("rtc_first_frame",m),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var a=this._currentAudioSend,s=a.type,c=a.startTime,u={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:c,result:!0,event_session_id:this._audioEventSessionId,type:s,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId)};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),ZG.print("rtcFirstFrameSend",Nm(u)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",u),this._audioFirstFrameState=3}else if("video"===e){var d,l,h,p,v;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var _=this._currentVideoSend,f=_.type,m=_.startTime,y={event_type:"sent_end",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:m,result:!0,event_session_id:this._videoEventSessionId,type:f,vendor_mode:(null===(l=this._stream)||void 0===l?void 0:l.vendorCode)||0,pc_session_id:(null===(h=this._stream)||void 0===h?void 0:h.pcSessionId)||(null===(p=this._handler)||void 0===p?void 0:p.peerConnectionId)};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),ZG.print("rtcFirstFrameSend",Nm(y)),null===(v=this._monitor)||void 0===v||v.report("rtc_first_frame",y),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,dL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Gs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(km().mark((function e(){var t,r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,dL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",gE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(km().mark((function n(){var i,o,a;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(km().mark((function r(){var n;return km().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),eH=(Jd(WG={},"audio",{delay:1200,stallRadio:.3}),Jd(WG,"video",{delay:1200,stallRadio:.6}),Jd(WG,"screen_audio",{delay:1600,stallRadio:.8}),Jd(WG,"screen_video",{delay:1600,stallRadio:.8}),WG),tH=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_connectionState",GG.CONNECTED),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,Tm(i=Om(o=[]).call(o,JT(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",_=r._fractionLost,f=r.rtt,m=r._sendBandWidth,y=r._retransmittedRate;0===m&&(_=Math.max(.65,_));var g=this._getQosLevel(f,_||0,y||0),S=this._preUplinkStats.get(v)||[g];this._preUplinkStats.set(v,Tm(h=Om(p=[]).call(p,JT(S),[g])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=gl.VBAD;else{var l=s.rtt,h=s.audioLossRate,p=s.stallDuration,v=s.statsInterval,_=s.e2eDelay,f=p/v,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,f,_);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=gl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,T=c.statsInterval,k=c.e2eDelay,I=c._retransmittedRate,R=E/T,A=u?"screen_video":"video",C=this._getQosLevel(S,b||0,I||0),w=this._getDownlinkQoE(A,R,k);n=this._getNetworkQuality(C,w)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,D,P,M=Om(O="".concat(d)).call(O,u?"_screen":""),N=this._preDownlinkStats.get(M)||[x];this._preDownlinkStats.set(M,Tm(D=Om(P=[]).call(P,JT(N),[x])).call(D,-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==GG.CONNECTED)e=t=gl.VBAD;else{var n,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||gl.EXCELLENT;var c=Gs(n=jm(i=qT(dO(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil(pb(c).call(c,(function(e,t){return t+e}),0)/c.length)||gl.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=eH[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=gl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Gs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,JT(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&TD(t)&&r.localaudio&&r.audiostream,videoActive:n&&kD(t)&&r.localvideo&&r.videostream}}}]),e}(),rH=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,_=void 0===v?0:v,f=p.height,m=void 0===f?0:f;h===m&&d===_||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,_,m),delete s[i],(n.isScreen?r:t)[i]={width:_,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),nH=qT((new TextEncoder).encode("subt")),iH={1:hA.SUBTITLE_ERR_POSTPROCESS,2:hA.SUBTITLE_ERR_CONNECTION_ERROR,3:hA.SUBTITLE_ERR_PROCESS_ERROR},oH=new yO("SubtitleTool",1),aH=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Nm({source_language:o}))}},sH=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(oH.print("start","Invoke config: %o",t),PP(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(uH).call(uH,t.targetLanguage||"")){e.next=4;break}throw new vA(hA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new vA(hA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:hA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(PP(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(uH).call(uH,t.targetLanguage||"")){e.next=3;break}throw new vA(hA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new vA(hA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new vA(hA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;oH.print("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){oH.print("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new vA(iH[r]||hA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=cH(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),cH=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(nH.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=cD.ab2str(Tm(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},uH=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],dH=ad,lH=tc,hH=function(e,t,r,n){for(var i,o=n>1?void 0:n?lH(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&dH(t,r,o),o},pH=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=PO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(km().mark((function e(){var t,r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(JT(dO(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new vA(hA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Nm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(km().mark((function e(){var t,r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(km().mark((function e(){var t,r,n,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mT(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===Cl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(uG.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(uG.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:Cl.FORWARD_STREAM_STATE_FAILURE,error:wl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=JR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$k(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:Cl.FORWARD_STREAM_STATE_SUCCESS,error:wl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=Cl.FORWARD_STREAM_STATE_FAILURE,s.error=wl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=Cl.FORWARD_STREAM_STATE_FAILURE,s.error=wl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=Cl.FORWARD_STREAM_STATE_FAILURE,s.error=wl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=gE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new vA(hA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=Cb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(dD()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),new vA(hA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=gE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function vH(e,t,r){var n=r.value;return r.value=Rm(km().mark((function e(){var r,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new vA(hA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}hH([vH],pH.prototype,"startForwardStream2Rooms",1),hH([vH],pH.prototype,"updateForwardStream2Rooms",1),hH([vH],pH.prototype,"stopForwardStream2Rooms",1),hH([vH],pH.prototype,"pauseForwardStream2AllRooms",1),hH([vH],pH.prototype,"resumeForwardStream2AllRooms",1);var _H=new yO("Room",1),fH={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},mH=function(e){PI(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w=JI(x);function x(e,t){var r;return Vl(this,x),Jd(tI(r=w.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),_H.print("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new zG(t),r._networkQualityManager=new tH,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new rH(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=PO(r.id),r._forwardStreamManager=new pH(tI(r)),r._addHandlerEventHandler(),r}return Ul(x,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P=this;null===(e=this._mediaServerClient)||void 0===e||e.on(tG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(tG.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(tG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(tG.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return P._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(tG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(tG.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(tG.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(tG.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return P._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(tG.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(tG.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(tG.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(tG.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(tG.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(tG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(tG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(tG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(tG.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(tG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(tG.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(tG.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(rG.RSCP,(function(e){!!gE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mT(t).call(t,null===(r=P._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(P._publishOnDemandItem=e,P._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(rG.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(rG.SSC,this._onSSC.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(nG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(nG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return P.emit(nG.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(tG.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){P._networkQualityManager.updateDownlinkStats(e,P._findRemoteStreamByScreen(e.userId,e.isScreen)),P.emit(uG.ON_REMOTE_STREAM_STATS,ID(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(uG.RESUBSCRIBE,(function(e){P.emit(uG.RESUBSCRIBE,e)})),null===(C=this._mediaServerClient)||void 0===C||C.on(uG.RECONNECT_FAILED,(function(){P.emit(uG.RECONNECT_FAILED)})),null===(w=this._mediaServerClient)||void 0===w||w.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(tG.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(uG.ON_REJOIN_WITH_TCP,(function(){P.emit(uG.ON_REJOIN_WITH_TCP)})),null===(D=this._mediaServerClient)||void 0===D||D.on(uG.ON_ICE_CONNECT_WITH_TCP,(function(){P.emit(uG.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(uG.ON_LOCAL_STREAM_STATS,ID(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(C=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"join",value:(A=Rm(km().mark((function e(t,r,n,i,o){var a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),_H.print("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===hA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"publishScreen",value:(R=Rm(km().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,_,f,m;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new eF(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=oC()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new $G(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof cV&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof uV&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(TD(i)&&(this._localScreenStream.pubAudio=o===lG.PUB),kD(i)&&(this._localScreenStream.pubVideo=o===lG.PUB),_H.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(c),l?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"unpublishScreen",value:(k=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return k.apply(this,arguments)})},{key:"liveControlMessage",value:(T=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _H.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(E=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"subtitleControlMessage",value:(b=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _H.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(g=Rm(km().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],_H.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new eF(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=oC()),this._mediaServerClient.handler&&(this._localStream.observer=new $G(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(TD(o)&&(this._localStream.pubAudio=a===lG.PUB),kD(o)&&(this._localStream.pubVideo=a===lG.PUB),_H.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,_=this._localStream.videoTrack instanceof cV,f=this._localStream.audioTrack instanceof uV,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableVideo(!0)),v&&(f?null===(g=this._localStream.observer)||void 0===g||g.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(uG.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(uG.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return g.apply(this,arguments)})},{key:"updatePubTrack",value:(y=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(f=Rm(km().mark((function e(t,r,n){var i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _H.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"updateSubTrack",value:(_=Rm(km().mark((function e(t,r,n,i){var o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_H.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(v=Rm(km().mark((function e(t,r){var n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,_;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(_=d[p])||void 0===_?void 0:_.height)){l=p;break}}var f=d[0];if(-1===l)f=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);f=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=f)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=f)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(p=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _H.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"startSubtitle",value:(h=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new vA(hA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"stopSubtitle",value:(l=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(d=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(u=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(c=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(s=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(a=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"leave",value:(o=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],_H.print("leave","Invoke leave"),n=aD(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$k(iR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:aD()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:aD()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return o.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;_H.print("destroy","Invoke destroy"),LO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$k(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(i=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _H.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(uG.ON_ROOM_ERROR,{errorCode:hA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=nC(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=Rm(km().mark((function e(t){var r,n,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,cD.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;_H.print("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(uG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(uG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,p=$k(iR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(y){p.e(y)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var _,f=$k(iR(n=this._remoteStreams).call(n));try{for(f.s();!(_=f.n()).done;){var m=_.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:$j.clientDisconnected})}))}}catch(y){f.e(y)}finally{f.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$k(iR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(km().mark((function e(t){var r,n,i,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,_H.print(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),e.next=6,o._mediaServerClient.subscribe(t,t.subMediaType);case 6:_H.print(Om(n="success resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),o.safeEmit(uG.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),_H.print(Om(i=Om(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(i,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=gE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new tF(this._context,"ff-stream","ff-stream",!1,!1,fH);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=kV(i),this._virtualStreams.push(s),this.safeEmit(uG.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Gs(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var _=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,_)_.attributes=e.attributes;else if((_=new tF(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(_),!c){var f=this._remoteStreams.get(e.clientId);f?f.push(_):this._remoteStreams.set(e.clientId,[_])}if(this._mediaServerClient.handler&&(_.observer=new QG(_,this._mediaServerClient.handler)),!_.isScreen&&l){var m,y,g,S,b,E,T,k;if(a&&_.hasVideo)if(_.attributes.extvideo)null===(m=_.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=_.observer)||void 0===y||y.setPushVideo(!0);else null===(g=_.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=_.observer)||void 0===S||S.setPublishVideo(!0);if(a&&_.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(_.attributes.extaudio)null===(b=_.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=_.observer)||void 0===E||E.setPushAudio(!0);else null===(T=_.observer)||void 0===T||T.setExternalAudioSource(!1),null===(k=_.observer)||void 0===k||k.setPublishAudio(!0);if(!0===i&&!1===a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,C=R.isAutoSubscribeVideo;null===(I=_.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!C})}}return i&&this.safeEmit(tG.ON_ADD_STREAM,{stream:_}),_}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(tG.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(uG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(uG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===iG.kickedByAdmin?a=hA.KICKED_OUT:i===iG.onUserTokenDidExpire?a=hA.TOKEN_EXPIRED:i===iG.userDuplicateLogin&&(a=hA.DUPLICATE_LOGIN),o===oG.roomDismissByAdmin&&(a=hA.ROOM_DISMISS),a&&this.safeEmit(uG.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===iG.userLeave?s=tl.QUIT:i===iG.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===iG.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:$j.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(uG.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===iG.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=gE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Gs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(tG.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(uG.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(uG.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,_=!1,f=l.localvideo!==d.localvideo,m=!1,y=NV.NONE,g=NV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?y|=ul.AUDIO:g|=ul.AUDIO),l.videostream!==d.videostream&&(_=l.localvideo,m=!!l.videostream,l.videostream?y|=ul.VIDEO:g|=ul.VIDEO),y&&this.safeEmit(uG.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:lG.PUB,remoteStream:s}),g&&this.safeEmit(uG.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:lG.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,T;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(T=s.observer)||void 0===T||T.setEnableAudio(!0);this.safeEmit(uG.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var k,I,R,A;if(l.extaudio)null===(k=s.observer)||void 0===k||k.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(uG.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var C,w,x,O;if(n&&l.videostream)if(l.extvideo)null===(C=s.observer)||void 0===C||C.setExternalVideoSource(!0),null===(w=s.observer)||void 0===w||w.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(uG.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var D,P,M,N;if(l.extvideo)null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!0),null===(P=s.observer)||void 0===P||P.setPushVideo(!1);else null===(M=s.observer)||void 0===M||M.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(uG.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(_&&!f)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&lA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:fH}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(uG.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){_H.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:fG.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;_H.print("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(uG.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mT(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&jR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i=this,o=$k(iR(r=this._remoteStreams).call(r));try{for(o.s();!(n=o.n()).done;){var a=n.value;Array.isArray(a)&&a.forEach((function(e){return e.clean()}))}}catch(s){o.e(s)}finally{o.f()}this._virtualStreams.forEach((function(e){i.emit(uG.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||e.clean(),null===(t=this.localScreenStream)||void 0===t||t.clean()}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===GG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===GG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==GG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===GG.CONNECTED&&e.next===GG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(nG.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(nG.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(uG.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(tG.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(tG.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(tG.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new sH(this),this._subtitleTool.onEvent=function(t){e.emit(uG.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(uG.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){var t=e.body,r=t.error||0,n=dG.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=dG.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?dG.START_FAILED:dG.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?dG.STOP_FAILED:dG.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?dG.UPDATE_FAILED:dG.UPDATE_SUCCESS}this.safeEmit(tG.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(tG.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(tG.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(uG.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===eG.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return u=[],this._publishOnDemandBusy=!0,d=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,l=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(a)&&(v={},_H.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mT(t).call(t,d)){var r=null==e?void 0:e.Metadata.VideoIndex;v[r]=!0}})),h.encodings=jm(p=h.encodings).call(p,(function(e){if(e.rid){v[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;u[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=u)),e.next=15,l.setParameters(h);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(uG.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(uG.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(uG.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),x}(tM),yH=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&Cb(r.style,t.style),t.attributes&&TA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},gH=new yO("Player",0),SH=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],bH={playsinline:"","webkit-playsinline":""},EH={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},TH=function(e){PI(n,e);var t,r=JI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":gH.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":gH.print("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(gH.print("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&GD&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:fG.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:fG.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=PO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new vA(hA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=yH("video",{style:{width:"100%",height:"100%"},attributes:EH}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,oD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){gH.print("resume player after iOS interruption"),t._internalPlay()},HU.on(jU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),HU.on(jU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),HU.on(jU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&SH.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&SH.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(BD){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=aD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=aD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(km().mark((function e(t,r){var n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,gH.print("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{LO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(FW){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),gH.print("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&kP.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(gH.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new vA(hA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||YD?this._videoDom.play():Yf.resolve()}},{key:"mirror",value:function(e){var t;gH.print("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(gH.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];gH.print("destroy","video player: ".concat(this.userId)),this.stop(e),OI(wI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),HU.off(jU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),HU.off(jU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),HU.off(jU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(ZP.exports.EventEmitter),kH=function(e){PI(i,e);var t,r,n=JI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&gH.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(gH.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),ZD&&YD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),JD&&XD&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(LO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=WU.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(ZD&&JD&&(i=i.then((function(){return new Yf((function(e){setTimeout(Rm(km().mark((function t(){var n;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){LO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:fG.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:fG.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new vA(hA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=PO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=yH("audio",{style:{display:"none"},attributes:bH}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,oD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&SH.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(SH.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(gH.print("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof MV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),ZD&&JD&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new vA(hA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(gH.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new vA(hA.INVALID_PARAMS,"Player not found");if(!this.played)return Yf.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=WU.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Yf.all(r):Yf.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return gH.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,FU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mT(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;gH.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){gH.print("destroy","audio player: ".concat(this.userId)),this.stop(),OI(wI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(ZP.exports.EventEmitter);function IH(e,t,r,n){var i=function(){var e=Rm(km().mark((function e(t,i){var o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof TH&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof kH&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Yf.all(o)}var RH=i,AH=lt("iterator"),CH=!RH((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[AH]||"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"!==r||"x"!==new URL("http://x",void 0).host})),wH=Jt,xH=E,OH=2147483647,DH=/[^\0-\u007E]/,PH=/[.\u3002\uFF0E\uFF61]/g,MH="Overflow: input needs wider integers to process",NH=RangeError,LH=xH(PH.exec),UH=Math.floor,VH=String.fromCharCode,FH=xH("".charCodeAt),BH=xH([].join),jH=xH([].push),GH=xH("".replace),HH=xH("".split),zH=xH("".toLowerCase),KH=function(e){return e+22+75*(e<26)},XH=function(e,t,r){var n=0;for(e=r?UH(e/700):e>>1,e+=UH(e/t);e>455;)e=UH(e/35),n+=36;return UH(n+36*e/(e+38))},WH=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=FH(e,r++);if(i>=55296&&i<=56319&&r<n){var o=FH(e,r++);56320==(64512&o)?jH(t,((1023&i)<<10)+(1023&o)+65536):(jH(t,i),r--)}else jH(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&jH(t,VH(n));var c=t.length,u=c;for(c&&jH(t,"-");u<i;){var d=OH;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>UH((OH-a)/l))throw NH(MH);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>OH)throw NH(MH);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var _=h-v,f=36-v;jH(t,VH(KH(v+_%f))),h=UH(_/f),p+=36}jH(t,VH(KH(h))),s=XH(a,l,u==c),a=0,u++}}a++,o++}return BH(t,"")},qH=Ar,YH=n,JH=O,QH=E,ZH=C,$H=CH,ez=li,tz=Qy,rz=Ni,nz=Mc,iz=Zi,oz=mp,az=R,sz=Ye,cz=Yt,uz=_n,dz=tr,lz=$,hz=yn,pz=Hn,vz=V,_z=gh,fz=hh,mz=Cp,yz=dR,gz=lt("iterator"),Sz="URLSearchParams",bz="URLSearchParamsIterator",Ez=iz.set,Tz=iz.getterFor(Sz),kz=iz.getterFor(bz),Iz=Object.getOwnPropertyDescriptor,Rz=function(e){if(!ZH)return YH[e];var t=Iz(YH,e);return t&&t.value},Az=Rz("fetch"),Cz=Rz("Request"),wz=Rz("Headers"),xz=Cz&&Cz.prototype,Oz=wz&&wz.prototype,Dz=YH.RegExp,Pz=YH.TypeError,Mz=YH.decodeURIComponent,Nz=YH.encodeURIComponent,Lz=QH("".charAt),Uz=QH([].join),Vz=QH([].push),Fz=QH("".replace),Bz=QH([].shift),jz=QH([].splice),Gz=QH("".split),Hz=QH("".slice),zz=/\+/g,Kz=Array(4),Xz=function(e){return Kz[e-1]||(Kz[e-1]=Dz("((?:%[\\da-f]{2}){"+e+"})","gi"))},Wz=function(e){try{return Mz(e)}catch(FW){return e}},qz=function(e){var t=Fz(e,zz," "),r=4;try{return Mz(t)}catch(FW){for(;r;)t=Fz(t,Xz(r--),Wz);return t}},Yz=/[!'()~]|%20/g,Jz={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Qz=function(e){return Jz[e]},Zz=function(e){return Fz(Nz(e),Yz,Qz)},$z=nz((function(e,t){Ez(this,{type:bz,iterator:_z(Tz(e).entries),kind:t})}),"Iterator",(function(){var e=kz(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),eK=function(e){this.entries=[],this.url=null,void 0!==e&&(lz(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Lz(e,0)?Hz(e,1):e:hz(e)))};eK.prototype={type:Sz,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=fz(e);if(c)for(r=(t=_z(e,c)).next;!(n=JH(r,t)).done;){if(o=(i=_z(dz(n.value))).next,(a=JH(o,i)).done||(s=JH(o,i)).done||!JH(o,i).done)throw Pz("Expected sequence with length 2");Vz(this.entries,{key:hz(a.value),value:hz(s.value)})}else for(var u in e)sz(e,u)&&Vz(this.entries,{key:u,value:hz(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=Gz(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=Gz(t,"="),Vz(this.entries,{key:qz(Bz(r)),value:qz(Uz(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Vz(r,Zz(e.key)+"="+Zz(e.value));return Uz(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var tK=function(){oz(this,rK);var e=arguments.length>0?arguments[0]:void 0;Ez(this,new eK(e))},rK=tK.prototype;if(tz(rK,{append:function(e,t){mz(arguments.length,2);var r=Tz(this);Vz(r.entries,{key:hz(e),value:hz(t)}),r.updateURL()},delete:function(e){mz(arguments.length,1);for(var t=Tz(this),r=t.entries,n=hz(e),i=0;i<r.length;)r[i].key===n?jz(r,i,1):i++;t.updateURL()},get:function(e){mz(arguments.length,1);for(var t=Tz(this).entries,r=hz(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){mz(arguments.length,1);for(var t=Tz(this).entries,r=hz(e),n=[],i=0;i<t.length;i++)t[i].key===r&&Vz(n,t[i].value);return n},has:function(e){mz(arguments.length,1);for(var t=Tz(this).entries,r=hz(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){mz(arguments.length,1);for(var r,n=Tz(this),i=n.entries,o=!1,a=hz(e),s=hz(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?jz(i,c--,1):(o=!0,r.value=s));o||Vz(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=Tz(this);yz(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=Tz(this).entries,n=cz(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new $z(this,"keys")},values:function(){return new $z(this,"values")},entries:function(){return new $z(this,"entries")}},{enumerable:!0}),ez(rK,gz,rK.entries,{name:"entries"}),ez(rK,"toString",(function(){return Tz(this).serialize()}),{enumerable:!0}),rz(tK,Sz),qH({global:!0,constructor:!0,forced:!$H},{URLSearchParams:tK}),!$H&&az(wz)){var nK=QH(Oz.has),iK=QH(Oz.set),oK=function(e){if(lz(e)){var t,r=e.body;if(uz(r)===Sz)return t=e.headers?new wz(e.headers):new wz,nK(t,"content-type")||iK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),pz(e,{body:vz(0,hz(r)),headers:vz(0,t)})}return e};if(az(Az)&&qH({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Az(e,arguments.length>1?oK(arguments[1]):{})}}),az(Cz)){var aK=function(e){return oz(this,xz),new Cz(e,arguments.length>1?oK(arguments[1]):{})};xz.constructor=aK,aK.prototype=xz,qH({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:aK})}}var sK,cK=Ar,uK=C,dK=CH,lK=n,hK=Yt,pK=E,vK=li,_K=function(e,t,r){return wH.f(e,t,r)},fK=mp,mK=Ye,yK=Rb,gK=XT,SK=ni,bK=Ud.codeAt,EK=function(e){var t,r,n=[],i=HH(GH(zH(e),PH,"."),".");for(t=0;t<i.length;t++)r=i[t],jH(n,LH(DH,r)?"xn--"+WH(r):r);return BH(n,".")},TK=yn,kK=Ni,IK=Cp,RK={URLSearchParams:tK,getState:Tz},AK=Zi,CK=AK.set,wK=AK.getterFor("URL"),xK=RK.URLSearchParams,OK=RK.getState,DK=lK.URL,PK=lK.TypeError,MK=lK.parseInt,NK=Math.floor,LK=Math.pow,UK=pK("".charAt),VK=pK(/./.exec),FK=pK([].join),BK=pK(1..toString),jK=pK([].pop),GK=pK([].push),HK=pK("".replace),zK=pK([].shift),KK=pK("".split),XK=pK("".slice),WK=pK("".toLowerCase),qK=pK([].unshift),YK="Invalid scheme",JK="Invalid host",QK="Invalid port",ZK=/[a-z]/i,$K=/[\d+-.a-z]/i,eX=/\d/,tX=/^0x/i,rX=/^[0-7]+$/,nX=/^\d+$/,iX=/^[\da-f]+$/i,oX=/[\0\t\n\r #%/:<>?@[\\\]^|]/,aX=/[\0\t\n\r #/:<>?@[\\\]^|]/,sX=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,cX=/[\t\n\r]/g,uX=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)qK(t,e%256),e=NK(e/256);return FK(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=BK(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},dX={},lX=yK({},dX,{" ":1,'"':1,"<":1,">":1,"`":1}),hX=yK({},lX,{"#":1,"?":1,"{":1,"}":1}),pX=yK({},hX,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),vX=function(e,t){var r=bK(e,0);return r>32&&r<127&&!mK(t,e)?e:encodeURIComponent(e)},_X={ftp:21,file:null,http:80,https:443,ws:80,wss:443},fX=function(e,t){var r;return 2==e.length&&VK(ZK,UK(e,0))&&(":"==(r=UK(e,1))||!t&&"|"==r)},mX=function(e){var t;return e.length>1&&fX(XK(e,0,2))&&(2==e.length||"/"===(t=UK(e,2))||"\\"===t||"?"===t||"#"===t)},yX=function(e){return"."===e||"%2e"===WK(e)},gX={},SX={},bX={},EX={},TX={},kX={},IX={},RX={},AX={},CX={},wX={},xX={},OX={},DX={},PX={},MX={},NX={},LX={},UX={},VX={},FX={},BX=function(e,t,r){var n,i,o,a=TK(e);if(t){if(i=this.parse(a))throw PK(i);this.searchParams=null}else{if(void 0!==r&&(n=new BX(r,!0)),i=this.parse(a,null,n))throw PK(i);(o=OK(new xK)).bindURL(this),this.searchParams=o}};BX.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||gX,d=0,l="",h=!1,p=!1,v=!1;for(e=TK(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=HK(e,sX,"")),e=HK(e,cX,""),n=gK(e);d<=n.length;){switch(i=n[d],u){case gX:if(!i||!VK(ZK,i)){if(t)return YK;u=bX;continue}l+=WK(i),u=SX;break;case SX:if(i&&(VK($K,i)||"+"==i||"-"==i||"."==i))l+=WK(i);else{if(":"!=i){if(t)return YK;l="",u=bX,d=0;continue}if(t&&(c.isSpecial()!=mK(_X,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&_X[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=DX:c.isSpecial()&&r&&r.scheme==c.scheme?u=EX:c.isSpecial()?u=RX:"/"==n[d+1]?(u=TX,d++):(c.cannotBeABaseURL=!0,GK(c.path,""),u=UX)}break;case bX:if(!r||r.cannotBeABaseURL&&"#"!=i)return YK;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=SK(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=FX;break}u="file"==r.scheme?DX:kX;continue;case EX:if("/"!=i||"/"!=n[d+1]){u=kX;continue}u=AX,d++;break;case TX:if("/"==i){u=CX;break}u=LX;continue;case kX:if(c.scheme=r.scheme,i==sK)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=SK(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=IX;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=SK(r.path),c.query="",u=VX;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=SK(r.path),c.path.length--,u=LX;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=SK(r.path),c.query=r.query,c.fragment="",u=FX}break;case IX:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=LX;continue}u=CX}else u=AX;break;case RX:if(u=AX,"/"!=i||"/"!=UK(l,d+1))continue;d++;break;case AX:if("/"!=i&&"\\"!=i){u=CX;continue}break;case CX:if("@"==i){h&&(l="%40"+l),h=!0,o=gK(l);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||v){var m=vX(f,pX);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==sK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=gK(l).length+1,l="",u=wX}else l+=i;break;case wX:case xX:if(t&&"file"==c.scheme){u=MX;continue}if(":"!=i||p){if(i==sK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return JK;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=NX,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return JK;if(a=c.parseHost(l))return a;if(l="",u=OX,t==xX)return}break;case OX:if(!VK(eX,i)){if(i==sK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=MK(l,10);if(y>65535)return QK;c.port=c.isSpecial()&&y===_X[c.scheme]?null:y,l=""}if(t)return;u=NX;continue}return QK}l+=i;break;case DX:if(c.scheme="file","/"==i||"\\"==i)u=PX;else{if(!r||"file"!=r.scheme){u=LX;continue}if(i==sK)c.host=r.host,c.path=SK(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=SK(r.path),c.query="",u=VX;else{if("#"!=i){mX(FK(SK(n,d),""))||(c.host=r.host,c.path=SK(r.path),c.shortenPath()),u=LX;continue}c.host=r.host,c.path=SK(r.path),c.query=r.query,c.fragment="",u=FX}}break;case PX:if("/"==i||"\\"==i){u=MX;break}r&&"file"==r.scheme&&!mX(FK(SK(n,d),""))&&(fX(r.path[0],!0)?GK(c.path,r.path[0]):c.host=r.host),u=LX;continue;case MX:if(i==sK||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&fX(l))u=LX;else if(""==l){if(c.host="",t)return;u=NX}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=NX}continue}l+=i;break;case NX:if(c.isSpecial()){if(u=LX,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=sK&&(u=LX,"/"!=i))continue}else c.fragment="",u=FX;else c.query="",u=VX;break;case LX:if(i==sK||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=WK(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||GK(c.path,"")):yX(l)?"/"==i||"\\"==i&&c.isSpecial()||GK(c.path,""):("file"==c.scheme&&!c.path.length&&fX(l)&&(c.host&&(c.host=""),l=UK(l,0)+":"),GK(c.path,l)),l="","file"==c.scheme&&(i==sK||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)zK(c.path);"?"==i?(c.query="",u=VX):"#"==i&&(c.fragment="",u=FX)}else l+=vX(i,hX);break;case UX:"?"==i?(c.query="",u=VX):"#"==i?(c.fragment="",u=FX):i!=sK&&(c.path[0]+=vX(i,dX));break;case VX:t||"#"!=i?i!=sK&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":vX(i,dX)):(c.fragment="",u=FX);break;case FX:i!=sK&&(c.fragment+=vX(i,lX))}d++}},parseHost:function(e){var t,r,n;if("["==UK(e,0)){if("]"!=UK(e,e.length-1))return JK;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return UK(e,l)};if(":"==h()){if(":"!=UK(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&VK(iX,h());)t=16*t+MK(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!VK(eX,h()))return;for(;VK(eX,h());){if(o=MK(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(XK(e,1,-1)),!t)return JK;this.host=t}else if(this.isSpecial()){if(e=EK(e),VK(oX,e))return JK;if(t=function(e){var t,r,n,i,o,a,s,c=KK(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==UK(i,0)&&(o=VK(tX,i)?16:8,i=XK(i,8==o?1:2)),""===i)a=0;else{if(!VK(10==o?nX:8==o?rX:iX,i))return e;a=MK(i,o)}GK(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=LK(256,5-t))return null}else if(a>255)return null;for(s=jK(r),n=0;n<r.length;n++)s+=r[n]*LK(256,3-n);return s}(e),null===t)return JK;this.host=t}else{if(VK(aX,e))return JK;for(t="",r=gK(e),n=0;n<r.length;n++)t+=vX(r[n],dX);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return mK(_X,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&fX(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=uX(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+FK(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw PK(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new jX(e.path[0]).origin}catch(FW){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+uX(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(TK(e)+":",gX)},getUsername:function(){return this.username},setUsername:function(e){var t=gK(TK(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=vX(t[r],pX)}},getPassword:function(){return this.password},setPassword:function(e){var t=gK(TK(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=vX(t[r],pX)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?uX(e):uX(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,wX)},getHostname:function(){var e=this.host;return null===e?"":uX(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,xX)},getPort:function(){var e=this.port;return null===e?"":TK(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=TK(e))?this.port=null:this.parse(e,OX))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+FK(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,NX))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=TK(e))?this.query=null:("?"==UK(e,0)&&(e=XK(e,1)),this.query="",this.parse(e,VX)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=TK(e))?("#"==UK(e,0)&&(e=XK(e,1)),this.fragment="",this.parse(e,FX)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var jX=function(e){var t=fK(this,GX),r=IK(arguments.length,1)>1?arguments[1]:void 0,n=CK(t,new BX(e,!1,r));uK||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},GX=jX.prototype,HX=function(e,t){return{get:function(){return wK(this)[e]()},set:t&&function(e){return wK(this)[t](e)},configurable:!0,enumerable:!0}};if(uK&&(_K(GX,"href",HX("serialize","setHref")),_K(GX,"origin",HX("getOrigin")),_K(GX,"protocol",HX("getProtocol","setProtocol")),_K(GX,"username",HX("getUsername","setUsername")),_K(GX,"password",HX("getPassword","setPassword")),_K(GX,"host",HX("getHost","setHost")),_K(GX,"hostname",HX("getHostname","setHostname")),_K(GX,"port",HX("getPort","setPort")),_K(GX,"pathname",HX("getPathname","setPathname")),_K(GX,"search",HX("getSearch","setSearch")),_K(GX,"searchParams",HX("getSearchParams")),_K(GX,"hash",HX("getHash","setHash"))),vK(GX,"toJSON",(function(){return wK(this).serialize()}),{enumerable:!0}),vK(GX,"toString",(function(){return wK(this).serialize()}),{enumerable:!0}),DK){var zX=DK.createObjectURL,KX=DK.revokeObjectURL;zX&&vK(jX,"createObjectURL",hK(zX,DK)),KX&&vK(jX,"revokeObjectURL",hK(KX,DK))}kK(jX,"URL"),cK({global:!0,constructor:!0,forced:!dK,sham:!uK},{URL:jX});var XX=ee.URL,WX=function(){var e=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(XX.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),qX=ad,YX=tc,JX=function(e,t,r,n){for(var i,o=n>1?void 0:n?YX(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&qX(t,r,o),o},QX=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new KN),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,PP(o=n.type,"mixingType",Gj(Dl)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_STOPPED,error:pA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(y){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_START_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,WX(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_START_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=XX.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_FINISHED,error:pA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),_=this._sharedAudioContext.createGain(),f=this.volumeConfig.get(t),_.gain.value=f?f/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:_,type:"file"}),o===Dl.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(y){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_PLAYING,error:pA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Pl.AUDIO_MIXING_STATE_STOPPED,error:pA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Pl.AUDIO_MIXING_STATE_PAUSED,error:pA.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Pl.AUDIO_MIXING_STATE_PLAYING,error:pA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(km().mark((function e(t,r){var n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new vA(hA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof vA)throw e;throw new vA(hA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,WX(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Pl.AUDIO_MIXING_STATE_PRELOADED,error:pA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=XX.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Yf((function(e){var r=XX.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),XX.revokeObjectURL(r),e(null)}))}));case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){PP(e,"type",Gj(Dl));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Dl.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Pl.AUDIO_MIXING_STATE_PCM_ENABLED,error:pA.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Pl.AUDIO_MIXING_STATE_PCM_DISABLED,error:pA.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$k(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){XX.revokeObjectURL(e)}))}}]),e}();JX([MO("id","filePath","options")],QX.prototype,"startAudioMixing",1),JX([MO("id")],QX.prototype,"stopAudioMixing",1),JX([MO("id")],QX.prototype,"pauseAudioMixing",1),JX([MO("id")],QX.prototype,"resumeAudioMixing",1),JX([MO("id")],QX.prototype,"preloadAudioMixing",1),JX([MO("id")],QX.prototype,"unloadAudioMixing",1),JX([MO("id")],QX.prototype,"getAudioMixingVolume",1),JX([MO("id","volume")],QX.prototype,"setAudioMixingVolume",1),JX([MO("id")],QX.prototype,"getAudioMixingDuration",1),JX([MO("id")],QX.prototype,"getAudioMixingCurrentPosition",1),JX([MO("id","position")],QX.prototype,"setAudioMixingPosition",1),JX([MO("type")],QX.prototype,"enableAudioMixingBuffer",1),JX([MO()],QX.prototype,"disableAudioMixingBuffer",1),JX([MO("buffer")],QX.prototype,"pushAudioMixingBuffer",1);var ZX=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(ZX||{}),$X=new yO("RTMClient",1),eW=function(e){PI(c,e);var t,r,n,i,o,a,s=JI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",GG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new LG(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Yf((function(n,i){var o;if($X.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new vA(hA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new vA(hA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=PO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:PG.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(km().mark((function e(t){var r=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Yf((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:PG.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,DP(t,"signature"),DP(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new vA(hA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:PG.C2RTM}).catch((function(e){throw new vA(hA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:AG.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;$X.print("destroy","invoke."),OI(wI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new vA(hA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=oD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:cD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:kP.VERSION,deviceId:mP.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Nm({requireICEUfragV2:!0})},{functionType:PG.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,TO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=hA.INVALID_PARAMS,n="Invalid userId"):(r=hA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=hA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new vA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==GG.CONNECTED)throw new vA(hA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=GG.CONNECTED,$X.print("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=Zj(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=GG.DISCONNECTED,$X.print("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=GG.CONNECTING,$X.print("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=GG.CONNECTING,$X.print("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(tG.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(tG.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(tG.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,TO.setRtsSessionId(this.id,"")}}]),c}(ZP.exports.EventEmitter),tW=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=mP.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=mP.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;CD(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),CD(null==t?void 0:t.channel)||(e.channelCount=t.channel),CD(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),CD(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),CD(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return CD(e.sampleRate)&&!CD(n)&&(e.sampleRate=n),CD(e.channelCount)&&!CD(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),rW=function(e){PI(o,e);var t,r,n,i=JI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new tW(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new gP(n.id),enableFallbackHandler:EW(t)},n}return Ul(o,[{key:"connect",value:(n=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new zG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new vA(hA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new tF(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=RD(e),i=0;i<t.seiCount;i++)n.emit(uG.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(km().mark((function e(){var t,r,n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$k(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(uG.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(tM),nW=new yO("AudioDeviceManager",1),iW=function(e){PI(c,e);var t,r,n,i,o,a,s=JI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new vA(hA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,nW.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),nW.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(nW.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(km().mark((function e(t,r,n){var i,o=this,a=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new vA(hA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new vA(hA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,nW.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){nW.print("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){nW.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(nW.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(nW.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new vA(hA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,FU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new vA(hA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){nW.print("destroy()","Invoke"),OI(wI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return nW.print("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Yf((function(e,n){var o=yH("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new XU(o),o.onplaying=function(){o.onplaying=null,nW.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(km().mark((function e(t){var r,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:nW.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new vA(hA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;nW.print("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Yf.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new vA(hA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(nW.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(nW.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(nW.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SV({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),nW.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Yf((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=gE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),nW.print("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(km().mark((function n(o){var a,c;return km().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return nW.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(XX.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new vA(hA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=WU.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),nW.print("setSinkId","ctx.sinkId=".concat(t))}catch(o){nW.print("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(ZP.exports.EventEmitter),oW=new yO("VideoSnapshot",1),aW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},sW=function(){var e=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=aW(n))){e.next=16;break}return oW.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,oW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return oW.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,oW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return oW.print("takeSnapshot","use temp video"),e.abrupt("return",new Yf((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);oW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),cW=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:uW(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:kl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function uW(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function dW(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new vA(hA.INVALID_PARAMS,"Invalid rtmp address")}function lW(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new vA(hA.INVALID_PARAMS,"regions should not be empty.");var t,r=$k(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new vA(hA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new vA(hA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function hW(e,t){var r,n,i,o=function(e,r){var n=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),cW());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!gE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mT(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mT(t=[kl.LC,kl.HEv1,kl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mT(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:uW(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&mT(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mT(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var pW,vW={getDefaultValue:cW,checkStartParams:function(e){var t;dW(e.url),lW(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&dW(e.url),lW(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return hW("started",e)},getUpdateParams:function(e){return hW("layoutChanged",e)}},_W=ad,fW=tc,mW=function(e,t,r,n){for(var i,o=n>1?void 0:n?fW(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&_W(t,r,o),o},yW=new yO("Engine",0),gW=function(e){PI(Ee,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N,L,U,V,F,B,j,G,H,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,_e,fe,me,ye,ge,Se,be=JI(Ee);function Ee(e,t,r){var n;return Vl(this,Ee),Jd(tI(n=be.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",CP),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[CP]),Jd(tI(n),"_screenStreamEncodeConfig",[wP]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(km().mark((function e(t){var r,i,o=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Dl.PLAYOUT_AND_PUBLISH,yW.print("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Nl.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Nl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new cG("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new YU(t),n._audioDeviceManager=new iW(n._extensionManager),n._audioMixingManager=new QX({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new tW(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new gP(t),enableFallbackHandler:EW(e)},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new eW(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new kO(t),n.monitor=PO(t),TO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(Ee,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Se=Rm(km().mark((function e(t){var r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("updateToken()","token: %s",t),DP(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new vA(hA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(ge=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setVideoCaptureDevice()","deviceId: %s",t),DP(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=UB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},ZD&&jD&&cP>=85&&cP<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||ZD&&jD,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),yW.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,yV(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return yW.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,yV(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(km().mark((function t(){var r;return km().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return yW.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,yV(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,yW.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return ge.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ye=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setAudioCaptureDevice()","deviceId: %s",t),DP(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,SV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,i.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return ye.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){FU.on(Nl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),FU.on(Nl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A,C,w,x,O,D,P,M,N=this;null===(e=this._room)||void 0===e||e.on(tG.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(tG.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(tG.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(uG.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(uG.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(uG.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(tG.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(tG.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(tG.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(tG.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(tG.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?N._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?N._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&N._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(nG.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(nG.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.safeEmit(Nl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(uG.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(uG.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(uG.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(uG.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=N._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&N.safeEmit(Nl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(uG.ON_REMOTE_STREAM_STATS,(function(e){N.safeEmit(Nl.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(uG.ON_LOCAL_STREAM_STATS,(function(e){N.safeEmit(Nl.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(uG.ON_SUBTITLE_STATE_CHANGED,(function(e){N.safeEmit(Nl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(uG.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){N.safeEmit(Nl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(uG.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(uG.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;N._updateAudioPlayerState(t),N.safeEmit(Nl.onUserStartAudioCapture,{userId:r})})),null===(T=this._room)||void 0===T||T.on(uG.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopAudioCapture,{userId:t})})),null===(k=this._room)||void 0===k||k.on(uG.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(uG.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(uG.ON_SEI_MESSAGED_RECEIVED,(function(e){N.safeEmit(Nl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(uG.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){N.safeEmit(Nl.onRemoteVideoSizeChanged,e,t)})),null===(C=this._room)||void 0===C||C.on(uG.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return N.safeEmit(Nl.onSimulcastSubscribeFallback,e)})),null===(w=this._room)||void 0===w||w.on(uG.RECONNECT_FAILED,(function(){N.safeEmit(Nl.onError,{errorCode:hA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(uG.ON_VIDEO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(uG.ON_AUDIO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(uG.ON_FORWARD_STREAM_ERROR,(function(e){N.safeEmit(Nl.onForwardStreamError,e)})),null===(P=this._room)||void 0===P||P.on(uG.ON_REJOIN_WITH_TCP,(function(){N.safeEmit(Nl.onRejoinWithTcp)})),null===(M=this._room)||void 0===M||M.on(uG.ON_ICE_CONNECT_WITH_TCP,(function(){N.safeEmit(Nl.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return WP(e)&&NO(this.id,e,i),(t=OI(wI(Ee.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(me=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new mH({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return me.apply(this,arguments)})},{key:"joinRoom",value:(fe=Rm(km().mark((function e(t,r,n,i){var o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),FP(t)||DP(t,"token"),BP(r),HP(n),zP(i=UB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==GG.CONNECTED){e.next=8;break}throw new vA(hA.REPEAT_JOIN,"Already joined");case 8:return this._room||(this._room=new mH(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,a=this._liveTranscodeConfig&&vW.getStartParams(this._liveTranscodeConfig),s=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?ZX.NORMAL_USER:ZX.SILENT_USER}),e.prev=12,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),aH(s),e.next=17,this._room.join(this._appId,r,t,s,a);case 17:return u=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(c=i)&&void 0!==c&&c.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),TO.setRoomId(this.id,r),TO.setUserId(this.id,n.userId),e.abrupt("return",u);case 27:throw e.prev=27,e.t0=e.catch(12),e.t0.code===hA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:s}),null===(d=this._room)||void 0===d||d.destroy(),delete this._room,e.t0;case 33:case"end":return e.stop()}}),e,this,[[12,27]])}))),function(e,t,r,n){return fe.apply(this,arguments)})},{key:"leaveRoom",value:(_e=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],yW.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,TO.setRoomId(this.id,""),TO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;yW.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[CP],this._screenStreamEncodeConfig=[wP],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),TO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ve=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!kD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,vV(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"unpublishStream",value:(pe=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:lG.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return pe.apply(this,arguments)})},{key:"publishScreen",value:(he=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!kD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,fV(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:lG.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof vA)){e.next=18;break}throw e.t0;case 18:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return he.apply(this,arguments)})},{key:"unpublishScreen",value:(le=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:lG.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return le.apply(this,arguments)})},{key:"subscribeStream",value:(de=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"_subscribe",value:(ue=Rm(km().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return yW.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:gE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),yW.print("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,v);case 19:TD(n)&&this._updateAudioPlayerState(d),kD(n)&&this._updateVideoPlayerState(d),_=0,f=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?_|=ul.AUDIO:f|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?_|=ul.VIDEO:f|=ul.VIDEO),_&&this.pauseAllSubscribedStream(_),f&&this.resumeAllSubscribedStream(f),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Nl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!TD(n)||!d.hasAudio||null===(y=d.observer)||void 0===y||y.setSubscribeAudio(!0),!p&&kD(n)&&d.hasVideo&&(null===(g=d.observer)||void 0===g||g.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return ue.apply(this,arguments)})},{key:"unsubscribeStream",value:(ce=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yW.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"subscribeScreen",value:(se=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ae=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yW.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:gE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");if(ZD&&cP&&cP>=85&&cP<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}yW.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(oe=Rm(km().mark((function e(t,r){var n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),jP(t),qP(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return oe.apply(this,arguments)})},{key:"startVideoCapture",value:(ie=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("startVideoCapture()","deviceId: %s",t),FP(t)||DP(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new vA(hA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,yV(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),u.close(),new vA(hA.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return p.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=28;break}return e.abrupt("return",s);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return ie.apply(this,arguments)})},{key:"stopVideoCapture",value:(ne=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,yW.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(qU.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ne.apply(this,arguments)})},{key:"startAudioCapture",value:(re=Rm(km().mark((function e(t){var r,n,i,o,a,s;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("startAudioCapture()","deviceId: $o",t),FP(t)||DP(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new vA(hA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,SV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 13:if(a=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(a),a.close(),new vA(hA.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(a),this._localAudioTrack=a,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||s)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return re.apply(this,arguments)})},{key:"stopAudioCapture",value:(te=Rm(km().mark((function e(){var t,r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,yW.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return yW.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(ee=Rm(km().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,y=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>0&&void 0!==y[0]?y[0]:{},yW.print("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,EV(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=null==p?void 0:p.getTrack())&&setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"stopScreenCapture",value:($=Rm(km().mark((function e(){var t,r,n,i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return $.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(yW.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PP(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(KP(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new TH(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new TH(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(Z=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("startLiveTranscoding()","transcode: %o",t),vW.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new vA(hA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Nl.onStreamMixingEvent,{event:dG.START,error:0,message:""}),!this._room||this._room.connectionState!==GG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(vW.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof vA)){e.next=19;break}throw e.t0;case 19:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return Z.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Q=Rm(km().mark((function e(t){var r,n,i,o;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=UB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,vW.checckUpdateParams(i),this._liveTranscodeConfig=UB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Nl.onStreamMixingEvent,{event:dG.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(vW.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof vA)){e.next=21;break}throw e.t0;case 21:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Q.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(J=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Nl.onStreamMixingEvent,{event:dG.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof vA)){e.next=16;break}throw e.t0;case 16:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return J.apply(this,arguments)})},{key:"startSubtitle",value:(Y=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;yW.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return yW.print("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(q=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?ZX.NORMAL_USER:ZX.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Nl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Nl.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Nl.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Nl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Nl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Nl.onVideoFirstFrameRendered,h),t.safeEmit(Nl.onVideoFirstFrameDecoded,h),t.safeEmit(Nl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),LO(t.id,"autoplay-error",e instanceof TH?"video":"audio",0,n.userId||""),void t.safeEmit(Nl.onAutoplayFailed,{userId:n.userId,kind:e instanceof TH?"video":"audio",mediaType:e instanceof TH?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Nl.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(km().mark((function e(n){var i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:fG.TRACK_ERROR}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack().kind,t.safeEmit({"track-ended":Nl.onTrackEnded,"track-mute":Nl.onTrackMute,"track-unmute":Nl.onTrackUnmute}[r],{kind:a,isScreen:o}),!QD&&!WD){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(HU.emit(jU.ON_IOS_LOCAL_TRACK_MUTE,a),"audio"!==a){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&HU.emit(jU.ON_IOS_LOCAL_TRACK_UNMUTE,a);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(qU.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){yW.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),PP(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),KP(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new TH(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:gE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new TH(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:gE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){yW.print("setLocalVideoMirrorType()","mirrorType: %o",e),PP(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(W=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("setAudioPlaybackDevice()","deviceId: %s",t),DP(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Nl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Nm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"play",value:(X=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y.length>1&&void 0!==y[1]?y[1]:ul.AUDIO_AND_VIDEO,a=y.length>2?y[2]:void 0,yW.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),h.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(_=this._screenPlayer)||void 0===_?void 0:_.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),f=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(IH(this._remoteVideoPlayer,t,!1,f)),l&&u&&h.push(IH(this._remoteScreenPlayer,t,!0,f)),d&&c&&h.push(IH(this._remoteAudioPlayer,t,!1,f)),l&&u&&h.push(IH(this._remoteScreenAudioPlayer,t,!0,f)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(IH(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(IH(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Yf.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(K=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),TD(t)&&(s._pauseAllSubscribeState.audio=!0),kD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$k(iR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(z=Rm(km().mark((function e(t){var r,n,i,o,a,s=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),TD(t)&&(s._pauseAllSubscribeState.audio=!1),kD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$k(iR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){var r=s._subscribe(e.isScreen,e.userId,t).then((function(){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId]}));r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"sendUserMessage",value:(H=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jP(t),XP(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(G=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jP(t),LP(r,"message"),XP(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"sendRoomMessage",value:(j=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XP(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(B=Rm(km().mark((function e(t){var r,n,i,o=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XP(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(F=Rm(km().mark((function e(){var t,r=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},yW.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,UP(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(V=Rm(km().mark((function e(){var t,r=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},yW.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(U=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,UP(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return U.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return yW.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==oP?void 0:oP[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&xD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(L=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(yW.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),JP(t=Gs(t).call(t,(function(e){return!!e}))),t.length>3&&(xD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=Tm(t).call(t,0,3)),n=1;n<t.length;n++)i=OD(t[0].width)/OD(t[n].width)||1,Math.floor(i)!==i&&xD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");jR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(N=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yW.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(yW.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!iL())throw new vA(hA.NOT_SUPPORTED,"Browser does not support sending SEI");PP(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),OP(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(cD.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)yW.print("sei size must not bigger than 4KB");else{var l=oD();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=JR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rT(t=i.seiList).call(t,r,1)}}),2e3)}}else yW.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;yW.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=gE(e).call(e,(function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Nl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=pb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Nl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};yW.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:ED(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:ED(o)}})}if(e.safeEmit(Nl.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:ED(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:ED(o)}})}}))}));e.safeEmit(Nl.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Gs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(M=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k,I,R,A;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),PP(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,yW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(qU.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(_=this._room)||void 0===_||null===(f=_.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(y=this._screenPlayer)||void 0===y||y.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(k=T.observer)||void 0===k||k.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(P=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setExternalVideoTrack()","index: %o, track: %o",t,r),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),MP(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,IV(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,wV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setAudioSourceType",value:(D=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,T,k;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),PP(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,yW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(_=v.observer)||void 0===_||_.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(y=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(T=E.localScreenStream)||void 0===T||null===(k=T.observer)||void 0===k||k.setPushAudio(!1),null===(f=this._room)||void 0===f||null===(m=f.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(O=Rm(km().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("setExternalAudioTrack()","index: %o, track: %o",t,r),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),MP(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,AV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,OV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"login",value:(x=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("login()","token: %o, userInfo: %o",t,r),FP(t)||DP(t,"token"),jP(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"logout",value:(w=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return w.apply(this,arguments)})},{key:"updateLoginToken",value:(C=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("updateLoginToken()","token: %o",t),FP(t)||DP(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return C.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(A=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("getPeerOnlineStatus()","userId: %o",t),jP(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(R=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jP(t),XP(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(I=Rm(km().mark((function e(t,r){var n,i=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jP(t),LP(r,"message"),XP(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"setServerParams",value:(k=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return k.apply(this,arguments)})},{key:"sendServerMessage",value:(T=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DP(t,"message"),XP(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return T.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(E=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LP(t,"message"),XP(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new vA(hA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");yW.print("startCloudProxy()",e),DP(e.logProxy,"logProxy"),DP(e.accessProxy,"accessProxy"),DP(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=RP("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=RP("LOG_SERVER_URL"),this._originConfigServerUrls=RP("CONFIG_REQUEST_DOMAINS"),IP("ICE_CONFIG_REQUEST_URLS",e.accessProxy),IP("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),IP("CONFIG_REQUEST_DOMAINS",[e.configProxy]),mP.clearAccessNode(this._appId),mP.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new vA(hA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");yW.print("stopCloudProxy()"),IP("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),IP("LOG_SERVER_URL",this._originLogServerUrl),IP("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),mP.clearAccessNode(this._appId),mP.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(b=Rm(km().mark((function e(t,r){var n,i,o,a=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),GP(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new vA(hA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=AP(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(S=Rm(km().mark((function e(t,r){var n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),GP(t),this._assertNotInRoom(),i=AP(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"stopPushPublicStream",value:(g=Rm(km().mark((function e(t){var r,n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("startPushPublicStream()","publicStreamId: %o",t),GP(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"startPlayPublicStream",value:(y=Rm(km().mark((function e(t){var r,n,i,o,a,s,c=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(GP(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new rW(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(uG.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Nl.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(uG.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Nl.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new kH(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===Tl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(m=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioProfile",value:(f=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:yW.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;yW.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new TH(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(_=Rm(km().mark((function e(t,r){var n=this;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,i){DP(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new vA(hA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new vA(hA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return _.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=OD(r.width),c=OD(r.height);if(!a)throw new vA(hA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,p,v=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=v,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=v,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(p=this._localScreenVideoTrack)||void 0===p||p.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(km().mark((function e(r,n){var i,o,a;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Nl.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=Rm(km().mark((function e(t){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Nm(vW.getDefaultValue()))}},{key:"_updatePublish",value:(p=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},yW.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:lG.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new vA(hA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===GG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof vA)){e.next=24;break}throw e.t0;case 24:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),DP(t,"filePath"),OP(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){yW.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(km().mark((function e(t,r){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return yW.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),OP(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){yW.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){yW.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;yW.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{jP(e),PP(t,"priority",[yl.HIGH,yl.MEDIUM,yl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(km().mark((function e(t){var r,n;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("takeLocalSnapshot()","streamIndex: %o",t),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new vA(hA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",sW(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(km().mark((function e(t,r){var n,i,o,a,s,c;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yW.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),DP(t,"id"),PP(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=gE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",sW(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){yW.print("setSubscribeFallbackOption()","option: %o",e);try{PP(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof PV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=gE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=gE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(PP(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=QP(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(jP(e),PP(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=QP(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)xD("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;DP(e,"publicStreamId"),t=QP(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){BP(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(km().mark((function e(t){var r;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){BP(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(km().mark((function e(){var t;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){LO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(km().mark((function e(){var t,r,n,i=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},yW.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:lG.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===GG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof vA)){e.next=22;break}throw e.t0;case 22:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){yW.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new kH(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===Tl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),BD&&WD&&(t=this._remoteAudioPlayer,pW&&clearTimeout(pW),pW=setTimeout((function(){var e,r=$k(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&lA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$k(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&lA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;yW.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==Tl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(km().mark((function e(t){var r,n,i,o,a,s,c,u,d;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=NV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Yf((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Nl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Nl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Nl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Nl.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=NV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&TD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&kD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=bW[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Nl.onUserUnpublishScreen:Nl.onUserUnpublishStream,a=NV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==NV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Nl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Nl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Nl.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Nl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Nl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Nl.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$k(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&lA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Nl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Nl.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===lG.PUB?this.safeEmit(Nl.onUserPublishScreen,c):this.safeEmit(Nl.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===lG.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Nl.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Nl.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Nl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Nl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Nl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Nl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Nl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Nl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Nl.onError,{errorCode:hA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Nl.onError,{errorCode:hA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Nl.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Nl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==GG.CONNECTED)throw new vA(hA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){PP(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(km().mark((function e(t){var r,n,i;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===JU.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+o),LO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=mP.getServerConfig(this.appId);t.rts_report&&TO.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),VO({engineId:this.id,appId:this.appId,sdkVersion:RP("VERSION"),requestDomains:RP("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:RP("DEVICE_ID")}).then((function(t){mP.setServerConfig(e.appId,t)}))}}]),Ee}(tM);mW([MO()],gW.prototype,"updateToken",1),mW([MO()],gW.prototype,"setVideoCaptureDevice",1),mW([MO()],gW.prototype,"setAudioCaptureDevice",1),mW([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=PO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},MO()],gW.prototype,"connect",1),mW([MO()],gW.prototype,"joinRoom",1),mW([MO()],gW.prototype,"leaveRoom",1),mW([MO()],gW.prototype,"destroy",1),mW([MO()],gW.prototype,"publishStream",1),mW([MO()],gW.prototype,"unpublishStream",1),mW([MO()],gW.prototype,"publishScreen",1),mW([MO()],gW.prototype,"unpublishScreen",1),mW([MO()],gW.prototype,"subscribeStream",1),mW([MO()],gW.prototype,"unsubscribeStream",1),mW([MO()],gW.prototype,"subscribeScreen",1),mW([MO()],gW.prototype,"unsubscribeScreen",1),mW([MO()],gW.prototype,"setRemoteVideoConfig",1),mW([MO()],gW.prototype,"startVideoCapture",1),mW([MO()],gW.prototype,"stopVideoCapture",1),mW([MO()],gW.prototype,"startAudioCapture",1),mW([MO()],gW.prototype,"stopAudioCapture",1),mW([MO()],gW.prototype,"getAudioMixingManager",1),mW([MO()],gW.prototype,"startScreenCapture",1),mW([MO()],gW.prototype,"stopScreenCapture",1),mW([MO()],gW.prototype,"setLocalVideoPlayer",1),mW([MO()],gW.prototype,"startLiveTranscoding",1),mW([MO()],gW.prototype,"updateLiveTranscoding",1),mW([MO()],gW.prototype,"stopLiveTranscoding",1),mW([MO()],gW.prototype,"startSubtitle",1),mW([MO()],gW.prototype,"stopSubtitle",1),mW([MO()],gW.prototype,"setBusinessId",1),mW([MO()],gW.prototype,"setUserVisibility",1),mW([MO()],gW.prototype,"setRemoteVideoPlayer",1),mW([MO()],gW.prototype,"setLocalVideoMirrorType",1),mW([MO()],gW.prototype,"setAudioPlaybackDevice",1),mW([MO()],gW.prototype,"play",1),mW([MO()],gW.prototype,"pauseAllSubscribedStream",1),mW([MO()],gW.prototype,"resumeAllSubscribedStream",1),mW([MO()],gW.prototype,"sendUserMessage",1),mW([MO()],gW.prototype,"sendUserBinaryMessage",1),mW([MO()],gW.prototype,"sendRoomMessage",1),mW([MO()],gW.prototype,"sendRoomBinaryMessage",1),mW([MO()],gW.prototype,"setAudioCaptureConfig",1),mW([wD("4.51"),MO()],gW.prototype,"setVideoCaptureConfig",1),mW([MO()],gW.prototype,"enableSimulcastMode",1),mW([MO()],gW.prototype,"setVideoEncoderConfig",1),mW([MO()],gW.prototype,"setScreenEncoderConfig",1),mW([MO()],gW.prototype,"sendSEIMessage",1),mW([wD("4.42"),MO()],gW.prototype,"setAudioVolumeIndicationInterval",1),mW([MO()],gW.prototype,"enableAudioPropertiesReport",1),mW([MO()],gW.prototype,"setVideoSourceType",1),mW([MO()],gW.prototype,"setExternalVideoTrack",1),mW([MO()],gW.prototype,"setAudioSourceType",1),mW([MO()],gW.prototype,"setExternalAudioTrack",1),mW([MO()],gW.prototype,"login",1),mW([MO()],gW.prototype,"logout",1),mW([MO()],gW.prototype,"updateLoginToken",1),mW([MO()],gW.prototype,"getPeerOnlineStatus",1),mW([MO()],gW.prototype,"sendUserMessageOutsideRoom",1),mW([MO()],gW.prototype,"sendUserBinaryMessageOutsideRoom",1),mW([MO()],gW.prototype,"setServerParams",1),mW([MO()],gW.prototype,"sendServerMessage",1),mW([MO()],gW.prototype,"sendServerBinaryMessage",1),mW([MO()],gW.prototype,"startCloudProxy",1),mW([MO()],gW.prototype,"stopCloudProxy",1),mW([MO()],gW.prototype,"startPushPublicStream",1),mW([MO()],gW.prototype,"updatePublicStreamParam",1),mW([MO()],gW.prototype,"stopPushPublicStream",1),mW([MO("streamId")],gW.prototype,"startPlayPublicStream",1),mW([MO("streamId")],gW.prototype,"stopPlayPublicStream",1),mW([MO()],gW.prototype,"setAudioProfile",1),mW([MO()],gW.prototype,"setPublicStreamVideoPlayer",1),mW([MO()],gW.prototype,"setDummyCaptureImagePath",1),mW([MO()],gW.prototype,"registerExtension",1),mW([MO()],gW.prototype,"startAudioPlaybackDeviceTest",1),mW([MO()],gW.prototype,"stopAudioPlaybackDeviceTest",1),mW([MO()],gW.prototype,"startAudioDeviceRecordTest",1),mW([MO()],gW.prototype,"stopAudioDeviceRecordAndPlayTest",1),mW([MO()],gW.prototype,"stopAudioDevicePlayTest",1),mW([MO()],gW.prototype,"setRemoteUserPriority",1),mW([MO()],gW.prototype,"takeLocalSnapshot",1),mW([MO()],gW.prototype,"takeRemoteSnapshot",1),mW([MO()],gW.prototype,"setSubscribeFallbackOption",1),mW([MO()],gW.prototype,"getLocalStreamTrack",1),mW([MO()],gW.prototype,"getRemoteStreamTrack",1),mW([MO()],gW.prototype,"getPublicStreamTrack",1),mW([MO()],gW.prototype,"setRemoteStreamRenderSync",1),mW([MO()],gW.prototype,"startForwardStreamToRooms",1),mW([MO()],gW.prototype,"updateForwardStreamToRooms",1),mW([MO()],gW.prototype,"stopForwardStreamToRooms",1),mW([MO()],gW.prototype,"pauseForwardStreamToAllRooms",1),mW([MO()],gW.prototype,"resumeForwardStreamToAllRooms",1);var SW,bW={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH};function EW(e){var t=mP.getServerConfig(e).web_rtc_config;return!(null==t||!t.fallback)||!!RP("ENABLE_FALLBACK_HANDLER")}var TW=new yO("VERTC",0);vO.storeKey=Om(SW="".concat(Date.now(),"-")).call(SW,mP.getDeviceId()),IO({rtc_sdk_version:kP.VERSION,device_id:mP.getDeviceId(),log_cache_key:vO.storeKey}),RO(kP.LOG_SERVER_URL);var kW=1,IW=function(e,t){TW.print("createEngine","Invoke VERTC.createEngine"),DP(e,"appId");var r=(kW++).toString();return function(e,t){var r=new Yx(e);r.set(Zd(Zd({},t),{},{engine_session_id:oC()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),DO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new gW(e,r,t)},RW=function(e){if(TW.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof gW))throw new vA(hA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),DO.delete(t.id)},AW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),CW=function(){var e=Rm(km().mark((function e(){var t,r,n,i,o,a,s=arguments;return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,FU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,FU.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),wW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),OW=function(){var e=Rm(km().mark((function e(){return km().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),DW=function(){return kP.VERSION},PW=function(){return CO("isSupported",0,""),XN()},MW=function(){return CO("getSupportedCodecs",0,""),qN()},NW=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(vO.logLevel=t),r&&(vO.LogfileSize=r)},LW=function(e){vO.download(e)};function UW(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Nm(jm(t).call(t,(function(e){return e instanceof gW?"[ENGINE]":e})))}function VW(e,t){return function(){CO(t,0,UW.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return wO(t,0,UW(e)),e})).catch((function(e){throw wO(t,e.code,e.message),e})):(wO(t,0,UW(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",VW(DW,"getSdkVersion")),Jd(this,"createEngine",VW(IW,"createEngine")),Jd(this,"destroyEngine",VW(RW,"destroyEngine")),Jd(this,"enumerateDevices",VW(AW,"enumerateDevices")),Jd(this,"enableDevices",VW(CW,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",VW(wW,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",VW(xW,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",VW(OW,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",RP),Jd(this,"setParameter",IP),Jd(this,"isSupported",VW(PW,"isSupported")),Jd(this,"getSupportedCodecs",VW(MW,"getSupportedCodecs")),Jd(this,"events",Nl),Jd(this,"ErrorCode",hA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_454<c538baf>"),Jd(this,"downloadLog",VW(LW,"downloadLog")),Jd(this,"setLogConfig",VW(NW,"setLogConfig"))})))),xl),Ml),{},{events:Nl})}));
6
+ !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).BytePlusRTC=t()}(this,(function(){"use strict";function e(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(e){return e&&e.Math==Math&&e},n=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof t&&t)||function(){return this}()||Function("return this")(),i=function(e){try{return!!e()}catch(t){return!0}},o=!i((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),a=o,s=Function.prototype,c=s.apply,u=s.call,d="object"==typeof Reflect&&Reflect.apply||(a?u.bind(c):function(){return u.apply(c,arguments)}),l=o,h=Function.prototype,p=h.call,v=l&&h.bind.bind(p,p),_=l?v:function(e){return function(){return p.apply(e,arguments)}},f=_,m=f({}.toString),y=f("".slice),g=function(e){return y(m(e),8,-1)},S=g,b=_,E=function(e){if("Function"===S(e))return b(e)},k="object"==typeof document&&document.all,T={all:k,IS_HTMLDDA:void 0===k&&void 0!==k},I=T.all,R=T.IS_HTMLDDA?function(e){return"function"==typeof e||e===I}:function(e){return"function"==typeof e},A={},w=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),C=o,x=Function.prototype.call,O=C?x.bind(x):function(){return x.apply(x,arguments)},D={},M={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,N=P&&!M.call({1:2},1);D.f=N?function(e){var t=P(this,e);return!!t&&t.enumerable}:M;var L,U,V=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},F=i,B=g,j=Object,H=E("".split),G=F((function(){return!j("z").propertyIsEnumerable(0)}))?function(e){return"String"==B(e)?H(e,""):j(e)}:j,z=function(e){return null==e},K=z,X=TypeError,W=function(e){if(K(e))throw X("Can't call method on "+e);return e},q=G,Y=W,J=function(e){return q(Y(e))},Q=R,Z=T.all,$=T.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:Q(e)||e===Z}:function(e){return"object"==typeof e?null!==e:Q(e)},ee={},te=ee,re=n,ne=R,ie=function(e){return ne(e)?e:void 0},oe=function(e,t){return arguments.length<2?ie(te[e])||ie(re[e]):te[e]&&te[e][t]||re[e]&&re[e][t]},ae=E({}.isPrototypeOf),se=oe("navigator","userAgent")||"",ce=n,ue=se,de=ce.process,le=ce.Deno,he=de&&de.versions||le&&le.version,pe=he&&he.v8;pe&&(U=(L=pe.split("."))[0]>0&&L[0]<4?1:+(L[0]+L[1])),!U&&ue&&(!(L=ue.match(/Edge\/(\d+)/))||L[1]>=74)&&(L=ue.match(/Chrome\/(\d+)/))&&(U=+L[1]);var ve=U,_e=ve,fe=i,me=!!Object.getOwnPropertySymbols&&!fe((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&_e&&_e<41})),ye=me&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ge=oe,Se=R,be=ae,Ee=Object,ke=ye?function(e){return"symbol"==typeof e}:function(e){var t=ge("Symbol");return Se(t)&&be(t.prototype,Ee(e))},Te=String,Ie=function(e){try{return Te(e)}catch(t){return"Object"}},Re=R,Ae=Ie,we=TypeError,Ce=function(e){if(Re(e))return e;throw we(Ae(e)+" is not a function")},xe=Ce,Oe=z,De=function(e,t){var r=e[t];return Oe(r)?void 0:xe(r)},Me=O,Pe=R,Ne=$,Le=TypeError,Ue={exports:{}},Ve=n,Fe=Object.defineProperty,Be=function(e,t){try{Fe(Ve,e,{value:t,configurable:!0,writable:!0})}catch(r){Ve[e]=t}return t},je="__core-js_shared__",He=n[je]||Be(je,{}),Ge=He;(Ue.exports=function(e,t){return Ge[e]||(Ge[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.0",mode:"pure",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ze=W,Ke=Object,Xe=function(e){return Ke(ze(e))},We=Xe,qe=E({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return qe(We(e),t)},Je=E,Qe=0,Ze=Math.random(),$e=Je(1..toString),et=function(e){return"Symbol("+(void 0===e?"":e)+")_"+$e(++Qe+Ze,36)},tt=n,rt=Ue.exports,nt=Ye,it=et,ot=me,at=ye,st=rt("wks"),ct=tt.Symbol,ut=ct&&ct.for,dt=at?ct:ct&&ct.withoutSetter||it,lt=function(e){if(!nt(st,e)||!ot&&"string"!=typeof st[e]){var t="Symbol."+e;ot&&nt(ct,e)?st[e]=ct[e]:st[e]=at&&ut?ut(t):dt(t)}return st[e]},ht=O,pt=$,vt=ke,_t=De,ft=function(e,t){var r,n;if("string"===t&&Pe(r=e.toString)&&!Ne(n=Me(r,e)))return n;if(Pe(r=e.valueOf)&&!Ne(n=Me(r,e)))return n;if("string"!==t&&Pe(r=e.toString)&&!Ne(n=Me(r,e)))return n;throw Le("Can't convert object to primitive value")},mt=TypeError,yt=lt("toPrimitive"),gt=function(e,t){if(!pt(e)||vt(e))return e;var r,n=_t(e,yt);if(n){if(void 0===t&&(t="default"),r=ht(n,e,t),!pt(r)||vt(r))return r;throw mt("Can't convert object to primitive value")}return void 0===t&&(t="number"),ft(e,t)},St=ke,bt=function(e){var t=gt(e,"string");return St(t)?t:t+""},Et=$,kt=n.document,Tt=Et(kt)&&Et(kt.createElement),It=function(e){return Tt?kt.createElement(e):{}},Rt=It,At=!w&&!i((function(){return 7!=Object.defineProperty(Rt("div"),"a",{get:function(){return 7}}).a})),wt=w,Ct=O,xt=D,Ot=V,Dt=J,Mt=bt,Pt=Ye,Nt=At,Lt=Object.getOwnPropertyDescriptor;A.f=wt?Lt:function(e,t){if(e=Dt(e),t=Mt(t),Nt)try{return Lt(e,t)}catch(r){}if(Pt(e,t))return Ot(!Ct(xt.f,e,t),e[t])};var Ut=i,Vt=R,Ft=/#|\.prototype\./,Bt=function(e,t){var r=Ht[jt(e)];return r==zt||r!=Gt&&(Vt(t)?Ut(t):!!t)},jt=Bt.normalize=function(e){return String(e).replace(Ft,".").toLowerCase()},Ht=Bt.data={},Gt=Bt.NATIVE="N",zt=Bt.POLYFILL="P",Kt=Bt,Xt=Ce,Wt=o,qt=E(E.bind),Yt=function(e,t){return Xt(e),void 0===t?e:Wt?qt(e,t):function(){return e.apply(t,arguments)}},Jt={},Qt=w&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Zt=$,$t=String,er=TypeError,tr=function(e){if(Zt(e))return e;throw er($t(e)+" is not an object")},rr=w,nr=At,ir=Qt,or=tr,ar=bt,sr=TypeError,cr=Object.defineProperty,ur=Object.getOwnPropertyDescriptor,dr="enumerable",lr="configurable",hr="writable";Jt.f=rr?ir?function(e,t,r){if(or(e),t=ar(t),or(r),"function"==typeof e&&"prototype"===t&&"value"in r&&hr in r&&!r.writable){var n=ur(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:lr in r?r.configurable:n.configurable,enumerable:dr in r?r.enumerable:n.enumerable,writable:!1})}return cr(e,t,r)}:cr:function(e,t,r){if(or(e),t=ar(t),or(r),nr)try{return cr(e,t,r)}catch(n){}if("get"in r||"set"in r)throw sr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var pr=Jt,vr=V,_r=w?function(e,t,r){return pr.f(e,t,vr(1,r))}:function(e,t,r){return e[t]=r,e},fr=n,mr=d,yr=E,gr=R,Sr=A.f,br=Kt,Er=ee,kr=Yt,Tr=_r,Ir=Ye,Rr=function(e){var t=function(r,n,i){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,n)}return new e(r,n,i)}return mr(e,this,arguments)};return t.prototype=e.prototype,t},Ar=function(e,t){var r,n,i,o,a,s,c,u,d=e.target,l=e.global,h=e.stat,p=e.proto,v=l?fr:h?fr[d]:(fr[d]||{}).prototype,_=l?Er:Er[d]||Tr(Er,d,{})[d],f=_.prototype;for(i in t)r=!br(l?i:d+(h?".":"#")+i,e.forced)&&v&&Ir(v,i),a=_[i],r&&(s=e.dontCallGetSet?(u=Sr(v,i))&&u.value:v[i]),o=r&&s?s:t[i],r&&typeof a==typeof o||(c=e.bind&&r?kr(o,fr):e.wrap&&r?Rr(o):p&&gr(o)?yr(o):o,(e.sham||o&&o.sham||a&&a.sham)&&Tr(c,"sham",!0),Tr(_,i,c),p&&(Ir(Er,n=d+"Prototype")||Tr(Er,n,{}),Tr(Er[n],i,o),e.real&&f&&!f[i]&&Tr(f,i,o)))},wr=Math.ceil,Cr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Cr:wr)(t)},Or=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Dr=Or,Mr=Math.max,Pr=Math.min,Nr=function(e,t){var r=Dr(e);return r<0?Mr(r+t,0):Pr(r,t)},Lr=Or,Ur=Math.min,Vr=function(e){return e>0?Ur(Lr(e),9007199254740991):0},Fr=Vr,Br=function(e){return Fr(e.length)},jr=J,Hr=Nr,Gr=Br,zr=function(e){return function(t,r,n){var i,o=jr(t),a=Gr(o),s=Hr(n,a);if(e&&r!=r){for(;a>s;)if((i=o[s++])!=i)return!0}else for(;a>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},Kr={includes:zr(!0),indexOf:zr(!1)},Xr={},Wr=Ye,qr=J,Yr=Kr.indexOf,Jr=Xr,Qr=E([].push),Zr=function(e,t){var r,n=qr(e),i=0,o=[];for(r in n)!Wr(Jr,r)&&Wr(n,r)&&Qr(o,r);for(;t.length>i;)Wr(n,r=t[i++])&&(~Yr(o,r)||Qr(o,r));return o},$r=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],en=Zr,tn=$r,rn=Object.keys||function(e){return en(e,tn)},nn=Xe,on=rn;Ar({target:"Object",stat:!0,forced:i((function(){on(1)}))},{keys:function(e){return on(nn(e))}});var an=ee.Object.keys,sn={};sn[lt("toStringTag")]="z";var cn="[object z]"===String(sn),un=cn,dn=R,ln=g,hn=lt("toStringTag"),pn=Object,vn="Arguments"==ln(function(){return arguments}()),_n=un?ln:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=pn(e),hn))?r:vn?ln(t):"Object"==(n=ln(t))&&dn(t.callee)?"Arguments":n},fn=_n,mn=String,yn=function(e){if("Symbol"===fn(e))throw TypeError("Cannot convert a Symbol value to a string");return mn(e)},gn={},Sn=w,bn=Qt,En=Jt,kn=tr,Tn=J,In=rn;gn.f=Sn&&!bn?Object.defineProperties:function(e,t){kn(e);for(var r,n=Tn(t),i=In(t),o=i.length,a=0;o>a;)En.f(e,r=i[a++],n[r]);return e};var Rn,An=oe("document","documentElement"),wn=Ue.exports,Cn=et,xn=wn("keys"),On=function(e){return xn[e]||(xn[e]=Cn(e))},Dn=tr,Mn=gn,Pn=$r,Nn=Xr,Ln=An,Un=It,Vn=On("IE_PROTO"),Fn=function(){},Bn=function(e){return"<script>"+e+"</"+"script>"},jn=function(e){e.write(Bn("")),e.close();var t=e.parentWindow.Object;return e=null,t},Hn=function(){try{Rn=new ActiveXObject("htmlfile")}catch(n){}var e,t;Hn="undefined"!=typeof document?document.domain&&Rn?jn(Rn):((t=Un("iframe")).style.display="none",Ln.appendChild(t),t.src=String("javascript:"),(e=t.contentWindow.document).open(),e.write(Bn("document.F=Object")),e.close(),e.F):jn(Rn);for(var r=Pn.length;r--;)delete Hn.prototype[Pn[r]];return Hn()};Nn[Vn]=!0;var Gn=Object.create||function(e,t){var r;return null!==e?(Fn.prototype=Dn(e),r=new Fn,Fn.prototype=null,r[Vn]=e):r=Hn(),void 0===t?r:Mn.f(r,t)},zn={},Kn=Zr,Xn=$r.concat("length","prototype");zn.f=Object.getOwnPropertyNames||function(e){return Kn(e,Xn)};var Wn={},qn=bt,Yn=Jt,Jn=V,Qn=function(e,t,r){var n=qn(t);n in e?Yn.f(e,n,Jn(0,r)):e[n]=r},Zn=Nr,$n=Br,ei=Qn,ti=Array,ri=Math.max,ni=function(e,t,r){for(var n=$n(e),i=Zn(t,n),o=Zn(void 0===r?n:r,n),a=ti(ri(o-i,0)),s=0;i<o;i++,s++)ei(a,s,e[i]);return a.length=s,a},ii=g,oi=J,ai=zn.f,si=ni,ci="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Wn.f=function(e){return ci&&"Window"==ii(e)?function(e){try{return ai(e)}catch(t){return si(ci)}}(e):ai(oi(e))};var ui={};ui.f=Object.getOwnPropertySymbols;var di=_r,li=function(e,t,r,n){return n&&n.enumerable?e[t]=r:di(e,t,r),e},hi={},pi=lt;hi.f=pi;var vi,_i,fi,mi=ee,yi=Ye,gi=hi,Si=Jt.f,bi=function(e){var t=mi.Symbol||(mi.Symbol={});yi(t,e)||Si(t,e,{value:gi.f(e)})},Ei=O,ki=oe,Ti=lt,Ii=li,Ri=function(){var e=ki("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,n=Ti("toPrimitive");t&&!t[n]&&Ii(t,n,(function(e){return Ei(r,this)}),{arity:1})},Ai=_n,wi=cn?{}.toString:function(){return"[object "+Ai(this)+"]"},Ci=cn,xi=Jt.f,Oi=_r,Di=Ye,Mi=wi,Pi=lt("toStringTag"),Ni=function(e,t,r,n){if(e){var i=r?e:e.prototype;Di(i,Pi)||xi(i,Pi,{configurable:!0,value:t}),n&&!Ci&&Oi(i,"toString",Mi)}},Li=R,Ui=n.WeakMap,Vi=Li(Ui)&&/native code/.test(String(Ui)),Fi=Vi,Bi=n,ji=$,Hi=_r,Gi=Ye,zi=He,Ki=On,Xi=Xr,Wi="Object already initialized",qi=Bi.TypeError,Yi=Bi.WeakMap;if(Fi||zi.state){var Ji=zi.state||(zi.state=new Yi);Ji.get=Ji.get,Ji.has=Ji.has,Ji.set=Ji.set,vi=function(e,t){if(Ji.has(e))throw qi(Wi);return t.facade=e,Ji.set(e,t),t},_i=function(e){return Ji.get(e)||{}},fi=function(e){return Ji.has(e)}}else{var Qi=Ki("state");Xi[Qi]=!0,vi=function(e,t){if(Gi(e,Qi))throw qi(Wi);return t.facade=e,Hi(e,Qi,t),t},_i=function(e){return Gi(e,Qi)?e[Qi]:{}},fi=function(e){return Gi(e,Qi)}}var Zi={set:vi,get:_i,has:fi,enforce:function(e){return fi(e)?_i(e):vi(e,{})},getterFor:function(e){return function(t){var r;if(!ji(t)||(r=_i(t)).type!==e)throw qi("Incompatible receiver, "+e+" required");return r}}},$i=g,eo=Array.isArray||function(e){return"Array"==$i(e)},to=R,ro=He,no=E(Function.toString);to(ro.inspectSource)||(ro.inspectSource=function(e){return no(e)});var io=ro.inspectSource,oo=E,ao=i,so=R,co=_n,uo=io,lo=function(){},ho=[],po=oe("Reflect","construct"),vo=/^\s*(?:class|function)\b/,_o=oo(vo.exec),fo=!vo.exec(lo),mo=function(e){if(!so(e))return!1;try{return po(lo,ho,e),!0}catch(t){return!1}},yo=function(e){if(!so(e))return!1;switch(co(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return fo||!!_o(vo,uo(e))}catch(t){return!0}};yo.sham=!0;var go=!po||ao((function(){var e;return mo(mo.call)||!mo(Object)||!mo((function(){e=!0}))||e}))?yo:mo,So=eo,bo=go,Eo=$,ko=lt("species"),To=Array,Io=function(e){var t;return So(e)&&(t=e.constructor,(bo(t)&&(t===To||So(t.prototype))||Eo(t)&&null===(t=t[ko]))&&(t=void 0)),void 0===t?To:t},Ro=function(e,t){return new(Io(e))(0===t?0:t)},Ao=Yt,wo=G,Co=Xe,xo=Br,Oo=Ro,Do=E([].push),Mo=function(e){var t=1==e,r=2==e,n=3==e,i=4==e,o=6==e,a=7==e,s=5==e||o;return function(c,u,d,l){for(var h,p,v=Co(c),_=wo(v),f=Ao(u,d),m=xo(_),y=0,g=l||Oo,S=t?g(c,m):r||a?g(c,0):void 0;m>y;y++)if((s||y in _)&&(p=f(h=_[y],y,v),e))if(t)S[y]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return y;case 2:Do(S,h)}else switch(e){case 4:return!1;case 7:Do(S,h)}return o?-1:n||i?i:S}},Po={forEach:Mo(0),map:Mo(1),filter:Mo(2),some:Mo(3),every:Mo(4),find:Mo(5),findIndex:Mo(6),filterReject:Mo(7)},No=Ar,Lo=n,Uo=O,Vo=E,Fo=w,Bo=me,jo=i,Ho=Ye,Go=ae,zo=tr,Ko=J,Xo=bt,Wo=yn,qo=V,Yo=Gn,Jo=rn,Qo=zn,Zo=Wn,$o=ui,ea=A,ta=Jt,ra=gn,na=D,ia=li,oa=Ue.exports,aa=Xr,sa=et,ca=lt,ua=hi,da=bi,la=Ri,ha=Ni,pa=Zi,va=Po.forEach,_a=On("hidden"),fa="Symbol",ma=pa.set,ya=pa.getterFor(fa),ga=Object.prototype,Sa=Lo.Symbol,ba=Sa&&Sa.prototype,Ea=Lo.TypeError,ka=Lo.QObject,Ta=ea.f,Ia=ta.f,Ra=Zo.f,Aa=na.f,wa=Vo([].push),Ca=oa("symbols"),xa=oa("op-symbols"),Oa=oa("wks"),Da=!ka||!ka.prototype||!ka.prototype.findChild,Ma=Fo&&jo((function(){return 7!=Yo(Ia({},"a",{get:function(){return Ia(this,"a",{value:7}).a}})).a}))?function(e,t,r){var n=Ta(ga,t);n&&delete ga[t],Ia(e,t,r),n&&e!==ga&&Ia(ga,t,n)}:Ia,Pa=function(e,t){var r=Ca[e]=Yo(ba);return ma(r,{type:fa,tag:e,description:t}),Fo||(r.description=t),r},Na=function(e,t,r){e===ga&&Na(xa,t,r),zo(e);var n=Xo(t);return zo(r),Ho(Ca,n)?(r.enumerable?(Ho(e,_a)&&e[_a][n]&&(e[_a][n]=!1),r=Yo(r,{enumerable:qo(0,!1)})):(Ho(e,_a)||Ia(e,_a,qo(1,{})),e[_a][n]=!0),Ma(e,n,r)):Ia(e,n,r)},La=function(e,t){zo(e);var r=Ko(t),n=Jo(r).concat(Ba(r));return va(n,(function(t){Fo&&!Uo(Ua,r,t)||Na(e,t,r[t])})),e},Ua=function(e){var t=Xo(e),r=Uo(Aa,this,t);return!(this===ga&&Ho(Ca,t)&&!Ho(xa,t))&&(!(r||!Ho(this,t)||!Ho(Ca,t)||Ho(this,_a)&&this[_a][t])||r)},Va=function(e,t){var r=Ko(e),n=Xo(t);if(r!==ga||!Ho(Ca,n)||Ho(xa,n)){var i=Ta(r,n);return!i||!Ho(Ca,n)||Ho(r,_a)&&r[_a][n]||(i.enumerable=!0),i}},Fa=function(e){var t=Ra(Ko(e)),r=[];return va(t,(function(e){Ho(Ca,e)||Ho(aa,e)||wa(r,e)})),r},Ba=function(e){var t=e===ga,r=Ra(t?xa:Ko(e)),n=[];return va(r,(function(e){!Ho(Ca,e)||t&&!Ho(ga,e)||wa(n,Ca[e])})),n};Bo||(Sa=function(){if(Go(ba,this))throw Ea("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wo(arguments[0]):void 0,t=sa(e),r=function(e){this===ga&&Uo(r,xa,e),Ho(this,_a)&&Ho(this[_a],t)&&(this[_a][t]=!1),Ma(this,t,qo(1,e))};return Fo&&Da&&Ma(ga,t,{configurable:!0,set:r}),Pa(t,e)},ia(ba=Sa.prototype,"toString",(function(){return ya(this).tag})),ia(Sa,"withoutSetter",(function(e){return Pa(sa(e),e)})),na.f=Ua,ta.f=Na,ra.f=La,ea.f=Va,Qo.f=Zo.f=Fa,$o.f=Ba,ua.f=function(e){return Pa(ca(e),e)},Fo&&Ia(ba,"description",{configurable:!0,get:function(){return ya(this).description}})),No({global:!0,constructor:!0,wrap:!0,forced:!Bo,sham:!Bo},{Symbol:Sa}),va(Jo(Oa),(function(e){da(e)})),No({target:fa,stat:!0,forced:!Bo},{useSetter:function(){Da=!0},useSimple:function(){Da=!1}}),No({target:"Object",stat:!0,forced:!Bo,sham:!Fo},{create:function(e,t){return void 0===t?Yo(e):La(Yo(e),t)},defineProperty:Na,defineProperties:La,getOwnPropertyDescriptor:Va}),No({target:"Object",stat:!0,forced:!Bo},{getOwnPropertyNames:Fa}),la(),ha(Sa,fa),aa[_a]=!0;var ja=me&&!!Symbol.for&&!!Symbol.keyFor,Ha=Ar,Ga=oe,za=Ye,Ka=yn,Xa=Ue.exports,Wa=ja,qa=Xa("string-to-symbol-registry"),Ya=Xa("symbol-to-string-registry");Ha({target:"Symbol",stat:!0,forced:!Wa},{for:function(e){var t=Ka(e);if(za(qa,t))return qa[t];var r=Ga("Symbol")(t);return qa[t]=r,Ya[r]=t,r}});var Ja=Ar,Qa=Ye,Za=ke,$a=Ie,es=ja,ts=(0,Ue.exports)("symbol-to-string-registry");Ja({target:"Symbol",stat:!0,forced:!es},{keyFor:function(e){if(!Za(e))throw TypeError($a(e)+" is not a symbol");if(Qa(ts,e))return ts[e]}});var rs=E([].slice),ns=Ar,is=oe,os=d,as=O,ss=E,cs=i,us=eo,ds=R,ls=$,hs=ke,ps=rs,vs=me,_s=is("JSON","stringify"),fs=ss(/./.exec),ms=ss("".charAt),ys=ss("".charCodeAt),gs=ss("".replace),Ss=ss(1..toString),bs=/[\uD800-\uDFFF]/g,Es=/^[\uD800-\uDBFF]$/,ks=/^[\uDC00-\uDFFF]$/,Ts=!vs||cs((function(){var e=is("Symbol")();return"[null]"!=_s([e])||"{}"!=_s({a:e})||"{}"!=_s(Object(e))})),Is=cs((function(){return'"\\udf06\\ud834"'!==_s("\udf06\ud834")||'"\\udead"'!==_s("\udead")})),Rs=function(e,t){var r=ps(arguments),n=t;if((ls(t)||void 0!==e)&&!hs(e))return us(t)||(t=function(e,t){if(ds(n)&&(t=as(n,this,e,t)),!hs(t))return t}),r[1]=t,os(_s,null,r)},As=function(e,t,r){var n=ms(r,t-1),i=ms(r,t+1);return fs(Es,e)&&!fs(ks,i)||fs(ks,e)&&!fs(Es,n)?"\\u"+Ss(ys(e,0),16):e};_s&&ns({target:"JSON",stat:!0,arity:3,forced:Ts||Is},{stringify:function(e,t,r){var n=ps(arguments),i=os(Ts?Rs:_s,null,n);return Is&&"string"==typeof i?gs(i,bs,As):i}});var ws=ui,Cs=Xe;Ar({target:"Object",stat:!0,forced:!me||i((function(){ws.f(1)}))},{getOwnPropertySymbols:function(e){var t=ws.f;return t?t(Cs(e)):[]}});var xs=ee.Object.getOwnPropertySymbols,Os=i,Ds=ve,Ms=lt("species"),Ps=function(e){return Ds>=51||!Os((function(){var t=[];return(t.constructor={})[Ms]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ns=Po.filter;Ar({target:"Array",proto:!0,forced:!Ps("filter")},{filter:function(e){return Ns(this,e,arguments.length>1?arguments[1]:void 0)}});var Ls=ee,Us=function(e){return Ls[e+"Prototype"]},Vs=Us("Array").filter,Fs=ae,Bs=Vs,js=Array.prototype,Hs=function(e){var t=e.filter;return e===js||Fs(js,e)&&t===js.filter?Bs:t},Gs={exports:{}},zs=Ar,Ks=i,Xs=J,Ws=A.f,qs=w,Ys=Ks((function(){Ws(1)}));zs({target:"Object",stat:!0,forced:!qs||Ys,sham:!qs},{getOwnPropertyDescriptor:function(e,t){return Ws(Xs(e),t)}});var Js=ee.Object,Qs=Gs.exports=function(e,t){return Js.getOwnPropertyDescriptor(e,t)};Js.getOwnPropertyDescriptor.sham&&(Qs.sham=!0);var Zs,$s,ec,tc=Gs.exports,rc={},nc=w,ic=Ye,oc=Function.prototype,ac=nc&&Object.getOwnPropertyDescriptor,sc=ic(oc,"name"),cc={EXISTS:sc,PROPER:sc&&"something"===function(){}.name,CONFIGURABLE:sc&&(!nc||nc&&ac(oc,"name").configurable)},uc=!i((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),dc=Ye,lc=R,hc=Xe,pc=uc,vc=On("IE_PROTO"),_c=Object,fc=_c.prototype,mc=pc?_c.getPrototypeOf:function(e){var t=hc(e);if(dc(t,vc))return t[vc];var r=t.constructor;return lc(r)&&t instanceof r?r.prototype:t instanceof _c?fc:null},yc=i,gc=R,Sc=$,bc=Gn,Ec=mc,kc=li,Tc=lt("iterator"),Ic=!1;[].keys&&("next"in(ec=[].keys())?($s=Ec(Ec(ec)))!==Object.prototype&&(Zs=$s):Ic=!0);var Rc=!Sc(Zs)||yc((function(){var e={};return Zs[Tc].call(e)!==e}));gc((Zs=Rc?{}:bc(Zs))[Tc])||kc(Zs,Tc,(function(){return this}));var Ac={IteratorPrototype:Zs,BUGGY_SAFARI_ITERATORS:Ic},wc=Ac.IteratorPrototype,Cc=Gn,xc=V,Oc=Ni,Dc=rc,Mc=function(){return this},Pc=function(e,t,r,n){var i=t+" Iterator";return e.prototype=Cc(wc,{next:xc(+!n,r)}),Oc(e,i,!1,!0),Dc[i]=Mc,e},Nc=R,Lc=String,Uc=TypeError,Vc=E,Fc=tr,Bc=function(e){if("object"==typeof e||Nc(e))return e;throw Uc("Can't set "+Lc(e)+" as a prototype")},jc=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Vc(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]),t=r instanceof Array}catch(n){}return function(r,n){return Fc(r),Bc(n),t?e(r,n):r.__proto__=n,r}}():void 0),Hc=Ar,Gc=O,zc=cc,Kc=Pc,Xc=mc,Wc=Ni,qc=li,Yc=rc,Jc=Ac,Qc=zc.PROPER,Zc=Jc.BUGGY_SAFARI_ITERATORS,$c=lt("iterator"),eu="keys",tu="values",ru="entries",nu=function(){return this},iu=function(e,t,r,n,i,o,a){Kc(r,t,n);var s,c,u,d=function(e){if(e===i&&_)return _;if(!Zc&&e in p)return p[e];switch(e){case eu:case tu:case ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,v=p[$c]||p["@@iterator"]||i&&p[i],_=!Zc&&v||d(i),f="Array"==t&&p.entries||v;if(f&&(s=Xc(f.call(new e)))!==Object.prototype&&s.next&&(Wc(s,l,!0,!0),Yc[l]=nu),Qc&&i==tu&&v&&v.name!==tu&&(h=!0,_=function(){return Gc(v,this)}),i)if(c={values:d(tu),keys:o?_:d(eu),entries:d(ru)},a)for(u in c)(Zc||h||!(u in p))&&qc(p,u,c[u]);else Hc({target:t,proto:!0,forced:Zc||h},c);return a&&p[$c]!==_&&qc(p,$c,_,{name:i}),Yc[t]=_,c},ou=function(e,t){return{value:e,done:t}},au=J,su=function(){},cu=rc,uu=Zi,du=(Jt.f,iu),lu=ou,hu="Array Iterator",pu=uu.set,vu=uu.getterFor(hu);du(Array,"Array",(function(e,t){pu(this,{type:hu,target:au(e),index:0,kind:t})}),(function(){var e=vu(this),t=e.target,r=e.kind,n=e.index++;return!t||n>=t.length?(e.target=void 0,lu(void 0,!0)):lu("keys"==r?n:"values"==r?t[n]:[n,t[n]],!1)}),"values");cu.Arguments=cu.Array;su(),su(),su();var _u={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},fu=n,mu=_n,yu=_r,gu=rc,Su=lt("toStringTag");for(var bu in _u){var Eu=fu[bu],ku=Eu&&Eu.prototype;ku&&mu(ku)!==Su&&yu(ku,Su,bu),gu[bu]=gu.Array}var Tu=i,Iu=function(e,t){var r=[][e];return!!r&&Tu((function(){r.call(null,t||function(){return 1},1)}))},Ru=Po.forEach,Au=Iu("forEach")?[].forEach:function(e){return Ru(this,e,arguments.length>1?arguments[1]:void 0)};Ar({target:"Array",proto:!0,forced:[].forEach!=Au},{forEach:Au});var wu=Us("Array").forEach,Cu=_n,xu=Ye,Ou=ae,Du=wu,Mu=Array.prototype,Pu={DOMTokenList:!0,NodeList:!0},Nu=function(e){var t=e.forEach;return e===Mu||Ou(Mu,e)&&t===Mu.forEach||xu(Pu,Cu(e))?Du:t},Lu=oe,Uu=zn,Vu=ui,Fu=tr,Bu=E([].concat),ju=Lu("Reflect","ownKeys")||function(e){var t=Uu.f(Fu(e)),r=Vu.f;return r?Bu(t,r(e)):t},Hu=ju,Gu=J,zu=A,Ku=Qn;Ar({target:"Object",stat:!0,sham:!w},{getOwnPropertyDescriptors:function(e){for(var t,r,n=Gu(e),i=zu.f,o=Hu(n),a={},s=0;o.length>s;)void 0!==(r=i(n,t=o[s++]))&&Ku(a,t,r);return a}});var Xu=ee.Object.getOwnPropertyDescriptors,Wu={exports:{}},qu=Ar,Yu=w,Ju=gn.f;qu({target:"Object",stat:!0,forced:Object.defineProperties!==Ju,sham:!Yu},{defineProperties:Ju});var Qu=ee.Object,Zu=Wu.exports=function(e,t){return Qu.defineProperties(e,t)};Qu.defineProperties.sham&&(Zu.sham=!0);var $u=Wu.exports,ed={exports:{}},td=Ar,rd=w,nd=Jt.f;td({target:"Object",stat:!0,forced:Object.defineProperty!==nd,sham:!rd},{defineProperty:nd});var id=ee.Object,od=ed.exports=function(e,t,r){return id.defineProperty(e,t,r)};id.defineProperty.sham&&(od.sham=!0);var ad=ed.exports,sd=TypeError,cd=function(e){if(e>9007199254740991)throw sd("Maximum allowed index exceeded");return e},ud=Ar,dd=i,ld=eo,hd=$,pd=Xe,vd=Br,_d=cd,fd=Qn,md=Ro,yd=Ps,gd=ve,Sd=lt("isConcatSpreadable"),bd=gd>=51||!dd((function(){var e=[];return e[Sd]=!1,e.concat()[0]!==e})),Ed=yd("concat"),kd=function(e){if(!hd(e))return!1;var t=e[Sd];return void 0!==t?!!t:ld(e)};ud({target:"Array",proto:!0,arity:1,forced:!bd||!Ed},{concat:function(e){var t,r,n,i,o,a=pd(this),s=md(a,0),c=0;for(t=-1,n=arguments.length;t<n;t++)if(kd(o=-1===t?a:arguments[t]))for(i=vd(o),_d(c+i),r=0;r<i;r++,c++)r in o&&fd(s,c,o[r]);else _d(c+1),fd(s,c++,o);return s.length=c,s}}),bi("asyncIterator"),bi("hasInstance"),bi("isConcatSpreadable"),bi("iterator"),bi("match"),bi("matchAll"),bi("replace"),bi("search"),bi("species"),bi("split");var Td=Ri;bi("toPrimitive"),Td();var Id=oe,Rd=Ni;bi("toStringTag"),Rd(Id("Symbol"),"Symbol"),bi("unscopables"),Ni(n.JSON,"JSON",!0);var Ad=ee.Symbol;bi("asyncDispose"),bi("dispose"),bi("matcher"),bi("metadataKey"),bi("observable"),bi("metadata"),bi("patternMatch"),bi("replaceAll");var wd=Ad,Cd=E,xd=Or,Od=yn,Dd=W,Md=Cd("".charAt),Pd=Cd("".charCodeAt),Nd=Cd("".slice),Ld=function(e){return function(t,r){var n,i,o=Od(Dd(t)),a=xd(r),s=o.length;return a<0||a>=s?e?"":void 0:(n=Pd(o,a))<55296||n>56319||a+1===s||(i=Pd(o,a+1))<56320||i>57343?e?Md(o,a):n:e?Nd(o,a,a+2):i-56320+(n-55296<<10)+65536}},Ud={codeAt:Ld(!1),charAt:Ld(!0)},Vd=Ud.charAt,Fd=yn,Bd=Zi,jd=iu,Hd=ou,Gd="String Iterator",zd=Bd.set,Kd=Bd.getterFor(Gd);jd(String,"String",(function(e){zd(this,{type:Gd,string:Fd(e),index:0})}),(function(){var e,t=Kd(this),r=t.string,n=t.index;return n>=r.length?Hd(void 0,!0):(e=Vd(r,n),t.index+=e.length,Hd(e,!1))}));var Xd=hi.f("iterator");function Wd(e){return(Wd="function"==typeof wd&&"symbol"==typeof Xd?function(e){return typeof e}:function(e){return e&&"function"==typeof wd&&e.constructor===wd&&e!==wd.prototype?"symbol":typeof e})(e)}var qd=hi.f("toPrimitive");function Yd(e){var t=function(e,t){if("object"!==Wd(e)||null===e)return e;var r=e[qd];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==Wd(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Wd(t)?t:String(t)}function Jd(e,t,r){return(t=Yd(t))in e?ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Qd(e,t){var r=an(e);if(xs){var n=xs(e);t&&(n=Hs(n).call(n,(function(t){return tc(e,t).enumerable}))),r.push.apply(r,n)}return r}function Zd(e){for(var t=1;t<arguments.length;t++){var r,n,i=null!=arguments[t]?arguments[t]:{};t%2?Nu(r=Qd(Object(i),!0)).call(r,(function(t){Jd(e,t,i[t])})):Xu?$u(e,Xu(i)):Nu(n=Qd(Object(i))).call(n,(function(t){ad(e,t,tc(i,t))}))}return e}var $d=function(e){return e[e.VIDEO_SOURCE_TYPE_EXTERNAL=0]="VIDEO_SOURCE_TYPE_EXTERNAL",e[e.VIDEO_SOURCE_TYPE_INTERNAL=1]="VIDEO_SOURCE_TYPE_INTERNAL",e}($d||{}),el=function(e){return e[e.AUDIO_SOURCE_TYPE_EXTERNAL=0]="AUDIO_SOURCE_TYPE_EXTERNAL",e[e.AUDIO_SOURCE_TYPE_INTERNAL=1]="AUDIO_SOURCE_TYPE_INTERNAL",e}(el||{}),tl=function(e){return e[e.QUIT=0]="QUIT",e[e.DROPPED=1]="DROPPED",e[e.SWITCH_TO_INVISIBLE=2]="SWITCH_TO_INVISIBLE",e[e.KICKED_BY_ADMIN=3]="KICKED_BY_ADMIN",e}(tl||{}),rl=function(e){return e[e.CHANNEL_PROFILE_COMMUNICATION=0]="CHANNEL_PROFILE_COMMUNICATION",e[e.CHANNEL_PROFILE_LIVE_BROADCASTING=1]="CHANNEL_PROFILE_LIVE_BROADCASTING",e}(rl||{}),nl=function(e){return e[e.AUTO_SUBSCRIBE_MODE=0]="AUTO_SUBSCRIBE_MODE",e[e.MANUAL_SUBSCRIBE_MODE=1]="MANUAL_SUBSCRIBE_MODE",e}(nl||{}),il=function(e){return e[e.SUBSCRIBE_SUCC=0]="SUBSCRIBE_SUCC",e[e.SUBSCRIBE_FAIL=1]="SUBSCRIBE_FAIL",e}(il||{}),ol=function(e){return e[e.PUBLISH_SUCC=0]="PUBLISH_SUCC",e[e.PUBLISH_FAIL=1]="PUBLISH_FAIL",e}(ol||{}),al=function(e){return e[e.MIRROR_MODE_OFF=0]="MIRROR_MODE_OFF",e[e.MIRROR_MODE_ON=1]="MIRROR_MODE_ON",e}(al||{}),sl=function(e){return e[e.RENDER_MODE_HIDDEN=0]="RENDER_MODE_HIDDEN",e[e.RENDER_MODE_FIT=1]="RENDER_MODE_FIT",e[e.RENDER_MODE_FILL=2]="RENDER_MODE_FILL",e}(sl||{}),cl=function(e){return e[e.STREAM_INDEX_MAIN=0]="STREAM_INDEX_MAIN",e[e.STREAM_INDEX_SCREEN=1]="STREAM_INDEX_SCREEN",e}(cl||{}),ul=function(e){return e[e.AUDIO=1]="AUDIO",e[e.VIDEO=2]="VIDEO",e[e.AUDIO_AND_VIDEO=3]="AUDIO_AND_VIDEO",e}(ul||{}),dl=function(e){return e[e.STREAM_REMOVE_REASON_UNPUBLISH=0]="STREAM_REMOVE_REASON_UNPUBLISH",e[e.STREAM_REMOVE_REASON_PUBLISH_FAILED=1]="STREAM_REMOVE_REASON_PUBLISH_FAILED",e[e.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED=2]="STREAM_REMOVE_REASON_KEEP_LIVE_FAILED",e[e.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED=3]="STREAM_REMOVE_REASON_CLIENT_DISCONNECTED",e[e.STREAM_REMOVE_REASON_REPUBLISH=4]="STREAM_REMOVE_REASON_REPUBLISH",e[e.STREAM_REMOVE_REASON_OTHER=5]="STREAM_REMOVE_REASON_OTHER",e}(dl||{}),ll=function(e){return e[e.CONNECTION_START=0]="CONNECTION_START",e[e.CONNECTION_STATE_DISCONNECTED=1]="CONNECTION_STATE_DISCONNECTED",e[e.CONNECTION_STATE_CONNECTING=2]="CONNECTION_STATE_CONNECTING",e[e.CONNECTION_STATE_CONNECTED=3]="CONNECTION_STATE_CONNECTED",e[e.CONNECTION_STATE_RECONNECTING=4]="CONNECTION_STATE_RECONNECTING",e[e.CONNECTION_STATE_RECONNECTED=5]="CONNECTION_STATE_RECONNECTED",e[e.CONNECTION_STATE_LOST=6]="CONNECTION_STATE_LOST",e}(ll||{}),hl=function(e){return e[e.MIRROR_TYPE_NONE=0]="MIRROR_TYPE_NONE",e[e.MIRROR_TYPE_RENDER=1]="MIRROR_TYPE_RENDER",e}(hl||{}),pl=function(e){return e[e.domestic=0]="domestic",e[e.overseas=1]="overseas",e}(pl||{}),vl=function(e){return e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE",e[e.UNREACHABLE=2]="UNREACHABLE",e}(vl||{}),_l=function(e){return e[e.AUDIO_AND_VIDEO=0]="AUDIO_AND_VIDEO",e[e.AUDIO_ONLY=1]="AUDIO_ONLY",e[e.VIDEO_ONLY=2]="VIDEO_ONLY",e}(_l||{}),fl=function(e){return e[e.PREV_FRAME=0]="PREV_FRAME",e[e.OTHER_FRAME=1]="OTHER_FRAME",e}(fl||{}),ml=function(e){return e[e.DISABLE=0]="DISABLE",e[e.VIDEO_STREAM_LOW=1]="VIDEO_STREAM_LOW",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e}(ml||{}),yl=function(e){return e[e.LOW=0]="LOW",e[e.MEDIUM=100]="MEDIUM",e[e.HIGH=200]="HIGH",e}(yl||{}),gl=function(e){return e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VBAD=5]="VBAD",e}(gl||{}),Sl=function(e){return e[e.Unknown=-1]="Unknown",e[e.SubscribeFallbackByBandwidth=0]="SubscribeFallbackByBandwidth",e[e.SubscribeRecoverByBandwidth=2]="SubscribeRecoverByBandwidth",e}(Sl||{}),bl=function(e){return e[e.communication=0]="communication",e[e.chat=5]="chat",e[e.chatRoom=6]="chatRoom",e[e.coHost=9]="coHost",e[e.meeting=16]="meeting",e[e.classRoom=18]="classRoom",e}(bl||{}),El=function(e){return e[e.default=0]="default",e[e.fluent=1]="fluent",e[e.standard=2]="standard",e[e.hd=3]="hd",e[e.standardStereo=4]="standardStereo",e[e.hdMono=5]="hdMono",e}(El||{}),kl=function(e){return e[e.AUTO_PLAY=0]="AUTO_PLAY",e[e.VIDEO_ONLY=1]="VIDEO_ONLY",e[e.PLAY_MANUALLY=2]="PLAY_MANUALLY",e}(kl||{}),Tl=function(e){return e.LC="LC",e.HEv1="HEv1",e.HEv2="HEv2",e}(Tl||{}),Il=function(e){return e.H264="H264",e.H265="H265",e}(Il||{}),Rl=function(e){return e[e.ASR_ONLY=0]="ASR_ONLY",e[e.ASR_AND_TRANSLATION=1]="ASR_AND_TRANSLATION",e}(Rl||{}),Al=function(e){return e[e.STARTED=0]="STARTED",e[e.STOPPED=1]="STOPPED",e[e.ERROR=2]="ERROR",e}(Al||{}),wl=function(e){return e[e.FORWARD_STREAM_STATE_SUCCESS=0]="FORWARD_STREAM_STATE_SUCCESS",e[e.FORWARD_STREAM_STATE_FAILURE=1]="FORWARD_STREAM_STATE_FAILURE",e}(wl||{}),Cl=function(e){return e[e.FORWARD_STREAM_ERROR_OK=0]="FORWARD_STREAM_ERROR_OK",e[e.FORWARD_STREAM_ERROR_INVALID_TOKEN=1202]="FORWARD_STREAM_ERROR_INVALID_TOKEN",e[e.FORWARD_STREAM_ERROR_RESPONSE=1203]="FORWARD_STREAM_ERROR_RESPONSE",e[e.FORWARD_STREAM_ERROR_REMOTE_KICKED=1204]="FORWARD_STREAM_ERROR_REMOTE_KICKED",e[e.FORWARD_STREAM_ERROR_NOT_SUPPORT=1205]="FORWARD_STREAM_ERROR_NOT_SUPPORT",e}(Cl||{}),xl=Object.freeze(Object.defineProperty({__proto__:null,VideoSourceType:$d,AudioSourceType:el,UserOfflineReason:tl,ChannelProfile:rl,SubscribeMode:nl,SubscribeState:il,PublishState:ol,MirrorMode:al,VideoRenderMode:sl,StreamIndex:cl,MediaType:ul,StreamRemoveReason:dl,ConnectionState:ll,MirrorType:hl,LogChannel:pl,USER_ONLINE_STATUS:vl,PublicStreamType:_l,PublicInterpolationMode:fl,SubscribeFallbackOption:ml,RemoteUserPriority:yl,NetworkQuality:gl,FallbackOrRecoverReason:Sl,RoomProfileType:bl,AudioProfileType:El,RTCAutoPlayPolicy:kl,AAC_PROFILE:Tl,TRANSCODING_VIDEO_CODEC:Il,SUBTITLE_MODE:Rl,SubtitleEventType:Al,ForwardStreamState:wl,ForwardStreamError:Cl},Symbol.toStringTag,{value:"Module"})),Ol=function(e){return e[e.AUTO=0]="AUTO",e[e.MODE_L=1]="MODE_L",e[e.MODE_R=2]="MODE_R",e[e.MODE_MIX=3]="MODE_MIX",e}(Ol||{}),Dl=function(e){return e[e.PLAYOUT=0]="PLAYOUT",e[e.PUBLISH=1]="PUBLISH",e[e.PLAYOUT_AND_PUBLISH=2]="PLAYOUT_AND_PUBLISH",e}(Dl||{}),Ml=function(e){return e[e.AUDIO_MIXING_STATE_PRELOADED=0]="AUDIO_MIXING_STATE_PRELOADED",e[e.AUDIO_MIXING_STATE_PLAYING=1]="AUDIO_MIXING_STATE_PLAYING",e[e.AUDIO_MIXING_STATE_PAUSED=2]="AUDIO_MIXING_STATE_PAUSED",e[e.AUDIO_MIXING_STATE_STOPPED=3]="AUDIO_MIXING_STATE_STOPPED",e[e.AUDIO_MIXING_STATE_FAILED=4]="AUDIO_MIXING_STATE_FAILED",e[e.AUDIO_MIXING_STATE_FINISHED=5]="AUDIO_MIXING_STATE_FINISHED",e[e.AUDIO_MIXING_STATE_PCM_ENABLED=6]="AUDIO_MIXING_STATE_PCM_ENABLED",e[e.AUDIO_MIXING_STATE_PCM_DISABLED=7]="AUDIO_MIXING_STATE_PCM_DISABLED",e}(Ml||{}),Pl=Object.freeze(Object.defineProperty({__proto__:null,AudioMixingDualMonoMode:Ol,AudioMixingType:Dl,AudioMixingState:Ml},Symbol.toStringTag,{value:"Module"})),Nl=function(e){return e.onTrackEnded="onTrackEnded",e.onTrackMute="onTrackMute",e.onTrackUnmute="onTrackUnmute",e.onPlayerEvent="onPlayerEvent",e.onAutoplayFailed="onAutoplayFailed",e.onUserJoined="onUserJoined",e.onUserLeave="onUserLeave",e.onConnectionStateChanged="onConnectionStateChanged",e.onUserPublishStream="onUserPublishStream",e.onUserUnpublishStream="onUserUnpublishStream",e.onUserPublishScreen="onUserPublishScreen",e.onUserUnpublishScreen="onUserUnpublishScreen",e.onRoomMessageReceived="onRoomMessageReceived",e.onRoomBinaryMessageReceived="onRoomBinaryMessageReceived",e.onUserMessageReceived="onUserMessageReceived",e.onUserBinaryMessageReceived="onUserBinaryMessageReceived",e.onVideoFirstFrameRendered="onVideoFirstFrameRendered",e.onVideoFirstFrameDecoded="onVideoFirstFrameDecoded",e.onRemoteVideoFirstFrame="onRemoteVideoFirstFrame",e.onAudioFirstFrameDecoded="onAudioFirstFrameDecoded",e.onRemoteAudioFirstFrame="onRemoteAudioFirstFrame",e.onFirstPublicStreamVideoFrameRendered="onFirstPublicStreamVideoFrameRendered",e.onFirstPublicStreamVideoFrameDecoded="onFirstPublicStreamVideoFrameDecoded",e.onFirstPublicStreamAudioFrameDecoded="onFirstPublicStreamAudioFrameDecoded",e.onVideoDeviceStateChanged="onVideoDeviceStateChanged",e.onAudioDeviceStateChanged="onAudioDeviceStateChanged",e.onRemoteStreamStats="onRemoteStreamStats",e.onPublicStreamStats="onPublicStreamStats",e.onLocalStreamStats="onLocalStreamStats",e.onAudioVolumeIndication="onAudioVolumeIndication",e.onLocalAudioPropertiesReport="onLocalAudioPropertiesReport",e.onRemoteAudioPropertiesReport="onRemoteAudioPropertiesReport",e.onActiveSpeaker="onActiveSpeaker",e.onAudioPlaybackDeviceChanged="onAudioPlaybackDeviceChanged",e.onUserStartVideoCapture="onUserStartVideoCapture",e.onUserStopVideoCapture="onUserStopVideoCapture",e.onUserStartAudioCapture="onUserStartAudioCapture",e.onUserStopAudioCapture="onUserStopAudioCapture",e.onAutoPublishResult="onAutoPublishResult",e.onAutoSubscribeResult="onAutoSubscribeResult",e.onLiveTranscodingResult="onLiveTranscodingResult",e.onStreamMixingEvent="onStreamMixingEvent",e.onAudioPlaybackDeviceTestVolume="onAudioPlaybackDeviceTestVolume",e.onSEIMessageReceived="onSEIMessageReceived",e.onError="onError",e.onAudioMixingStateChanged="onAudioMixingStateChanged",e.onUserMessageReceivedOutsideRoom="onUserMessageReceivedOutsideRoom",e.onUserBinaryMessageReceivedOutsideRoom="onUserBinaryMessageReceivedOutsideRoom",e.onTokenWillExpire="onTokenWillExpire",e.onCloudProxyConnected="onCloudProxyConnected",e.onPushPublicStreamResult="onPushPublicStreamResult",e.onPublicStreamSEIMessageReceived="onPublicStreamSEIMessageReceived",e.onNetworkQuality="onNetworkQuality",e.onSimulcastSubscribeFallback="onSimulcastSubscribeFallback",e.onRemoteVideoSizeChanged="onRemoteVideoSizeChanged",e.onVideoStreamBanned="onVideoStreamBanned",e.onAudioStreamBanned="onAudioStreamBanned",e.onLocalVideoSizeChanged="onLocalVideoSizeChanged",e.onSubtitleStateChanged="onSubtitleStateChanged",e.onSubtitleMessageReceived="onSubtitleMessageReceived",e.onServerParamsSetResult="onServerParamsSetResult",e.onLocalStreamTrackChangedByExtension="onLocalStreamTrackChangedByExtension",e.onVendorConnectionStateChanged="onVendorConnectionStateChanged",e.onForwardStreamError="onForwardStreamError",e.onRejoinWithTcp="onRejoinWithTcp",e.onIceConnectWithTcp="onIceConnectWithTcp",e}(Nl||{});function Ll(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),ad(e,Yd(n.key),n)}}function Ul(e,t,r){return t&&Ll(e.prototype,t),r&&Ll(e,r),ad(e,"prototype",{writable:!1}),e}function Vl(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Ar({target:"Object",stat:!0,sham:!w},{create:Gn});var Fl=ee.Object,Bl=function(e,t){return Fl.create(e,t)},jl=Xe,Hl=mc,Gl=uc;Ar({target:"Object",stat:!0,forced:i((function(){Hl(1)})),sham:!Gl},{getPrototypeOf:function(e){return Hl(jl(e))}});var zl=ee.Object.getPrototypeOf;Ar({target:"Object",stat:!0},{setPrototypeOf:jc});var Kl=ee.Object.setPrototypeOf,Xl=Ye,Wl=ju,ql=A,Yl=Jt,Jl=Error,Ql=E("".replace),Zl=String(Jl("zxcasd").stack),$l=/\n\s*at [^:]*:[^\n]*/,eh=$l.test(Zl),th=$,rh=_r,nh=rc,ih=lt("iterator"),oh=Array.prototype,ah=function(e){return void 0!==e&&(nh.Array===e||oh[ih]===e)},sh=_n,ch=De,uh=z,dh=rc,lh=lt("iterator"),hh=function(e){if(!uh(e))return ch(e,lh)||ch(e,"@@iterator")||dh[sh(e)]},ph=O,vh=Ce,_h=tr,fh=Ie,mh=hh,yh=TypeError,gh=function(e,t){var r=arguments.length<2?mh(e):t;if(vh(r))return _h(ph(r,e));throw yh(fh(e)+" is not iterable")},Sh=O,bh=tr,Eh=De,kh=function(e,t,r){var n,i;bh(e);try{if(!(n=Eh(e,"return"))){if("throw"===t)throw r;return r}n=Sh(n,e)}catch(o){i=!0,n=o}if("throw"===t)throw r;if(i)throw n;return bh(n),r},Th=Yt,Ih=O,Rh=tr,Ah=Ie,wh=ah,Ch=Br,xh=ae,Oh=gh,Dh=hh,Mh=kh,Ph=TypeError,Nh=function(e,t){this.stopped=e,this.result=t},Lh=Nh.prototype,Uh=function(e,t,r){var n,i,o,a,s,c,u,d=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),v=!(!r||!r.INTERRUPTED),_=Th(t,d),f=function(e){return n&&Mh(n,"normal",e),new Nh(!0,e)},m=function(e){return l?(Rh(e),v?_(e[0],e[1],f):_(e[0],e[1])):v?_(e,f):_(e)};if(h)n=e.iterator;else if(p)n=e;else{if(!(i=Dh(e)))throw Ph(Ah(e)+" is not iterable");if(wh(i)){for(o=0,a=Ch(e);a>o;o++)if((s=m(e[o]))&&xh(Lh,s))return s;return new Nh(!1)}n=Oh(e,i)}for(c=h?e.next:n.next;!(u=Ih(c,n)).done;){try{s=m(u.value)}catch(y){Mh(n,"throw",y)}if("object"==typeof s&&s&&xh(Lh,s))return s}return new Nh(!1)},Vh=yn,Fh=V,Bh=!i((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Fh(1,7)),7!==e.stack)})),jh=Ar,Hh=ae,Gh=mc,zh=jc,Kh=function(e,t,r){for(var n=Wl(t),i=Yl.f,o=ql.f,a=0;a<n.length;a++){var s=n[a];Xl(e,s)||r&&Xl(r,s)||i(e,s,o(t,s))}},Xh=Gn,Wh=_r,qh=V,Yh=function(e,t){if(eh&&"string"==typeof e&&!Jl.prepareStackTrace)for(;t--;)e=Ql(e,$l,"");return e},Jh=function(e,t){th(t)&&"cause"in t&&rh(e,"cause",t.cause)},Qh=Uh,Zh=function(e,t){return void 0===e?arguments.length<2?"":t:Vh(e)},$h=Bh,ep=lt("toStringTag"),tp=Error,rp=[].push,np=function(e,t){var r,n=arguments.length>2?arguments[2]:void 0,i=Hh(ip,this);zh?r=zh(tp(),i?Gh(this):ip):(r=i?this:Xh(ip),Wh(r,ep,"Error")),void 0!==t&&Wh(r,"message",Zh(t)),$h&&Wh(r,"stack",Yh(r.stack,1)),Jh(r,n);var o=[];return Qh(e,rp,{that:o}),Wh(r,"errors",o),r};zh?zh(np,tp):Kh(np,tp,{name:!0});var ip=np.prototype=Xh(tp.prototype,{constructor:qh(1,np),message:qh(1,""),name:qh(1,"AggregateError")});jh({global:!0,constructor:!0,arity:2},{AggregateError:np});var op,ap,sp,cp,up="process"==g(n.process),dp=oe,lp=Jt,hp=w,pp=lt("species"),vp=function(e){var t=dp(e),r=lp.f;hp&&t&&!t[pp]&&r(t,pp,{configurable:!0,get:function(){return this}})},_p=ae,fp=TypeError,mp=function(e,t){if(_p(t,e))return e;throw fp("Incorrect invocation")},yp=go,gp=Ie,Sp=TypeError,bp=function(e){if(yp(e))return e;throw Sp(gp(e)+" is not a constructor")},Ep=tr,kp=bp,Tp=z,Ip=lt("species"),Rp=function(e,t){var r,n=Ep(e).constructor;return void 0===n||Tp(r=Ep(n)[Ip])?t:kp(r)},Ap=TypeError,wp=function(e,t){if(e<t)throw Ap("Not enough arguments");return e},Cp=/(?:ipad|iphone|ipod).*applewebkit/i.test(se),xp=n,Op=d,Dp=Yt,Mp=R,Pp=Ye,Np=i,Lp=An,Up=rs,Vp=It,Fp=wp,Bp=Cp,jp=up,Hp=xp.setImmediate,Gp=xp.clearImmediate,zp=xp.process,Kp=xp.Dispatch,Xp=xp.Function,Wp=xp.MessageChannel,qp=xp.String,Yp=0,Jp={},Qp="onreadystatechange";try{op=xp.location}catch(eq){}var Zp=function(e){if(Pp(Jp,e)){var t=Jp[e];delete Jp[e],t()}},$p=function(e){return function(){Zp(e)}},ev=function(e){Zp(e.data)},tv=function(e){xp.postMessage(qp(e),op.protocol+"//"+op.host)};Hp&&Gp||(Hp=function(e){Fp(arguments.length,1);var t=Mp(e)?e:Xp(e),r=Up(arguments,1);return Jp[++Yp]=function(){Op(t,void 0,r)},ap(Yp),Yp},Gp=function(e){delete Jp[e]},jp?ap=function(e){zp.nextTick($p(e))}:Kp&&Kp.now?ap=function(e){Kp.now($p(e))}:Wp&&!Bp?(cp=(sp=new Wp).port2,sp.port1.onmessage=ev,ap=Dp(cp.postMessage,cp)):xp.addEventListener&&Mp(xp.postMessage)&&!xp.importScripts&&op&&"file:"!==op.protocol&&!Np(tv)?(ap=tv,xp.addEventListener("message",ev,!1)):ap=Qp in Vp("script")?function(e){Lp.appendChild(Vp("script")).onreadystatechange=function(){Lp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rv,nv,iv,ov,av,sv,cv,uv,dv={set:Hp,clear:Gp},lv=n,hv=/ipad|iphone|ipod/i.test(se)&&void 0!==lv.Pebble,pv=/web0s(?!.*chrome)/i.test(se),vv=n,_v=Yt,fv=A.f,mv=dv.set,yv=Cp,gv=hv,Sv=pv,bv=up,Ev=vv.MutationObserver||vv.WebKitMutationObserver,kv=vv.document,Tv=vv.process,Iv=vv.Promise,Rv=fv(vv,"queueMicrotask"),Av=Rv&&Rv.value;Av||(rv=function(){var e,t;for(bv&&(e=Tv.domain)&&e.exit();nv;){t=nv.fn,nv=nv.next;try{t()}catch(eq){throw nv?ov():iv=void 0,eq}}iv=void 0,e&&e.enter()},yv||bv||Sv||!Ev||!kv?!gv&&Iv&&Iv.resolve?((cv=Iv.resolve(void 0)).constructor=Iv,uv=_v(cv.then,cv),ov=function(){uv(rv)}):bv?ov=function(){Tv.nextTick(rv)}:(mv=_v(mv,vv),ov=function(){mv(rv)}):(av=!0,sv=kv.createTextNode(""),new Ev(rv).observe(sv,{characterData:!0}),ov=function(){sv.data=av=!av}));var wv=Av||function(e){var t={fn:e,next:void 0};iv&&(iv.next=t),nv||(nv=t,ov()),iv=t},Cv=n,xv=function(e){try{return{error:!1,value:e()}}catch(eq){return{error:!0,value:eq}}},Ov=function(){this.head=null,this.tail=null};Ov.prototype={add:function(e){var t={item:e,next:null};this.head?this.tail.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return this.head=e.next,this.tail===e&&(this.tail=null),e.item}};var Dv=Ov,Mv=n.Promise,Pv="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Nv=!Pv&&!up&&"object"==typeof window&&"object"==typeof document,Lv=n,Uv=Mv,Vv=R,Fv=Kt,Bv=io,jv=lt,Hv=Nv,Gv=Pv,zv=ve,Kv=Uv&&Uv.prototype,Xv=jv("species"),Wv=!1,qv=Vv(Lv.PromiseRejectionEvent),Yv={CONSTRUCTOR:Fv("Promise",(function(){var e=Bv(Uv),t=e!==String(Uv);if(!t&&66===zv)return!0;if(!Kv.catch||!Kv.finally)return!0;if(!zv||zv<51||!/native code/.test(e)){var r=new Uv((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Xv]=n,!(Wv=r.then((function(){}))instanceof n))return!0}return!t&&(Hv||Gv)&&!qv})),REJECTION_EVENT:qv,SUBCLASSING:Wv},Jv={},Qv=Ce,Zv=TypeError,$v=function(e){var t,r;this.promise=new e((function(e,n){if(void 0!==t||void 0!==r)throw Zv("Bad Promise constructor");t=e,r=n})),this.resolve=Qv(t),this.reject=Qv(r)};Jv.f=function(e){return new $v(e)};var e_,t_,r_=Ar,n_=up,i_=n,o_=O,a_=li,s_=Ni,c_=vp,u_=Ce,d_=R,l_=$,h_=mp,p_=Rp,v_=dv.set,__=wv,f_=function(e,t){var r=Cv.console;r&&r.error&&(1==arguments.length?r.error(e):r.error(e,t))},m_=xv,y_=Dv,g_=Zi,S_=Mv,b_=Yv,E_=Jv,k_="Promise",T_=b_.CONSTRUCTOR,I_=b_.REJECTION_EVENT,R_=g_.getterFor(k_),A_=g_.set,w_=S_&&S_.prototype,C_=S_,x_=w_,O_=i_.TypeError,D_=i_.document,M_=i_.process,P_=E_.f,N_=P_,L_=!!(D_&&D_.createEvent&&i_.dispatchEvent),U_="unhandledrejection",V_=function(e){var t;return!(!l_(e)||!d_(t=e.then))&&t},F_=function(e,t){var r,n,i,o=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,u=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&z_(t),t.rejection=1),!0===s?r=o:(d&&d.enter(),r=s(o),d&&(d.exit(),i=!0)),r===e.promise?u(O_("Promise-chain cycle")):(n=V_(r))?o_(n,r,c,u):c(r)):u(o)}catch(eq){d&&!i&&d.exit(),u(eq)}},B_=function(e,t){e.notified||(e.notified=!0,__((function(){for(var r,n=e.reactions;r=n.get();)F_(r,e);e.notified=!1,t&&!e.rejection&&H_(e)})))},j_=function(e,t,r){var n,i;L_?((n=D_.createEvent("Event")).promise=t,n.reason=r,n.initEvent(e,!1,!0),i_.dispatchEvent(n)):n={promise:t,reason:r},!I_&&(i=i_["on"+e])?i(n):e===U_&&f_("Unhandled promise rejection",r)},H_=function(e){o_(v_,i_,(function(){var t,r=e.facade,n=e.value;if(G_(e)&&(t=m_((function(){n_?M_.emit("unhandledRejection",n,r):j_(U_,r,n)})),e.rejection=n_||G_(e)?2:1,t.error))throw t.value}))},G_=function(e){return 1!==e.rejection&&!e.parent},z_=function(e){o_(v_,i_,(function(){var t=e.facade;n_?M_.emit("rejectionHandled",t):j_("rejectionhandled",t,e.value)}))},K_=function(e,t,r){return function(n){e(t,n,r)}},X_=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,B_(e,!0))},W_=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw O_("Promise can't be resolved itself");var n=V_(t);n?__((function(){var r={done:!1};try{o_(n,t,K_(W_,r,e),K_(X_,r,e))}catch(eq){X_(r,eq,e)}})):(e.value=t,e.state=1,B_(e,!1))}catch(eq){X_({done:!1},eq,e)}}};T_&&(x_=(C_=function(e){h_(this,x_),u_(e),o_(e_,this);var t=R_(this);try{e(K_(W_,t),K_(X_,t))}catch(eq){X_(t,eq)}}).prototype,(e_=function(e){A_(this,{type:k_,done:!1,notified:!1,parent:!1,reactions:new y_,rejection:!1,state:0,value:void 0})}).prototype=a_(x_,"then",(function(e,t){var r=R_(this),n=P_(p_(this,C_));return r.parent=!0,n.ok=!d_(e)||e,n.fail=d_(t)&&t,n.domain=n_?M_.domain:void 0,0==r.state?r.reactions.add(n):__((function(){F_(n,r)})),n.promise})),t_=function(){var e=new e_,t=R_(e);this.promise=e,this.resolve=K_(W_,t),this.reject=K_(X_,t)},E_.f=P_=function(e){return e===C_||undefined===e?new t_(e):N_(e)}),r_({global:!0,constructor:!0,wrap:!0,forced:T_},{Promise:C_}),s_(C_,k_,!1,!0),c_(k_);var q_=lt("iterator"),Y_=!1;try{var J_=0,Q_={next:function(){return{done:!!J_++}},return:function(){Y_=!0}};Q_[q_]=function(){return this},Array.from(Q_,(function(){throw 2}))}catch(eq){}var Z_=function(e,t){if(!t&&!Y_)return!1;var r=!1;try{var n={};n[q_]=function(){return{next:function(){return{done:r=!0}}}},e(n)}catch(eq){}return r},$_=Mv,ef=Yv.CONSTRUCTOR||!Z_((function(e){$_.all(e).then(void 0,(function(){}))})),tf=O,rf=Ce,nf=Jv,of=xv,af=Uh;Ar({target:"Promise",stat:!0,forced:ef},{all:function(e){var t=this,r=nf.f(t),n=r.resolve,i=r.reject,o=of((function(){var r=rf(t.resolve),o=[],a=0,s=1;af(e,(function(e){var c=a++,u=!1;s++,tf(r,t,e).then((function(e){u||(u=!0,o[c]=e,--s||n(o))}),i)})),--s||n(o)}));return o.error&&i(o.value),r.promise}});var sf=Ar,cf=Yv.CONSTRUCTOR;Mv&&Mv.prototype,sf({target:"Promise",proto:!0,forced:cf,real:!0},{catch:function(e){return this.then(void 0,e)}});var uf=O,df=Ce,lf=Jv,hf=xv,pf=Uh;Ar({target:"Promise",stat:!0,forced:ef},{race:function(e){var t=this,r=lf.f(t),n=r.reject,i=hf((function(){var i=df(t.resolve);pf(e,(function(e){uf(i,t,e).then(r.resolve,n)}))}));return i.error&&n(i.value),r.promise}});var vf=O,_f=Jv;Ar({target:"Promise",stat:!0,forced:Yv.CONSTRUCTOR},{reject:function(e){var t=_f.f(this);return vf(t.reject,void 0,e),t.promise}});var ff=tr,mf=$,yf=Jv,gf=function(e,t){if(ff(e),mf(t)&&t.constructor===e)return t;var r=yf.f(e);return(0,r.resolve)(t),r.promise},Sf=Ar,bf=Mv,Ef=Yv.CONSTRUCTOR,kf=gf,Tf=oe("Promise"),If=!Ef;Sf({target:"Promise",stat:!0,forced:true},{resolve:function(e){return kf(If&&this===Tf?bf:this,e)}});var Rf=O,Af=Ce,wf=Jv,Cf=xv,xf=Uh;Ar({target:"Promise",stat:!0},{allSettled:function(e){var t=this,r=wf.f(t),n=r.resolve,i=r.reject,o=Cf((function(){var r=Af(t.resolve),i=[],o=0,a=1;xf(e,(function(e){var s=o++,c=!1;a++,Rf(r,t,e).then((function(e){c||(c=!0,i[s]={status:"fulfilled",value:e},--a||n(i))}),(function(e){c||(c=!0,i[s]={status:"rejected",reason:e},--a||n(i))}))})),--a||n(i)}));return o.error&&i(o.value),r.promise}});var Of=O,Df=Ce,Mf=oe,Pf=Jv,Nf=xv,Lf=Uh,Uf="No one promise resolved";Ar({target:"Promise",stat:!0},{any:function(e){var t=this,r=Mf("AggregateError"),n=Pf.f(t),i=n.resolve,o=n.reject,a=Nf((function(){var n=Df(t.resolve),a=[],s=0,c=1,u=!1;Lf(e,(function(e){var d=s++,l=!1;c++,Of(n,t,e).then((function(e){l||u||(u=!0,i(e))}),(function(e){l||u||(l=!0,a[d]=e,--c||o(new r(a,Uf)))}))})),--c||o(new r(a,Uf))}));return a.error&&o(a.value),n.promise}});var Vf=Ar,Ff=Mv,Bf=i,jf=oe,Hf=R,Gf=Rp,zf=gf,Kf=Ff&&Ff.prototype;Vf({target:"Promise",proto:!0,real:!0,forced:!!Ff&&Bf((function(){Kf.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Gf(this,jf("Promise")),r=Hf(e);return this.then(r?function(r){return zf(t,e()).then((function(){return r}))}:e,r?function(r){return zf(t,e()).then((function(){throw r}))}:e)}});var Xf=ee.Promise,Wf=Jv,qf=xv;Ar({target:"Promise",stat:!0,forced:!0},{try:function(e){var t=Wf.f(this),r=qf(e);return(r.error?t.reject:t.resolve)(r.value),t.promise}});var Yf=Xf,Jf=Ar,Qf=eo,Zf=E([].reverse),$f=[1,2];Jf({target:"Array",proto:!0,forced:String($f)===String($f.reverse())},{reverse:function(){return Qf(this)&&(this.length=this.length),Zf(this)}});var em=Us("Array").reverse,tm=ae,rm=em,nm=Array.prototype,im=function(e){var t=e.reverse;return e===nm||tm(nm,e)&&t===nm.reverse?rm:t},om=Ar,am=eo,sm=go,cm=$,um=Nr,dm=Br,lm=J,hm=Qn,pm=lt,vm=rs,_m=Ps("slice"),fm=pm("species"),mm=Array,ym=Math.max;om({target:"Array",proto:!0,forced:!_m},{slice:function(e,t){var r,n,i,o=lm(this),a=dm(o),s=um(e,a),c=um(void 0===t?a:t,a);if(am(o)&&(r=o.constructor,(sm(r)&&(r===mm||am(r.prototype))||cm(r)&&null===(r=r[fm]))&&(r=void 0),r===mm||void 0===r))return vm(o,s,c);for(n=new(void 0===r?mm:r)(ym(c-s,0)),i=0;s<c;s++,i++)s in o&&hm(n,i,o[s]);return n.length=i,n}});var gm=Us("Array").slice,Sm=ae,bm=gm,Em=Array.prototype,km=function(e){var t=e.slice;return e===Em||Sm(Em,e)&&t===Em.slice?bm:t};function Tm(){Tm=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=ad||function(e,t,r){e[t]=r.value},i="function"==typeof wd?wd:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return ad(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(A){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var o=t&&t.prototype instanceof h?t:h,a=Bl(o.prototype),s=new T(i||[]);return n(a,"_invoke",{value:S(e,r,s)}),a}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(A){return{type:"throw",arg:A}}}e.wrap=u;var l={};function h(){}function p(){}function v(){}var _={};c(_,o,(function(){return this}));var f=zl&&zl(zl(I([])));f&&f!==t&&r.call(f,o)&&(_=f);var m=v.prototype=h.prototype=Bl(_);function y(e){var t;Nu(t=["next","throw","return"]).call(t,(function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){function i(n,o,a,s){var c=d(e[n],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==Wd(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,a,s)}),(function(e){i("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return i("throw",e,a,s)}))}s(c.arg)}var o;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return o=o?o.then(n,n):n()}})}function S(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=d(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===l)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function b(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=d(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var o=i.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function E(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function k(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],Nu(e).call(e,E,this),this.reset(!0)}function I(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:R}}function R(){return{value:void 0,done:!0}}return p.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:p,configurable:!0}),p.displayName=c(v,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Kl?Kl(e,v):(e.__proto__=v,c(e,s,"GeneratorFunction")),e.prototype=Bl(m),e},e.awrap=function(e){return{__await:e}},y(g.prototype),c(g.prototype,a,(function(){return this})),e.AsyncIterator=g,e.async=function(t,r,n,i,o){void 0===o&&(o=Yf);var a=new g(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},y(m),c(m,s,"Generator"),c(m,o,(function(){return this})),c(m,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return im(r).call(r),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=I,T.prototype={constructor:T,reset:function(e){var t;if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,Nu(t=this.tryEntries).call(t,k),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+km(n).call(n,1))&&(this[n]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(s&&c){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),k(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:I(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Im(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(eq){return void r(eq)}s.done?t(c):Yf.resolve(c).then(n,i)}function Rm(e){return function(){var t=this,r=arguments;return new Yf((function(n,i){var o=e.apply(t,r);function a(e){Im(o,n,i,a,s,"next",e)}function s(e){Im(o,n,i,a,s,"throw",e)}a(void 0)}))}}var Am=Us("Array").concat,wm=ae,Cm=Am,xm=Array.prototype,Om=function(e){var t=e.concat;return e===xm||wm(xm,e)&&t===xm.concat?Cm:t},Dm=ee,Mm=d;Dm.JSON||(Dm.JSON={stringify:JSON.stringify});var Pm=function(e,t,r){return Mm(Dm.JSON.stringify,null,arguments)},Nm=Pm,Lm=Po.map;Ar({target:"Array",proto:!0,forced:!Ps("map")},{map:function(e){return Lm(this,e,arguments.length>1?arguments[1]:void 0)}});var Um=Us("Array").map,Vm=ae,Fm=Um,Bm=Array.prototype,jm=function(e){var t=e.map;return e===Bm||Vm(Bm,e)&&t===Bm.map?Fm:t},Hm="\t\n\v\f\r                 \u2028\u2029\ufeff",Gm=W,zm=yn,Km=E("".replace),Xm="[\t\n\v\f\r                 \u2028\u2029\ufeff]",Wm=RegExp("^"+Xm+Xm+"*"),qm=RegExp(Xm+Xm+"*$"),Ym=function(e){return function(t){var r=zm(Gm(t));return 1&e&&(r=Km(r,Wm,"")),2&e&&(r=Km(r,qm,"")),r}},Jm={start:Ym(1),end:Ym(2),trim:Ym(3)},Qm=n,Zm=i,$m=E,ey=yn,ty=Jm.trim,ry=Hm,ny=Qm.parseInt,iy=Qm.Symbol,oy=iy&&iy.iterator,ay=/^[+-]?0x/i,sy=$m(ay.exec),cy=8!==ny(ry+"08")||22!==ny(ry+"0x16")||oy&&!Zm((function(){ny(Object(oy))}))?function(e,t){var r=ty(ey(e));return ny(r,t>>>0||(sy(ay,r)?16:10))}:ny;Ar({global:!0,forced:parseInt!=cy},{parseInt:cy});var uy=ee.parseInt,dy={exports:{}},ly=i((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})),hy=i,py=$,vy=g,_y=ly,fy=Object.isExtensible,my=hy((function(){fy(1)}))||_y?function(e){return!!py(e)&&((!_y||"ArrayBuffer"!=vy(e))&&(!fy||fy(e)))}:fy,yy=!i((function(){return Object.isExtensible(Object.preventExtensions({}))})),gy=Ar,Sy=E,by=Xr,Ey=$,ky=Ye,Ty=Jt.f,Iy=zn,Ry=Wn,Ay=my,wy=yy,Cy=!1,xy=et("meta"),Oy=0,Dy=function(e){Ty(e,xy,{value:{objectID:"O"+Oy++,weakData:{}}})},My=dy.exports={enable:function(){My.enable=function(){},Cy=!0;var e=Iy.f,t=Sy([].splice),r={};r[xy]=1,e(r).length&&(Iy.f=function(r){for(var n=e(r),i=0,o=n.length;i<o;i++)if(n[i]===xy){t(n,i,1);break}return n},gy({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Ry.f}))},fastKey:function(e,t){if(!Ey(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!ky(e,xy)){if(!Ay(e))return"F";if(!t)return"E";Dy(e)}return e[xy].objectID},getWeakData:function(e,t){if(!ky(e,xy)){if(!Ay(e))return!0;if(!t)return!1;Dy(e)}return e[xy].weakData},onFreeze:function(e){return wy&&Cy&&Ay(e)&&!ky(e,xy)&&Dy(e),e}};by[xy]=!0;var Py=Ar,Ny=n,Ly=dy.exports,Uy=i,Vy=_r,Fy=Uh,By=mp,jy=R,Hy=$,Gy=Ni,zy=Jt.f,Ky=Po.forEach,Xy=w,Wy=Zi.set,qy=Zi.getterFor,Yy=function(e,t,r){var n,i=-1!==e.indexOf("Map"),o=-1!==e.indexOf("Weak"),a=i?"set":"add",s=Ny[e],c=s&&s.prototype,u={};if(Xy&&jy(s)&&(o||c.forEach&&!Uy((function(){(new s).entries().next()})))){var d=(n=t((function(t,r){Wy(By(t,d),{type:e,collection:new s}),null!=r&&Fy(r,t[a],{that:t,AS_ENTRIES:i})}))).prototype,l=qy(e);Ky(["add","clear","delete","forEach","get","has","set","keys","values","entries"],(function(e){var t="add"==e||"set"==e;!(e in c)||o&&"clear"==e||Vy(d,e,(function(r,n){var i=l(this).collection;if(!t&&o&&!Hy(r))return"get"==e&&void 0;var a=i[e](0===r?0:r,n);return t?this:a}))})),o||zy(d,"size",{configurable:!0,get:function(){return l(this).collection.size}})}else n=r.getConstructor(t,e,i,a),Ly.enable();return Gy(n,e,!1,!0),u[e]=n,Py({global:!0,forced:!0},u),o||r.setStrong(n,e,i),n},Jy=li,Qy=function(e,t,r){for(var n in t)r&&r.unsafe&&e[n]?e[n]=t[n]:Jy(e,n,t[n],r);return e},Zy=Jt.f,$y=Gn,eg=Qy,tg=Yt,rg=mp,ng=z,ig=Uh,og=iu,ag=ou,sg=vp,cg=w,ug=dy.exports.fastKey,dg=Zi.set,lg=Zi.getterFor,hg={getConstructor:function(e,t,r,n){var i=e((function(e,i){rg(e,o),dg(e,{type:t,index:$y(null),first:void 0,last:void 0,size:0}),cg||(e.size=0),ng(i)||ig(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=lg(t),s=function(e,t,r){var n,i,o=a(e),s=c(e,t);return s?s.value=r:(o.last=s={index:i=ug(t,!0),key:t,value:r,previous:n=o.last,next:void 0,removed:!1},o.first||(o.first=s),n&&(n.next=s),cg?o.size++:e.size++,"F"!==i&&(o.index[i]=s)),e},c=function(e,t){var r,n=a(e),i=ug(t);if("F"!==i)return n.index[i];for(r=n.first;r;r=r.next)if(r.key==t)return r};return eg(o,{clear:function(){for(var e=a(this),t=e.index,r=e.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete t[r.index],r=r.next;e.first=e.last=void 0,cg?e.size=0:this.size=0},delete:function(e){var t=this,r=a(t),n=c(t,e);if(n){var i=n.next,o=n.previous;delete r.index[n.index],n.removed=!0,o&&(o.next=i),i&&(i.previous=o),r.first==n&&(r.first=i),r.last==n&&(r.last=o),cg?r.size--:t.size--}return!!n},forEach:function(e){for(var t,r=a(this),n=tg(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;)for(n(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!c(this,e)}}),eg(o,r?{get:function(e){var t=c(this,e);return t&&t.value},set:function(e,t){return s(this,0===e?0:e,t)}}:{add:function(e){return s(this,e=0===e?0:e,e)}}),cg&&Zy(o,"size",{get:function(){return a(this).size}}),i},setStrong:function(e,t,r){var n=t+" Iterator",i=lg(t),o=lg(n);og(e,t,(function(e,t){dg(this,{type:n,target:e,state:i(e),kind:t,last:void 0})}),(function(){for(var e=o(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?ag("keys"==t?r.key:"values"==t?r.value:[r.key,r.value],!1):(e.target=void 0,ag(void 0,!0))}),r?"entries":"values",!r,!0),sg(t)}};Yy("Map",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var pg=ee.Map,vg=Yt,_g=O,fg=Ce,mg=bp,yg=z,gg=Uh,Sg=[].push,bg=function(e){var t,r,n,i,o=arguments.length,a=o>1?arguments[1]:void 0;return mg(this),(t=void 0!==a)&&fg(a),yg(e)?new this:(r=[],t?(n=0,i=vg(a,o>2?arguments[2]:void 0),gg(e,(function(e){_g(Sg,r,i(e,n++))}))):gg(e,Sg,{that:r}),new this(r))};Ar({target:"Map",stat:!0,forced:!0},{from:bg});var Eg=rs,kg=function(){return new this(Eg(arguments))};Ar({target:"Map",stat:!0,forced:!0},{of:kg});var Tg=O,Ig=Ce,Rg=tr,Ag=function(){for(var e,t=Rg(this),r=Ig(t.delete),n=!0,i=0,o=arguments.length;i<o;i++)e=Tg(r,t,arguments[i]),n=n&&e;return!!n};Ar({target:"Map",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var wg=O,Cg=Ce,xg=tr,Og=function(e,t){var r,n,i=xg(this),o=Cg(i.get),a=Cg(i.has),s=Cg(i.set);return wg(a,i,e)?(r=wg(o,i,e),"update"in t&&(r=t.update(r,e,i),wg(s,i,e,r)),r):(n=t.insert(e,i),wg(s,i,e,n),n)};Ar({target:"Map",proto:!0,real:!0,forced:!0},{emplace:Og});var Dg=gh,Mg=tr,Pg=Yt,Ng=Dg,Lg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{every:function(e){var t=Mg(this),r=Ng(t),n=Pg(e,arguments.length>1?arguments[1]:void 0);return!Lg(r,(function(e,r,i){if(!n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var Ug=oe,Vg=Yt,Fg=O,Bg=Ce,jg=tr,Hg=Rp,Gg=Dg,zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{filter:function(e){var t=jg(this),r=Gg(t),n=Vg(e,arguments.length>1?arguments[1]:void 0),i=new(Hg(t,Ug("Map"))),o=Bg(i.set);return zg(r,(function(e,r){n(r,e,t)&&Fg(o,i,e,r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var Kg=tr,Xg=Yt,Wg=Dg,qg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{find:function(e){var t=Kg(this),r=Wg(t),n=Xg(e,arguments.length>1?arguments[1]:void 0);return qg(r,(function(e,r,i){if(n(r,e,t))return i(r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var Yg=tr,Jg=Yt,Qg=Dg,Zg=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{findKey:function(e){var t=Yg(this),r=Qg(t),n=Jg(e,arguments.length>1?arguments[1]:void 0);return Zg(r,(function(e,r,i){if(n(r,e,t))return i(e)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var $g=Ar,eS=O,tS=Ce,rS=gh,nS=Uh,iS=E([].push);$g({target:"Map",stat:!0,forced:!0},{groupBy:function(e,t){tS(t);var r=rS(e),n=new this,i=tS(n.has),o=tS(n.get),a=tS(n.set);return nS(r,(function(e){var r=t(e);eS(i,n,r)?iS(eS(o,n,r),e):eS(a,n,r,[e])}),{IS_ITERATOR:!0}),n}});var oS=tr,aS=Dg,sS=function(e,t){return e===t||e!=e&&t!=t},cS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{includes:function(e){return cS(aS(oS(this)),(function(t,r,n){if(sS(r,e))return n()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var uS=O,dS=Uh,lS=Ce;Ar({target:"Map",stat:!0,forced:!0},{keyBy:function(e,t){var r=new this;lS(t);var n=lS(r.set);return dS(e,(function(e){uS(n,r,t(e),e)})),r}});var hS=tr,pS=Dg,vS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{keyOf:function(e){return vS(pS(hS(this)),(function(t,r,n){if(r===e)return n(t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var _S=oe,fS=Yt,mS=O,yS=Ce,gS=tr,SS=Rp,bS=Dg,ES=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapKeys:function(e){var t=gS(this),r=bS(t),n=fS(e,arguments.length>1?arguments[1]:void 0),i=new(SS(t,_S("Map"))),o=yS(i.set);return ES(r,(function(e,r){mS(o,i,n(r,e,t),r)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var kS=oe,TS=Yt,IS=O,RS=Ce,AS=tr,wS=Rp,CS=Dg,xS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{mapValues:function(e){var t=AS(this),r=CS(t),n=TS(e,arguments.length>1?arguments[1]:void 0),i=new(wS(t,kS("Map"))),o=RS(i.set);return xS(r,(function(e,r){IS(o,i,e,n(r,e,t))}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),i}});var OS=Ce,DS=tr,MS=Uh;Ar({target:"Map",proto:!0,real:!0,arity:1,forced:!0},{merge:function(e){for(var t=DS(this),r=OS(t.set),n=arguments.length,i=0;i<n;)MS(arguments[i++],r,{that:t,AS_ENTRIES:!0});return t}});var PS=tr,NS=Ce,LS=Dg,US=Uh,VS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=PS(this),r=LS(t),n=arguments.length<2,i=n?void 0:arguments[1];if(NS(e),US(r,(function(r,o){n?(n=!1,i=o):i=e(i,o,r,t)}),{AS_ENTRIES:!0,IS_ITERATOR:!0}),n)throw VS("Reduce of empty map with no initial value");return i}});var FS=tr,BS=Yt,jS=Dg,HS=Uh;Ar({target:"Map",proto:!0,real:!0,forced:!0},{some:function(e){var t=FS(this),r=jS(t),n=BS(e,arguments.length>1?arguments[1]:void 0);return HS(r,(function(e,r,i){if(n(r,e,t))return i()}),{AS_ENTRIES:!0,IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var GS=O,zS=tr,KS=Ce,XS=TypeError;Ar({target:"Map",proto:!0,real:!0,forced:!0},{update:function(e,t){var r=zS(this),n=KS(r.get),i=KS(r.has),o=KS(r.set),a=arguments.length;KS(t);var s=GS(i,r,e);if(!s&&a<3)throw XS("Updating absent value");var c=s?GS(n,r,e):KS(a>2?arguments[2]:void 0)(e,r);return GS(o,r,e,t(c,e,r)),r}});var WS=O,qS=Ce,YS=R,JS=tr,QS=TypeError,ZS=function(e,t){var r,n=JS(this),i=qS(n.get),o=qS(n.has),a=qS(n.set),s=arguments.length>2?arguments[2]:void 0;if(!YS(t)&&!YS(s))throw QS("At least one callback required");return WS(o,n,e)?(r=WS(i,n,e),YS(t)&&(r=t(r),WS(a,n,e,r))):YS(s)&&(r=s(),WS(a,n,e,r)),r};Ar({target:"Map",proto:!0,real:!0,forced:!0},{upsert:ZS}),Ar({target:"Map",proto:!0,real:!0,name:"upsert",forced:!0},{updateOrInsert:ZS});var $S=pg,eb=Ce,tb=Xe,rb=G,nb=Br,ib=TypeError,ob=function(e){return function(t,r,n,i){eb(r);var o=tb(t),a=rb(o),s=nb(o),c=e?s-1:0,u=e?-1:1;if(n<2)for(;;){if(c in a){i=a[c],c+=u;break}if(c+=u,e?c<0:s<=c)throw ib("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=u)c in a&&(i=r(i,a[c],c,o));return i}},ab={left:ob(!1),right:ob(!0)}.left,sb=ve,cb=up;Ar({target:"Array",proto:!0,forced:!Iu("reduce")||!cb&&sb>79&&sb<83},{reduce:function(e){var t=arguments.length;return ab(this,e,t,t>1?arguments[1]:void 0)}});var ub=Us("Array").reduce,db=ae,lb=ub,hb=Array.prototype,pb=function(e){var t=e.reduce;return e===hb||db(hb,e)&&t===hb.reduce?lb:t},vb=w,_b=E,fb=O,mb=i,yb=rn,gb=ui,Sb=D,bb=Xe,Eb=G,kb=Object.assign,Tb=Object.defineProperty,Ib=_b([].concat),Rb=!kb||mb((function(){if(vb&&1!==kb({b:1},kb(Tb({},"a",{enumerable:!0,get:function(){Tb(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol(),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach((function(e){t[e]=e})),7!=kb({},e)[r]||yb(kb({},t)).join("")!=n}))?function(e,t){for(var r=bb(e),n=arguments.length,i=1,o=gb.f,a=Sb.f;n>i;)for(var s,c=Eb(arguments[i++]),u=o?Ib(yb(c),o(c)):yb(c),d=u.length,l=0;d>l;)s=u[l++],vb&&!fb(a,c,s)||(r[s]=c[s]);return r}:kb,Ab=Rb;Ar({target:"Object",stat:!0,arity:2,forced:Object.assign!==Ab},{assign:Ab});var wb=ee.Object.assign,Cb=$,xb=g,Ob=lt("match"),Db=function(e){var t;return Cb(e)&&(void 0!==(t=e[Ob])?!!t:"RegExp"==xb(e))},Mb=TypeError,Pb=function(e){if(Db(e))throw Mb("The method doesn't accept regular expressions");return e},Nb=lt("match"),Lb=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Nb]=!1,"/./"[e](t)}catch(n){}}return!1},Ub=Ar,Vb=E;A.f;var Fb=Vr,Bb=yn,jb=Pb,Hb=W,Gb=Lb,zb=Vb("".endsWith),Kb=Vb("".slice),Xb=Math.min;Ub({target:"String",proto:!0,forced:!Gb("endsWith")},{endsWith:function(e){var t=Bb(Hb(this));jb(e);var r=arguments.length>1?arguments[1]:void 0,n=t.length,i=void 0===r?n:Xb(Fb(r),n),o=Bb(e);return zb?zb(t,o,i):Kb(t,i-o.length,i)===o}});var Wb=Us("String").endsWith,qb=ae,Yb=Wb,Jb=String.prototype,Qb=function(e){var t=e.endsWith;return"string"==typeof e||e===Jb||qb(Jb,e)&&t===Jb.endsWith?Yb:t},Zb=!0,$b=!0;function eE(e,t,r){var n=e.match(t);return n&&n.length>=r&&uy(n[r],10)}function tE(e,t,r){if(e.RTCPeerConnection){var n=e.RTCPeerConnection.prototype,i=n.addEventListener;n.addEventListener=function(e,n){if(e!==t)return i.apply(this,arguments);var o=function(e){var t=r(e);t&&(n.handleEvent?n.handleEvent(t):n(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new $S),this._eventMap[t].set(n,o),i.apply(this,[e,o])};var o=n.removeEventListener;n.removeEventListener=function(e,r){if(e!==t||!this._eventMap||!this._eventMap[t])return o.apply(this,arguments);if(!this._eventMap[t].has(r))return o.apply(this,arguments);var n=this._eventMap[t].get(r);return this._eventMap[t].delete(r),0===this._eventMap[t].size&&delete this._eventMap[t],0===an(this._eventMap).length&&delete this._eventMap,o.apply(this,[e,n])},ad(n,"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})}}function rE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):(Zb=e,e?"adapter.js logging disabled":"adapter.js logging enabled")}function nE(e){return"boolean"!=typeof e?new Error("Argument type: "+Wd(e)+". Please use a boolean."):($b=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))}function iE(){if("object"===("undefined"==typeof window?"undefined":Wd(window))){if(Zb)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function oE(e,t){$b&&console.warn(e+" is deprecated, please use "+t+" instead.")}function aE(e){var t={browser:null,version:null};if(void 0===e||!e.navigator)return t.browser="Not a browser.",t;var r=e.navigator;if(r.mozGetUserMedia)t.browser="firefox",t.version=eE(r.userAgent,/Firefox\/(\d+)\./,1);else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=eE(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=eE(r.userAgent,/AppleWebKit\/(\d+)\./,1),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype}return t}function sE(e){return"[object Object]"===Object.prototype.toString.call(e)}function cE(e){var t;return sE(e)?pb(t=an(e)).call(t,(function(t,r){var n=sE(e[r]),i=n?cE(e[r]):e[r],o=n&&!an(i).length;return void 0===i||o?t:wb(t,Jd({},r,i))}),{}):e}function uE(e,t,r){t&&!r.has(t.id)&&(r.set(t.id,t),an(t).forEach((function(n){Qb(n).call(n,"Id")?uE(e,e.get(t[n]),r):Qb(n).call(n,"Ids")&&t[n].forEach((function(t){uE(e,e.get(t),r)}))})))}function dE(e,t,r){var n=r?"outbound-rtp":"inbound-rtp",i=new $S;if(null===t)return i;var o=[];return e.forEach((function(e){"track"===e.type&&e.trackIdentifier===t.id&&o.push(e)})),o.forEach((function(t){e.forEach((function(r){r.type===n&&r.trackId===t.id&&uE(e,r,i)}))})),i}var lE=Ar,hE=Po.find,pE="find",vE=!0;pE in[]&&Array(1).find((function(){vE=!1})),lE({target:"Array",proto:!0,forced:vE},{find:function(e){return hE(this,e,arguments.length>1?arguments[1]:void 0)}});var _E=Us("Array").find,fE=ae,mE=_E,yE=Array.prototype,gE=function(e){var t=e.find;return e===yE||fE(yE,e)&&t===yE.find?mE:t},SE=Ar,bE=Kr.indexOf,EE=Iu,kE=E([].indexOf),TE=!!kE&&1/kE([1],1,-0)<0,IE=EE("indexOf");SE({target:"Array",proto:!0,forced:TE||!IE},{indexOf:function(e){var t=arguments.length>1?arguments[1]:void 0;return TE?kE(this,e,t)||0:bE(this,e,t)}});var RE=Us("Array").indexOf,AE=ae,wE=RE,CE=Array.prototype,xE=function(e){var t=e.indexOf;return e===CE||AE(CE,e)&&t===CE.indexOf?wE:t},OE=w,DE=eo,ME=TypeError,PE=Object.getOwnPropertyDescriptor,NE=OE&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(eq){return eq instanceof TypeError}}(),LE=Ie,UE=TypeError,VE=function(e,t){if(!delete e[t])throw UE("Cannot delete property "+LE(t)+" of "+LE(e))},FE=Ar,BE=Xe,jE=Nr,HE=Or,GE=Br,zE=NE?function(e,t){if(DE(e)&&!PE(e,"length").writable)throw ME("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},KE=cd,XE=Ro,WE=Qn,qE=VE,YE=Ps("splice"),JE=Math.max,QE=Math.min;FE({target:"Array",proto:!0,forced:!YE},{splice:function(e,t){var r,n,i,o,a,s,c=BE(this),u=GE(c),d=jE(e,u),l=arguments.length;for(0===l?r=n=0:1===l?(r=0,n=u-d):(r=l-2,n=QE(JE(HE(t),0),u-d)),KE(u+r-n),i=XE(c,n),o=0;o<n;o++)(a=d+o)in c&&WE(i,o,c[a]);if(i.length=n,r<n){for(o=d;o<u-n;o++)s=o+r,(a=o+n)in c?c[s]=c[a]:qE(c,s);for(o=u;o>u-n+r;o--)qE(c,o-1)}else if(r>n)for(o=u-n;o>d;o--)s=o+r-1,(a=o+n-1)in c?c[s]=c[a]:qE(c,s);for(o=0;o<r;o++)c[o+d]=arguments[o+2];return zE(c,u-n+r),i}});var ZE=Us("Array").splice,$E=ae,ek=ZE,tk=Array.prototype,rk=function(e){var t=e.splice;return e===tk||$E(tk,e)&&t===tk.splice?ek:t},nk=Kr.includes;Ar({target:"Array",proto:!0,forced:i((function(){return!Array(1).includes()}))},{includes:function(e){return nk(this,e,arguments.length>1?arguments[1]:void 0)}});var ik=Us("Array").includes,ok=Ar,ak=Pb,sk=W,ck=yn,uk=Lb,dk=E("".indexOf);ok({target:"String",proto:!0,forced:!uk("includes")},{includes:function(e){return!!~dk(ck(sk(this)),ck(ak(e)),arguments.length>1?arguments[1]:void 0)}});var lk=Us("String").includes,hk=ae,pk=ik,vk=lk,_k=Array.prototype,fk=String.prototype,mk=function(e){var t=e.includes;return e===_k||hk(_k,e)&&t===_k.includes?pk:"string"==typeof e||e===fk||hk(fk,e)&&t===fk.includes?vk:t},yk=iE;function gk(e,t){var r=e&&e.navigator;if(r.mediaDevices){var n=function(e){if("object"!==Wd(e)||e.mandatory||e.optional)return e;var t,r={};(an(e).forEach((function(t){if("require"!==t&&"advanced"!==t&&"mediaSource"!==t){var n="object"===Wd(e[t])?e[t]:{ideal:e[t]};void 0!==n.exact&&"number"==typeof n.exact&&(n.min=n.max=n.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+km(t).call(t,1):"deviceId"===t?"sourceId":t};if(void 0!==n.ideal){r.optional=r.optional||[];var o={};"number"==typeof n.ideal?(o[i("min",t)]=n.ideal,r.optional.push(o),(o={})[i("max",t)]=n.ideal,r.optional.push(o)):(o[i("",t)]=n.ideal,r.optional.push(o))}void 0!==n.exact&&"number"!=typeof n.exact?(r.mandatory=r.mandatory||{},r.mandatory[i("",t)]=n.exact):["min","max"].forEach((function(e){void 0!==n[e]&&(r.mandatory=r.mandatory||{},r.mandatory[i(e,t)]=n[e])}))}})),e.advanced)&&(r.optional=Om(t=r.optional||[]).call(t,e.advanced));return r},i=function(e,i){if(t.version>=61)return i(e);if((e=JSON.parse(Nm(e)))&&"object"===Wd(e.audio)){var o=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])};o((e=JSON.parse(Nm(e))).audio,"autoGainControl","googAutoGainControl"),o(e.audio,"noiseSuppression","googNoiseSuppression"),e.audio=n(e.audio)}if(e&&"object"===Wd(e.video)){var a=e.video.facingMode;a=a&&("object"===Wd(a)?a:{ideal:a});var s,c=t.version<66;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!r.mediaDevices.getSupportedConstraints||!r.mediaDevices.getSupportedConstraints().facingMode||c))if(delete e.video.facingMode,"environment"===a.exact||"environment"===a.ideal?s=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(s=["front"]),s)return r.mediaDevices.enumerateDevices().then((function(t){t=Hs(t).call(t,(function(e){return"videoinput"===e.kind}));var r=gE(t).call(t,(function(e){return s.some((function(t){var r;return mk(r=e.label.toLowerCase()).call(r,t)}))}));return!r&&t.length&&mk(s).call(s,"back")&&(r=t[t.length-1]),r&&(e.video.deviceId=a.exact?{exact:r.deviceId}:{ideal:r.deviceId}),e.video=n(e.video),yk("chrome: "+Nm(e)),i(e)}));e.video=n(e.video)}return yk("chrome: "+Nm(e)),i(e)},o=function(e){return t.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(r.getUserMedia=function(e,t,n){i(e,(function(e){r.webkitGetUserMedia(e,t,(function(e){n&&n(o(e))}))}))}.bind(r),r.mediaDevices.getUserMedia){var a=r.mediaDevices.getUserMedia.bind(r.mediaDevices);r.mediaDevices.getUserMedia=function(e){return i(e,(function(e){return a(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 Yf.reject(o(e))}))}))}}}}function Sk(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function bk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("ontrack"in e.RTCPeerConnection.prototype)){ad(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 t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){var r=this;return this._ontrackpoly||(this._ontrackpoly=function(t){t.stream.addEventListener("addtrack",(function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.track.id})):i={track:n.track};var a=new Event("track");a.track=n.track,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)})),t.stream.getTracks().forEach((function(n){var i,o;e.RTCPeerConnection.prototype.getReceivers?i=gE(o=r.getReceivers()).call(o,(function(e){return e.track&&e.track.id===n.id})):i={track:n};var a=new Event("track");a.track=n,a.receiver=i,a.transceiver={receiver:i},a.streams=[t.stream],r.dispatchEvent(a)}))},this.addEventListener("addstream",this._ontrackpoly)),t.apply(this,arguments)}}else tE(e,"track",(function(e){return e.transceiver||ad(e,"transceiver",{value:{receiver:e.receiver}}),e}))}function Ek(e){if("object"===Wd(e)&&e.RTCPeerConnection&&!("getSenders"in e.RTCPeerConnection.prototype)&&"createDTMFSender"in e.RTCPeerConnection.prototype){var t=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(){var e;return this._senders=this._senders||[],km(e=this._senders).call(e)};var r=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){var i=r.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};var n=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t;n.apply(this,arguments);var r,i=xE(t=this._senders).call(t,e);-1!==i&&rk(r=this._senders).call(r,i,1)}}var i=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var r=this;this._senders=this._senders||[],i.apply(this,[e]),e.getTracks().forEach((function(e){r._senders.push(t(r,e))}))};var o=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;this._senders=this._senders||[],o.apply(this,[e]),e.getTracks().forEach((function(e){var r,n,i,o=gE(r=t._senders).call(r,(function(t){return t.track===e}));o&&rk(n=t._senders).call(n,xE(i=t._senders).call(i,o),1)}))}}else if("object"===Wd(e)&&e.RTCPeerConnection&&"getSenders"in e.RTCPeerConnection.prototype&&"createDTMFSender"in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!("dtmf"in e.RTCRtpSender.prototype)){var a=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){var e=this,t=a.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t},ad(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}})}}function kk(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){var e=this,r=km(Array.prototype).call(arguments),n=r[0],i=r[1],o=r[2];if(arguments.length>0&&"function"==typeof n)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof n))return t.apply(this,[]);var a=function(e){var t={};return e.result().forEach((function(e){var r={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach((function(t){r[t]=e.stat(t)})),t[r.id]=r})),t},s=function(e){var t;return new $S(jm(t=an(e)).call(t,(function(t){return[t,e[t]]})))};if(arguments.length>=2){var c=function(e){i(s(a(e)))};return t.apply(this,[c,n])}return new Yf((function(r,n){t.apply(e,[function(e){r(s(a(e)))},n])})).then(i,o)}}}function Tk(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver){if(!("getStats"in e.RTCRtpSender.prototype)){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});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 dE(t,e.track,!0)}))}}if(!("getStats"in e.RTCRtpReceiver.prototype)){var n=e.RTCPeerConnection.prototype.getReceivers;n&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,t=n.apply(this,[]);return t.forEach((function(t){return t._pc=e})),t}),tE(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 dE(t,e.track,!1)}))}}if("getStats"in e.RTCRtpSender.prototype&&"getStats"in e.RTCRtpReceiver.prototype){var i=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){var t,r,n,o=arguments[0];return this.getSenders().forEach((function(e){e.track===o&&(t?n=!0:t=e)})),this.getReceivers().forEach((function(e){return e.track===o&&(r?n=!0:r=e),e.track===o})),n||t&&r?Yf.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):t?t.getStats():r?r.getStats():Yf.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return i.apply(this,arguments)}}}}function Ik(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){var e,t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},jm(e=an(this._shimmedLocalStreams)).call(e,(function(e){return t._shimmedLocalStreams[e][0]}))};var t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){var n;if(!r)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};var i=t.apply(this,arguments);return this._shimmedLocalStreams[r.id]?-1===xE(n=this._shimmedLocalStreams[r.id]).call(n,i)&&this._shimmedLocalStreams[r.id].push(i):this._shimmedLocalStreams[r.id]=[r,i],i};var r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){var t,n,i=this;this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach((function(e){var t;if(gE(t=i.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")}));var o=this.getSenders();r.apply(this,arguments);var a=Hs(t=this.getSenders()).call(t,(function(e){return-1===xE(o).call(o,e)}));this._shimmedLocalStreams[e.id]=Om(n=[e]).call(n,a)};var n=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],n.apply(this,arguments)};var i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){var t=this;return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&an(this._shimmedLocalStreams).forEach((function(r){var n,i,o=xE(n=t._shimmedLocalStreams[r]).call(n,e);-1!==o&&rk(i=t._shimmedLocalStreams[r]).call(i,o,1);1===t._shimmedLocalStreams[r].length&&delete t._shimmedLocalStreams[r]})),i.apply(this,arguments)}}function Rk(e,t){if(e.RTCPeerConnection){if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return Ik(e);var r=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){var e=this,t=r.apply(this);return this._reverseStreams=this._reverseStreams||{},jm(t).call(t,(function(t){return e._reverseStreams[t.id]}))};var n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){var r=this;if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach((function(e){var t;if(gE(t=r.getSenders()).call(t,(function(t){return t.track===e})))throw new DOMException("Track already exists.","InvalidAccessError")})),!this._reverseStreams[t.id]){var i=new e.MediaStream(t.getTracks());this._streams[t.id]=i,this._reverseStreams[i.id]=t,t=i}n.apply(this,[t])};var i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.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,r){var n,i,o,a=this;if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var s=km([]).call(arguments,1);if(1!==s.length||!gE(n=s[0].getTracks()).call(n,(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 c=gE(i=this.getSenders()).call(i,(function(e){return e.track===t}));if(c)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};var u=this._streams[r.id];if(u)u.addTrack(t),Yf.resolve().then((function(){a.dispatchEvent(new Event("negotiationneeded"))}));else{var d=new e.MediaStream([t]);this._streams[r.id]=d,this._reverseStreams[d.id]=r,this.addStream(d)}return gE(o=this.getSenders()).call(o,(function(e){return e.track===t}))},["createOffer","createAnswer"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){var e=this,t=arguments,n=arguments.length&&"function"==typeof arguments[0];return n?r.apply(this,[function(r){var n=s(e,r);t[0].apply(null,[n])},function(e){t[1]&&t[1].apply(null,e)},arguments[2]]):r.apply(this,arguments).then((function(t){return s(e,t)}))}));e.RTCPeerConnection.prototype[t]=n[t]}));var o=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=c(this,arguments[0]),o.apply(this,arguments)):o.apply(this,arguments)};var a=tc(e.RTCPeerConnection.prototype,"localDescription");ad(e.RTCPeerConnection.prototype,"localDescription",{get:function(){var e=a.get.apply(this);return""===e.type?e:s(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){var t,r=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||{},an(this._streams).forEach((function(n){var i;gE(i=r._streams[n].getTracks()).call(i,(function(t){return e.track===t}))&&(t=r._streams[n])})),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function s(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(i.id,"g"),n.id)})),new RTCSessionDescription({type:t.type,sdp:r})}function c(e,t){var r=t.sdp;return an(e._reverseStreams||[]).forEach((function(t){var n=e._reverseStreams[t],i=e._streams[n.id];r=r.replace(new RegExp(n.id,"g"),i.id)})),new RTCSessionDescription({type:t.type,sdp:r})}}function Ak(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[t]}))}function wk(e,t){tE(e,"negotiationneeded",(function(e){var r=e.target;if(!(t.version<72||r.getConfiguration&&"plan-b"===r.getConfiguration().sdpSemantics)||"stable"===r.signalingState)return e}))}var Ck=Object.freeze(Object.defineProperty({__proto__:null,shimMediaStream:Sk,shimOnTrack:bk,shimGetSendersWithDtmf:Ek,shimGetStats:kk,shimSenderReceiverGetStats:Tk,shimAddTrackRemoveTrackWithNative:Ik,shimAddTrackRemoveTrack:Rk,shimPeerConnection:Ak,fixNegotiationNeeded:wk,shimGetUserMedia:gk,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&("function"==typeof t?e.navigator.mediaDevices.getDisplayMedia=function(r){return t(r).then((function(t){var n=r.video&&r.video.width,i=r.video&&r.video.height,o=r.video&&r.video.frameRate;return r.video={mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:t,maxFrameRate:o||3}},n&&(r.video.mandatory.maxWidth=n),i&&(r.video.mandatory.maxHeight=i),e.navigator.mediaDevices.getUserMedia(r)}))}:console.error("shimGetDisplayMedia: getSourceId argument is not a function"))}},Symbol.toStringTag,{value:"Module"}));Ar({target:"Array",stat:!0},{isArray:eo});var xk=ee.Array.isArray;function Ok(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Dk=hh,Mk=tr,Pk=kh,Nk=Yt,Lk=O,Uk=Xe,Vk=function(e,t,r,n){try{return n?t(Mk(r)[0],r[1]):t(r)}catch(eq){Pk(e,"throw",eq)}},Fk=ah,Bk=go,jk=Br,Hk=Qn,Gk=gh,zk=hh,Kk=Array,Xk=function(e){var t=Uk(e),r=Bk(this),n=arguments.length,i=n>1?arguments[1]:void 0,o=void 0!==i;o&&(i=Nk(i,n>2?arguments[2]:void 0));var a,s,c,u,d,l,h=zk(t),p=0;if(!h||this===Kk&&Fk(h))for(a=jk(t),s=r?new this(a):Kk(a);a>p;p++)l=o?i(t[p],p):t[p],Hk(s,p,l);else for(d=(u=Gk(t,h)).next,s=r?new this:[];!(c=Lk(d,u)).done;p++)l=o?Vk(u,i,[c.value,p],!0):c.value,Hk(s,p,l);return s.length=p,s},Wk=Xk;Ar({target:"Array",stat:!0,forced:!Z_((function(e){Array.from(e)}))},{from:Wk});var qk=ee.Array.from;function Yk(e,t){var r;if(e){if("string"==typeof e)return Ok(e,t);var n=km(r=Object.prototype.toString.call(e)).call(r,8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?qk(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ok(e,t):void 0}}function Jk(e){return function(e){if(xk(e))return Ok(e)}(e)||function(e){if(void 0!==wd&&null!=Dk(e)||null!=e["@@iterator"])return qk(e)}(e)||Yk(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var Qk=n,Zk=i,$k=yn,eT=Jm.trim,tT=E("".charAt),rT=Qk.parseFloat,nT=Qk.Symbol,iT=nT&&nT.iterator,oT=1/rT("\t\n\v\f\r                 \u2028\u2029\ufeff-0")!=-1/0||iT&&!Zk((function(){rT(Object(iT))}))?function(e){var t=eT($k(e)),r=rT(t);return 0===r&&"-"==tT(t,0)?-0:r}:rT;Ar({global:!0,forced:parseFloat!=oT},{parseFloat:oT});var aT=ee.parseFloat;function sT(e,t){var r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){oE("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){var i=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},o=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(e){return"object"===Wd(e)&&"object"===Wd(e.audio)&&(e=JSON.parse(Nm(e)),i(e.audio,"autoGainControl","mozAutoGainControl"),i(e.audio,"noiseSuppression","mozNoiseSuppression")),o(e)},n&&n.prototype.getSettings){var a=n.prototype.getSettings;n.prototype.getSettings=function(){var e=a.apply(this,arguments);return i(e,"mozAutoGainControl","autoGainControl"),i(e,"mozNoiseSuppression","noiseSuppression"),e}}if(n&&n.prototype.applyConstraints){var s=n.prototype.applyConstraints;n.prototype.applyConstraints=function(e){return"audio"===this.kind&&"object"===Wd(e)&&(e=JSON.parse(Nm(e)),i(e,"autoGainControl","mozAutoGainControl"),i(e,"noiseSuppression","mozNoiseSuppression")),s.apply(this,[e])}}}}function cT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function uT(e,t){if("object"===Wd(e)&&(e.RTCPeerConnection||e.mozRTCPeerConnection)){!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){var r=e.RTCPeerConnection.prototype[t],n=Jd({},t,(function(){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}));e.RTCPeerConnection.prototype[t]=n[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=km(Array.prototype).call(arguments),i=e[0],o=e[1],a=e[2];return n.apply(this,[i||null]).then((function(e){if(t.version<53&&!o)try{e.forEach((function(e){e.type=r[e.type]||e.type}))}catch(n){if("TypeError"!==n.name)throw n;e.forEach((function(t,n){e.set(n,wb({},t,{type:r[t.type]||t.type}))}))}return e})).then(o,a)}}}function dT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpSender.prototype))){var t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r});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):Yf.resolve(new $S)}}}function lT(e){if("object"===Wd(e)&&e.RTCPeerConnection&&e.RTCRtpSender&&(!e.RTCRtpSender||!("getStats"in e.RTCRtpReceiver.prototype))){var t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){var e=this,r=t.apply(this,[]);return r.forEach((function(t){return t._pc=e})),r}),tE(e,"track",(function(e){return e.receiver._pc=e.srcElement,e})),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}}function hT(e){e.RTCPeerConnection&&!("removeStream"in e.RTCPeerConnection.prototype)&&(e.RTCPeerConnection.prototype.removeStream=function(e){var t=this;oE("removeStream","removeTrack"),this.getSenders().forEach((function(r){var n;r.track&&mk(n=e.getTracks()).call(n,r.track)&&t.removeTrack(r)}))})}function pT(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function vT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];var e=arguments[1]&&arguments[1].sendEncodings;void 0===e&&(e=[]);var r=(e=Jk(e)).length>0;r&&e.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&&!(aT(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(aT(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")}));var n=t.apply(this,arguments);if(r){var i=n.sender,o=i.getParameters();(!("encodings"in o)||1===o.encodings.length&&0===an(o.encodings[0]).length)&&(o.encodings=e,i.sendEncodings=e,this.setParametersPromises.push(i.setParameters(o).then((function(){delete i.sendEncodings})).catch((function(){delete i.sendEncodings}))))}return n})}}function _T(e){if("object"===Wd(e)&&e.RTCRtpSender){var t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){var e,r=t.apply(this,arguments);"encodings"in r||(r.encodings=Om(e=[]).call(e,this.sendEncodings||[{}]));return r})}}function fT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}function mT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){var e=arguments,r=this;return this.setParametersPromises&&this.setParametersPromises.length?Yf.all(this.setParametersPromises).then((function(){return t.apply(r,e)})).finally((function(){r.setParametersPromises=[]})):t.apply(this,arguments)}}}var yT=Object.freeze(Object.defineProperty({__proto__:null,shimOnTrack:cT,shimPeerConnection:uT,shimSenderGetStats:dT,shimReceiverGetStats:lT,shimRemoveStream:hT,shimRTCDataChannel:pT,shimAddTransceiver:vT,shimGetParameters:_T,shimCreateOffer:fT,shimCreateAnswer:mT,shimGetUserMedia:sT,shimGetDisplayMedia:function(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){var n=new DOMException("getDisplayMedia without video constraints is undefined");return n.name="NotFoundError",n.code=8,Yf.reject(n)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}},Symbol.toStringTag,{value:"Module"}));function gT(e){if("object"===Wd(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 t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){var r,n=this;this._localStreams||(this._localStreams=[]),mk(r=this._localStreams).call(r,e)||this._localStreams.push(e),e.getAudioTracks().forEach((function(r){return t.call(n,r,e)})),e.getVideoTracks().forEach((function(r){return t.call(n,r,e)}))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var r=this,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return i&&i.forEach((function(e){var t;r._localStreams?mk(t=r._localStreams).call(t,e)||r._localStreams.push(e):r._localStreams=[e]})),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){var t,r,n=this;this._localStreams||(this._localStreams=[]);var i=xE(t=this._localStreams).call(t,e);if(-1!==i){rk(r=this._localStreams).call(r,i,1);var o=e.getTracks();this.getSenders().forEach((function(e){mk(o).call(o,e.track)&&n.removeTrack(e)}))}})}}function ST(e){if("object"===Wd(e)&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){ad(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){var r;if(t._remoteStreams||(t._remoteStreams=[]),!mk(r=t._remoteStreams).call(r,e)){t._remoteStreams.push(e);var n=new Event("addstream");n.stream=e,t.dispatchEvent(n)}}))})}});var t=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){var r;if(e._remoteStreams||(e._remoteStreams=[]),!(xE(r=e._remoteStreams).call(r,t)>=0)){e._remoteStreams.push(t);var n=new Event("addstream");n.stream=t,e.dispatchEvent(n)}}))}),t.apply(e,arguments)}}}function bT(e){if("object"===Wd(e)&&e.RTCPeerConnection){var t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,i=t.setLocalDescription,o=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){var n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Yf.resolve()):i},t.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Yf.resolve()):i};var s=function(e,t,r){var n=i.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){var n=o.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){var n=a.apply(this,[e]);return r?(n.then(t,r),Yf.resolve()):n},t.addIceCandidate=s}}function ET(e){var t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){var r=t.mediaDevices,n=r.getUserMedia.bind(r);t.mediaDevices.getUserMedia=function(e){return n(kT(e))}}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function kT(e){return e&&void 0!==e.video?wb({},e,{video:cE(e.video)}):e}function TT(e){if(e.RTCPeerConnection){var t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var o=e.iceServers[i];!o.hasOwnProperty("urls")&&o.hasOwnProperty("url")?(oE("RTCIceServer.url","RTCIceServer.urls"),(o=JSON.parse(Nm(o))).urls=o.url,delete o.url,n.push(o)):n.push(e.iceServers[i])}e.iceServers=n}return new t(e,r)},e.RTCPeerConnection.prototype=t.prototype,"generateCertificate"in t&&ad(e.RTCPeerConnection,"generateCertificate",{get:function(){return t.generateCertificate}})}}function IT(e){"object"===Wd(e)&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&ad(e.RTCTrackEvent.prototype,"transceiver",{get:function(){return{receiver:this.receiver}}})}function RT(e){var t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){var r,n;void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);var i=gE(r=this.getTransceivers()).call(r,(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",{direction:"recvonly"}),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);var o=gE(n=this.getTransceivers()).call(n,(function(e){return"video"===e.receiver.track.kind}));!1===e.offerToReceiveVideo&&o?"sendrecv"===o.direction?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":"recvonly"===o.direction&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):!0!==e.offerToReceiveVideo||o||this.addTransceiver("video",{direction:"recvonly"})}return t.apply(this,arguments)}}function AT(e){"object"!==Wd(e)||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var wT=Object.freeze(Object.defineProperty({__proto__:null,shimLocalStreamsAPI:gT,shimRemoteStreamsAPI:ST,shimCallbacksAPI:bT,shimGetUserMedia:ET,shimConstraints:kT,shimRTCIceServerUrls:TT,shimTrackEventTransceiver:IT,shimCreateOfferLegacy:RT,shimAudioContext:AT},Symbol.toStringTag,{value:"Module"})),CT=cc.PROPER,xT=i,OT=Hm,DT=Jm.trim;Ar({target:"String",proto:!0,forced:function(e){return xT((function(){return!!OT[e]()||"​…᠎"!=="​…᠎"[e]()||CT&&OT[e].name!==e}))}("trim")},{trim:function(){return DT(this)}});var MT,PT,NT=Us("String").trim,LT=ae,UT=NT,VT=String.prototype,FT=function(e){var t=e.trim;return"string"==typeof e||e===VT||LT(VT,e)&&t===VT.trim?UT:t},BT={exports:{}};MT=BT,(PT={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}}).localCName=PT.generateIdentifier(),PT.splitLines=function(e){var t;return jm(t=FT(e).call(e).split("\n")).call(t,(function(e){return FT(e).call(e)}))},PT.splitSections=function(e){var t=e.split("\nm=");return jm(t).call(t,(function(e,t){var r;return FT(r=t>0?"m="+e:e).call(r)+"\r\n"}))},PT.getDescription=function(e){var t=PT.splitSections(e);return t&&t[0]},PT.getMediaSections=function(e){var t=PT.splitSections(e);return t.shift(),t},PT.matchPrefix=function(e,t){var r;return Hs(r=PT.splitLines(e)).call(r,(function(e){return 0===xE(e).call(e,t)}))},PT.parseCandidate=function(e){for(var t,r={foundation:(t=0===xE(e).call(e,"a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:{1:"rtp",2:"rtcp"}[t[1]]||t[1],protocol:t[2].toLowerCase(),priority:uy(t[3],10),ip:t[4],address:t[4],port:uy(t[5],10),type:t[7]},n=8;n<t.length;n+=2)switch(t[n]){case"raddr":r.relatedAddress=t[n+1];break;case"rport":r.relatedPort=uy(t[n+1],10);break;case"tcptype":r.tcpType=t[n+1];break;case"ufrag":r.ufrag=t[n+1],r.usernameFragment=t[n+1];break;default:void 0===r[t[n]]&&(r[t[n]]=t[n+1])}return r},PT.writeCandidate=function(e){var t=[];t.push(e.foundation);var r=e.component;"rtp"===r?t.push(1):"rtcp"===r?t.push(2):t.push(r),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.address||e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&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(" ")},PT.parseIceOptions=function(e){return e.substr(14).split(" ")},PT.parseRtpMap=function(e){var t=e.substr(9).split(" "),r={payloadType:uy(t.shift(),10)};return t=t[0].split("/"),r.name=t[0],r.clockRate=uy(t[1],10),r.channels=3===t.length?uy(t[2],10):1,r.numChannels=r.channels,r},PT.writeRtpMap=function(e){var t=e.payloadType;void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType);var r=e.channels||e.numChannels||1;return"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==r?"/"+r:"")+"\r\n"},PT.parseExtmap=function(e){var t,r=e.substr(9).split(" ");return{id:uy(r[0],10),direction:xE(t=r[0]).call(t,"/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1]}},PT.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},PT.parseFmtp=function(e){for(var t,r={},n=e.substr(xE(e).call(e," ")+1).split(";"),i=0;i<n.length;i++){var o,a;t=FT(o=n[i]).call(o).split("="),r[FT(a=t[0]).call(a)]=t[1]}return r},PT.writeFmtp=function(e){var t="",r=e.payloadType;if(void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.parameters&&an(e.parameters).length){var n=[];an(e.parameters).forEach((function(t){void 0!==e.parameters[t]?n.push(t+"="+e.parameters[t]):n.push(t)})),t+="a=fmtp:"+r+" "+n.join(";")+"\r\n"}return t},PT.parseRtcpFb=function(e){var t=e.substr(xE(e).call(e," ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},PT.writeRtcpFb=function(e){var t="",r=e.payloadType;return void 0!==e.preferredPayloadType&&(r=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach((function(e){t+="a=rtcp-fb:"+r+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"})),t},PT.parseSsrcMedia=function(e){var t=xE(e).call(e," "),r={ssrc:uy(e.substr(7,t-7),10)},n=xE(e).call(e,":",t);return n>-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},PT.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:jm(t).call(t,(function(e){return uy(e,10)}))}},PT.getMid=function(e){var t=PT.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},PT.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1].toUpperCase()}},PT.getDtlsParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=fingerprint:");return{role:"auto",fingerprints:jm(r).call(r,PT.parseFingerprint)}},PT.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},PT.parseCryptoLine=function(e){var t=e.substr(9).split(" ");return{tag:uy(t[0],10),cryptoSuite:t[1],keyParams:t[2],sessionParams:km(t).call(t,3)}},PT.writeCryptoLine=function(e){return"a=crypto:"+e.tag+" "+e.cryptoSuite+" "+("object"===Wd(e.keyParams)?PT.writeCryptoKeyParams(e.keyParams):e.keyParams)+(e.sessionParams?" "+e.sessionParams.join(" "):"")+"\r\n"},PT.parseCryptoKeyParams=function(e){if(0!==xE(e).call(e,"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}},PT.writeCryptoKeyParams=function(e){return e.keyMethod+":"+e.keySalt+(e.lifeTime?"|"+e.lifeTime:"")+(e.mkiValue&&e.mkiLength?"|"+e.mkiValue+":"+e.mkiLength:"")},PT.getCryptoParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=crypto:");return jm(r).call(r,PT.parseCryptoLine)},PT.getIceParameters=function(e,t){var r=PT.matchPrefix(e+t,"a=ice-ufrag:")[0],n=PT.matchPrefix(e+t,"a=ice-pwd:")[0];return r&&n?{usernameFragment:r.substr(12),password:n.substr(10)}:null},PT.writeIceParameters=function(e){var t="a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n";return e.iceLite&&(t+="a=ice-lite\r\n"),t},PT.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=PT.splitLines(e)[0].split(" "),n=3;n<r.length;n++){var i=r[n],o=PT.matchPrefix(e,"a=rtpmap:"+i+" ")[0];if(o){var a,s=PT.parseRtpMap(o),c=PT.matchPrefix(e,"a=fmtp:"+i+" ");switch(s.parameters=c.length?PT.parseFmtp(c[0]):{},s.rtcpFeedback=jm(a=PT.matchPrefix(e,"a=rtcp-fb:"+i+" ")).call(a,PT.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return PT.matchPrefix(e,"a=extmap:").forEach((function(e){t.headerExtensions.push(PT.parseExtmap(e))})),t},PT.writeRtpDescription=function(e,t){var r,n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=jm(r=t.codecs).call(r,(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){n+=PT.writeRtpMap(e),n+=PT.writeFmtp(e),n+=PT.writeRtcpFb(e)}));var i=0;return t.codecs.forEach((function(e){e.maxptime>i&&(i=e.maxptime)})),i>0&&(n+="a=maxptime:"+i+"\r\n"),t.headerExtensions&&t.headerExtensions.forEach((function(e){n+=PT.writeExtmap(e)})),n},PT.parseRtpEncodingParameters=function(e){var t,r,n,i,o,a,s=[],c=PT.parseRtpParameters(e),u=-1!==xE(t=c.fecMechanisms).call(t,"RED"),d=-1!==xE(r=c.fecMechanisms).call(r,"ULPFEC"),l=Hs(n=jm(i=PT.matchPrefix(e,"a=ssrc:")).call(i,(function(e){return PT.parseSsrcMedia(e)}))).call(n,(function(e){return"cname"===e.attribute})),h=l.length>0&&l[0].ssrc,p=jm(o=PT.matchPrefix(e,"a=ssrc-group:FID")).call(o,(function(e){var t=e.substr(17).split(" ");return jm(t).call(t,(function(e){return uy(e,10)}))}));p.length>0&&p[0].length>1&&p[0][0]===h&&(a=p[0][1]),c.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var t={ssrc:h,codecPayloadType:uy(e.parameters.apt,10)};h&&a&&(t.rtx={ssrc:a}),s.push(t),u&&((t=JSON.parse(Nm(t))).fec={ssrc:h,mechanism:d?"red+ulpfec":"red"},s.push(t))}})),0===s.length&&h&&s.push({ssrc:h});var v,_,f=PT.matchPrefix(e,"b=");return f.length&&(f=0===xE(v=f[0]).call(v,"b=TIAS:")?uy(f[0].substr(7),10):0===xE(_=f[0]).call(_,"b=AS:")?1e3*uy(f[0].substr(5),10)*.95-16e3:void 0,s.forEach((function(e){e.maxBitrate=f}))),s},PT.parseRtcpParameters=function(e){var t,r,n={},i=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.parseSsrcMedia(e)}))).call(t,(function(e){return"cname"===e.attribute}))[0];i&&(n.cname=i.value,n.ssrc=i.ssrc);var o=PT.matchPrefix(e,"a=rtcp-rsize");n.reducedSize=o.length>0,n.compound=0===o.length;var a=PT.matchPrefix(e,"a=rtcp-mux");return n.mux=a.length>0,n},PT.writeRtcpParameters=function(e){var t="";return e.reducedSize&&(t+="a=rtcp-rsize\r\n"),e.mux&&(t+="a=rtcp-mux\r\n"),void 0!==e.ssrc&&e.cname&&(t+="a=ssrc:"+e.ssrc+" cname:"+e.cname+"\r\n"),t},PT.parseMsid=function(e){var t,r,n,i=PT.matchPrefix(e,"a=msid:");if(1===i.length)return{stream:(n=i[0].substr(7).split(" "))[0],track:n[1]};var o=Hs(t=jm(r=PT.matchPrefix(e,"a=ssrc:")).call(r,(function(e){return PT.parseSsrcMedia(e)}))).call(t,(function(e){return"msid"===e.attribute}));return o.length>0?{stream:(n=o[0].value.split(" "))[0],track:n[1]}:void 0},PT.parseSctpDescription=function(e){var t,r=PT.parseMLine(e),n=PT.matchPrefix(e,"a=max-message-size:");n.length>0&&(t=uy(n[0].substr(19),10)),isNaN(t)&&(t=65536);var i=PT.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:uy(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};var o=PT.matchPrefix(e,"a=sctpmap:");if(o.length>0){var a=o[0].substr(10).split(" ");return{port:uy(a[0],10),protocol:a[1],maxMessageSize:t}}},PT.writeSctpDescription=function(e,t){var r=[];return r="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&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},PT.generateSessionId=function(){return Math.random().toString().substr(2,21)},PT.writeSessionBoilerplate=function(e,t,r){var n=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||PT.generateSessionId())+" "+n+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},PT.getDirection=function(e,t){for(var r=PT.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?PT.getDirection(t):"sendrecv"},PT.getKind=function(e){return PT.splitLines(e)[0].split(" ")[0].substr(2)},PT.isRejected=function(e){return"0"===e.split(" ",2)[1]},PT.parseMLine=function(e){var t=PT.splitLines(e)[0].substr(2).split(" ");return{kind:t[0],port:uy(t[1],10),protocol:t[2],fmt:km(t).call(t,3).join(" ")}},PT.parseOLine=function(e){var t=PT.matchPrefix(e,"o=")[0].substr(2).split(" ");return{username:t[0],sessionId:t[1],sessionVersion:uy(t[2],10),netType:t[3],addressType:t[4],address:t[5]}},PT.isValidSDP=function(e){if("string"!=typeof e||0===e.length)return!1;for(var t=PT.splitLines(e),r=0;r<t.length;r++)if(t[r].length<2||"="!==t[r].charAt(1))return!1;return!0},MT.exports=PT;var jT=BT.exports,HT=e({__proto__:null,default:jT},[BT.exports]);function GT(e){if(!(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)){var t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){var r;if("object"===Wd(e)&&e.candidate&&0===xE(r=e.candidate).call(r,"a=")&&((e=JSON.parse(Nm(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){var n=new t(e),i=jT.parseCandidate(e.candidate),o=wb(n,i);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,tE(e,"icecandidate",(function(t){return t.candidate&&ad(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t}))}}function zT(e){!e.RTCIceCandidate||e.RTCIceCandidate&&"relayProtocol"in e.RTCIceCandidate.prototype||tE(e,"icecandidate",(function(e){if(e.candidate){var t=jT.parseCandidate(e.candidate.candidate);"relay"===t.type&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[t.priority>>24])}return e}))}function KT(e,t){if(e.RTCPeerConnection){"sctp"in e.RTCPeerConnection.prototype||ad(e.RTCPeerConnection.prototype,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp}});var r=function(e){if(!e||!e.sdp)return!1;var t=jT.splitSections(e.sdp);return t.shift(),t.some((function(e){var t,r=jT.parseMLine(e);return r&&"application"===r.kind&&-1!==xE(t=r.protocol).call(t,"SCTP")}))},n=function(e){var t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;var r=uy(t[1],10);return r!=r?-1:r},i=function(e){var r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},o=function(e,r){var n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);var i=jT.matchPrefix(e.sdp,"a=max-message-size:");return i.length>0?n=uy(i[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){var e=this.getConfiguration(),s=e.sdpSemantics;"plan-b"===s&&ad(this,"sctp",{get:function(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){var c,u=n(arguments[0]),d=i(u),l=o(arguments[0],u);c=0===d&&0===l?Number.POSITIVE_INFINITY:0===d||0===l?Math.max(d,l):Math.min(d,l);var h={};ad(h,"maxMessageSize",{get:function(){return c}}),this._sctp=h}return a.apply(this,arguments)}}}function XT(e){if(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype){var t=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){var e=t.apply(this,arguments);return r(e,this),e},tE(e,"datachannel",(function(e){return r(e.channel,e.target),e}))}function r(e,t){var r=e.send;e.send=function(){var n=arguments[0],i=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&i>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}}function WT(e){if(e.RTCPeerConnection&&!("connectionState"in e.RTCPeerConnection.prototype)){var t=e.RTCPeerConnection.prototype;ad(t,"connectionState",{get:function(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),ad(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 r=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 r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}}))}}function qT(e,t){if(e.RTCPeerConnection&&!("chrome"===t.browser&&t.version>=71||"safari"===t.browser&&t.version>=605)){var r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(t){var n;if(t&&t.sdp&&-1!==xE(n=t.sdp).call(n,"\na=extmap-allow-mixed")){var i,o=Hs(i=t.sdp.split("\n")).call(i,(function(e){return"a=extmap-allow-mixed"!==FT(e).call(e)})).join("\n");e.RTCSessionDescription&&t instanceof e.RTCSessionDescription?arguments[0]=new e.RTCSessionDescription({type:t.type,sdp:o}):t.sdp=o}return r.apply(this,arguments)}}}function YT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.addIceCandidate;r&&0!==r.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?Yf.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Yf.resolve())})}}function JT(e,t){if(e.RTCPeerConnection&&e.RTCPeerConnection.prototype){var r=e.RTCPeerConnection.prototype.setLocalDescription;r&&0!==r.length&&(e.RTCPeerConnection.prototype.setLocalDescription=function(){var e=this,t=arguments[0]||{};if("object"!==Wd(t)||t.type&&t.sdp)return r.apply(this,arguments);if(!(t={type:t.type,sdp:t.sdp}).type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":t.type="offer";break;default:t.type="answer"}if(t.sdp||"offer"!==t.type&&"answer"!==t.type)return r.apply(this,[t]);var n="offer"===t.type?this.createOffer:this.createAnswer;return n.apply(this).then((function(t){return r.apply(e,[t])}))})}}var QT=Object.freeze(Object.defineProperty({__proto__:null,shimRTCIceCandidate:GT,shimRTCIceCandidateRelayProtocol:zT,shimMaxMessageSize:KT,shimSendThrowTypeError:XT,shimConnectionState:WT,removeExtmapAllowMixed:qT,shimAddIceCandidateNullOrEmpty:YT,shimParameterlessSetLocalDescription:JT},Symbol.toStringTag,{value:"Module"}));if(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.window,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0},n=iE,i=aE(t),o={browserDetails:i,commonShim:QT,extractVersion:eE,disableLog:rE,disableWarnings:nE,sdp:HT};switch(i.browser){case"chrome":if(!Ck||!Ak||!r.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(null===i.version)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=Ck,YT(t,i),JT(t),gk(t,i),Sk(t),Ak(t,i),bk(t),Rk(t,i),Ek(t),kk(t),Tk(t),wk(t,i),GT(t),zT(t),WT(t),KT(t,i),XT(t),qT(t,i);break;case"firefox":if(!yT||!uT||!r.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=yT,YT(t,i),JT(t),sT(t,i),uT(t,i),cT(t),hT(t),dT(t),lT(t),pT(t),vT(t),_T(t),fT(t),mT(t),GT(t),WT(t),KT(t,i),XT(t);break;case"safari":if(!wT||!r.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=wT,YT(t,i),JT(t),TT(t),RT(t),bT(t),gT(t),ST(t),IT(t),ET(t),AT(t),GT(t),zT(t),KT(t,i),XT(t),qT(t,i);break;default:n("Unsupported browser!")}}({window:"undefined"==typeof window?void 0:window}),"undefined"!=typeof MediaStreamTrack){var ZT=MediaStreamTrack.prototype.getSettings;MediaStreamTrack.prototype.getSettings=function(){var e=ZT.call(this);return e.width&&(e.width=Math.floor(e.width)),e.height&&(e.height=Math.floor(e.height)),e.frameRate&&(e.frameRate=Math.floor(e.frameRate)),e}}function $T(e,t){var r=void 0!==wd&&Dk(e)||e["@@iterator"];if(!r){if(xk(e)||(r=Yk(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function eI(e,t){return function(e){if(xk(e))return e}(e)||function(e,t){var r=null==e?null:void 0!==wd&&Dk(e)||e["@@iterator"];if(null!=r){var n,i,o,a,s=[],c=!0,u=!1;try{if(o=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=o.call(r)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(d){u=!0,i=d}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw i}}return s}}(e,t)||Yk(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tI(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var rI=Ye,nI=function(e){return void 0!==e&&(rI(e,"value")||rI(e,"writable"))},iI=O,oI=$,aI=tr,sI=nI,cI=A,uI=mc;Ar({target:"Reflect",stat:!0},{get:function e(t,r){var n,i,o=arguments.length<3?t:arguments[2];return aI(t)===o?t[r]:(n=cI.f(t,r))?sI(n)?n.value:void 0===n.get?void 0:iI(n.get,o):oI(i=uI(t))?e(i,r,o):void 0}});var dI=ee.Reflect.get,lI=E,hI=Ce,pI=$,vI=Ye,_I=rs,fI=o,mI=Function,yI=lI([].concat),gI=lI([].join),SI={},bI=function(e,t,r){if(!vI(SI,t)){for(var n=[],i=0;i<t;i++)n[i]="a["+i+"]";SI[t]=mI("C,a","return new C("+gI(n,",")+")")}return SI[t](e,r)},EI=fI?mI.bind:function(e){var t=hI(this),r=t.prototype,n=_I(arguments,1),i=function(){var r=yI(n,_I(arguments));return this instanceof i?bI(t,r.length,r):t.apply(e,r)};return pI(r)&&(i.prototype=r),i},kI=EI;Ar({target:"Function",proto:!0,forced:Function.bind!==kI},{bind:kI});var TI=Us("Function").bind,II=ae,RI=TI,AI=Function.prototype,wI=function(e){var t=e.bind;return e===AI||II(AI,e)&&t===AI.bind?RI:t};function CI(e){var t;return(CI=Kl?wI(t=zl).call(t):function(e){return e.__proto__||zl(e)})(e)}function xI(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=CI(e)););return e}function OI(){var e;"undefined"!=typeof Reflect&&dI?OI=wI(e=dI).call(e):OI=function(e,t,r){var n=xI(e,t);if(n){var i=tc(n,t);return i.get?i.get.call(arguments.length<3?e:r):i.value}};return OI.apply(this,arguments)}function DI(e,t){var r;return(DI=Kl?wI(r=Kl).call(r):function(e,t){return e.__proto__=t,e})(e,t)}function MI(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Bl(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),ad(e,"prototype",{writable:!1}),t&&DI(e,t)}var PI=Ar,NI=d,LI=EI,UI=bp,VI=tr,FI=$,BI=Gn,jI=i,HI=oe("Reflect","construct"),GI=Object.prototype,zI=[].push,KI=jI((function(){function e(){}return!(HI((function(){}),[],e)instanceof e)})),XI=!jI((function(){HI((function(){}))})),WI=KI||XI;PI({target:"Reflect",stat:!0,forced:WI,sham:WI},{construct:function(e,t){UI(e),VI(t);var r=arguments.length<3?e:UI(arguments[2]);if(XI&&!KI)return HI(e,t,r);if(e==r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var n=[null];return NI(zI,n,t),new(NI(LI,e,n))}var i=r.prototype,o=BI(FI(i)?i:GI),a=NI(e,o,t);return FI(a)?a:o}});var qI=ee.Reflect.construct;function YI(e,t){if(t&&("object"===Wd(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return tI(e)}function JI(e){var t=function(){if("undefined"==typeof Reflect||!qI)return!1;if(qI.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(qI(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=CI(e);if(t){var i=CI(this).constructor;r=qI(n,arguments,i)}else r=n.apply(this,arguments);return YI(this,r)}}var QI=Us("Array").values,ZI=_n,$I=Ye,eR=ae,tR=QI,rR=Array.prototype,nR={DOMTokenList:!0,NodeList:!0},iR=function(e){var t=e.values;return e===rR||eR(rR,e)&&t===rR.values||$I(nR,ZI(e))?tR:t},oR=ni,aR=Math.floor,sR=function(e,t){var r=e.length,n=aR(r/2);return r<8?cR(e,t):uR(e,sR(oR(e,0,n),t),sR(oR(e,n),t),t)},cR=function(e,t){for(var r,n,i=e.length,o=1;o<i;){for(n=o,r=e[o];n&&t(e[n-1],r)>0;)e[n]=e[--n];n!==o++&&(e[n]=r)}return e},uR=function(e,t,r,n){for(var i=t.length,o=r.length,a=0,s=0;a<i||s<o;)e[a+s]=a<i&&s<o?n(t[a],r[s])<=0?t[a++]:r[s++]:a<i?t[a++]:r[s++];return e},dR=sR,lR=se.match(/firefox\/(\d+)/i),hR=!!lR&&+lR[1],pR=/MSIE|Trident/.test(se),vR=se.match(/AppleWebKit\/(\d+)\./),_R=!!vR&&+vR[1],fR=Ar,mR=E,yR=Ce,gR=Xe,SR=Br,bR=VE,ER=yn,kR=i,TR=dR,IR=Iu,RR=hR,AR=pR,wR=ve,CR=_R,xR=[],OR=mR(xR.sort),DR=mR(xR.push),MR=kR((function(){xR.sort(void 0)})),PR=kR((function(){xR.sort(null)})),NR=IR("sort"),LR=!kR((function(){if(wR)return wR<70;if(!(RR&&RR>3)){if(AR)return!0;if(CR)return CR<603;var e,t,r,n,i="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(n=0;n<47;n++)xR.push({k:t+n,v:r})}for(xR.sort((function(e,t){return t.v-e.v})),n=0;n<xR.length;n++)t=xR[n].k.charAt(0),i.charAt(i.length-1)!==t&&(i+=t);return"DGBEFHACIJK"!==i}}));fR({target:"Array",proto:!0,forced:MR||!PR||!NR||!LR},{sort:function(e){void 0!==e&&yR(e);var t=gR(this);if(LR)return void 0===e?OR(t):OR(t,e);var r,n,i=[],o=SR(t);for(n=0;n<o;n++)n in t&&DR(i,t[n]);for(TR(i,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:ER(t)>ER(r)?1:-1}}(e)),r=SR(i),n=0;n<r;)t[n]=i[n++];for(;n<o;)bR(t,n++);return t}});var UR=Us("Array").sort,VR=ae,FR=UR,BR=Array.prototype,jR=function(e){var t=e.sort;return e===BR||VR(BR,e)&&t===BR.sort?FR:t},HR=Ar,GR=Po.findIndex,zR="findIndex",KR=!0;zR in[]&&Array(1).findIndex((function(){KR=!1})),HR({target:"Array",proto:!0,forced:KR},{findIndex:function(e){return GR(this,e,arguments.length>1?arguments[1]:void 0)}});var XR=Us("Array").findIndex,WR=ae,qR=XR,YR=Array.prototype,JR=function(e){var t=e.findIndex;return e===YR||WR(YR,e)&&t===YR.findIndex?qR:t},QR=Ar,ZR=E;A.f;var $R=Vr,eA=yn,tA=Pb,rA=W,nA=Lb,iA=ZR("".startsWith),oA=ZR("".slice),aA=Math.min;QR({target:"String",proto:!0,forced:!nA("startsWith")},{startsWith:function(e){var t=eA(rA(this));tA(e);var r=$R(aA(arguments.length>1?arguments[1]:void 0,t.length)),n=eA(e);return iA?iA(t,n,r):oA(t,r,r+n.length)===n}});var sA=Us("String").startsWith,cA=ae,uA=sA,dA=String.prototype,lA=function(e){var t=e.startsWith;return"string"==typeof e||e===dA||cA(dA,e)&&t===dA.startsWith?uA:t},hA=function(e){return e.INVALID_ENGINE="INVALID_ENGINE",e.INVALID_PARAMS="INVALID_PARAMS",e.INVOKED_BEFORE_JOIN_ROOM="INVOKED_BEFORE_JOIN_ROOM",e.INVALID_TOKEN="INVALID_TOKEN",e.EXPIRED_TOKEN="EXPIRED_TOKEN",e.JOIN_ROOM_FAILED="JOIN_ROOM_FAILED",e.UPDATE_TOKEN_WITH_INVALID_TOKEN="UPDATE_TOKEN_WITH_INVALID_TOKEN",e.UPDATE_TOKEN_BEFORE_JOIN="UPDATE_TOKEN_BEFORE_JOIN",e.REPEAT_JOIN="REPEAT_JOIN",e.REPEAT_PUBLISH="REPEAT_PUBLISH",e.REPEAT_PUSH="REPEAT_PUSH",e.REPEAT_PLAY="REPEAT_PLAY",e.PUBLISH_BEFORE_JOIN="PUBLISH_BEFORE_JOIN",e.UNPUBLISH_BEFORE_JOIN="UNPUBLISH_BEFORE_JOIN",e.SUBSCRIBE_BEFORE_JOIN="SUBSCRIBE_BEFORE_JOIN",e.UNSUBSCRIBE_BEFORE_JOIN="UNSUBSCRIBE_BEFORE_JOIN",e.NO_PUBLISH_PERMISSION="NO_PUBLISH_PERMISSION",e.STREAM_NOT_EXIST="STREAM_NOT_EXIST",e.EMPTY_STREAM="EMPTY_STREAM",e.NOT_CONNECTED_YET="NOT_CONNECTED_YET",e.IM_BEFORE_JOIN="IM_BEFORE_JOIN",e.USER_NOT_EXIST="USER_NOT_EXIST",e.ALREADY_IN_ROOM="ALREADY_IN_ROOM",e.KICKED_OUT="KICKED_OUT",e.ROOM_DISMISS="ROOM_DISMISS",e.TOKEN_EXPIRED="TOKEN_EXPIRED",e.DUPLICATE_LOGIN="DUPLICATE_LOGIN",e.INVOKED_BEFORE_CAPTURE="INVOKED_BEFORE_CAPTURE",e.REPEAT_CAPTURE="REPEAT_CAPTURE",e.GET_VIDEO_TRACK_FAILED="GET_VIDEO_TRACK_FAILED",e.GET_AUDIO_TRACK_FAILED="GET_AUDIO_TRACK_FAILED",e.GET_SCREEN_TRACK_FAILED="GET_SCREEN_TRACK_FAILED",e.STREAM_TYPE_NOT_MATCH="STREAM_TYPE_NOT_MATCH",e.CANT_FIND_DOM="CANT_FIND_DOM",e.INVALID_DEVICE_ID="INVALID_DEVICE_ID",e.NO_PERMISSION="NO_PERMISSION",e.NOT_SUPPORTED="NOT_SUPPORTED",e.INTERRUPT="INTERRUPT",e.ICE_SERVER_WRONG="ICE_SERVER_WRONG",e.ESTABLISH_DATACHANNEL_FAILED="ESTABLISH_DATACHANNEL_FAILED",e.LOAD_RESOURCES_FAILED="LOAD_RESOURCES_FAILED",e.SIGNALING_CHANNEL_NOT_OPEN="SIGNALING_CHANNEL_NOT_OPEN",e.TIME_OUT="TIME_OUT",e.REFUSE_OPERATION_IN_DISCONNECT="REFUSE_OPERATION_IN_DISCONNECT",e.ADD_TRANSCEIVER_FAILED="ADD_TRANSCEIVER_FAILED",e.UPDATE_TRACK_FAILED="UPDATE_TRACK_FAILED",e.PUBLISH_FAILED="PUBLISH_FAILED",e.UNPUBLISH_FAILED="UNPUBLISH_FAILED",e.SUBSCRIBE_FAILED="SUBSCRIBE_FAILED",e.UNSUBSCRIBE_FAILED="UNSUBSCRIBE_FAILED",e.OPERATION_CANCEL="OPERATION_CANCEL",e.START_CLOUD_PROXY_AFTER_JOIN="START_CLOUD_PROXY_AFTER_JOIN",e.STOP_CLOUD_PROXY_BEFORE_LEAVE="STOP_CLOUD_PROXY_BEFORE_LEAVE",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.REPEAT_DEVICE_TEST="REPEAT_DEVICE_TEST",e.AUDIO_DEVICE_TEST_FAILED="AUDIO_DEVICE_RECORD_FAILED",e.ALREADY_LOGIN="ALREADY_LOGIN",e.LOGIN_FAILED="LOGIN_FAILED",e.NOT_LOGIN="NOT_LOGIN",e.RTM_DUPLICATE_LOGIN="RTM_DUPLICATE_LOGIN",e.RTM_TOKEN_ERROR="RTM_TOKEN_ERROR",e.USER_MESSAGE_TIMEOUT="USER_MESSAGE_TIMEOUT",e.USER_MESSAGE_BROKEN="USER_MESSAGE_BROKEN",e.USER_MESSAGE_NO_RECEIVER="USER_MESSAGE_NO_RECEIVER",e.USER_MESSAGE_NO_RELAYPATH="USER_MESSAGE_NO_RELAYPATH",e.USER_MESSAGE_EXCEED_QPS="USER_MESSAGE_EXCEED_QPS",e.USER_MESSAGE_SEND_TO_SERVER_ERROR="USER_MESSAGE_SEND_TO_SERVER_ERROR",e.USER_MESSAGE_SERVER_RESPONSE_ERROR="USER_MESSAGE_SERVER_RESPONSE_ERROR",e.USER_MESSAGE_NOT_JOIN="USER_MESSAGE_NOT_JOIN",e.USER_MESSAGE_INIT="USER_MESSAGE_INIT",e.USER_MESSAGE_NO_CONNECTION="USER_MESSAGE_NO_CONNECTION",e.USER_MESSAGE_NOT_LOGIN="USER_MESSAGE_NOT_LOGIN",e.USER_MESSAGE_SERVER_PARAMS_NOTSET="USER_MESSAGE_SERVER_PARAMS_NOTSET",e.USER_MESSAGE_UNKNOWN="USER_MESSAGE_UNKNOWN",e.START_PUBLIC_STREAM_BEFORE_JOIN="START_PUBLIC_STREAM_BEFORE_JOIN",e.RECONNECT_FAILED="RECONNECT_FAILED",e.SUBTITLE_ALREADY_ON="SUBTITLE_ALREADY_ON",e.SUBTITLE_NOT_TURNED_ON="SUBTITLE_NOT_TURNED_ON",e.SUBTITLE_ERR_POSTPROCESS="SUBTITLE_ERR_POSTPROCESS",e.SUBTITLE_ERR_CONNECTION_ERROR="SUBTITLE_ERR_CONNECTION_ERROR",e.SUBTITLE_ERR_PROCESS_ERROR="SUBTITLE_ERR_PROCESS_ERROR",e.SUBTITLE_ERR_UNKNOWN="SUBTITLE_ERR_UNKNOWN",e.UNEXPECTED_INVOKE_FORWARD_STREAM="UNEXPECTED_INVOKE_FORWARD_STREAM",e}(hA||{}),pA=function(e){return e[e.AUDIO_MIXING_ERROR_OK=0]="AUDIO_MIXING_ERROR_OK",e[e.AUDIO_MIXING_ERROR_PRELOAD_FAILED=1]="AUDIO_MIXING_ERROR_PRELOAD_FAILED",e[e.AUDIO_MIXING_ERROR_START_FAILED=2]="AUDIO_MIXING_ERROR_START_FAILED",e[e.AUDIO_MIXING_ERROR_ID_NOT_FOUND=3]="AUDIO_MIXING_ERROR_ID_NOT_FOUND",e[e.AUDIO_MIXING_ERROR_SET_POSITION_FAILED=4]="AUDIO_MIXING_ERROR_SET_POSITION_FAILED",e[e.AUDIO_MIXING_ERROR_INVALID_VOLUME=5]="AUDIO_MIXING_ERROR_INVALID_VOLUME",e[e.AUDIO_MIXING_ERROR_LOAD_CONFLICT=6]="AUDIO_MIXING_ERROR_LOAD_CONFLICT",e[e.AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH=7]="AUDIO_MIXING_ERROR_ID_TYPE_NOT_MATCH",e[e.AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH=8]="AUDIO_MIXING_ERROR_ID_TYPE_INVALID_PITCH",e[e.AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK=9]="AUDIO_MIXING_ERROR_INVALID_AUDIO_TRACK",e}(pA||{}),vA=Ul((function e(t,r,n){Vl(this,e),Jd(this,"code",void 0),Jd(this,"message",void 0),Jd(this,"error",void 0),this.code=t,this.message=r,this.error=n})),_A=w,fA=E,mA=rn,yA=J,gA=fA(D.f),SA=fA([].push),bA=function(e){return function(t){for(var r,n=yA(t),i=mA(n),o=i.length,a=0,s=[];o>a;)r=i[a++],_A&&!gA(n,r)||SA(s,e?[r,n[r]]:n[r]);return s}},EA={entries:bA(!0),values:bA(!1)}.entries;Ar({target:"Object",stat:!0},{entries:function(e){return EA(e)}});var kA=ee.Object.entries,TA=Or,IA=yn,RA=W,AA=RangeError,wA=E,CA=Vr,xA=yn,OA=function(e){var t=IA(RA(this)),r="",n=TA(e);if(n<0||n==1/0)throw AA("Wrong number of repetitions");for(;n>0;(n>>>=1)&&(t+=t))1&n&&(r+=t);return r},DA=W,MA=wA(OA),PA=wA("".slice),NA=Math.ceil,LA=function(e){return function(t,r,n){var i,o,a=xA(DA(t)),s=CA(r),c=a.length,u=void 0===n?" ":xA(n);return s<=c||""==u?a:((o=MA(u,NA((i=s-c)/u.length))).length>i&&(o=PA(o,0,i)),e?a+o:o+a)}},UA={start:LA(!1),end:LA(!0)},VA=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(se),FA=UA.end;Ar({target:"String",proto:!0,forced:VA},{padEnd:function(e){return FA(this,e,arguments.length>1?arguments[1]:void 0)}});var BA=Us("String").padEnd,jA=ae,HA=BA,GA=String.prototype,zA=function(e){var t=e.padEnd;return"string"==typeof e||e===GA||jA(GA,e)&&t===GA.padEnd?HA:t},KA=cy;Ar({target:"Number",stat:!0,forced:Number.parseInt!=KA},{parseInt:KA});var XA=ee.Number.parseInt,WA=Math.log,qA=Math.LOG10E;Ar({target:"Math",stat:!0},{log10:Math.log10||function(e){return WA(e)*qA}});var YA,JA=ee.Math.log10,QA=new Uint8Array(16);function ZA(){if(!YA&&!(YA="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return YA(QA)}var $A=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function ew(e){return"string"==typeof e&&$A.test(e)}for(var tw=[],rw=0;rw<256;++rw)tw.push((rw+256).toString(16).substr(1));function nw(e,t,r){var n=(e=e||{}).random||(e.rng||ZA)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(var i=0;i<16;++i)t[r+i]=n[i];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=(tw[e[t+0]]+tw[e[t+1]]+tw[e[t+2]]+tw[e[t+3]]+"-"+tw[e[t+4]]+tw[e[t+5]]+"-"+tw[e[t+6]]+tw[e[t+7]]+"-"+tw[e[t+8]]+tw[e[t+9]]+"-"+tw[e[t+10]]+tw[e[t+11]]+tw[e[t+12]]+tw[e[t+13]]+tw[e[t+14]]+tw[e[t+15]]).toLowerCase();if(!ew(r))throw TypeError("Stringified UUID is invalid");return r}(n)}var iw=function(){return"undefined"==typeof window},ow=function(){return nw()},aw=function(e){return"number"==typeof e},sw=function(e){var t;return mk(t=Function.prototype.toString.call(e)).call(t,"[native code]")},cw={};!function(e){var t="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.assign=function(e){for(var t=km(Array.prototype).call(arguments,1);t.length;){var n=t.shift();if(n){if("object"!==Wd(n))throw new TypeError(n+"must be non-object");for(var i in n)r(n,i)&&(e[i]=n[i])}}return e},e.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+n),i);else for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){var t,r,n,i,o,a;for(n=0,t=0,r=e.length;t<r;t++)n+=e[t].length;for(a=new Uint8Array(n),i=0,t=0,r=e.length;t<r;t++)o=e[t],a.set(o,i),i+=o.length;return a}},i={arraySet:function(e,t,r,n,i){for(var o=0;o<n;o++)e[i+o]=t[r+o]},flattenChunks:function(e){return Om([]).apply([],e)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,n)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,i))},e.setTyped(t)}(cw);var uw={},dw={},lw={},hw=cw;function pw(e){for(var t=e.length;--t>=0;)e[t]=0}var vw=256,_w=286,fw=30,mw=15,yw=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],gw=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],Sw=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],bw=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Ew=new Array(576);pw(Ew);var kw=new Array(60);pw(kw);var Tw=new Array(512);pw(Tw);var Iw=new Array(256);pw(Iw);var Rw=new Array(29);pw(Rw);var Aw,ww,Cw,xw=new Array(fw);function Ow(e,t,r,n,i){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=e&&e.length}function Dw(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function Mw(e){return e<256?Tw[e]:Tw[256+(e>>>7)]}function Pw(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function Nw(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,Pw(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function Lw(e,t,r){Nw(e,r[2*t],r[2*t+1])}function Uw(e,t){var r=0;do{r|=1&e,e>>>=1,r<<=1}while(--t>0);return r>>>1}function Vw(e,t,r){var n,i,o=new Array(16),a=0;for(n=1;n<=mw;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];0!==s&&(e[2*i]=Uw(o[s]++,s))}}function Fw(e){var t;for(t=0;t<_w;t++)e.dyn_ltree[2*t]=0;for(t=0;t<fw;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function Bw(e){e.bi_valid>8?Pw(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function jw(e,t,r,n){var i=2*t,o=2*r;return e[i]<e[o]||e[i]===e[o]&&n[t]<=n[r]}function Hw(e,t,r){for(var n=e.heap[r],i=r<<1;i<=e.heap_len&&(i<e.heap_len&&jw(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!jw(t,n,e.heap[i],e.depth));)e.heap[r]=e.heap[i],r=i,i<<=1;e.heap[r]=n}function Gw(e,t,r){var n,i,o,a,s=0;if(0!==e.last_lit)do{n=e.pending_buf[e.d_buf+2*s]<<8|e.pending_buf[e.d_buf+2*s+1],i=e.pending_buf[e.l_buf+s],s++,0===n?Lw(e,i,t):(Lw(e,(o=Iw[i])+vw+1,t),0!==(a=yw[o])&&Nw(e,i-=Rw[o],a),Lw(e,o=Mw(--n),r),0!==(a=gw[o])&&Nw(e,n-=xw[o],a))}while(s<e.last_lit);Lw(e,256,t)}function zw(e,t){var r,n,i,o=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,c=t.stat_desc.elems,u=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<c;r++)0!==o[2*r]?(e.heap[++e.heap_len]=u=r,e.depth[r]=0):o[2*r+1]=0;for(;e.heap_len<2;)o[2*(i=e.heap[++e.heap_len]=u<2?++u:0)]=1,e.depth[i]=0,e.opt_len--,s&&(e.static_len-=a[2*i+1]);for(t.max_code=u,r=e.heap_len>>1;r>=1;r--)Hw(e,o,r);i=c;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Hw(e,o,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,o[2*i]=o[2*r]+o[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,o[2*r+1]=o[2*n+1]=i,e.heap[1]=i++,Hw(e,o,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,o,a,s,c=t.dyn_tree,u=t.max_code,d=t.stat_desc.static_tree,l=t.stat_desc.has_stree,h=t.stat_desc.extra_bits,p=t.stat_desc.extra_base,v=t.stat_desc.max_length,_=0;for(o=0;o<=mw;o++)e.bl_count[o]=0;for(c[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)(o=c[2*c[2*(n=e.heap[r])+1]+1]+1)>v&&(o=v,_++),c[2*n+1]=o,n>u||(e.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=c[2*n],e.opt_len+=s*(o+a),l&&(e.static_len+=s*(d[2*n+1]+a)));if(0!==_){do{for(o=v-1;0===e.bl_count[o];)o--;e.bl_count[o]--,e.bl_count[o+1]+=2,e.bl_count[v]--,_-=2}while(_>0);for(o=v;0!==o;o--)for(n=e.bl_count[o];0!==n;)(i=e.heap[--r])>u||(c[2*i+1]!==o&&(e.opt_len+=(o-c[2*i+1])*c[2*i],c[2*i+1]=o),n--)}}(e,t),Vw(o,u,e.bl_count)}function Kw(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),t[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=t[2*(n+1)+1],++s<c&&i===a||(s<u?e.bl_tree[2*i]+=s:0!==i?(i!==o&&e.bl_tree[2*i]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4))}function Xw(e,t,r){var n,i,o=-1,a=t[1],s=0,c=7,u=4;for(0===a&&(c=138,u=3),n=0;n<=r;n++)if(i=a,a=t[2*(n+1)+1],!(++s<c&&i===a)){if(s<u)do{Lw(e,i,e.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(Lw(e,i,e.bl_tree),s--),Lw(e,16,e.bl_tree),Nw(e,s-3,2)):s<=10?(Lw(e,17,e.bl_tree),Nw(e,s-3,3)):(Lw(e,18,e.bl_tree),Nw(e,s-11,7));s=0,o=i,0===a?(c=138,u=3):i===a?(c=6,u=3):(c=7,u=4)}}pw(xw);var Ww=!1;function qw(e,t,r,n){Nw(e,0+(n?1:0),3),function(e,t,r,n){Bw(e),n&&(Pw(e,r),Pw(e,~r)),hw.arraySet(e.pending_buf,e.window,t,r,e.pending),e.pending+=r}(e,t,r,!0)}lw._tr_init=function(e){Ww||(!function(){var e,t,r,n,i,o=new Array(16);for(r=0,n=0;n<28;n++)for(Rw[n]=r,e=0;e<1<<yw[n];e++)Iw[r++]=n;for(Iw[r-1]=n,i=0,n=0;n<16;n++)for(xw[n]=i,e=0;e<1<<gw[n];e++)Tw[i++]=n;for(i>>=7;n<fw;n++)for(xw[n]=i<<7,e=0;e<1<<gw[n]-7;e++)Tw[256+i++]=n;for(t=0;t<=mw;t++)o[t]=0;for(e=0;e<=143;)Ew[2*e+1]=8,e++,o[8]++;for(;e<=255;)Ew[2*e+1]=9,e++,o[9]++;for(;e<=279;)Ew[2*e+1]=7,e++,o[7]++;for(;e<=287;)Ew[2*e+1]=8,e++,o[8]++;for(Vw(Ew,287,o),e=0;e<fw;e++)kw[2*e+1]=5,kw[2*e]=Uw(e,5);Aw=new Ow(Ew,yw,257,_w,mw),ww=new Ow(kw,gw,0,fw,mw),Cw=new Ow(new Array(0),Sw,0,19,7)}(),Ww=!0),e.l_desc=new Dw(e.dyn_ltree,Aw),e.d_desc=new Dw(e.dyn_dtree,ww),e.bl_desc=new Dw(e.bl_tree,Cw),e.bi_buf=0,e.bi_valid=0,Fw(e)},lw._tr_stored_block=qw,lw._tr_flush_block=function(e,t,r,n){var i,o,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<vw;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),zw(e,e.l_desc),zw(e,e.d_desc),a=function(e){var t;for(Kw(e,e.dyn_ltree,e.l_desc.max_code),Kw(e,e.dyn_dtree,e.d_desc.max_code),zw(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*bw[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),i=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==t?qw(e,t,r,n):4===e.strategy||o===i?(Nw(e,2+(n?1:0),3),Gw(e,Ew,kw)):(Nw(e,4+(n?1:0),3),function(e,t,r,n){var i;for(Nw(e,t-257,5),Nw(e,r-1,5),Nw(e,n-4,4),i=0;i<n;i++)Nw(e,e.bl_tree[2*bw[i]+1],3);Xw(e,e.dyn_ltree,t-1),Xw(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Gw(e,e.dyn_ltree,e.dyn_dtree)),Fw(e),n&&Bw(e)},lw._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(Iw[r]+vw+1)]++,e.dyn_dtree[2*Mw(t)]++),e.last_lit===e.lit_bufsize-1},lw._tr_align=function(e){Nw(e,2,3),Lw(e,256,Ew),function(e){16===e.bi_valid?(Pw(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)};var Yw=function(e,t,r,n){for(var i=65535&e|0,o=e>>>16&65535|0,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+t[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16|0};var Jw=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();var Qw,Zw=function(e,t,r,n){var i=Jw,o=n+r;e^=-1;for(var a=n;a<o;a++)e=e>>>8^i[255&(e^t[a])];return-1^e},$w={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},eC=cw,tC=lw,rC=Yw,nC=Zw,iC=$w,oC=-2,aC=258,sC=262,cC=103,uC=113,dC=666;function lC(e,t){return e.msg=iC[t],t}function hC(e){return(e<<1)-(e>4?9:0)}function pC(e){for(var t=e.length;--t>=0;)e[t]=0}function vC(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(eC.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function _C(e,t){tC._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,vC(e.strm)}function fC(e,t){e.pending_buf[e.pending++]=t}function mC(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function yC(e,t){var r,n,i=e.max_chain_length,o=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-sC?e.strstart-(e.w_size-sC):0,u=e.window,d=e.w_mask,l=e.prev,h=e.strstart+aC,p=u[o+a-1],v=u[o+a];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do{if(u[(r=t)+a]===v&&u[r+a-1]===p&&u[r]===u[o]&&u[++r]===u[o+1]){o+=2,r++;do{}while(u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&u[++o]===u[++r]&&o<h);if(n=aC-(h-o),o=h-aC,n>a){if(e.match_start=t,a=n,n>=s)break;p=u[o+a-1],v=u[o+a]}}}while((t=l[t&d])>c&&0!=--i);return a<=e.lookahead?a:e.lookahead}function gC(e){var t,r,n,i,o,a,s,c,u,d,l=e.w_size;do{if(i=e.window_size-e.lookahead-e.strstart,e.strstart>=l+(l-sC)){eC.arraySet(e.window,e.window,l,l,0),e.match_start-=l,e.strstart-=l,e.block_start-=l,t=r=e.hash_size;do{n=e.head[--t],e.head[t]=n>=l?n-l:0}while(--r);t=r=l;do{n=e.prev[--t],e.prev[t]=n>=l?n-l:0}while(--r);i+=l}if(0===e.strm.avail_in)break;if(a=e.strm,s=e.window,c=e.strstart+e.lookahead,u=i,d=void 0,(d=a.avail_in)>u&&(d=u),r=0===d?0:(a.avail_in-=d,eC.arraySet(s,a.input,a.next_in,d,c),1===a.state.wrap?a.adler=rC(a.adler,s,d,c):2===a.state.wrap&&(a.adler=nC(a.adler,s,d,c)),a.next_in+=d,a.total_in+=d,d),e.lookahead+=r,e.lookahead+e.insert>=3)for(o=e.strstart-e.insert,e.ins_h=e.window[o],e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[o+3-1])&e.hash_mask,e.prev[o&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=o,o++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<sC&&0!==e.strm.avail_in)}function SC(e,t){for(var r,n;;){if(e.lookahead<sC){if(gC(e),e.lookahead<sC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-sC&&(e.match_length=yC(e,r)),e.match_length>=3)if(n=tC._tr_tally(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else n=tC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(_C(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_C(e,!1),0===e.strm.avail_out)?1:2}function bC(e,t){for(var r,n,i;;){if(e.lookahead<sC){if(gC(e),e.lookahead<sC&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-sC&&(e.match_length=yC(e,r),e.match_length<=5&&(1===e.strategy||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-3,n=tC._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=i&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,n&&(_C(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((n=tC._tr_tally(e,0,e.window[e.strstart-1]))&&_C(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=tC._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_C(e,!1),0===e.strm.avail_out)?1:2}function EC(e,t,r,n,i){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=n,this.func=i}function kC(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new eC.Buf16(1146),this.dyn_dtree=new eC.Buf16(122),this.bl_tree=new eC.Buf16(78),pC(this.dyn_ltree),pC(this.dyn_dtree),pC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new eC.Buf16(16),this.heap=new eC.Buf16(573),pC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new eC.Buf16(573),pC(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function TC(e){var t;return e&&e.state?(e.total_in=e.total_out=0,e.data_type=2,(t=e.state).pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?42:uC,e.adler=2===t.wrap?0:1,t.last_flush=0,tC._tr_init(t),0):lC(e,oC)}function IC(e){var t,r=TC(e);return 0===r&&((t=e.state).window_size=2*t.w_size,pC(t.head),t.max_lazy_match=Qw[t.level].max_lazy,t.good_match=Qw[t.level].good_length,t.nice_match=Qw[t.level].nice_length,t.max_chain_length=Qw[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function RC(e,t,r,n,i,o){if(!e)return oC;var a=1;if(-1===t&&(t=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),i<1||i>9||8!==r||n<8||n>15||t<0||t>9||o<0||o>4)return lC(e,oC);8===n&&(n=9);var s=new kC;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=i+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new eC.Buf8(2*s.w_size),s.head=new eC.Buf16(s.hash_size),s.prev=new eC.Buf16(s.w_size),s.lit_bufsize=1<<i+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new eC.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=r,IC(e)}Qw=[new EC(0,0,0,0,(function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(gC(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var n=e.block_start+r;if((0===e.strstart||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,_C(e,!1),0===e.strm.avail_out))return 1;if(e.strstart-e.block_start>=e.w_size-sC&&(_C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_C(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_C(e,!1),e.strm.avail_out),1)})),new EC(4,4,8,4,SC),new EC(4,5,16,8,SC),new EC(4,6,32,32,SC),new EC(4,4,16,16,bC),new EC(8,16,32,32,bC),new EC(8,16,128,128,bC),new EC(8,32,128,256,bC),new EC(32,128,258,1024,bC),new EC(32,258,258,4096,bC)],dw.deflateInit=function(e,t){return RC(e,t,8,15,8,0)},dw.deflateInit2=RC,dw.deflateReset=IC,dw.deflateResetKeep=TC,dw.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?oC:(e.state.gzhead=t,0):oC},dw.deflate=function(e,t){var r,n,i,o;if(!e||!e.state||t>5||t<0)return e?lC(e,oC):oC;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||n.status===dC&&4!==t)return lC(e,0===e.avail_out?-5:oC);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,fC(n,31),fC(n,139),fC(n,8),n.gzhead?(fC(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),fC(n,255&n.gzhead.time),fC(n,n.gzhead.time>>8&255),fC(n,n.gzhead.time>>16&255),fC(n,n.gzhead.time>>24&255),fC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),fC(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(fC(n,255&n.gzhead.extra.length),fC(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=nC(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(fC(n,0),fC(n,0),fC(n,0),fC(n,0),fC(n,0),fC(n,9===n.level?2:n.strategy>=2||n.level<2?4:0),fC(n,3),n.status=uC);else{var a=8+(n.w_bits-8<<4)<<8;a|=(n.strategy>=2||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(a|=32),a+=31-a%31,n.status=uC,mC(n,a),0!==n.strstart&&(mC(n,e.adler>>>16),mC(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(i=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),vC(e),i=n.pending,n.pending!==n.pending_buf_size));)fC(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),vC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,fC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){i=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),vC(e),i=n.pending,n.pending===n.pending_buf_size)){o=1;break}o=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,fC(n,o)}while(0!==o);n.gzhead.hcrc&&n.pending>i&&(e.adler=nC(e.adler,n.pending_buf,n.pending-i,i)),0===o&&(n.status=cC)}else n.status=cC;if(n.status===cC&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&vC(e),n.pending+2<=n.pending_buf_size&&(fC(n,255&e.adler),fC(n,e.adler>>8&255),e.adler=0,n.status=uC)):n.status=uC),0!==n.pending){if(vC(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&hC(t)<=hC(r)&&4!==t)return lC(e,-5);if(n.status===dC&&0!==e.avail_in)return lC(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&n.status!==dC){var s=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(gC(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=tC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(_C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_C(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,n,i,o,a=e.window;;){if(e.lookahead<=aC){if(gC(e),e.lookahead<=aC&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=a[i=e.strstart-1])===a[++i]&&n===a[++i]&&n===a[++i]){o=e.strstart+aC;do{}while(n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&n===a[++i]&&i<o);e.match_length=aC-(o-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=tC._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=tC._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(_C(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_C(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_C(e,!1),0===e.strm.avail_out)?1:2}(n,t):Qw[n.level].func(n,t);if(3!==s&&4!==s||(n.status=dC),1===s||3===s)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===s&&(1===t?tC._tr_align(n):5!==t&&(tC._tr_stored_block(n,0,0,!1),3===t&&(pC(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),vC(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(fC(n,255&e.adler),fC(n,e.adler>>8&255),fC(n,e.adler>>16&255),fC(n,e.adler>>24&255),fC(n,255&e.total_in),fC(n,e.total_in>>8&255),fC(n,e.total_in>>16&255),fC(n,e.total_in>>24&255)):(mC(n,e.adler>>>16),mC(n,65535&e.adler)),vC(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?0:1)},dw.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&t!==cC&&t!==uC&&t!==dC?lC(e,oC):(e.state=null,t===uC?lC(e,-3):0):oC},dw.deflateSetDictionary=function(e,t){var r,n,i,o,a,s,c,u,d=t.length;if(!e||!e.state)return oC;if(2===(o=(r=e.state).wrap)||1===o&&42!==r.status||r.lookahead)return oC;for(1===o&&(e.adler=rC(e.adler,t,d,0)),r.wrap=0,d>=r.w_size&&(0===o&&(pC(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new eC.Buf8(r.w_size),eC.arraySet(u,t,d-r.w_size,r.w_size,0),t=u,d=r.w_size),a=e.avail_in,s=e.next_in,c=e.input,e.avail_in=d,e.next_in=0,e.input=t,gC(r);r.lookahead>=3;){n=r.strstart,i=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--i);r.strstart=n,r.lookahead=2,gC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=s,e.input=c,e.avail_in=a,r.wrap=o,0},dw.deflateInfo="pako deflate (from Nodeca project)";var AC={},wC=cw,CC=!0,xC=!0;try{String.fromCharCode.apply(null,[0])}catch(tq){CC=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(tq){xC=!1}for(var OC=new wC.Buf8(256),DC=0;DC<256;DC++)OC[DC]=DC>=252?6:DC>=248?5:DC>=240?4:DC>=224?3:DC>=192?2:1;function MC(e,t){if(t<65534&&(e.subarray&&xC||!e.subarray&&CC))return String.fromCharCode.apply(null,wC.shrinkBuf(e,t));for(var r="",n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r}OC[254]=OC[254]=1,AC.string2buf=function(e){var t,r,n,i,o,a=e.length,s=0;for(i=0;i<a;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),s+=r<128?1:r<2048?2:r<65536?3:4;for(t=new wC.Buf8(s),o=0,i=0;o<s;i++)55296==(64512&(r=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(r=65536+(r-55296<<10)+(n-56320),i++),r<128?t[o++]=r:r<2048?(t[o++]=192|r>>>6,t[o++]=128|63&r):r<65536?(t[o++]=224|r>>>12,t[o++]=128|r>>>6&63,t[o++]=128|63&r):(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63,t[o++]=128|r>>>6&63,t[o++]=128|63&r);return t},AC.buf2binstring=function(e){return MC(e,e.length)},AC.binstring2buf=function(e){for(var t=new wC.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},AC.buf2string=function(e,t){var r,n,i,o,a=t||e.length,s=new Array(2*a);for(n=0,r=0;r<a;)if((i=e[r++])<128)s[n++]=i;else if((o=OC[i])>4)s[n++]=65533,r+=o-1;else{for(i&=2===o?31:3===o?15:7;o>1&&r<a;)i=i<<6|63&e[r++],o--;o>1?s[n++]=65533:i<65536?s[n++]=i:(i-=65536,s[n++]=55296|i>>10&1023,s[n++]=56320|1023&i)}return MC(s,n)},AC.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;r>=0&&128==(192&e[r]);)r--;return r<0||0===r?t:r+OC[e[r]]>t?r:t};var PC=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},NC=dw,LC=cw,UC=AC,VC=$w,FC=PC,BC=Object.prototype.toString;function jC(e){if(!(this instanceof jC))return new jC(e);this.options=LC.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new FC,this.strm.avail_out=0;var r=NC.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(VC[r]);if(t.header&&NC.deflateSetHeader(this.strm,t.header),t.dictionary){var n;if(n="string"==typeof t.dictionary?UC.string2buf(t.dictionary):"[object ArrayBuffer]"===BC.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=NC.deflateSetDictionary(this.strm,n)))throw new Error(VC[r]);this._dict_set=!0}}function HC(e,t){var r=new jC(t);if(r.push(e,!0),r.err)throw r.msg||VC[r.err];return r.result}jC.prototype.push=function(e,t){var r,n,i=this.strm,o=this.options.chunkSize;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?i.input=UC.string2buf(e):"[object ArrayBuffer]"===BC.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;do{if(0===i.avail_out&&(i.output=new LC.Buf8(o),i.next_out=0,i.avail_out=o),1!==(r=NC.deflate(i,n))&&0!==r)return this.onEnd(r),this.ended=!0,!1;0!==i.avail_out&&(0!==i.avail_in||4!==n&&2!==n)||("string"===this.options.to?this.onData(UC.buf2binstring(LC.shrinkBuf(i.output,i.next_out))):this.onData(LC.shrinkBuf(i.output,i.next_out)))}while((i.avail_in>0||0===i.avail_out)&&1!==r);return 4===n?(r=NC.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==n||(this.onEnd(0),i.avail_out=0,!0)},jC.prototype.onData=function(e){this.chunks.push(e)},jC.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=LC.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},uw.Deflate=jC,uw.deflate=HC,uw.deflateRaw=function(e,t){return(t=t||{}).raw=!0,HC(e,t)},uw.gzip=function(e,t){return(t=t||{}).gzip=!0,HC(e,t)};var GC={},zC=tr,KC=O,XC=Ye,WC=ae,qC=function(){var e=zC(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},YC=RegExp.prototype,JC=ae,QC=function(e){var t=e.flags;return void 0!==t||"flags"in YC||XC(e,"flags")||!WC(YC,e)?t:KC(qC,e)},ZC=RegExp.prototype,$C=function(e){return e===ZC||JC(ZC,e)?QC(e):e.flags},ex={},tx=cw,rx=15,nx=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],ix=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],ox=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],ax=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],sx=cw,cx=Yw,ux=Zw,dx=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R;r=e.state,n=e.next_in,I=e.input,i=n+(e.avail_in-5),o=e.next_out,R=e.output,a=o-(t-e.avail_out),s=o+(e.avail_out-257),c=r.dmax,u=r.wsize,d=r.whave,l=r.wnext,h=r.window,p=r.hold,v=r.bits,_=r.lencode,f=r.distcode,m=(1<<r.lenbits)-1,y=(1<<r.distbits)-1;e:do{v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=_[p&m];t:for(;;){if(p>>>=S=g>>>24,v-=S,0===(S=g>>>16&255))R[o++]=65535&g;else{if(!(16&S)){if(0==(64&S)){g=_[(65535&g)+(p&(1<<S)-1)];continue t}if(32&S){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&g,(S&=15)&&(v<S&&(p+=I[n++]<<v,v+=8),b+=p&(1<<S)-1,p>>>=S,v-=S),v<15&&(p+=I[n++]<<v,v+=8,p+=I[n++]<<v,v+=8),g=f[p&y];r:for(;;){if(p>>>=S=g>>>24,v-=S,!(16&(S=g>>>16&255))){if(0==(64&S)){g=f[(65535&g)+(p&(1<<S)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(E=65535&g,v<(S&=15)&&(p+=I[n++]<<v,(v+=8)<S&&(p+=I[n++]<<v,v+=8)),(E+=p&(1<<S)-1)>c){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=S,v-=S,E>(S=o-a)){if((S=E-S)>d&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(k=0,T=h,0===l){if(k+=u-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}else if(l<S){if(k+=u+l-S,(S-=l)<b){b-=S;do{R[o++]=h[k++]}while(--S);if(k=0,l<b){b-=S=l;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}}}else if(k+=l-S,S<b){b-=S;do{R[o++]=h[k++]}while(--S);k=o-E,T=R}for(;b>2;)R[o++]=T[k++],R[o++]=T[k++],R[o++]=T[k++],b-=3;b&&(R[o++]=T[k++],b>1&&(R[o++]=T[k++]))}else{k=o-E;do{R[o++]=R[k++],R[o++]=R[k++],R[o++]=R[k++],b-=3}while(b>2);b&&(R[o++]=R[k++],b>1&&(R[o++]=R[k++]))}break}}break}}while(n<i&&o<s);n-=b=v>>3,p&=(1<<(v-=b<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=v},lx=function(e,t,r,n,i,o,a,s){var c,u,d,l,h,p,v,_,f,m=s.bits,y=0,g=0,S=0,b=0,E=0,k=0,T=0,I=0,R=0,A=0,w=null,C=0,x=new tx.Buf16(16),O=new tx.Buf16(16),D=null,M=0;for(y=0;y<=rx;y++)x[y]=0;for(g=0;g<n;g++)x[t[r+g]]++;for(E=m,b=rx;b>=1&&0===x[b];b--);if(E>b&&(E=b),0===b)return i[o++]=20971520,i[o++]=20971520,s.bits=1,0;for(S=1;S<b&&0===x[S];S++);for(E<S&&(E=S),I=1,y=1;y<=rx;y++)if(I<<=1,(I-=x[y])<0)return-1;if(I>0&&(0===e||1!==b))return-1;for(O[1]=0,y=1;y<rx;y++)O[y+1]=O[y]+x[y];for(g=0;g<n;g++)0!==t[r+g]&&(a[O[t[r+g]]++]=g);if(0===e?(w=D=a,p=19):1===e?(w=nx,C-=257,D=ix,M-=257,p=256):(w=ox,D=ax,p=-1),A=0,g=0,y=S,h=o,k=E,T=0,d=-1,l=(R=1<<E)-1,1===e&&R>852||2===e&&R>592)return 1;for(;;){v=y-T,a[g]<p?(_=0,f=a[g]):a[g]>p?(_=D[M+a[g]],f=w[C+a[g]]):(_=96,f=0),c=1<<y-T,S=u=1<<k;do{i[h+(A>>T)+(u-=c)]=v<<24|_<<16|f|0}while(0!==u);for(c=1<<y-1;A&c;)c>>=1;if(0!==c?(A&=c-1,A+=c):A=0,g++,0==--x[y]){if(y===b)break;y=t[r+a[g]]}if(y>E&&(A&l)!==d){for(0===T&&(T=E),h+=S,I=1<<(k=y-T);k+T<b&&!((I-=x[k+T])<=0);)k++,I<<=1;if(R+=1<<k,1===e&&R>852||2===e&&R>592)return 1;i[d=A&l]=E<<24|k<<16|h-o|0}}return 0!==A&&(i[h+A]=y-T<<24|64<<16|0),s.bits=E,0},hx=-2,px=12,vx=30;function _x(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function fx(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new sx.Buf16(320),this.work=new sx.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function mx(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new sx.Buf32(852),t.distcode=t.distdyn=new sx.Buf32(592),t.sane=1,t.back=-1,0):hx}function yx(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,mx(e)):hx}function gx(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?hx:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=r,n.wbits=t,yx(e))):hx}function Sx(e,t){var r,n;return e?(n=new fx,e.state=n,n.window=null,0!==(r=gx(e,t))&&(e.state=null),r):hx}var bx,Ex,kx=!0;function Tx(e){if(kx){var t;for(bx=new sx.Buf32(512),Ex=new sx.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(lx(1,e.lens,0,288,bx,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;lx(2,e.lens,0,32,Ex,0,e.work,{bits:5}),kx=!1}e.lencode=bx,e.lenbits=9,e.distcode=Ex,e.distbits=5}function Ix(e,t,r,n){var i,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new sx.Buf8(o.wsize)),n>=o.wsize?(sx.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):((i=o.wsize-o.wnext)>n&&(i=n),sx.arraySet(o.window,t,r-n,i,o.wnext),(n-=i)?(sx.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=i,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=i))),0}ex.inflateReset=yx,ex.inflateReset2=gx,ex.inflateResetKeep=mx,ex.inflateInit=function(e){return Sx(e,15)},ex.inflateInit2=Sx,ex.inflate=function(e,t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R=0,A=new sx.Buf8(4),w=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return hx;(r=e.state).mode===px&&(r.mode=13),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,l=s,h=c,k=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(2&r.wrap&&35615===u){r.check=0,A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0),u=0,d=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg="incorrect header check",r.mode=vx;break}if(8!=(15&u)){e.msg="unknown compression method",r.mode=vx;break}if(d-=4,E=8+(15&(u>>>=4)),0===r.wbits)r.wbits=E;else if(E>r.wbits){e.msg="invalid window size",r.mode=vx;break}r.dmax=1<<E,e.adler=r.check=1,r.mode=512&u?10:px,u=0,d=0;break;case 2:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.flags=u,8!=(255&$C(r))){e.msg="unknown compression method",r.mode=vx;break}if(57344&$C(r)){e.msg="unknown header flags set",r.mode=vx;break}r.head&&(r.head.text=u>>8&1),512&$C(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0,r.mode=3;case 3:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.time=u),512&$C(r)&&(A[0]=255&u,A[1]=u>>>8&255,A[2]=u>>>16&255,A[3]=u>>>24&255,r.check=ux(r.check,A,4,0)),u=0,d=0,r.mode=4;case 4:for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.head&&(r.head.xflags=255&u,r.head.os=u>>8),512&$C(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0,r.mode=5;case 5:if(1024&$C(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length=u,r.head&&(r.head.extra_len=u),512&$C(r)&&(A[0]=255&u,A[1]=u>>>8&255,r.check=ux(r.check,A,2,0)),u=0,d=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&$C(r)&&((p=r.length)>s&&(p=s),p&&(r.head&&(E=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),sx.arraySet(r.head.extra,n,o,p,E)),512&$C(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,r.length-=p),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&$C(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.name+=String.fromCharCode(E))}while(E&&p<s);if(512&$C(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&$C(r)){if(0===s)break e;p=0;do{E=n[o+p++],r.head&&E&&r.length<65536&&(r.head.comment+=String.fromCharCode(E))}while(E&&p<s);if(512&$C(r)&&(r.check=ux(r.check,n,p,o)),s-=p,o+=p,E)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&$C(r)){for(;d<16;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(65535&r.check)){e.msg="header crc mismatch",r.mode=vx;break}u=0,d=0}r.head&&(r.head.hcrc=$C(r)>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=px;break;case 10:for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}e.adler=r.check=_x(u),u=0,d=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,2;e.adler=r.check=1,r.mode=px;case px:if(5===t||6===t)break e;case 13:if(r.last){u>>>=7&d,d-=7&d,r.mode=27;break}for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}switch(r.last=1&u,d-=1,3&(u>>>=1)){case 0:r.mode=14;break;case 1:if(Tx(r),r.mode=20,6===t){u>>>=2,d-=2;break e}break;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=vx}u>>>=2,d-=2;break;case 14:for(u>>>=7&d,d-=7&d;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if((65535&u)!=(u>>>16^65535)){e.msg="invalid stored block lengths",r.mode=vx;break}if(r.length=65535&u,u=0,d=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(p=r.length){if(p>s&&(p=s),p>c&&(p=c),0===p)break e;sx.arraySet(i,n,o,p,a),s-=p,o+=p,c-=p,a+=p,r.length-=p;break}r.mode=px;break;case 17:for(;d<14;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(r.nlen=257+(31&u),u>>>=5,d-=5,r.ndist=1+(31&u),u>>>=5,d-=5,r.ncode=4+(15&u),u>>>=4,d-=4,r.nlen>286||r.ndist>30){e.msg="too many length or distance symbols",r.mode=vx;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;d<3;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.lens[w[r.have++]]=7&u,u>>>=3,d-=3}for(;r.have<19;)r.lens[w[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,T={bits:r.lenbits},k=lx(0,r.lens,0,19,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid code lengths set",r.mode=vx;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(y<16)u>>>=f,d-=f,r.lens[r.have++]=y;else{if(16===y){for(I=f+2;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u>>>=f,d-=f,0===r.have){e.msg="invalid bit length repeat",r.mode=vx;break}E=r.lens[r.have-1],p=3+(3&u),u>>>=2,d-=2}else if(17===y){for(I=f+3;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,p=3+(7&(u>>>=f)),u>>>=3,d-=3}else{for(I=f+7;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}d-=f,E=0,p=11+(127&(u>>>=f)),u>>>=7,d-=7}if(r.have+p>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=vx;break}for(;p--;)r.lens[r.have++]=E}}if(r.mode===vx)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=vx;break}if(r.lenbits=9,T={bits:r.lenbits},k=lx(1,r.lens,0,r.nlen,r.lencode,0,r.work,T),r.lenbits=T.bits,k){e.msg="invalid literal/lengths set",r.mode=vx;break}if(r.distbits=6,r.distcode=r.distdyn,T={bits:r.distbits},k=lx(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,T),r.distbits=T.bits,k){e.msg="invalid distances set",r.mode=vx;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,dx(e,h),a=e.next_out,i=e.output,c=e.avail_out,o=e.next_in,n=e.input,s=e.avail_in,u=r.hold,d=r.bits,r.mode===px&&(r.back=-1);break}for(r.back=0;m=(R=r.lencode[u&(1<<r.lenbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(m&&0==(240&m)){for(g=f,S=m,b=y;m=(R=r.lencode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=f,d-=f,r.back+=f,r.length=y,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=px;break}if(64&m){e.msg="invalid literal/length code",r.mode=vx;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.length+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=(R=r.distcode[u&(1<<r.distbits)-1])>>>16&255,y=65535&R,!((f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(0==(240&m)){for(g=f,S=m,b=y;m=(R=r.distcode[b+((u&(1<<g+S)-1)>>g)])>>>16&255,y=65535&R,!(g+(f=R>>>24)<=d);){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}u>>>=g,d-=g,r.back+=g}if(u>>>=f,d-=f,r.back+=f,64&m){e.msg="invalid distance code",r.mode=vx;break}r.offset=y,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(I=r.extra;d<I;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}r.offset+=u&(1<<r.extra)-1,u>>>=r.extra,d-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=vx;break}r.mode=25;case 25:if(0===c)break e;if(p=h-c,r.offset>p){if((p=r.offset-p)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=vx;break}p>r.wnext?(p-=r.wnext,v=r.wsize-p):v=r.wnext-p,p>r.length&&(p=r.length),_=r.window}else _=i,v=a-r.offset,p=r.length;p>c&&(p=c),c-=p,r.length-=p;do{i[a++]=_[v++]}while(--p);0===r.length&&(r.mode=21);break;case 26:if(0===c)break e;i[a++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;d<32;){if(0===s)break e;s--,u|=n[o++]<<d,d+=8}if(h-=c,e.total_out+=h,r.total+=h,h&&(e.adler=r.check=$C(r)?ux(r.check,i,h,a-h):cx(r.check,i,h,a-h)),h=c,($C(r)?u:_x(u))!==r.check){e.msg="incorrect data check",r.mode=vx;break}u=0,d=0}r.mode=28;case 28:if(r.wrap&&$C(r)){for(;d<32;){if(0===s)break e;s--,u+=n[o++]<<d,d+=8}if(u!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=vx;break}u=0,d=0}r.mode=29;case 29:k=1;break e;case vx:k=-3;break e;case 31:return-4;default:return hx}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,r.hold=u,r.bits=d,(r.wsize||h!==e.avail_out&&r.mode<vx&&(r.mode<27||4!==t))&&Ix(e,e.output,e.next_out,h-e.avail_out),l-=e.avail_in,h-=e.avail_out,e.total_in+=l,e.total_out+=h,r.total+=h,r.wrap&&h&&(e.adler=r.check=$C(r)?ux(r.check,i,h,e.next_out-h):cx(r.check,i,h,e.next_out-h)),e.data_type=r.bits+(r.last?64:0)+(r.mode===px?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===h||4===t)&&0===k&&(k=-5),k},ex.inflateEnd=function(e){if(!e||!e.state)return hx;var t=e.state;return t.window&&(t.window=null),e.state=null,0},ex.inflateGetHeader=function(e,t){var r;return e&&e.state?0==(2&(r=e.state).wrap)?hx:(r.head=t,t.done=!1,0):hx},ex.inflateSetDictionary=function(e,t){var r,n=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?hx:11===r.mode&&cx(1,t,n,0)!==r.check?-3:Ix(e,t,n,n)?(r.mode=31,-4):(r.havedict=1,0):hx},ex.inflateInfo="pako inflate (from Nodeca project)";var Rx={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};var Ax=ex,wx=cw,Cx=AC,xx=Rx,Ox=$w,Dx=PC,Mx=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},Px=Object.prototype.toString;function Nx(e){if(!(this instanceof Nx))return new Nx(e);this.options=wx.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Dx,this.strm.avail_out=0;var r=Ax.inflateInit2(this.strm,t.windowBits);if(r!==xx.Z_OK)throw new Error(Ox[r]);if(this.header=new Mx,Ax.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Cx.string2buf(t.dictionary):"[object ArrayBuffer]"===Px.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(r=Ax.inflateSetDictionary(this.strm,t.dictionary))!==xx.Z_OK))throw new Error(Ox[r])}function Lx(e,t){var r=new Nx(t);if(r.push(e,!0),r.err)throw r.msg||Ox[r.err];return r.result}Nx.prototype.push=function(e,t){var r,n,i,o,a,s=this.strm,c=this.options.chunkSize,u=this.options.dictionary,d=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?xx.Z_FINISH:xx.Z_NO_FLUSH,"string"==typeof e?s.input=Cx.binstring2buf(e):"[object ArrayBuffer]"===Px.call(e)?s.input=new Uint8Array(e):s.input=e,s.next_in=0,s.avail_in=s.input.length;do{if(0===s.avail_out&&(s.output=new wx.Buf8(c),s.next_out=0,s.avail_out=c),(r=Ax.inflate(s,xx.Z_NO_FLUSH))===xx.Z_NEED_DICT&&u&&(r=Ax.inflateSetDictionary(this.strm,u)),r===xx.Z_BUF_ERROR&&!0===d&&(r=xx.Z_OK,d=!1),r!==xx.Z_STREAM_END&&r!==xx.Z_OK)return this.onEnd(r),this.ended=!0,!1;s.next_out&&(0!==s.avail_out&&r!==xx.Z_STREAM_END&&(0!==s.avail_in||n!==xx.Z_FINISH&&n!==xx.Z_SYNC_FLUSH)||("string"===this.options.to?(i=Cx.utf8border(s.output,s.next_out),o=s.next_out-i,a=Cx.buf2string(s.output,i),s.next_out=o,s.avail_out=c-o,o&&wx.arraySet(s.output,s.output,i,o,0),this.onData(a)):this.onData(wx.shrinkBuf(s.output,s.next_out)))),0===s.avail_in&&0===s.avail_out&&(d=!0)}while((s.avail_in>0||0===s.avail_out)&&r!==xx.Z_STREAM_END);return r===xx.Z_STREAM_END&&(n=xx.Z_FINISH),n===xx.Z_FINISH?(r=Ax.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===xx.Z_OK):n!==xx.Z_SYNC_FLUSH||(this.onEnd(xx.Z_OK),s.avail_out=0,!0)},Nx.prototype.onData=function(e){this.chunks.push(e)},Nx.prototype.onEnd=function(e){e===xx.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=wx.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},GC.Inflate=Nx,GC.inflate=Lx,GC.inflateRaw=function(e,t){return(t=t||{}).raw=!0,Lx(e,t)},GC.ungzip=Lx;var Ux={};(0,cw.assign)(Ux,uw,GC,Rx);var Vx,Fx=Ux,Bx="BytePlusRTC",jx=function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},Hx=function(){function e(t){Vl(this,e),Jd(this,"storeName",void 0),Jd(this,"pendingList",[]),this.storeName=t,!iw()&&jx()&&this._checkAndCreateStore(t)}var t,r;return Ul(e,[{key:"_checkAndCreateStore",value:function(t,r){var n=this;e.db&&e.db.close();var i=r?jx().open(Bx,r):jx().open(Bx);i.onupgradeneeded=function(){i.result.createObjectStore(t)},i.onerror=function(e){console.error("IndexedDBInterface error",i.error)},i.onsuccess=function(){var r=i.result;e.db=r;try{e.db.transaction(n.storeName,"readonly"),n.pendingList.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.txMode,i=t.resolve,o=t.reject,e.prev=1,e.next=4,n._getStore(r);case 4:a=e.sent,i(a),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o();case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}())}catch(o){n._checkAndCreateStore(t,r.version+1)}}}},{key:"_getStore",value:function(t){var r=this;return new Yf((function(n,i){e.db?n(e.db.transaction(r.storeName,t).objectStore(r.storeName)):r.pendingList.push({txMode:t,resolve:n,reject:i})}))}},{key:"put",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readwrite");case 2:return n=e.sent,e.abrupt("return",new Yf((function(e,i){var o=n.put(t,r);o.onsuccess=function(){e()},o.onerror=function(e){i(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._getStore("readonly");case 2:return r=e.sent,e.abrupt("return",new Yf((function(e,n){var i=r.get(t);i.onsuccess=function(){e(i.result)},i.onerror=function(e){n(e)}})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),e}();Jd(Hx,"db",void 0),Jd(Hx,"state","init");var Gx={product_line:"rtc",report_version:"5",os:"web",user_agent:iw()?"":null===(Vx=navigator)||void 0===Vx?void 0:Vx.userAgent,platform:"web",product:"webrtc",app_state:"active"},zx="ReportErrorBuffer",Kx=function(){function e(){Vl(this,e),Jd(this,"_buffer",new Hx(zx))}var t,r;return Ul(e,[{key:"set",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._buffer.put(t,zx);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"get",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.prev=1,e.next=4,this._buffer.get(zx);case 4:t=e.sent,e.next=9;break;case 7:e.prev=7,e.t0=e.catch(1);case 9:return e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(){return t.apply(this,arguments)})}]),e}(),Xx=function(){function e(){var t=this;Vl(this,e),Jd(this,"report_common",Gx),Jd(this,"dataBuffer",[]),Jd(this,"posting",!1),Jd(this,"sucSendTimer",void 0),Jd(this,"preSucTime",0),Jd(this,"errSendTimer",void 0),Jd(this,"errSendDelay",100),Jd(this,"errSendBuffer",void 0),Jd(this,"_logServerUrl",void 0),Jd(this,"_retryCount",0),iw()||(window.addEventListener("beforeunload",(function(){clearTimeout(t.errSendTimer),clearTimeout(t.sucSendTimer),t._send(void 0,!0)})),document.addEventListener("visibilitychange",(function(){"visible"===document.visibilityState?t.setCommonStats({app_state:"active"}):"hidden"===document.visibilityState&&t.setCommonStats({app_state:"background"})})))}var t;return Ul(e,[{key:"setUrl",value:function(e){this._logServerUrl=e}},{key:"setCommonStats",value:function(e){this.report_common=wb(this.report_common,e)}},{key:"enableErrorBuffer",value:function(){this.errSendBuffer=new Kx,this.loadErrorBuffer()}},{key:"push",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?this._send(e):(this.dataBuffer.push(e),!this.posting&&!this.errSendTimer&&Date.now()-this.preSucTime>2e3&&(clearTimeout(this.sucSendTimer),this._send()))}},{key:"_unshift",value:function(e){this.dataBuffer=Om(e).call(e,this.dataBuffer)}},{key:"_send",value:function(e,t){var r,n,i=this;if((e||this.dataBuffer.length)&&this._logServerUrl){var o={data:e||rk(r=this.dataBuffer).call(r,0,Wx(this.dataBuffer,5e5)),header:Zd(Zd({},this.report_common),{},{http_retry_count:this._retryCount}),from:"web",os:"web",version:"1"},a=new XMLHttpRequest;if(a.timeout=1e4,a.onreadystatechange=function(){if(4===a.readyState){var r,n,s,c;if(e||(i.posting=!1),200===a.status||304===a.status)try{r=JSON.parse(a.responseText)}catch(eq){n=eq}if(r&&0===r.StatusCode){if(!e&&!t)null===(s=i.errSendBuffer)||void 0===s||s.set([]),i._sucSend()}else if(setTimeout((function(){var e,t;xO(Om(e="reportor error, res:".concat(null===(t=r)||void 0===t?void 0:t.toString()," err:")).call(e,n),a.status,n)}),0),e)i._send(e);else i._unshift(o.data),null===(c=i.errSendBuffer)||void 0===c||c.set(Jk(i.dataBuffer)),t?i._send():i._errSend()}},a.open("POST",this._logServerUrl,!0),e||(this.posting=!0),!iw()&&mk(n=location.search).call(n,"_rtc_debug_"))a.send(Nm(o));else{var s=Fx.gzip(Nm(o));a.setRequestHeader("Content-Encoding","gzip"),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"),a.send(s)}}}},{key:"_sucSend",value:function(){this.errSendDelay=100,this._retryCount=0,this.preSucTime=Date.now(),this.sucSendTimer=window.setTimeout(this._send.bind(this),2e3)}},{key:"_errSend",value:function(){var e=this;this.errSendTimer=window.setTimeout((function(){e._send(),delete e.errSendTimer}),this.errSendDelay),this.errSendDelay*=2,this._retryCount++}},{key:"loadErrorBuffer",value:(t=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this.errSendBuffer)||void 0===r?void 0:r.get();case 2:if(e.t1=t=e.sent,e.t0=null!==e.t1,!e.t0){e.next=6;break}e.t0=void 0!==t;case 6:if(!e.t0){e.next=10;break}e.t2=t,e.next=11;break;case 10:e.t2=[];case 11:e.t2.forEach((function(e){n.push(e)}));case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function Wx(e,t){for(var r=0,n=0;n<e.length;n++)if((r+=Nm(e[n]).length)>t)return n-1;return e.length}var qx=new Xx,Yx=function(){function e(t){Vl(this,e),Jd(this,"report_id",0),Jd(this,"modify_ids",{}),this.id=t}return Ul(e,[{key:"report",value:function(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=Zd(Zd(Zd({event_key:e,report_id:this.report_id++,rtc_timestamp:Date.now()},this.modify_ids),t),{},{common_extra_info:Nm(i)});(qx.push(o),iw())||(null===(r=(n=window).__onRTCReport)||void 0===r||r.call(n,this.id,o))}},{key:"set",value:function(e){this.modify_ids=wb(this.modify_ids,e)}},{key:"destroy",value:function(){}}]),e}(),Jx=UA.start;Ar({target:"String",proto:!0,forced:VA},{padStart:function(e){return Jx(this,e,arguments.length>1?arguments[1]:void 0)}});var Qx,Zx=Us("String").padStart,$x=ae,eO=Zx,tO=String.prototype,rO=function(e){var t=e.padStart;return"string"==typeof e||e===tO||$x(tO,e)&&t===tO.padStart?eO:t},nO=Us("Array").keys,iO=_n,oO=Ye,aO=ae,sO=nO,cO=Array.prototype,uO={DOMTokenList:!0,NodeList:!0},dO=function(e){var t=e.keys;return e===cO||aO(cO,e)&&t===cO.keys||oO(uO,iO(e))?sO:t},lO="@byted/ve-rtc",hO="@byted/ve-rtc-cache-size",pO=function(){function e(){Vl(this,e),Jd(this,"storeKey",void 0),Jd(this,"logLevel",void 0),Jd(this,"LogfileSize",void 0),Jd(this,"db",void 0),Jd(this,"logId",void 0),Jd(this,"cacheLog",void 0),Jd(this,"cachedSize",void 0),Jd(this,"preCacheTime",void 0),Jd(this,"timer",void 0),Jd(this,"_getSize",(function(e){return new Blob(e).size/1048576})),this.storeKey="",this.logId=1,this.cacheLog="",this.logLevel="none",this.LogfileSize=100,this._createStore()}return Ul(e,[{key:"_createStore",value:function(){var e=this;if(!iw()&&window.indexedDB){var t=indexedDB.open("@byted/ve-rtc");t.onupgradeneeded=function(){t.result.createObjectStore(lO);try{localStorage.removeItem(hO)}catch(eq){}},t.onerror=function(e){},t.onsuccess=function(){e.db=t.result,e._getCachedSize()}}}},{key:"_getCachedSize",value:function(){var e=this;try{var t=localStorage.getItem(hO);if(t)this.cachedSize=+t;else iR(this).call(this).then((function(t){e.cachedSize=e._getSize(t),e._setCachedSize()}))}catch(eq){}}},{key:"_setCachedSize",value:function(){try{localStorage.setItem(hO,"".concat(this.cachedSize))}catch(eq){}}},{key:"_getStore",value:function(e){if(this.db)return this.db.transaction(lO,e).objectStore(lO)}},{key:"set",value:function(e){var t=this;return new Yf((function(r,n){if("none"===t.logLevel)return r();var i;if(e&&t.preCacheTime&&t.preCacheTime-Date.now()<1e3)return t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,t.timer||(t.timer=setTimeout((function(){t.set("")}),1e3-(t.preCacheTime-Date.now()))),r();clearTimeout(t.timer),t.timer=null;var o=t._getStore("readwrite");if(!o)return n("get store fail");t.cachedSize&&t.cachedSize>t.LogfileSize&&t.keyEarliest().then((function(e){t.get(e).then((function(r){t.del(e).then((function(){t.cachedSize=t.cachedSize-t._getSize(["".concat(r)]),t._setCachedSize()}))}))}));var a=o.get(t.storeKey);a.onsuccess=function(){try{var i,s,c,u,d,l=Om(i="".concat(a.result||"")).call(i,t.cacheLog),h=e?Om(s=Om(c="".concat(l?"\n\n":"")).call(c,t.logId,": ")).call(s,e):"";o.put(Om(u="".concat(l)).call(u,h),t.storeKey),e&&t.logId++,t.cacheLog="",t.cachedSize=(t.cachedSize||0)+t._getSize([Om(d="".concat(t.cacheLog)).call(d,h)]),t._setCachedSize(),t.preCacheTime=Date.now(),r()}catch(v){var p;if(!e)return n(v);t.cacheLog+=Om(p="\n\n".concat(t.logId,": ")).call(p,e),t.logId++,n(v)}},a.onerror=function(r){var i;if(!e)return n(r);t.cacheLog+=Om(i="\n\n".concat(t.logId,": ")).call(i,e),t.logId++,n(r)}}))}},{key:"get",value:function(e){var t=this;return new Yf((function(r,n){var i=t._getStore("readonly");if(!i)return n();var o=i.get(e);o.onsuccess=function(){r(o.result)},o.onerror=function(e){n(e)}}))}},{key:"del",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.storeKey;return new Yf((function(r,n){var i=e._getStore("readwrite");if(!i)return n();var o=i.delete(t);o.onsuccess=function(){return r(o.result)},o.onerror=function(e){return n(e)}}))}},{key:"keyEarliest",value:function(){return dO(this).call(this).then((function(e){var t,r=Date.now();return e.forEach((function(e){if(e&&e.length){var n=e.split("-")[0];Number(n)<r&&(r=Number(n),t=e)}})),t}))}},{key:"keys",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAllKeys){var i=n.getAllKeys();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.key),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"values",value:function(){var e=this;return new Yf((function(t,r){var n=e._getStore("readonly");if(!n)return r();if(n.getAll){var i=n.getAll();return i.onsuccess=function(){t(i.result)},void(i.onerror=function(){r()})}var o=[];n.openCursor().onsuccess=function(){this.result&&(o.push(this.result.value),this.result.continue())},n.transaction.oncomplete=function(){return t(o)}}))}},{key:"download",value:function(e){e=e||this.storeKey,this.get(e).then((function(t){var r=document.createElement("a");r.download="".concat(e,".txt"),r.href="data:text/paint;utf-8,"+(t||""),r.click()}))}}]),e}(),vO=new pO,_O="[VERTC]",fO=["#0050b3","#0050b3","#0050b3","#0050b3","#0050b3"],mO="undefined"!=typeof window&&mk(Qx=window.location.search).call(Qx,"_rtc_debug_"),yO=function(){function e(t,r,n){Vl(this,e),Jd(this,"_indent",void 0),Jd(this,"_module",void 0),Jd(this,"_id",void 0),this._module=t,this._indent=r}return Ul(e,[{key:"print",value:function(e){for(var t,r,n,i,o,a,s,c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];var l=u.shift();try{var h,p,v,_,f=Om(h=[]).call(h,u),m="".concat(l).replace(/\%o/gi,(function(){var e=f.shift();return Nm(e)}));vO.set(Om(p=Om(v=Om(_="".concat(_O,"[").concat(this._module,".")).call(_,e,"] ")).call(v,m," ")).call(p,jm(f).call(f,(function(e){return Nm(e)})).join(", ")))}catch(eq){}if(mO){for(var y="",g=0;g<this._indent;g++)y+=" ";(t=console).log.apply(t,Om(r=[Om(n=Om(i=Om(o=Om(a=Om(s="%c".concat(gO(),"-")).call(s,_O)).call(a,y,"[")).call(o,this._module,".")).call(i,e,"] ")).call(n,l),"color:".concat(fO[this._indent],";")]).call(r,u))}}}]),e}(),gO=function(){var e,t=new Date;return t.toTimeString().split(" ")[0]+":"+rO(e=t.getMilliseconds().toString()).call(e,3,"0")},SO=new yO("MessageReportor",1),bO=function(){function e(t){Vl(this,e),Jd(this,"_preTime",Date.now()),Jd(this,"_one2oneNum",0),Jd(this,"_one2manyNum",0),Jd(this,"_one2oneMsgCache",new $S),Jd(this,"_one2manyMsgCache",new $S),Jd(this,"roomId",""),Jd(this,"userId",""),Jd(this,"rtsSessionId",""),this.id=t}return Ul(e,[{key:"needReport",value:function(t){return!!e.config&&(Date.now()-this._preTime>=36e5&&(this._preTime=Date.now(),this._one2oneNum=0,this._one2manyNum=0),"one2one"===t&&this._one2oneNum<e.config.max_one2one_fpt_per_hour&&Math.random()<=e.config.one2one_fpt_ratio/100||"one2many"===t&&this._one2manyNum<e.config.max_one2many_fpt_per_hour&&Math.random()<=e.config.one2many_fpt_ratio/100)}},{key:"cacheP2PMsg",value:function(t){var r;this._one2oneMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateP2PMsg",value:function(e,t){var r=this._one2oneMsgCache.get(e);r&&this._one2oneMsgCache.set(e,Zd(Zd({},r),t))}},{key:"cacheCustomMsg",value:function(t){var r;this._one2manyMsgCache.set(t.msg_id,Zd({config_version:(null===(r=e.config)||void 0===r?void 0:r.version)||""},t))}},{key:"updateOne2ManyMsg",value:function(e,t){var r=this._one2manyMsgCache.get(e);r&&this._one2manyMsgCache.set(e,Zd(Zd({},r),t))}},{key:"reportP2PMsg",value:function(e){var t,r=this._one2oneMsgCache.get(e);r&&(SO.print("reportP2PMsg",r.type,Nm(r)),null===(t=MO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportOne2ManyMsg",value:function(e){var t,r=this._one2manyMsgCache.get(e);r&&(SO.print("reportOne2ManyMsg",r.type,Nm(r)),null===(t=MO(this.id))||void 0===t||t.report("rts_message",r))}},{key:"reportMsgRecv",value:function(t){var r,n;t.config_version=(null===(r=e.config)||void 0===r?void 0:r.version)||"",SO.print("reportMsgRecv",t.type,Nm(t)),null===(n=MO(this.id))||void 0===n||n.report("rts_message",t)}},{key:"destroy",value:function(){this._one2manyNum=0,this._one2oneNum=0,this._one2manyMsgCache.clear(),this._one2oneMsgCache.clear(),this._preTime=Date.now(),this.roomId="",this.userId="",this.rtsSessionId=""}}]),e}();Jd(bO,"config",void 0);var EO=new $S,kO={_cache:EO,setConfig:function(e){SO.print("setConfig","get config: "+Nm(e)),bO.config=e},setRtsSessionId:function(e,t){var r=EO.get(e);r&&(r.rtsSessionId=t)},createRTSMsgReportor:function(e){var t=EO.get(e)||new bO(e);return EO.set(e,t),t},destroyRTSMsgReportor:function(e){var t=EO.get(e);t&&(t.destroy(),EO.delete(e))},setRoomId:function(e,t){var r=EO.get(e);r&&(r.roomId=t||"")},setUserId:function(e,t){var r=EO.get(e);r&&(r.userId=t||"")},samplingP2PMsg:function(e,t){var r=EO.get(e);if(null!=r&&r.needReport("one2one")){var n,i=Om(n="".concat(t.from)).call(n,t.id),o=t.to?"one2one":"one2server";t.enable_report=!0,t.report_msg_id=t.id,r.cacheP2PMsg({rts_session_id:r.rtsSessionId,msg_id:i,node_role:"src_sdk",from:t.from,to:t.to||"server",type:o,rts_room_id:t.room,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""})}return t},updateP2PMsgReq:function(e,t,r){var n,i;t.enable_report&&aw(t.report_msg_id)&&(null===(n=EO.get(e))||void 0===n||n.updateP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id),{send_ts:Date.now(),msg_size:r}))},updateP2PMsgAck:function(e,t,r){if(t.enable_report&&aw(t.report_msg_id)){var n,i,o=EO.get(e);null==o||o.updateP2PMsg(Om(n="".concat(t.from)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportP2PMsg(Om(i="".concat(t.from)).call(i,t.report_msg_id))}},samplingOne2ManyMsg:function(e,t,r){var n,i=EO.get(e);null!=i&&i.needReport("one2many")&&(r.enable_report=!0,r.report_msg_id=t,i.cacheCustomMsg({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(r.clientId)).call(n,t),node_role:"src_sdk",from:r.clientId,to:i.roomId,type:"one2many",rts_room_id:i.roomId,req_ts:Date.now(),send_ts:Date.now(),ack_ts:Date.now(),msg_size:0,error_code:0,recv_msg_ts:0,fwd_msg_ts:0,reply_ack_ts:0,cur_dst_uid:""}));return r},reportP2PMsgRecv:function(e,t,r){if(t.enable_report&&aw(t.report_msg_id)){var n,i=EO.get(e),o=t.to?"one2one":"one2many";null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.from)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:o,rts_room_id:t.room,from:t.from,to:t.to||t.room,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:t.to?"":i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}},updateOne2ManyMsgAck:function(e,t,r){if(t.enable_report&&aw(t.report_msg_id)){var n,i,o=EO.get(e);if(o)null==o||o.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{ack_ts:Date.now(),error_code:r}),null==o||o.reportOne2ManyMsg(Om(i="".concat(t.clientId)).call(i,t.report_msg_id))}},updateOne2ManyMsgReq:function(e,t,r){if(t.enable_report&&aw(t.report_msg_id)){var n,i=EO.get(e);if(i)i.updateOne2ManyMsg(Om(n="".concat(t.clientId)).call(n,t.report_msg_id),{send_ts:Date.now(),msg_size:r})}},reportOne2ManyMsgRecv:function(e,t,r){if(t.enable_report&&aw(t.report_msg_id)){var n,i=EO.get(e);null==i||i.reportMsgRecv({rts_session_id:i.rtsSessionId,msg_id:Om(n="".concat(t.clientId)).call(n,t.report_msg_id),msg_size:r.msg_size,node_role:"dst_sdk",type:"one2many",rts_room_id:t.roomId,from:t.clientId,to:t.roomId,error_code:0,recv_msg_ts:r.recv_msg_ts,fwd_msg_ts:r.fwd_msg_ts,reply_ack_ts:Date.now(),cur_dst_uid:i.userId,config_version:"",req_ts:0,send_ts:0,ack_ts:0})}}},TO=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"userMessage",{}),Jd(this,"roomMessage",{}),this.id=t,this._setTimer()}return Ul(e,[{key:"_setTimer",value:function(){var e=this;!function t(){e._reportAndgReset(),clearTimeout(e._timer),e._timer=setTimeout(t,1e4)}()}},{key:"_reportAndgReset",value:function(){(an(this.userMessage).length||an(this.roomMessage).length)&&(this._report(),this._reset())}},{key:"_report",value:function(){var e,t,r,n=this;null===(e=MO(this.id))||void 0===e||e.report("rtc_message_statistics",{dc_user_message:jm(t=an(this.userMessage)).call(t,(function(e){return n.userMessage[e]})),dc_room_message:jm(r=an(this.roomMessage)).call(r,(function(e){return n.roomMessage[e]})),media_server_ip:""})}},{key:"_reset",value:function(){this.userMessage={},this.roomMessage={}}},{key:"_checkInitUserMessage",value:function(e,t){var r,n;this.userMessage[Om(r="".concat(t,"-")).call(r,e)]||(this.userMessage[Om(n="".concat(t,"-")).call(n,e)]={dc_peer_user_id:e,dc_send_total:0,dc_recv_total:0,dc_send_ack:0,dc_send_fail:0,dc_fail_timeout:0,dc_fail_no_receiver:0,dc_fail_no_relay_path:0,dc_cost_time:0,dc_cost_e2s:0,dc_cost_s2s:0,dc_least_time:1/0,dc_most_time:0,dc_cost_peer_s2e:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_message_type:t,dc_send_binary:0})}},{key:"_sendUserMessage",value:function(e,t,r){var n,i;(this._checkInitUserMessage(e,t),this.userMessage[Om(n="".concat(t,"-")).call(n,e)].dc_send_total++,r)&&this.userMessage[Om(i="".concat(t,"-")).call(i,e)].dc_send_binary++}},{key:"_recvUserMessage",value:function(e,t){var r;this._checkInitUserMessage(e,t),this.userMessage[Om(r="".concat(t,"-")).call(r,e)].dc_recv_total++}},{key:"_sendUserFail",value:function(e,t,r){var n,i=this.userMessage[Om(n="".concat(t,"-")).call(n,e)];i&&(i.dc_send_fail++,this._handleUserFail(i,r))}},{key:"_handleUserFail",value:function(e,t){var r;t&&(t.code||t.err)&&(mk(r=["TIME_OUT","USER_MESSAGE_TIMEOUT"]).call(r,t.code)?e.dc_fail_timeout++:3===t.err?e.dc_fail_no_receiver++:4===t.err?e.dc_fail_no_relay_path++:1===t.err&&e.dc_fail_timeout++)}},{key:"_sendUserAck",value:function(e,t,r,n,i){var o,a=this.userMessage[Om(o="".concat(t,"-")).call(o,e)];a&&(a.dc_send_ack++,a.dc_cost_time+=r,a.dc_cost_s2s+=n||0,a.dc_cost_peer_s2e+=i,a.dc_cost_e2s+=r-(n||0)-i,r<=100?(a.dc_send_ack_100++,a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=200?(a.dc_send_ack_200++,a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=400?(a.dc_send_ack_400++,a.dc_send_ack_1s++):r<=1e3&&a.dc_send_ack_1s++,r<a.dc_least_time&&(a.dc_least_time=r),r>a.dc_most_time&&(a.dc_most_time=r))}},{key:"sendRoomMessage",value:function(e,t){this.roomMessage[e]||(this.roomMessage[e]={dc_room_id:e,dc_send_total:0,dc_send_ack:0,dc_cost_time:0,dc_least_time:1/0,dc_most_time:0,dc_send_fail:0,dc_send_ack_100:0,dc_send_ack_200:0,dc_send_ack_400:0,dc_send_ack_1s:0,dc_send_binary:0}),this.roomMessage[e].dc_send_total++,t&&this.roomMessage[e].dc_send_binary++}},{key:"sendRoomFail",value:function(e){var t=this.roomMessage[e];t&&t.dc_send_fail++}},{key:"sendRoomAck",value:function(e,t){var r=this.roomMessage[e];r&&(r.dc_send_ack++,r.dc_cost_time+=t,t<r.dc_least_time&&(r.dc_least_time=t),t>r.dc_most_time&&(r.dc_most_time=t),t<=100?(r.dc_send_ack_100++,r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=200?(r.dc_send_ack_200++,r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=400?(r.dc_send_ack_400++,r.dc_send_ack_1s++):t<=1e3&&r.dc_send_ack_1s++)}},{key:"sendP2PMessage",value:function(e,t){this._sendUserMessage(e,"p2p",t)}},{key:"recvP2PMessage",value:function(e){this._recvUserMessage(e,"p2p")}},{key:"sendP2PFail",value:function(e,t){this._sendUserFail(e,"p2p",t)}},{key:"sendP2PAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p",t,r,n)}},{key:"sendP2POutRoomMessage",value:function(e,t){this._sendUserMessage(e,"p2p_outside_room",t)}},{key:"recvP2POutRoomMessage",value:function(e){this._recvUserMessage(e,"p2p_outside_room")}},{key:"sendP2POutRoomFail",value:function(e,t){this._sendUserFail(e,"p2p_outside_room",t)}},{key:"sendP2POutRoomAck",value:function(e,t,r,n){this._sendUserAck(e,"p2p_outside_room",t,r,n)}},{key:"sendP2serverMessage",value:function(e){this._sendUserMessage("","p2server",e)}},{key:"sendP2serverFail",value:function(e){this._sendUserFail("","p2server",e)}},{key:"sendP2serveAck",value:function(e,t,r){this._sendUserAck("","p2server",e,t,r)}},{key:"countP2PMessage",value:function(e,t,r,n,i){this.sendP2PMessage(t,r),e?this.sendP2PAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2PFail(t,i)}},{key:"countRoomMessage",value:function(e,t,r,n){this.sendRoomMessage(t,r),e?this.sendRoomAck(t,Date.now()-n):this.sendRoomFail(t)}},{key:"countUserMessageOutsideRoom",value:function(e,t,r,n,i){this.sendP2POutRoomMessage(t,r),e?this.sendP2POutRoomAck(t,Date.now()-n,i.s2s_time,i.s2e_time):this.sendP2POutRoomFail(t,i)}},{key:"countServerMessage",value:function(e,t,r,n){this.sendP2serverMessage(t),e?(n=n||{},this.sendP2serveAck(Date.now()-r,n.s2s_time||0,n.s2e_time||0)):this.sendP2serverFail(n)}},{key:"destroy",value:function(){this._reset(),clearTimeout(this._timer)}}]),e}(),IO=function(e){qx.setCommonStats(e)},RO=function(e){qx.setUrl(e)},AO=new Yx("global"),wO=function(e,t,r){AO.report("rtc_sdk_api_call",{sdk_api_name:e,error_code:t,message:r})},CO=function(e,t,r){AO.report("rtc_sdk_callback",{sdk_callback_name:e,error_code:t,message:r})},xO=function(e,t,r){AO.report("rtc_error",{message:e,error_code:t},r)},OO=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;AO.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)},DO=new $S,MO=function(e){return DO.get(e)};function PO(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e,r,n){if("function"==typeof n.value){var i=n.value;n.value=function(){for(var e,n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];var s,c,u=this.engineId||this.id,d={};(t.forEach((function(e,t){d[e]=o[t]})),"joinRoom"===r)&&(null===(s=MO(u))||void 0===s||s.set({room_id:o[1],user_id:null===(c=o[2])||void 0===c?void 0:c.userId}));null===(e=MO(u))||void 0===e||e.report("rtc_sdk_api_call",{sdk_api_name:r,message:Nm(UO(o)),error_code:0},d);var l=i.apply(this,o);return"function"==typeof(null==l?void 0:l.then)?l.then((function(e){return NO(u,r,[e||{}]),e})).catch((function(e){throw NO(u,r,e.message,e.code),e})):(NO(u,r,[l||{}]),l)}}}}var NO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4?arguments[4]:void 0,a={sdk_callback_name:t,error_code:i,message:Nm(Array.isArray(r)?UO(r):r)};o&&(a.room_id=o),null===(n=MO(e))||void 0===n||n.report("rtc_sdk_callback",a)},LO=function(e,t,r){var n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",a=arguments.length>5?arguments[5]:void 0;null===(n=MO(e))||void 0===n||n.report("rtc_invoke_status",{sdk_api_name:t,message:r,error_code:i,stream_id:o,elapse:0},a)};function UO(e){return jm(e).call(e,(function e(t){var r;if(null!=t&&t._reportName)return t._reportName;if(t instanceof HTMLElement)return t.toString();if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)){var n,i,o=ArrayBuffer.isView(t)?t.buffer:t,a=o.byteLength,s=[];if(a>10){var c,u,d,l,h=new DataView(o),p=jm(c=qk({length:5})).call(c,(function(e,t){return h.getUint8(t)})),v=jm(u=jm(d=qk({length:5})).call(d,(function(e,t){return a-1-t})).reverse()).call(u,(function(e){return h.getUint8(e)}));s=Om(l=[]).call(l,Jk(p),["..."],Jk(v))}else s=qk(new Uint8Array(o));return Om(n=Om(i="".concat(t.constructor.name,"(")).call(i,a,") [")).call(n,s.join(", "),"]")}if(t instanceof ImageData)return"ImageData";if(Array.isArray(t))return jm(t).call(t,e);if(mk(r=["[object Object]","[object MediaStreamTrack]"]).call(r,Object.prototype.toString.call(t))){var _={};for(var f in t)_[f]=e(t[f]);return _}return t}))}var VO=function(e){var t,r=MO(e.engineId),n={keys:dO(e),labelSelector:"",sdkVersion:e.sdkVersion,deviceType:"web",appId:e.appId,deviceId:e.deviceId,userAgent:"undefined"!=typeof navigator?navigator.userAgent:void 0},i=jm(t=e.requestDomains).call(t,(function(e){return"https://".concat(e,"/decision/v1/multi")}));null==r||r.report("rtc_get_config",{error_code:0,message:Nm(n),elapse:0,host:i.join(","),type:"request",config_id:"",enable_cloud_proxy:!1});var o=jm(i).call(i,function(){var e=Rm(Tm().mark((function e(t,r){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch(t,{method:"POST",body:Nm(n)}).then((function(e){return e.json()}));case 2:return i=e.sent,e.abrupt("return",{result:i,index:r});case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}());return new Yf((function(e){(function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))})(o).then((function(t){var n=t.result,o=t.index;null==r||r.report("rtc_get_config",{error_code:200,message:Nm(n),elapse:0,host:i[o],type:"response",config_id:"",enable_cloud_proxy:!1}),e(n)})).catch((function(e){var t;null==r||r.report("rtc_get_config",{error_code:500,message:null===(t=e[0])||void 0===t?void 0:t.message,elapse:0,host:"",type:"response",config_id:"",enable_cloud_proxy:!1})}))}))},FO={exports:{}},BO=n;Ar({global:!0,forced:BO.globalThis!==BO},{globalThis:BO});var jO=n,HO={exports:{}};!function(e,r){var n;e.exports=(n=n||function(e,r){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),void 0!==jO&&jO.crypto&&(n=jO.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==t&&t.crypto&&(n=t.crypto),!n)try{n=require("crypto")}catch(f){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(f){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(f){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},c=s.Base={extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},u=s.WordArray=c.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=t!=r?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e,t=c.clone.call(this);return t.words=km(e=this.words).call(e,0),t},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),d=a.enc={},l=d.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=uy(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},h=d.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=d.Utf8={stringify:function(e){try{return decodeURIComponent(escape(h.stringify(e)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(e){return h.parse(unescape(encodeURIComponent(e)))}},v=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){var t;"string"==typeof e&&(e=p.parse(e)),Om(t=this._data).call(t,e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),c=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,d=e.min(4*c,o);if(c){for(var l=0;l<c;l+=a)this._doProcessBlock(i,l);r=rk(i).call(i,0,c),n.sigBytes-=d}return new u.init(r,d)},clone:function(){var e=c.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=v.extend({cfg:c.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){v.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new _.HMAC.init(e,r).finalize(t)}}});var _=a.algo={};return a}(Math),n)}(HO),function(e,t){var r;e.exports=(r=HO.exports,function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,t=e.init,n=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};n.prototype=e}}(),r.lib.WordArray)}(FO);var GO=FO.exports,zO={exports:{}},KO={exports:{}};!function(e,t){var r;e.exports=(r=HO.exports,function(){var e=r,t=e.lib.WordArray;function n(e,r,n){for(var i=[],o=0,a=0;a<r;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return t.create(i,o)}e.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var c=n.charAt(64);if(c)for(;i.length%4;)i.push(c);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=xE(e).call(e,a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),r.enc.Base64)}(KO);var XO={exports:{}};!function(e,t){var r;e.exports=(r=HO.exports,function(e){var t=r,n=t.lib,i=n.WordArray,o=n.Hasher,a=t.algo,s=[];!function(){for(var t=0;t<64;t++)s[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,a=e[t+0],c=e[t+1],p=e[t+2],v=e[t+3],_=e[t+4],f=e[t+5],m=e[t+6],y=e[t+7],g=e[t+8],S=e[t+9],b=e[t+10],E=e[t+11],k=e[t+12],T=e[t+13],I=e[t+14],R=e[t+15],A=o[0],w=o[1],C=o[2],x=o[3];A=u(A,w,C,x,a,7,s[0]),x=u(x,A,w,C,c,12,s[1]),C=u(C,x,A,w,p,17,s[2]),w=u(w,C,x,A,v,22,s[3]),A=u(A,w,C,x,_,7,s[4]),x=u(x,A,w,C,f,12,s[5]),C=u(C,x,A,w,m,17,s[6]),w=u(w,C,x,A,y,22,s[7]),A=u(A,w,C,x,g,7,s[8]),x=u(x,A,w,C,S,12,s[9]),C=u(C,x,A,w,b,17,s[10]),w=u(w,C,x,A,E,22,s[11]),A=u(A,w,C,x,k,7,s[12]),x=u(x,A,w,C,T,12,s[13]),C=u(C,x,A,w,I,17,s[14]),A=d(A,w=u(w,C,x,A,R,22,s[15]),C,x,c,5,s[16]),x=d(x,A,w,C,m,9,s[17]),C=d(C,x,A,w,E,14,s[18]),w=d(w,C,x,A,a,20,s[19]),A=d(A,w,C,x,f,5,s[20]),x=d(x,A,w,C,b,9,s[21]),C=d(C,x,A,w,R,14,s[22]),w=d(w,C,x,A,_,20,s[23]),A=d(A,w,C,x,S,5,s[24]),x=d(x,A,w,C,I,9,s[25]),C=d(C,x,A,w,v,14,s[26]),w=d(w,C,x,A,g,20,s[27]),A=d(A,w,C,x,T,5,s[28]),x=d(x,A,w,C,p,9,s[29]),C=d(C,x,A,w,y,14,s[30]),A=l(A,w=d(w,C,x,A,k,20,s[31]),C,x,f,4,s[32]),x=l(x,A,w,C,g,11,s[33]),C=l(C,x,A,w,E,16,s[34]),w=l(w,C,x,A,I,23,s[35]),A=l(A,w,C,x,c,4,s[36]),x=l(x,A,w,C,_,11,s[37]),C=l(C,x,A,w,y,16,s[38]),w=l(w,C,x,A,b,23,s[39]),A=l(A,w,C,x,T,4,s[40]),x=l(x,A,w,C,a,11,s[41]),C=l(C,x,A,w,v,16,s[42]),w=l(w,C,x,A,m,23,s[43]),A=l(A,w,C,x,S,4,s[44]),x=l(x,A,w,C,k,11,s[45]),C=l(C,x,A,w,R,16,s[46]),A=h(A,w=l(w,C,x,A,p,23,s[47]),C,x,a,6,s[48]),x=h(x,A,w,C,y,10,s[49]),C=h(C,x,A,w,I,15,s[50]),w=h(w,C,x,A,f,21,s[51]),A=h(A,w,C,x,k,6,s[52]),x=h(x,A,w,C,v,10,s[53]),C=h(C,x,A,w,b,15,s[54]),w=h(w,C,x,A,c,21,s[55]),A=h(A,w,C,x,g,6,s[56]),x=h(x,A,w,C,R,10,s[57]),C=h(C,x,A,w,m,15,s[58]),w=h(w,C,x,A,T,21,s[59]),A=h(A,w,C,x,_,6,s[60]),x=h(x,A,w,C,E,10,s[61]),C=h(C,x,A,w,p,15,s[62]),w=h(w,C,x,A,S,21,s[63]),o[0]=o[0]+A|0,o[1]=o[1]+w|0,o[2]=o[2]+C|0,o[3]=o[3]+x|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;r[i>>>5]|=128<<24-i%32;var o=e.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),t.sigBytes=4*(r.length+1),this._process();for(var s=this._hash,c=s.words,u=0;u<4;u++){var d=c[u];c[u]=16711935&(d<<8|d>>>24)|4278255360&(d<<24|d>>>8)}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function l(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function h(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),r.MD5)}(XO);var WO={exports:{}},qO={exports:{}};!function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=HO.exports).lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],c=a.SHA1=o.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],c=r[4],u=0;u<80;u++){if(u<16)s[u]=0|e[t+u];else{var d=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=d<<1|d>>>31}var l=(n<<5|n>>>27)+c+s[u];l+=u<20?1518500249+(i&o|~i&a):u<40?1859775393+(i^o^a):u<60?(i&o|i&a|o&a)-1894007588:(i^o^a)-899497514,c=a,a=o,o=i<<30|i>>>2,i=n,n=l}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+c|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[14+(n+64>>>9<<4)]=Math.floor(r/4294967296),t[15+(n+64>>>9<<4)]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}}),r.SHA1=o._createHelper(c),r.HmacSHA1=o._createHmacHelper(c),u.SHA1)}(qO);var YO={exports:{}};!function(e,t){var r,n,i;e.exports=(n=(r=HO.exports).lib.Base,i=r.enc.Utf8,void(r.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,c=a.words,u=0;u<r;u++)s[u]^=1549556828,c[u]^=909522486;o.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t,r=this._hasher,n=r.finalize(e);return r.reset(),r.finalize(Om(t=this._oKey.clone()).call(t,n))}})))}(YO),function(e,t){var r,n,i,o,a,s,c,u;e.exports=(n=(r=u=HO.exports).lib,i=n.Base,o=n.WordArray,a=r.algo,s=a.MD5,c=a.EvpKDF=i.extend({cfg:i.extend({keySize:4,hasher:s,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,i=n.hasher.create(),a=o.create(),s=a.words,c=n.keySize,u=n.iterations;s.length<c;){r&&i.update(r),r=i.update(e).finalize(t),i.reset();for(var d=1;d<u;d++)r=i.finalize(r),i.reset();Om(a).call(a,r)}return a.sigBytes=4*c,a}}),r.EvpKDF=function(e,t,r){return c.create(r).compute(e,t)},u.EvpKDF)}(WO);var JO={exports:{}};!function(e,t){var r;e.exports=void((r=HO.exports).lib.Cipher||function(e){var t=r,n=t.lib,i=n.Base,o=n.WordArray,a=n.BufferedBlockAlgorithm,s=t.enc;s.Utf8;var c=s.Base64,u=t.algo.EvpKDF,d=n.Cipher=a.extend({cfg:i.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){a.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?g:m}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});n.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},h=n.BlockCipherMode=i.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),p=l.CBC=function(){var t=h.extend();function r(t,r,n){var i,o=this._iv;o?(i=o,this._iv=e):i=this._prevBlock;for(var a=0;a<n;a++)t[r+a]^=i[a]}return t.Encryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize;r.call(this,e,t,i),n.encryptBlock(e,t),this._prevBlock=km(e).call(e,t,t+i)}}),t.Decryptor=t.extend({processBlock:function(e,t){var n=this._cipher,i=n.blockSize,o=km(e).call(e,t,t+i);n.decryptBlock(e,t),r.call(this,e,t,i),this._prevBlock=o}}),t}(),v=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,i=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(i);var c=o.create(a,n);Om(e).call(e,c)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:v}),reset:function(){var e;d.reset.call(this);var t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var _=n.CipherParams=i.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),f=(t.format={}).OpenSSL={stringify:function(e){var t,r,n=e.ciphertext,i=e.salt;return(i?Om(t=Om(r=o.create([1398893684,1701076831])).call(r,i)).call(t,n):n).toString(c)},parse:function(e){var t,r=c.parse(e),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(t=o.create(km(n).call(n,2,4)),rk(n).call(n,0,4),r.sigBytes-=16),_.create({ciphertext:r,salt:t})}},m=n.SerializableCipher=i.extend({cfg:i.extend({format:f}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return _.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),y=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,i){var a;if(n||(n=o.random(8)),i)s=u.create({keySize:t+r,hasher:i}).compute(e,n);else var s=u.create({keySize:t+r}).compute(e,n);var c=o.create(km(a=s.words).call(a,t),4*r);return s.sigBytes=4*t,_.create({key:s,iv:c,salt:n})}},g=n.PasswordBasedCipher=m.extend({cfg:m.cfg.extend({kdf:y}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=m.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,m.decrypt.call(this,e,t,i.key,n)}})}())}(JO),function(e,t){var r;e.exports=(r=HO.exports,function(){var e=r,t=e.lib.BlockCipher,n=e.algo,i=[],o=[],a=[],s=[],c=[],u=[],d=[],l=[],h=[],p=[];!function(){for(var e=[],t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;var r=0,n=0;for(t=0;t<256;t++){var v=n^n<<1^n<<2^n<<3^n<<4;v=v>>>8^255&v^99,i[r]=v,o[v]=r;var _=e[r],f=e[_],m=e[f],y=257*e[v]^16843008*v;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,c[r]=y<<8|y>>>24,u[r]=y,y=16843009*m^65537*f^257*_^16843008*r,d[v]=y<<24|y>>>8,l[v]=y<<16|y>>>16,h[v]=y<<8|y>>>24,p[v]=y,r?(r=_^e[e[e[m^_]]],n^=e[e[n]]):r=n=1}}();var v=[0,1,2,4,8,16,32,64,128,27,54],_=n.AES=t.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e=this._keyPriorReset=this._key,t=e.words,r=e.sigBytes/4,n=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a<n;a++)a<r?o[a]=t[a]:(u=o[a-1],a%r?r>6&&a%r==4&&(u=i[u>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u]):(u=i[(u=u<<8|u>>>24)>>>24]<<24|i[u>>>16&255]<<16|i[u>>>8&255]<<8|i[255&u],u^=v[a/r|0]<<24),o[a]=o[a-r]^u);for(var s=this._invKeySchedule=[],c=0;c<n;c++){if(a=n-c,c%4)var u=o[a];else u=o[a-4];s[c]=c<4||a<=4?u:d[i[u>>>24]]^l[i[u>>>16&255]]^h[i[u>>>8&255]]^p[i[255&u]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,c,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,d,l,h,p,o),r=e[t+1],e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var c=this._nRounds,u=e[t]^r[0],d=e[t+1]^r[1],l=e[t+2]^r[2],h=e[t+3]^r[3],p=4,v=1;v<c;v++){var _=n[u>>>24]^i[d>>>16&255]^o[l>>>8&255]^a[255&h]^r[p++],f=n[d>>>24]^i[l>>>16&255]^o[h>>>8&255]^a[255&u]^r[p++],m=n[l>>>24]^i[h>>>16&255]^o[u>>>8&255]^a[255&d]^r[p++],y=n[h>>>24]^i[u>>>16&255]^o[d>>>8&255]^a[255&l]^r[p++];u=_,d=f,l=m,h=y}_=(s[u>>>24]<<24|s[d>>>16&255]<<16|s[l>>>8&255]<<8|s[255&h])^r[p++],f=(s[d>>>24]<<24|s[l>>>16&255]<<16|s[h>>>8&255]<<8|s[255&u])^r[p++],m=(s[l>>>24]<<24|s[h>>>16&255]<<16|s[u>>>8&255]<<8|s[255&d])^r[p++],y=(s[h>>>24]<<24|s[u>>>16&255]<<16|s[d>>>8&255]<<8|s[255&l])^r[p++],e[t]=_,e[t+1]=f,e[t+2]=m,e[t+3]=y},keySize:8});e.AES=t._createHelper(_)}(),r.AES)}(zO);var QO={exports:{}};!function(e,t){e.exports=HO.exports.enc.Hex}(QO);var ZO=QO.exports,$O={exports:{}};!function(e,t){var r,n,i;e.exports=((i=HO.exports).mode.CTR=(r=i.lib.BlockCipherMode.extend(),n=r.Encryptor=r.extend({processBlock:function(e,t){var r=this._cipher,n=r.blockSize,i=this._iv,o=this._counter;i&&(o=this._counter=km(i).call(i,0),this._iv=void 0);var a=km(o).call(o,0);r.encryptBlock(a,0),o[n-1]=o[n-1]+1|0;for(var s=0;s<n;s++)e[t+s]^=a[s]}}),r.Decryptor=n,r),i.mode.CTR)}($O);var eD=$O.exports,tD={exports:{}};!function(e,t){var r;e.exports=((r=HO.exports).pad.NoPadding={pad:function(){},unpad:function(){}},r.pad.NoPadding)}(tD);var rD=tD.exports,nD=new TextDecoder,iD=new TextEncoder,oD=function(){return nw()},aD=function(){return Date.now()};function sD(e){for(var t=0,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];for(var o=0,a=n;o<a.length;o++){var s=a[o];t+=s.length}for(var c=new e(t),u=0,d=0,l=n;d<l.length;d++){var h=l[d];c.set(h,u),u+=h.length}return c}var cD=function(){function e(){Vl(this,e)}var t,r;return Ul(e,null,[{key:"token2auth",value:function(t,r,n,i){return i?"Bearer ".concat(i):"Basic ".concat(e.createUnsafeToken(t,r,n))}},{key:"createUnsafeToken",value:function(e,t,r){var n;return window.btoa(Hs(n=[e,t,r]).call(n,(function(e){return null!==e})).join(":"))}},{key:"merge",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,i=kA(t);n<i.length;n++){var o=eI(i[n],2),a=o[0],s=o[1];null!==s&&"object"===Wd(s)?e.merge(t[a],r[a]):void 0!==r[a]&&(t[a]=r[a])}}},{key:"ab2str",value:function(e){return nD.decode(e)}},{key:"ab2obj",value:function(t){try{var r=e.ab2str(t);return JSON.parse(r)}catch(n){return{}}}},{key:"str2ab",value:function(e){return iD.encode(e).buffer}},{key:"ab2b64str",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Yf((function(e){var r=new FileReader;r.onload=function(){return e(r.result)},r.readAsDataURL(new Blob([t]))}));case 2:return r=e.sent,e.abrupt("return",r.split(",",2)[1]);case 4:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"b64str2ab",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch("data:application/octet;base64,"+t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}]),e}();function uD(){for(var e,t,r=(+zA(e=km(t="".concat(Math.random())).call(t,-7)).call(e,7,"0")).toString(2),n=zA(r).call(r,28,"1").split(""),i=[];n.length;)i.push(rk(n).call(n,0,7));return jm(i).call(i,(function(e,t){var r=t===i.length-1?"0":"1";return XA(r+e.join(""),2)}))}var dD=function(){return Math.floor(65535*Math.random())};function lD(e){return"string"==typeof e&&xE(e).call(e,"__web__rtc__rtt__")>-1}var hD,pD,vD,_D,fD,mD,yD,gD,SD=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]&&i[0],(r=new RTCPeerConnection({iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",sdpSemantics:"unified-plan"})).createDataChannel("default"),r.addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),t&&(r.addTransceiver("audio",{direction:"sendonly"}),r.addTransceiver("video",{direction:"sendonly"})),e.next=8,r.createOffer();case 8:return n=e.sent,r.close(),e.abrupt("return",n.sdp);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),bD=function(e){return new Yf((function(t,r){var n=(e=Array.isArray(e)?e:[]).length,i=[];0===n?r([]):e.forEach((function(e){e.then((function(e){t(e)}),(function(e){n--,i.push(e),0===n&&r(i)}))}))}))};function ED(e){return+Math.max(-127,10*JA(Math.pow(e/255,2))).toFixed(2)}function kD(e){return(e&ul.AUDIO)===ul.AUDIO}function TD(e){return(e&ul.VIDEO)===ul.VIDEO}function ID(e){var t={};return an(e).forEach((function(r){"object"===Wd(e[r])?t[r]=ID(e[r]):lA(r).call(r,"_")||(t[r]=e[r])})),t}function RD(e){var t=new DataView(e.buffer);if(t.byteLength<=4||65535!==t.getUint16(0))return{seiCount:1,seis:[e]};for(var r={seiCount:0,seis:[]},n=!1,i=2;i<t.byteLength;){var o=t.getUint16(i);if(i+=2,t.byteLength-i<o){n=!0;break}var a=new Uint8Array(e.buffer,i,o);if(i+=o,t.byteLength-i>0&&t.byteLength-i<=2){n=!0;break}r.seiCount++,r.seis.push(a)}return n&&(r.seiCount=1,r.seis=[e]),r}function AD(e){return null==e?"undefined | null":"string"==typeof e?e:Nm({contentHint:e.contentHint,enabled:e.enabled,id:e.id,kind:e.kind,label:e.label,muted:e.muted,readyState:e.readyState})}function wD(e){return void 0===e}function CD(e){return function(t,r,n){var i=n.value;n.value=function(){var t;console.warn(Om(t="[RTC WebSDK]: Api: ".concat(r," has been abandoned from version ")).call(t,e));for(var n=arguments.length,o=new Array(n),a=0;a<n;a++)o[a]=arguments[a];return i.apply(this,o)}}}function xD(e){console.warn("[RTC WebSDK]: "+e)}function OD(e){return"number"==typeof e?e:"number"==typeof(null==e?void 0:e.exact)?e.exact:"number"==typeof(null==e?void 0:e.ideal)?e.ideal:"number"==typeof(null==e?void 0:e.max)?e.max:"number"==typeof(null==e?void 0:e.min)?e.min:1}function DD(e){for(var t=atob(e),r=t.length,n=new Uint8Array(r),i=0;i<r;i++)n[i]=t.charCodeAt(i);return n}function MD(e){for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function PD(e,t,r){var n=ND(e),i=ND(t),o=ND(r);return function(e){for(var t=e.toString(ZO),r=new Uint8Array(t.length/2),n=0;n<t.length;n+=2)r[n/2]=uy(t.substr(n,2),16);return r}(zO.exports.encrypt(n,i,{iv:o,mode:eD,padding:rD}).ciphertext)}function ND(e){for(var t=[],r=0;r<e.length;r+=4)t.push(e[r]<<24|(e[r+1]||0)<<16|(e[r+2]||0)<<8|(e[r+3]||0));return GO.create(t,e.length)}var LD=function(){return"undefined"==typeof window},UD=LD()?"":window.navigator.userAgent;function VD(){var e="none";return LD()||(null!==UD.match("Firefox")?e="mozilla":null!==UD.match("Chrome")?(e="chrome-stable",null!==UD.match("Electron")&&(e="electron")):(null!==UD.match("Safari")||null!==UD.match("AppleWebKit"))&&(e="safari")),e}var FD="mozilla"===VD(),BD="safari"===VD(),jD="chrome-stable"===VD(),HD=!LD()&&/CriOS/i.test(UD),GD=!LD()&&/Edg\//i.test(UD),zD=!LD()&&/EdgA/i.test(UD),KD=!LD()&&/EdgiOS/i.test(UD),XD=GD||zD||KD;!LD()&&/(iPhone|iPod)/i.exec(UD);var WD=!LD()&&(!!/(iPad)/i.exec(UD)||/Macintosh/i.test(UD)&&"ontouchend"in document),qD=!LD()&&/Macintosh/i.test(UD),YD=!LD()&&/MicroMessenger/i.test(UD),JD=!LD()&&mk(hD=UD.toLowerCase()).call(hD,"mobile");!LD()&&/SM-\w+/i.test(UD);var QD=!LD()&&!!/(iPhone|iPad|iPod)/i.exec(UD),ZD=!LD()&&/Android/i.test(UD),$D=!LD()&&/Windows/i.test(UD),eM=0,tM=!LD()&&(null===(pD=UD.match(/version\/(\d+)/i))||void 0===pD?void 0:pD[1]);BD&&tM&&(eM=+tM);var rM=!LD()&&(null===(vD=UD.match(/Firefox\/(\d+)/i))||void 0===vD?void 0:vD[1]);FD&&rM&&(eM=+rM);var nM=eM,iM=eM,oM=null!==(_D=!LD()&&(null===(fD=UD.match(/ ([\d_]+) like Mac OS X/i))||void 0===fD||null===(mD=fD[1])||void 0===mD?void 0:jm(yD=mD.split("_")).call(yD,(function(e){return uy(e)}))))&&void 0!==_D?_D:[],aM=0,sM=!LD()&&(null===(gD=UD.match(/Chrome\/(\d+)/i))||void 0===gD?void 0:gD[1]);sM&&(aM=+sM);var cM=aM,uM="BytePlus",dM="RTC_DEVICE_ID",lM="RTC_ACCESS_NODE",hM="RTC_ACCESS_URLS",pM="ENGINE_WEB_CONFIG",vM="SERVER_CONFIG",_M=function(){function e(){Vl(this,e)}return Ul(e,[{key:"get",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{var r=JSON.parse(t);return r.ttl>0&&Date.now()-r.saveTime>r.ttl?(this.delete(e),null):r.message}catch(n){return null}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,n={ttl:r,saveTime:Date.now(),message:t};try{return localStorage.setItem(e,Nm(n)),!0}catch(i){return!1}}},{key:"getTtl",value:function(e){var t=localStorage.getItem(e);if(!t)return null;try{return JSON.parse(t).ttl}catch(r){return null}}},{key:"delete",value:function(e){try{return localStorage.removeItem(e),!0}catch(t){return!1}}}]),e}(),fM=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"_accessVersion","v2"),n}return Ul(r,[{key:"getDeviceId",value:function(){if(LD())return"";var e=this.get(dM);return e&&!/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e)||(e=function(e){for(var t="",r=0;r<e;r++)t+=Math.floor(10*Math.random());return t}(30)),this.setDeviceId(e),e}},{key:"setDeviceId",value:function(e){return IO({device_id:e}),this.set(dM,e),e}},{key:"getAccessNode",value:function(e){var t,r;return this.get(Om(t=Om(r="".concat(lM,"_").concat(e,"-")).call(r,uM,"-")).call(t,this._accessVersion))}},{key:"setAccessNode",value:function(e,t,r){var n,i;return this.set(Om(n=Om(i="".concat(lM,"_").concat(e,"-")).call(i,uM,"-")).call(n,this._accessVersion),t,1e3*r)}},{key:"deleteAccessNode",value:function(e,t){var r,n,i=this.getAccessNode(e),o=this.getTtl(Om(r=Om(n="".concat(lM,"_").concat(e,"-")).call(n,uM,"-")).call(r,this._accessVersion));Array.isArray(i)&&i.length>0&&((i=Hs(i).call(i,(function(e){return e.mediaID!==t.mediaID&&e.msgKey!==t.msgKey}))).length>0?this.setAccessNode(e,i,o||0):this.clearAccessNode(e))}},{key:"clearAccessNode",value:function(e){var t,r;this.delete(Om(t=Om(r="".concat(lM,"_").concat(e,"-")).call(r,uM,"-")).call(t,this._accessVersion))}},{key:"getAccessUrls",value:function(){return this.get("".concat(hM,"-").concat(uM))}},{key:"setAccessUrls",value:function(e){var t=jm(e).call(e,(function(e){var t,r=e.host,n=e.path;return Om(t="https://".concat(r)).call(t,n)}));return this.set("".concat(hM,"-").concat(uM),t)}},{key:"clearAccessUrls",value:function(){this.delete("".concat(hM,"-").concat(uM))}},{key:"getEngineWebConfig",value:function(e,t){var r,n,i,o=Om(r=Om(n="".concat(e,"_")).call(n,t,"_")).call(r,this.getDeviceId()),a=this.get(pM);return(null==a||null===(i=gE(a).call(a,(function(e){return e.key===o})))||void 0===i?void 0:i.config)||{}}},{key:"setEngineWebConfig",value:function(e,t,r){var n,i;if(r){var o=Om(n=Om(i="".concat(e,"_")).call(i,t,"_")).call(n,this.getDeviceId()),a=this.get(pM)||[];return(a=Hs(a).call(a,(function(e){return e.key!==o}))).push({key:o,config:r}),this.set(pM,km(a).call(a,-5))}}},{key:"getServerConfig",value:function(e){var t,r="".concat(e),n=this.get(vM);return(null==n||null===(t=gE(n).call(n,(function(e){return e.key===r})))||void 0===t?void 0:t.config)||{}}},{key:"setServerConfig",value:function(e,t){if(t){var r="".concat(e),n=this.get(vM)||[];return(n=Hs(n).call(n,(function(e){return e.key!==r}))).push({key:r,config:t}),this.set(vM,km(n).call(n,-5))}}}]),r}(_M),mM=new fM,yM=new yO("JoinRoomConfig",0),gM=function(){function e(t){var r;Vl(this,e),Jd(this,"_useTcpAfterJoinTimeout",e.DEFAULT_CONF.useTcpAfterJoinTimeout),Jd(this,"_joinWithTcpOnly",e.DEFAULT_CONF.joinWithTcpOnly),Jd(this,"_joinWithTcpOnlyDelay",e.DEFAULT_CONF.joinWithTcpOnlyDelay),Jd(this,"_blackBrowserRegexList",[]),this._engineId=t,xE(r=location.search).call(r,"__rtc_tcp_only__")>-1&&(this._joinWithTcpOnly=!0,this._joinWithTcpOnlyDelay=0),this._report()}return Ul(e,[{key:"useTcpAfterJoinTimeout",get:function(){return this._useTcpAfterJoinTimeout}},{key:"useTcpJoin",get:function(){return this._joinWithTcpOnly}},{key:"useTcpJoinDelay",get:function(){return this._joinWithTcpOnlyDelay}},{key:"isBlackBrower",value:function(){var e;return gE(e=this._blackBrowserRegexList).call(e,(function(e){return new RegExp(e).test(navigator.userAgent)}))}},{key:"setServerConfig",value:function(e){var t,r,n,i,o,a,s=!1;"boolean"==typeof(null==e||null===(t=e.use_tcp_after_join_timeout)||void 0===t?void 0:t.enable)&&(this._useTcpAfterJoinTimeout=null===(i=e.use_tcp_after_join_timeout)||void 0===i?void 0:i.enable,s=!0);"boolean"==typeof(null==e||null===(r=e.join_with_tcp_only)||void 0===r?void 0:r.enable)&&(this._joinWithTcpOnly=null===(o=e.join_with_tcp_only)||void 0===o?void 0:o.enable,s=!0);"number"==typeof(null==e||null===(n=e.join_with_tcp_only)||void 0===n?void 0:n.delay_ms)&&(this._joinWithTcpOnlyDelay=null===(a=e.join_with_tcp_only)||void 0===a?void 0:a.delay_ms,s=!0);e&&Array.isArray(e.black_browser_regex_list)&&(this._blackBrowserRegexList=e.black_browser_regex_list,s=!0),s&&this._report()}},{key:"toString",value:function(){return Nm({use_tcp_after_join_timeout:this._useTcpAfterJoinTimeout,join_with_tcp_only:this._joinWithTcpOnly,join_with_tcp_only_delay:this._joinWithTcpOnlyDelay,black_browser_regex_list:this._blackBrowserRegexList})}},{key:"_report",value:function(){yM.print("_report",this.toString()),LO(this._engineId,"web_join_room_config",this.toString())}}],[{key:"setDefaulConf",value:function(t){var r=t.useTcpAfterJoinTimeout,n=t.joinWithTcpOnly,i=t.joinWithTcpOnlyDelay;return"boolean"==typeof r&&(e.DEFAULT_CONF.useTcpAfterJoinTimeout=r),"boolean"==typeof n&&(e.DEFAULT_CONF.joinWithTcpOnly=n),"number"==typeof i&&(e.DEFAULT_CONF.joinWithTcpOnlyDelay=Math.max(0,i)),e.DEFAULT_CONF}}]),e}();Jd(gM,"DEFAULT_CONF",{useTcpAfterJoinTimeout:!0,joinWithTcpOnly:!1,joinWithTcpOnlyDelay:5e3});var SM="rtc-access.rtcplus.com,rtc-access-sg.rtcplus.com,rtc-access-va.rtcplus.com,rtc-access-fr.rtcplus.com".split(",");function bM(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/dispatch/v1/AccessInfo?Action=GetAccessInfo")}var EM="https://web-log-report.rtcplus.com/video/v1/webrtc_log/",kM="rtc.rtcplus.com".split(","),TM={VERSION:"4.54.11",ICE_CONFIG_REQUEST_URLS_INTERNAL:jm(SM).call(SM,bM),ICE_CONFIG_REQUEST_URLS:[],EXPECTED_ADDR:"",LOG_SERVER_URL:EM,CONFIG_REQUEST_DOMAINS:kM,DEVICE_ID:"",OVERSEA:!1,PLATFORM:"",PRODUCT:"",FORCE_ENABLED_REPORT_CALLBACKS:[],SKIP_WEB_AUDIO_IN_TRACK:!1,AUDIO_STALL:!0,VIDEO_STALL:!0,STATS_SCALLBACK_SUPPORT:!0,JOIN_ROOM_CONFIG:gM.DEFAULT_CONF,ENABLE_FALLBACK_HANDLER:!1,ENABLE_STANDARD_HANDLER:!1,PC_KILLSWITCH:{}};function IM(e,t){var r;if(wO("setParameter",0,Om(r="key: ".concat(e,", value: ")).call(r,t)),"VERSION"!==e){if("JOIN_ROOM_CONFIG"===e)return gM.setDefaulConf(t);if("ICE_CONFIG_REQUEST_URLS"===e)return"string"==typeof t&&(t=[t]),void(TM.ICE_CONFIG_REQUEST_URLS=jm(t).call(t,bM));if("PLATFORM"!==e||"string"!=typeof t)if("PRODUCT"!==e||"string"!=typeof t){if("FORCE_ENABLED_REPORT_CALLBACKS"===e)return"string"==typeof t&&(t=[t]),void(TM.FORCE_ENABLED_REPORT_CALLBACKS=t);if("LOG_SERVER_URL"===e){var n=t===pl.overseas?"https://web-log-report.rtcplus.com/video/v1/webrtc_log/":t===pl.domestic?EM:"string"==typeof t?t:void 0;n&&(TM.LOG_SERVER_URL=n,RO(n))}else if("OVERSEA"===e)return IO({extra_is_oversea:t?"1":"0"}),void(TM.OVERSEA=t);"DEVICE_ID"===e&&mM.setDeviceId(t),"ENABLE_REPORT_ERROR_BUFFER"===e&&t&&qx.enableErrorBuffer(),TM[e]=t}else IO({product:t});else IO({platform:t})}}function RM(e){return"DEVICE_ID"===e?mM.getDeviceId():TM[e]}function AM(e,t,r){var n,i,o,a,s,c,u,d,l;return{type:"publicstream",action:t,publicStreamID:e,publicStreamMeta:{audio:{},video:{fps:(null===(n=r.video)||void 0===n?void 0:n.fps)||15,bitrate:1e3*((null===(i=r.video)||void 0===i?void 0:i.kBitRate)||40),width:(null===(o=r.video)||void 0===o?void 0:o.width)||640,height:(null===(a=r.video)||void 0===a?void 0:a.height)||360},layout:{layoutMode:2,interpolationMode:(null===(s=r.layout)||void 0===s?void 0:s.interpolationMode)||fl.PREV_FRAME,canvas:{bgColor:(null===(c=r.layout)||void 0===c?void 0:c.backgroundColor)||"#000000",bgImage:(null===(u=r.layout)||void 0===u?void 0:u.backgroundImage)||""},regions:(null===(d=r.layout)||void 0===d||null===(l=d.regions)||void 0===l?void 0:jm(l).call(l,(function(e){return{roomId:e.roomId,userId:e.userId,alterImage:e.alertImage||"",alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,renderMode:void 0===e.renderMode?1:e.renderMode,streamType:e.isScreenStream?1:0,mediaType:e.mediaType||0,sourceCrop:e.sourceCrop}})))||[]}}}}var wM={width:640,height:480,frameRate:15,maxKbps:600},CM={width:1920,height:1080,frameRate:15,maxKbps:3e3};function xM(e,t){if("boolean"!=typeof e)throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,": The value should be boolean type."))}function OM(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(e<r||e>n||"number"!=typeof e){var i,o,a=new vA(hA.INVALID_PARAMS,Om(i=Om(o="Invalid ".concat(t,": the value range is [")).call(o,r,", ")).call(i,n,"]. integer only"));throw a}}function DM(e,t){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;if(null==e)throw new vA(hA.INVALID_PARAMS,"".concat(t," cannot be empty"));if(!VM(e,i,o))throw new vA(hA.INVALID_PARAMS,Om(r=Om(n="Invalid ".concat(t,": The value should be string type. Length of the string: [")).call(n,i,",")).call(r,o,"]"))}function MM(e,t,r){var n;if(!mk(r).call(r,e))throw new vA(hA.INVALID_PARAMS,Om(n="Invalid ".concat(t,": The value can only be set as ")).call(n,Nm(r)))}function PM(e){if(!(e instanceof MediaStreamTrack))throw new vA(hA.INVALID_PARAMS,"Invalid track, The value should be MediaStreamTrack type.")}function NM(e,t){if(FM(e))throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,", should not be empty"))}function LM(e,t){if(!(e instanceof ArrayBuffer))throw new vA(hA.INVALID_PARAMS,"Invalid ".concat(t,", should be ArrayBuffer"))}function UM(e){try{for(var t=navigator.mediaDevices.getSupportedConstraints(),r=0,n=an(e);r<n.length;r++){var i=n[r];t[i]||delete e[i]}}catch(o){}}function VM(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.POSITIVE_INFINITY;return"string"==typeof e&&e.length<=r&&e.length>=t}function FM(e){return null==e}function BM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The RoomId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function jM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The userId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function HM(e){if("string"!=typeof e||!/^[a-zA-Z0-9@._\-]{1,128}$/.test(e))throw new vA(hA.INVALID_PARAMS,"The publicStreamId must be within 128 bytes. The supported characters: a-z,A-Z,0-9,@,-,_,.")}function GM(e){NM(e,"userInfo"),jM(e.userId),FM(e.extraInfo)||DM(e.extraInfo,"userInfo.extraInfo",1,200)}function zM(e){NM(e,"roomConfig"),xM(e.isAutoPublish,"roomConfig.isAutoPublish"),xM(e.isAutoSubscribeAudio,"roomConfig.isAutoSubscribeAudio"),xM(e.isAutoSubscribeVideo,"roomConfig.isAutoSubscribeVideo"),FM(e.roomProfileType)||MM(e.roomProfileType,"roomConfig",[bl.communication,bl.chat,bl.chatRoom,bl.coHost,bl.meeting,bl.classRoom])}function KM(e){NM(e,"videoPlayerOption")}function XM(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:64;if(!e||0===(null==e?void 0:e.byteLength))throw new vA(hA.INVALID_PARAMS,"The message cannot be empty");if((null===(t=e instanceof ArrayBuffer?e:cD.str2ab(Nm(e)))||void 0===t?void 0:t.byteLength)>1024*r)throw new vA(hA.INVALID_PARAMS,"The message length must be less than ".concat(r,"K"))}function WM(e){var t,r=RM("FORCE_ENABLED_REPORT_CALLBACKS");return!(null==r||!mk(r).call(r,e))||!mk(t=[Nl.onRemoteStreamStats,Nl.onLocalStreamStats,Nl.onAudioVolumeIndication,Nl.onLocalAudioPropertiesReport,Nl.onRemoteAudioPropertiesReport]).call(t,e)}function qM(e){if("number"!=typeof(null==e?void 0:e.width)||"number"!=typeof(null==e?void 0:e.height))throw new vA(hA.INVALID_PARAMS,"remoteVideoConfig must contain width, height, frameRate")}function YM(e,t){if("number"!=typeof e||Number.isNaN(e)||!(e>=1)){var r=e;if(!(null!=r&&r.min||null!=r&&r.max||null!=r&&r.exact||null!=r&&r.ideal))throw new vA(hA.INVALID_PARAMS,"".concat(t," is not a valid ConstrainULong"))}}function JM(e){var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;OM(null==n?void 0:n.maxKbps,"maxKbps"),YM(null==n?void 0:n.width,"width"),YM(null==n?void 0:n.height,"height"),YM(null==n?void 0:n.frameRate,"frameRate")}}catch(i){r.e(i)}finally{r.f()}}function QM(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Number.NEGATIVE_INFINITY,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Number.POSITIVE_INFINITY;return OM(e,t,Number.NEGATIVE_INFINITY,Number.POSITIVE_INFINITY),e=(e=e>r?e:r)<n?e:n}var ZM={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||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 a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?km(n).call(n,1):n);return xs?Om(i).call(i,xs(e)):i},s.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,a=new Array(o);i<o;i++)a[i]=n[i].fn;return a},s.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,u,d=this._events[s],l=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),l){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,n),!0;case 4:return d.fn.call(d.context,t,n,i),!0;case 5:return d.fn.call(d.context,t,n,i,o),!0;case 6:return d.fn.call(d.context,t,n,i,o,a),!0}for(u=1,c=new Array(l-1);u<l;u++)c[u-1]=arguments[u];d.fn.apply(d.context,c)}else{var h,p=d.length;for(u=0;u<p;u++)switch(d[u].once&&this.removeListener(e,d[u].fn,void 0,!0),l){case 1:d[u].fn.call(d[u].context);break;case 2:d[u].fn.call(d[u].context,t);break;case 3:d[u].fn.call(d[u].context,t,n);break;case 4:d[u].fn.call(d[u].context,t,n,i);break;default:if(!c)for(h=1,c=new Array(l-1);h<l;h++)c[h-1]=arguments[h];d[u].fn.apply(d[u].context,c)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var c=0,u=[],d=s.length;c<d;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&a(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(ZM);var $M=ZM.exports,eP=new yO("VERTC",0),tP=function(e){MI(r,e);var t=JI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"safeEmit",value:function(e){var t=this.listenerCount(e);try{for(var n,i,o=arguments.length,a=new Array(o>1?o-1:0),s=1;s<o;s++)a[s-1]=arguments[s];return(n=OI(CI(r.prototype),"emit",this)).call.apply(n,Om(i=[this,e]).call(i,a))}catch(eq){return eP.print("safeEmit","safeEmit() | event listener threw an error [event:%s]:%o",e,eq),console.error(eq),Boolean(t)}}}]),r}(ZM.exports.EventEmitter),rP=O,nP=tr,iP=$,oP=nI,aP=Jt,sP=A,cP=mc,uP=V;Ar({target:"Reflect",stat:!0,forced:i((function(){var e=function(){},t=aP.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)}))},{set:function e(t,r,n){var i,o,a,s=arguments.length<4?t:arguments[3],c=sP.f(nP(t),r);if(!c){if(iP(o=cP(t)))return e(o,r,n,s);c=uP(0)}if(oP(c)){if(!1===c.writable||!iP(s))return!1;if(i=sP.f(s,r)){if(i.get||i.set||!1===i.writable)return!1;i.value=n,aP.f(s,r,i)}else aP.f(s,r,uP(0,n))}else{if(void 0===(a=c.set))return!1;rP(a,s,n)}return!0}});var dP=ee.Reflect.set,lP=hi.f("asyncIterator");function hP(e){var t,r,n,i=2;for(void 0!==wd&&(r=lP,n=Xd);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new pP(t.call(e));r="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function pP(e){function t(e){if(Object(e)!==e)return Yf.reject(new TypeError(e+" is not an object."));var t=e.done;return Yf.resolve(e.value).then((function(e){return{value:e,done:t}}))}return(pP=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Yf.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Yf.reject(e):t(r.apply(this.s,arguments))}},new pP(e)}var vP=[{maxLayers:3,totalPixels:2073600},{maxLayers:3,totalPixels:921600},{maxLayers:3,totalPixels:518400},{maxLayers:2,totalPixels:230400},{maxLayers:2,totalPixels:129600},{maxLayers:1,totalPixels:57600},{maxLayers:1,totalPixels:0}];Yy("Set",(function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}}),hg);var _P=ee.Set;Ar({target:"Set",stat:!0,forced:!0},{from:bg}),Ar({target:"Set",stat:!0,forced:!0},{of:kg});var fP=O,mP=Ce,yP=tr,gP=function(){for(var e=yP(this),t=mP(e.add),r=0,n=arguments.length;r<n;r++)fP(t,e,arguments[r]);return e};Ar({target:"Set",proto:!0,real:!0,forced:!0},{addAll:gP}),Ar({target:"Set",proto:!0,real:!0,forced:!0},{deleteAll:Ag});var SP=gh,bP=tr,EP=Yt,kP=SP,TP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{every:function(e){var t=bP(this),r=kP(t),n=EP(e,arguments.length>1?arguments[1]:void 0);return!TP(r,(function(e,r){if(!n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var IP=oe,RP=O,AP=Ce,wP=tr,CP=Rp,xP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{difference:function(e){var t=wP(this),r=new(CP(t,IP("Set")))(t),n=AP(r.delete);return xP(e,(function(e){RP(n,r,e)})),r}});var OP=oe,DP=O,MP=Ce,PP=tr,NP=Yt,LP=Rp,UP=SP,VP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{filter:function(e){var t=PP(this),r=UP(t),n=NP(e,arguments.length>1?arguments[1]:void 0),i=new(LP(t,OP("Set"))),o=MP(i.add);return VP(r,(function(e){n(e,e,t)&&DP(o,i,e)}),{IS_ITERATOR:!0}),i}});var FP=tr,BP=Yt,jP=SP,HP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{find:function(e){var t=FP(this),r=jP(t),n=BP(e,arguments.length>1?arguments[1]:void 0);return HP(r,(function(e,r){if(n(e,e,t))return r(e)}),{IS_ITERATOR:!0,INTERRUPTED:!0}).result}});var GP=oe,zP=O,KP=Ce,XP=tr,WP=Rp,qP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{intersection:function(e){var t=XP(this),r=new(WP(t,GP("Set"))),n=KP(t.has),i=KP(r.add);return qP(e,(function(e){zP(n,t,e)&&zP(i,r,e)})),r}});var YP=O,JP=Ce,QP=tr,ZP=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isDisjointFrom:function(e){var t=QP(this),r=JP(t.has);return!ZP(e,(function(e,n){if(!0===YP(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var $P=oe,eN=O,tN=Ce,rN=R,nN=tr,iN=gh,oN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSubsetOf:function(e){var t=iN(this),r=nN(e),n=r.has;return rN(n)||(r=new($P("Set"))(e),n=tN(r.has)),!oN(t,(function(e,t){if(!1===eN(n,r,e))return t()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var aN=O,sN=Ce,cN=tr,uN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{isSupersetOf:function(e){var t=cN(this),r=sN(t.has);return!uN(e,(function(e,n){if(!1===aN(r,t,e))return n()}),{INTERRUPTED:!0}).stopped}});var dN=Ar,lN=tr,hN=yn,pN=SP,vN=Uh,_N=E([].join),fN=[].push;dN({target:"Set",proto:!0,real:!0,forced:!0},{join:function(e){var t=lN(this),r=pN(t),n=void 0===e?",":hN(e),i=[];return vN(r,fN,{that:i,IS_ITERATOR:!0}),_N(i,n)}});var mN=oe,yN=Yt,gN=O,SN=Ce,bN=tr,EN=Rp,kN=SP,TN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{map:function(e){var t=bN(this),r=kN(t),n=yN(e,arguments.length>1?arguments[1]:void 0),i=new(EN(t,mN("Set"))),o=SN(i.add);return TN(r,(function(e){gN(o,i,n(e,e,t))}),{IS_ITERATOR:!0}),i}});var IN=Ce,RN=tr,AN=SP,wN=Uh,CN=TypeError;Ar({target:"Set",proto:!0,real:!0,forced:!0},{reduce:function(e){var t=RN(this),r=AN(t),n=arguments.length<2,i=n?void 0:arguments[1];if(IN(e),wN(r,(function(r){n?(n=!1,i=r):i=e(i,r,r,t)}),{IS_ITERATOR:!0}),n)throw CN("Reduce of empty set with no initial value");return i}});var xN=tr,ON=Yt,DN=SP,MN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{some:function(e){var t=xN(this),r=DN(t),n=ON(e,arguments.length>1?arguments[1]:void 0);return MN(r,(function(e,r){if(n(e,e,t))return r()}),{IS_ITERATOR:!0,INTERRUPTED:!0}).stopped}});var PN=oe,NN=O,LN=Ce,UN=tr,VN=Rp,FN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{symmetricDifference:function(e){var t=UN(this),r=new(VN(t,PN("Set")))(t),n=LN(r.delete),i=LN(r.add);return FN(e,(function(e){NN(n,r,e)||NN(i,r,e)})),r}});var BN=oe,jN=Ce,HN=tr,GN=Rp,zN=Uh;Ar({target:"Set",proto:!0,real:!0,forced:!0},{union:function(e){var t=HN(this),r=new(GN(t,BN("Set")))(t);return zN(e,jN(r.add),{that:r}),r}});var KN=_P,XN=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!LD()&&window.RTCPeerConnection&&window.RTCPeerConnection.prototype.addTransceiver&&window.RTCPeerConnection.prototype.createDataChannel){e.next=3;break}return e.abrupt("return",!1);case 3:return e.next=5,tL();case 5:if(e.t0=e.sent,!e.t0){e.next=10;break}return e.next=9,eL();case 9:e.t0=e.sent;case 10:return e.abrupt("return",e.t0);case 13:return e.prev=13,e.t1=e.catch(0),e.abrupt("return",!1);case 16:case"end":return e.stop()}}),e,null,[[0,13]])})));return function(){return e.apply(this,arguments)}}(),WN=function(){var e=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=[],e.next=3,tL();case 3:if(e.t0=e.sent,!e.t0){e.next=8;break}return e.next=7,eL();case 7:e.t0=e.sent;case 8:if(!e.t0){e.next=10;break}t.push("H264");case 10:return e.next=12,nL();case 12:if(e.t1=e.sent,!e.t1){e.next=17;break}return e.next=16,rL();case 16:e.t1=e.sent;case 17:if(!e.t1){e.next=19;break}t.push("vp8");case 19:return e.abrupt("return",t);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),qN=function(){var e=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,WN();case 2:return t=e.sent,e.abrupt("return",jm(t).call(t,(function(e){return e.toUpperCase()})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),YN={};function JN(e){var t,r=!1,n=$T(e.split("\n"));try{for(n.s();!(t=n.n()).done;){var i=t.value;if(mk(i).call(i,"level-asymmetry-allowed=1")&&mk(i).call(i,"packetization-mode=1")&&mk(i).call(i,"profile-level-id=42e0")){r=!0;break}}}catch(d){n.e(d)}finally{n.f()}if(r){for(var o=navigator.userAgent.toLowerCase(),a=!1,s=0,c=["miuibrowser"];s<c.length;s++){var u=c[s];mk(o).call(o,u)&&(a=!0)}return!a}return!1}var QN=function(){var e=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("video",{direction:t}),e.next=4,r.createOffer();case 4:return n=e.sent,r.close(),e.abrupt("return",n.sdp.toLowerCase());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ZN=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QN("sendonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QN("sendonly");case 6:r=e.sent;case 7:return YN.h264encode=JN(r),YN.vp8encode=xE(r).call(r,"vp8")>-1,e.abrupt("return",YN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$N=function(){var e=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,QN("recvonly");case 2:if(r=e.sent,!mk(t=navigator.userAgent).call(t,"VivoBrowser")){e.next=7;break}return e.next=6,QN("recvonly");case 6:r=e.sent;case 7:return YN.h264decode=JN(r),YN.vp8decode=xE(r).call(r,"vp8")>-1,e.abrupt("return",YN);case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),eL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.h264encode){e.next=9;break}return e.prev=1,e.next=4,ZN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.h264encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),tL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.h264decode){e.next=9;break}return e.prev=1,e.next=4,$N();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.h264decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),rL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.vp8encode){e.next=9;break}return e.prev=1,e.next=4,ZN();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.vp8encode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),nL=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==YN.vp8decode){e.next=9;break}return e.prev=1,e.next=4,$N();case 4:e.next=9;break;case 6:return e.prev=6,e.t0=e.catch(1),e.abrupt("return",!1);case 9:return e.abrupt("return",YN.vp8decode||!1);case 10:case"end":return e.stop()}}),e,null,[[1,6]])})));return function(){return e.apply(this,arguments)}}(),iL=function(){return"undefined"!=typeof TransformStream&&"undefined"!=typeof RTCRtpSender&&"undefined"!=typeof RTCRtpReceiver&&void 0!==RTCRtpSender.prototype.createEncodedStreams&&void 0!==RTCRtpReceiver.prototype.createEncodedStreams},oL=function(){return qD?jD&&cM>=70||FD&&iM>=80||BD&&nM>=14:$D?jD&&cM>=70||FD&&iM>=80:QD?oM[0]>=14:!!ZD&&(jD&&cM>=86)},aL=jD&&cM<=114,sL=new $S,cL=function(){var e=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,r){var n=RM("STATS_SCALLBACK_SUPPORT");if(jD&&void 0===window.InstallTrigger&&aL&&n)try{t.getStats((function(t){var r=[];t.result().forEach((function(e){if(!mk(hL).call(hL,e.type)){var t={};e.names().forEach((function(r){t[r]=e.stat(r)})),r.push(Zd(Zd({},t),{},{id:e.id,type:e.type,timestamp:e.timestamp}))}})),e({all:r,getTrackStats:function(e){return Hs(r).call(r,(function(t){return"ssrc"!==t.type||t.googTrackId===e}))}})}))}catch(eq){r(eq)}else e({all:[],getTrackStats:function(){return[]}})})));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),uL=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getStats();case 2:return n=e.sent,i={all:[]},o=new $S,n.forEach((function(e){var t=o.get(e.type)||new $S;t.set(e.id,e),o.set(e.type,t),i.all.push(e)})),a=function(e,t){e.forEach((function(e){var r,n,i,a,s,c,u=e.codecId,d=e.transportId,l=e.trackId,h=e.playoutId;if(null===(r=o.get(lL.codec))||void 0===r||r.forEach((function(e){e.id===u&&t.add(e)})),null===(n=o.get(lL.transport))||void 0===n||n.forEach((function(e){e.id===d&&(s=e,t.add(e))})),null===(i=o.get(lL.track))||void 0===i||i.forEach((function(e){e.id===l&&t.add(e)})),null===(a=o.get(lL.mediaPlayout))||void 0===a||a.forEach((function(e){e.id===h&&t.add(e)})),s){var p,v,_=s,f=_.localCertificateId,m=_.remoteCertificateId,y=_.selectedCandidatePairId;null===(p=o.get(lL.certificate))||void 0===p||p.forEach((function(e){(e.id===f||e.id===m)&&t.add(e)})),null===(v=o.get(lL.candidatePair))||void 0===v||v.forEach((function(e){e.id===y&&(c=e,t.add(e))}))}if(c){var g,S,b=c,E=b.localCandidateId,k=b.remoteCandidateId;null===(g=o.get(lL.localCandidate))||void 0===g||g.forEach((function(e){e.id===E&&t.add(e)})),null===(S=o.get(lL.remoteCandidate))||void 0===S||S.forEach((function(e){e.id===k&&t.add(e)}))}}))},o.get(lL.mediaSource)?null===(s=o.get(lL.mediaSource))||void 0===s||s.forEach((function(e){var t,r=new KN;r.add(e);var n=[];null===(t=o.get(lL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.mediaSourceId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)})):o.get(lL.track)&&(null===(c=o.get(lL.track))||void 0===c||c.forEach((function(e){var t,r=new KN;r.add(e);var n=[];null===(t=o.get(lL.outboundRtp))||void 0===t||t.forEach((function(t){var i;t.trackId===e.id&&(r.add(t),n.push(t),null===(i=o.get(lL.remoteInboundRtp))||void 0===i||i.forEach((function(e){e.localId===t.id&&r.add(e)})))})),a(n,r),i[e.trackIdentifier]=qk(r)}))),null===(r=o.get(lL.inboundRtp))||void 0===r||r.forEach((function(e){var t,r=new KN;r.add(e),null===(t=o.get(lL.remoteOutboundRtp))||void 0===t||t.forEach((function(t){t.localId===e.id&&r.add(t)})),a([e],r);var n,s=e.trackIdentifier;s||(null===(n=o.get(lL.track))||void 0===n||n.forEach((function(t){t.id===e.trackId&&(s=t.trackIdentifier)})));i[s]=qk(r)})),e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),dL=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==r?void 0:r.id,t instanceof RTCPeerConnection){e.next=3;break}return e.abrupt("return",[]);case 3:if(!FD&&!BD){e.next=10;break}return o=[],e.next=7,t.getStats(r);case 7:return e.sent.forEach((function(e){o.push(e)})),e.abrupt("return",o);case 10:return(!(a=sL.get(t))||Date.now()-a.timestamp>150)&&(a={timestamp:Date.now(),statsPromise:uL(t),extraStatsPromise:cL(t)},sL.set(t,a)),e.next=14,a.statsPromise;case 14:if(s=e.sent,c=(i?s[i]:s.all)||[],n){e.next=21;break}return e.next=19,a.extraStatsPromise;case 19:u=e.sent,c=Om(c).call(c,(i?u.getTrackStats(i):u.all)||[]);case 21:return e.abrupt("return",c);case 22:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),lL=function(e){return e.codec="codec",e.inboundRtp="inbound-rtp",e.outboundRtp="outbound-rtp",e.remoteInboundRtp="remote-inbound-rtp",e.remoteOutboundRtp="remote-outbound-rtp",e.mediaSource="media-source",e.csrc="csrc",e.peerConnection="peer-connection",e.dataChannel="data-channel",e.stream="stream",e.track="track",e.transceiver="transceiver",e.sender="sender",e.receiver="receiver",e.transport="transport",e.sctpTransport="sctp-transport",e.candidatePair="candidate-pair",e.localCandidate="local-candidate",e.remoteCandidate="remote-candidate",e.certificate="certificate",e.iceServer="ice-server",e.mediaPlayout="media-playout",e}(lL||{}),hL=["codec","inbound-rtp","outbound-rtp","remote-inbound-rtp","remote-outbound-rtp","media-source","csrc","peer-connection","data-channel","stream","track","transceiver","sender","receiver","transport","sctp-transport","candidate-pair","local-candidate","remote-candidate","certificate","ice-server"],pL={},vL={},_L={exports:{}},fL=_L.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"]}]};an(fL).forEach((function(e){fL[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))})),function(e){var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,n){var i=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:i&&!r[e.name]&&(r[e.name]={});var o=e.push?{}:i?r[e.name]:r;!function(e,r,n,i){if(i&&!n)r[i]=t(e[1]);else for(var o=0;o<n.length;o+=1)null!=e[o+1]&&(r[n[o]]=t(e[o+1]))}(n.match(e.reg),o,e.names,e.name),e.push&&r[e.push].push(o)},n=_L.exports,i=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t,o={},a=[],s=o;return Hs(t=e.split(/(\r\n|\r|\n)/)).call(t,i).forEach((function(e){var t=e[0],i=km(e).call(e,2);"m"===t&&(a.push({rtp:[],fmtp:[]}),s=a[a.length-1]);for(var o=0;o<(n[t]||[]).length;o+=1){var c=n[t][o];if(c.reg.test(i))return r(c,s,i)}})),o.media=a,o};var o=function(e,r){var n=r.split(/=(.+)/,2);return 2===n.length?e[n[0]]=t(n[1]):1===n.length&&r.length>1&&(e[n[0]]=void 0),e};e.parseParams=function(e){var t;return pb(t=e.split(/;\s?/)).call(t,o,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){var t;return jm(t=e.toString().split(" ")).call(t,Number)},e.parseRemoteCandidates=function(e){for(var r,n=[],i=jm(r=e.split(" ")).call(r,t),o=0;o<i.length;o+=3)n.push({component:i[o],ip:i[o+1],port:i[o+2]});return n},e.parseImageAttributes=function(e){var t;return jm(t=e.split(" ")).call(t,(function(e){var t;return pb(t=e.substring(1,e.length-1).split(",")).call(t,o,{})}))},e.parseSimulcastStreamList=function(e){var r;return jm(r=e.split(";")).call(r,(function(e){var r;return jm(r=e.split(",")).call(r,(function(e){var r,n=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),n=!0),{scid:r,paused:n}}))}))}}(vL);var mL=_L.exports,yL=/%[sdv%]/g,gL=function(e){var t=1,r=arguments,n=r.length;return e.replace(yL,(function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},SL=function(e,t,r){var n=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var i=0;i<t.names.length;i+=1){var o=t.names[i];t.name?n.push(r[t.name][o]):n.push(r[t.names[i]])}else n.push(r[t.name]);return gL.apply(null,n)},bL=["v","o","s","i","u","e","p","c","b","t","r","z","a"],EL=["i","c","b","a"],kL=vL,TL=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||bL,n=t.innerOrder||EL,i=[];return r.forEach((function(t){mL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(SL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(SL(t,r,e))}))}))})),e.media.forEach((function(e){i.push(SL("m",mL.m[0],e)),n.forEach((function(t){mL[t].forEach((function(r){r.name in e&&null!=e[r.name]?i.push(SL(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){i.push(SL(t,r,e))}))}))}))})),i.join("\r\n")+"\r\n"};pL.write=TL,pL.parse=kL.parse,pL.parseParams=kL.parseParams,pL.parseFmtpConfig=kL.parseFmtpConfig,pL.parsePayloads=kL.parsePayloads,pL.parseRemoteCandidates=kL.parseRemoteCandidates,pL.parseImageAttributes=kL.parseImageAttributes,pL.parseSimulcastStreamList=kL.parseSimulcastStreamList;var IL=Xe,RL=Nr,AL=Br,wL=function(e){for(var t=IL(this),r=AL(t),n=arguments.length,i=RL(n>1?arguments[1]:void 0,r),o=n>2?arguments[2]:void 0,a=void 0===o?r:RL(o,r);a>i;)t[i++]=e;return t};Ar({target:"Array",proto:!0},{fill:wL});var CL=Us("Array").fill,xL=ae,OL=CL,DL=Array.prototype,ML=function(e){var t=e.fill;return e===DL||xL(DL,e)&&t===DL.fill?OL:t},PL=new yO("FirefoxHandler",3),NL=Math.pow(2,32),LL="kp34Za0H+aVf862l",UL="o/i14u9pJrxRKAsu";function VL(e){return e>NL-18?(PL.print("generateAllSsrc","reset start id",e),VL(e=e-NL+1e4+18)):{audio:e,audioFec:e+1,audioRtx:e+2,video:e+3,videoFec:e+4,videoRtx:e+5,next:e+18}}var FL=function(e,t,r){var n,i,o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:UL;return[{id:r,attribute:"cname",value:a},{id:r,attribute:"msid",value:Om(n=Om(i="".concat(e," ")).call(i,e,"-")).call(n,t)},{id:r,attribute:"mslabel",value:"".concat(e)},{id:r,attribute:"label",value:Om(o="".concat(e,"-")).call(o,t)}]},BL=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=t.video,o=t.videoRtx,a=t.videoFec,s=[i,o],c=n.cname,u=n.flexfec;u&&s.push(a);var d,l=pb(s).call(s,(function(t,r){return Om(t).call(t,FL(e,"video",r,c))}),[]),h=[{semantics:"FID",ssrcs:Om(r="".concat(i," ")).call(r,o)}];u&&h.push({semantics:"FEC-FR",ssrcs:Om(d="".concat(i," ")).call(d,a)});return{ssrcs:l,ssrcGroups:h}};function jL(e){return e.direction="inactive",e.port=0,delete e.ext,delete e.ssrcs,delete e.ssrcGroups,delete e.simulcast,delete e.simulcast_03,delete e.rids,delete e.extmapAllowMixed,delete e.bundleOnly,e}var HL=function(e,t,r){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=Zd(Zd({},e),{},{media:[]});return n&&(i.invalid=[{value:"realx-exts:rscp"}]),t&&i.media.push(t),r&&i.media.push(r),delete i.groups,delete i.msidSemantic,pL.write(i)};function GL(e){return zL.apply(this,arguments)}function zL(){return(zL=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={},n=t.publicIPs,i=t.certFingerprint,o=t.iceParams,a=t.iceConfig,r.fingerprint={type:"sha-256",hash:i},r.icePwd=o.serverIcePwd,e.next=6,XL(o.serverIceUfrag);case 6:return r.iceUfrag=e.sent,r.candidates=KL(n,a),r.setup="active",r.iceOptions="renomination",e.abrupt("return",r);case 11:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function KL(e,t){if(!Array.isArray(e))return[];var r=0,n=2130706431,i=[];return e.forEach((function(e){var o={component:1,ip:e.ip,type:"host",generation:e.generation};e.udpPorts&&!t.tcpOnly&&e.udpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"udp",port:e,priority:n}))})),e.tcpPorts&&e.tcpPorts.forEach((function(e){i.push(Zd(Zd({},o),{},{foundation:r++,transport:"tcp",port:e,tcptype:"passive",priority:2130705431}))}))})),i}var XL=function(){var e=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new TextEncoder,n=r.encode("PREC"),e.t0=Uint8Array,e.next=5,cD.b64str2ab(t);case 5:return e.t1=e.sent,i=new e.t0(e.t1),o=new Uint8Array(4),crypto.getRandomValues(o),(a=new Uint8Array(2))[0]=0,a[1]=1,s=sD(Uint8Array,n,i,o,a),e.next=15,cD.ab2b64str(s.buffer);case 15:return c=e.sent,e.abrupt("return",c);case 17:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),WL=function(e){return e[e.kICEConfigTypeSrtpDtlsType=0]="kICEConfigTypeSrtpDtlsType",e[e.kICEConfigTypeRenominationType=1]="kICEConfigTypeRenominationType",e[e.kICEConfigTypeTcpType=2]="kICEConfigTypeTcpType",e[e.kICEConfigTypeMultiSendType=3]="kICEConfigTypeMultiSendType",e[e.kICEConfigTypeKcpType=4]="kICEConfigTypeKcpType",e[e.kICEConfigTypeSrtpSdesType=5]="kICEConfigTypeSrtpSdesType",e}(WL||{});function qL(e){var t,r=e.random,n=e.serverUfrag,i=e.serverPwd,o=e.clientPwd,a=e.options,s=(new TextEncoder).encode("WPRE");r||(r=new Uint8Array(4),crypto.getRandomValues(r));var c=DD(n);c.byteLength;var u=PD(DD(o),DD(i).subarray(0,16),DD(n).subarray(0,16));u.byteLength;var d=new Uint8Array(pb(t=an(a)).call(t,(function(e,t){var r=Number(t);return e.push(r),e.push(a[r]?1:0),e}),[]));d.byteLength;var l,h=sD(Uint8Array,s,r,[c.byteLength],c,[u.byteLength],u,d);h.byteLength%3!=0&&(h=sD(Uint8Array,h,ML(l=new Uint8Array(3-h.byteLength%3)).call(l,255)));return[MD(h),MD(sD(Uint8Array,r,c.subarray(0,20)))]}var YL=function(e,t){var r=0;if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){var n,i=$T(e.fmtp);try{for(i.s();!(n=i.n()).done;){var o,a,s,c=n.value;if(mk(o=c.config).call(o,"level-asymmetry-allowed=1")&&mk(a=c.config).call(a,"packetization-mode=1")&&mk(s=c.config).call(s,"profile-level-id=42e0")){r=c.payload;break}}}catch(v){i.e(v)}finally{i.f()}for(var u=0;u<e.rtp.length;u++){var d=e.rtp[u];if("H264"===t){if(d.payload===r){var l;e.rtp.unshift(rk(l=e.rtp).call(l,u,1)[0]);break}}else if(d.codec===t){var h;e.rtp.unshift(rk(h=e.rtp).call(h,u,1)[0]);break}}var p=[];e.rtp.forEach((function(e){return p.push(e.payload)})),e.payloads=p.join(" ")}},JL=new yO("BasicHandler",3),QL=function(e){MI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this)),"_peerConnection",void 0),Jd(tI(i),"_dataChannel",void 0),Jd(tI(i),"_context",void 0),Jd(tI(i),"peerConnectionMode",0),Jd(tI(i),"peerConnectionId",""),Jd(tI(i),"id",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_nextSsrc",Math.floor(Math.random()*NL+1e4)),Jd(tI(i),"_aSendonlyAnswerTpl",void 0),Jd(tI(i),"_vSendonlyAnswerTpl",void 0),Jd(tI(i),"_enableSubFlexfec",!1),Jd(tI(i),"audioTrack4ff",void 0),Jd(tI(i),"setLocalDescription",void 0),Jd(tI(i),"setRemoteDescription",void 0),i.peer=t,i.id=e.id,i._monitor=MO(i.id),i._peerConnection=t.getOriginRTCPeerConnection(),i._dataChannel=t.getOriginRTCDataChannel(),i.setLocalDescription=t.setLocalDescription.bind(t),i.setRemoteDescription=t.setRemoteDescription.bind(t),i._context=e,i.peer.on("ontrack",(function(e){i.emit("ontrack",e)})),i}return Ul(n,[{key:"destroy",value:function(){JL.print("destroy",this.peerConnectionId||""),OI(CI(n.prototype),"removeAllListeners",this).call(this)}},{key:"getTransceivers",value:function(){return this._peerConnection.getTransceivers()}},{key:"_simulcast",value:function(e,t,r,n,i){var o,a,s,c=[];1===e.videoEncodeConfig.length?(c=function(e,t){var r=[];if(t<=1)return r;var n=Math.min(e.width,e.height)/90;return r.push({scaleResolutionDownBy:n,width:Math.floor(e.width/n),height:Math.floor(e.height/n),maxkbps:100,frameRate:10}),t<=2||r.unshift({scaleResolutionDownBy:2,width:Math.floor(e.width/2),height:Math.floor(e.height/2),maxkbps:Math.floor(e.maxKbps/2),frameRate:e.frameRate>=30?Math.floor(e.frameRate/2):e.frameRate}),r}(t,i),JL.print("simulcast() ","simulcastLayers: %o",c)):(c=jm(o=km(a=km(s=e.videoEncodeConfig).call(s,1)).call(a,1-i)).call(o,(function(e){var r=OD(e.width),n=t.width/r;return{width:r,height:Math.floor(t.height/n),scaleResolutionDownBy:n,frameRate:OD(e.frameRate)||15,maxkbps:e.maxKbps||600}})),JL.print("simulcast() ","simulcastLayers2: %o",c));var u=[!0];c.forEach((function(e,t){var i,o={maxBitrate:1e3*e.maxkbps,scaleResolutionDownBy:e.scaleResolutionDownBy,rid:"".concat(t+1),maxFramerate:e.frameRate};null===(i=r.sendEncodings)||void 0===i||i.unshift(o),n.push({width:e.width,height:e.height,framerate:e.frameRate,maxkbps:e.maxkbps,rid:"".concat(t+1)}),u.push(!0)})),this._context&&(this._context.activeSimStreams=u)}},{key:"internalPublish",value:function(e){var t=e.stream,r=e.videoTrack,n=e.audioTrack,i=e.enableSimulcast,o=e.pubAudio,a=e.pubVideo,s={direction:"sendonly",streams:[t]},c={direction:"sendonly",streams:[t]},u=[],d=[];if(Array.isArray(null==e?void 0:e.videoEncodeConfig)&&e.videoEncodeConfig.length){var l=null==r?void 0:r.getTrack(),h=Zd({},wM);if(l){var p=null==l?void 0:l.getSettings();h={width:Math.floor(p.width),height:Math.floor(p.height),frameRate:Math.floor(p.frameRate)}}"number"!=typeof h.frameRate&&(h.frameRate=30);var v=null==e?void 0:e.videoEncodeConfig[0],_={maxBitrate:1e3*v.maxKbps,rid:"0"};if(e.prevBitrate=v.maxKbps,c.sendEncodings=[_],u.push({width:h.width,height:h.height,framerate:h.frameRate,maxkbps:v.maxKbps,rid:"0"}),!FD&&i){var f,m,y=function(e){for(var t=0,r=e.width*e.height,n=0;n<vP.length;n++)if(r>=vP[n].totalPixels){t=n;break}if(0===t)return vP[t].maxLayers;var i=vP[t-1].totalPixels;return(i-r)/(i-vP[t].totalPixels)<.1?vP[t-1].maxLayers:vP[t].maxLayers}(h);if(JL.print("simulcast() ","maxLayers: %o",y),y>1)this._simulcast(e,Zd(Zd({},h),{},{maxKbps:v.maxKbps}),c,u,y),null!==(f=this._context)&&void 0!==f&&null!==(m=f.serverConfig)&&void 0!==m&&m.simulcastOnDemand&&(d=jm(u).call(u,(function(e,t){return Zd(Zd({},e),{},{video_index:t,sub_index:t})})))}}JL.print("publish videoTransceiverInit videoDescriptions","",c,u);var g=null==n?void 0:n.getTrack("preprocessing");(null==n?void 0:n.mixType)!==Dl.PLAYOUT&&null!=n&&n.mixedAudioTrack&&(g=null==n?void 0:n.mixedAudioTrack),g=o&&g?g:"audio";var S=null==r?void 0:r.getTrack("preprocessing");S=a&&S?S:"video";try{this._reportRtcInvokeStatus("Handler.internalPublish",Nm({aTrack:AD(g),vTrack:AD(S),audioTransceiverInit:s,videoTransceiverInit:c}))}catch(eq){}return{semantics:"unified-plan",videoDescriptions:u,subVideoDescriptions:d,audioTransceiverInit:{track:g,init:s},videoTransceiverInit:{track:S,init:c}}}},{key:"updateMaxBitrate",value:function(e){var t,r,n,i;JL.print("updateMaxBitrate()");var o=null===(t=e.videoTrack)||void 0===t?void 0:t.getTrack(),a=e.videoTransceiver;if(o&&e.pubVideo&&a){var s=null===(r=e.videoEncodeConfig)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.maxKbps;if(s){if(s===e.prevBitrate)return void JL.print("updateMaxBitrate()","no change");e.prevBitrate=s}var c=null===(i=a.sender)||void 0===i?void 0:i.getParameters();if(c){var u;c.encodings=null==c||null===(u=c.encodings)||void 0===u?void 0:jm(u).call(u,(function(t){var r,n=+t.rid||0,i=null===(r=e.videoEncodeConfig[n])||void 0===r?void 0:r.maxKbps;return"number"==typeof i&&(t.maxBitrate=1e3*i),t})),null==a||a.sender.setParameters(c);try{this._reportRtcInvokeStatus("Handler.updateScaleResolutionDownBy",Nm(c.encodings))}catch(eq){}}}else JL.print("updateMaxBitrate()","no pub")}},{key:"getStats",value:function(e,t){return dL(this._peerConnection,e,t)}},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineAnswerTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){if("audio"===e.type){if("sendonly"===e.direction){var r,n=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&null!=e&&e.fmtp){var i,o=null==e?void 0:gE(i=e.fmtp).call(i,(function(e){return e.payload===n.payload}));o&&t._context&&(o.config+=";stereo=1;sprop-stereo=1")}t._aSendonlyAnswerTpl=e}}else"video"===e.type&&("sendonly"===e.direction&&(t._vSendonlyAnswerTpl=e),Array.isArray(e.rtp)&&e.rtp.forEach((function(e){var r;null!==(r=e.codec)&&void 0!==r&&mk(r).call(r,"flexfec")&&(t._enableSubFlexfec=!0)})))}))}},{key:"pc",get:function(){return this._peerConnection}},{key:"addBitrateLimit",value:function(e,t){null==e||e.rtp.forEach((function(r){var n,i=r.codec,o=r.payload;if(mk(n=["vp8","h264"]).call(n,i.toLocaleLowerCase())){var a,s,c=gE(a=e.fmtp).call(a,(function(e){return e.payload===o}));if(c)c.config=Om(s=[]).call(s,Jk(c.config.split(";")),["x-google-min-bitrate=100","x-google-start-bitrate=".concat(t)]).join(";");else e.fmtp.push({payload:o,config:"x-google-min-bitrate=100;x-google-start-bitrate=".concat(t)})}}))}},{key:"_report",value:function(e,t,r){var n;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this.peer.getConnectionId(),group_connection_id:this.peer.getGroupConnectionId()}),r)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}]),n}(ZM.exports.EventEmitter),ZL=E,$L=Qy,eU=dy.exports.getWeakData,tU=mp,rU=tr,nU=z,iU=$,oU=Uh,aU=Ye,sU=Zi.set,cU=Zi.getterFor,uU=Po.find,dU=Po.findIndex,lU=ZL([].splice),hU=0,pU=function(e){return e.frozen||(e.frozen=new vU)},vU=function(){this.entries=[]},_U=function(e,t){return uU(e.entries,(function(e){return e[0]===t}))};vU.prototype={get:function(e){var t=_U(this,e);if(t)return t[1]},has:function(e){return!!_U(this,e)},set:function(e,t){var r=_U(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=dU(this.entries,(function(t){return t[0]===e}));return~t&&lU(this.entries,t,1),!!~t}};var fU,mU={getConstructor:function(e,t,r,n){var i=e((function(e,i){tU(e,o),sU(e,{type:t,id:hU++,frozen:void 0}),nU(i)||oU(i,e[n],{that:e,AS_ENTRIES:r})})),o=i.prototype,a=cU(t),s=function(e,t,r){var n=a(e),i=eU(rU(t),!0);return!0===i?pU(n).set(t,r):i[n.id]=r,e};return $L(o,{delete:function(e){var t=a(this);if(!iU(e))return!1;var r=eU(e);return!0===r?pU(t).delete(e):r&&aU(r,t.id)&&delete r[t.id]},has:function(e){var t=a(this);if(!iU(e))return!1;var r=eU(e);return!0===r?pU(t).has(e):r&&aU(r,t.id)}}),$L(o,r?{get:function(e){var t=a(this);if(iU(e)){var r=eU(e);return!0===r?pU(t).get(e):r?r[t.id]:void 0}},set:function(e,t){return s(this,e,t)}}:{add:function(e){return s(this,e,!0)}}),i}},yU=n,gU=E,SU=Qy,bU=dy.exports,EU=Yy,kU=mU,TU=$,IU=my,RU=Zi.enforce,AU=Vi,wU=!yU.ActiveXObject&&"ActiveXObject"in yU,CU=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},xU=EU("WeakMap",CU,kU);if(AU&&wU){fU=kU.getConstructor(CU,"WeakMap",!0),bU.enable();var OU=xU.prototype,DU=gU(OU.delete),MU=gU(OU.has),PU=gU(OU.get),NU=gU(OU.set);SU(OU,{delete:function(e){if(TU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),DU(this,e)||t.frozen.delete(e)}return DU(this,e)},has:function(e){if(TU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),MU(this,e)||t.frozen.has(e)}return MU(this,e)},get:function(e){if(TU(e)&&!IU(e)){var t=RU(this);return t.frozen||(t.frozen=new fU),MU(this,e)?PU(this,e):t.frozen.get(e)}return PU(this,e)},set:function(e,t){if(TU(e)&&!IU(e)){var r=RU(this);r.frozen||(r.frozen=new fU),MU(this,e)?NU(this,e,t):r.frozen.set(e,t)}else NU(this,e,t);return this}})}var LU=ee.WeakMap;Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{emplace:Og}),Ar({target:"WeakMap",stat:!0,forced:!0},{from:bg}),Ar({target:"WeakMap",stat:!0,forced:!0},{of:kg}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{deleteAll:Ag}),Ar({target:"WeakMap",proto:!0,real:!0,forced:!0},{upsert:ZS});var UU=LU,VU=function(e){MI(p,e);var t,r,n,i,o,a,s,c,u,d,l,h=JI(p);function p(){var e,t,r;return Vl(this,p),Jd(tI(r=h.call(this)),"inited",!1),Jd(tI(r),"deviceMap",{audioinput:new $S,audiooutput:new $S,videoinput:new $S}),Jd(tI(r),"checkDeviceChangeTimer",null),Jd(tI(r),"isSupportedPermissionsQuery",!1),Jd(tI(r),"isGrantedMicrophonePermission",!1),Jd(tI(r),"isGrantedCameraPermission",!1),r.isSupportedPermissionsQuery=!LD()&&!(null===(e=navigator)||void 0===e||null===(t=e.permissions)||void 0===t||!t.query),r._handleDeviceChange=r._handleDeviceChange.bind(tI(r)),!LD()&&r.refreshDevices(),r}return Ul(p,[{key:"refreshDevices",value:(l=Rm(Tm().mark((function e(){var t,r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(navigator.mediaDevices){e.next=2;break}return e.abrupt("return");case 2:if(t=void 0,!FD){e.next=12;break}return e.prev=4,e.next=7,navigator.mediaDevices.getUserMedia({audio:!0});case 7:t=e.sent,e.next=12;break;case 10:e.prev=10,e.t0=e.catch(4);case 12:return e.next=14,navigator.mediaDevices.enumerateDevices();case 14:r=e.sent,t&&t.getTracks().forEach((function(e){return e.stop()})),r.forEach((function(e){var t;e.deviceId&&(null===(t=n.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e))})),this.inited||this.initListener(),this.inited=!0;case 19:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return l.apply(this,arguments)})},{key:"initListener",value:(d=Rm(Tm().mark((function e(){var t,r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(null===(t=navigator.mediaDevices)||void 0===t?void 0:t.ondevicechange)&&"function"==typeof(null===(r=navigator.mediaDevices)||void 0===r?void 0:r.addEventListener)?navigator.mediaDevices.addEventListener("devicechange",(function(){o._handleDeviceChange(),setTimeout((function(){o._handleDeviceChange()}),300)})):this.checkDeviceChangeTimer=window.setInterval((function(){o._handleDeviceChange()}),3e3),!this.isSupportedPermissionsQuery){e.next=22;break}return e.prev=2,e.next=5,navigator.permissions.query({name:"microphone"});case 5:n=e.sent,this.isGrantedMicrophonePermission="granted"===n.state,n.addEventListener("change",(function(){o.isGrantedMicrophonePermission="granted"===n.state})),e.next=12;break;case 10:e.prev=10,e.t0=e.catch(2);case 12:return e.prev=12,e.next=15,navigator.permissions.query({name:"camera"});case 15:i=e.sent,this.isGrantedCameraPermission="granted"===i.state,i.addEventListener("change",(function(){o.isGrantedCameraPermission="granted"===i.state})),e.next=22;break;case 20:e.prev=20,e.t1=e.catch(12);case 22:case"end":return e.stop()}}),e,this,[[2,10],[12,20]])}))),function(){return d.apply(this,arguments)})},{key:"_handleDeviceChange",value:(u=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=void 0,!FD){e.next=5;break}return e.next=4,navigator.mediaDevices.getUserMedia({audio:!0});case 4:o=e.sent;case 5:return e.next=7,navigator.mediaDevices.enumerateDevices();case 7:a=e.sent,a=Hs(a).call(a,(function(e){return!!e.deviceId})),o&&o.getTracks().forEach((function(e){return e.stop()})),s=qk(Om(t=[]).call(t,Jk(iR(r=this.deviceMap.audioinput).call(r)),Jk(iR(n=this.deviceMap.videoinput).call(n)),Jk(iR(i=this.deviceMap.audiooutput).call(i)))),(JD||WD)&&!s.length&&a.length&&a.forEach((function(e){var t;null===(t=c.deviceMap[e.kind])||void 0===t||t.set(e.deviceId,e)})),a.forEach((function(e){var t,r,n=c.deviceMap[e.kind].get(e.deviceId);c.deviceMap[e.kind].set(e.deviceId,e),n||(mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"active"}))})),s.forEach((function(e){var t,r;gE(a).call(a,(function(t){return t.deviceId===e.deviceId&&t.kind===e.kind}))||(c.deviceMap[e.kind].delete(e.deviceId),mk(t=e.kind).call(t,"video")?c.emit(Nl.onVideoDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}):mk(r=e.kind).call(r,"audio")&&c.emit(Nl.onAudioDeviceStateChanged,{mediaDeviceInfo:e,deviceState:"inactive"}))}));case 14:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"getUserMedia",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,navigator.mediaDevices.getUserMedia(t);case 2:return r=e.sent,null!=t&&t.audio&&(this.isGrantedMicrophonePermission=!0),null!=t&&t.video&&(this.isGrantedCameraPermission=!0),this.refreshDevices(),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"checkPermissionsByDevices",value:(s=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t={audio:!1,video:!1},navigator.mediaDevices){e.next=3;break}return e.abrupt("return",t);case 3:return e.next=5,navigator.mediaDevices.enumerateDevices();case 5:return r=e.sent,t.audio=Hs(r).call(r,(function(e){return"audioinput"===e.kind&&e.label&&e.deviceId})).length>0,t.video=Hs(r).call(r,(function(e){return"videoinput"===e.kind&&e.label&&e.deviceId})).length>0,e.abrupt("return",t);case 9:case"end":return e.stop()}}),e)}))),function(){return s.apply(this,arguments)})},{key:"getPermissions",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c=this,u=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>0&&void 0!==u[0]?u[0]:{},n=r.audio,i=r.video,o=r.force,n||i||(n=!0,i=!0),a={audio:!1,video:!1},o){e.next=30;break}if(!this.isSupportedPermissionsQuery){e.next=20;break}if(!n||!i){e.next=14;break}if(!this.isGrantedMicrophonePermission||!this.isGrantedCameraPermission){e.next=12;break}return a.audio=!0,a.video=!0,e.abrupt("return",a);case 12:e.next=18;break;case 14:if(!(n&&this.isGrantedMicrophonePermission||i&&this.isGrantedCameraPermission)){e.next=18;break}return a.audio=this.isGrantedMicrophonePermission,a.video=this.isGrantedCameraPermission,e.abrupt("return",a);case 18:case 26:e.next=30;break;case 20:return e.next=22,this.checkPermissionsByDevices();case 22:if(s=e.sent,!n||!i){e.next=28;break}if(!s.audio||!s.video){e.next=26;break}return e.abrupt("return",s);case 28:if(!(n&&s.audio||i&&s.video)){e.next=30;break}return e.abrupt("return",s);case 30:if(null===(t=navigator.mediaDevices)||void 0===t||!t.getUserMedia){e.next=33;break}return e.next=33,navigator.mediaDevices.getUserMedia({audio:n,video:i}).then((function(e){e&&(e.getTracks().forEach((function(e){return e.stop()})),n&&(a.audio=!0,c.isGrantedMicrophonePermission=!0),i&&(a.video=!0,c.isGrantedCameraPermission=!0))})).catch((function(){}));case 33:return e.next=35,this.refreshDevices();case 35:return e.abrupt("return",a);case 36:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"enumerateDevices",value:(o=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions();case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(Om(t=[]).call(t,Jk(iR(r=this.deviceMap.audioinput).call(r)),Jk(iR(n=this.deviceMap.videoinput).call(n)),Jk(iR(i=this.deviceMap.audiooutput).call(i)))));case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"enumerateAudioCaptureDevices",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(iR(t=this.deviceMap.audioinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"enumerateVideoCaptureDevices",value:(n=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({video:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(iR(t=this.deviceMap.videoinput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"enumerateAudioPlaybackDevices",value:(r=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPermissions({audio:!0});case 2:return e.next=4,this.refreshDevices();case 4:return e.abrupt("return",qk(iR(t=this.deviceMap.audiooutput).call(t)));case 5:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getDeviceById",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.enumerateDevices();case 2:return r=e.sent,e.abrupt("return",gE(r).call(r,(function(e){return e.deviceId===t})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}]),p}(tP),FU=new VU;!LD()&&(window.__rtc_dd__=FU);var BU=new yO("InternalEventBus",1),jU=function(e){return e.ON_IOS_INTERRUPTION_START="ON_IOS_INTERRUPTION_START",e.ON_IOS_INTERRUPTION_END="ON_IOS_INTERRUPTION_END",e.ON_IOS_LOCAL_TRACK_MUTE="ON_IOS_LOCAL_TRACK_MUTE",e.ON_IOS_LOCAL_TRACK_UNMUTE="ON_IOS_LOCAL_TRACK_UNMUTE",e}(jU||{}),HU=function(e){MI(r,e);var t=JI(r);function r(){return Vl(this,r),t.apply(this,arguments)}return Ul(r,[{key:"emit",value:function(e){var t,n;BU.print(e);for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];return(t=OI(CI(r.prototype),"emit",this)).call.apply(t,Om(n=[this,e]).call(n,o))}}]),r}(ZM.exports.EventEmitter),GU=new HU,zU=new yO("AudioContext",1),KU=function(){function e(){var t=this;Vl(this,e),Jd(this,"_audioContextInstance",void 0),Jd(this,"_previousState",""),Jd(this,"_currentState",""),Jd(this,"_contextStuckAt",0);var r=0;LD()||setInterval((function(){if(t._audioContextInstance){var e=t._audioContextInstance.currentTime;t._contextStuckAt?t._contextStuckAt!==e&&(t._contextStuckAt=0,zU.print("currentTime resume"),OO("currentTime resume","")):e&&r===e&&(t._contextStuckAt=e,zU.print("currentTime stuck",t._contextStuckAt),t._audioContextInstance.suspend(),t._audioContextInstance.resume(),OO("AudioContext currentTime stuck",t._contextStuckAt)),r=e}}),3e3)}return Ul(e,[{key:"getAudioContextInstance",value:function(){var e=this;if(!this._audioContextInstance){var t=window.AudioContext||window.webkitAudioContext;this._audioContextInstance=new t,this._audioContextInstance.onstatechange=function(){var t,r,n;zU.print("state change",null===(t=e._audioContextInstance)||void 0===t?void 0:t.state),e._previousState=e._currentState,e._currentState=(null===(r=e._audioContextInstance)||void 0===r?void 0:r.state)||"","interrupted"===(null===(n=e._audioContextInstance)||void 0===n?void 0:n.state)&&e._audioContextInstance.resume(),(QD||WD)&&("running"===e._previousState&&"interrupted"===e._currentState&&GU.emit(jU.ON_IOS_INTERRUPTION_START),"interrupted"===e._previousState&&"running"===e._currentState&&GU.emit(jU.ON_IOS_INTERRUPTION_END))}}return this._audioContextInstance}}]),e}(),XU=function(){function e(t){Vl(this,e),Jd(this,"_ctx",void 0),Jd(this,"_analyserNode",void 0),Jd(this,"_audioSource",void 0);var r=WU.getAudioContextInstance();if(t instanceof MediaStreamTrack){var n=new MediaStream;n.addTrack(t),this._audioSource=r.createMediaStreamSource(n)}else this._audioSource=r.createMediaElementSource(t),this._audioSource.connect(r.destination);var i=r.createAnalyser();this._audioSource.connect(i),this._analyserNode=i,this._ctx=r}var t;return Ul(e,[{key:"getAudioLevel",value:function(){var e;"suspended"===(null===(e=this._ctx)||void 0===e?void 0:e.state)&&this._ctx.resume();var t=new Uint8Array(2048);this._analyserNode.getByteTimeDomainData(t);var r=0;t.forEach((function(e){return r=Math.max(r,Math.abs(e-128))}));var n=r/128*255;return n>2?n:0}},{key:"resume",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(t=this._ctx)||void 0===t?void 0:t.resume();case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._audioSource.disconnect(),this._analyserNode.disconnect()}}]),e}(),WU=new KU,qU=function(e){return e[e.CAPTURE=0]="CAPTURE",e[e.PRE_PROCESSING=1]="PRE_PROCESSING",e[e.ENCODE=2]="ENCODE",e[e.TRANSFER=3]="TRANSFER",e[e.POST_PROCESSING=4]="POST_PROCESSING",e[e.DECODE=5]="DECODE",e[e.RENDERING=6]="RENDERING",e}(qU||{}),YU=function(){function e(t){Vl(this,e),Jd(this,"_plugins",new $S),this.id=t}var t;return Ul(e,[{key:"register",value:function(e){var t=this._plugins.get(e.type)||[];if(JR(t).call(t,(function(t){return t.name===e.name}))>-1)throw new Error("Failed to register ".concat(e.name,": name is repeated."));t.push(e),this._plugins.set(e.type,t)}},{key:"getPluginsByType",value:function(e){return this._plugins.get(e)||[]}},{key:"getPluginByName",value:function(e,t){var r;return gE(r=this._plugins.get(e)||[]).call(r,(function(e){return e.name===t}))}},{key:"getPreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=this._plugins.get(1)||[],n=t.getTrack(),i=$T(r),e.prev=3,i.s();case 5:if((o=i.n()).done){e.next=12;break}return a=o.value,e.next=9,a.effect(t,n);case 9:n=e.sent;case 10:e.next=5;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(3),i.e(e.t0);case 17:return e.prev=17,i.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),e,this,[[3,14,17,20]])}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._plugins.forEach((function(e){e.forEach((function(e){return e.destroy()}))})),this._plugins.clear()}}]),e}(),JU=function(e){return e[e.EXTERNAL=0]="EXTERNAL",e[e.INTERNAL=1]="INTERNAL",e}(JU||{}),QU=new yO("VERTC",0),ZU=new UU,$U=function(e){MI(r,e);var t=JI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this)),"sourceType",1),Jd(tI(i),"mediaType",void 0),Jd(tI(i),"_trackId",void 0),Jd(tI(i),"_ac",void 0),Jd(tI(i),"_sourceNode",void 0),Jd(tI(i),"_gainNode",void 0),Jd(tI(i),"_destNode",void 0),Jd(tI(i),"_channelCount",void 0),i._trackId=e,i.mediaType=n,"audio"===n&&oL()&&!RM("SKIP_WEB_AUDIO_IN_TRACK")&&(i._ac=WU.getAudioContextInstance(),i._gainNode=i._ac.createGain(),i._destNode=i._ac.createMediaStreamDestination(),i._gainNode.connect(i._destNode)),i}return Ul(r,[{key:"getId",value:function(){return this._trackId}},{key:"setVolume",value:function(e){this._gainNode&&(this._gainNode.gain.value=e/100)}},{key:"getVolume",value:function(){return this._gainNode?Math.round(100*this._gainNode.gain.value):-1}},{key:"channelCount",get:function(){var e;return null!==(e=this._channelCount)&&void 0!==e?e:0}},{key:"connectAudioTrack",value:function(e){var t;if(this._channelCount=e.getSettings().channelCount,!oL()||RM("SKIP_WEB_AUDIO_IN_TRACK"))return e;this._sourceNode&&(this._sourceNode.mediaStream.getTracks().forEach((function(e){e.stop()})),delete this._sourceNode);var r,n=new MediaStream;(n.addTrack(e),this._sourceNode=null===(t=this._ac)||void 0===t?void 0:t.createMediaStreamSource(n),this._gainNode)&&(null===(r=this._sourceNode)||void 0===r||r.connect(this._gainNode));return this._destNode.stream.getTracks()[0]}},{key:"destroy",value:function(){var e,t,r,n;(null===(e=this._sourceNode)||void 0===e||e.mediaStream.getTracks().forEach((function(e){e.stop()})),13!==nM)&&(null===(n=this._destNode)||void 0===n||n.stream.getTracks().forEach((function(e){e.stop()})));null===(t=this._sourceNode)||void 0===t||t.disconnect(),null===(r=this._gainNode)||void 0===r||r.disconnect(),delete this._sourceNode,delete this._gainNode,delete this._destNode}}]),r}(tP),eV=function(e){MI(n,e);var t,r=JI(n);function n(e,t,i){var o;return Vl(this,n),Jd(tI(o=r.call(this,t,i)),"_mediaTrack",void 0),Jd(tI(o),"_preProcessingTrack",void 0),Jd(tI(o),"_originTrack",void 0),Jd(tI(o),"handleTrackEnded",(function(){o.emit("track-ended",tI(o)),o.close()})),Jd(tI(o),"handleMute",(function(){o.emit("track-mute",tI(o))})),Jd(tI(o),"handleUnmute",(function(){o.emit("track-unmute",tI(o))})),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o._initListeners(),o}return Ul(n,[{key:"getTrack",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"origin";return"origin"===e?this._mediaTrack:this._preProcessingTrack||this._mediaTrack}},{key:"setTrack",value:function(e,t){this._mediaTrack="audio"===this.mediaType?this.connectAudioTrack(e):e,this._originTrack=e,t&&this.generatePreProcessingTrack(t)}},{key:"generatePreProcessingTrack",value:(t=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preProcessingTrack=void 0,e.prev=1,e.next=4,t.getPreProcessingTrack(this);case 4:(r=e.sent)instanceof MediaStreamTrack&&(this._preProcessingTrack=r),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),console.error(e.t0);case 11:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e){return t.apply(this,arguments)})},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){var e,t,r,n,i;return this._mediaTrack.onended=null,this._mediaTrack.onmute=null,this._mediaTrack.onunmute=null,null===(e=this._originTrack)||void 0===e||e.removeEventListener("ended",this.handleTrackEnded),null===(t=this._originTrack)||void 0===t||t.removeEventListener("mute",this.handleMute),null===(r=this._originTrack)||void 0===r||r.removeEventListener("unmute",this.handleUnmute),null===(n=this._preProcessingTrack)||void 0===n||n.stop(),"audio"===this.mediaType?this.destroy():null===(i=this._mediaTrack)||void 0===i?void 0:i.stop()}},{key:"_initListeners",value:function(){this._originTrack instanceof MediaStreamTrack&&(this._originTrack.addEventListener("ended",this.handleTrackEnded),this._originTrack.addEventListener("mute",this.handleMute),this._originTrack.addEventListener("unmute",this.handleUnmute))}}]),n}($U),tV=function(e){MI(r,e);var t=JI(r);function r(e,n,i){var o;return Vl(this,r),Jd(tI(o=t.call(this,n,i)),"_mediaTrack",void 0),Jd(tI(o),"_originTrack",void 0),o._mediaTrack="audio"===o.mediaType?o.connectAudioTrack(e):e,o._originTrack=e,o}return Ul(r,[{key:"getTrack",value:function(){return this._mediaTrack}},{key:"getOrgTrack",value:function(){return this._originTrack}},{key:"close",value:function(){return this.destroy()}}]),r}($U),rV=function(e){MI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"video")),"resolution",void 0),Jd(tI(i),"dummy",!1),i.resolution={width:0,height:0},i}return Ul(n,[{key:"updateVideoCaptureConfig",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.getTrack()){e.next=2;break}return e.abrupt("return");case 2:return QU.print("updateVideoEncoderConfig","update localVideoTrack: ",t),delete(r=Zd({},t)).contentHint,FD&&(r.frameRate={ideal:30,max:30}),e.next=8,this.getTrack().applyConstraints(r);case 8:((n=this.getTrack().getSettings()).width&&n.width!==this.resolution.width||n.height&&n.height!==this.resolution.height)&&(this.resolution={width:n.width,height:n.height},this.emit("resolution-change",this.resolution));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"replaceTrack",value:function(e){this.setTrack(e)}},{key:"setContentHint",value:function(e){var t;this._mediaTrack&&"contentHint"in this._mediaTrack&&mk(t=["text","motion","detail"]).call(t,e)&&(this._mediaTrack.contentHint=e)}}]),n}(eV),nV=function(e){MI(n,e);var t,r=JI(n);function n(e,t){var i;return Vl(this,n),Jd(tI(i=r.call(this,e,t,"audio")),"audioCaptureConfig",void 0),Jd(tI(i),"_audioLevelFetcher",void 0),Jd(tI(i),"mixedAudioTrack",void 0),Jd(tI(i),"mixType",Dl.PLAYOUT_AND_PUBLISH),i}return Ul(n,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new XU(this.getTrack("preprocessing"))),this._audioLevelFetcher.getAudioLevel()}},{key:"updateAudioCaptureConfig",value:(t=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.audioCaptureConfig){e.next=2;break}return e.abrupt("return");case 2:return QU.print("updateAudioCaptureConfig","update localAudioTrack: ",this.audioCaptureConfig),e.next=5,null===(t=this.getOrgTrack())||void 0===t?void 0:t.applyConstraints(this.audioCaptureConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),n}(eV),iV=function(e){MI(r,e);var t=JI(r);function r(e,n){return Vl(this,r),t.call(this,e,n,"video")}return Ul(r)}(tV),oV=function(e){MI(r,e);var t=JI(r);function r(e,n){var i;return Vl(this,r),Jd(tI(i=t.call(this,e,n,"audio")),"_audioLevelFetcher",void 0),i}return Ul(r,[{key:"getAudioLevel",value:function(){return this._audioLevelFetcher||(this._audioLevelFetcher=new XU(this.getOrgTrack())),this._audioLevelFetcher.getAudioLevel()}}]),r}(tV),aV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(nV),sV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),n}return Ul(r)}(rV),cV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(rV),uV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_MAIN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(nV),dV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(rV),lV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),n}return Ul(r)}(nV),hV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(rV),pV=function(e){MI(r,e);var t=JI(r);function r(){var e,n;Vl(this,r);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return Jd(tI(n=t.call.apply(t,Om(e=[this]).call(e,o))),"streamIndex",cl.STREAM_INDEX_SCREEN),Jd(tI(n),"sourceType",0),n}return Ul(r)}(nV);function vV(e,t){return _V.apply(this,arguments)}function _V(){return(_V=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new sV(t,oD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function fV(e,t){return mV.apply(this,arguments)}function mV(){return(mV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new dV(t,oD())).dummy=!0,e.next=4,n.generatePreProcessingTrack(r);case 4:return e.abrupt("return",n);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function yV(e,t){return gV.apply(this,arguments)}function gV(){return(gV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=MO(r.id),e.prev=2,QU.print("createCameraVideoTrack","constraints:",t),null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=aD(),FD&&(t.frameRate={ideal:30,max:30}),e.next=9,FU.getUserMedia({video:t});case 9:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:aD()-s}),e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(2),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_VIDEO_TRACK_FAILED,Om(c="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(c,e.t0.message||"unknown message","."),e.t0);case 17:return u=i.getVideoTracks()[0],ZU.set(u,i),d=new sV(u,oD()),e.next=22,d.generatePreProcessingTrack(r);case 22:return e.abrupt("return",d);case 23:case"end":return e.stop()}}),e,null,[[2,13]])})))).apply(this,arguments)}function SV(e,t){return bV.apply(this,arguments)}function bV(){return(bV=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return QU.print("createMicrophoneAudioTrack","constraints:",t),o=(null==t||null===(n=t.deviceId)||void 0===n?void 0:n.exact)||"default",a=MO(r.id),e.prev=3,null==a||a.report("rtc_video_capture_event",{event_type:"start",media_device_id:o}),s=aD(),(c=r.getPluginByName(qU.PRE_PROCESSING,"RTCAIAnsExtension"))&&(c.isOpen()?(t.autoGainControl=!0,t.noiseSuppression=!1):t.noiseSuppression=!0),e.next=10,FU.getUserMedia({audio:t});case 10:i=e.sent,null==a||a.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:o,reason:"success",elapse:aD()-s}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(3),null==a||a.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:o,error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_AUDIO_TRACK_FAILED,Om(u="throw error from getUserMedia. [".concat(e.t0.name||"unknown name","]: ")).call(u,e.t0.message||"unknown message","."),e.t0);case 18:return d=i.getAudioTracks()[0],ZU.set(d,i),l=new aV(d,oD()),e.next=23,l.generatePreProcessingTrack(r);case 23:return e.abrupt("return",l);case 24:case"end":return e.stop()}}),e,null,[[3,14]])})))).apply(this,arguments)}function EV(){return kV.apply(this,arguments)}function kV(){return kV=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]&&l[0],r=l.length>1?l[1]:void 0,n=l.length>2?l[2]:void 0,QU.print("createScreenTracks","withAudio: %o, constraints: %o",t,n),o=MO(r.id),e.prev=5,null==o||o.report("rtc_video_capture_event",{event_type:"start",media_device_id:"screen"}),a=aD(),e.next=10,navigator.mediaDevices.getDisplayMedia({video:!(n&&(!BD||16!==nM))||n,audio:!!t&&{channelCount:2,noiseSuppression:!1,echoCancellation:!1,autoGainControl:!1}});case 10:i=e.sent,null==o||o.report("rtc_video_capture_event",{event_type:"start_capture_result",media_device_id:"screen",reason:"success",elapse:aD()-a}),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(5),null==o||o.report("rtc_video_capture_event",{event_type:"running_failed",media_device_id:"screen",error_code:e.t0.code,reason:e.t0.name+e.t0.message}),new vA(hA.GET_SCREEN_TRACK_FAILED,"throw error from getDisplayMedia",e.t0);case 18:return s=i.getVideoTracks()[0],c=new dV(s,oD()),e.next=22,c.generatePreProcessingTrack(r);case 22:if(!(u=i.getAudioTracks()[0])){e.next=28;break}return d=new lV(u,oD()),e.next=27,d.generatePreProcessingTrack(r);case 27:return e.abrupt("return",[c,d]);case 28:return e.abrupt("return",[c,void 0]);case 29:case"end":return e.stop()}}),e,null,[[5,14]])}))),kV.apply(this,arguments)}function TV(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oD();return new oV(e,t)}function IV(e,t){return RV.apply(this,arguments)}function RV(){return(RV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new cV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function AV(e,t){return wV.apply(this,arguments)}function wV(){return(wV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new uV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function CV(e,t){return xV.apply(this,arguments)}function xV(){return(xV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new hV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function OV(e,t){return DV.apply(this,arguments)}function DV(){return(DV=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new pV(t,oD()),e.next=3,n.generatePreProcessingTrack(r);case 3:return e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var MV=nV,PV=oV,NV=function(e){return e[e.NONE=0]="NONE",e}(NV||{}),LV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"getNalunits",value:function(t){if(t.length-t.position<4)return[];var r=t.position;return 1===t.getInt32(r)||0===t.getInt16(r)&&1===t.getInt8(r+2)?e.getAnnexbNals(t):e.getAvccNals(t)}},{key:"getAnnexbNals",value:function(t){for(var r=[],n=e.getHeaderPositionAnnexB(t),i=n.pos,o=i;i<t.length-4;){var a,s,c=new Uint8Array(km(a=t.buffer).call(a,i,i+n.headerLength));n.pos===t.position&&t.skip(n.headerLength),o=(n=e.getHeaderPositionAnnexB(t)).pos;var u={header:c,body:new Uint8Array(km(s=t.buffer).call(s,i+c.byteLength,o)),type:-1};e.analyseNal(u),u.type<=9&&0!==u.type&&r.push(u),t.skip(o-t.position),i=o}return r}},{key:"getAvccNals",value:function(t){for(var r=[];t.position<t.length-4;){var n=t.getInt32(t.position);if(!(t.length-t.position>=n))break;var i,o,a=new Uint8Array(km(i=t.buffer).call(i,t.position,t.position+4));t.skip(4);var s=new Uint8Array(km(o=t.buffer).call(o,t.position,t.position+n));t.skip(n);var c={header:a,body:s,type:-1};e.analyseNal(c),c.type<=9&&0!==c.type&&r.push(c)}return r}},{key:"analyseNal",value:function(e){var t=31&e.body[0];switch(e.type=t,t){case 1:e.ndr=!0;break;case 5:e.idr=!0;break;case 6:e.sei=!0;break;case 7:e.sps=!0;break;case 8:e.pps=!0}}},{key:"getHeaderPositionAnnexB",value:function(e){for(var t=e.position,r=0,n=e.length;3!==r&&4!==r&&t<n-4;)0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:1===e.getInt8(t+2)?r=3:t++:t++;return t===n-4&&(0===e.getInt16(t)?1===e.getInt16(t+2)?r=4:t=n:(t++,0===e.getInt16(t)&&1===e.getInt8(t)?r=3:t=n)),{pos:t,headerLength:r}}}]),e}(),UV=function(){function e(t){Vl(this,e),Jd(this,"_position",0),Jd(this,"_dataview",void 0),this._dataview=new DataView(t)}return Ul(e,[{key:"length",get:function(){return this.buffer.byteLength}},{key:"buffer",get:function(){return this._dataview.buffer}},{key:"position",get:function(){return this._position},set:function(e){this._position=e}},{key:"back",value:function(e){this.position-=e}},{key:"getUint8",value:function(e){return this._dataview.getUint8(e)}},{key:"getInt8",value:function(e){return this._dataview.getInt8(e)}},{key:"getInt16",value:function(e){return this._dataview.getInt16(e)}},{key:"getUint16",value:function(e){return this._dataview.getUint16(e)}},{key:"getUint32",value:function(e){return this._dataview.getUint32(e)}},{key:"getInt32",value:function(e){return this._dataview.getInt32(e)}},{key:"skip",value:function(t){for(var r=Math.floor(t/4),n=t%4,i=0;i<r;i++)e.readByte(this,4);n>0&&e.readByte(this,n)}},{key:"readUint8",value:function(){return e.readByte(this,1)}},{key:"readUint16",value:function(){return e.readByte(this,2)}},{key:"readUint24",value:function(){return e.readByte(this,3)}},{key:"readUint32",value:function(){return e.readByte(this,4)}},{key:"readUint64",value:function(){return e.readByte(this,8)}},{key:"readInt8",value:function(){return e.readByte(this,1,!0)}},{key:"readInt16",value:function(){return e.readByte(this,2,!0)}},{key:"readInt32",value:function(){return e.readByte(this,4,!0)}},{key:"writeUint32",value:function(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}}],[{key:"readByte",value:function(e,t,r){var n;switch(t){case 1:n=r?e.getInt8(e.position):e.getUint8(e.position);break;case 2:n=r?e.getInt16(e.position):e.getUint16(e.position);break;case 3:if(r)throw new Error("not supported for readByte 3");n=e.getUint8(e.position)<<16,n|=e.getUint8(e.position+1)<<8,n|=e.getUint8(e.position+2);break;case 4:n=r?e.getInt32(e.position):e.getUint32(e.position);break;case 8:if(r)throw new Error("not supported for readBody 8");n=e.getUint32(e.position)<<32,n|=e.getUint32(e.position+4);break;default:n=""}return e.position+=t,n}}]),e}(),VV=function(e){return e[e.internal=0]="internal",e[e.external=1]="external",e[e.bypass=2]="bypass",e}(VV||{}),FV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,85]),BV=new Uint8Array([109,167,53,190,103,90,72,1,170,89,63,164,194,199,19,84]),jV=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]&&t.push(3),t.push(e[r]);return new Uint8Array(t)};function HV(e){for(var t=[];e>=255;)e-=255,t.push(255);return t.push(e),new Uint8Array(t)}function GV(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0;255===e[t]&&t<e.byteLength;)t++,r+=255;return t<e.byteLength&&(r+=e[t++]),[r,t]}var zV=function(){function e(){Vl(this,e)}return Ul(e,null,[{key:"generateSEI",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint8Array([0,0,0,1]),i=new Uint8Array([6]),o=new Uint8Array([5]),a=r?FV:BV,s=HV(e.byteLength+a.byteLength),c=jV(e);return new Uint8Array(Om(t=[]).call(t,Jk(n),Jk(i),Jk(o),Jk(s),Jk(a),Jk(c),[128]))}},{key:"decodeSeiBody",value:function(e){var t=function(e){for(var t=[],r=0;r<e.length;r++)e[r]<=3&&0===e[r-1]&&0===e[r-2]||t.push(e[r]);return new Uint8Array(t)}(e=km(e).call(e,0,e.length-1));if(!(t.byteLength<2)){var r=0;if(5===t[1]||100===t[1]){var n=eI(GV(t,r+=2),2),i=n[0],o=2,a=(r=n[1])+i;return t.byteLength>=BV.byteLength&&i>=BV.byteLength&&km(t).call(t,r,r+BV.byteLength).toString()===BV.toString()?(r+=BV.byteLength,o=1):t.byteLength>=BV.byteLength&&i>=BV.byteLength&&km(t).call(t,r,r+FV.byteLength).toString()===FV.toString()&&(r+=FV.byteLength,o=0),{type:o,payload:km(t).call(t,r,a)}}}}},{key:"parseInternalSEI",value:function(e){var t=new $S,r=0;if(0===e.type){for(;e.payload.byteLength-r>=2;){var n=eI(GV(e.payload,r),2),i=n[0];r=n[1];var o,a=eI(GV(e.payload,r),2),s=a[0];if(r=a[1],t.get(i)||!(s<=e.payload.byteLength-r))break;t.set(i,km(o=e.payload).call(o,r,r+s)),r+=s}return t}}},{key:"makeInternalSei",value:function(e){var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=eI(t.value,2),o=i[0],a=i[1],s=HV(o),c=HV(a.byteLength);r.push(s,c,a)}}catch(l){n.e(l)}finally{n.f()}var u=pb(r).call(r,(function(e,t){return e+t.byteLength}),0),d=new Uint8Array(u);return pb(r).call(r,(function(e,t){return d.set(t,e),e+t.byteLength}),0),d}}]),e}(),KV=new yO("Stats",3),XV=function(){function e(t){Vl(this,e),Jd(this,"player",void 0),Jd(this,"_timer",void 0),Jd(this,"handler",void 0),Jd(this,"_monitor",void 0),Jd(this,"_destroyed",!1),this._context=t,this._monitor=MO(t.id)}return Ul(e,[{key:"setVar",value:function(e){this.handler=e}},{key:"stopReport",value:function(e){var t;this._timer&&(KV.print("stopReport","invoke"),clearTimeout(this._timer),delete this._timer,LO(this._context.id,"del_media_statistics_timer",Om(t="reason: ".concat(e,", stack: ")).call(t,(new Error).stack),0,this._stream.streamId||""))}},{key:"filterIllegal",value:function(e){var t={};return an(e).forEach((function(r){null===e[r]||void 0===e[r]||Number.isNaN(e[r])||(t[r]=e[r])})),t}},{key:"destroy",value:function(){KV.print("destroy","invoke"),LO(this._context.id,"media_statistics_destroy","".concat((new Error).stack),0,"".concat(this._stream.streamId)),this.stopReport("destroy"),this._destroyed=!0}}]),e}(),WV=function(e){MI(i,e);var t,r,n=JI(i);function i(e,t){var r;return Vl(this,i),(r=n.call(this,e))._stream=t,r}return Ul(i,[{key:"setLocalStreamStatsEvtInterval",value:function(e,t){var r,n,i,o=this;if(!this._timer){KV.print("setLocalStreamStatsEvtInterval","invoke"),this.setVar(t),this._destroyed=!1;var a={audio:{},video:{}},s=this._stream,c=null===(r=s.audioTrack)||void 0===r?void 0:r.getTrack("preprocessing"),u=null===(n=s.videoTrack)||void 0===n?void 0:n.getTrack("preprocessing");this.getAudioStats(c,a,null===(i=s.audioTrack)||void 0===i?void 0:i.getAudioLevel()),this.getVideoStats(u,a);var d=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=s.audioTrack)||void 0===t?void 0:t.getTrack("preprocessing"),c=null===(r=s.videoTrack)||void 0===r?void 0:r.getTrack("preprocessing"),e.next=4,o.getAudioStats(i,a,null===(n=s.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return u=e.sent,e.next=7,o.getVideoStats(c,a);case 7:return d=e.sent,e.abrupt("return",{audioStats:u,videoStats:d,isScreen:s.isScreen});case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),l=function(){var t=Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:r=t.sent,e(r),o._destroyed||(o._timer=setTimeout(l,2e3));case 5:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();this._timer=setTimeout(l,2e3)}}},{key:"getAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s={},c={timestamp:Date.now()},u=this._stream,d=u.streamId,l=u.audioMid,h=u.isScreen,p=u.pubAttributes,v=u.pubAudio,_=u.audioTrack,f={media_type:"audio",is_screen:!!h,direction:"up",stream_id:d,vid:l,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:p.localaudio?"capture_state_on":"capture_state_off",mute_state:v?"mute_state_off":"mute_state_on"},_&&(f.playback_volume=_.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,this.handler.getStats(t);case 9:if((m=e.sent).length){e.next=12;break}return e.abrupt("return",s);case 12:if(m.forEach((function(e){var t=e.type,r=e.packetsSent,n=e.packetsLost,i=e.bytesSent,o=e.clockRate,a=e.roundTripTime,u=e.channels,d=e.audioLevel;e.googRtt;var l=e.mimeType,h=e.availableIncomingBitrate,p=e.availableOutgoingBitrate,v=e.bytesReceived,_=e.nominated,m=e.id,y=e.currentRoundTripTime,g=e.state,S=e.writable,b=e.requestsReceived,E=e.responsesReceived,k=e.requestsSent,T=e.consentRequestsSent,I=e.responsesSent,R=e.jitter,A=e.candidateType,w=e.ip,C=e.address,x=e.networkType,O=e.port,D=e.protocol,M=e.nackCount,P=e.retransmittedBytesSent,N=e.retransmittedPacketsSent,L=e.audioInputLevel,U=e.ssrc,V=e.totalAudioEnergy,F=e.totalSamplesDuration,B=e.mediaType,j=e.fractionLost;"outbound-rtp"===t?(c.packetsSent=r,c.bytesSent=i,f.bytes=i,f.packetsSent=r,f.nackCount=M,f.ssrc=U,f.retransmitted_bytes_sent=P,f.retransmitted_packets_sent=N,c.retransmittedBytesSent=P,c.retransmittedPacketsSent=N):"remote-inbound-rtp"===t?(c.packetsLost=n,f.packetsLost=n,f.net_jitter=1e3*R,s.rtt=1e3*a,f.rtt=s.rtt,s._fractionLost=j||0):"codec"===t?(s.recordSampleRate=o,s.numChannels=u,f.codecName=l):"media-source"===t&&void 0!==d?(f.audio_level=d?-10*JA(Math.pow(d,2)):d,f.volume=255*d,f.total_audio_energy=V,f.totalInputDuration=F):"ssrc"===t&&"audio"===B?f.send_level=L:"candidate-pair"===t?(f.ice_available_incoming_bitrate=h,f.ice_available_outgoing_bitrate=p,f.ice_bytes_received=v,f.ice_bytes_sent=i,f.ice_nominated=+_,f.ice_pair_id=m,f.ice_pair_rtt=y,f.ice_pair_state=g,f.ice_pair_writable=S,f.recv_ping_requests=b,f.recv_ping_responses=E,f.sent_ping_requests_before_first_response=k,f.sent_ping_requests_total=k+(T||0),f.sent_ping_responses=I):"local-candidate"===t?(f.local_candidate_type=A,f.local_ip=w||C,f.local_network_type=x,f.local_port=O,f.protocol=D):"remote-candidate"===t&&(f.remote_candidate_type=A,f.remote_ip=w||C,f.remote_port=O);var H=RM("STATS_SCALLBACK_SUPPORT");aL&&H||"media-source"===t&&(f.send_level=d)})),void 0===f.volume&&void 0!==n&&(f.volume=n,f.audio_level=n?-10*JA(Math.pow(n/255,2)):n),(y=r.audio).timestamp){e.next=18;break}return r.audio=c,e.abrupt("return",this.filterIllegal(s));case 18:return void 0!==c.packetsLost&&(s.audioLossRate=(c.packetsLost-y.packetsLost)/(c.packetsSent-y.packetsSent),s.audioLossRate=Number.isNaN(s.audioLossRate)?0:s.audioLossRate,f.fraction_lost=s.audioLossRate),s.statsInterval=c.timestamp-y.timestamp,f.stats_interval=s.statsInterval,s.sendKBitrate=(c.bytesSent-y.bytesSent||0)/s.statsInterval*8,f.mediaBitratebps=Math.round(1e3*s.sendKBitrate),f.bandwidth=Math.round(f.mediaBitratebps/1024),void 0!==c.retransmittedBytesSent&&(f.retransmitBitratebps=(c.retransmittedBytesSent-y.retransmittedBytesSent||0)/s.statsInterval),r.audio=c,f.vendor_mode=(null===(i=this._stream)||void 0===i?void 0:i.vendorCode)||0,f.pc_session_id=null===(o=this.handler)||void 0===o?void 0:o.peerConnectionId,null===(a=this._monitor)||void 0===a||a.report("rtc_media_statistics",f),s._retransmittedRate=(c.retransmittedPacketsSent-y.retransmittedPacketsSent)/(c.packetsSent-y.packetsSent),void 0===s.audioLossRate&&(s.audioLossRate=s._retransmittedRate,f.fraction_lost=s.audioLossRate),s._fractionLost=Math.max(s._fractionLost,s.audioLossRate),e.abrupt("return",this.filterIllegal(s));case 33:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={},i={timestamp:Date.now(),simulcast:{}},o=this._stream,a=o.streamId,s=o.videoMid,c=o.isScreen,u=o.pubAttributes,d=o.enableSimulcast,l=o.pubVideo,e.t0=Zd,e.t1={media_type:"video",is_screen:!!c,direction:"up",stream_id:a,vid:s,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,capture_state:u.localvideo?"capture_state_on":"capture_state_off",mute_state:l?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,h=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",n);case 11:return h.cap_frame_width=t.getSettings().width,h.cap_frame_height=t.getSettings().height,h.frameRateSent=t.getSettings().frameRate,n.isScreen=c,e.next=17,this.handler.getStats(t);case 17:if((p=e.sent).length){e.next=20;break}return e.abrupt("return",n);case 20:if(v=0,p.forEach((function(e){var t=e.type,o=e.framesEncoded,a=e.packetsLost,s=e.bytesSent,c=e.framesSent,u=e.retransmittedBytesSent,l=e.totalPacketSendDelay,p=e.totalEncodeTime,_=e.firCount,f=e.targetBitrate,m=e.roundTripTime,y=e.mimeType,g=e.frameWidth,S=e.frameHeight,b=e.packetsSent,E=e.googActualEncBitrate,k=e.googAvailableReceiveBandwidth,T=e.googAvailableSendBandwidth,I=e.googAvgEncodeMs,R=e.googBucketDelay,A=e.googEncodeUsagePercent,w=e.googFrameRateInput,C=e.availableIncomingBitrate,x=e.availableOutgoingBitrate,O=e.bytesReceived,D=e.nominated,M=e.id,P=e.currentRoundTripTime,N=e.state,L=e.writable,U=e.candidateType,V=e.ip,F=e.address,B=e.networkType,j=e.port,H=e.nackCount,G=e.pliCount,z=e.protocol,K=e.qpSum,X=e.requestsReceived,W=e.responsesReceived,q=e.googRetransmitBitrate,Y=e.requestsSent,J=e.consentRequestsSent,Q=e.responsesSent,Z=e.ssrc,$=e.googTargetEncBitrate,ee=e.googTransmitBitrate,te=e.retransmittedPacketsSent,re=e.encoderImplementation,ne=e.jitter,ie=e.rid,oe=e.fractionLost,ae=e.googAdaptationChanges,se=e.qualityLimitationReason,ce=e.qualityLimitationDurations,ue=e.googFirsReceived,de=e.googFrameRateSent,le=e.keyFramesEncoded,he=e.scalabilityMode,pe=e.framesPerSecond,ve=e.frames;"outbound-rtp"===t?(d&&(ie?i.simulcast[ie]=e:i.simulcast[v]=e,v++),i.framesEncoded=o||i.framesEncoded||0,h.key_frames_encoded=le||0,i.bytesSent=s||i.bytesSent||0,i.framesSent=c||i.framesSent,h.bytes=s||h.bytes||0,i.packetsSent=b||i.packetsSent||0,h.packetsSent=b||h.packetsSent||0,h.nackCount=H||h.nackCount||0,h.pli_count=G||h.pli_count||0,h.qp_sum=K||h.qp_sum||0,h.ssrc=Z||h.ssrc||0,h.retransmitted_packets_sent=te,i.retransmittedPacketsSent=te,i.retransmittedBytesSent=u,h.encoder_implementation=re,h.qualityLimitationReason=se,h.qualityLimitationDurations=ce,h.scalabilityMode=he,void 0!==g&&((!n.encodedFrameWidth||g>n.encodedFrameWidth)&&(n.encodedFrameWidth=g),(!n.encodedFrameHeight||S>n.encodedFrameHeight)&&(n.encodedFrameHeight=S),h.frame_size_height=S,h.frame_size_width=g)):"track"===t?(n.encodedFrameWidth=g,n.encodedFrameHeight=S,h.frame_size_height=S,h.frame_size_width=g):"remote-inbound-rtp"===t?(i.packetsLost=a,n.rtt=1e3*m,h.rtt=n.rtt,h.jitter=1e3*ne,h.packetsLost=a,n._fractionLost=oe||0):"codec"===t?(n.codecType=y,h.codecName=y):"candidate-pair"===t?(h.ice_available_incoming_bitrate=C,h.ice_available_outgoing_bitrate=x,h.ice_bytes_received=O,h.ice_bytes_sent=s,h.ice_nominated=+D,h.ice_pair_id=M,h.ice_pair_rtt=P,h.ice_pair_state=N,h.ice_pair_writable=L,h.recv_ping_requests=X,h.recv_ping_responses=W,h.sent_ping_requests_before_first_response=Y,h.sent_ping_requests_total=Y+J,h.sent_ping_responses=Q):"local-candidate"===t?(h.local_candidate_type=U,h.local_ip=V||F,h.local_network_type=B,h.local_port=j,h.protocol=z):"remote-candidate"===t?(h.remote_candidate_type=U,h.remote_ip=V||F,h.remote_port=j):"VideoBwe"===t?(h.encBitratebps=E,h.available_receive_bandwidth=k,h.available_send_bandwidth=T,h.bucket_delay=R,h.retransmitBitratebps=q,h.targetEncBitratebps=$,h.transmit_bitrate=ee,n._sendBandWidth=+T):"ssrc"===t&&(h.avg_encode_ms=I,h.encodeUsage=A,h.frame_rate_input=w,h.orignal_input_Framerate=+w,h.ddaptationChanges=ae,h.firsReceived=ue,h.frameRateSent=de);var _e=RM("STATS_SCALLBACK_SUPPORT");if(!aL||!_e){var fe=r.video,me=i.timestamp-fe.timestamp;if("outbound-rtp"===t){var ye=s-fe.bytesSent,ge=u-fe.retransmittedBytesSent;h.encBitratebps=Math.round(8e3*(ye-ge)/me),h.bucket_delay=l/b,h.retransmitBitratebps=Math.round(8e3*ge/me),h.targetEncBitratebps=f,h.transmit_bitrate=Math.round(1e3*(s-fe.bytesSent)*8/me),h.avg_encode_ms=1e3*p/o,h.firsReceived=_+G}else"candidate-pair"===t?(h.available_send_bandwidth=x,n._sendBandWidth=x):"media-source"===t&&(h.frame_rate_input=pe,h.orignal_input_Framerate=+pe,h.frame_input=ve)}})),(_=r.video).timestamp){e.next=26;break}return r.video=i,e.abrupt("return",this.filterIllegal(n));case 26:return n.statsInterval=i.timestamp-_.timestamp,h.stats_interval=n.statsInterval,f=an(i.simulcast),d?(h.sim_enc_width=[],h.sim_enc_height=[],h.sim_enc_bps=[],h.sim_enc_framerate=[],h.sim_enc_key_frames=[],h.sim_rids=[],h.sim_enc_bandwidth=[],h.sim_sent_framerate=[],h.sim_fraction_lost=[],h.sim_keyencoded=[],h.active_sim_streams=(null===(m=this._context)||void 0===m?void 0:m.activeSimStreams)||[],h.sim_retransmittedRate=[],b=!1,jR(f).call(f,(function(e,t){return+e-+t})).forEach((function(e){var t=i.simulcast[e],r=t.frameWidth,o=t.frameHeight,a=t.bytesSent,s=t.framesEncoded,c=t.framesSent,u=t.packetsLost,d=t.packetsSent,l=t.qualityLimitationReason,p=t.qualityLimitationDurations,v=t.qualityLimitationResolutionChanges,f=t.retransmittedPacketsSent,m=t.pliCount,y=t.keyFramesEncoded;void 0!==l&&(h.sim_qualityLimitationReason||(h.sim_qualityLimitationReason=[],h.sim_qualityLimitationDurations=[],h.sim_qualityLimitationResolutionChanges=[]),h.sim_qualityLimitationReason.push(l),h.sim_qualityLimitationDurations.push(p),h.sim_qualityLimitationResolutionChanges.push(v));var g=_.simulcast[e];if(h.sim_enc_width.push(r||0),h.sim_enc_height.push(o||0),h.sim_enc_key_frames.push(y||0),g){var S=(a-g.bytesSent||0)/n.statsInterval;h.sim_enc_bps.push(Math.round(8e3*S)),h.sim_enc_bandwidth.push(Math.round(8e3*S/1024));var E=1e3*(s-g.framesEncoded)/n.statsInterval;h.sim_enc_framerate.push(Math.round(E)),h.sim_rids.push(e);var k=void 0!==c?c-g.framesSent:s-g.framesEncoded,T=1e3*k/n.statsInterval;h.sim_sent_framerate.push(Math.round(T));var I=(u-g.packetsLost)/(d-g.packetsSent);n._retransmittedRate=(f-g.retransmittedPacketsSent)/(d-g.packetsSent),I=Number.isNaN(I)?0:I,h.sim_fraction_lost.push(I),h.sim_keyencoded.push(m-g.pliCount>0),h.sim_retransmittedRate.push(n._retransmittedRate),r>0&&!b&&(n.sentKBitrate=8*S,n.encoderOutputFrameRate=E,n.encodedFrameCount=k,n.sentFrameRate=T,n.videoLossRate=I,b=!0)}})),h.vendor_mode=(null===(y=this._stream)||void 0===y?void 0:y.vendorCode)||0,h.pc_session_id=null===(g=this.handler)||void 0===g?void 0:g.peerConnectionId,null===(S=this._monitor)||void 0===S||S.report("rtc_media_statistics",h)):(n.encodedFrameCount=void 0!==i.framesSent?i.framesSent-_.framesSent:i.framesEncoded-_.framesEncoded,n.sentKBitrate=(i.bytesSent-_.bytesSent||0)/n.statsInterval*8,h.bitrate=Math.round(1e3*n.sentKBitrate),h.bandwidth=Math.round(h.bitrate/1024),n.encoderOutputFrameRate=1e3*(i.framesEncoded-_.framesEncoded)/n.statsInterval,h.frame_rate_encoded=Math.round(n.encoderOutputFrameRate),n.sentFrameRate=1e3*n.encodedFrameCount/n.statsInterval,h.frame_rate_sent=Math.round(n.sentFrameRate),n.videoLossRate=(i.packetsLost-_.packetsLost)/(i.packetsSent-_.packetsSent),n.videoLossRate=Number.isNaN(n.videoLossRate)?0:n.videoLossRate,h.fraction_lost=n.videoLossRate,n._retransmittedRate=(i.retransmittedPacketsSent-_.retransmittedPacketsSent)/(i.packetsSent-_.packetsSent),h.vendor_mode=(null===(E=this._stream)||void 0===E?void 0:E.vendorCode)||0,h.pc_session_id=null===(k=this.handler)||void 0===k?void 0:k.peerConnectionId,null===(T=this._monitor)||void 0===T||T.report("rtc_media_statistics",h)),r.video=i,n._fractionLost=Math.max(n._fractionLost,n.videoLossRate),e.abrupt("return",this.filterIllegal(n));case 33:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})}]),i}(XV),qV=function(e){MI(o,e);var t,r,n,i=JI(o);function o(e,t){var r;return Vl(this,o),Jd(tI(r=i.call(this,e)),"isPaused",void 0),Jd(tI(r),"pauseStart",void 0),Jd(tI(r),"pauseDuration",void 0),Jd(tI(r),"_audioStallCount",void 0),Jd(tI(r),"_setAudioStallCount",void 0),Jd(tI(r),"_audioStallTimer",void 0),Jd(tI(r),"_audioStallInterval",void 0),Jd(tI(r),"_audioStallRatio",void 0),Jd(tI(r),"_videoInWaiting",void 0),r._stream=t,r._videoInWaiting=!1,r.pauseDuration=0,r}return Ul(o,[{key:"setRemoteStreamStatsEvtInterval",value:(n=Rm(Tm().mark((function e(t,r){var n,i,a,s,c,u,d,l,h,p,v,_,f,m,y,g=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._timer){e.next=2;break}return e.abrupt("return");case 2:return KV.print("setRemoteStreamStatsEvtInterval","invoke"),this.setVar(r),this._audioStallInterval=o.audioStallInterval||100,this._audioStallRatio=o.audioStallRatio||.6,s={audio:{},video:{}},this._destroyed=!1,c=this._stream,u=null===(n=c.audioTrack)||void 0===n?void 0:n.getOrgTrack(),d=null===(i=c.videoTrack)||void 0===i?void 0:i.getTrack(),this.getRemoteVideoStats(d,s),e.next=14,this.getRemoteAudioStats(u,s,null===(a=this._stream.audioTrack)||void 0===a?void 0:a.getAudioLevel());case 14:this._stopAudioStallTimer(),l=0,h=0,v=[],_=0,f=aD(),this._setAudioStallCount=function(){if(TM.AUDIO_STALL&&g._audioStallInterval>0&&void 0!==s.audio.concealedSamples){var e=s.audio.concealedSamples,t=s.audio.totalSamplesReceived;f=aD();var r={isStall:!1,counted:!1,diff:0},n=.5*g._audioStallInterval;g._audioStallCount=Rm(Tm().mark((function i(){var o,a,s,u,d,p,m,y,S,b,E,k,T,I,R,A,w,C,x,O;return Tm().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(a=c.hasAudio,s=c.subAudio,u=c.virtual,d=c.virtualOccupy,a&&s){i.next=7;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(p="hasAudio: ".concat(a,", subAudio: ")).call(p,s)}),f=aD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 7:if(!u||d){i.next=13;break}return r.isStall=!1,r.counted=!1,v.push({reason:Om(m="virtual: ".concat(u,", virtualOccupy: ")).call(m,d)}),f=aD(),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 13:return y=null===(o=c.audioTrack)||void 0===o?void 0:o.getOrgTrack(),S=Date.now(),i.next=17,g.handler.getStats(y,!0);case 17:if(b=i.sent,E=Date.now(),k=aD(),!((T=k-f)<n)){i.next=24;break}return v.push({diff:T,start:f,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:Om(I="diff(".concat(T,") < minInterval(")).call(I,n,")")}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 24:if(R=b.length,A=gE(b).call(b,(function(e){return"inbound-rtp"===e.type}))){i.next=29;break}return v.push({diff:T,start:f,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,reason:R?"no inbound-rtp":"no report"}),i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 29:return w=A.concealedSamples,C=A.totalSamplesReceived,O=C-t,(x=w-e)>=0&&O>=0&&x>=g._audioStallRatio*O?(v.push({concealed:x,received:O,diff:T,start:f,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E,is_stall:!0}),r.isStall?(r.counted?h+=T:(h=h+r.diff+T,l++),r.counted=!0):T>=200?(h+=T,l++,r.counted=!0):(r.counted=!1,r.diff=T),r.isStall=!0):(v.push({concealed:x,received:O,diff:T,start:f,end:k,get_stats_cost:E-S,get_stats_start:S,get_stats_end:E}),r.isStall=!1,r.counted=!1),e=w,t=C,f=k,_++,i.abrupt("return",{stall_count:l,stall_duration:h,stall_list:v,stats_count:_});case 38:case"end":return i.stop()}}),i)}))),p=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g._audioStallCount&&g._setAudioStallCount&&g._setAudioStallCount(),!g._audioStallCount){e.next=6;break}return e.next=4,g._audioStallCount();case 4:g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)}},this._setAudioStallCount(),m=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,u;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=null===(t=c.audioTrack)||void 0===t?void 0:t.getOrgTrack(),o=null===(r=c.videoTrack)||void 0===r?void 0:r.getTrack(),e.next=4,g.getRemoteAudioStats(i,s,null===(n=g._stream.audioTrack)||void 0===n?void 0:n.getAudioLevel());case 4:return a=e.sent,l=0,h=0,v=[],_=0,e.next=11,g.getRemoteVideoStats(o,s);case 11:return u=e.sent,e.abrupt("return",{audioStats:a,videoStats:u,isScreen:c.isScreen,userId:c.userId,streamId:c.streamId});case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Rm(Tm().mark((function e(){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,m();case 2:r=e.sent,t(r),p&&(f=aD(),g._audioStallTimer&&clearTimeout(g._audioStallTimer),g._audioStallTimer=setTimeout(p,g._audioStallInterval)),g._timer&&clearTimeout(g._timer),g._destroyed||(g._timer=setTimeout(y,2e3));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),this._timer&&clearTimeout(this._timer),this._timer=setTimeout(y,2e3);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"_stopAudioStallTimer",value:function(){clearTimeout(this._audioStallTimer),this._audioStallCount=void 0,this._setAudioStallCount=void 0,this.pauseDuration=0}},{key:"unsubscribe",value:function(){KV.print("unsubscribe","invoke"),OI(CI(o.prototype),"stopReport",this).call(this,"unsubscribe"),this._stopAudioStallTimer(),this._videoInWaiting=!1}},{key:"getRemoteAudioStats",value:(r=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(d={},l={},h=this._stream,p=h.streamId,v=h.userId,_=h.isScreen,f=h.audioMid,m=h.subMediaType,y=h._attributes,g=h.virtual,S=h.audioTrack,b={media_type:"audio",is_screen:!!_,direction:"down",stream_id:p,stream_user_id:v,vid:f,audio_mux:g,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:kD(m)?"mute_state_off":"mute_state_on",remote_user_capture_state:y.localaudio?"capture_state_on":"capture_state_off",remote_user_mute_state:y.localaudio&&y.audiostream?"mute_state_off":"mute_state_on"},S&&(b.playback_volume=S.getVolume()),t&&this.handler){e.next=7;break}return e.abrupt("return",d);case 7:return e.next=9,this.handler.getStats(t);case 9:if((E=e.sent).length){e.next=12;break}return e.abrupt("return",d);case 12:if(E.forEach((function(e){var t=e.type,r=e.packetsLost,i=e.packetsReceived,o=e.bytesReceived,a=e.jitterBufferDelay,s=e.jitterBufferEmittedCount,c=e.clockRate,u=e.channels,h=e.totalSamplesReceived,v=e.concealedSamples,_=e.silentConcealedSamples,f=e.concealmentEvents,m=e.totalRoundTripTime,y=e.packetsDiscarded,g=e.state,S=e.currentRoundTripTime,E=e.audioLevel,k=e.totalAudioEnergy,T=e.totalSamplesDuration,I=e.mimeType,R=e.googDecodingNormal,A=e.googDecodingMuted,w=e.availableIncomingBitrate,C=e.availableOutgoingBitrate,O=e.bytesSent,D=e.nominated,M=e.id,P=e.writable,N=e.jitter,L=e.candidateType,U=e.ip,V=e.address,F=e.networkType,B=e.port,j=e.protocol,H=e.audioOutputLevel,G=e.requestsReceived,z=e.responsesReceived,K=e.requestsSent,X=e.consentRequestsSent,W=e.responsesSent,q=e.ssrc;e.kind;var Y=e.nackCount,J=e.lastPacketReceivedTimestamp,Q=e.concealmentevents,Z=e.fecPacketsReceived;if("inbound-rtp"===t)l.packetsLost=r,l.packetsReceived=i,b.packetsLost=r,b.packetsReceived=i,b.packetsDiscarded=y,b.nackCount=Y,b.lastPacketReceivedTimestamp=J,b.concealmentevents=Q,l.bytesReceived=o,void 0!==a&&(d.jitterBufferDelay=a/s*1e3,b.average_jitter_buffer_delay_ms=d.jitterBufferDelay),void 0!==h&&(l.totalSamplesReceived=h,d.concealedSamples=v,l.concealedSamples=v,l.silentConcealedSamples=_,b.concealedSamples=v,d.concealmentEvents=f,b.totalSamplesReceived=h),void 0!==Z&&(b.fec_packets_received=Z,l.fecPacketsReceived=Z),b.jitter=1e3*N,b.ssrc=q,void 0!==E&&0!==E?(b.audio_level=E?-10*JA(Math.pow(E,2)):E,b.volume=255*E):(b.volume=null!=n?n:255*E,b.audio_level=n?-10*JA(Math.pow(n/255,2)):n),void 0!==k&&(b.total_audio_energy=k),void 0!==T&&(b.totalAudioDuration=T);else if("codec"===t)d.recordSampleRate=c,u&&(d.numChannels=u),b.codecName=I;else if("candidate-pair"===t){var $,ee,te;b.ice_available_incoming_bitrate=w,b.ice_available_outgoing_bitrate=C,b.ice_bytes_received=o,b.ice_bytes_sent=O,b.ice_nominated=+D,b.ice_pair_id=M,b.ice_pair_rtt=S,b.rtt=1e3*S,b.rtt&&null!==($=x._context)&&void 0!==$&&null!==(ee=$.streamRTT)&&void 0!==ee&&null!==(te=ee[p])&&void 0!==te&&te.audio&&(b.total_rtt_ms=Math.round(b.rtt+x._context.streamRTT[p].audio)),b.ice_pair_state=g,b.ice_pair_writable=P,b.recv_ping_requests=G,b.recv_ping_responses=z,b.sent_ping_requests_before_first_response=K,b.sent_ping_requests_total=K+(X||0),b.sent_ping_responses=W,"succeeded"===g&&(d.rtt=1e3*S,d.total_rtt=1e3*m)}else"track"===t&&void 0!==E?(0===E&&0!==n?(b.volume=n,b.audio_level=n?-10*JA(Math.pow(n/255,2)):n):(b.audio_level=E?-10*JA(Math.pow(E,2)):E,b.volume=255*E),b.total_audio_energy=k,b.totalAudioDuration=T):"ssrc"===t?(b.decodingNormal=R,b.recvAudioLevel=H,b.decodingMuted=A):"local-candidate"===t?(b.local_candidate_type=L,b.local_ip=U||V,b.local_network_type=F,b.local_port=B,b.protocol=j):"remote-candidate"===t&&(b.remote_candidate_type=L,b.remote_ip=U||V,b.remote_port=B)})),(k=r.audio).timestamp){e.next=18;break}return l.timestamp=Date.now(),r.audio=l,e.abrupt("return",this.filterIllegal(d));case 18:if(T={},void 0!==l.concealedSamples&&(b.interval_concealed_samples=l.concealedSamples-k.concealedSamples,b.interval_samples_received=l.totalSamplesReceived-k.totalSamplesReceived,b.interval_silent_concealed_samples=l.silentConcealedSamples-k.silentConcealedSamples),!(this._audioStallInterval>0&&void 0!==k.concealedSamples)){e.next=36;break}if(!this._audioStallCount&&this._setAudioStallCount&&this._setAudioStallCount(),clearTimeout(this._audioStallTimer),!this._audioStallCount){e.next=36;break}return e.next=26,this._audioStallCount();case 26:I=e.sent,R=I.stall_count,A=I.stall_duration,w=I.stall_list,C=I.stats_count,T.stall_list=w,T.stats_count=C,b.concealedSamples===b.interval_concealed_samples&&b.totalSamplesReceived===b.interval_samples_received?(b.stall_count=0,b.stall_duration=0):(b.stall_count=R,b.stall_duration=A),d.stallCount=b.stall_count,d.stallDuration=b.stall_duration;case 36:return l.timestamp=Date.now(),d.audioLossRate=(l.packetsLost-k.packetsLost)/(l.packetsReceived-k.packetsReceived+(l.packetsLost-k.packetsLost)),d.audioLossRate=Number.isNaN(d.audioLossRate)?0:d.audioLossRate,b.fraction_lost=d.audioLossRate,d.statsInterval=l.timestamp-k.timestamp,b.stats_interval=d.statsInterval,d.receivedKBitrate=(l.bytesReceived-k.bytesReceived||0)/d.statsInterval*8,b.bandwidth=Math.round(1e3*d.receivedKBitrate/1024),void 0!==l.concealedSamples&&(d.receivedSampleRate=1e3*b.interval_samples_received/d.statsInterval),void 0!==l.fecPacketsReceived&&(b.fecBitratebps=(l.fecPacketsReceived-k.fecPacketsReceived||0)/d.statsInterval),b.average_jitter_buffer_delay_ms&&b.total_rtt_ms&&(d.e2eDelay=b.average_jitter_buffer_delay_ms+b.total_rtt_ms),null!==(i=this._context)&&void 0!==i&&null!==(o=i.streamRTT)&&void 0!==o&&null!==(a=o[p])&&void 0!==a&&a.audio&&(d.totalRtt=(b.rtt?b.rtt:0)+this._context.streamRTT[p].audio),r.audio=l,b.vendor_mode=(null===(s=this._stream)||void 0===s?void 0:s.vendorCode)||0,b.pc_session_id=null===(c=this.handler)||void 0===c?void 0:c.peerConnectionId,null===(u=this._monitor)||void 0===u||u.report("rtc_media_statistics",b,T),e.abrupt("return",this.filterIllegal(d));case 53:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"getRemoteVideoStats",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u={},d={timestamp:Date.now()},l=this._stream,h=l.streamId,p=l.userId,v=l.isScreen,_=l.subMediaType,f=l._attributes,e.t0=Zd,e.t1={media_type:"video",is_screen:!!v,direction:"down",stream_id:h,stream_user_id:p,vid:this._stream.videoMid,connection_status:navigator.onLine,track_enabled:null==t?void 0:t.enabled,mute_state:TD(_)?"mute_state_off":"mute_state_on",remote_user_capture_state:f.localvideo?"capture_state_on":"capture_state_off",remote_user_mute_state:f.localvideo&&f.videostream?"mute_state_off":"mute_state_on"},e.next=7,this._stream.requestVideoFrameCallback();case 7:if(e.t2=e.sent,m=(0,e.t0)(e.t1,e.t2),t&&this.handler){e.next=11;break}return e.abrupt("return",u);case 11:return u.isScreen=v,e.next=14,this.handler.getStats(t);case 14:if((y=e.sent).length){e.next=17;break}return e.abrupt("return",u);case 17:if(y.forEach((function(e){var t=e.type,r=e.frameHeight,n=e.frameWidth,i=e.packetsLost,o=e.packetsReceived,a=e.bytesReceived,s=e.framesDecoded,c=e.jitterBufferDelay,l=e.jitterBufferEmittedCount,p=e.mimeType,v=e.firCount,_=e.availableIncomingBitrate,f=e.availableOutgoingBitrate,y=e.bytesSent,g=e.nominated,S=e.id,E=e.currentRoundTripTime,k=e.state,T=e.writable,I=e.candidateType,R=e.ip,A=e.address,w=e.networkType,C=e.port,x=e.nackCount,O=e.pliCount,D=e.protocol,M=e.requestsReceived,P=e.responsesReceived,N=e.requestsSent,L=e.consentRequestsSent,U=e.responsesSent,V=e.ssrc,F=e.jitter,B=e.framesReceived,j=e.keyFramesDecoded,H=e.totalDecodeTime,G=e.decoderImplementation,z=e.lastPacketReceivedTimestamp,K=e.framesDropped;if("inbound-rtp"===t)d.packetsLost=i,m.packetsLost=i,d.packetsReceived=o,m.packetsReceived=o,d.bytesReceived=a,m.bytes=a,d.framesDecoded=s,d.totalDecodeTime=H,void 0!==c&&(d.jitterBufferDelay=c/l*1e3,m.average_jitter_buffer_delay_ms=d.jitterBufferDelay),m.fir_count=v,m.nackCount=x,d.nackCount=x,m.pli_count=O,m.ssrc=V,m.framesDropped=K,m.jitter=1e3*F,m.framesReceived=B,d.framesReceived=B,m.framesDecoded=s,m.key_frames_decoded=j,m.decoder_name=G,m.last_packet_received_timestamp=z,void 0!==n&&(u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r);else if("track"===t&&void 0!==n)u.width=n,m.frame_size_width=n,u.height=r,m.frame_size_height=r,void 0!==B&&(m.framesReceived=B,d.framesReceived=B);else if("codec"===t)m.codecName=p;else if("candidate-pair"===t){var X,W,q;m.ice_available_incoming_bitrate=_,m.ice_available_outgoing_bitrate=f,m.ice_bytes_received=a,m.ice_bytes_sent=y,m.ice_nominated=+g,m.ice_pair_id=S,m.ice_pair_rtt=E,m.rtt=1e3*E,m.rtt&&null!==(X=b._context)&&void 0!==X&&null!==(W=X.streamRTT)&&void 0!==W&&null!==(q=W[h])&&void 0!==q&&q.video&&(m.total_rtt_ms=Math.round(m.rtt+b._context.streamRTT[h].video)),u.rtt=m.rtt,m.ice_pair_state=k,m.ice_pair_writable=T,m.recv_ping_requests=M,m.recv_ping_responses=P,m.sent_ping_requests_before_first_response=N,m.sent_ping_requests_total=N+(L||0),m.sent_ping_responses=U}else"local-candidate"===t?(m.local_candidate_type=I,m.local_ip=R||A,m.local_network_type=w,m.local_port=C,m.protocol=D):"remote-candidate"===t&&(m.remote_candidate_type=I,m.remote_ip=R||A,m.remote_port=C)})),(g=r.video).timestamp){e.next=22;break}return r.video=d,e.abrupt("return",this.filterIllegal(u));case 22:return u.videoLossRate=(d.packetsLost-g.packetsLost)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),g.totalDecodeTime&&g.framesDecoded&&d.framesDecoded!==g.framesDecoded&&(m.decode_elapse_per_frame=+((d.totalDecodeTime-g.totalDecodeTime)/(d.framesDecoded-g.framesDecoded)*1e3).toFixed(2)),u._retransmittedRate=(d.nackCount-g.nackCount)/(d.packetsReceived-g.packetsReceived+(d.packetsLost-g.packetsLost)),u.videoLossRate=Number.isNaN(u.videoLossRate)?0:u.videoLossRate,m.fraction_lost=u.videoLossRate,u.statsInterval=d.timestamp-g.timestamp,m.stats_interval=u.statsInterval,u.receivedKBitrate=(d.bytesReceived-g.bytesReceived||0)/u.statsInterval*8,m.bitrate=Math.round(1e3*u.receivedKBitrate),m.bandwidth=Math.round(m.bitrate/1024),u.decoderOutputFrameRate=1e3*(d.framesDecoded-g.framesDecoded)/u.statsInterval,u.receivedFrameRate=1e3*(d.framesReceived-g.framesReceived)/u.statsInterval,m.frame_rate_decoded=Math.round(u.decoderOutputFrameRate),m.frame_rate_received=Math.round(u.receivedFrameRate),m.average_jitter_buffer_delay_ms&&m.total_rtt_ms&&(u.e2eDelay=m.average_jitter_buffer_delay_ms+m.total_rtt_ms),null!==(n=this._context)&&void 0!==n&&null!==(i=n.streamRTT)&&void 0!==i&&null!==(o=i[h])&&void 0!==o&&o.video&&(u.totalRtt=(m.rtt?m.rtt:0)+this._context.streamRTT[h].video),r.video=d,this.processStall(this._stream,m,u,v),this.isPaused?(S=d.timestamp-(this.pauseStart||0),m.pause_duration=this.pauseDuration+(S>500?S:0),this.pauseStart=d.timestamp):m.pause_duration=this.pauseDuration,m.pause_duration=Math.min(m.stall_duration||m.stuck_length||0,m.pause_duration),this.pauseDuration=0,m.vendor_mode=(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,m.pc_session_id=null===(s=this.handler)||void 0===s?void 0:s.peerConnectionId,null===(c=this._monitor)||void 0===c||c.report("rtc_media_statistics",m),e.abrupt("return",this.filterIllegal(u));case 47:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"processStall",value:function(e,t,r,n){var i=0,o=0,a=0;if(e.recordedVideoFrames&&this.player&&this.player.played){e.recordedVideoFrames.forEach((function(e){e.isStall&&(i+=e.stallCount,o+=e.stallDuration),a=e.playTime})),e.recordedVideoFrames.length||(o=2e3,i=this._videoInWaiting?0:1,this._videoInWaiting=!0);var s=e.recordedVideoFrames.pop();s&&(s.isStall?this._videoInWaiting=!0:this._videoInWaiting=!1),e.recordedVideoFrames=[]}t.stall_count=i,n?(t.stuck_length=Math.min(o,t.stats_interval),t.stall_duration=void 0):(t.stall_duration=Math.min(o,t.stats_interval),t.stuck_length=void 0),t.play_time=a,r.stallCount=i,r.stallDuration=o}},{key:"destroy",value:function(){OI(CI(o.prototype),"destroy",this).call(this),OI(CI(o.prototype),"stopReport",this).call(this,"destroy"),this._stopAudioStallTimer(),this._videoInWaiting=!1}}],[{key:"audioStallConfig",set:function(e){o.audioStallInterval=((null==e?void 0:e.audio_stall_interval)||200)/2,o.audioStallRatio=null==e?void 0:e.audio_stall_ratio}}]),o}(XV);Jd(qV,"audioStallInterval",void 0),Jd(qV,"audioStallRatio",void 0);var YV,JV,QV=new yO("Stream",0),ZV=function(e){MI(r,e);var t=JI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this)),"videoDom",void 0),Jd(tI(n),"audioMid",void 0),Jd(tI(n),"videoMid",void 0),Jd(tI(n),"videoTransceiver",void 0),Jd(tI(n),"audioTransceiver",void 0),Jd(tI(n),"vendorHandler",void 0),Jd(tI(n),"vendorCode",0),Jd(tI(n),"engineId",void 0),n._ctx=e,n.engineId=e.id,n}return Ul(r,[{key:"requestVideoFrameCallback",value:function(){var e=this;return new Yf((function(t){var r,n=null===(r=e.videoDom)||void 0===r?void 0:r.requestVideoFrameCallback;if("function"==typeof n){var i=function(e,r){var n={};an(r).forEach((function(e){var t=e.replace(/[a-z]{1}[A-Z]{1}/g,(function(e){var t;return Om(t="".concat(e[0],"_")).call(t,e[1].toLowerCase())}));n["video_".concat(t)]=r[e]})),clearInterval(o),t(n)};n.call(e.videoDom,i);var o=setTimeout((function(){var r;null===(r=e.videoDom)||void 0===r||r.cancelVideoFrameCallback(i),t({})}),500)}else t({})}))}},{key:"stopReport",value:function(e){this.statsReport.stopReport(e)}},{key:"destroy",value:function(){var e,t;delete this.audioMid,delete this.videoMid,this.statsReport.destroy(),null===(e=this.observer)||void 0===e||e.reset(),delete this.videoTransceiver,delete this.audioTransceiver,null===(t=this.vendorHandler)||void 0===t||t.destroy(),this.vendorCode=0,delete this.vendorHandler}}]),r}(tP),$V=function(e){return e[e.INIT=0]="INIT",e[e.SUB_ING=1]="SUB_ING",e[e.SUB_ED=2]="SUB_ED",e}($V||{}),eF=function(e){MI(r,e);var t=JI(r);function r(e){var n;return Vl(this,r),Jd(tI(n=t.call(this,e)),"isScreen",!1),Jd(tI(n),"stream",void 0),Jd(tI(n),"streamId",void 0),Jd(tI(n),"seiList",[]),Jd(tI(n),"videoTrack",void 0),Jd(tI(n),"audioTrack",void 0),Jd(tI(n),"videoEncodeConfig",[wM]),Jd(tI(n),"subVideoDescriptions",[]),Jd(tI(n),"enableSimulcast",!1),Jd(tI(n),"observer",void 0),Jd(tI(n),"statsReport",void 0),Jd(tI(n),"prevBitrate",0),Jd(tI(n),"pubAudio",!1),Jd(tI(n),"pubVideo",!1),Jd(tI(n),"pubAttributes",void 0),Jd(tI(n),"pcSessionId",void 0),n.stream=new MediaStream,n.pubAttributes={localaudio:!1,localvideo:!1,videostream:!1,audiostream:!1,extvideo:!1,extaudio:!1},n.statsReport=new WV(e,tI(n)),n}return Ul(r,[{key:"audioHasCapture",get:function(){return this.pubAttributes.localaudio}},{key:"audioHasPublish",get:function(){return this.pubAttributes.audiostream}},{key:"videoHasCapture",get:function(){return this.pubAttributes.localvideo}},{key:"videoHasPublish",get:function(){return this.pubAttributes.videostream}},{key:"hasPublished",get:function(){return!!this.audioMid&&!!this.videoMid}},{key:"isEmptyStream",get:function(){return!this.audioTrack&&!this.videoTrack}},{key:"initStreamId",get:function(){return this.stream.id}},{key:"startReport",value:function(e,t){this.statsReport.setLocalStreamStatsEvtInterval(e,t)}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.sender){var t=this.videoTransceiver.sender;if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add&&iL()){var r=t.createEncodedStreams(),n=r.readable,i=r.writable,o=new TransformStream({transform:function(t,r){var n=e.seiList[0];if(n){var i,o=zV.generateSEI(n.content),a=new Uint8Array(o.byteLength+t.data.byteLength);if(0===n.repeatCount)rk(i=e.seiList).call(i,0,1);n.repeatCount--,a.set(new Uint8Array(t.data)),a.set(o,t.data.byteLength),t.data=a.buffer,r.enqueue(t)}else r.enqueue(t)}});n.pipeThrough(o).pipeTo(i)}}else QV.print("no sender found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.sender)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var e=this.audioTransceiver.sender.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else QV.print("initAudioEncodedTransform","legacy EncodedTransform is not supported");else QV.print("no sender found when trying to bind encodedTransform")}},{key:"clean",value:function(){LO(this.engineId,"localstream_clean","".concat((new Error).stack),0,this.streamId||""),OI(CI(r.prototype),"destroy",this).call(this),this.prevBitrate=0,this.subVideoDescriptions=[]}},{key:"switchTrackEnableState",value:function(e,t){var r,n;"audio"===e?n=this.audioTrack:"video"===e&&(n=this.videoTrack);var i=null===(r=n)||void 0===r?void 0:r.getTrack();return!(!i||(null==i?void 0:i.enabled)===t)&&(i.enabled=t,!0)}}]),r}(ZV),tF=function(e){MI(r,e);var t=JI(r);function r(e,n,i,o,a,s){var c;return Vl(this,r),Jd(tI(c=t.call(this,e)),"streamId",void 0),Jd(tI(c),"userId",void 0),Jd(tI(c),"isScreen",void 0),Jd(tI(c),"isPublic",void 0),Jd(tI(c),"hasVideo",void 0),Jd(tI(c),"hasAudio",void 0),Jd(tI(c),"_attributes",void 0),Jd(tI(c),"streamState",void 0),Jd(tI(c),"observer",void 0),Jd(tI(c),"statsReport",void 0),Jd(tI(c),"subVideo",void 0),Jd(tI(c),"subAudio",void 0),Jd(tI(c),"subMediaType",void 0),Jd(tI(c),"subLayer",void 0),Jd(tI(c),"_sequenceId",void 0),Jd(tI(c),"stream",void 0),Jd(tI(c),"videoTrack",void 0),Jd(tI(c),"audioTrack",void 0),Jd(tI(c),"recordedVideoFrames",void 0),Jd(tI(c),"stillExist",void 0),Jd(tI(c),"originalMediaType",void 0),Jd(tI(c),"priority",void 0),Jd(tI(c),"originalStreamIndex",0),Jd(tI(c),"virtual",void 0),Jd(tI(c),"pcSessionId",void 0),Jd(tI(c),"_virtualOccupy",void 0),c.virtual=!1,c._virtualOccupy=!1,c.userId=n,c.isScreen=o,c.isPublic=a,c.streamId=i,c.hasAudio=s.audiostream&&s.localaudio,c.hasVideo=s.videostream&&s.localvideo,c._attributes=s,c.vendorCode=(null==s?void 0:s.vendorCode)||0,c.subVideo=!1,c.subAudio=!1,c._sequenceId=0,c.subMediaType=NV.NONE,c.subLayer={spatialLayer:0,spatialSubLayer:-1},c.streamState=0,c.statsReport=new qV(e,tI(c)),c.enableVendorMode&&(c.pcSessionId=ow()),c}return Ul(r,[{key:"vendor",get:function(){return this._attributes.vendorCode}},{key:"audioHasCapture",get:function(){return this._attributes.localaudio}},{key:"audioHasPublish",get:function(){return this._attributes.audiostream}},{key:"videoHasCapture",get:function(){return this._attributes.localvideo}},{key:"videoHasPublish",get:function(){return this._attributes.videostream}},{key:"sequenceId",get:function(){return this._sequenceId||-1},set:function(e){"number"==typeof e&&(this._sequenceId=e)}},{key:"enableVendorMode",get:function(){return"number"==typeof this.attributes.vendorCode&&0!==this.attributes.vendorCode}},{key:"hasSubscribed",get:function(){return 2===this.streamState}},{key:"attributes",get:function(){return this._attributes},set:function(e){this.hasVideo=e.localvideo&&e.videostream,this.hasAudio=e.localaudio&&e.audiostream,this._attributes=e,this.vendorCode=e.vendorCode||0}},{key:"virtualOccupy",get:function(){return this._virtualOccupy},set:function(e){var t;if(this._virtualOccupy&&!e)null===(t=this.observer)||void 0===t||t.setPushTrack(!1);else if(!this._virtualOccupy&&e){var r;null===(r=this.observer)||void 0===r||r.setPushTrack(!0)}this._virtualOccupy=e}},{key:"initVideoEncodedTransform",value:function(){var e=this;if(this.videoTransceiver&&this.videoTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var t=this.videoTransceiver.receiver.createEncodedStreams(),r=t.readable,n=t.writable;r.pipeThrough(new TransformStream({transform:function(t,r){LV.getNalunits(new UV(t.data)).forEach((function(t){if(t.sei){var r=zV.decodeSeiBody(t.body);r&&r.type!==VV.internal&&e.safeEmit("onSEIMessage",r.payload)}})),r.enqueue(t)}})).pipeTo(n)}else QV.print("initAudioEncodedTransform","legacy EncodedTransform is not supported");else QV.print("no receiver found when trying to bind encodedTransform")}},{key:"initAudioEncodedTransform",value:function(){if(this.audioTransceiver&&this.audioTransceiver.receiver)if(this._ctx.pcKillSwitch.ctor_encodedinsetablestream_add){var e=this.audioTransceiver.receiver.createEncodedStreams(),t=e.readable,r=e.writable;t.pipeThrough(new TransformStream({transform:function(e,t){t.enqueue(e)}})).pipeTo(r)}else QV.print("legacy EncodedTransform is not supported");else QV.print("no receiver found when trying to bind encodedTransform")}},{key:"ontrack",value:function(e){var t,r,n,i,o,a;try{var s;LO(this.engineId,"Stream.ontrack",Nm({uid:this.userId,streamId:this.streamId,streams:pb(s=e.streams).call(s,(function(e,t){return e+(null==(r=t)?"undefined | null":"string"==typeof r?r:Nm({id:r.id,active:r.active}));var r}),""),transceiver:(i=e.transceiver,null==i?"undefined | null":"string"==typeof i?i:Nm({currentDirection:i.currentDirection,direction:i.direction,mid:i.mid,stopped:i.stopped,receiver:(a=i.receiver,null==a?"undefined | null":"string"==typeof a?a:Nm({track:AD(a.track)})),sender:(o=i.sender,null==o?"undefined | null":"string"==typeof o?o:Nm({track:AD(o.track)}))})),track:AD(e.track)}),0,this.streamId||"")}catch(eq){}if(this.enableVendorMode||null!==(t=e.streams)&&void 0!==t&&null!==(r=t[0])&&void 0!==r&&null!==(n=r.id)&&void 0!==n&&mk(n).call(n,this.streamId)){var c,u=e.track;"video"===(null==u?void 0:u.kind)?this._setVideoTrack(u):"audio"===(null===(c=e.track)||void 0===c?void 0:c.kind)&&this._setAudioTrack(u),this._setStream(e.streams[0])}this.safeEmit("ontrack",e)}},{key:"clean",value:function(){var e,t;QV.print("clean",Om(e="exec stream.clean ".concat(this.streamId," ")).call(e,this.userId)),LO(this.engineId,"remotestream_clean","".concat((new Error).stack),0,this.streamId),OI(CI(r.prototype),"destroy",this).call(this),this.subAudio=!1,this.subVideo=!1,this.sequenceId=0,this.videoTrack=void 0,null===(t=this.audioTrack)||void 0===t||t.close(),this.audioTrack=void 0,this.stream=void 0,this.recordedVideoFrames=void 0,delete this.priority}},{key:"destroy",value:function(){this.clean(),this.attributes={audiostream:!1,localaudio:!1,localvideo:!1,videostream:!1,extvideo:!1,extaudio:!1,videoDescriptions:[]}}},{key:"resetHasSubscribed",value:function(){this.streamState=0}},{key:"_setStream",value:function(e){var t=this;this.stream=e,e.onaddtrack=function(e){"video"===e.track.kind?t._setVideoTrack(e.track):"audio"===e.track.kind&&t._setAudioTrack(e.track)}}},{key:"_setAudioTrack",value:function(e){var t,r;(null===(t=this.audioTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.audioTrack=TV(e),this.emit("ontrack",this.audioTrack))}},{key:"_setVideoTrack",value:function(e){var t,r;(null===(t=this.videoTrack)||void 0===t||null===(r=t.getTrack())||void 0===r?void 0:r.id)!==(null==e?void 0:e.id)&&(this.videoTrack=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:oD();return new iV(e,t)}(e),this.emit("ontrack",this.videoTrack))}}]),r}(ZV),rF=new yO("queue",4),nF=function(e){return e[e.ADD=0]="ADD",e[e.CLOSE=1]="CLOSE",e}(nF||{}),iF=function(e){return e.publish="publish",e.unpublish="unpublish",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.pushtrack="pushtrack",e.removetrack="removetrack",e}(iF||{}),oF=(Jd(YV={},"publish","unpublish"),Jd(YV,"subscribe","unsubscribe"),Jd(YV,"pushtrack","removetrack"),YV),aF=(Jd(JV={},"publish",0),Jd(JV,"subscribe",0),Jd(JV,"pushtrack",0),Jd(JV,"unpublish",1),Jd(JV,"unsubscribe",1),Jd(JV,"removetrack",1),JV),sF=function(e){MI(r,e);var t=JI(r);function r(){var e;return Vl(this,r),Jd(tI(e=t.call(this)),"_queue",void 0),e._queue=[],e}return Ul(r,[{key:"queue",get:function(){return this._queue}},{key:"enqueue",value:function(e){var t,r=this._queue.length,n="";return this._queue=Hs(t=this._queue).call(t,(function(t){return t.streamId!==e.streamId||e.action!==oF[t.action]||(n=t.streamId,rF.print("offsetStreamId",n),!1)})),this._queue.length===r&&this._queue.push(e),this.emit("start"),n}},{key:"dequeue",value:function(){var e;if(!this._queue.length)return null;var t=this._queue.length;jD&&cM>=86&&cM<=92&&(t=Math.min(this._queue.length,5));for(var r=aF[this._queue[0].action],n=1;n<t;n++){var i;if(aF[this._queue[n].action]!==r)return{sdpStrategy:r,items:rk(i=this._queue).call(i,0,n)}}return{sdpStrategy:r,items:rk(e=this._queue).call(e,0,t)}}}]),r}($M),cF="object"==typeof global&&global&&global.Object===Object&&global,uF="object"==typeof self&&self&&self.Object===Object&&self,dF=cF||uF||Function("return this")(),lF=dF.Symbol,hF=Object.prototype,pF=hF.hasOwnProperty,vF=hF.toString,_F=lF?lF.toStringTag:void 0;var fF=Object.prototype.toString;var mF=lF?lF.toStringTag:void 0;function yF(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":mF&&mF in Object(e)?function(e){var t=pF.call(e,_F),r=e[_F];try{e[_F]=void 0;var n=!0}catch(o){}var i=vF.call(e);return n&&(t?e[_F]=r:delete e[_F]),i}(e):function(e){return fF.call(e)}(e)}function gF(e){return null!=e&&"object"==typeof e}var SF=Array.isArray;function bF(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function EF(e){return e}function kF(e){if(!bF(e))return!1;var t=yF(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var TF,IF=dF["__core-js_shared__"],RF=(TF=/[^.]+$/.exec(IF&&IF.keys&&IF.keys.IE_PROTO||""))?"Symbol(src)_1."+TF:"";var AF=Function.prototype.toString;function wF(e){if(null!=e){try{return AF.call(e)}catch(t){}try{return e+""}catch(t){}}return""}var CF=/^\[object .+?Constructor\]$/,xF=Function.prototype,OF=Object.prototype,DF=xF.toString,MF=OF.hasOwnProperty,PF=RegExp("^"+DF.call(MF).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function NF(e){return!(!bF(e)||(t=e,RF&&RF in t))&&(kF(e)?PF:CF).test(wF(e));var t}function LF(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return NF(r)?r:void 0}var UF=LF(dF,"WeakMap"),VF=Object.create,FF=function(){function e(){}return function(t){if(!bF(t))return{};if(VF)return VF(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function BF(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var jF=Date.now;var HF,GF,zF,KF=function(){try{var e=LF(Object,"defineProperty");return e({},"",{}),e}catch(t){}}(),XF=KF,WF=XF?function(e,t){return XF(e,"toString",{configurable:!0,enumerable:!1,value:(r=t,function(){return r}),writable:!0});var r}:EF,qF=(HF=WF,GF=0,zF=0,function(){var e=jF(),t=16-(e-zF);if(zF=e,t>0){if(++GF>=800)return arguments[0]}else GF=0;return HF.apply(void 0,arguments)}),YF=qF;var JF=/^(?:0|[1-9]\d*)$/;function QF(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&JF.test(e))&&e>-1&&e%1==0&&e<t}function ZF(e,t,r){"__proto__"==t&&XF?XF(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function $F(e,t){return e===t||e!=e&&t!=t}var eB=Object.prototype.hasOwnProperty;function tB(e,t,r){var n=e[t];eB.call(e,t)&&$F(n,r)&&(void 0!==r||t in e)||ZF(e,t,r)}function rB(e,t,r,n){var i=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var s=t[o],c=n?n(r[s],e[s],s,r,e):void 0;void 0===c&&(c=e[s]),i?ZF(r,s,c):tB(r,s,c)}return r}var nB=Math.max;function iB(e,t){return YF(function(e,t,r){return t=nB(void 0===t?e.length-1:t,0),function(){for(var n=arguments,i=-1,o=nB(n.length-t,0),a=Array(o);++i<o;)a[i]=n[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=n[i];return s[t]=r(a),BF(e,this,s)}}(e,t,EF),e+"")}function oB(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function aB(e){return null!=e&&oB(e.length)&&!kF(e)}var sB=Object.prototype;function cB(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||sB)}function uB(e){return gF(e)&&"[object Arguments]"==yF(e)}var dB=Object.prototype,lB=dB.hasOwnProperty,hB=dB.propertyIsEnumerable,pB=uB(function(){return arguments}())?uB:function(e){return gF(e)&&lB.call(e,"callee")&&!hB.call(e,"callee")},vB=pB;var _B="object"==typeof exports&&exports&&!exports.nodeType&&exports,fB=_B&&"object"==typeof module&&module&&!module.nodeType&&module,mB=fB&&fB.exports===_B?dF.Buffer:void 0,yB=(mB?mB.isBuffer:void 0)||function(){return!1},gB={};function SB(e){return function(t){return e(t)}}gB["[object Float32Array]"]=gB["[object Float64Array]"]=gB["[object Int8Array]"]=gB["[object Int16Array]"]=gB["[object Int32Array]"]=gB["[object Uint8Array]"]=gB["[object Uint8ClampedArray]"]=gB["[object Uint16Array]"]=gB["[object Uint32Array]"]=!0,gB["[object Arguments]"]=gB["[object Array]"]=gB["[object ArrayBuffer]"]=gB["[object Boolean]"]=gB["[object DataView]"]=gB["[object Date]"]=gB["[object Error]"]=gB["[object Function]"]=gB["[object Map]"]=gB["[object Number]"]=gB["[object Object]"]=gB["[object RegExp]"]=gB["[object Set]"]=gB["[object String]"]=gB["[object WeakMap]"]=!1;var bB="object"==typeof exports&&exports&&!exports.nodeType&&exports,EB=bB&&"object"==typeof module&&module&&!module.nodeType&&module,kB=EB&&EB.exports===bB&&cF.process,TB=function(){try{var e=EB&&EB.require&&EB.require("util").types;return e||kB&&kB.binding&&kB.binding("util")}catch(t){}}(),IB=TB&&TB.isTypedArray,RB=IB?SB(IB):function(e){return gF(e)&&oB(e.length)&&!!gB[yF(e)]},AB=Object.prototype.hasOwnProperty;function wB(e,t){var r=SF(e),n=!r&&vB(e),i=!r&&!n&&yB(e),o=!r&&!n&&!i&&RB(e),a=r||n||i||o,s=a?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=s.length;for(var u in e)!t&&!AB.call(e,u)||a&&("length"==u||i&&("offset"==u||"parent"==u)||o&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||QF(u,c))||s.push(u);return s}function CB(e,t){return function(r){return e(t(r))}}var xB=CB(Object.keys,Object),OB=Object.prototype.hasOwnProperty;function DB(e){return aB(e)?wB(e):function(e){if(!cB(e))return xB(e);var t=[];for(var r in Object(e))OB.call(e,r)&&"constructor"!=r&&t.push(r);return t}(e)}var MB=Object.prototype.hasOwnProperty;function PB(e){if(!bF(e))return function(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t}(e);var t=cB(e),r=[];for(var n in e)("constructor"!=n||!t&&MB.call(e,n))&&r.push(n);return r}function NB(e){return aB(e)?wB(e,!0):PB(e)}var LB,UB=(LB=function(e,t){rB(t,NB(t),e)},iB((function(e,t){var r=-1,n=t.length,i=n>1?t[n-1]:void 0,o=n>2?t[2]:void 0;for(i=LB.length>3&&"function"==typeof i?(n--,i):void 0,o&&function(e,t,r){if(!bF(r))return!1;var n=typeof t;return!!("number"==n?aB(r)&&QF(t,r.length):"string"==n&&t in r)&&$F(r[t],e)}(t[0],t[1],o)&&(i=n<3?void 0:i,n=1),e=Object(e);++r<n;){var a=t[r];a&&LB(e,a,r,i)}return e}))),VB=LF(Object,"create");var FB=Object.prototype.hasOwnProperty;var BB=Object.prototype.hasOwnProperty;function jB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function HB(e,t){for(var r=e.length;r--;)if($F(e[r][0],t))return r;return-1}jB.prototype.clear=function(){this.__data__=VB?VB(null):{},this.size=0},jB.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},jB.prototype.get=function(e){var t=this.__data__;if(VB){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return FB.call(t,e)?t[e]:void 0},jB.prototype.has=function(e){var t=this.__data__;return VB?void 0!==t[e]:BB.call(t,e)},jB.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=VB&&void 0===t?"__lodash_hash_undefined__":t,this};var GB=Array.prototype.splice;function zB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}zB.prototype.clear=function(){this.__data__=[],this.size=0},zB.prototype.delete=function(e){var t=this.__data__,r=HB(t,e);return!(r<0)&&(r==t.length-1?t.pop():GB.call(t,r,1),--this.size,!0)},zB.prototype.get=function(e){var t=this.__data__,r=HB(t,e);return r<0?void 0:t[r][1]},zB.prototype.has=function(e){return HB(this.__data__,e)>-1},zB.prototype.set=function(e,t){var r=this.__data__,n=HB(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this};var KB=LF(dF,"Map");function XB(e,t){var r,n,i=e.__data__;return("string"==(n=typeof(r=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof t?"string":"hash"]:i.map}function WB(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function qB(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}WB.prototype.clear=function(){this.size=0,this.__data__={hash:new jB,map:new(KB||zB),string:new jB}},WB.prototype.delete=function(e){var t=XB(this,e).delete(e);return this.size-=t?1:0,t},WB.prototype.get=function(e){return XB(this,e).get(e)},WB.prototype.has=function(e){return XB(this,e).has(e)},WB.prototype.set=function(e,t){var r=XB(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this};var YB=CB(Object.getPrototypeOf,Object);function JB(e){var t=this.__data__=new zB(e);this.size=t.size}JB.prototype.clear=function(){this.__data__=new zB,this.size=0},JB.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},JB.prototype.get=function(e){return this.__data__.get(e)},JB.prototype.has=function(e){return this.__data__.has(e)},JB.prototype.set=function(e,t){var r=this.__data__;if(r instanceof zB){var n=r.__data__;if(!KB||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new WB(n)}return r.set(e,t),this.size=r.size,this};var QB="object"==typeof exports&&exports&&!exports.nodeType&&exports,ZB=QB&&"object"==typeof module&&module&&!module.nodeType&&module,$B=ZB&&ZB.exports===QB?dF.Buffer:void 0,ej=$B?$B.allocUnsafe:void 0;function tj(){return[]}var rj=Object.prototype.propertyIsEnumerable,nj=Object.getOwnPropertySymbols,ij=nj?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,o=[];++r<n;){var a=e[r];t(a,r,e)&&(o[i++]=a)}return o}(nj(e),(function(t){return rj.call(e,t)})))}:tj;var oj=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)qB(t,ij(e)),e=YB(e);return t}:tj;function aj(e,t,r){var n=t(e);return SF(e)?n:qB(n,r(e))}function sj(e){return aj(e,DB,ij)}function cj(e){return aj(e,NB,oj)}var uj=LF(dF,"DataView"),dj=LF(dF,"Promise"),lj=LF(dF,"Set"),hj="[object Map]",pj="[object Promise]",vj="[object Set]",_j="[object WeakMap]",fj="[object DataView]",mj=wF(uj),yj=wF(KB),gj=wF(dj),Sj=wF(lj),bj=wF(UF),Ej=yF;(uj&&Ej(new uj(new ArrayBuffer(1)))!=fj||KB&&Ej(new KB)!=hj||dj&&Ej(dj.resolve())!=pj||lj&&Ej(new lj)!=vj||UF&&Ej(new UF)!=_j)&&(Ej=function(e){var t=yF(e),r="[object Object]"==t?e.constructor:void 0,n=r?wF(r):"";if(n)switch(n){case mj:return fj;case yj:return hj;case gj:return pj;case Sj:return vj;case bj:return _j}return t});var kj=Ej,Tj=Object.prototype.hasOwnProperty;var Ij=dF.Uint8Array;function Rj(e){var t=new e.constructor(e.byteLength);return new Ij(t).set(new Ij(e)),t}var Aj=/\w*$/;var wj=lF?lF.prototype:void 0,Cj=wj?wj.valueOf:void 0;function xj(e,t,r){var n,i,o,a=e.constructor;switch(t){case"[object ArrayBuffer]":return Rj(e);case"[object Boolean]":case"[object Date]":return new a(+e);case"[object DataView]":return function(e,t){var r=t?Rj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(e,t){var r=t?Rj(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}(e,r);case"[object Map]":case"[object Set]":return new a;case"[object Number]":case"[object String]":return new a(e);case"[object RegExp]":return(o=new(i=e).constructor(i.source,Aj.exec(i))).lastIndex=i.lastIndex,o;case"[object Symbol]":return n=e,Cj?Object(Cj.call(n)):{}}}var Oj=TB&&TB.isMap,Dj=Oj?SB(Oj):function(e){return gF(e)&&"[object Map]"==kj(e)};var Mj=TB&&TB.isSet,Pj=Mj?SB(Mj):function(e){return gF(e)&&"[object Set]"==kj(e)},Nj="[object Arguments]",Lj="[object Function]",Uj="[object Object]",Vj={};function Fj(e,t,r,n,i,o){var a,s=1&t,c=2&t,u=4&t;if(r&&(a=i?r(e,n,i,o):r(e)),void 0!==a)return a;if(!bF(e))return e;var d=SF(e);if(d){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&Tj.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!s)return function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}(e,a)}else{var l=kj(e),h=l==Lj||"[object GeneratorFunction]"==l;if(yB(e))return function(e,t){if(t)return e.slice();var r=e.length,n=ej?ej(r):new e.constructor(r);return e.copy(n),n}(e,s);if(l==Uj||l==Nj||h&&!i){if(a=c||h?{}:function(e){return"function"!=typeof e.constructor||cB(e)?{}:FF(YB(e))}(e),!s)return c?function(e,t){return rB(e,oj(e),t)}(e,function(e,t){return e&&rB(t,NB(t),e)}(a,e)):function(e,t){return rB(e,ij(e),t)}(e,function(e,t){return e&&rB(t,DB(t),e)}(a,e))}else{if(!Vj[l])return i?e:{};a=xj(e,l,s)}}o||(o=new JB);var p=o.get(e);if(p)return p;o.set(e,a),Pj(e)?e.forEach((function(n){a.add(Fj(n,t,r,n,e,o))})):Dj(e)&&e.forEach((function(n,i){a.set(i,Fj(n,t,r,i,e,o))}));var v=d?void 0:(u?c?cj:sj:c?NB:DB)(e);return function(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););}(v||e,(function(n,i){v&&(n=e[i=n]),tB(a,i,Fj(n,t,r,i,e,o))})),a}Vj[Nj]=Vj["[object Array]"]=Vj["[object ArrayBuffer]"]=Vj["[object DataView]"]=Vj["[object Boolean]"]=Vj["[object Date]"]=Vj["[object Float32Array]"]=Vj["[object Float64Array]"]=Vj["[object Int8Array]"]=Vj["[object Int16Array]"]=Vj["[object Int32Array]"]=Vj["[object Map]"]=Vj["[object Number]"]=Vj[Uj]=Vj["[object RegExp]"]=Vj["[object Set]"]=Vj["[object String]"]=Vj["[object Symbol]"]=Vj["[object Uint8Array]"]=Vj["[object Uint8ClampedArray]"]=Vj["[object Uint16Array]"]=Vj["[object Uint32Array]"]=!0,Vj["[object Error]"]=Vj[Lj]=Vj["[object WeakMap]"]=!1;function Bj(e){return Fj(e,5)}function jj(e,t){return function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}(t,(function(t){return e[t]}))}function Hj(e){return null==e?[]:jj(e,DB(e))}var Gj=new yO("ChromeHandler",3),zj=iL(),Kj=function(e){MI(u,e);var t,r,n,i,o,a,s,c=JI(u);function u(e,t){var r;return Vl(this,u),Jd(tI(r=c.call(this,e,t)),"name","chrome"),Jd(tI(r),"_queueBusy",!1),Jd(tI(r),"_sdpQueue",void 0),Jd(tI(r),"_aSendonlyOfferTpl",void 0),Jd(tI(r),"_vSendonlyOfferTpl",void 0),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),Jd(tI(r),"_vRecvonlyOfferTpl",void 0),Jd(tI(r),"_mid",10),Jd(tI(r),"_inactiveMlineIndex",[]),Jd(tI(r),"_mlinesCache",{}),Jd(tI(r),"setDescription",void 0),r.setDescription=t.setDescription.bind(t),r._sdpQueue=new sF,r._sdpQueue.on("start",(function(){r._queueBusy||"stable"!==r._peerConnection.signalingState||(Gj.print("dequeue start"),r.dequeue())})),r}return Ul(u,[{key:"destroy",value:function(){OI(CI(u.prototype),"destroy",this).call(this),this._mlinesCache={}}},{key:"publish",value:(s=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N,L,U,V,F;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d=t.stream,l=t.enableSimulcast,h=OI(CI(u.prototype),"internalPublish",this).call(this,t),p=h.videoDescriptions,v=h.subVideoDescriptions,_=h.audioTransceiverInit,f=h.videoTransceiverInit,m=VL(this._nextSsrc),this._nextSsrc=m.next,y="".concat(this._mid++),g="".concat(this._mid++),S=Zd(Zd(Zd({},this._aSendonlyOfferTpl),this.peer._offerIce),{},{mid:y,msid:Om(r="".concat(d.id," ")).call(r,d.id,"-audio"),ssrcs:FL(d.id,"audio",m.audio,LL)}),b=Zd(Zd(Zd({},this._vSendonlyOfferTpl),this.peer._offerIce),{},{mid:g,msid:Om(n="".concat(d.id," ")).call(n,d.id,"-video")}),l?(Gj.print("subVideoDesc","desc: %o ",v),delete b.ssrcGroups,delete b.ssrcs,E=[],b.rids=jm(p).call(p,(function(e){var t=e.rid;return E.unshift(t),{id:t,direction:"send"}})),b.simulcast={dir1:"send",list1:E.join(";")}):(k=BL(d.id,m,{cname:LL}),T=k.ssrcs,I=k.ssrcGroups,b.ssrcs=T,b.ssrcGroups=I),null!==(i=this._context)&&void 0!==i&&null!==(o=i.serverConfig)&&void 0!==o&&o.audioRed&&Array.isArray(S.rtp)&&(-1!==(A=JR(R=S.rtp).call(R,(function(e){return"red"===e.codec})))&&(C=rk(w=S.rtp).call(w,A,1),x=eI(C,1),O=x[0],S.rtp.unshift(O)),D=[],S.rtp.forEach((function(e){return D.push(e.payload)})),S.payloads=D.join(" ")),null!==(a=this._context)&&void 0!==a&&null!==(s=a.serverConfig)&&void 0!==s&&s.videoCodec&&YL(b,null===(M=this._context)||void 0===M||null===(P=M.serverConfig)||void 0===P?void 0:P.videoCodec),(BD||QD)&&Array.isArray(b.ext)&&(b.ext=Hs(N=b.ext).call(N,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),(L=null==S?void 0:gE(c=S.rtp).call(c,(function(e){return"opus"===e.codec})))&&S.fmtp&&(F=gE(U=S.fmtp).call(U,(function(e){return e.payload===L.payload})))&&null!==(V=this._context)&&void 0!==V&&V.audioProfileManager&&(F.config=this._context.audioProfileManager.getOpusConfigStr(F.config)),l||BD||this.addBitrateLimit(b,t.videoEncodeConfig[0].maxKbps),this._mlinesCache[t.stream.id]=[S,b],e.abrupt("return",{partialSdp:HL(this.peer._offerSession,S,b),audioMid:y,videoMid:g,type:"incroffer",semantics:"unified-plan",videoDescriptions:p,subVideoDescriptions:v,audioTransceiverInit:_,videoTransceiverInit:f,peerConnectionMode:this.peerConnectionMode});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"subscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N,L,U,V=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Gj.print("subscribe"),a="incroffer",s="unified-plan",this._aRecvonlyOfferTpl&&this._vRecvonlyOfferTpl){e.next=9;break}return e.next=6,this._genOfferSdp();case 6:return c=e.sent,e.next=9,this.createAVMlineOfferTpl(c);case 9:if(u="",d="",l=!1,h=!1,p=void 0,v=void 0,this._mlinesCache[t.streamId]=[p,v],t.virtual?(u="".concat(this._mid++),l=!0):r.multiChatMode?(u="".concat(this._mid++),d="".concat(this._mid++),h=!0):(l=!0,h=!0,u="".concat(this._mid++),d="".concat(this._mid++)),u&&(p=Zd(Zd({},Bj(this._aRecvonlyOfferTpl)),{},{mid:u})),l&&(this._mlinesCache[t.streamId][0]=p,_={track:"audio",init:{direction:"recvonly"}}),d&&(v=Zd(Zd({},Bj(this._vRecvonlyOfferTpl)),{},{mid:d})),h&&(this._mlinesCache[t.streamId][1]=v,f={track:"video",init:{direction:"recvonly"}}),m=HL(this.peer._offerSession,p,v),y=void 0,t.enableVendorMode||r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._vSendonlyAnswerTpl){e.next=32;break}return y=VL(this._nextSsrc),this._nextSsrc=y.next,R=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-audio"," ")).call(g,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",y.audio)}),A=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:d,msid:Om(E=Om(k="".concat(t.streamId)).call(k,null!==(T=this._context)&&void 0!==T&&T.avSync?"":"-video"," ")).call(E,t.streamId,"-video")},BL(t.streamId,y,{flexfec:this._enableSubFlexfec})),w=new Yf((function(e){V._sdpQueue.enqueue({action:iF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:_,videoTransceiverInit:f,signalingAck:{sdp:pL.write(Zd(Zd({},V.peer._answerSession),{},{media:[R,A]})),sequenceId:t.sequenceId?++t.sequenceId:0},stream:t,sdp:m,onSuccess:function(){Gj.print("subscribe()","sub success"),e(0)}})})),e.next=31,w;case 31:null===(I=y)||void 0===I||delete I.next;case 32:return(C=null===(n=p)||void 0===n?void 0:gE(i=n.rtp).call(i,(function(e){return"opus"===e.codec})))&&null!==(o=p)&&void 0!==o&&o.fmtp&&(D=null===(x=p)||void 0===x?void 0:gE(O=x.fmtp).call(O,(function(e){return e.payload===C.payload})))&&this._context&&(D.config+=";stereo=1;sprop-stereo=1"),t.isPublic&&cM>=86&&null!=(L=null===(M=v)||void 0===M?void 0:Hs(P=M.rtp).call(P,(function(e){return"H264"===e.codec})))&&L.length&&null!==(N=v)&&void 0!==N&&N.fmtp&&(null===(U=v)||void 0===U||U.fmtp.forEach((function(e){gE(L).call(L,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))),e.abrupt("return",{partialSdp:m,audioMid:u,videoMid:d,type:a,semantics:s,audioTransceiverInit:_,videoTransceiverInit:f,allSsrc:y,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"handleAck",value:(o=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(Gj.print("handleAck()","item: %o",t),!t.generatorSsrc){e.next=4;break}return Gj.print("already set remote"),e.abrupt("return","");case 4:return e.abrupt("return",this._sdpQueue.enqueue(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"dequeue",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._queueBusy=!0,t=this._sdpQueue.dequeue(),Gj.print("dequeue()","ret: %o",t),t){e.next=6;break}return this._queueBusy=!1,e.abrupt("return");case 6:if(e.prev=6,r=t.items,n=t.sdpStrategy,i=[],o=[],a=[],n!==nF.ADD){e.next=15;break}return e.delegateYield(Tm().mark((function e(){var t,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete(t=Zd({},f.peer._answerIce)).candidates,s=!1,c=!1,e.prev=4,d=hP(r);case 6:return e.next=8,d.next();case 8:if(!(s=!(l=e.sent).done)){e.next=16;break}if(n=l.value,"break"!==function(){var e=n.audioMid,r=n.videoMid,s=n.action,c=n.audioTransceiverInit,u=n.videoTransceiverInit,d=n.signalingAck,l=n.stream,h=l instanceof tF;if(n.onSuccess&&a.push(n.onSuccess),h&&(null==d?void 0:d.sequenceId)<l.sequenceId)return"break";var p,v={},_={},m=pL.parse(d.sdp);Array.isArray(m.media)&&jR(p=m.media).call(p,(function(e,t){var r;return null==e||null===(r=e.type)||void 0===r?void 0:r.localeCompare(null==t?void 0:t.type)})).forEach((function(n){"audio"===(n=Zd(Zd({},n),t)).type?(v=n).mid=e:(_=n).mid=r}));var y,g=l.streamId;if(s===iF.publish&&(g=null===(y=l.stream)||void 0===y?void 0:y.id),!f._mlinesCache[g])return"break";var S=eI(f._mlinesCache[g],2),b=S[0],E=S[1];if(c&&b){l.audioTransceiver=f._peerConnection.addTransceiver(c.track,c.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({audioStreamTrack:AD(c.track)}));var k=f._inactiveMlineIndex.shift();k||(k=f.peer._offerMlines.length),f.peer._offerMlines[k]=Zd({},b),f.peer._answerMlines[k]=v,zj&&l.initAudioEncodedTransform()}if(u&&E){var T,I;l.videoTransceiver=f._peerConnection.addTransceiver(u.track,u.init),f._reportRtcInvokeStatus("chromeHandler.addTrack",Nm({videoStreamTrack:AD(u.track)}));var R,A,w=f._inactiveMlineIndex.shift();w||(w=f.peer._offerMlines.length),f.peer._offerMlines[w]=Zd({},E),s===iF.publish&&null!==(T=f._context)&&void 0!==T&&null!==(I=T.serverConfig)&&void 0!==I&&I.videoCodec&&YL(_,null===(R=f._context)||void 0===R||null===(A=R.serverConfig)||void 0===A?void 0:A.videoCodec),f.peer._answerMlines[w]=_,zj&&l.initVideoEncodedTransform()}i.push(l.streamId||""),o.push(h?l.userId:"local"),h&&(l.sequenceId=null==d?void 0:d.sequenceId),delete f._mlinesCache[g]}()){e.next=13;break}return e.abrupt("break",16);case 13:s=!1,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),c=!0,u=e.t0;case 22:if(e.prev=22,e.prev=23,!s||null==d.return){e.next=27;break}return e.next=27,d.return();case 27:if(e.prev=27,!c){e.next=30;break}throw u;case 30:return e.finish(27);case 31:return e.finish(22);case 32:case"end":return e.stop()}}),e,null,[[4,18,22,32],[23,,27,31]])}))(),"t0",13);case 13:e.next=20;break;case 15:_={},r.forEach((function(e){var t=e.audioMid,r=e.videoMid,n=e.action;_[t]=t,n!==iF.removetrack&&(_[r]=r),_[t]=t})),this.peer._offerMlines=jm(h=this.peer._offerMlines).call(h,(function(e,t){return _[e.mid]&&(e=jL(e),f._inactiveMlineIndex.push(t)),e})),jR(p=this._inactiveMlineIndex).call(p,(function(e,t){return e-t})),this.peer._answerMlines=jm(v=this.peer._answerMlines).call(v,(function(e){return _[e.mid]&&(e=jL(e)),e}));case 20:return e.next=22,this.peer.getOriginRTCPeerConnection().createOffer();case 22:return e.next=24,this.setDescription(i.length?{streamId:i.join(","),streamUserId:o.join(",")}:void 0);case 24:try{a.forEach((function(e){return e()}))}catch(eq){}Gj.print("dequeue","loop"),e.next=31;break;case 28:e.prev=28,e.t1=e.catch(6),Gj.print("dequeue","unknown error: %o",e.t1);case 31:return e.prev=31,this.dequeue(),e.finish(31);case 34:case"end":return e.stop()}}),e,this,[[6,28,31,34]])}))),function(){return i.apply(this,arguments)})},{key:"getDefaultSdp",value:(n=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._genOfferSdp();case 2:return r=e.sent,this.createAVMlineOfferTpl(r),n=pL.parse(r),i=[],n.media=Hs(t=n.media).call(t,(function(e){var t;return"recvonly"===e.direction&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))),i.push(e.mid+""),!0)})),n.groups=[{mids:i.join(" "),type:"BUNDLE"}],e.abrupt("return",{sdp:pL.write(n),semantics:"unified-plan",type:"incroffer"});case 9:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"rollback",value:(r=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:delete this._mlinesCache[t];case 1:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){if(e.icePwd=t.peer._offerIce.icePwd,e.iceUfrag=t.peer._offerIce.iceUfrag,"audio"===e.type)if("sendonly"===e.direction)t._aSendonlyOfferTpl=e;else{var r;if(Array.isArray(e.ext))e.ext=Hs(r=e.ext).call(r,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._aRecvonlyOfferTpl=e}else if("video"===e.type)if("sendonly"===e.direction)t._vSendonlyOfferTpl=e;else{var n;if(Array.isArray(e.ext))e.ext=Hs(n=e.ext).call(n,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}));t._vRecvonlyOfferTpl=e}}))}},{key:"_genOfferSdp",value:(t=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,SD(!0);case 3:if(t=e.sent){e.next=6;break}throw"pc.createOffer() return empty.";case 6:e.next=12;break;case 8:throw e.prev=8,e.t0=e.catch(0),r="Get offer Error. ".concat(e.t0.message|e.t0),new vA(hA.NOT_SUPPORTED,r);case 12:return e.abrupt("return",t);case 13:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(){return t.apply(this,arguments)})}]),u}(QL),Xj=new yO("FirefoxHandler",3),Wj=function(e){MI(d,e);var t,r,n,i,o,a,s,c,u=JI(d);function d(){var e,t;Vl(this,d);for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return Jd(tI(t=u.call.apply(u,Om(e=[this]).call(e,n))),"name","firefox"),Jd(tI(t),"_aRecvonlyOfferTpl",void 0),t}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_,f,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=OI(CI(d.prototype),"internalPublish",this).call(this,t),o=i.videoDescriptions,a=i.subVideoDescriptions,s=i.audioTransceiverInit,c=i.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(s.track,s.init),t.videoTransceiver=this._peerConnection.addTransceiver(c.track,c.init),u=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return l=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:aD()-u}),(h=pL.parse(l.sdp)).media=null===(r=h.media)||void 0===r?void 0:jm(r).call(r,(function(e){return Zd(Zd({},e),m.peer._offerIce)})),e.next=13,this.setLocalDescription(pL.write(h));case 13:return p=t.audioTransceiver.mid,v=t.videoTransceiver.mid,_=null,f=null,h.media=null===(n=h.media)||void 0===n?void 0:jm(n).call(n,(function(e){if("".concat(e.mid)===p){var t,r,n=null===(t=_=e)||void 0===t?void 0:gE(r=t.rtp).call(r,(function(e){return"opus"===e.codec}));if(n&&_.fmtp){var i,o,a=gE(i=_.fmtp).call(i,(function(e){return e.payload===n.payload}));a&&null!==(o=m._context)&&void 0!==o&&o.audioProfileManager&&(a.config=m._context.audioProfileManager.getOpusConfigStr(a.config))}}else if("".concat(e.mid)===v){var s,c,u,d;null!==(s=m._context)&&void 0!==s&&null!==(c=s.serverConfig)&&void 0!==c&&c.videoCodec&&YL(e,null===(u=m._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec),f=e}return e})),this.addBitrateLimit(f,t.videoEncodeConfig[0].maxKbps),e.next=21,this.setLocalDescription(pL.write(h));case 21:return e.abrupt("return",{partialSdp:HL(h,_,f,!1),audioMid:p,videoMid:v,type:"incroffer",semantics:"unified-plan",videoDescriptions:o,subVideoDescriptions:a,audioTransceiverInit:s,videoTransceiverInit:c,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Xj.print("subscribe()"),c="",u="",d=!1,l=!1,h=void 0,p=void 0,t.virtual?d=!0:(r.multiChatMode||(d=!0),l=!0),d&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),l&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),v=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return _=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-v}),(f=pL.parse(_.sdp)).media=null===(n=f.media)||void 0===n?void 0:jm(n).call(n,(function(e){return Zd(Zd({},e),A.peer._offerIce)})),jm(i=f.media).call(i,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=21,this.setLocalDescription(pL.write(f),{streamId:t.streamId||"",streamUserId:t.userId});case 21:if(c=null===(o=t.audioTransceiver)||void 0===o?void 0:o.mid,u=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid,null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===c?h=e:"".concat(e.mid)===u&&(p=e)})),c&&h||(c="audio_".concat(u),h=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:c})),t.audioMid=c,t.videoMid=u,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=36;break}return m=VL(this._nextSsrc),this._nextSsrc=m.next,I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:c,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:u,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},BL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=35,this._internalSetRemoteDescription([I,R],t);case 35:null===(T=m)||void 0===T||delete T.next;case 36:return e.abrupt("return",{partialSdp:HL(f,h,p,!1),audioMid:c,videoMid:u,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 37:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==iF.unpublish&&i!==iF.unsubscribe&&i!==iF.removetrack){e.next=5;break}return e.next=4,this.close(n);case 4:return e.abrupt("return",n.streamId||"");case 5:if(!t.generatorSsrc){e.next=8;break}return Xj.print("already set remote"),e.abrupt("return","");case 8:return o=pL.parse(null==r?void 0:r.sdp),e.next=11,this._internalSetRemoteDescription(o.media,n);case 11:return e.abrupt("return","");case 12:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=pL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){if("audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type){if(r instanceof eF&&iM<=87){var t,n,i,o,a={};Array.isArray(e.rtp)&&(e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"!==e.codec||(a[e.payload]=e.payload,!1)}))),"string"==typeof e.payloads&&(e.payloads=Hs(n=e.payloads.split(" ")).call(n,(function(e){return!a[e]})).join(" ")),Array.isArray(e.fmtp)&&(e.fmtp=Hs(i=e.fmtp).call(i,(function(e){return!a[e.payload]}))),Array.isArray(e.rtcpFb)&&(e.fmtp=Hs(o=e.fmtp).call(o,(function(e){return!a[e.payload]})))}r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e}})),u=pL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r,n;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})),iM>=138&&(e.ext=null===(n=e.ext)||void 0===n?void 0:Hs(n).call(n,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")}))))})),e.next=11,this.setRemoteDescription(pL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=pL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:pL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Xj.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return Xj.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=pL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=jL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=pL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(pL.write(u));case 17:return e.next=19,this.setRemoteDescription(pL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(QL),qj=new yO("FallbackHandler",3),Yj=function(e){MI(d,e);var t,r,n,i,o,a,s,c,u=JI(d);function d(e,t){var r;return Vl(this,d),Jd(tI(r=u.call(this,e,t)),"name","fallback"),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),qj.print("ctor","using fallback handler"),r._report("rtc_error",{message:"using fallback handler",error_code:-1}),r}return Ul(d,[{key:"publish",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,l,h,p,v,_;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=OI(CI(d.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,a.init),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,s.init),c=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=7,this._peerConnection.createOffer();case 7:return u=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:aD()-c}),l=pL.parse(u.sdp),e.next=12,this.setLocalDescription(u.sdp);case 12:return h=t.audioTransceiver.mid,p=t.videoTransceiver.mid,v=null,_=null,l.media=null===(r=l.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===h?v=e:"".concat(e.mid)===p&&(_=e),e})),iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HL(l,v,_,!1),audioMid:h,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 19:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"subscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("subscribe()"),a="",s="",c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=14,this._peerConnection.createOffer();case 14:return p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-h}),v=pL.parse(p.sdp),e.next=19,this.setLocalDescription(p.sdp,{streamId:t.streamId||"",streamUserId:t.userId});case 19:if(a=null===(n=t.audioTransceiver)||void 0===n?void 0:n.mid,s=null===(i=t.videoTransceiver)||void 0===i?void 0:i.mid,null===(o=v.media)||void 0===o||o.forEach((function(e){"".concat(e.mid)===a?d=e:"".concat(e.mid)===s&&(l=e)})),a&&d||(a="audio_".concat(s),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:a})),t.audioMid=a,t.videoMid=s,_=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=34;break}return _=VL(this._nextSsrc),this._nextSsrc=_.next,k=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:a,msid:Om(f=Om(m="".concat(t.streamId)).call(m,null!==(y=this._context)&&void 0!==y&&y.avSync?"":"-audio"," ")).call(f,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",_.audio)}),T=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:s,msid:Om(g=Om(S="".concat(t.streamId)).call(S,null!==(b=this._context)&&void 0!==b&&b.avSync?"":"-video"," ")).call(g,t.streamId,"-video")},BL(t.streamId,_,{flexfec:this._enableSubFlexfec})),e.next=33,this._internalSetRemoteDescription([k,T],t);case 33:null===(E=_)||void 0===E||delete E.next;case 34:return iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HL(v,d,l,!1),audioMid:a,videoMid:s,type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:_,peerConnectionMode:this.peerConnectionMode});case 36:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handleAck",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==iF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==iF.unpublish&&i!==iF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return qj.print("already set remote"),e.abrupt("return","");case 10:return o=pL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(o=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s={},(c=pL.parse(null===(n=this._peerConnection.remoteDescription)||void 0===n?void 0:n.sdp)).media.forEach((function(e){void 0!==e.mid&&(s[e.mid]=e)})),t.forEach((function(e){"audio"===(e=Zd(Zd({},e),l.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,s[r.audioMid]=e):s[e.mid]=e),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,s[r.videoMid]=e):s[e.mid]=e)})),u=pL.parse(null===(i=this._peerConnection.localDescription)||void 0===i?void 0:i.sdp),d=jm(o=u.media).call(o,(function(e){var t=s[e.mid];return"inactive"===e.direction?e:t})),c.groups=u.groups,c.media=d,jm(a=c.media).call(a,(function(e){var t,r;"video"===e.type&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(r=e.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type})))})),e.next=11,this.setRemoteDescription(pL.write(c));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"getDefaultSdp",value:(i=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=pL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:pL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"rollback",value:(n=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"close",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return qj.print("close()"),a={},t.audioTransceiver&&t.audioMid&&(t.audioTransceiver.stop(),a[t.audioMid]=t.audioMid),t.videoTransceiver&&t.videoMid&&!r&&(t.videoTransceiver.stop(),a[t.videoMid]=t.videoMid),s=[],e.next=7,this._peerConnection.createOffer();case 7:return c=e.sent,(u=pL.parse(null==c?void 0:c.sdp)).media=jm(n=u.media).call(n,(function(e){return a[e.mid]&&(e=jL(e)),"inactive"!==e.direction&&s.push(e.mid),Zd(Zd({},e),h.peer._offerIce)})),d=pL.parse(null===(i=this._peerConnection.remoteDescription)||void 0===i?void 0:i.sdp),l={},d.media.forEach((function(e){void 0!==e.mid&&(l[e.mid]=e)})),d.media=jm(o=u.media).call(o,(function(e){return"inactive"===e.direction?e:l[e.mid]})),u.groups&&d.groups&&(u.groups[0].mids=s.join(" "),d.groups[0].mids=s.join(" ")),e.next=17,this.setLocalDescription(null==c?void 0:c.sdp);case 17:return e.next=19,this.setRemoteDescription(pL.write(d));case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"setCurrentDescription",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._peerConnection.createOffer();case 2:if(!this._peerConnection.localDescription||!this._peerConnection.remoteDescription){e.next=7;break}return e.next=5,this._peerConnection.setLocalDescription(this._peerConnection.localDescription);case 5:return e.next=7,this._peerConnection.setRemoteDescription(this._peerConnection.remoteDescription);case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}}]),d}(QL);function Jj(e,t){var r=(new Error).stack;xO("[DCHECK FAILED] ".concat(t),-1,{stack:r})}var Qj=ad,Zj=tc,$j=function(e,t,r,n){for(var i,o=n>1?void 0:n?Zj(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Qj(t,r,o),o},eH=new yO("StandardHandler",3),tH=function(){function e(t){Vl(this,e),Jd(this,"_queue",[]),Jd(this,"_runningTask",[]),Jd(this,"executor",void 0),Jd(this,"busy",!1),this.executor=t}var t;return Ul(e,[{key:"add",value:function(e){var t=oH(),r=t.promise,n=t.resolve,i=t.reject;return this._queue.push({item:e,resolve:n,reject:i}),this.busy||this._emit(),r}},{key:"destroy",value:function(){var e;Om(e=[]).call(e,Jk(this._queue),Jk(this._runningTask)).forEach((function(e){(0,e.reject)(new vA(hA.OPERATION_CANCEL,"queue close"))})),this.busy=!1,this._queue=[]}},{key:"_emit",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._queue,this._runningTask=t,this._queue=[],0!==t.length){e.next=6;break}return this.busy=!1,e.abrupt("return");case 6:return r=jm(t).call(t,(function(e){return e.item})),n=jm(t).call(t,(function(e){return e.resolve})),i=jm(t).call(t,(function(e){return e.reject})),e.prev=9,this.busy=!0,e.next=13,this.executor(r);case 13:o=e.sent,n.forEach((function(e){return e(o)})),e.next=20;break;case 17:e.prev=17,e.t0=e.catch(9),i.forEach((function(t){return t(e.t0)}));case 20:return this._runningTask=[],setTimeout((function(){a._emit()})),e.abrupt("return");case 23:case"end":return e.stop()}}),e,this,[[9,17]])}))),function(){return t.apply(this,arguments)})}]),e}(),rH=function(e){MI(h,e);var t,r,n,i,o,a,s,c,u,d,l=JI(h);function h(e,t){var r;return Vl(this,h),Jd(tI(r=l.call(this,e,t)),"name","standard"),Jd(tI(r),"_applyQueue",new tH(r.apply.bind(tI(r)))),Jd(tI(r),"_createQueue",new tH(r.create.bind(tI(r)))),Jd(tI(r),"_pqueue",new iH),Jd(tI(r),"_midMap",new $S),Jd(tI(r),"_aRecvonlyOfferTpl",void 0),eH.print("ctor","using standard handler"),r}return Ul(h,[{key:"publish",value:(d=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,p,v,_,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("publish()","streamId: ".concat(t.streamId)),n=OI(CI(h.prototype),"internalPublish",this).call(this,t),i=n.videoDescriptions,o=n.subVideoDescriptions,a=n.audioTransceiverInit,s=n.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(a.track,Zd(Zd({},a.init),{},{direction:"sendonly"})),Array.isArray(s.init.sendEncodings)&&1===s.init.sendEncodings.length&&(s.init.sendEncodings=jm(c=s.init.sendEncodings).call(c,(function(e){return delete e.rid,e}))),t.videoTransceiver=this._peerConnection.addTransceiver(s.track,Zd(Zd({},s.init),{},{direction:"sendonly"})),u=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=9,this._createQueue.add();case 9:return d=e.sent,this._report("rtc_create_offer",{direction:"up",error_code:0,stream_id:"",stream_user_id:"",elapse:aD()-u}),l=t.audioTransceiver.mid,p=t.videoTransceiver.mid,Jj(0,"Transceiver not return MID after setLocalDescription"),t.audioMid=l,t.videoMid=p,v=null,_=null,(f=pL.parse(d)).media=null===(r=f.media)||void 0===r?void 0:jm(r).call(r,(function(e){return"".concat(e.mid)===l?v=e:"".concat(e.mid)===p&&(_=e),e})),iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HL(f,v,_,!1),audioMid:l,videoMid:p,type:"incroffer",semantics:"unified-plan",videoDescriptions:i,subVideoDescriptions:o,audioTransceiverInit:a,videoTransceiverInit:s,peerConnectionMode:this.peerConnectionMode});case 22:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"subscribe",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("subscribe()","streamId: ".concat(t.streamId)),c=!1,u=!1,d=void 0,l=void 0,t.virtual?c=!0:(r.multiChatMode||(c=!0),u=!0),c&&(t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"})),u&&(t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"})),h=aD(),this._report("rtc_begin_create_offer",{direction:"up",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:0}),e.next=12,this._createQueue.add();case 12:if(p=e.sent,this._report("rtc_create_offer",{error_code:0,direction:"up",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-h}),v=null!==(n=null===(i=t.audioTransceiver)||void 0===i?void 0:i.mid)&&void 0!==n?n:void 0,_=null!==(o=null===(a=t.videoTransceiver)||void 0===a?void 0:a.mid)&&void 0!==o?o:void 0,f=pL.parse(p),null===(s=f.media)||void 0===s||s.forEach((function(e){"".concat(e.mid)===v?d=e:"".concat(e.mid)===_&&(l=e)})),v&&d||(v="audio_".concat(_),d=Zd(Zd({},this._aRecvonlyOfferTpl),{},{mid:v})),t.audioMid=v,t.videoMid=_,m=void 0,r.multiChatMode||t.virtual||!this._aSendonlyAnswerTpl||!this._aSendonlyAnswerTpl){e.next=29;break}return m=this._generateAllSsrc(),I=Zd(Zd(Zd({},this._aSendonlyAnswerTpl),this.peer._answerIce),{},{mid:v,msid:Om(y=Om(g="".concat(t.streamId)).call(g,null!==(S=this._context)&&void 0!==S&&S.avSync?"":"-audio"," ")).call(y,t.streamId,"-audio"),ssrcs:FL(t.streamId,"audio",m.audio)}),R=Zd(Zd(Zd({},this._vSendonlyAnswerTpl),this.peer._answerIce),{},{mid:_,msid:Om(b=Om(E="".concat(t.streamId)).call(E,null!==(k=this._context)&&void 0!==k&&k.avSync?"":"-video"," ")).call(b,t.streamId,"-video")},BL(t.streamId,m,{flexfec:this._enableSubFlexfec})),e.next=28,this._internalSetRemoteDescription([I,R],t);case 28:null===(T=m)||void 0===T||delete T.next;case 29:return iL()&&(t.initVideoEncodedTransform(),t.initAudioEncodedTransform()),e.abrupt("return",{partialSdp:HL(f,d,l,!1),audioMid:v,videoMid:_||"",type:"incroffer",semantics:"unified-plan",audioTransceiverInit:t.audioTransceiver?{track:"audio",init:{direction:"recvonly"}}:void 0,videoTransceiverInit:t.videoTransceiver?{track:"video",init:{direction:"recvonly"}}:void 0,allSsrc:m,peerConnectionMode:this.peerConnectionMode});case 31:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"handleAck",value:(c=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.signalingAck,n=t.stream,(i=t.action)!==iF.removetrack){e.next=3;break}return e.abrupt("return","");case 3:if(i!==iF.unpublish&&i!==iF.unsubscribe){e.next=7;break}return e.next=6,this.close(n);case 6:return e.abrupt("return",n.streamId||"");case 7:if(!t.generatorSsrc){e.next=10;break}return eH.print("already set remote"),e.abrupt("return","");case 10:return o=pL.parse(null==r?void 0:r.sdp),e.next=13,this._internalSetRemoteDescription(o.media,n);case 13:return e.abrupt("return","");case 14:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"_internalSetRemoteDescription",value:(s=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){"audio"===(e=Zd(Zd({},e),n.peer._answerIce)).type&&(r.audioMid?(e.mid=r.audioMid,n._midMap.set(r.audioMid,e)):n._midMap.set(e.mid,e)),"video"===e.type&&(r.videoMid?(e.mid=r.videoMid,n._midMap.set(r.videoMid,e)):n._midMap.set(e.mid,e))})),r instanceof eF?this.handlePublishAction({stream:r}):this.handleSubscribeAction({stream:r}),e.next=7,this._applyQueue.add();case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"handlePublishAction",value:function(e){var t,r,n,i,o,a,s,c,u=e.stream,d=u.audioMid?this._midMap.get(u.audioMid):void 0,l=u.videoMid?this._midMap.get(u.videoMid):void 0,h=null!==(t=this._context)&&void 0!==t&&null!==(r=t.serverConfig)&&void 0!==r&&r.audioRed?"RED":"OPUS";("OPUS"!==h&&d&&function(e,t){if(Array.isArray(e.fmtp)&&Array.isArray(e.rtp)){for(var r=0;r<e.rtp.length;r++)if(e.rtp[r].codec.toUpperCase()===t.toUpperCase()){var n;e.rtp.unshift(rk(n=e.rtp).call(n,r,1)[0]);break}var i=[];e.rtp.forEach((function(e){return i.push(e.payload)})),e.payloads=i.join(" ")}}(d,h),null!==(n=this._context)&&void 0!==n&&n.pcKillSwitch.sld_fmtp_opus_add)&&nH.decorateOpusConfig(d,null===(c=this._context)||void 0===c?void 0:c.audioProfileManager);FD&&iM<=87&&nH.removeRtxInMLine(l);var p=null===(i=this._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec;p&&l&&YL(l,p),null!==(a=this._context)&&void 0!==a&&a.pcKillSwitch.sld_ext_sdesmid_remove&&FD&&iM>=138&&nH.removeExtSdesMid(l),null!==(s=this._context)&&void 0!==s&&s.pcKillSwitch.sld_fmtp_bitrate_add&&(u.enableSimulcast||BD||!l||this.addBitrateLimit(l,u.videoEncodeConfig[0].maxKbps)),u.audioMid&&d&&this._midMap.set(u.audioMid,d),u.videoMid&&l&&this._midMap.set(u.videoMid,l)}},{key:"handleSubscribeAction",value:function(e){var t,r,n=e.stream,i=n.audioMid?this._midMap.get(n.audioMid):void 0,o=n.videoMid?this._midMap.get(n.videoMid):void 0;FD||(nH.removeRtpStreamId(i),nH.removeRtpStreamId(o)),null!==(t=this._context)&&void 0!==t&&t.pcKillSwitch.sld_fmtp_opus_add&&nH.decorateOpusConfig(i),RM("IOS_SAFARI_ORIENTATION")||!BD&&!QD||nH.removeExtVideoOrientation(o),null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_sps_add&&n.isPublic&&jD&&cM>=86&&nH.decorateSpsPpsIdrInKeyframe(o),n.audioMid&&i&&this._midMap.set(n.audioMid,i),n.videoMid&&o&&this._midMap.set(n.videoMid,o)}},{key:"getDefaultSdp",value:(a=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=new RTCPeerConnection).addTransceiver("audio",{direction:"recvonly"}),r.addTransceiver("video",{direction:"recvonly"}),e.next=5,r.createOffer();case 5:return n=e.sent,i=pL.parse(n.sdp),this.createAVMlineOfferTpl(n.sdp),o=[],i.media=Hs(t=i.media).call(t,(function(e){if("recvonly"===e.direction){var t="template_".concat(e.type);return e.mid=t,o.push(t),!0}return!1})),i.groups=[{mids:o.join(" "),type:"BUNDLE"}],r.close(),e.abrupt("return",{sdp:pL.write(i),semantics:"unified-plan",type:"incroffer"});case 13:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"rollback",value:(o=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("rollback()"),e.abrupt("return",this.close(r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return o.apply(this,arguments)})},{key:"close",value:(i=Rm(Tm().mark((function e(t,r,n){var i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(eH.print("close()"),i=t.audioMid||r,o=t.videoMid||n,t.audioTransceiver&&i)try{t.audioTransceiver.stop(),delete t.audioTransceiver}catch(c){}if(t.videoTransceiver&&o)try{t.videoTransceiver.stop(),delete t.videoTransceiver}catch(u){}return a=i?this._midMap.get(i):void 0,s=o?this._midMap.get(o):void 0,a&&jL(a),s&&jL(s),i&&a&&this._midMap.set(i,a),o&&s&&this._midMap.set(o,s),e.next=13,this._applyQueue.add();case 13:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return i.apply(this,arguments)})},{key:"setCurrentDescription",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._applyQueue.add();case 2:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"createAVMlineOfferTpl",value:function(e){var t=this;pL.parse(e).media.forEach((function(e){"audio"===e.type&&(t._aRecvonlyOfferTpl=e)}))}},{key:"_generateAllSsrc",value:function(){var e=VL(this._nextSsrc);return this._nextSsrc=e.next,e}},{key:"create",value:(r=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("RTCPeerConnection create"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,Jj(0,"RTCPeerConnection not return SDP"),e.next=8,this.peer.setLocalDescription(r);case 8:return e.abrupt("return",r);case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"apply",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("RTCPeerConnection apply"),e.next=3,this._peerConnection.createOffer();case 3:return t=e.sent,r=t.sdp,Jj(0,"RTCPeerConnection not return SDP"),n=pL.parse(r),r=this.generateOffer(n,r),i=this.generateAnswer(n),e.next=11,this.setLocalDescription(r);case 11:return e.next=13,this.setRemoteDescription(i);case 13:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"generateOffer",value:function(e,t){var r,n,i,o=this,a=!1;"v1"===this.peer.getIceVersion()&&FD&&(e.media=jm(n=e.media).call(n,(function(e){return Zd(Zd({},e),o.peer._offerIce)})),a=!0);null!==(r=this._context)&&void 0!==r&&r.pcKillSwitch.sld_fmtp_opus_add&&(e.media=jm(i=e.media).call(i,(function(e){if("audio"===e.type){var t,r="sendonly"===e.direction;nH.decorateOpusConfig(e,r?null===(t=o._context)||void 0===t?void 0:t.audioProfileManager:void 0)}return e})),a=!0);return a?pL.write(e):t}},{key:"generateAnswer",value:function(e){var t=this,r=[];return e.media.forEach((function(e){if("application"===e.type){Jj(e.mid,"should always have mid in mline");var n=t._midMap.get(e.mid);return n||(n=t.generateDCAnswer(e),t._midMap.set(e.mid,n)),void r.push(Zd({},n))}var i="".concat(e.mid);Jj(0,"No MID in offer m-line: ".concat(e));var o=t._midMap.get(i);o||(eH.print("generateInactiveAnswerMLine","mid: %o, mLine: %o",e.mid,e),o=t.generateInactiveAnswerMLine(e)),r.push(o)})),this.peer.createAnswerSdp(r,e.groups)}},{key:"generateInactiveAnswerMLine",value:function(e){return Zd(Zd(Zd({},e),this.peer._answerIce),{},{direction:"inactive"})}},{key:"generateDCAnswer",value:function(e){var t=Zd(Zd(Zd({},e),this.peer._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}});return FD&&(delete t.bundleOnly,t.port=9),t}},{key:"destroy",value:function(){OI(CI(h.prototype),"destroy",this).call(this),this._pqueue.destroy(),this._applyQueue.destroy(),this._createQueue.destroy()}}]),h}(QL);$j([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(0);case 3:for(r=e.sent,eH.print("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,eH.print("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],rH.prototype,"create",1),$j([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return eH.print("SDP Lock","pending task %o",t),e.next=3,this._pqueue.enqueue(1);case 3:for(r=e.sent,eH.print("SDP Lock","running task %o",t),e.prev=5,i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=9,null==n?void 0:n.apply(this,o);case 9:return e.abrupt("return",e.sent);case 10:return e.prev=10,eH.print("SDP Lock","unlocking by task %o",t),r(),e.finish(10);case 14:case"end":return e.stop()}}),e,this,[[5,,10,14]])}))),r}],rH.prototype,"apply",1);var nH={decorateOpusConfig:function(e,t){var r,n;if(e){var i=null==e?void 0:gE(r=e.rtp).call(r,(function(e){return"opus"===e.codec}));if(i&&e.fmtp){var o=gE(n=e.fmtp).call(n,(function(e){return e.payload===i.payload}));o&&(t&&(o.config=t.getOpusConfigStr(o.config)),o.config=cH(o.config))}}},removeRtxInMLine:function(e){var t,r,n,i;if(e){var o=[];e.rtp=Hs(t=e.rtp).call(t,(function(e){return"rtx"===e.codec&&o.push(e.payload),"rtx"!==e.codec})),e.fmtp=Hs(r=e.fmtp).call(r,(function(e){return mk(o).call(o,e.payload)})),e.payloads=null===(n=e.payloads)||void 0===n?void 0:Hs(i=n.split(" ")).call(i,(function(e){return!mk(o).call(o,uy(e))})).join(" ")}},removeExtSdesMid:function(e){var t;e&&(e.ext=null===(t=e.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"sdes:mid")})))},selectCC:function(e,t){var r,n;if(e)if("tcc"===t)e.ext=null===(r=e.ext)||void 0===r?void 0:Hs(r).call(r,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),e.rtcpFb=null===(n=e.rtcpFb)||void 0===n?void 0:Hs(n).call(n,(function(e){return"goog-remb"!==e.type}));else if("remb"===t){var i,o;e.rtcpFb=null===(i=e.rtcpFb)||void 0===i?void 0:Hs(i).call(i,(function(e){return"transport-cc"!==e.type})),e.ext=null===(o=e.ext)||void 0===o?void 0:Hs(o).call(o,(function(e){var t;return-1===xE(t=e.uri).call(t,"transport")}))}},addRRTR:function(e){e&&e.rtp.forEach((function(t){var r;e.rtcpFb||(e.rtcpFb=[]),gE(r=e.rtcpFb).call(r,(function(e){return e.payload===t.payload&&"rrtr"===e.type}))||e.rtcpFb.push({payload:t.payload,type:"rrtr"})}))},removeRtpStreamId:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){return"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"!==e.uri}))))},decorateSpsPpsIdrInKeyframe:function(e){var t;if(e){var r=Hs(t=e.rtp).call(t,(function(e){return"H264"===e.codec}));r.length&&e.fmtp&&e.fmtp.forEach((function(e){gE(r).call(r,(function(t){return t.payload===e.payload}))&&(e.config+=";sps-pps-idr-in-keyframe=1")}))}},removeExtVideoOrientation:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"video-orientation")}))))},removeExtFramemarking:function(e){var t;e&&(Array.isArray(e.ext)&&(e.ext=Hs(t=e.ext).call(t,(function(e){var t;return!mk(t=e.uri).call(t,"framemarking")}))))}},iH=function(){function e(){Vl(this,e),Jd(this,"queue",[]),Jd(this,"processing",!1)}var t;return Ul(e,[{key:"enqueue",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u=this,d=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=d.length>0&&void 0!==d[0]?d[0]:0,n=oH(),i=n.promise,o=n.resolve,a={priority:r,resolve:o},-1===(s=JR(t=this.queue).call(t,(function(e){return e.priority>r})))?this.queue.push(a):rk(c=this.queue).call(c,s,0,a),this.tryProcess(),e.next=8,i;case 8:return this.processing=!0,e.abrupt("return",(function(){u.processing=!1,u.tryProcess()}));case 10:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.queue.forEach((function(e){(0,e.resolve)()})),this.queue=[],this.processing=!1}},{key:"tryProcess",value:function(){if(!this.processing){var e=this.queue.shift();e&&e.resolve()}}}]),e}();function oH(){var e=void 0,t=void 0,r=new Yf((function(r,n){e=r,t=n}));if(!e||!t)throw Error("Broken Implement of Promise");return{promise:r,resolve:e,reject:t}}var aH,sH,cH=function(e){var t,r={};return e.split(";").forEach((function(e){var t=eI(e.split("="),2),n=t[0],i=t[1];n&&i&&(r[n]=i)})),r["sprop-stereo"]=1,r.stereo=1,jm(t=an(r)).call(t,(function(e){var t;return Om(t="".concat(e,"=")).call(t,r[e])})).join(";")},uH=function(e,t){return e.enableFallbackHandler?new Yj(e,t):e.enableStandardHandler?new rH(e,t):FD?new Wj(e,t):new Kj(e,t)},dH=function(e){return e.streamRemovedBySchedule308="stream removed",e.clientRePublish="client republish",e.publishStreamFaied="publish failed",e.clientUnPublish="client unpublished",e.clientDisconnected="client disconnected",e.videoMuted="video muted",e}(dH||{}),lH=function(e){return e.PushLimitWarn="PushLimitWarn",e}(lH||{}),hH=function(e){return e.ON_ADD_STREAM="onAddStream",e.ON_ADD_STREAM_LIST="onAddStreamList",e.ON_REMOVE_STREAM="onRemoveStream",e.ON_REMOVE_STREAM_LIST="onRemoveStreamList",e.USER_DISCONNECTION="userDisconnection",e.USER_DISCONNECTION_LIST="userDisconnectionList",e.USER_CONNECTION="userConnection",e.USER_CONNECTION_LIST="userConnectionList",e.ON_UPDATE_STREAM_ATTRIBUTES="onUpdateStreamAttributes",e.ON_UPDATE_ROOM_ATTRIBUTES="onUpdateRoomAttributes",e.ON_UPDATE_USER_ATTRIBUTES="onUpdateUserAttributes",e.ON_PUSH_TRACK="onPushTrack",e.ON_REMOVE_TRACK="onRemoveTrack",e.ON_CUSTOM_MESSAGE="onCustomMessage",e.NODE_CHANGE="nodeChange",e.USER_MESSAGE_RECEIVED="userMessageReceived",e.USER_BINARY_MESSAGE_RECEIVED="userBinaryMessageReceived",e.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM="userMessageReceivedOutsideRoom",e.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM="userBinaryMessageReceivedOutsideRoom",e.POST_PROCESSING_MESSAGE="postProcessingMessage",e.ON_USER_TOKEN_WILL_EXPIRE="onUserTokenWillExpire",e.STREAM_CONTROL_MESSAGE="streamControlMessage",e.ON_SPEAKER_CHANGE="onSpeakerChange",e.ON_STREAM_FAILED="streamFailed",e.ON_NOTIFY_RECONNECT="notifyReconnect",e.ON_FORWARD_DST_ROOM_USER_KICK="onForwardDstRoomUserKick",e}(hH||{}),pH=function(e){return e.RSCP="RSCP",e.RTT="RTT",e.SSC="SSC",e}(pH||{}),vH=function(e){return e.ON_CONNECTION_STATE_CHANGE="onConnectionStateChange",e.ON_VENDOR_CONNECTION_STATE_CHANGE="onVendorConnectionStateChange",e.ABNORMAL_DISCONNECTION="normalConnection",e}(vH||{}),_H=function(e){return e.userLeave="userLeave",e.connectionLost="connectionLost",e.userDuplicateLogin="userDuplicateLogin",e.kickedByAdmin="kickedByAdmin",e.roleChanged="roleChanged",e.onUserTokenDidExpire="onUserTokenDidExpire",e}(_H||{}),fH=function(e){return e[e.roomDismissByAdmin=2]="roomDismissByAdmin",e}(fH||{}),mH=new yO("Locker",2),yH=1,gH=function(){function e(t){var r;Vl(this,e),Jd(this,"lockingPromise",Yf.resolve()),Jd(this,"locks",0),Jd(this,"name",""),Jd(this,"lockId",void 0),this.lockId=yH++,t&&(this.name=t),mH.print(Om(r="[lock-".concat(this.name,"-")).call(r,this.lockId,"] is created."))}return Ul(e,[{key:"isLocked",get:function(){return this.locks>0}},{key:"lock",value:function(){var e,t,r,n=this;this.locks+=1,mH.print(Om(e=Om(t="[lock-".concat(this.name,"-")).call(t,this.lockId,"] locked, current queue ")).call(e,this.locks,"."));var i=new Yf((function(e){r=function(){var t,r;n.locks-=1,mH.print(Om(t=Om(r="[lock-".concat(n.name,"-")).call(r,n.lockId,"] unlocked, current queue ")).call(t,n.locks,".")),e()}})),o=this.lockingPromise.then((function(){return r}));return this.lockingPromise=this.lockingPromise.then((function(){return i})),o}}]),e}(),SH=function(e){return e.RESUBSCRIBE="resubscribe",e.STREAM_FAILED="stream_failed",e.SUBSCRIBE_PUSH_TRACK="subscribe_push_track",e.REMOVE_PUSH_TRACK="remove_push_track",e.VIDEO_FIRST_FRAME="video_first_frame",e.ON_USER_PUBLISH_STATE_CHANGE="on_user_publish_state_change",e.ON_USER_START_AUDIO_CAPTURE="on_user_start_audio_capture",e.ON_USER_STOP_AUDIO_CAPTURE="on_user_stop_audio_capture",e.ON_USER_START_VIDEO_CAPTURE="on_user_start_video_capture",e.ON_USER_STOP_VIDEO_CAPTURE="on_user_stop_video_capture",e.ON_SEI_MESSAGED_RECEIVED="on_sei_messaged_received",e.ON_PUBLISH_RESULT="on_publish_result",e.ON_UPDATE_TOKEN_SUCCESS="on_update_token_success",e.ON_REMOTE_STREAM_STATS="ON_REMOTE_STREAM_STATS",e.ON_LOCAL_STREAM_STATS="ON_LOCAL_STREAM_STATS",e.ON_USER_LEAVE="on_user_leave",e.ON_ROOM_ERROR="on_room_error",e.ON_NETWORK_QUALITY="on_network_quality",e.ON_SIMULCAST_SUBSCRIBE_FALLBACK="on_simulcast_subscribe_fallback",e.ON_REMOTE_VIDEO_SIZE_CHANGED="on_remote_video_size_changed",e.RECONNECT_FAILED="reconnect_failed",e.ON_SUBTITLE_STATE_CHANGED="ON_SUBTITLE_STATE_CHANGED",e.ON_SUBTITLE_MESSAGE_RECEIVED="ON_SUBTITLE_MESSAGE_RECEIVED",e.ON_VIDEO_STREAM_BANNED="ON_VIDEO_STREAM_BANNED",e.ON_AUDIO_STREAM_BANNED="ON_AUDIO_STREAM_BANNED",e.ON_FORWARD_STREAM_ERROR="ON_FORWARD_STREAM_ERROR",e.ON_REJOIN_WITH_TCP="ON_REJOIN_WITH_TCP",e.ON_ICE_CONNECT_WITH_TCP="ON_ICE_CONNECT_WITH_TCP",e}(SH||{}),bH=function(e){return e[e.START=1]="START",e[e.START_SUCCESS=2]="START_SUCCESS",e[e.START_FAILED=3]="START_FAILED",e[e.UPDATE=4]="UPDATE",e[e.UPDATE_SUCCESS=5]="UPDATE_SUCCESS",e[e.UPDATE_FAILED=6]="UPDATE_FAILED",e[e.STOP=7]="STOP",e[e.STOP_SUCCESS=8]="STOP_SUCCESS",e[e.STOP_FAILED=9]="STOP_FAILED",e}(bH||{}),EH=function(e){return e[e.PUB=0]="PUB",e[e.UNPUB=1]="UNPUB",e}(EH||{}),kH=function(e){return e[e.SUB=0]="SUB",e[e.UNSUB=1]="UNSUB",e}(kH||{}),TH=(Jd(aH={},bl.communication,[0]),Jd(aH,bl.chat,[0]),Jd(aH,bl.chatRoom,[1,"IES_chatroom"]),Jd(aH,bl.coHost,[1,"IES_PK"]),Jd(aH,bl.meeting,[16]),Jd(aH,bl.classRoom,[0]),aH),IH=iL(),RH=function(e){MI(s,e);var t,r,n,i,o,a=JI(s);function s(e,t){var r;return Vl(this,s),Jd(tI(r=a.call(this,e,t)),"peerConnectionId",oD()),Jd(tI(r),"peerConnectionMode",1),Jd(tI(r),"name","vendor"),Jd(tI(r),"direction","up"),Jd(tI(r),"stream",void 0),t.on("ice_state",(function(e){r._report("rtc_ice_state",{pc_session_id:r.peerConnectionId,direction:r.direction,error_code:0,ice_state:e.toUpperCase(),message:"",peer_connection_id:r.peerConnectionId,stream_id:"",stream_user_id:""})})),r}return Ul(s,[{key:"publish",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.enableSimulcast=!1,this.stream=t,r=OI(CI(s.prototype),"internalPublish",this).call(this,t),n=r.videoDescriptions,i=r.subVideoDescriptions,o=r.audioTransceiverInit,a=r.videoTransceiverInit,t.audioTransceiver=this._peerConnection.addTransceiver(o.track,o.init),t.videoTransceiver=this._peerConnection.addTransceiver(a.track,a.init),IH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"up",stream_id:"",stream_user_id:"",pc_session_id:this.peerConnectionId,vendor_mode:(null==t?void 0:t.vendorCode)||0}),e.next=9,this._peerConnection.createOffer();case 9:return c=e.sent,u=aD(),d=pL.parse(c.sdp),Array.isArray(d.media)&&(d.media=jm(l=d.media).call(l,(function(e){var r,n,i,o,a;if("video"===e.type)null!==(r=p._context)&&void 0!==r&&null!==(n=r.serverConfig)&&void 0!==n&&n.videoCodec&&YL(e,null===(i=p._context)||void 0===i||null===(o=i.serverConfig)||void 0===o?void 0:o.videoCodec),(BD||QD)&&Array.isArray(e.ext)&&(e.ext=Hs(a=e.ext).call(a,(function(e){var t;return!(null!=e&&null!==(t=e.uri)&&void 0!==t&&mk(t).call(t,"video-orientation"))}))),BD||p.addBitrateLimit(e,t.videoEncodeConfig[0].maxKbps);else if("audio"===e.type){var s,c=null==e?void 0:gE(s=e.rtp).call(s,(function(e){return"opus"===e.codec}));if(c&&e.fmtp){var u,d,l=gE(u=e.fmtp).call(u,(function(e){return e.payload===c.payload}));l&&null!==(d=p._context)&&void 0!==d&&d.audioProfileManager&&(l.config=p._context.audioProfileManager.getOpusConfigStr(l.config))}}return e}))),h=new RTCSessionDescription({type:"offer",sdp:pL.write(d)}),e.prev=14,e.next=17,this._peerConnection.setLocalDescription(h);case 17:this._report("rtc_set_description",{error_code:0,message:h.sdp||"",is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:aD()-u},{type:"offer"}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(14),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+h.sdp,is_local:"1",direction:"up",stream_id:"",stream_user_id:"",elapse:aD()-u},{type:"offer"}),e.t0;case 24:return e.abrupt("return",{partialSdp:h.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",videoDescriptions:n,subVideoDescriptions:i,audioTransceiverInit:o,videoTransceiverInit:a,peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 25:case"end":return e.stop()}}),e,this,[[14,20]])}))),function(e){return o.apply(this,arguments)})},{key:"subscribe",value:(i=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stream=t,this.direction="down",t.audioTransceiver=this._peerConnection.addTransceiver("audio",{direction:"recvonly"}),t.videoTransceiver=this._peerConnection.addTransceiver("video",{direction:"recvonly"}),IH&&(t.initAudioEncodedTransform(),t.initVideoEncodedTransform()),this._report("rtc_begin_create_offer",{direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:this.peerConnectionId,vendor_mode:t.vendorCode||0}),e.next=8,this._peerConnection.createOffer();case 8:return r=e.sent,n=aD(),i=pL.parse(r.sdp),Array.isArray(i.media)&&(i.media=jm(o=i.media).call(o,(function(e){if("audio"===e.type){var t,r=null==e?void 0:gE(t=e.rtp).call(t,(function(e){return"opus"===e.codec}));if(r&&null!=e&&e.fmtp){var n,i=null==e?void 0:gE(n=e.fmtp).call(n,(function(e){return e.payload===r.payload}));i&&s._context&&(i.config+=";stereo=1;sprop-stereo=1")}}return e}))),a=new RTCSessionDescription({type:"offer",sdp:pL.write(i)}),e.prev=13,e.next=16,this._peerConnection.setLocalDescription(a);case 16:this._report("rtc_set_description",{error_code:0,message:a.sdp||"",is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-n},{type:"offer"}),e.next=23;break;case 19:throw e.prev=19,e.t0=e.catch(13),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+a.sdp,is_local:"1",direction:"down",stream_id:t.streamId,stream_user_id:t.userId,elapse:aD()-n},{type:"offer"}),e.t0;case 23:return e.abrupt("return",{partialSdp:a.sdp||"",audioMid:"0",videoMid:"1",type:"offer",semantics:"unified-plan",peerConnectionMode:this.peerConnectionMode,peerConnectionId:this.peerConnectionId});case 24:case"end":return e.stop()}}),e,this,[[13,19]])}))),function(e){return i.apply(this,arguments)})},{key:"handleAck",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.action!==iF.publish&&t.action!==iF.subscribe){e.next=16;break}return n=new RTCSessionDescription({sdp:null===(r=t.signalingAck)||void 0===r?void 0:r.sdp,type:"answer"}),i=aD(),e.prev=3,e.next=6,this._peerConnection.setRemoteDescription(n);case 6:this._report("rtc_set_description",{error_code:0,message:n.sdp||"",is_local:"1",direction:"down",stream_id:null===(o=t.stream)||void 0===o?void 0:o.userId,stream_user_id:(null===(a=t.stream)||void 0===a?void 0:a.streamId)||"",elapse:aD()-i},{type:"answer"}),e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(3),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+n.sdp,is_local:"1",direction:"down",stream_id:null===(s=t.stream)||void 0===s?void 0:s.userId,stream_user_id:(null===(c=t.stream)||void 0===c?void 0:c.streamId)||"",elapse:aD()-i},{type:"offer"}),e.t0;case 13:"function"==typeof t.onSuccess&&t.onSuccess(),e.next=17;break;case 16:t.action!==iF.unpublish&&t.action!==iF.unsubscribe||this.destroy();case 17:return e.abrupt("return","");case 18:case"end":return e.stop()}}),e,this,[[3,9]])}))),function(e){return n.apply(this,arguments)})},{key:"destroy",value:function(){this.peer.destroy(),OI(CI(s.prototype),"destroy",this).call(this)}},{key:"getDefaultSdp",value:(r=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{sdp:"",type:"offer",semantics:""});case 1:case"end":return e.stop()}}),e)}))),function(){return r.apply(this,arguments)})},{key:"connect",value:function(){throw new Error("Method not implemented.")}},{key:"rollback",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:try{this._peerConnection.close()}catch(t){}case 1:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),s}(QL),AH=function(e){return e[e.AUTOPLAY_FAILED=-1e3]="AUTOPLAY_FAILED",e[e.TRACK_ERROR=-1001]="TRACK_ERROR",e[e.Fetch_MODIFY=-1002]="Fetch_MODIFY",e[e.BLACK_BROWSER=-1003]="BLACK_BROWSER",e}(AH||{}),wH={start_interval:100,multiplier:2,max_interval:3e4},CH=function(){function e(){Vl(this,e),Jd(this,"_times",0),Jd(this,"_config",wH),Jd(this,"initTs",aD())}return Ul(e,[{key:"getRetryDelay",value:function(){return Math.min(this._config.max_interval,Math.pow(this._config.multiplier,this._times++)*this._config.start_interval)}},{key:"setConfig",value:function(e){this._config=e}},{key:"reset",value:function(){this._times=0}}]),e}(),xH=new yO("ICERequest",4),OH=function(){function e(t){Vl(this,e),Jd(this,"_reconnectTimer",void 0),Jd(this,"_abortControllers",[]),Jd(this,"_monitor",void 0),Jd(this,"_groupConfigId",oD()),Jd(this,"_retryLimiter",new CH),Jd(this,"_timer",void 0),this._ctx=t,this._monitor=MO(t.id)}var t,r,n,i,o;return Ul(e,[{key:"getICENode",value:(o=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return xH.print("getICENode","invoke"),e.prev=1,e.next=4,this._getAccessWithRetry(t);case 4:if(0!==(r=e.sent).length){e.next=7;break}throw"server return empty nodes.";case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(1),this._reportRtcInvokeStatus("es.join.getNodeFailed",e.t0),new vA(hA.ICE_SERVER_WRONG,"get ICE config failed: ".concat(e.t0),e.t0);case 13:return xH.print("getICENode","success"),this._reportRtcInvokeStatus("es.join.getNodeSuccess",r),e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return o.apply(this,arguments)})},{key:"_getAccessWithRetry",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==r&&xH.print("_getAccessWithRetry()","invoke feedbackInfo: %o, 201count: %o",e,r),new Yf((function(n,i){t._getAccessNode(e).then((function(e){t._retryLimiter.reset(),n(e)})).catch((function(o){if(Array.isArray(o)&&o.length>0){if(JR(o).call(o,(function(e){return 400<=e.code&&e.code<500}))>-1)return t._retryLimiter.reset(),i("HTTP request failed(4xx)");if(o.every((function(e){var t;return 201===e.code||201===(null===(t=e.error)||void 0===t?void 0:t.code)}))&&r++,3===r)return t._retryLimiter.reset(),i("HTTP request failed(201)")}var a=t._retryLimiter.getRetryDelay();xH.print("_getAccessWithRetry()","_getAccessWithRetry error, will retry after ".concat(a,"ms"),o),t._reconnectTimer=self.setTimeout((function(){t._getAccessWithRetry(e,r).then(n).catch(i)}),a)}))}))}},{key:"_getAccessNode",value:(i=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,n){var i=mM.getAccessNode(r._ctx.appId);i?(xH.print("getAccessNode","use cache node."),e(Array.isArray(i)?i:[i]),r._timer=window.setTimeout((function(){r._getAccessNodeFromServer(t),r._reportRtcInvokeStatus("es.R.node.cache",i),delete r._timer}),0)):r._getAccessNodeFromServer(t).then(e).catch(n)})));case 1:case"end":return e.stop()}}),e)}))),function(e){return i.apply(this,arguments)})},{key:"_getAccessNodeFromServer",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=this._getAccessUrls(),n=r.urls,i=r.needFallback,e.abrupt("return",this.getICEConfigFromServer(n,t).then((function(e){var t=e.nodes;return!o._ctx.useCloudProxy&&mM.setAccessNode(o._ctx.appId,t,e.ttl||11200),e.dispatchDomains&&!o._ctx.useCloudProxy&&mM.setAccessUrls(e.dispatchDomains),t})).catch((function(e){if(i)return o._reportRtcInvokeStatus("es.R.req.fallback",""),mM.clearAccessUrls(),o._getAccessNodeFromServer(t);throw e})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_getAccessUrls",value:function(){var e=mM.getAccessUrls()||[],t=!0;return this._reportRtcInvokeStatus("es.R.req.cache.urls",e),0===e.length&&(e=TM.ICE_CONFIG_REQUEST_URLS,t=!1,this._reportRtcInvokeStatus("es.R.req.external.urls",e)),0===e.length&&(e=TM.ICE_CONFIG_REQUEST_URLS_INTERNAL,t=!1,this._reportRtcInvokeStatus("es.R.req.internal.urls",e)),{urls:e,needFallback:t}}},{key:"getICEConfigFromServer",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={appID:this._ctx.appId,deviceID:mM.getDeviceId(),os:"web",sdkVersion:TM.VERSION,isOversea:TM.OVERSEA,expectedAddr:RM("EXPECTED_ADDR"),productPlatform:"BytePlus",enableCloudProxy:this._ctx.useCloudProxy,expectedIDC:this._ctx.expectedIDC,accessParams:Nm({requireICEUfragV2:!0}),userAgent:navigator.userAgent},r&&(n.feedbackInfo=r,"ICE_FAILED"!==(null===(i=r[0])||void 0===i||null===(o=i.feedbackReason)||void 0===o?void 0:o.type)&&delete n.expectedAddr),a=jm(t).call(t,(function(e){return s._httpRequest(e,n)})),e.abrupt("return",bD(a));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_httpRequest",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=oD(),r.connectSessionID=i,o=Date.now(),null===(n=this._monitor)||void 0===n||n.report("rtc_get_access",{error_code:0,message:Nm(r),elapse:0,type:"request",host:t,config_id:i,group_config_id:this._groupConfigId}),a=new AbortController,this._abortControllers.push(a),e.prev=6,e.prev=7,e.next=10,fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:Nm(r),signal:a.signal});case 10:s=e.sent,e.next=17;break;case 13:throw e.prev=13,e.t0=e.catch(7),sw(fetch)||null===(d=this._monitor)||void 0===d||d.report("rtc_error",{error_code:AH.Fetch_MODIFY,message:"get access failed, possibly due to modifying the browser's Fetch API."},{origin_error:e.t0}),e.t0;case 17:if(this._abortControllers=Hs(c=this._abortControllers).call(c,(function(e){return e!==a})),200===s.status){e.next=20;break}throw{message:s.statusText,code:s.status};case 20:return e.next=22,s.json();case 22:if(200===(l=e.sent).code){e.next=25;break}throw l;case 25:return null===(u=this._monitor)||void 0===u||u.report("rtc_get_access",{error_code:200,message:Nm(l),elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId}),e.abrupt("return",l);case 29:throw e.prev=29,e.t1=e.catch(6),null===(h=this._monitor)||void 0===h||h.report("rtc_get_access",{error_code:Number((null===e.t1||void 0===e.t1?void 0:e.t1.code)||(null===e.t1||void 0===e.t1?void 0:e.t1.server_code)),message:null===e.t1||void 0===e.t1?void 0:e.t1.message,elapse:Date.now()-o,type:"response",host:t,config_id:i,group_config_id:this._groupConfigId},{error:Nm(e.t1)}),e.t1;case 33:case"end":return e.stop()}}),e,this,[[6,29],[7,13]])}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this._abortControllers.forEach((function(e){return e.abort()})),this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer),this._timer&&(window.clearTimeout(this._timer),delete this._timer)}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null===(r=this._monitor)||void 0===r||r.report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:n,stream_id:"",elapse:0,group_config_id:this._groupConfigId},i)}}]),e}(),DH=iL(),MH={iceServers:[],iceTransportPolicy:"all",bundlePolicy:"max-bundle",rtcpMuxPolicy:"require"},PH=function(e){return e[e.DC_ERROR=0]="DC_ERROR",e[e.DC_CLOSE=1]="DC_CLOSE",e[e.ICE_FAILED=2]="ICE_FAILED",e[e.DESTROY=3]="DESTROY",e[e.TIMEOUT=4]="TIMEOUT",e}(PH||{}),NH=0,LH=function(e){MI(c,e);var t,r,n,i,o,a,s=JI(c);function c(e,t){var r;return Vl(this,c),Jd(tI(r=s.call(this)),"uuid",(NH++).toString()),Jd(tI(r),"_peerConnectionId",""),Jd(tI(r),"audioTrack4ff",void 0),Jd(tI(r),"_pc",void 0),Jd(tI(r),"_dc",void 0),Jd(tI(r),"_iceNode",void 0),Jd(tI(r),"_initSctpEvents",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_offerIce",{}),Jd(tI(r),"_answerIce",{}),Jd(tI(r),"_offerSession",void 0),Jd(tI(r),"_answerSession",void 0),Jd(tI(r),"_offerMlines",[]),Jd(tI(r),"_answerMlines",[]),Jd(tI(r),"_connectReject",void 0),Jd(tI(r),"_logger",new yO("PeerConnection_".concat(r.uuid),4)),Jd(tI(r),"_peerConfig",void 0),r._ctx=e,r._groupConnectionId=t,r._monitor=MO(e.id),r._ctx.enableFallbackHandler&&r._logger.print("ctor","PeerConnection running in fallback mode"),r._peerConfig=UH(e),r._pc=new RTCPeerConnection(r._peerConfig),r._pc.ontrack=function(e){var t,n,i,o,a=null===(t=e.streams)||void 0===t||null===(n=t[0])||void 0===n?void 0:n.id;r._print("pc.ontrack",Om(i=Om(o="".concat(e.track.kind," ")).call(o,e.track.id," ")).call(i,a)),"ff-stream"===a&&(r.audioTrack4ff=e.track),r.emit("ontrack",e)},r._pc.onconnectionstatechange=function(e){var t;r._print("onconnectionstatechange",Om(t="".concat(r._pc.connectionState,". ice -> ")).call(t,r._pc.iceConnectionState)),"failed"!==r._pc.iceConnectionState&&"closed"!==r._pc.iceConnectionState&&"failed"!==r._pc.connectionState||r.emit("disconnect","ice failed")},r._pc.oniceconnectionstatechange=function(){var e=r._pc.iceConnectionState;r._report("rtc_pre_ice_state",{message:e,ice_state:e.toUpperCase()}),r.emit("ice_state",e)},r}return Ul(c,[{key:"getOriginRTCPeerConnection",value:function(){return this._pc}},{key:"getOriginRTCDataChannel",value:function(){return this._dc}},{key:"getConnectionId",value:function(){return this._peerConnectionId}},{key:"getGroupConnectionId",value:function(){return this._groupConnectionId}},{key:"connect",value:(a=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._ctx.enableStandardHandler){e.next=2;break}return e.abrupt("return",this.startIceConnectStandard(t));case 2:return this._print("connect","invoke. %o",t),this._iceNode=t,this._dc=this._pc.createDataChannel("signaling",{negotiated:!0,id:100}),this._dc.binaryType="arraybuffer",e.next=8,this._genIceInfo(t);case 8:return r=e.sent,n=r.offerIce,i=r.answerIce,this._offerIce=n,this._answerIce=i,FD&&iM<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=16,this._pc.createOffer();case 16:if((o=e.sent).sdp){e.next=19;break}throw new vA(hA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(a=pL.parse(o.sdp),this._peerConnectionId=i.iceUfrag||"",(s=!n.iceUfrag&&!n.icePwd)&&((l="renomination"===(null===(c=a.media[0])||void 0===c?void 0:c.iceOptions))||(delete n.iceOptions,delete i.iceOptions),delete n.iceUfrag,delete n.icePwd,h=qL({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null===(u=a.media[0])||void 0===u?void 0:u.icePwd,options:(d={},Jd(d,WL.kICEConfigTypeSrtpDtlsType,!0),Jd(d,WL.kICEConfigTypeRenominationType,l),d)}),p=eI(h,2),v=p[0],_=p[1],this._peerConnectionId=_,i.iceUfrag=v,this._logger.print("use serverUfrag v2",Nm({dtls:!0,renomination:l}))),f=eI(a.media,1),m=f[0],this._offerIce.fingerprint=a.fingerprint||m.fingerprint,!FD&&!this._ctx.enableFallbackHandler){e.next=41;break}if(a.media=jm(y=a.media).call(y,(function(e){var t,r,n=Zd(Zd({},e),b._offerIce);return"video"===n.type&&(n.ext=null===(t=n.ext)||void 0===t?void 0:Hs(t).call(t,(function(e){var t;return-1===xE(t=e.uri).call(t,"abs-send-time")})),n.rtcpFb=null===(r=n.rtcpFb)||void 0===r?void 0:Hs(r).call(r,(function(e){return"goog-remb"!==e.type}))),n})),(S=Zd({},a)).fingerprint=this._answerIce.fingerprint,S.media=jm(g=S.media).call(g,(function(e){return delete(e=Zd(Zd({},e),b._answerIce)).bundleOnly,e.port=9,"application"===e.type?e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}:("audio"===e.type&&(e.msid="ff-stream ff-stream-audio"),e.direction="sendonly"),e})),!this._ctx.enableFallbackHandler){e.next=35;break}return e.next=33,this.setLocalDescription(o.sdp);case 33:e.next=37;break;case 35:return e.next=37,this.setLocalDescription(pL.write(a));case 37:return e.next=39,this.setRemoteDescription(pL.write(S));case 39:e.next=50;break;case 41:delete a.media,this._offerSession=Zd({},a),this._answerSession=Zd({},a),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),s&&(this._offerIce.iceUfrag=m.iceUfrag,this._offerIce.icePwd=m.icePwd),this._offerMlines=[Zd(Zd(Zd({},m),this._offerIce),{},{mid:"".concat(0)})],this._answerMlines=[Zd(Zd(Zd({},m),this._answerIce),{},{sctpmap:{sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144},mid:"".concat(0)})],this.setDescription();case 50:return e.next=52,new Yf((function(e,t){b._connectReject=t,b._dc.onopen=function(){b._print("connect","dataChannel open"),b._reportRtcInvokeStatus("es.dc.open",""),e(""),delete b._connectReject},b._dc.onerror=function(e){var t,r;b._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),b._reportRtcInvokeStatus("es.dc.error",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),b.emit("disconnect","dc onerror"),delete b._connectReject},b._dc.onclose=function(e){var t;b._reportRtcInvokeStatus("es.dc.close",""),null===(t=b._connectReject)||void 0===t||t.call(b,{message:"dc.onclose",code:1}),b.emit("disconnect","dc onclose"),delete b._connectReject},b._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==b._pc.iceConnectionState&&"closed"!==b._pc.iceConnectionState&&"failed"!==b._pc.connectionState||(null===(t=b._connectReject)||void 0===t||t.call(b,{message:Om(r="pc.connectionstatechange -> ".concat(b._pc.connectionState,", ice -> ")).call(r,b._pc.iceConnectionState),code:2}),delete b._connectReject)})),setTimeout((function(){var e;null===(e=b._connectReject)||void 0===e||e.call(b,{code:4,message:"connect timeout"}),delete b._connectReject}),8e3)}));case 52:return this._print("connect","dataChannel establish success"),e.abrupt("return",this._dc);case 54:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"startIceConnectStandard",value:(o=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("connect","standard invoke. %o",t),this._iceNode=t,(i=this._pc.createDataChannel("signaling",{negotiated:!0,id:100})).binaryType="arraybuffer",this._dc=i,e.next=7,this._genIceInfo(t);case 7:return o=e.sent,a=o.offerIce,s=o.answerIce,this._offerIce=a,this._answerIce=s,FD&&iM<138&&(this._pc.addTransceiver("audio",{direction:"recvonly"}),this._pc.addTransceiver("video",{direction:"recvonly"})),e.next=15,this._pc.createOffer();case 15:if(c=e.sent,u=c.sdp){e.next=19;break}throw new vA(hA.NOT_SUPPORTED,"create offer sdp failed.");case 19:if(d=pL.parse(u),this._answerSession=Zd({},d),this._answerSession.fingerprint&&(this._answerSession.fingerprint=this._answerIce.fingerprint),l=gE(r=d.media).call(r,(function(e){return"application"===e.type})),this._peerConnectionId=s.iceUfrag||"",!a.iceUfrag&&!a.icePwd&&((p="renomination"===(null==l?void 0:l.iceOptions))||(delete a.iceOptions,delete s.iceOptions),delete a.iceUfrag,delete a.icePwd,v=qL({serverUfrag:t.iceParams.serverIceUfrag,serverPwd:t.iceParams.serverIcePwd,clientPwd:null==l?void 0:l.icePwd,options:(h={},Jd(h,WL.kICEConfigTypeSrtpDtlsType,!0),Jd(h,WL.kICEConfigTypeRenominationType,p),h)}),_=eI(v,2),f=_[0],m=_[1],this._peerConnectionId=m,s.iceUfrag=f,this._logger.print("use serverUfrag v2",Nm({dtls:!0,renomination:p}))),this._offerIce.fingerprint=d.fingerprint||l.fingerprint,(y=Zd({},d)).fingerprint=this._answerIce.fingerprint,y.media=jm(n=y.media).call(n,(function(e){return"application"===(e=Zd(Zd({},e),S._answerIce)).type&&(e.sctpmap={sctpmapNumber:5e3,app:"webrtc-datachannel",maxMessageSize:262144}),FD&&(delete e.bundleOnly,e.port=9,"audio"===e.type?(e.msid="ff-stream ff-stream-audio",e.direction="sendonly"):"video"===e.type&&(e.direction="sendonly")),e})),"v1"!==this.getIceVersion()){e.next=36;break}return d.media=jm(g=d.media).call(g,(function(e){return e=Zd(Zd({},e),S._offerIce)})),e.next=34,this.setLocalDescription(pL.write(d));case 34:e.next=38;break;case 36:return e.next=38,this.setLocalDescription(u);case 38:return e.next=40,this.setRemoteDescription(pL.write(y));case 40:return e.next=42,new Yf((function(e,t){S._connectReject=t,S._dc.onopen=function(){S._print("connect","dataChannel open"),S._reportRtcInvokeStatus("es.dc.open",""),e(""),delete S._connectReject},S._dc.onerror=function(e){var t,r;S._report("rtc_signaling_msg_error",{error_code:e.error.sdpLineNumber,message:e.error.errorDetail,reason:"invalid data"}),S._reportRtcInvokeStatus("es.dc.error",""),null===(t=S._connectReject)||void 0===t||t.call(S,{message:"dc.onerror, ".concat(null===(r=e.error)||void 0===r?void 0:r.errorDetail),code:0}),S.emit("disconnect","dc onerror"),delete S._connectReject},S._dc.onclose=function(e){var t;S._reportRtcInvokeStatus("es.dc.close",""),null===(t=S._connectReject)||void 0===t||t.call(S,{message:"dc.onclose",code:1}),S.emit("disconnect","dc onclose"),delete S._connectReject},S._pc.addEventListener("connectionstatechange",(function(e){var t,r;"failed"!==S._pc.iceConnectionState&&"closed"!==S._pc.iceConnectionState&&"failed"!==S._pc.connectionState||(null===(t=S._connectReject)||void 0===t||t.call(S,{message:Om(r="pc.connectionstatechange -> ".concat(S._pc.connectionState,", ice -> ")).call(r,S._pc.iceConnectionState),code:2}),delete S._connectReject)})),setTimeout((function(){var e;null===(e=S._connectReject)||void 0===e||e.call(S,{code:4,message:"connect timeout"}),delete S._connectReject}),8e3)}));case 42:return this._print("connect","dataChannel establish success"),e.abrupt("return",i);case 44:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"setDescription",value:(i=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._print("setDescription","invoke."),this._offerSession.media=this._offerMlines,this._answerSession.media=this._answerMlines,r=[],this._offerMlines.forEach((function(e){"inactive"!==e.direction&&r.push(e.mid)})),this._offerSession.groups&&this._answerSession.groups&&(this._offerSession.groups[0].mids=r.join(" "),this._answerSession.groups[0].mids=r.join(" ")),n=aD(),t&&this._report("rtc_begin_create_offer",{direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,pc_session_id:this._peerConnectionId,vendor_mode:0}),t&&this._report("rtc_create_offer",{error_code:0,direction:"local"===t.streamUserId?"up":"down",stream_id:t.streamId,stream_user_id:t.streamUserId,elapse:aD()-n}),e.next=11,this.setLocalDescription(pL.write(this._offerSession),t);case 11:return e.next=13,this.setRemoteDescription(pL.write(this._answerSession),t);case 13:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"setLocalDescription",value:(n=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=aD(),e.prev=1,e.next=4,this._pc.setLocalDescription({type:"offer",sdp:t});case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"offer"}),this._initSctpEvents||(this._initSctpEvents=!0,(o=null===(i=this._pc)||void 0===i?void 0:i.sctp)&&(o.onstatechange=function(){a._reportRtcInvokeStatus("sctp","sctp state change TO: ".concat(o.state))},o.transport&&(o.transport.onstatechange=function(){var e;a._reportRtcInvokeStatus("dtls","dtls state change TO: ".concat(null==o||null===(e=o.transport)||void 0===e?void 0:e.state))}))),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("setLocal",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"1",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:"",stream_user_id:"",elapse:aD()-n},{type:"offer"});case 12:case"end":return e.stop()}}),e,this,[[1,8]])}))),function(e,t){return n.apply(this,arguments)})},{key:"setRemoteDescription",value:(r=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=aD(),e.prev=1,e.next=4,this._pc.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:t}));case 4:this._report("rtc_set_description",{error_code:0,message:t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"answer"}),e.next=11;break;case 7:e.prev=7,e.t0=e.catch(1),console.error("setRemote",e.t0),this._report("rtc_set_description",{error_code:-1,message:e.t0.message+t,is_local:"0",direction:"local"===(null==r?void 0:r.streamUserId)?"up":"down",stream_id:(null==r?void 0:r.streamId)||"",stream_user_id:(null==r?void 0:r.streamUserId)||"",elapse:aD()-n},{type:"answer"});case 11:case"end":return e.stop()}}),e,this,[[1,7]])}))),function(e,t){return r.apply(this,arguments)})},{key:"disconnect",value:function(){var e,t;null===(e=this._connectReject)||void 0===e||e.call(this,{code:3,message:"invoke destroy()"}),delete this._connectReject,this._pc.close(),null===(t=this._dc)||void 0===t||t.close(),this._pc.ontrack=null}},{key:"getIceVersion",value:function(){var e,t;return null!==(e=this._iceNode)&&void 0!==e&&e.iceParams.clientIceUfrag||null!==(t=this._iceNode)&&void 0!==t&&t.iceParams.clientIcePwd?"v1":"v2"}},{key:"createAnswerSdp",value:function(e,t){Jj(this._answerSession,"_answerSession should be existed");var r=Zd({},this._answerSession);return r.media=e,r.groups=t,pL.write(r)}},{key:"destroy",value:function(){this._print("destroy",this._peerConnectionId),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.disconnect()}},{key:"_genIceInfo",value:(t=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i={iceUfrag:null===(r=t.iceParams)||void 0===r?void 0:r.clientIceUfrag,icePwd:null===(n=t.iceParams)||void 0===n?void 0:n.clientIcePwd,iceOptions:"renomination"},e.next=3,GL(t);case 3:return o=e.sent,e.abrupt("return",{offerIce:i,answerIce:o});case 5:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"_print",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];(t=this._logger).print.apply(t,Om(r=["".concat(e)]).call(r,i))}},{key:"_report",value:function(e,t,r){var n,i,o,a;null===(n=this._monitor)||void 0===n||n.report(e,Zd(Zd({},t),{},{connection_id:this._peerConnectionId,group_connection_id:this._groupConnectionId}),Zd(Zd({},r),{},{tcp_only:null===(i=this._iceNode)||void 0===i?void 0:i.iceConfig.tcpOnly,ms_addr:Nm((null===(o=this._iceNode)||void 0===o?void 0:jm(a=o.publicIPs).call(a,(function(e){return{ip:e.ip,tcp:e.tcpPorts,udp:e.udpPorts}})))||[])}))}},{key:"_reportRtcInvokeStatus",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",i=arguments.length>4?arguments[4]:void 0;this._report("rtc_invoke_status",{sdk_api_name:e,message:t,error_code:r,stream_id:n,elapse:0},i)}}],[{key:"checkSupported",value:function(){if(!RTCPeerConnection)throw new vA(hA.NOT_SUPPORTED,"missing RTCPeerConnection API.");["addTransceiver","createDataChannel","createOffer","setLocalDescription","setRemoteDescription"].forEach((function(e){var t,r;if(null===(t=RTCPeerConnection)||void 0===t||null===(r=t.prototype)||void 0===r||!r[e])throw new vA(hA.NOT_SUPPORTED,"missing peer.".concat(e," API."))}))}}]),c}(tP),UH=function(e){var t=Zd({},MH);return e.pcKillSwitch.ctor_sdpsemantics_add&&(t.sdpSemantics="unified-plan"),e.pcKillSwitch.ctor_encodedinsetablestream_add&&DH&&!RM("DISABLE_ENCODED_TRANSFORM")&&(t.encodedInsertableStreams=!0),t};function VH(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=an(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||(i[r]=e[r]);return i}(e,t);if(xs){var o=xs(e);for(n=0;n<o.length;n++)r=o[n],xE(t).call(t,r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var FH=function(e){return e[e.SEND=0]="SEND",e[e.FEEDBACK=1]="FEEDBACK",e}(FH||{}),BH=function(e){return e[e.P2P=0]="P2P",e[e.SIGNAL=1]="SIGNAL",e[e.BROADCAST=2]="BROADCAST",e[e.BUSINESS_SERVER=3]="BUSINESS_SERVER",e}(BH||{}),jH=function(e){return e[e.SUCCESS=0]="SUCCESS",e[e.TIMEOUT=1]="TIMEOUT",e[e.BROKEN=2]="BROKEN",e[e.NO_RECEIVER=3]="NO_RECEIVER",e[e.NO_RELAYPATH=4]="NO_RELAYPATH",e[e.EXCEED_QPS=5]="EXCEED_QPS",e[e.SEND_TO_SERVER_ERROR=17]="SEND_TO_SERVER_ERROR",e[e.SERVER_RESPONSE_ERROR=18]="SERVER_RESPONSE_ERROR",e[e.NOT_JOIN=100]="NOT_JOIN",e[e.NOT_LOGIN=105]="NOT_LOGIN",e[e.SERVER_PARAMS_NOTSET=106]="SERVER_PARAMS_NOTSET",e[e.UNKNOWN=1e3]="UNKNOWN",e}(jH||{}),HH=(Jd(sH={},0,[0,"success"]),Jd(sH,1,[hA.USER_MESSAGE_TIMEOUT,"timeout, failed to send."]),Jd(sH,2,[hA.USER_MESSAGE_BROKEN,"dataChannel broken, failed to send."]),Jd(sH,3,[hA.USER_MESSAGE_NO_RECEIVER,"cannot find the receiver."]),Jd(sH,4,[hA.USER_MESSAGE_NO_RECEIVER,"cannot find relay path."]),Jd(sH,5,[hA.USER_MESSAGE_EXCEED_QPS,"cannot find relay path."]),Jd(sH,17,[hA.USER_MESSAGE_SEND_TO_SERVER_ERROR,"failed to send to business server."]),Jd(sH,18,[hA.USER_MESSAGE_SERVER_RESPONSE_ERROR,"business server response error."]),Jd(sH,100,[hA.USER_MESSAGE_NOT_JOIN,"not join room"]),Jd(sH,105,[hA.USER_MESSAGE_NOT_LOGIN,"not login."]),Jd(sH,106,[hA.USER_MESSAGE_SERVER_PARAMS_NOTSET,"server param is not set."]),Jd(sH,1e3,[hA.USER_MESSAGE_UNKNOWN,"unknown."]),sH),GH=["msg"],zH=new yO("DataChannelSignaling",3),KH=[],XH=function(e){return e[e.C2S=0]="C2S",e[e.C2C=1]="C2C",e[e.C2GW=2]="C2GW",e[e.C2CDirect=3]="C2CDirect",e[e.C2RTM=4]="C2RTM",e}(XH||{}),WH=function(e){MI(a,e);var t,r,n,i,o=JI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_singlingCache",new $S),Jd(tI(r),"_p2pCache",new $S),Jd(tI(r),"_rttIds",{}),Jd(tI(r),"_p2pMessageId",1),Jd(tI(r),"_clearDataChannelListener",void 0),Jd(tI(r),"_monitor",void 0),r.id=e,r._dataChannel=t,r._clearDataChannelListener=r._handleHandler(),r._monitor=MO(e),r}return Ul(a,[{key:"destroy",value:function(){var e=this;this._dataChannel&&(this._clearDataChannelListener(),this._dataChannel.close()),this._singlingCache.forEach((function(t,r){t.error(new vA(hA.OPERATION_CANCEL,"disconnect")),e._singlingCache.delete(r)})),this._singlingCache.clear(),this._p2pCache.clear(),this._p2pMessageId=1,this._rttIds={}}},{key:"sendSignaling",value:function(e,t,r){var n,i=this,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:6e4;return null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:Nm(t),signaling_event:"call-".concat(e),signaling_type:"Send",stream_id:t.streamId,stream_user_id:t.streamUserId,direction:"up"}),new Yf((function(n,a){var s,c=i._genHeader(r);c.id=uD();var u=c.id.join("-"),d="customMessage"===e;d&&kO.samplingOne2ManyMsg(i.id,+c.id.join(""),t);var l=setTimeout((function(){i._singlingCache.delete(u),a(new vA(hA.TIME_OUT,"".concat(e," message time out"))),d&&kO.updateOne2ManyMsgAck(i.id,t,999)}),o);i._singlingCache.set(u,{signalingType:e,success:function(e){clearTimeout(l),n(e),d&&kO.updateOne2ManyMsgAck(i.id,t,0)},error:function(e){clearTimeout(l),a(e),d&&kO.updateOne2ManyMsgAck(i.id,t,e.code)}}),zH.print("Signal",Om(s=">>>>>> [".concat(e,"][")).call(s,u,"]"),t),i._sendMessage(e,c,t)}))}},{key:"sendPingSignaling",value:function(){return this.sendSignaling("CheckConnectivity",{ts:Date.now()},{functionType:2})}},{key:"sendP2PMessage",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.msg,i=VH(t,GH),o=n instanceof ArrayBuffer,e.t0=this,e.t1=kO,e.t2=this.id,e.t3=Zd,e.t4=Zd({ver:1,id:this._p2pMessageId++,time:Date.now(),dir:FH.SEND,type:BH.P2P,err:jH.SUCCESS},i),e.t5={},e.t6=o,!o){e.next=15;break}return e.next=12,cD.ab2b64str(n);case 12:e.t7=e.sent,e.next=16;break;case 15:e.t7=n;case 16:return e.t8=e.t7,e.t9={binary:e.t6,msg:e.t8},e.t10=(0,e.t3)(e.t4,e.t5,e.t9),e.t11=e.t1.samplingP2PMsg.call(e.t1,e.t2,e.t10),e.t12=r,e.abrupt("return",e.t0._sendP2PMessage.call(e.t0,e.t11,e.t12));case 22:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"_sendP2PMessage",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return lD(e.msg)?this._rttIds[e.id]=e.id:e.dir===FH.SEND&&zH.print("_sendP2PMessage [DC Signaling p2p >>]",Nm(e)),new Yf((function(n,i){var o=t._genHeader(Zd(Zd({needAck:!0,functionType:1},r),{},{id:uD()}));if(e.dir===FH.SEND){var a=setTimeout((function(){t._p2pCache.delete(e.id),i(new vA(hA.USER_MESSAGE_TIMEOUT,"P2P message timeout")),kO.updateP2PMsgAck(t.id,e,999)}),12e3);t._p2pCache.set(e.id,{success:function(r,i){clearTimeout(a),n(i),kO.updateP2PMsgAck(t.id,e,0)},error:function(r){var n;clearTimeout(a),kO.updateP2PMsgAck(t.id,e,r.err);var o=eI(HH[r.err]||[hA.USER_MESSAGE_UNKNOWN,Om(n="err: ".concat(r.err,", msg: ")).call(n,r.msg)],2),s=o[0],c=o[1];i({err:r.err,code:s,message:r.msg||c})}})}try{t._sendMessage("p2p",o,e)}catch(s){throw s.code===hA.NOT_CONNECTED_YET&&(s.code=hA.USER_MESSAGE_BROKEN),s}}))}},{key:"_sendMessage",value:function(e,t,r){var n;if(!this._dataChannel||"open"!==this._dataChannel.readyState)throw new vA(hA.NOT_CONNECTED_YET,"DataChannel not open");var i=t.version+(+t.zip<<5)+(+t.encrypt<<6),o=+t.needAck+(+t.direction<<1)+(+t.functionType<<2)+(+t.binary<<6),a=cD.str2ab(Nm([e,r])),s=sD(Uint8Array,Om(n=[i,o]).call(n,Jk(t.id||[])),new Uint8Array(a));this._dataChannel.send(s.buffer),"p2p"===e?kO.updateP2PMsgReq(this.id,r,s.buffer.byteLength):"customMessage"===e&&kO.updateOne2ManyMsgReq(this.id,r,s.buffer.byteLength)}},{key:"_dispartData",value:function(e){var t=new Uint8Array(e),r=0,n=t[r++],i=t[r++],o={version:15&n,zip:16==(16&n),encrypt:32==(32&n),needAck:1==(1&i),direction:(2&i)>>1,functionType:(60&i)>>2,binary:64==(64&i)};if(o.needAck||1===o.direction){for(;r<=6;r++)if(128!=(128&t[r])){r++;break}o.id=qk(km(t).call(t,2,r))}return{header:o,data:km(t).call(t,r)}}},{key:"_feedbackSignaling",value:function(e,t,r){var n,i,o=this._genHeader({needAck:!0,direction:1,id:jm(n=e.split("-")).call(n,(function(e){return+e}))});mk(KH).call(KH,t)||zH.print("Signal",Om(i=">>>>>> [".concat(t,"-res][")).call(i,e,"]"));this._sendMessage("".concat(t,"-res"),o,r)}},{key:"_handleMessage",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Date.now(),n=t.byteLength,i=this._dispartData(t),o=i.data,(a=i.header).zip&&((s=new Fx.Inflate).push(o,!0),o=s.result),c=cD.ab2str(o),u=[],e.prev=8,u=JSON.parse(c),e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(8),e.t0 instanceof Error&&(null===(d=this._monitor)||void 0===d||d.report("rtc_signaling_msg_error",{error_code:-1,message:e.t0.message,reason:"message parse failed"})),e.abrupt("return");case 16:e.t1=a.functionType,e.next=0===e.t1?19:1===e.t1?21:2===e.t1?23:25;break;case 19:return this.C2S(a,u,c,n,r),e.abrupt("break",26);case 21:return this.C2C(u,n,r),e.abrupt("break",26);case 23:return this.C2GW(a,u,c),e.abrupt("break",26);case 25:return e.abrupt("break",26);case 26:case"end":return e.stop()}}),e,this,[[8,12]])}))),function(e){return n.apply(this,arguments)})},{key:"C2S",value:(r=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=(null===(a=t.id)||void 0===a?void 0:a.join("-"))||"",1!==t.direction){e.next=5;break}this._handleAckMessage(s,r[0]||{},n),e.next=18;break;case 5:if(!Array.isArray(r)){e.next=18;break}if(u=r[0],r=r[1],mk(KH).call(KH,u)||zH.print("Signal","<<<<<< ".concat(u),r,s),this._feedbackSignaling(s,u,u===hH.ON_CUSTOM_MESSAGE?Zd(Zd({},r),{},{message:""}):""),!r.binary||"string"!=typeof r.message){e.next=14;break}return e.next=13,cD.b64str2ab(r.message);case 13:r.message=e.sent;case 14:d=Date.now(),this.emit(u,Zd({},r)),u===hH.ON_CUSTOM_MESSAGE&&kO.reportOne2ManyMsgRecv(this.id,r,{msg_size:i,recv_msg_ts:o,fwd_msg_ts:d}),null===(c=this._monitor)||void 0===c||c.report("rtc_signaling",{error_code:0,message:n,signaling_event:"on-".concat(u),signaling_type:"Recv",stream_id:r.streamId,stream_user_id:r.clientId,direction:"down"});case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,n,i,o){return r.apply(this,arguments)})},{key:"C2C",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:Array.isArray(t)&&(t=t[1]),c=null===(i=t)||void 0===i?void 0:i.id,this._rttIds[c]||(null===(o=t)||void 0===o?void 0:o.dir)===FH.FEEDBACK||lD(null===(a=t)||void 0===a?void 0:a.msg)?delete this._rttIds[c]:zH.print("Signal","<<<<<< p2p response",t),e.t0=t.dir,e.next=e.t0===FH.SEND?6:e.t0===FH.FEEDBACK?46:48;break;case 6:if(u=Date.now(),lD(null===(s=t)||void 0===s?void 0:s.msg)){e.next=43;break}if(l=(d=t).binary,h=d.msg,p=d.room,v=d.to,_=d.from,f=""===p?l?hH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM:hH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM:l?hH.USER_BINARY_MESSAGE_RECEIVED:hH.USER_MESSAGE_RECEIVED,v){e.next=27;break}if(e.t1=this,e.t2=hH.ON_CUSTOM_MESSAGE,e.t3=_,e.t4=l,!l){e.next=21;break}return e.next=18,cD.b64str2ab(h);case 18:e.t5=e.sent,e.next=22;break;case 21:e.t5=h;case 22:e.t6=e.t5,e.t7={clientId:e.t3,binary:e.t4,message:e.t6},e.t1.emit.call(e.t1,e.t2,e.t7),e.next=43;break;case 27:if(e.t8=this,e.t9=f,e.t10=Zd,e.t11=Zd({},t),e.t12={},!l){e.next=38;break}return e.next=35,cD.b64str2ab(h);case 35:e.t13=e.sent,e.next=39;break;case 38:e.t13=h;case 39:e.t14=e.t13,e.t15={msg:e.t14},e.t16=(0,e.t10)(e.t11,e.t12,e.t15),e.t8.emit.call(e.t8,e.t9,e.t16);case 43:return this._sendP2PMessage(Zd(Zd({},t),{},{dir:FH.FEEDBACK,msg:""})),kO.reportP2PMsgRecv(this.id,t,{msg_size:r,recv_msg_ts:n,fwd_msg_ts:u}),e.abrupt("break",49);case 46:return this._handleP2PMsgFeedback(t),e.abrupt("break",49);case 48:return e.abrupt("break",49);case 49:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"C2GW",value:function(e,t,r){if(1===e.direction){var n,i=(null===(n=e.id)||void 0===n?void 0:n.join("-"))||"";this._handleAckMessage(i,t[0]||{},r)}else{var o=eI(t,2),a=o[0],s=o[1],c=void 0===s?{}:s;if("RXMediaMsg"===a){var u,d=c.type,l=c.data;switch(null===(u=this._monitor)||void 0===u||u.report("rtc_signaling",{error_code:0,message:r,signaling_event:"on-".concat(d),signaling_type:"Recv",stream_id:"",stream_user_id:"",direction:"down"}),d){case"RSCP":try{var h=JSON.parse(l);Array.isArray(h)&&this.emit(d,h)}catch(_){}break;case"RTT":try{var p=JSON.parse(l);p.length&&this.emit(d,p[0])}catch(_){}break;case"SSC":try{var v=JSON.parse(l);v.length&&this.emit(d,v[0])}catch(_){}}}}}},{key:"_handleHandler",value:function(){var e=this,t=function(e){zH.print("_handleHandler","dataChannel close",e)},r=function(e){zH.print("_handleHandler","dataChannel error",e)},n=function(t){e._handleMessage(t.data)};return this._dataChannel.addEventListener("close",t),this._dataChannel.addEventListener("error",r),this._dataChannel.addEventListener("message",n),function(){e._dataChannel.removeEventListener("close",t),e._dataChannel.removeEventListener("error",r),e._dataChannel.removeEventListener("message",n)}}},{key:"_genHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Zd({version:2,zip:!1,encrypt:!1,needAck:!0,direction:0,functionType:0,binary:!1},e)}},{key:"_handleAckMessage",value:function(e,t,r){var n,i,o=this._singlingCache.get(e);o&&(this._singlingCache.delete(e),200===t.code?o.success(t):o.error(t),zH.print("Signal",Om(i="<<<<<< [".concat(o.signalingType,"-ack] ")).call(i,e),t));null===(n=this._monitor)||void 0===n||n.report("rtc_signaling",{error_code:0,message:r,signaling_event:null==o?void 0:o.signalingType,signaling_type:"Ack",stream_id:"",stream_user_id:"",direction:"down"})}},{key:"_handleP2PMsgFeedback",value:function(e){var t=this._p2pCache.get(e.id);t&&(this._p2pCache.delete(e.id),e.err===jH.SUCCESS?t.success(e.id,e):t.error(e))}}]),a}(ZM.exports.EventEmitter),qH=new yO("ConnectionManager",3),YH=function(e){MI(o,e);var t,r,n,i=JI(o);function o(e){var t;return Vl(this,o),Jd(tI(t=i.call(this)),"id",void 0),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_getAccessManager",void 0),Jd(tI(t),"_connectionPool",new $S),Jd(tI(t),"_curConnection",void 0),Jd(tI(t),"_hasReportBrowerWarning",!1),Jd(tI(t),"_reconnectTimer",void 0),Jd(tI(t),"_connecting",!1),Jd(tI(t),"_isFirstTimeConnected",!0),Jd(tI(t),"_feedbackNodes",[]),Jd(tI(t),"_preIceStartTime",-1),Jd(tI(t),"_tcpOnlyTimer",void 0),Jd(tI(t),"_destroyed",!1),t._ctx=e,qH.print("constructor","invoke"),t.id=e.id,t._monitor=MO(t.id),t._getAccessManager=new OH(e),t}return Ul(o,[{key:"connect",value:function(){var e=this;qH.print("connect","invoke");try{LH.checkSupported()}catch(t){this.safeEmit("disconnected",t)}this._connecting||(this._onConnectStart("init"),Yf.resolve().then((function(){return e.emit("__onGetIceConfigHook")})),this._getAccess())}},{key:"reconnectByNodeChange",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:qH.print("reconnectByNodeChange","invoke %o",t),o=t.nodes,a=t.reason,null===(r=this._monitor)||void 0===r||r.report("rtc_node_change",{error_code:0,message:Nm(t),reason:Nm(a)}),mM.clearAccessNode(this._ctx.appId),s=(null===(n=this._curConnection)||void 0===n||null===(i=n.node.publicIPs[0])||void 0===i?void 0:i.ip)||"",this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart("node change"),Array.isArray(o)&&o.length>0?this._startIceConnect(o):this._getAccess([{feedbackIP:s,feedbackReason:{type:"NODE_CHANGED",reason:a}}]);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"reconnect",value:(r=Rm(Tm().mark((function e(t){var r,n=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=n.length>1&&void 0!==n[1]&&n[1],qH.print("reconnect","invoke. ".concat(r?"ICE over TCP":"")),this._closeCurrentConnection(),this._clearConnectionPool(),this._clearReconnectTimer(),this._onConnectStart(t),this._getAccess(void 0,r);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){qH.print("destroy","invoke"),this._destroyed=!0,this.safeEmit("disconnected",new vA(hA.OPERATION_CANCEL,"destroy")),OI(CI(o.prototype),"removeAllListeners",this).call(this),this._clearReconnectTimer(),this._clearConnectionPool(),this._getAccessManager.destroy(),this._closeCurrentConnection()}},{key:"_getAccess",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._getAccessManager.getICENode(e).then((function(e){t.emit("__onGetIceSuccessHook",e),t._startIceConnect(e,r)})).catch((function(e){t.safeEmit("disconnected",e)}))}},{key:"_startIceConnect",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!this._destroyed){qH.print("_startIceConnect","invoke");var n=ow();this._preIceStartTime=aD();var i=this._ctx.joinRoomConfig.useTcpJoin,o=this._ctx.joinRoomConfig.useTcpJoinDelay,a=function(){var e=Rm(Tm().mark((function e(i){var o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r&&((i=Bj(i)).iceConfig.tcpOnly=!0),o={node:i},e.prev=2,a=new LH(t._ctx,n),o.pc=a,t._connectionPool.set(a.uuid,o),e.next=8,a.connect(i);case 8:return s=e.sent,c=new WH(t.id,s),o.signaling=c,e.next=13,c.sendPingSignaling();case 13:t._onConnectSuccess({node:i,pc:a,signaling:c,dc:s}),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(2),t._onConnectionFailed(o,e.t0);case 19:case"end":return e.stop()}}),e,null,[[2,16]])})));return function(t){return e.apply(this,arguments)}}();this.emit("__onIceConnectStartHook"),e.forEach(a),i&&!r&&(qH.print("_startIceConnect","tcp-only will try after ".concat(o,"ms")),this._tcpOnlyTimer=window.setTimeout((function(){t.emit("connectWidthTcp"),e.forEach((function(e){(e=Bj(e)).iceConfig.tcpOnly=!0,a(e)})),delete t._tcpOnlyTimer}),o))}}},{key:"_onConnectSuccess",value:function(e){var t,r,n,i=this;(qH.print("connect","peer_%s connect success.",e.pc.uuid),this.emit("__onIceConnectSuccessHook",e),this._curConnection)?(e.pc.destroy(),null===(t=e.signaling)||void 0===t||t.destroy(),this._connectionPool.delete(e.pc.uuid)):(this._curConnection=e,this._addConnectionHandler(e.pc,e.dc),null===(r=this._monitor)||void 0===r||r.set({connection_id:e.pc.getConnectionId(),rtc_vid:(null===(n=e.node.iceConfig)||void 0===n?void 0:n._abtest_vid)||""}),this._connectionPool.delete(e.pc.uuid),this._feedbackNodes.forEach((function(e){return i._feedbackBySignaling(e)})),this._feedbackNodes=[],this._onConnectEnded(e))}},{key:"_onConnectionFailed",value:function(e,t){var r,n,i=this;(qH.print("connect","peer_%s connect failed. %s",(null===(r=e.pc)||void 0===r?void 0:r.uuid)||"",t.message),this.emit("__onIceConnectFailedHook",e),t.code!==PH.DESTROY&&t.code!==hA.OPERATION_CANCEL)&&(this._curConnection?this._feedbackBySignaling(e.node):this._feedbackNodes.push(e.node),qH.print("connect","remove cache node"),mM.deleteAccessNode(this._ctx.appId,e.node),e.pc&&(this._connectionPool.delete(e.pc.uuid),e.pc.destroy()),null===(n=e.signaling)||void 0===n||n.destroy());0!==this._connectionPool.size||this._curConnection||this._destroyed||(qH.print("connect","establish peerConnection failed"),this._checkBrowserUA(),aD()-this._preIceStartTime<1e3?(this._clearReconnectTimer(),this._reconnectTimer=window.setTimeout((function(){delete i._reconnectTimer,i._reconnectWithIceFailed(i._feedbackNodes)}),1e3)):this._reconnectWithIceFailed(this._feedbackNodes))}},{key:"_feedbackBySignaling",value:function(e){var t;null===(t=this._curConnection)||void 0===t||t.signaling.sendSignaling("scheduleMessage",{type:"feedback",body:{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})}},{key:"_reconnectWithIceFailed",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this._onConnectStart("ice failed"),qH.print("reconnect","because of ice failed"),this._getAccess(jm(t).call(t,(function(e){return{feedbackIP:e.publicIPs[0].ip,feedbackReason:{type:"ICE_FAILED",reason:{}}}})));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_checkBrowserUA",value:function(){var e;!this._hasReportBrowerWarning&&this._ctx.joinRoomConfig.isBlackBrower()&&(this._hasReportBrowerWarning=!0,null===(e=this._monitor)||void 0===e||e.report("rtc_error",{error_code:AH.BLACK_BROWSER,message:"failed to establish data-channel, and the current browser is on the browser blacklist."}))}},{key:"_onConnectStart",value:function(e){var t;qH.print("_onConnectStart","invoke, reason: ".concat(e)),this._connecting=!0,this.safeEmit(this._isFirstTimeConnected?"connecting":"reconnecting");var r,n=ow();(null===(t=this._monitor)||void 0===t||t.set({connect_session_id:n}),this._isFirstTimeConnected)||(null===(r=this._monitor)||void 0===r||r.report("rtc_reconnect",{error_code:1002,message:"peerconnection reconnecting",reconnect_id:n,reconnect_type:"peerconnection"},{reason:e}))}},{key:"_onConnectEnded",value:function(e){var t;(qH.print("_onConnectEnded","invoke"),this._connecting=!1,this._isFirstTimeConnected=!1,this.safeEmit("connected",e),this._isFirstTimeConnected)||(null===(t=this._monitor)||void 0===t||t.report("rtc_reconnected",{message:"peerconnection reconnected",reconnect_type:"peerconnection"}));e.node.iceConfig.tcpOnly&&(qH.print("_onConnectEnded","use tcp only"),LO(this._ctx.id,"connected_with_tcp_only",Nm(e.node))),this._tcpOnlyTimer&&(window.clearTimeout(this._tcpOnlyTimer),delete this._tcpOnlyTimer),this._clearConnectionPool()}},{key:"_addConnectionHandler",value:function(e,t){var r=this;e.on("disconnect",(function(e){r._closeCurrentConnection(),r._clearReconnectTimer(),navigator.onLine?r.reconnect(e):r._reconnectTimer=window.setTimeout((function(){return r.reconnect(e)}),3e3)}))}},{key:"_closeCurrentConnection",value:function(){var e,t;null===(e=this._curConnection)||void 0===e||e.pc.destroy(),null===(t=this._curConnection)||void 0===t||t.signaling.destroy(),delete this._curConnection}},{key:"_clearConnectionPool",value:function(){var e=this;this._connectionPool.forEach((function(t,r){var n,i;null===(n=t.pc)||void 0===n||n.destroy(),null===(i=t.signaling)||void 0===i||i.destroy(),e._connectionPool.delete(r)}))}},{key:"_clearReconnectTimer",value:function(){this._reconnectTimer&&(window.clearTimeout(this._reconnectTimer),delete this._reconnectTimer)}}]),o}(tP),JH=ad,QH=tc,ZH=function(e,t,r,n){for(var i,o=n>1?void 0:n?QH(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&JH(t,r,o),o},$H=new yO("MediaServerClient",2),eG=6e4,tG=function(e){return e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTED="connected",e.CONNECTING="connecting",e}(tG||{}),rG=function(e,t){$H.print(e,"userId: %o, subAudio: %o, subVideo: %o, audioMid: %o, videoMid: %o, sequenceId: %o",t.userId,t.subAudio,t.subVideo,t.audioMid,t.videoMid,t.sequenceId)},nG=function(e){MI(T,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k=JI(T);function T(e){var t;return Vl(this,T),Jd(tI(t=k.call(this)),"id",void 0),Jd(tI(t),"_token",void 0),Jd(tI(t),"_roomId",void 0),Jd(tI(t),"_roomAttributes",void 0),Jd(tI(t),"_vendorConfig",{enableMultiVendor:!1,vendorCode:0}),Jd(tI(t),"_clientId",void 0),Jd(tI(t),"_businessId",void 0),Jd(tI(t),"_userInfo",void 0),Jd(tI(t),"_authorization",void 0),Jd(tI(t),"_sessionId",""),Jd(tI(t),"_liveControlMessage",void 0),Jd(tI(t),"isReconnecting",!1),Jd(tI(t),"_ontrackCallbackMap",new $S),Jd(tI(t),"_subResolves",{}),Jd(tI(t),"supportConcurrent",!1),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_pubSubLock",void 0),Jd(tI(t),"_joinLeaveLock",void 0),Jd(tI(t),"_state",void 0),Jd(tI(t),"_dataChannelSignal",void 0),Jd(tI(t),"_joinRoomStartTs",void 0),Jd(tI(t),"_subConfig",{}),Jd(tI(t),"_monitor",void 0),Jd(tI(t),"_roomProfile",bl.communication),Jd(tI(t),"_context",void 0),Jd(tI(t),"_subStreamQueue",{}),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"_joinRoom5xxTimer",void 0),Jd(tI(t),"_joinResolve",void 0),Jd(tI(t),"_joinReject",void 0),$H.print("constructor","invoke"),t.id=e.id,t._monitor=MO(t.id),t._pubSubLock=new gH("pubSubLock"),t._joinLeaveLock=new gH("joinLeaveLock"),t._state="disconnected",t._roomAttributes={multiChatMode:!1,bigRoomMode:!1},t._context=e,t.on("SUB_END",(function(e){return t._handleSubStreamQueue(e)})),t._connectionManager=new YH(e),t._addConnectHandler(),t}return Ul(T,[{key:"_addSignalEventHandler",value:function(){var e,t,r=this;[hH.ON_ADD_STREAM,hH.ON_ADD_STREAM_LIST,hH.ON_REMOVE_STREAM,hH.ON_REMOVE_STREAM_LIST,hH.USER_CONNECTION,hH.USER_CONNECTION_LIST,hH.USER_DISCONNECTION,hH.USER_DISCONNECTION_LIST,hH.ON_UPDATE_STREAM_ATTRIBUTES,hH.ON_UPDATE_ROOM_ATTRIBUTES,hH.ON_PUSH_TRACK,hH.ON_REMOVE_TRACK,hH.ON_CUSTOM_MESSAGE,hH.USER_MESSAGE_RECEIVED,hH.USER_BINARY_MESSAGE_RECEIVED,hH.POST_PROCESSING_MESSAGE,hH.ON_USER_TOKEN_WILL_EXPIRE,hH.STREAM_CONTROL_MESSAGE,hH.ON_UPDATE_USER_ATTRIBUTES,hH.ON_SPEAKER_CHANGE,pH.RSCP,pH.RTT,hH.ON_STREAM_FAILED,hH.ON_NOTIFY_RECONNECT,pH.SSC,hH.ON_FORWARD_DST_ROOM_USER_KICK].forEach((function(e){var t;null===(t=r._dataChannelSignal)||void 0===t||t.on(e,(function(t){r.safeEmit(e,t)}))})),null===(e=this._dataChannelSignal)||void 0===e||e.on(hH.NODE_CHANGE,(function(e){r._connectionManager.reconnectByNodeChange(e)})),null===(t=this._dataChannelSignal)||void 0===t||t.on(hH.ON_NOTIFY_RECONNECT,(function(){r._connectionManager.reconnect("recv notifyReconnect signaling")}))}},{key:"_removeSignalEventHandler",value:function(){var e,t;null===(e=this._dataChannelSignal)||void 0===e||e.removeAllListeners(),null===(t=this._handler)||void 0===t||t.removeAllListeners()}},{key:"connectionState",get:function(){return this._state},set:function(e){this._state!==e&&(this.safeEmit(vH.ON_CONNECTION_STATE_CHANGE,{prev:this._state,next:e}),this._state=e)}},{key:"businessId",set:function(e){this._businessId=e}},{key:"setLiveControlMessage",value:function(e){this._liveControlMessage=e}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"join",value:(E=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $H.print("join()","info: %o",t),this._token=t.token,this._roomId=t.roomId,this._clientId=t.userInfo.userId,this._businessId=t.userInfo.businessId,this._userInfo=t.userInfo,this._roomProfile=t.roomProfile,this._reportJoinRoomStart(),e.next=10,new Yf((function(e,t){n._joinResolve=e,n._joinReject=t,(n._handler?Yf.resolve():n.connect()).then((function(){n._callJoinRoom()})).catch((function(e){var t=Array.isArray(e)&&e.length>0?e[0]:e;n._joinRoomFailed(t.message)}))}));case 10:return r=e.sent,e.abrupt("return",r);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"_callJoinRoom",value:(b=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.length>0&&void 0!==y[0]&&y[0],$H.print("_callJoinRoom","invoke"),e.t0=cD.token2auth(this._context.appId,this._roomId,this._clientId,this._token),e.t1=this._sessionId,e.t2=Date.now(),e.t3=this._liveControlMessage,e.t4={extra_info:this._userInfo.extraInfo,role:this._userInfo.role},e.next=9,null===(t=this._handler)||void 0===t?void 0:t.getDefaultSdp();case 9:return e.t5=e.sent,e.next=12,WN();case 12:return e.t6=e.sent,e.t7=window.navigator.userAgent,e.t8=TM.VERSION,e.t9=mM.getDeviceId(),e.t10=this._context.appId,e.t11=this._roomId,e.t12=this._clientId,e.t13=this._businessId,e.t14=this._context.useCloudProxy,e.t15=TH[this._roomProfile]?TH[this._roomProfile][0]+"":"0",e.t16={supportedCodecs:e.t6,deviceType:"web",userAgent:e.t7,sdkVersion:e.t8,deviceId:e.t9,appId:e.t10,roomId:e.t11,userId:e.t12,businessId:e.t13,enableCloudProxy:e.t14,channelProfile:e.t15},e.t17={supportTokenExpireCallBack:!0,enableSceneConfigV2:!0,enableUnBundleMode:!0,enableAudioMux:!0,enableBigRoomMode:!0,needNegotiateSDP:!0,supportMultiVendor:!0},e.t18=Nm({requireICEUfragV2:!0}),n={Authorization:e.t0,sessionId:e.t1,timestamp:e.t2,controlMessage:e.t3,userAttributes:e.t4,sdpInfo:e.t5,params:e.t16,options:e.t17,accessParams:e.t18},Yf.resolve().then((function(){return m.emit("onSendingJoinMessageHook")})),e.prev=27,o=r?"reconnected":"joinRoom",e.next=31,this._joinRoomWithRetry(o,n);case 31:a=e.sent,$H.print("join","send join message success"),s=a.config||{},c=s.engine_WEB,this._authorization=n.Authorization,mM.setEngineWebConfig(this._context.appId,this._roomId,c),this._context&&(this._context.serverConfig={videoCodec:(null==c?void 0:c.video_codec)||"H264",audioRed:!(null==c||!c.pub_audio_red),muteReplaceUnsub:!(null===(u=a.config)||void 0===u||!u.mute_replace_unsub),simulcastOnDemand:!(FD||!1===(null===(d=a.config)||void 0===d||null===(l=d.engine_VPM)||void 0===l||null===(h=l.ondemand)||void 0===h?void 0:h.enable)),forceUniHandler:1===(null==a||null===(p=a.config)||void 0===p||null===(v=p.vendor_param)||void 0===v?void 0:v.vendor_stream_sub_mode)},"boolean"==typeof(null==c?void 0:c.av_sync)&&(this._context.avSync=c.av_sync)),a.vendorConfig&&(this._vendorConfig=a.vendorConfig),qV.audioStallConfig=c,null!=a&&null!==(i=a.relayMessage)&&void 0!==i&&i.sdp&&(null===(_=this._handler)||void 0===_||_.createAVMlineAnswerTpl(a.relayMessage.sdp)),this.emit("joinSuccess",{joinRes:a,reconnect:r}),this._joinRoomSuccess(a),e.next=47;break;case 44:e.prev=44,e.t19=e.catch(27),(null===e.t19||void 0===e.t19?void 0:e.t19.code)>=700&&(null===e.t19||void 0===e.t19?void 0:e.t19.code)<800?this._joinRoomFailed("token_error",hA.INVALID_TOKEN):(null===e.t19||void 0===e.t19?void 0:e.t19.code)===hA.TIME_OUT&&this._context.joinRoomConfig.useTcpAfterJoinTimeout?(f="joinRoom timeout, retry with tcp only",$H.print("join",f),this.safeEmit(SH.ON_REJOIN_WITH_TCP),this._connectionManager.reconnect(f,!0)):e.t19.code===hA.OPERATION_CANCEL&&"connecting"===this.connectionState||this._joinRoomFailed((null===e.t19||void 0===e.t19?void 0:e.t19.message)||"signaling_error");case 47:case"end":return e.stop()}}),e,this,[[27,44]])}))),function(){return b.apply(this,arguments)})},{key:"publish",value:(S=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("publish()","localStream: %o",t),r=t.videoTrack,n=t.audioTrack,i=aD(),o="",a="",s=this._handler,e.prev=7,!this._vendorConfig.enableMultiVendor){e.next=20;break}return T=new LH(this._context,""),t.vendorHandler=new RH(this._context,T),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),e.next=14,t.vendorHandler.publish(t);case 14:k=e.sent,(s=t.vendorHandler).on("ice_state",(function(e){N.emit(vH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:N._clientId})})),T.once("disconnect",Rm(Tm().mark((function e(){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=s)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=N._handler)||void 0===n||null===(i=n.pc)||void 0===i?void 0:i.iceConnectionState)){e.next=4;break}return $H.print("vendor ice failed",t.streamId),e.abrupt("return");case 4:t.clean(),N.unpublish(t),N.publish(t);case 7:case"end":return e.stop()}}),e)})))),e.next=23;break;case 20:return e.next=22,null===(I=this._handler)||void 0===I?void 0:I.publish(t);case 22:k=e.sent;case 23:if(null===(c=t.observer)||void 0===c||c.setHandler(s),k){e.next=26;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 26:if("H264"!==(null===(u=this._context)||void 0===u||null===(d=u.serverConfig)||void 0===d?void 0:d.videoCodec)){e.next=32;break}return e.next=29,eL();case 29:if(e.sent){e.next=32;break}throw new vA(hA.PUBLISH_FAILED,"h264 is not supported");case 32:return o=k.audioMid,a=k.videoMid,t.pubAttributes={localaudio:!!n,localvideo:!!r,videostream:t.pubVideo,audiostream:t.pubAudio,extvideo:!!(r instanceof cV),extaudio:!!(n instanceof uV)},R={attributes:Zd({videoDescriptions:k.videoDescriptions},t.pubAttributes),audio:!0,video:!0,screen:t.isScreen,audioMid:o,videoMid:a,sdpInfo:{msid:t.stream.id,type:k.type,sdp:k.partialSdp,semantics:k.semantics},peerConnectionMode:null===(l=k)||void 0===l?void 0:l.peerConnectionMode,supportMultiVendor:!0},(A=!this._vendorConfig.enableMultiVendor&&t.enableSimulcast&&(null===(h=this._context)||void 0===h||null===(p=h.serverConfig)||void 0===p?void 0:p.simulcastOnDemand)&&(null===(v=k.subVideoDescriptions)||void 0===v?void 0:v.length))&&(R.attributes.subVideoDescriptions=k.subVideoDescriptions),null!==(_=k)&&void 0!==_&&_.peerConnectionId&&(R.peerConnectionId=k.peerConnectionId),e.next=41,null===(f=this._dataChannelSignal)||void 0===f?void 0:f.sendSignaling("publish",R);case 41:if(200===(null==(w=e.sent)?void 0:w.code)){e.next=44;break}throw new vA(hA.PUBLISH_FAILED,(null==w?void 0:w.message)||"publish failed");case 44:if(null===(m=this._monitor)||void 0===m||m.report("rtc_recv_answer",{error_code:0,answer_type:null==w?void 0:w.relayMessage.type,sequence_id:(null==w||null===(y=w.relayMessage)||void 0===y?void 0:y.sequenceId)||0,message:null==w||null===(g=w.relayMessage)||void 0===g?void 0:g.sdp,direction:"up",stream_id:"",stream_user_id:"",pc_session_id:(null===(S=s)||void 0===S?void 0:S.peerConnectionId)||""}),C=new Yf((function(e,r){var n,i,c,u,d,l;null===(n=s)||void 0===n||n.handleAck({action:iF.publish,streamId:w.streamId,audioMid:o,videoMid:a,audioTransceiverInit:null===(i=k)||void 0===i?void 0:i.audioTransceiverInit,videoTransceiverInit:null===(c=k)||void 0===c?void 0:c.videoTransceiverInit,signalingAck:{sdp:null==w||null===(u=w.relayMessage)||void 0===u?void 0:u.sdp,sequenceId:null==w||null===(d=w.relayMessage)||void 0===d?void 0:d.sequenceId},sdp:null===(l=k)||void 0===l?void 0:l.sdp,stream:t,onSuccess:function(){$H.print("publish()","publish success"),e(0)}})})),"chrome"!==(null===(b=this.handler)||void 0===b?void 0:b.name)){e.next=49;break}return e.next=49,C;case 49:return A&&this.emit(pH.RSCP,[{StreamIds:[t.stream.id],Metadata:{VideoIndex:0}}]),t.streamId=w.streamId,t.videoMid=a,t.audioMid=o,t.subVideoDescriptions=k.subVideoDescriptions,null===(E=this._monitor)||void 0===E||E.report("rtc_publish_stat",{result:"success",is_screen:"0",start:i,message:"unknown"}),e.abrupt("return");case 58:return e.prev=58,e.t0=e.catch(7),e.t0 instanceof Error?null===(O=this._monitor)||void 0===O||O.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(D="".concat(e.t0.name,": ")).call(D,e.t0.message)}):e.t0 instanceof vA&&(null===(M=this._monitor)||void 0===M||M.report("rtc_publish_stat",{result:"fail",is_screen:"0",start:i,message:Om(P="".concat(e.t0.code,": ")).call(P,e.t0.message)})),e.next=63,null===(x=s)||void 0===x?void 0:x.rollback(t.stream.id,t);case 63:throw e.t0;case 64:case"end":return e.stop()}}),e,this,[[7,58]])}))),function(e){return S.apply(this,arguments)})},{key:"updatePubTrack",value:(g=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:$H.print("updatePubTrack()","localStream: %o",t),i=t.videoTrack,o=t.audioTrack,a=t.pubAudio,s=t.pubVideo,c=t.vendorHandler||this.handler,u=null==o?void 0:o.getTrack("preprocessing"),d=null==i?void 0:i.getTrack("preprocessing"),s&&d?null===(l=t.videoTransceiver)||void 0===l||l.sender.replaceTrack(d):null===(h=t.videoTransceiver)||void 0===h||h.sender.replaceTrack(null),null==c||c.updateMaxBitrate(t),a&&u?(v=o.mixType,(_=o.mixedAudioTrack)&&v!==Dl.PLAYOUT&&!0===u.enabled&&(u=_),null===(p=t.audioTransceiver)||void 0===p||p.sender.replaceTrack(u)):(null===(f=t.audioTransceiver)||void 0===f||f.sender.replaceTrack(null),LO(this.id,"MediaClient.updatePubTrack(audio)","null"));try{LO(this.id,"MediaClient.updatePubTrack",Nm({audioStreamTrack:AD(u),videoStreamTrack:AD(d)}))}catch(eq){}for(y={},g=0,S=kA(m={localaudio:!!o,localvideo:!!i,videostream:s,audiostream:a,extvideo:!!(i instanceof cV),extaudio:!!(o instanceof uV)});g<S.length;g++)b=eI(S[g],2),E=b[0],(k=b[1])!==dI(t.pubAttributes,E)&&dP(y,E,k);if(an(y).length){e.next=14;break}return e.abrupt("return");case 14:return t.observer&&(T=t.observer,I=y.audiostream,R=y.videostream,A=y.localaudio,w=y.localvideo,C=y.extaudio,x=y.extvideo,void 0!==w?void 0!==x?T.setPushVideo(x):T.setEnableVideo(w):void 0!==R&&T.setUnmuteVideo(R),void 0!==A?void 0!==C?T.setPushAudio(C):T.setEnableAudio(A):void 0!==I&&T.setUnmuteAudio(I)),t.pubAttributes=m,O={roomId:this._roomId,streamId:t.streamId,attributes:y},e.next=19,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateStreamAttributes",O);case 19:if(200===(null==(D=e.sent)?void 0:D.code)){e.next=22;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==D?void 0:D.message)||"update track failed");case 22:if("chrome"===(null===(n=this.handler)||void 0===n?void 0:n.name)){e.next=25;break}return e.next=25,null==c?void 0:c.setCurrentDescription();case 25:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"updateToken",value:(y=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("updateToken()","newToken: %o",t),this._token=t,this._context.appId&&null!==(r=this._userInfo)&&void 0!==r&&r.userId&&this._roomId){e.next=4;break}return e.abrupt("return");case 4:return i={roomId:this._roomId,userId:null===(n=this._userInfo)||void 0===n?void 0:n.userId,appId:this._context.appId,token:"Bearer ".concat(t)},e.prev=5,e.next=8,null===(o=this._dataChannelSignal)||void 0===o?void 0:o.sendSignaling("updateToken",i);case 8:if(200===(null==(a=e.sent)?void 0:a.code)){e.next=11;break}throw new vA(hA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 11:e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(5),new vA(hA.UPDATE_TOKEN_WITH_INVALID_TOKEN,"invoke updateToken with an invalid token");case 16:case"end":return e.stop()}}),e,this,[[5,13]])}))),function(e){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $H.print("unpublish()","localStream: %o",t),n={roomId:this._roomId,initStreamId:t.initStreamId,streamId:t.streamId},null===(r=this._dataChannelSignal)||void 0===r||r.sendSignaling("unpublish",n),i=t.vendorHandler||this._handler,e.next=6,null==i?void 0:i.handleAck({action:iF.unpublish,audioMid:t.audioMid,videoMid:t.videoMid,stream:t,streamId:t.streamId});case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"subscribe",value:(f=Rm(Tm().mark((function e(t,r,n){var i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf(function(){var e=Rm(Tm().mark((function e(o,a){var s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.streamState!==$V.SUB_ED){e.next=2;break}return e.abrupt("return",i._updateSubTrack(t,r,kH.SUB).then(o,a));case 2:if(t.streamState!==$V.SUB_ING){e.next=7;break}return i._subStreamQueue[t.streamId]||(i._subStreamQueue[t.streamId]=[]),$H.print("_subStreamQueue","streamId: %o, enqueue",t.streamId),i._subStreamQueue[t.streamId].push({fn:i.subscribe,args:[t,r,n],resolve:o,reject:a}),e.abrupt("return");case 7:if($H.print("subscribe()","mediaType: %o",r),rG("subscribe()",t),t.streamState=$V.SUB_ING,c=!1,u=!1,kD(r)&&(u=!0),TD(r)&&(c=!0),c||!i.multiChatMode()){e.next=17;break}return t.streamState=$V.INIT,i.emit("SUB_END",t.streamId),e.abrupt("return",o(null));case 17:if(d=aD(),l=t.subVideo,h=[],p=!i.multiChatMode(),i._subResolves[t.streamId]||(i._subResolves[t.streamId]=[]),h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait video timeout for userId: ".concat(t.userId)))}),eG);t.on("ontrack",(function r(i){"video"===i.mediaType&&($H.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p&&h.push(new Yf((function(e,r){i._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),eG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&($H.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(s=i._handler)||void 0===s||s.on("ontrack",v),i._ontrackCallbackMap.set(t,v),_=i._handler,e.prev=28,null!==(f=i._context.serverConfig)&&void 0!==f&&f.forceUniHandler||!t.enableVendorMode){e.next=42;break}return V=new LH(i._context,""),t.vendorHandler=new RH(i._context,V),t.pcSessionId&&(t.vendorHandler.peerConnectionId=t.pcSessionId),(_=t.vendorHandler).on("ontrack",v),e.next=37,t.vendorHandler.subscribe(t);case 37:U=e.sent,_.on("ice_state",(function(e){i.emit(vH.ON_VENDOR_CONNECTION_STATE_CHANGE,{state:{checking:ll.CONNECTION_STATE_CONNECTING,connected:ll.CONNECTION_STATE_CONNECTED,disconnected:ll.CONNECTION_STATE_RECONNECTING}[e],userId:t.userId})})),V.once("disconnect",Rm(Tm().mark((function e(){var r,n,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=_)||void 0===r||r.removeAllListeners(),"connected"===(null===(n=i._handler)||void 0===n||null===(o=n.pc)||void 0===o?void 0:o.iceConnectionState)){e.next=4;break}return $H.print("vendor ice failed",t.streamId),e.abrupt("return");case 4:return t.resetHasSubscribed(),i.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0),e.next=8,i.subscribe(t,t.subMediaType);case 8:i.emit(SH.RESUBSCRIBE,{stream:t});case 9:case"end":return e.stop()}}),e)})))),e.next=45;break;case 42:return e.next=44,null===(F=i._handler)||void 0===F?void 0:F.subscribe(t,{multiChatMode:i.multiChatMode()});case 44:U=e.sent;case 45:if(null===(m=t.observer)||void 0===m||m.setHandler(_),U){e.next=48;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 48:return B=U.audioMid,j=U.videoMid,t.subVideo=c,H={spatialLayer:(null==n?void 0:n.spatialLayer)||0,temporalLayer:0,spatialSubLayer:(null==n?void 0:n.spatialSubLayer)||-1},G={audio:!i.multiChatMode(),video:!0,data:!0,screen:t.isScreen,browser:"chrome-stable",videoMid:j,audioMid:B,sdpInfo:{sdp:null===(y=U)||void 0===y?void 0:y.partialSdp,semantics:null===(g=U)||void 0===g?void 0:g.semantics,type:null===(S=U)||void 0===S?void 0:S.type},streamUserId:t.userId,streamId:t.streamId,config:{enableMediaType:{audio:!!i.multiChatMode()||u,video:c},qualityLayer:H},extra:{enableSendRTT:!0},peerConnectionMode:null===(b=U)||void 0===b?void 0:b.peerConnectionMode,supportMultiVendor:!0},null!==(E=U)&&void 0!==E&&E.peerConnectionId&&(G.peerConnectionId=U.peerConnectionId),z=i._context||{},K=z.subscribeFallbackOption,X=z.userPriority,"number"==typeof K&&(G.config.fallbackOption=K),X.has(t.userId)&&(G.config.priority=X.get(t.userId)),null!==(k=U)&&void 0!==k&&k.allSsrc&&(G.extra.subscribeSSRC=U.allSsrc),e.next=60,null===(T=i._dataChannelSignal)||void 0===T?void 0:T.sendSignaling("subscribe",G);case 60:if(200===(null==(W=e.sent)?void 0:W.code)){e.next=63;break}throw new vA(hA.SUBSCRIBE_FAILED,(null==W?void 0:W.message)||"subscribe failed");case 63:return q=null==W?void 0:W.relayMessage,Y=q.audioMid,J=q.videoMid,Jd(I={},B,Y),Jd(I,j,J),Q=I,$H.print("sub midmap",t.userId,Q),t.videoMid=j,t.audioMid=B,t.subMediaType=r,t.streamState=$V.SUB_ED,t.subLayer=H,null===(R=i._monitor)||void 0===R||R.report("rtc_recv_answer",{error_code:0,answer_type:null==W||null===(A=W.relayMessage)||void 0===A?void 0:A.type,sequence_id:(null==W||null===(w=W.relayMessage)||void 0===w?void 0:w.sequenceId)||0,message:null==W||null===(C=W.relayMessage)||void 0===C?void 0:C.sdp,direction:"down",stream_id:t.streamId,stream_user_id:t.userId,pc_session_id:(null===(x=_)||void 0===x?void 0:x.peerConnectionId)||""}),e.next=74,null===(O=_)||void 0===O?void 0:O.handleAck({action:iF.subscribe,streamId:t.streamId,audioMid:B,videoMid:j,audioTransceiverInit:null===(D=U)||void 0===D?void 0:D.audioTransceiverInit,videoTransceiverInit:null===(M=U)||void 0===M?void 0:M.videoTransceiverInit,signalingAck:{sdp:null==W||null===(P=W.relayMessage)||void 0===P?void 0:P.sdp,sequenceId:null==W||null===(N=W.relayMessage)||void 0===N?void 0:N.sequenceId},stream:t,sdp:U.sdp,generatorSsrc:!!U.allSsrc});case 74:return e.next=76,Yf.all(h);case 76:i.multiChatMode()||(t.subAudio=u),null===(L=i._monitor)||void 0===L||L.report("rtc_subscribe_stat",{result:"success",start:d,message:"unknown",stream_user_id:t.userId}),i._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return i.emit("onRemoteStreamStats",e)}),_),o(null),i.emit("SUB_END",t.streamId),e.next=92;break;case 83:return e.prev=83,e.t0=e.catch(28),e.t0 instanceof Error&&(null===($=i._monitor)||void 0===$||$.report("rtc_subscribe_stat",{result:"fail",start:d,message:e.t0.message,stream_user_id:t.userId})),t.subVideo=l,t.streamState=$V.INIT,e.next=90,null===(Z=_)||void 0===Z?void 0:Z.rollback(t.streamId,t);case 90:a(e.t0),i.emit("SUB_END",t.streamId);case 92:case"end":return e.stop()}}),e,null,[[28,83]])})));return function(t,r){return e.apply(this,arguments)}}()));case 1:case"end":return e.stop()}}),e)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"_handleSubStreamQueue",value:function(e){var t,r=this;if(null!==(t=this._subStreamQueue[e])&&void 0!==t&&t.length){$H.print("_subStreamQueue","streamId: %o, exec",e);var n=this._subStreamQueue[e].shift(),i=n.fn,o=n.args,a=n.resolve,s=n.reject;i.apply(this,o).then(a,s).finally((function(){return r._handleSubStreamQueue(e)}))}else $H.print("_subStreamQueue","streamId: %o, END",e)}},{key:"controlMessage",value:(_=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $H.print("controlMessage()","params: %o",t),n=t,"transcode"===t.type&&(n.roomId=this._roomId),e.next=5,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("controlMessage",n);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return _.apply(this,arguments)})},{key:"updateUserAttributes",value:(v=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $H.print("updateUserAttributes()","attributes: %o",t),e.next=3,null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendSignaling("updateUserAttributes",{roomId:this._roomId,sessionId:this._sessionId,attributes:t});case 3:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"updateSubTrack",value:(p=Rm(Tm().mark((function e(t,r,n){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._updateSubTrack(t,r,n));case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return p.apply(this,arguments)})},{key:"updateSubTrackLayer",value:(h=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("updateSubTrack()","subLayer: %o",r),t.subLayer.spatialLayer!==r.spatialLayer||t.subLayer.spatialSubLayer!==r.spatialSubLayer){e.next=4;break}return $H.print("updateSubTrack()","subLayer no change"),e.abrupt("return");case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{qualityLayer:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.subLayer=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"updateSubPriority",value:(l=Rm(Tm().mark((function e(t,r){var n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("updateSubPriority()","priority: %o",r),t.priority!==r){e.next=4;break}return $H.print("updateSubPriority()","priority no change"),e.abrupt("return",t);case 4:return i={roomId:this._roomId,streamList:[t.streamId],streamId:t.streamId,streamUserId:t.userId,config:{priority:r}},e.next=7,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("updateSubscribe",i);case 7:if(200===(null==(o=e.sent)?void 0:o.code)){e.next=10;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==o?void 0:o.message)||"update track failed");case 10:return t.priority=r,e.abrupt("return",t);case 12:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"_updateSubTrack",value:(d=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("updateSubTrack()","mediaType: %o",r),rG("updateSubTrack()",t),!this.multiChatMode()||r!==ul.AUDIO){e.next=5;break}return $H.print("updateSubTrack","multiChatMode mediaType only audio"),e.abrupt("return",t);case 5:return a=0,a=n===kH.SUB?t.subMediaType|r:t.subMediaType-(t.subMediaType&r),$H.print("updateSubTrack","prev: %o, direction: %o, mediaType: %o, newMediaType: %o",t.subMediaType,n,r,a),t.subMediaType===a&&$H.print("updateSubTrack","mediaType no change"),s=!1,c=!1,kD(a)&&(c=!0),TD(a)&&(s=!0),u={roomId:this._roomId,streamList:[t.streamId],config:{enableMediaType:{video:s,audio:!!this.multiChatMode()||c}}},e.next=15,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("updateSubscribe",u);case 15:if(200===(null==(d=e.sent)?void 0:d.code)){e.next=18;break}throw new vA(hA.UPDATE_TRACK_FAILED,(null==d?void 0:d.message)||"update track failed");case 18:return this.multiChatMode()||(null===(l=t.observer)||void 0===l||l.setUnmuteAudio(c),t.subAudio=c),null===(o=t.observer)||void 0===o||o.setUnmuteVideo(s),t.subVideo=s,t.subMediaType=a,e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return d.apply(this,arguments)})},{key:"subscribe4pushTrack",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return $H.print("subscribe4pushTrack()","streamInfo: %o",r),rG("subscribe4pushTrack()",t),t.subAudio=!0,e.next=5,null===(n=this._handler)||void 0===n?void 0:n.subscribe(t,{multiChatMode:this.multiChatMode()});case 5:if(a=e.sent){e.next=8;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 8:return s=a.audioMid,c=a.videoMid,(u=[]).push(new Yf((function(e,r){var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for userId: ".concat(t.userId)))}),eG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&($H.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),d=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",d),this._ontrackCallbackMap.set(t,d),e.next=17,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:iF.pushtrack,streamId:t.streamId,audioMid:s,videoMid:c,stream:t,audioTransceiverInit:null==a?void 0:a.audioTransceiverInit,videoTransceiverInit:null==a?void 0:a.videoTransceiverInit,signalingAck:null==r?void 0:r.message,sdp:a.sdp});case 17:return e.next=19,Yf.all(u);case 19:this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return l.emit("onRemoteStreamStats",e)}),this._handler);case 20:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"unsubscribe4removeTrack",value:(c=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rG("unsubscribe4removeTrack()",t),$H.print("unsubscribe4removeTrack()","sequenceId: ",r.sequenceId,"trackType: ",n),!(r.sequenceId<t.sequenceId)){e.next=5;break}return $H.print("unsubscribe4removeTrack()","sequenceId return"),e.abrupt("return");case 5:return u=!!((c=n+1)&ul.AUDIO),d=!!(c&ul.VIDEO),e.next=10,null===(i=this._handler)||void 0===i?void 0:i.handleAck({action:iF.removetrack,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 10:null===(o=t.observer)||void 0===o||o.setPushTrack(!1),null===(a=t.observer)||void 0===a||a.setUnmuteAudio(!u),t.subAudio=!u,null===(s=t.observer)||void 0===s||s.setUnmuteVideo(!d),t.subVideo=!d,t.subMediaType=t.subMediaType-(t.subMediaType&c),t.virtual&&(t.clean(),t.resetHasSubscribed(),t.statsReport.unsubscribe());case 17:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return c.apply(this,arguments)})},{key:"unsubscribe",value:(s=Rm(Tm().mark((function e(t,r){var n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>2&&void 0!==o[2]&&o[2],rG("unsubscribe()",t),!n){e.next=4;break}return e.abrupt("return",this._unsubscribe(t,r));case 4:if(!this.multiChatMode()||!TD(r)){e.next=6;break}return e.abrupt("return",this._unsubscribe(t,r));case 6:if(i=t.subMediaType-(t.subMediaType&r),this.multiChatMode()||i!==NV.NONE){e.next=9;break}return e.abrupt("return",this._unsubscribe(t,r));case 9:return e.abrupt("return",this._updateSubTrack(t,r,kH.UNSUB));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"_unsubscribe",value:(a=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subConfig.muteReplaceUnsub){e.next=2;break}return e.abrupt("return",this._updateSubTrack(t,r,kH.UNSUB));case 2:return a={roomId:this._roomId,streamId:t.streamId,userId:t.userId},s=t.vendorHandler||this.handler,null===(n=this._dataChannelSignal)||void 0===n||n.sendSignaling("unsubscribe",a).catch((function(){})),t.streamState=$V.INIT,this._subStreamQueue[t.streamId]&&(this._subStreamQueue[t.streamId].forEach((function(e){return(0,e.resolve)(null)})),delete this._subStreamQueue[t.streamId]),t.subVideo=!1,null===(i=t.observer)||void 0===i||i.setSubscribeVideo(!1),!this.multiChatMode()&&(null===(o=t.observer)||void 0===o||o.setSubscribeAudio(!1)),e.next=12,null==s?void 0:s.handleAck({action:iF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 12:c=e.sent,this._subResolves[c]&&this._subResolves[c].forEach((function(e){return e(0)})),$H.print("unsubscribe","clean unsub ".concat(t.userId)),t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 18:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"removeOnTrackListener",value:function(e){var t=this._ontrackCallbackMap.get(e);if(t){var r=e.vendorHandler||this._handler;null==r||r.off("ontrack",t),this._ontrackCallbackMap.delete(e)}}},{key:"handleRemoveStream",value:(o=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(rG("handleRemoveStream()",t),t.subVideo=!1,t.streamState!==$V.INIT){e.next=4;break}return e.abrupt("return");case 4:this.unsubscribe(t,ul.AUDIO_AND_VIDEO,!0);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return o.apply(this,arguments)})},{key:"leave",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if($H.print("leave()"),this._stopJoinRoom5xxRetry(),this._joinRoomFailed("leave_room"),"connected"!==this.connectionState){e.next=20;break}return t={Authorization:this._authorization,roomId:this._roomId,sessionId:this._sessionId},e.next=7,this._joinLeaveLock.lock();case 7:return r=e.sent,e.prev=8,e.next=11,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("leaveRoom",t);case 11:r(),e.next=18;break;case 14:throw e.prev=14,e.t0=e.catch(8),r(),e.t0;case 18:e.next=21;break;case 20:return e.abrupt("return",Yf.reject(new vA(hA.NOT_CONNECTED_YET,"server not connected")));case 21:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(){return i.apply(this,arguments)})},{key:"subscribePublicStream",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null===(r=this._handler)||void 0===r?void 0:r.subscribe(t,{multiChatMode:!1});case 2:if(s=e.sent){e.next=5;break}throw new vA(hA.ADD_TRANSCEIVER_FAILED,"add transceiver failed");case 5:return c=aD(),u=s.audioMid,d=s.videoMid,e.t0=this._context.appId,e.t1=t.streamId,e.t2=u,e.t3=d,e.t4={sdp:null==s?void 0:s.partialSdp,semantics:null==s?void 0:s.semantics,type:null==s?void 0:s.type},e.next=15,WN();case 15:return e.t5=e.sent,e.t6=window.navigator.userAgent,e.t7=TM.VERSION,e.t8=mM.getDeviceId(),e.t9=this._context.appId,e.t10=this._businessId,e.t11=this._context.useCloudProxy,e.t12={supportedCodecs:e.t5,deviceType:"web",userAgent:e.t6,sdkVersion:e.t7,deviceId:e.t8,appId:e.t9,businessId:e.t10,enableCloudProxy:e.t11},e.t13={enableMediaType:{audio:!0,video:!0},qualityLayer:{spatialLayer:0,temporalLayer:0}},l={appId:e.t0,streamId:e.t1,audio:!0,video:!0,data:!0,audioMid:e.t2,videoMid:e.t3,sdpInfo:e.t4,params:e.t12,config:e.t13},e.next=27,null===(n=this._dataChannelSignal)||void 0===n?void 0:n.sendSignaling("startPullStream",l);case 27:return h=e.sent,p=[],this._subResolves[t.streamId]=[],p.push(new Yf((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait video timeout for streamId: ".concat(t.streamId)))}),eG);t.on("ontrack",(function r(i){"video"===i.mediaType&&($H.print("remoteStream ".concat(t.userId," received video track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),p.push(new Yf((function(e,r){y._subResolves[t.streamId].push(e);var n=setTimeout((function(){return r(new vA(hA.TIME_OUT,"wait audio timeout for streamId: ".concat(t.streamId)))}),eG);t.on("ontrack",(function r(i){"audio"===i.mediaType&&($H.print("remoteStream ".concat(t.userId," received audio track")),t.off("ontrack",r),clearTimeout(n),e(0))}))}))),v=function(e){t.ontrack(e)},null===(i=this._handler)||void 0===i||i.on("ontrack",v),this._ontrackCallbackMap.set(t,v),_=null==h?void 0:h.relayMessage,f=_.sequenceId,m=_.sdp,t.videoMid=d,t.audioMid=u,t.sequenceId=f,t.streamState=$V.SUB_ED,t.subAudio=!0,t.subVideo=!0,e.next=44,null===(o=this._handler)||void 0===o?void 0:o.handleAck({action:iF.subscribe,streamId:t.streamId,audioMid:u,videoMid:d,audioTransceiverInit:null==s?void 0:s.audioTransceiverInit,videoTransceiverInit:null==s?void 0:s.videoTransceiverInit,signalingAck:{sdp:m,sequenceId:f},stream:t});case 44:return e.next=46,Yf.all(p);case 46:null===(a=this._monitor)||void 0===a||a.report("rtc_subscribe_stat",{result:"success",start:c,message:"unknown",stream_user_id:t.userId}),this._context&&t.statsReport.setRemoteStreamStatsEvtInterval((function(e){return y.emit("onRemoteStreamStats",e)}),this._handler);case 48:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"unsubscribePublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return rG("unsubscribePublicStream()",t),n={appId:this._context.appId,streamId:t.streamId},e.prev=2,e.next=5,null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("stopPullStream",n);case 5:e.next=9;break;case 7:e.prev=7,e.t0=e.catch(2);case 9:return t.streamState=$V.INIT,t.subVideo=!1,t.subAudio=!1,e.next=14,null===(r=this._handler)||void 0===r?void 0:r.handleAck({action:iF.unsubscribe,streamId:t.streamId,audioMid:t.audioMid,videoMid:t.videoMid,stream:t});case 14:t.clean(),this.removeOnTrackListener(t),t.statsReport.unsubscribe();case 17:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return r.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;$H.print("destroy()"),this._joinRoomFailed("leave_room"),this._token=void 0,this._roomId=void 0,this._clientId=void 0,this._authorization=void 0,this._sessionId="",this._stopJoinRoom5xxRetry(),null===(e=this._handler)||void 0===e||e.destroy(),this._handler=void 0,null===(t=this._dataChannelSignal)||void 0===t||t.destroy(),this._dataChannelSignal=void 0,this._connectionManager.destroy(),null===(r=this._monitor)||void 0===r||r.set({connection_id:""}),this._removeSignalEventHandler(),this.removeAllListeners(),this.connectionState="disconnected"}},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._dataChannelSignal)||void 0===r?void 0:r.sendP2PMessage({to:e,from:this._userInfo.userId,room:this._roomId,app:this._context.appId,msg:t})}},{key:"sendRoomMessage",value:function(e){var t;return null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("customMessage",e)}},{key:"_joinRoomWithRetry",value:function(e,t,r){var n=this;return new Yf((function(i,o){n._dataChannelSignal.sendSignaling(e,t,void 0,1e4).then((function(e){n.emit("onJoinRoomAck",e),i(e)})).catch((function(a){if(r=r||new CH,a.code>=500&&a.code<600&&aD()-r.initTs<6e4){var s,c=r.getRetryDelay();return $H.print("_joinRoomWithRetry",Om(s="joinRoom failed(code: ".concat(a.code,"), will retry after ")).call(s,c,"ms")),void(n._joinRoom5xxTimer=window.setTimeout((function(){delete n._joinRoom5xxTimer,n._joinRoomWithRetry(e,t,r).then(i).catch(o)}),c))}o(a)}))}))}},{key:"_stopJoinRoom5xxRetry",value:function(){this._joinRoom5xxTimer&&(clearTimeout(this._joinRoom5xxTimer),delete this._joinRoom5xxTimer)}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n,i;e.connectionState="connected",$H.print("connectStateChange","connected"),null===(r=e._dataChannelSignal)||void 0===r||r.destroy(),null===(n=e._handler)||void 0===n||n.destroy(),e._handler=uH(e._context,t.pc),e._dataChannelSignal=t.signaling,e.supportConcurrent="chrome"===(null===(i=e._handler)||void 0===i?void 0:i.name),e._addSignalEventHandler(),e.isReconnecting&&(e._reportJoinRoomStart(),e._callJoinRoom(!0))})),this._connectionManager.on("disconnected",(function(t){e.connectionState="disconnected",$H.print("connectStateChange","disconnected. %o",t),e.isReconnecting&&e.safeEmit(SH.RECONNECT_FAILED)})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",$H.print("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.connectionState="disconnected",e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e.connectionState="connecting",$H.print("connectStateChange","reconnecting"),e.safeEmit("reconnecting")})),this._connectionManager.on("connectWidthTcp",(function(){e.safeEmit(SH.ON_ICE_CONNECT_WITH_TCP)})),["__onGetIceConfigHook","__onIceConnectSuccessHook"].forEach((function(t){e._connectionManager.on(t,(function(){return e.emit(t)}))}))}},{key:"_reportJoinRoomStart",value:function(){var e;this._joinRoomStartTs=aD(),this.emit("__joinRoomStartReport"),null===(e=this._monitor)||void 0===e||e.report("join_room",{type:"begin",start:this._joinRoomStartTs,result:!1,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC})}},{key:"_joinRoomSuccess",value:function(e){var t,r;(this._joinReject&&this._joinResolve&&(this._joinResolve(e),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomSuccessReport"),null===(t=this._monitor)||void 0===t||t.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!0,reason:""},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),null===(r=this._monitor)||void 0===r||r.report("rtc_join_room",{error_code:0,deviceModel:"web",deviceManufacturer:"web",elapse:aD()-this._joinRoomStartTs}),delete this._joinRoomStartTs)}},{key:"_joinRoomFailed",value:function(e,t){var r;(this._joinReject&&this._joinResolve&&(this._joinReject(new vA(t||hA.JOIN_ROOM_FAILED,e)),delete this._joinReject,delete this._joinResolve),this._joinRoomStartTs)&&(this.emit("__joinRoomFailedReport"),null===(r=this._monitor)||void 0===r||r.report("join_room",{type:"end",start:this._joinRoomStartTs,result:!1,reason:e},{enable_cloud_proxy:this._context.useCloudProxy,expectedIDC:this._context.expectedIDC}),delete this._joinRoomStartTs)}},{key:"multiChatMode",value:function(){var e;return null===(e=this._roomAttributes)||void 0===e?void 0:e.multiChatMode}},{key:"sendForwardStreamSignal",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o={forwardStreamType:t,roomId:r},("start"===t||"update"===t)&&(o.dstRoomInfos=null==n?void 0:jm(n).call(n,(function(e){return{dstRoomId:e.roomId,dstToken:cD.token2auth(a._context.appId,e.roomId,a._clientId,e.token)}}))),e.abrupt("return",null===(i=this._dataChannelSignal)||void 0===i?void 0:i.sendSignaling("forwardStream",o));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})},{key:"handler",get:function(){return this._handler}},{key:"roomAttributes",get:function(){return this._roomAttributes},set:function(e){this._roomAttributes=e}},{key:"vendorConfig",get:function(){return this._vendorConfig}}]),T}(tP);function iG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._handler||"connected"!==this._state){e.next=6;break}for(r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=4,n.apply(this,i);case 4:e.next=7;break;case 6:throw new vA(hA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 7:case"end":return e.stop()}}),e,this)}))),r}function oG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._pubSubLock.lock();case 2:for(t=e.sent,this.supportConcurrent&&t(),e.prev=4,r=a.length,i=new Array(r),o=0;o<r;o++)i[o]=a[o];return e.next=8,n.apply(this,i);case 8:return e.abrupt("return",e.sent);case 9:return e.prev=9,this.supportConcurrent||t(),e.finish(9);case 12:case"end":return e.stop()}}),e,this,[[4,,9,12]])}))),r}ZH([function(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var t,r,i,o,a=this,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(t=s.length,r=new Array(t),i=0;i<t;i++)r[i]=s[i];return o=!1,e.abrupt("return",new Yf(function(){var e=Rm(Tm().mark((function e(t,i){var s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a.on("INTERRUPT",(function(){o=!0,i(new vA(hA.OPERATION_CANCEL,"operation not finish when leave"))})),e.prev=1,e.next=4,n.apply(a,r);case 4:s=e.sent,t(s),e.next=11;break;case 8:e.prev=8,e.t0=e.catch(1),o||i(e.t0);case 11:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t,r){return e.apply(this,arguments)}}()));case 3:case"end":return e.stop()}}),e)}))),r}],nG.prototype,"join",1),ZH([oG,iG],nG.prototype,"publish",1),ZH([oG,iG],nG.prototype,"updatePubTrack",1),ZH([oG,iG],nG.prototype,"unpublish",1),ZH([oG,iG],nG.prototype,"subscribe",1),ZH([iG],nG.prototype,"controlMessage",1),ZH([iG],nG.prototype,"updateUserAttributes",1),ZH([iG],nG.prototype,"updateSubTrack",1),ZH([iG],nG.prototype,"updateSubTrackLayer",1),ZH([iG],nG.prototype,"updateSubPriority",1),ZH([oG,iG],nG.prototype,"subscribe4pushTrack",1),ZH([oG,iG],nG.prototype,"unsubscribe4removeTrack",1),ZH([oG,iG],nG.prototype,"unsubscribe",1),ZH([iG],nG.prototype,"handleRemoveStream",1),ZH([oG],nG.prototype,"subscribePublicStream",1),ZH([oG],nG.prototype,"unsubscribePublicStream",1);var aG,sG=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getOrgTrack():null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getOrgTrack(),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.receiver:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.receiver,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=gE(p=v||[]).call(p,(function(e){return"inbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==(null==v?void 0:v.length)||0===m.length){e.next=22;break}return e.next=21,dL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==_?void 0:_.bytesReceived,framesReceived:null==_?void 0:_.framesReceived,packetsReceived:null==_?void 0:_.packetsReceived,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_recv_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),cG=function(){var e=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l,h,p,v,_,f,m,y;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u="",d=-1,l="video"===t?null==n||null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack("preprocessing"):null==n||null===(a=n.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"),h="video"===t?null==n||null===(s=n.videoTransceiver)||void 0===s?void 0:s.sender:null==n||null===(c=n.audioTransceiver)||void 0===c?void 0:c.sender,e.prev=5,e.t0=null==r?void 0:r.pc,!e.t0){e.next=11;break}return e.next=10,dL(null==r?void 0:r.pc,l);case 10:e.t0=e.sent;case 11:return v=e.t0,_=gE(p=v||[]).call(p,(function(e){return"outbound-rtp"===e.type})),e.next=15,null==h?void 0:h.getStats();case 15:if(f=e.sent,m=[],null==f||f.forEach((function(e){return m.push(e.type)})),null==r||!r.pc||0!==v.length||0===m.length){e.next=22;break}return e.next=21,dL(r.pc);case 21:y=e.sent;case 22:u=Nm({type:t,reports:jm(v).call(v,(function(e){return e.type})),reports2:m,pc:(null==r?void 0:r.pc)||null,track:(null==l?void 0:l.id)||null,bytes:null==_?void 0:_.bytesSent,framesSent:null==_?void 0:_.framesSent,packetsSent:null==_?void 0:_.packetsSent,allReports:y}),e.next=29;break;case 25:e.prev=25,e.t1=e.catch(5),d=-999,u=e.t1.mseeage||Nm(e.t1);case 29:null==i||i.report("rtc_invoke_status",{sdk_api_name:"first_frame_send_timeout",error_code:d,message:u,stream_id:(null==n?void 0:n.streamId)||"",stream_user_id:null==n?void 0:n.userId,elapse:0}),e.next=34;break;case 32:e.prev=32,e.t2=e.catch(0);case 34:case"end":return e.stop()}}),e,null,[[0,32],[5,25]])})));return function(t,r,n,i){return e.apply(this,arguments)}}(),uG=new yO("RecvFrameObserver",0),dG=function(e){MI(a,e);var t,r,n,i,o=JI(a);function a(e,t){var r;return Vl(this,a),Jd(tI(r=o.call(this)),"_audioEventSessionId",dD()),Jd(tI(r),"_videoEventSessionId",dD()),Jd(tI(r),"_handler",void 0),Jd(tI(r),"_stream",void 0),Jd(tI(r),"_firstAudioFrameTimer",void 0),Jd(tI(r),"_firstVideoFrameTimer",void 0),Jd(tI(r),"_transportDelayInterval",void 0),Jd(tI(r),"_transportDelay",void 0),Jd(tI(r),"_firstVideoFrameInterval",void 0),Jd(tI(r),"_firstAudioFrameInterval",void 0),Jd(tI(r),"_isScreen",!1),Jd(tI(r),"_audioFirstFrameState",0),Jd(tI(r),"_videoFirstFrameState",0),Jd(tI(r),"_timeout",1e4),Jd(tI(r),"_currentAudioRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_currentVideoRecv",{startTime:0,eventSessionId:0,type:"login"}),Jd(tI(r),"_login",!1),Jd(tI(r),"_unMuteAudio",!1),Jd(tI(r),"_enableAudio",!1),Jd(tI(r),"_unMuteVideo",!1),Jd(tI(r),"_enableVideo",!1),Jd(tI(r),"_remoteUnmuteAudio",!1),Jd(tI(r),"_remoteUnmuteVideo",!1),Jd(tI(r),"_audioExternal",!1),Jd(tI(r),"_pushAudio",!1),Jd(tI(r),"_videoExternal",!1),Jd(tI(r),"_pushVideo",!1),Jd(tI(r),"_autoSubscribeVideo",!1),Jd(tI(r),"_autoSubscribeAudio",!1),Jd(tI(r),"_autoSubscribe",!1),Jd(tI(r),"_publishVideo",!1),Jd(tI(r),"_publishAudio",!1),Jd(tI(r),"_subscribeAudio",!1),Jd(tI(r),"_subscribeVideo",!1),Jd(tI(r),"_subscribe",!1),Jd(tI(r),"_pushTrack",!1),Jd(tI(r),"_multiChatMode",!1),Jd(tI(r),"_monitor",void 0),r._stream=e,r._handler=t,r.getTransportDelay(),r._monitor=MO(e.engineId),r}return Ul(a,[{key:"beginRecvFrame",value:(i=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:i=this._transportDelay,o=!0,xE(n=["login","unmute","subscribe","push_track"]).call(n,r)>=0&&(i=0,o=!1),"audio"===t?(o||this._audioEventSessionId++,this._currentAudioRecv={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:r},p={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(a=this._stream)||void 0===a||!a.isScreen),start:null===(s=this._currentAudioRecv)||void 0===s?void 0:s.startTime,event_session_id:this._audioEventSessionId,stream_user_id:null===(c=this._stream)||void 0===c?void 0:c.userId,transport_delay:i,vendor_mode:(null===(u=this._stream)||void 0===u?void 0:u.vendorCode)||0,pc_session_id:(null===(d=this._stream)||void 0===d?void 0:d.pcSessionId)||(null===(l=this._handler)||void 0===l?void 0:l.peerConnectionId)},this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){sG("audio",E._handler,E._stream,E._monitor),E.stopRecvFrame("audio","timeout"),E._firstAudioFrameInterval&&window.clearInterval(E._firstAudioFrameInterval)}),this._timeout),uG.print("rtcFirstFrameRecv",Nm(p)),null===(h=this._monitor)||void 0===h||h.report("rtc_first_frame",p),this._watchForFirstAudioFrameRecv(),this._audioFirstFrameState=1,this._login=!0,this._unMuteAudio=!0,this._enableAudio=!0,this._remoteUnmuteAudio=!0):"video"===t&&(o||this._videoEventSessionId++,this._currentVideoRecv={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:r},b={media_type:t,event_type:"begin_recv",type:r,is_screen:!(null===(v=this._stream)||void 0===v||!v.isScreen),start:null===(_=this._currentVideoRecv)||void 0===_?void 0:_.startTime,event_session_id:this._videoEventSessionId,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,transport_delay:i,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){sG("video",E._handler,E._stream,E._monitor),E.stopRecvFrame("video","timeout"),E._firstVideoFrameInterval&&window.clearInterval(E._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameRecv(),uG.print("rtcFirstFrameRecv",Nm(b)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",b),this._videoFirstFrameState=1,this._login=!0,this._unMuteVideo=!0,this._enableVideo=!0,this._remoteUnmuteVideo=!0);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return i.apply(this,arguments)})},{key:"stopRecvFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c,u;if(1!==this._audioFirstFrameState)return;var d={event_type:"recv_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioRecv)||void 0===n?void 0:n.startTime,reason:t,result:!1,stream_user_id:null===(i=this._stream)||void 0===i?void 0:i.userId,event_session_id:this._audioEventSessionId,type:null===(o=this._currentAudioRecv)||void 0===o?void 0:o.type,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioRecv,uG.print("rtcFirstFrameRecv",Nm(d)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",d),this._audioFirstFrameState=2}else if("video"===e){var l,h,p,v,_,f,m,y;if(1!==this._videoFirstFrameState)return;var g={event_type:"recv_end",media_type:e,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),start:null===(h=this._currentVideoRecv)||void 0===h?void 0:h.startTime,reason:t,result:!1,stream_user_id:null===(p=this._stream)||void 0===p?void 0:p.userId,event_session_id:this._videoEventSessionId,type:null===(v=this._currentVideoRecv)||void 0===v?void 0:v.type,vendor_mode:(null===(_=this._stream)||void 0===_?void 0:_.vendorCode)||0,pc_session_id:(null===(f=this._stream)||void 0===f?void 0:f.pcSessionId)||(null===(m=this._handler)||void 0===m?void 0:m.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoRecv,uG.print("rtcFirstFrameRecv",Nm(g)),null===(y=this._monitor)||void 0===y||y.report("rtc_first_frame",g),this._videoFirstFrameState=2}}},{key:"recvFrameFinish",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelay();case 2:if(r=this._transportDelay,"audio"!==t){e.next=19;break}if(1===this._audioFirstFrameState){e.next=6;break}return e.abrupt("return");case 6:if(this._currentAudioRecv){e.next=8;break}return e.abrupt("return");case 8:d=this._currentAudioRecv,l=d.type,h=d.startTime,xE(n=["login","unmute","subscribe","push_track"]).call(n,l)>=0&&(r=0),p={event_type:"recv_end",media_type:t,start:h,result:!0,is_screen:!(null===(i=this._stream)||void 0===i||!i.isScreen),stream_user_id:null===(o=this._stream)||void 0===o?void 0:o.userId,event_session_id:this._audioEventSessionId,type:l,transport_delay:r,vendor_mode:(null===(a=this._stream)||void 0===a?void 0:a.vendorCode)||0,pc_session_id:(null===(s=this._stream)||void 0===s?void 0:s.pcSessionId)||(null===(c=this._handler)||void 0===c?void 0:c.peerConnectionId)},delete this._currentAudioRecv,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),uG.print("rtcFirstFrameRecv",Nm(p)),null===(u=this._monitor)||void 0===u||u.report("rtc_first_frame",p),this.emit("recvAudioFirstFrame"),this._audioFirstFrameState=3,e.next=33;break;case 19:if("video"!==t){e.next=33;break}if(1===this._videoFirstFrameState){e.next=22;break}return e.abrupt("return");case 22:if(this._currentVideoRecv){e.next=24;break}return e.abrupt("return");case 24:b=this._currentVideoRecv,E=b.type,k=b.startTime,xE(v=["login","unmute","subscribe","push_track"]).call(v,E)>=0&&(r=0),T={event_type:"recv_end",media_type:t,is_screen:!(null===(_=this._stream)||void 0===_||!_.isScreen),start:k,result:!0,stream_user_id:null===(f=this._stream)||void 0===f?void 0:f.userId,event_session_id:this._videoEventSessionId,type:E,transport_delay:r,vendor_mode:(null===(m=this._stream)||void 0===m?void 0:m.vendorCode)||0,pc_session_id:(null===(y=this._stream)||void 0===y?void 0:y.pcSessionId)||(null===(g=this._handler)||void 0===g?void 0:g.peerConnectionId)},delete this._currentVideoRecv,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),uG.print("rtcFirstFrameRecv",Nm(T)),null===(S=this._monitor)||void 0===S||S.report("rtc_first_frame",T),this.emit("recvVideoFirstFrame"),this._videoFirstFrameState=3;case 33:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setLogin",value:function(e){var t,r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{audio:!0,video:!0};this._login!==e&&(this._login=e,e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&o.audio&&this.beginRecvFrame("audio","login"),e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&o.video&&this.beginRecvFrame("video","login"),!e&&null!==(n=this._stream)&&void 0!==n&&n.hasAudio&&this.stopRecvFrame("audio","leave_room"),!e&&null!==(i=this._stream)&&void 0!==i&&i.hasVideo&&this.stopRecvFrame("video","leave_room"))}},{key:"setUnmuteAudio",value:function(e){var t,r,n;if(this._unMuteAudio!==e){this._unMuteAudio=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasAudio);null!==(r=this._stream)&&void 0!==r&&r.audioHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.audioHasPublish&&(this._unMuteAudio&&i?this.beginRecvFrame("audio","unmute"):i&&this.stopRecvFrame("audio","mute"))}}},{key:"setRemoteUnmuteAudio",value:function(e){this._remoteUnmuteAudio!==e&&(this._remoteUnmuteAudio=e,this._remoteUnmuteAudio?this.beginRecvFrame("audio","remote_unmute"):this.stopRecvFrame("audio","remote_mute"))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&(this._enableAudio=e,this._enableAudio?this.beginRecvFrame("audio","enable"):null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t,r,n;if(this._unMuteVideo!==e){this._unMuteVideo=e;var i=!(null===(t=this._stream)||void 0===t||!t.hasVideo);null!==(r=this._stream)&&void 0!==r&&r.videoHasCapture&&null!==(n=this._stream)&&void 0!==n&&n.videoHasPublish&&(this._unMuteVideo&&i?this.beginRecvFrame("video","unmute"):i&&this.stopRecvFrame("video","mute"))}}},{key:"setHandler",value:function(e){this._handler=e}},{key:"setRemoteUnmuteVideo",value:function(e){this._remoteUnmuteVideo!==e&&(this._remoteUnmuteVideo=e,this._remoteUnmuteVideo?this.beginRecvFrame("video","remote_unmute"):this.stopRecvFrame("video","remote_mute"))}},{key:"setEnableVideo",value:function(e){this._enableVideo!==e&&(this._enableVideo=e,this._enableVideo?this.beginRecvFrame("video","enable"):this.stopRecvFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal=e}},{key:"setPushAudio",value:function(e){var t;this._audioExternal&&this._pushAudio!==e&&(this._pushAudio=e),this._pushAudio&&this.beginRecvFrame("audio","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.beginRecvFrame("audio","push")}},{key:"setExternalVideoSource",value:function(e){this._videoExternal=e}},{key:"setPushVideo",value:function(e){var t;this._videoExternal&&this._pushVideo!==e&&(this._pushVideo=e),this._pushVideo&&this.beginRecvFrame("video","push"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.beginRecvFrame("video","push")}},{key:"setPublishVideo",value:function(e){var t;this._publishVideo!==e&&(this._publishVideo=e),this._publishVideo&&this.beginRecvFrame("video","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unpublish")}},{key:"setPublishAudio",value:function(e){var t;this._publishAudio!==e&&(this._publishAudio=e),this._publishAudio&&this.beginRecvFrame("audio","publish"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unpublish")}},{key:"setAutoSubscribe",value:function(e){this._autoSubscribe=e}},{key:"setAutoSubscribeVideo",value:function(e){this._autoSubscribeVideo=e}},{key:"setAutoSubscribeAudio",value:function(e){this._autoSubscribeAudio=e}},{key:"setSubscribeAudio",value:function(e){var t,r;this._autoSubscribeAudio||this._subscribeAudio===e||(this._subscribe=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasAudio&&this.beginRecvFrame("audio","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","unsubscribe")}},{key:"setSubscribeVideo",value:function(e){var t,r;this._autoSubscribeVideo||this._subscribeVideo===e||(this._subscribeVideo=e,e&&null!==(r=this._stream)&&void 0!==r&&r.hasVideo&&this.beginRecvFrame("video","subscribe"));!e&&null!==(t=this._stream)&&void 0!==t&&t.hasVideo&&this.stopRecvFrame("video","unsubscribe")}},{key:"setPushTrack",value:function(e){var t;this._pushTrack!==e&&(e&&!this._isScreen&&this.beginRecvFrame("audio","push_track"),!e&&null!==(t=this._stream)&&void 0!==t&&t.hasAudio&&this.stopRecvFrame("audio","remove_track"))}},{key:"setMultiChatMode",value:function(e){this._multiChatMode=e}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"_watchForFirstVideoFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a||!a.getTrack()){n.next=12;break}return n.next=3,dL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.videoTrack)||void 0===u?void 0:u.getTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.framesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.framesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"_watchForFirstAudioFrameRecv",value:function(){var e=this,t=-1,r=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a,s,c,u,d,l;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(null===(i=e._handler)||void 0===i||!i.pc||null===(o=e._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a||!a.getOrgTrack()){n.next=12;break}return n.next=3,dL(null===(s=e._handler)||void 0===s?void 0:s.pc,null===(c=e._stream)||void 0===c||null===(u=c.audioTrack)||void 0===u?void 0:u.getOrgTrack());case 3:if(d=n.sent,!(l=gE(d).call(d,(function(e){return"inbound-rtp"===e.type})))||!(l.totalSamplesReceived>t||l.packetsReceived>r)){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=l.totalSamplesReceived,r=l.packetsReceived,n.abrupt("return");case 10:e.recvFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 12:case"end":return n.stop()}}),n)}))),200)}},{key:"getTransportDelay",value:(r=Rm(Tm().mark((function e(){var t=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getTransportDelayIntl();case 2:window.clearInterval(this._transportDelayInterval),this._transportDelayInterval=window.setInterval(Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getTransportDelayIntl();case 2:case"end":return e.stop()}}),e)}))),2e3);case 4:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"getTransportDelayIntl",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc){e.next=7;break}return e.next=3,dL(null===(r=this._handler)||void 0===r?void 0:r.pc);case 3:n=e.sent,i=gE(n).call(n,(function(e){return"transport"===e.type&&"connected"===e.dtlsState})),(o=gE(n).call(n,(function(e){return"candidate-pair"===e.type&&"succeeded"===e.state&&e.id===(null==i?void 0:i.selectedCandidatePairId)})))&&(this._transportDelay=Math.round(1e3*o.currentRoundTripTime/2));case 7:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"reset",value:function(){this._currentAudioRecv={startTime:0,eventSessionId:0,type:"login"},this._currentVideoRecv={startTime:0,eventSessionId:0,type:"login"},this._login=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._remoteUnmuteAudio=!1,this._remoteUnmuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoSubscribeVideo=!1,this._autoSubscribeAudio=!1,this._autoSubscribe=!1,this._subscribeAudio=!1,this._subscribeVideo=!1,this._subscribe=!1,this._pushTrack=!1,this._multiChatMode=!1,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._transportDelayInterval&&window.clearInterval(this._transportDelayInterval)}},{key:"audioFirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}},{key:"FirstFrameReceived",get:function(){return 3===this._audioFirstFrameState}}]),a}(ZM.exports.EventEmitter),lG=new yO("SendFrameObserver",0),hG=function(){function e(t,r){Vl(this,e),Jd(this,"_audioEventSessionId",dD()),Jd(this,"_videoEventSessionId",dD()),Jd(this,"_pcSessionId",void 0),Jd(this,"_handler",void 0),Jd(this,"_firstAudioFrameTimer",void 0),Jd(this,"_firstVideoFrameTimer",void 0),Jd(this,"_stream",void 0),Jd(this,"_firstVideoFrameInterval",void 0),Jd(this,"_firstAudioFrameInterval",void 0),Jd(this,"_currentAudioSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_currentVideoSend",{startTime:0,eventSessionId:0,type:"login"}),Jd(this,"_login",!1),Jd(this,"_publisher",!1),Jd(this,"_unMuteAudio",!1),Jd(this,"_enableAudio",!1),Jd(this,"_unMuteVideo",!1),Jd(this,"_enableVideo",!1),Jd(this,"_audioExternal",!1),Jd(this,"_pushAudio",!1),Jd(this,"_videoExternal",!1),Jd(this,"_pushVideo",!1),Jd(this,"_autoPublish",!1),Jd(this,"_publish",!1),Jd(this,"_timeout",1e4),Jd(this,"_audioFirstFrameState",0),Jd(this,"_videoFirstFrameState",0),Jd(this,"_monitor",void 0),this._stream=t,this._handler=r,this._monitor=MO(t.engineId)}var t,r;return Ul(e,[{key:"beginSendFrame",value:function(e,t){var r=this;if("audio"===e){var n,i,o,a,s,c;this._audioEventSessionId++,this._currentAudioSend={startTime:Date.now(),eventSessionId:this._audioEventSessionId,type:t};var u={event_type:"begin_send",media_type:e,is_screen:!(null===(n=this._stream)||void 0===n||!n.isScreen),type:t,start:null===(i=this._currentAudioSend)||void 0===i?void 0:i.startTime,event_session_id:this._audioEventSessionId,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),this._firstAudioFrameTimer=window.setTimeout((function(){cG("audio",r._handler,r._stream,r._monitor),r.stopSendFrame("audio","timeout"),r._firstAudioFrameInterval&&window.clearInterval(r._firstAudioFrameInterval)}),this._timeout),lG.print("rtcFirstFrameSend",Nm(u)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",u),this._watchForFirstAudioFrameSend(),this._audioFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteAudio=!0,this._pushAudio||(this._enableAudio=!0)}else if("video"===e){var d,l,h,p,v,_;this._videoEventSessionId++,this._currentVideoSend={startTime:Date.now(),eventSessionId:this._videoEventSessionId,type:t};var f={event_type:"begin_send",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),type:t,start:null===(l=this._currentVideoSend)||void 0===l?void 0:l.startTime,event_session_id:this._videoEventSessionId,vendor_mode:(null===(h=this._stream)||void 0===h?void 0:h.vendorCode)||0,pc_session_id:(null===(p=this._stream)||void 0===p?void 0:p.pcSessionId)||(null===(v=this._handler)||void 0===v?void 0:v.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),this._firstVideoFrameTimer=window.setTimeout((function(){cG("video",r._handler,r._stream,r._monitor),r.stopSendFrame("video","timeout"),r._firstVideoFrameInterval&&window.clearInterval(r._firstVideoFrameInterval)}),this._timeout),this._watchForFirstVideoFrameSend(),lG.print("rtcFirstFrameSend",Nm(f)),null===(_=this._monitor)||void 0===_||_.report("rtc_first_frame",f),this._videoFirstFrameState=1,this._login=!0,this._publisher=!0,this._publish=!0,this._unMuteVideo=!0,this._pushVideo||(this._enableVideo=!0)}}},{key:"stopSendFrame",value:function(e,t){if("audio"===e){var r,n,i,o,a,s,c;if(1!==this._audioFirstFrameState)return;var u={event_type:"sent_end",media_type:e,is_screen:!(null===(r=this._stream)||void 0===r||!r.isScreen),start:null===(n=this._currentAudioSend)||void 0===n?void 0:n.startTime,reason:t,result:!1,event_session_id:this._audioEventSessionId,type:null===(i=this._currentAudioSend)||void 0===i?void 0:i.type,vendor_mode:(null===(o=this._stream)||void 0===o?void 0:o.vendorCode)||0,pc_session_id:(null===(a=this._stream)||void 0===a?void 0:a.pcSessionId)||(null===(s=this._handler)||void 0===s?void 0:s.peerConnectionId)};this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),delete this._currentAudioSend,lG.print("rtcFirstFrameSend",Nm(u)),null===(c=this._monitor)||void 0===c||c.report("rtc_first_frame",u),this._audioFirstFrameState=2}else if("video"===e){var d,l,h,p,v,_,f;if(1!==this._videoFirstFrameState)return;var m={event_type:"sent_end",media_type:e,start:null===(d=this._currentVideoSend)||void 0===d?void 0:d.startTime,is_screen:!(null===(l=this._stream)||void 0===l||!l.isScreen),reason:t,result:!1,event_session_id:this._videoEventSessionId,type:null===(h=this._currentVideoSend)||void 0===h?void 0:h.type,vendor_mode:(null===(p=this._stream)||void 0===p?void 0:p.vendorCode)||0,pc_session_id:(null===(v=this._stream)||void 0===v?void 0:v.pcSessionId)||(null===(_=this._handler)||void 0===_?void 0:_.peerConnectionId)};this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),delete this._currentVideoSend,lG.print("rtcFirstFrameSend",Nm(m)),null===(f=this._monitor)||void 0===f||f.report("rtc_first_frame",m),this._videoFirstFrameState=2}}},{key:"sendFrameFinish",value:function(e){if("audio"===e){var t,r,n,i,o;if(1!==this._audioFirstFrameState)return;if(!this._currentAudioSend)return;var a=this._currentAudioSend,s=a.type,c=a.startTime,u={event_type:"sent_end",media_type:e,is_screen:!(null===(t=this._stream)||void 0===t||!t.isScreen),start:c,result:!0,event_session_id:this._audioEventSessionId,type:s,vendor_mode:(null===(r=this._stream)||void 0===r?void 0:r.vendorCode)||0,pc_session_id:(null===(n=this._stream)||void 0===n?void 0:n.pcSessionId)||(null===(i=this._handler)||void 0===i?void 0:i.peerConnectionId)};delete this._currentAudioSend,this._firstAudioFrameTimer&&window.clearTimeout(this._firstAudioFrameTimer),lG.print("rtcFirstFrameSend",Nm(u)),null===(o=this._monitor)||void 0===o||o.report("rtc_first_frame",u),this._audioFirstFrameState=3}else if("video"===e){var d,l,h,p,v;if(1!==this._videoFirstFrameState)return;if(!this._currentVideoSend)return;var _=this._currentVideoSend,f=_.type,m=_.startTime,y={event_type:"sent_end",media_type:e,is_screen:!(null===(d=this._stream)||void 0===d||!d.isScreen),start:m,result:!0,event_session_id:this._videoEventSessionId,type:f,vendor_mode:(null===(l=this._stream)||void 0===l?void 0:l.vendorCode)||0,pc_session_id:(null===(h=this._stream)||void 0===h?void 0:h.pcSessionId)||(null===(p=this._handler)||void 0===p?void 0:p.peerConnectionId)};delete this._currentVideoSend,this._firstVideoFrameTimer&&window.clearTimeout(this._firstVideoFrameTimer),lG.print("rtcFirstFrameSend",Nm(y)),null===(v=this._monitor)||void 0===v||v.report("rtc_first_frame",y),this._videoFirstFrameState=3}}},{key:"setLogin",value:function(e){if(this._login!==e){var t,r;if(this._login=e,e)null!==(t=this._stream)&&void 0!==t&&t.videoTrack&&this.beginSendFrame("video","login"),null!==(r=this._stream)&&void 0!==r&&r.audioTrack&&this.beginSendFrame("audio","login");!e&&this._audioSending&&this.stopSendFrame("audio","leave_room"),!e&&this._videoSending&&this.stopSendFrame("video","leave_room")}}},{key:"setPublish",value:function(e){if(this._publish!==e){var t,r,n,i;if(this._publish=e,e)(null===(t=this._stream)||void 0===t?void 0:t.videoTrack)&&(null===(r=this._stream)||void 0===r?void 0:r.pubVideo)&&this.beginSendFrame("video","publish"),(null===(n=this._stream)||void 0===n?void 0:n.audioTrack)&&(null===(i=this._stream)||void 0===i?void 0:i.pubAudio)&&this.beginSendFrame("audio","publish");!e&&this._audioSending&&this.stopSendFrame("audio","unpublish"),!e&&this._videoSending&&this.stopSendFrame("video","unpublish")}}},{key:"setUnmuteAudio",value:function(e){var t;this._unMuteAudio!==e&&(this._unMuteAudio=e,null!==(t=this._stream)&&void 0!==t&&t.audioHasCapture&&(e&&this.beginSendFrame("audio","unmute"),!e&&this._audioSending&&this.stopSendFrame("audio","mute")))}},{key:"setEnableAudio",value:function(e){var t;this._enableAudio!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubAudio&&(this._enableAudio=e,e&&this.beginSendFrame("audio","enable"),!e&&this._audioSending&&this.stopSendFrame("audio","disable"))}},{key:"setUnmuteVideo",value:function(e){var t;this._unMuteVideo!==e&&(this._unMuteVideo=e,null!==(t=this._stream)&&void 0!==t&&t.videoHasCapture&&(e&&this.beginSendFrame("video","unmute"),!e&&this._videoSending&&this.stopSendFrame("video","mute")))}},{key:"setEnableVideo",value:function(e){var t;this._enableVideo!==e&&null!==(t=this._stream)&&void 0!==t&&t.pubVideo&&(this._enableVideo=e,e&&this.beginSendFrame("video","enable"),!e&&this._videoSending&&this.stopSendFrame("video","disable"))}},{key:"setExternalAudioSource",value:function(e){this._audioExternal!==e&&(this._audioExternal=e,e&&(this._audioSending&&this.stopSendFrame("audio","disable"),this._enableAudio=!1),e||(this._audioSending&&this.stopSendFrame("audio","stop_push"),this._pushAudio=!1))}},{key:"setPushAudio",value:function(e){this._pushAudio!==e&&(this._pushAudio=e,e&&this.beginSendFrame("audio","push"),!e&&this._audioSending&&this.stopSendFrame("audio","stop_push"))}},{key:"setExternalVideoSource",value:function(e){this._videoExternal!==e&&(this._videoExternal=e,e&&(this._videoSending&&this.stopSendFrame("video","disable"),this._enableVideo=!1),e||(this._videoSending&&this.stopSendFrame("video","stop_push"),this._pushVideo=!1))}},{key:"setPushVideo",value:function(e){this._pushVideo!==e&&(this._pushVideo=e,e&&this.beginSendFrame("video","push"),!e&&this._videoSending&&this.stopSendFrame("video","stop_push"))}},{key:"setAutoPublish",value:function(e){this._autoPublish=e}},{key:"setPublisher",value:function(e){this._publisher!==e&&(this._publisher=e,!e&&this._audioSending&&this.stopSendFrame("audio","audience"),!e&&this._videoSending&&this.stopSendFrame("video","audience"))}},{key:"setTimeout",value:function(e){this._timeout=e}},{key:"setPCSessionId",value:function(e){this._pcSessionId=e}},{key:"setHandler",value:function(e){this._handler=e}},{key:"_getFirstVideoFrameStats",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.videoTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=6;break}return e.next=3,dL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.videoTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,c=Hs(s).call(s,(function(e){return"outbound-rtp"===e.type})),e.abrupt("return",c);case 6:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"_getFirstAudioFrameStats",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(t=this._handler)||void 0===t||!t.pc||null===(r=this._stream)||void 0===r||null===(n=r.audioTrack)||void 0===n||!n.getTrack("preprocessing")){e.next=5;break}return e.next=3,dL(null===(i=this._handler)||void 0===i?void 0:i.pc,null===(o=this._stream)||void 0===o||null===(a=o.audioTrack)||void 0===a?void 0:a.getTrack("preprocessing"));case 3:return s=e.sent,e.abrupt("return",gE(s).call(s,(function(e){return"outbound-rtp"===e.type})));case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_watchForFirstVideoFrameSend",value:function(){var e=this,t=-1,r=-1;this._firstVideoFrameInterval&&window.clearInterval(this._firstVideoFrameInterval),this._firstVideoFrameInterval=window.setInterval(Rm(Tm().mark((function n(){var i,o,a;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,e._getFirstVideoFrameStats();case 2:if(i=n.sent,o=0,a=0,null==i||jm(i).call(i,(function(e){o+=e.framesSent,a+=e.packetsSent})),!(i&&i.length>0&&(o>t||a>r))){n.next=12;break}if(-1!==t||-1!==r){n.next=10;break}return t=o,r=a,n.abrupt("return");case 10:e.sendFrameFinish("video"),window.clearInterval(e._firstVideoFrameInterval);case 12:case"end":return n.stop()}}),n)}))),100)}},{key:"_watchForFirstAudioFrameSend",value:function(){var e=this,t=-1;this._firstAudioFrameInterval&&window.clearInterval(this._firstAudioFrameInterval),this._firstAudioFrameInterval=window.setInterval(Rm(Tm().mark((function r(){var n;return Tm().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,e._getFirstAudioFrameStats();case 2:if(!((n=r.sent)&&n.packetsSent>t)){r.next=9;break}if(-1!==t){r.next=7;break}return t=n.packetsSent,r.abrupt("return");case 7:e.sendFrameFinish("audio"),window.clearInterval(e._firstAudioFrameInterval);case 9:case"end":return r.stop()}}),r)}))),100)}},{key:"reset",value:function(){this._login=!1,this._publisher=!1,this._unMuteAudio=!1,this._enableAudio=!1,this._unMuteVideo=!1,this._enableVideo=!1,this._audioExternal=!1,this._pushAudio=!1,this._videoExternal=!1,this._pushVideo=!1,this._autoPublish=!1,this._publish=!1,this._audioFirstFrameState=0,this._videoFirstFrameState=0,this._currentAudioSend={startTime:0,eventSessionId:0,type:"login"},this._currentVideoSend={startTime:0,eventSessionId:0,type:"login"},window.clearTimeout(this._firstAudioFrameTimer),window.clearTimeout(this._firstVideoFrameTimer),window.clearInterval(this._firstAudioFrameInterval),window.clearInterval(this._firstVideoFrameInterval)}},{key:"destroy",value:function(){this.reset(),delete this._stream,delete this._handler}},{key:"_audioSending",get:function(){return 1===this._audioFirstFrameState}},{key:"_videoSending",get:function(){return 1===this._videoFirstFrameState}}]),e}(),pG=(Jd(aG={},"audio",{delay:1200,stallRadio:.3}),Jd(aG,"video",{delay:1200,stallRadio:.6}),Jd(aG,"screen_audio",{delay:1600,stallRadio:.8}),Jd(aG,"screen_video",{delay:1600,stallRadio:.8}),aG),vG=function(){function e(){Vl(this,e),Jd(this,"_preUplinkStats",new $S),Jd(this,"_preDownlinkStats",new $S),Jd(this,"_timer",void 0),Jd(this,"_delayTimer",void 0),Jd(this,"_connectionState",tG.CONNECTED),Jd(this,"reportor",void 0)}return Ul(e,[{key:"updateUplinkStats",value:function(e){var t=e.audioStats,r=e.videoStats,n=e.isScreen;if(t.sendKBitrate>0&&t.rtt){var i,o,a=n?"screen_audio":"audio",s=t.rtt,c=t._fractionLost,u=t._retransmittedRate,d=this._getQosLevel(s,c||0,u||0),l=this._preUplinkStats.get(a)||[d];this._preUplinkStats.set(a,km(i=Om(o=[]).call(o,Jk(l),[d])).call(i,-2))}if(r.sentKBitrate>0&&r.rtt){var h,p,v=n?"screen_video":"video",_=r._fractionLost,f=r.rtt,m=r._sendBandWidth,y=r._retransmittedRate;0===m&&(_=Math.max(.65,_));var g=this._getQosLevel(f,_||0,y||0),S=this._preUplinkStats.get(v)||[g];this._preUplinkStats.set(v,km(h=Om(p=[]).call(p,Jk(S),[g])).call(h,-2))}this._startNetworkQualityReport()}},{key:"updateDownlinkStats",value:function(e,t){if(t){var r,n,i=this._getStreamActiveState(t),o=i.audioActive,a=i.videoActive,s=e.audioStats,c=e.videoStats,u=e.isScreen,d=e.userId;if(o)if(0===s.receivedKBitrate)r=gl.VBAD;else{var l=s.rtt,h=s.audioLossRate,p=s.stallDuration,v=s.statsInterval,_=s.e2eDelay,f=p/v,m=u?"screen_audio":"audio",y=this._getQosLevel(l,h||0,c._retransmittedRate||0),g=this._getDownlinkQoE(m,f,_);r=this._getNetworkQuality(y,g)}if(a)if(0===c.receivedKBitrate||0===c.rtt)n=gl.VBAD;else{var S=c.rtt,b=c.videoLossRate,E=c.stallDuration,k=c.statsInterval,T=c.e2eDelay,I=c._retransmittedRate,R=E/k,A=u?"screen_video":"video",w=this._getQosLevel(S,b||0,I||0),C=this._getDownlinkQoE(A,R,T);n=this._getNetworkQuality(w,C)}var x=r&&n?Math.ceil((r+n)/2):r||n;if(x){var O,D,M,P=Om(O="".concat(d)).call(O,u?"_screen":""),N=this._preDownlinkStats.get(P)||[x];this._preDownlinkStats.set(P,km(D=Om(M=[]).call(M,Jk(N),[x])).call(D,-2)),this._startNetworkQualityReport()}}}},{key:"setConnectionState",value:function(e){this._connectionState=e}},{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._delayTimer&&(window.clearTimeout(this._delayTimer),delete this._delayTimer),this._preUplinkStats.clear(),this._preDownlinkStats.clear()}},{key:"_startNetworkQualityReport",value:function(){var e=this;this._delayTimer||this._timer||(this._preUplinkStats.size>0||this._preDownlinkStats.size>0)&&(this._delayTimer=window.setTimeout((function(){delete e._delayTimer,e._reportNetworkQuality(),e._timer=window.setInterval((function(){e._reportNetworkQuality()}),2e3)}),300))}},{key:"_reportNetworkQuality",value:function(){var e,t,r=this;if(this._connectionState!==tG.CONNECTED)e=t=gl.VBAD;else{var n,i,o,a=this._getBetterQualityAndRemoveOldest("audio","up"),s=this._getBetterQualityAndRemoveOldest("video","up");e=a&&s?Math.ceil((a+s)/2):a||s||this._getBetterQualityAndRemoveOldest("screen_video","up")||this._getBetterQualityAndRemoveOldest("screen_audio","up")||gl.EXCELLENT;var c=Hs(n=jm(i=qk(dO(o=this._preDownlinkStats).call(o))).call(i,(function(e){return r._getBetterQualityAndRemoveOldest(e,"down")}))).call(n,(function(e){return e}));t=Math.ceil(pb(c).call(c,(function(e,t){return t+e}),0)/c.length)||gl.UNKNOWN}"function"==typeof this.reportor&&this.reportor(e,t)}},{key:"_getNetworkQuality",value:function(e,t){return 1===t?Math.max(e-2,1):2===t?e:Math.min(e+1,5)}},{key:"_getQosLevel",value:function(e,t,r){var n;return n=(!e||e<=250)&&t<=.15?1:(!e||e<=500)&&t<=.3?2:(!e||e<=750)&&t<=.45?3:(!e||e<=1e3)&&t<=.6?4:5,r>.5?n=Math.max(n,4):r>.35?n=Math.max(n,3):r>.15&&(n=Math.max(n,2)),n}},{key:"_getUplinkQoE",value:function(e,t){var r=0;switch(e){case"audio":case"video":r=t<.05?1:t<.1?2:3;break;case"screen_video":case"screen_audio":r=t<.04?1:t<.08?2:3}return r}},{key:"_getDownlinkQoE",value:function(e,t,r){var n=pG[e];return t>n.stallRadio||r>n.delay||t>n.stallRadio/2&&r>n.delay/2?3:(t>n.stallRadio/2||n.delay,2)}},{key:"_getBetterQualityAndRemoveOldest",value:function(e,t){var r=gl.UNKNOWN,n="up"===t?this._preUplinkStats:this._preDownlinkStats,i=n.get(e);if(i){var o=Hs(i).call(i,(function(e){return e}));o.length>0&&(r=Math.min.apply(Math,Jk(o))),i.shift(),0===i.length&&n.delete(e)}return r}},{key:"_getStreamActiveState",value:function(e){var t=e.subMediaType,r=e._attributes,n=e.subVideo;return{audioActive:e.subAudio&&kD(t)&&r.localaudio&&r.audiostream,videoActive:n&&TD(t)&&r.localvideo&&r.videostream}}}]),e}(),_G=function(){function e(t){Vl(this,e),Jd(this,"_timer",void 0),Jd(this,"_remoteVideoSizeCache",{}),Jd(this,"_remoteScreenSizeCache",{}),Jd(this,"onchange",void 0),this._room=t,this._start()}return Ul(e,[{key:"destroy",value:function(){this._timer&&(window.clearInterval(this._timer),delete this._timer),this._remoteVideoSizeCache={},this._remoteScreenSizeCache={}}},{key:"_start",value:function(){var e=this;this._timer||(this._timer=window.setInterval((function(){var t={},r={};e._room.remoteStreams.forEach((function(n,i){n.forEach((function(n){var o,a=null===(o=n.videoTrack)||void 0===o?void 0:o.getTrack();if(a){var s=n.isScreen?e._remoteScreenSizeCache:e._remoteVideoSizeCache,c=s[i]||{},u=c.width,d=void 0===u?0:u,l=c.height,h=void 0===l?0:l,p=a.getSettings(),v=p.width,_=void 0===v?0:v,f=p.height,m=void 0===f?0:f;h===m&&d===_||"function"==typeof e.onchange&&e.onchange(i,n.isScreen,_,m),delete s[i],(n.isScreen?r:t)[i]={width:_,height:m}}}))})),an(e._remoteVideoSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!1,0,0)})),an(e._remoteScreenSizeCache).forEach((function(t){"function"==typeof e.onchange&&e.onchange(t,!0,0,0)})),e._remoteVideoSizeCache=t,e._remoteScreenSizeCache=r}),1e3))}}]),e}(),fG=qk((new TextEncoder).encode("subt")),mG={1:hA.SUBTITLE_ERR_POSTPROCESS,2:hA.SUBTITLE_ERR_CONNECTION_ERROR,3:hA.SUBTITLE_ERR_PROCESS_ERROR},yG=new yO("SubtitleTool",1),gG=function(e){if(e.extraInfo)try{var t,r=JSON.parse(e.extraInfo);r.source_language&&xE(t=["zh","en","ja"]).call(t,r.source_language)}catch(a){}else{var n,i,o=(null===(n=navigator.language)||void 0===n?void 0:n.substring(0,2))||"";xE(i=["zh","en","ja"]).call(i,o)>-1&&(e.extraInfo=Nm({source_language:o}))}},SG=function(){function e(t){var r,n,i;Vl(this,e),Jd(this,"_taskId",void 0),Jd(this,"_appId",void 0),Jd(this,"_roomId",void 0),Jd(this,"_userId",void 0),Jd(this,"onEvent",void 0),Jd(this,"onMessage",void 0),Jd(this,"_preConfig",void 0),Jd(this,"_timer",void 0),this._room=t,this._appId=null===(r=this._room._roomInfo)||void 0===r?void 0:r.appId,this._roomId=null===(n=this._room._roomInfo)||void 0===n?void 0:n.roomId,this._userId=null===(i=this._room._roomInfo)||void 0===i?void 0:i.userInfo.userId}var t,r,n;return Ul(e,[{key:"start",value:(n=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(yG.print("start","Invoke config: %o",t),MM(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(EG).call(EG,t.targetLanguage||"")){e.next=4;break}throw new vA(hA.INVALID_PARAMS,"Invalid targetLanguage.");case 4:if(!this._taskId){e.next=6;break}throw new vA(hA.SUBTITLE_ALREADY_ON,"Already turned on subtitle");case 6:return this._preConfig=t,this._taskId=(Date.now().toString()+this._roomId+this._userId).substring(0,20),e.next=10,this._room.subtitleControlMessage(this._genSubtitleSignaling("started",t,this._taskId));case 10:this._preConfig=t,this._timer=self.setTimeout((function(){var e;null===(e=r.onEvent)||void 0===e||e.call(r,{event:Al.ERROR,errorCode:hA.TIME_OUT,errorMessage:"start subtitle timeout."}),delete r._timer,r.stop()}),3e4);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"update",value:(r=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(MM(t.mode,"mode",[Rl.ASR_ONLY,Rl.ASR_AND_TRANSLATION]),t.mode!==Rl.ASR_AND_TRANSLATION||-1!==xE(EG).call(EG,t.targetLanguage||"")){e.next=3;break}throw new vA(hA.INVALID_PARAMS,"Invalid targetLanguage.");case 3:if(!this._taskId){e.next=5;break}throw new vA(hA.SUBTITLE_ALREADY_ON,"Already started subtitle");case 5:if(this._taskId){e.next=7;break}throw new vA(hA.SUBTITLE_NOT_TURNED_ON,"Start subtitle first.");case 7:if((null===(r=this._preConfig)||void 0===r?void 0:r.mode)===t.mode&&this._preConfig.targetLanguage===t.targetLanguage){e.next=11;break}return this._preConfig=t,e.next=11,this._room.subtitleControlMessage(this._genSubtitleSignaling("update",t,this._taskId));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stop",value:function(){var e=this;yG.print("stop","Invoke"),this._taskId&&this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId}).finally((function(){var t;delete e._taskId,null===(t=e.onEvent)||void 0===t||t.call(e,{event:Al.STOPPED}),e._clearTimer()}))}},{key:"reconnect",value:(t=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._taskId||!this._preConfig){e.next=5;break}return e.next=3,this._room.subtitleControlMessage({type:"subtitle",action:"stopped",appId:this._appId,roomId:this._roomId,userId:this._userId,taskId:this._taskId});case 3:delete this._taskId,this.start(this._preConfig);case 5:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getConfig",value:function(){return this._preConfig}},{key:"destroy",value:function(){yG.print("destroy","Invoke"),this.stop(),delete this._preConfig,delete this._taskId}},{key:"onResult",value:function(e){var t=e.body,r=t.error,n=t.errorMessage,i=t.eventType;if(0!==r){var o,a=new vA(mG[r]||hA.SUBTITLE_ERR_UNKNOWN,n||"");null===(o=this.onEvent)||void 0===o||o.call(this,{event:Al.ERROR,errorCode:a.code,errorMessage:a.message}),this._clearTimer()}else if("SubtitleStarted"===i){var s;null===(s=this.onEvent)||void 0===s||s.call(this,{event:Al.STARTED}),this._clearTimer()}}},{key:"onMessageRecv",value:function(e){if(this._taskId&&this._preConfig){var t=bG(e);if(t&&t.length>0){var r,n=this._preConfig,i=n.mode,o=n.targetLanguage,a=[];if(t.forEach((function(e){i===Rl.ASR_ONLY?e.mode===i&&a.push(e):i===Rl.ASR_AND_TRANSLATION&&(e.language!==o&&e.mode!==Rl.ASR_ONLY||a.push(e),e.mode===Rl.ASR_ONLY&&e.language===o&&a.push(Zd(Zd({},e),{},{mode:Rl.ASR_AND_TRANSLATION})))})),a.length>0)null===(r=this.onMessage)||void 0===r||r.call(this,a)}return!!t}return!1}},{key:"_genSubtitleSignaling",value:function(e,t,r){return{taskId:r,type:"subtitle",action:e,roomId:this._roomId,appId:this._appId,userId:this._userId,subtitleMeta:{subtitleConfig:{mode:t.mode,usersConfig:[{userId:this._userId,targetLanguages:[t.targetLanguage||""]}]},vendorConfig:{type:0}}}}},{key:"_clearTimer",value:function(){this._timer&&(self.clearTimeout(this._timer),delete this._timer)}}]),e}(),bG=function(e){var t=e.message;if(t instanceof ArrayBuffer&&t.byteLength>8)try{var r=new DataView(t,0),n=0;if(fG.every((function(e){return r.getUint8(n++)===e}))){var i=r.getUint32(n);if(n+=4,i===r.byteLength-8){var o=cD.ab2str(km(t).call(t,8)),a=JSON.parse(o),s=a.data;if("subtitle"===a.type)return s}}}catch(c){}return!1},EG=["zh","zh-Hant","tn","vi","iu","it","id","hi","en","ho","he","es","el","uk","ur","tk","tr","ti","ty","tl","to","th","ta","te","sl","sk","ss","eo","sm","sg","st","sv","ja","tw","qu","pt","pa","no","nb","nr","my","bn","mn","mh","mk","ml","mr","ms","lu","ro","lt","lv","lo","kj","hr","kn","ki","cs","ca","nl","ko","ht","gu","ka","kl","km","lg","kg","fi","fj","fr","ru","ng","de","tt","da","ts","cv","fa","bs","pl","bi","nd","ba","bg","az","ar","af","sq","ab","os","ee","et","ay","lzh","am","ckb","cy","gl","ha","hy","ig","kmr","ln","nso","ny","om","sn","so","sr","sw","xh","yo","zu"],kG=ad,TG=tc,IG=function(e,t,r,n){for(var i,o=n>1?void 0:n?TG(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&kG(t,r,o),o},RG=function(){function e(t){Vl(this,e),Jd(this,"_forwardDstRooms",new $S),Jd(this,"forwardStreamState","stopped"),Jd(this,"_monitor",void 0),this._room=t,this._monitor=MO(this._room.id)}var t,r,n,i,o,a;return Ul(e,[{key:"startForwardStream2Rooms",value:(a=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("running"!==this.forwardStreamState&&"paused"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke startForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("start",this._room.roomInfo.roomId,t);case 4:return r=e.sent,this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),this.forwardStreamState="running",e.abrupt("return",n);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(o=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke updateForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult(t),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("update",this._room._roomInfo.roomId,t);case 6:r=e.sent;case 7:return this._updateDstRooms(t,r),n=this._transformForwardStreamResult(r),e.abrupt("return",n);case 10:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(i=Rm(Tm().mark((function e(){var t,r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke stopForwardStreamToRooms in state: ".concat(this.forwardStreamState));case 2:if(r=this._mockForwardStreamResult([]),"running"!==this.forwardStreamState){e.next=7;break}return e.next=6,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 6:r=e.sent;case 7:if(this._updateDstRooms([],r),!(Jk(dO(t=this._forwardDstRooms).call(t)).length>0)){e.next=10;break}throw new vA(hA.UNEXPECTED_ERROR,"stopforwardstream failed: ".concat(Nm(r)));case 10:return n=this._transformForwardStreamResult(r),this.forwardStreamState="stopped",e.abrupt("return",n);case 13:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(n=Rm(Tm().mark((function e(){var t,r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("paused"!==this.forwardStreamState&&"stopped"!==this.forwardStreamState){e.next=2;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke pauseForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 2:return e.next=4,this._sendForwardStreamSignaling("stop",this._room._roomInfo.roomId);case 4:return t=e.sent,r=this._transformForwardStreamResult(t),this.forwardStreamState="paused",e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(r=Rm(Tm().mark((function e(){var t,r,n,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o.length>0&&void 0!==o[0]&&o[0]||!mk(t=["running","stopped"]).call(t,this.forwardStreamState)){e.next=3;break}throw new vA(hA.UNEXPECTED_INVOKE_FORWARD_STREAM,"should not invoke resumeForwardStreamToAllRooms in state: ".concat(this.forwardStreamState));case 3:return r=this._getDstRooms(),e.next=6,this._sendForwardStreamSignaling("start",this._room._roomInfo.roomId,r);case 6:return n=e.sent,this._updateDstRooms(r,n),i=this._transformForwardStreamResult(n),this.forwardStreamState="running",e.abrupt("return",i);case 11:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"resumeFromReconnect",value:function(){var e=this;"running"===this.forwardStreamState&&this.resumeForwardStream2AllRooms(!0).then((function(t){t.forEach((function(t){t.state===wl.FORWARD_STREAM_STATE_FAILURE&&e._room.safeEmit(SH.ON_FORWARD_STREAM_ERROR,t)}))}))}},{key:"onForwardDstRoomUserKick",value:function(e){var t=[{dstRoomId:e.dstRoomId,code:200,forwardStreamType:"stop"}];this._updateDstRooms([],t),this._room.safeEmit(SH.ON_FORWARD_STREAM_ERROR,{roomId:e.dstRoomId,state:wl.FORWARD_STREAM_STATE_FAILURE,error:Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED})}},{key:"clear",value:function(){this._forwardDstRooms.clear(),this.forwardStreamState="stopped"}},{key:"_mockForwardStreamResult",value:function(e){var t=this,r=[];return this._forwardDstRooms.forEach((function(e,t){r.push({dstRoomId:t,forwardStreamType:"stop",code:200})})),e.forEach((function(e){var n,i=JR(r).call(r,(function(t){return t.dstRoomId===e.roomId}));-1===i?r.push({dstRoomId:e.roomId,forwardStreamType:"start",code:e.roomId===(null===(n=t._room.roomInfo)||void 0===n?void 0:n.roomId)?400:200}):r[i].forwardStreamType="update"})),r}},{key:"_transformForwardStreamResult",value:function(e){e||(e=[]);var t,r=[],n=$T(e);try{for(n.s();!(t=n.n()).done;){var i=t.value,o=i.dstRoomId,a=i.code,s={roomId:o,state:wl.FORWARD_STREAM_STATE_SUCCESS,error:Cl.FORWARD_STREAM_ERROR_OK};200===a||(400===a?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_REMOTE_KICKED):a>=700&&a<800?(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_INVALID_TOKEN):(s.state=wl.FORWARD_STREAM_STATE_FAILURE,s.error=Cl.FORWARD_STREAM_ERROR_RESPONSE)),r.push(s)}}catch(c){n.e(c)}finally{n.f()}return r}},{key:"_updateDstRooms",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];0===(null==r?void 0:r.length)&&this._forwardDstRooms.clear(),r.forEach((function(r){var n=r.dstRoomId,i=r.code,o=r.forwardStreamType;if(200===i)if("stop"===o)t._forwardDstRooms.delete(n);else{var a,s=gE(e).call(e,(function(e){return e.roomId===n}));if(!s&&!t._forwardDstRooms.has(n))throw new vA(hA.UNEXPECTED_ERROR,"unknow roomid ".concat(n," in signaling return"));var c=null!==(a=t._forwardDstRooms.get(n))&&void 0!==a?a:{token:void 0};c=wb(c,s),t._forwardDstRooms.set(n,c)}else t._forwardDstRooms.has(n)&&t._forwardDstRooms.delete(n)}))}},{key:"_getDstRooms",value:function(){var e=[];return this._forwardDstRooms.forEach((function(t,r){e.push({roomId:r,token:t.token})})),e}},{key:"_sendForwardStreamSignaling",value:(t=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="".concat(dD()),"stop"!==t&&(a=jm(n).call(n,(function(e){return e.roomId})),null===(o=this._monitor)||void 0===o||o.report("rtc_forward_stream",{type:"begin",dst_rooms:"{ ".concat(jm(a).call(a,(function(e){return'"'.concat(e,'"')})).join(",")," }"),event_session_id:i})),e.next=4,this._room._mediaServerClient.sendForwardStreamSignal(t,r,n);case 4:if(s=e.sent,c=[],200===(null==s?void 0:s.code)){e.next=9;break}throw"stop"!==t&&(null==n||n.forEach((function(e){c.push({dst_room_id:e.roomId,result:"server error ".concat(null==s?void 0:s.code)})})),null===(u=this._monitor)||void 0===u||u.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),new vA(hA.UNEXPECTED_ERROR,"server side internal error, error code: ".concat(s));case 9:return"stop"!==t&&(null===(d=s.forwardStreamResults)||void 0===d||d.forEach((function(e){c.push({dst_room_id:e.dstRoomId,result:"dst room lost"})})),null===(l=s.forwardStreamResults)||void 0===l||l.forEach((function(e){var t=gE(c).call(c,(function(t){return t.dst_room_id===e.dstRoomId}));t&&(200===e.code?"update"===e.forwardStreamType?t.result="update":t.result="success":t.result="server error ".concat(e.code))})),null===(h=this._monitor)||void 0===h||h.report("rtc_forward_stream",{type:"end",dst_rooms:Nm(c),event_session_id:i})),e.abrupt("return",s.forwardStreamResults);case 11:case"end":return e.stop()}}),e,this)}))),function(e,r,n){return t.apply(this,arguments)})}]),e}();function AG(e,t,r){var n=r.value;return r.value=Rm(Tm().mark((function e(){var r,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null===(r=this._room._roomInfo)||void 0===r||!r.roomId){e.next=7;break}for(i=s.length,o=new Array(i),a=0;a<i;a++)o[a]=s[a];return e.next=4,n.apply(this,o);case 4:return e.abrupt("return",e.sent);case 7:throw new vA(hA.NOT_CONNECTED_YET,"error in ".concat(t,": try again after joined"));case 8:case"end":return e.stop()}}),e,this)}))),r}IG([AG],RG.prototype,"startForwardStream2Rooms",1),IG([AG],RG.prototype,"updateForwardStream2Rooms",1),IG([AG],RG.prototype,"stopForwardStream2Rooms",1),IG([AG],RG.prototype,"pauseForwardStream2AllRooms",1),IG([AG],RG.prototype,"resumeForwardStream2AllRooms",1);var wG=new yO("Room",1),CG={audiostream:!0,extaudio:!1,extvideo:!1,localaudio:!0,localvideo:!1,videoDescriptions:[],videostream:!1,publishTime:0},xG=function(e){MI(x,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C=JI(x);function x(e,t){var r;return Vl(this,x),Jd(tI(r=C.call(this)),"id",void 0),Jd(tI(r),"_mediaServerClient",void 0),Jd(tI(r),"_localStream",void 0),Jd(tI(r),"_localScreenStream",void 0),Jd(tI(r),"_remoteUsers",new $S),Jd(tI(r),"_remoteStreams",new $S),Jd(tI(r),"_remoteStreamStreamIdUserIdMap",{}),Jd(tI(r),"_virtualStreams",[]),Jd(tI(r),"_context",void 0),Jd(tI(r),"_sessionId",void 0),Jd(tI(r),"_connectionLostTimer",void 0),Jd(tI(r),"_serverConfig",void 0),Jd(tI(r),"_roomConfig",void 0),Jd(tI(r),"_roomInfo",void 0),Jd(tI(r),"_userDuplicateLoginTimerMap",new $S),Jd(tI(r),"_networkQualityManager",void 0),Jd(tI(r),"_videoSizeObserver",void 0),Jd(tI(r),"_hasPublished",!1),Jd(tI(r),"_subtitleTool",void 0),Jd(tI(r),"_csrcUserIdMap",void 0),Jd(tI(r),"_publishOnDemandItem",void 0),Jd(tI(r),"_publishOnDemandBusy",!1),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_forwardStreamManager",void 0),wG.print("constructor","invoke"),r.id=t.id,r._roomConfig=e,r._mediaServerClient=new nG(t),r._networkQualityManager=new vG,r._networkQualityManager.reportor=r._reportNetworkQuality.bind(tI(r)),r._videoSizeObserver=new _G(tI(r)),r._videoSizeObserver.onchange=r._emitVideoSizeChange.bind(tI(r)),r._context=t,r._csrcUserIdMap={},r._monitor=MO(r.id),r._forwardStreamManager=new RG(tI(r)),r._addHandlerEventHandler(),r}return Ul(x,[{key:"hasScreenPublished",get:function(){var e;return null===(e=this._localScreenStream)||void 0===e?void 0:e.hasPublished}},{key:"hasPublished",get:function(){var e;return null===(e=this._localStream)||void 0===e?void 0:e.hasPublished}},{key:"connectionState",get:function(){return this._mediaServerClient.connectionState}},{key:"remoteUsers",get:function(){return this._remoteUsers}},{key:"remoteStreams",get:function(){return this._remoteStreams}},{key:"localStream",get:function(){return this._localStream}},{key:"localScreenStream",get:function(){return this._localScreenStream}},{key:"roomInfo",get:function(){return this._roomInfo}},{key:"roomConfig",set:function(e){this._roomConfig=e}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M=this;null===(e=this._mediaServerClient)||void 0===e||e.on(hH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._mediaServerClient)||void 0===t||t.on(hH.ON_ADD_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onAddStream(e)}))})),null===(r=this._mediaServerClient)||void 0===r||r.on(hH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(n=this._mediaServerClient)||void 0===n||n.on(hH.ON_REMOVE_STREAM_LIST,(function(e){Array.isArray(null==e?void 0:e.streamList)&&e.streamList.forEach((function(e){return M._onRemoveStream(e)}))})),null===(i=this._mediaServerClient)||void 0===i||i.on(hH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(o=this._mediaServerClient)||void 0===o||o.on(hH.USER_CONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserConnection(e)}))})),null===(a=this._mediaServerClient)||void 0===a||a.on(hH.USER_DISCONNECTION,this._onUserDisconnection.bind(this)),null===(s=this._mediaServerClient)||void 0===s||s.on(hH.USER_DISCONNECTION_LIST,(function(e){Array.isArray(null==e?void 0:e.userList)&&e.userList.forEach((function(e){return M._onUserDisconnection(e)}))})),null===(c=this._mediaServerClient)||void 0===c||c.on(hH.ON_UPDATE_ROOM_ATTRIBUTES,this._onUpdateRoomAttributes.bind(this)),null===(u=this._mediaServerClient)||void 0===u||u.on(hH.ON_UPDATE_USER_ATTRIBUTES,this._onUpdateUserAttributes.bind(this)),null===(d=this._mediaServerClient)||void 0===d||d.on(hH.ON_UPDATE_STREAM_ATTRIBUTES,this._onUpdateStreamAttributes.bind(this)),null===(l=this._mediaServerClient)||void 0===l||l.on(hH.ON_PUSH_TRACK,this._onPushTrack.bind(this)),null===(h=this._mediaServerClient)||void 0===h||h.on(hH.ON_REMOVE_TRACK,this._onRemoveTrack.bind(this)),null===(p=this._mediaServerClient)||void 0===p||p.on(hH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(v=this._mediaServerClient)||void 0===v||v.on(hH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(_=this._mediaServerClient)||void 0===_||_.on(hH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(f=this._mediaServerClient)||void 0===f||f.on(hH.POST_PROCESSING_MESSAGE,this._onPostProcessingMessage.bind(this)),null===(m=this._mediaServerClient)||void 0===m||m.on(hH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(y=this._mediaServerClient)||void 0===y||y.on(hH.STREAM_CONTROL_MESSAGE,this._onStreamControlMessage.bind(this)),null===(g=this._mediaServerClient)||void 0===g||g.on(hH.ON_STREAM_FAILED,this._onStreamFailed.bind(this)),null===(S=this._mediaServerClient)||void 0===S||S.on(pH.RSCP,(function(e){!!gE(e).call(e,(function(e){var t,r,n;return null==e||null===(t=e.StreamIds)||void 0===t?void 0:mk(t).call(t,null===(r=M._localStream)||void 0===r||null===(n=r.stream)||void 0===n?void 0:n.id)}))&&(M._publishOnDemandItem=e,M._onPublishOnDemand())})),null===(b=this._mediaServerClient)||void 0===b||b.on(pH.RTT,this._onRTT.bind(this)),null===(E=this._mediaServerClient)||void 0===E||E.on(pH.SSC,this._onSSC.bind(this)),null===(k=this._mediaServerClient)||void 0===k||k.on(vH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(T=this._mediaServerClient)||void 0===T||T.on(vH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return M.emit(vH.ON_VENDOR_CONNECTION_STATE_CHANGE,e)})),null===(I=this._mediaServerClient)||void 0===I||I.on(hH.ON_SPEAKER_CHANGE,this._onMeetingSpeakerChange.bind(this)),null===(R=this._mediaServerClient)||void 0===R||R.on("onRemoteStreamStats",(function(e){M._networkQualityManager.updateDownlinkStats(e,M._findRemoteStreamByScreen(e.userId,e.isScreen)),M.emit(SH.ON_REMOTE_STREAM_STATS,ID(e))})),null===(A=this._mediaServerClient)||void 0===A||A.on(SH.RESUBSCRIBE,(function(e){M.emit(SH.RESUBSCRIBE,e)})),null===(w=this._mediaServerClient)||void 0===w||w.on(SH.RECONNECT_FAILED,(function(){M.emit(SH.RECONNECT_FAILED)})),null===(C=this._mediaServerClient)||void 0===C||C.on("joinSuccess",this._onJoinSucc.bind(this)),null===(x=this._mediaServerClient)||void 0===x||x.on(hH.ON_FORWARD_DST_ROOM_USER_KICK,this._forwardStreamManager.onForwardDstRoomUserKick.bind(this._forwardStreamManager)),null===(O=this._mediaServerClient)||void 0===O||O.on(SH.ON_REJOIN_WITH_TCP,(function(){M.emit(SH.ON_REJOIN_WITH_TCP)})),null===(D=this._mediaServerClient)||void 0===D||D.on(SH.ON_ICE_CONNECT_WITH_TCP,(function(){M.emit(SH.ON_ICE_CONNECT_WITH_TCP)}))}},{key:"_onLocalStreamStats",value:function(e){this._networkQualityManager.updateUplinkStats(e),this.emit(SH.ON_LOCAL_STREAM_STATS,ID(e))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._mediaServerClient)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(w=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.connect();case 2:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"join",value:(A=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return null===(a=this._monitor)||void 0===a||a.set({rtc_app_id:t,room_id:r,user_id:i.userId}),wG.print("join()"),this._mediaServerClient.setLiveControlMessage(o),this._roomInfo={appId:t,roomId:r,token:n,userInfo:i,roomProfile:this._roomConfig.roomProfileType},this.setSessionId(),e.prev=5,e.next=8,this._mediaServerClient.join(this._roomInfo);case 8:return c=e.sent,null!==(s=c.roomAttributes)&&void 0!==s&&s.multiChatMode&&this._handleFFAudioTrack(),this._initSubtitleTool(),e.abrupt("return",{users:c.clients,streams:c.streams});case 14:if(e.prev=14,e.t0=e.catch(5),e.t0.code===hA.OPERATION_CANCEL){e.next=18;break}throw e.t0;case 18:case"end":return e.stop()}}),e,this,[[5,14]])}))),function(e,t,r,n,i){return A.apply(this,arguments)})},{key:"publishScreen",value:(R=Rm(Tm().mark((function e(t,r,n,i,o){var a,s,c,u,d,l,h,p,v,_,f,m;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("publishScreen()"),this._localScreenStream||(this._localScreenStream=new eF(this._context),null!==(a=this._mediaServerClient)&&void 0!==a&&null!==(s=a.vendorConfig)&&void 0!==s&&s.enableMultiVendor&&(this._localScreenStream.pcSessionId=ow()),this._localScreenStream.isScreen=!0,this._mediaServerClient.handler&&(this._localScreenStream.observer=new hG(this._localScreenStream,this._mediaServerClient.handler))),c=!1,u=!1,d=!1,l=!1,!this._localScreenStream.videoTrack&&r?(r instanceof cV&&(u=!0),c=!0):this._localScreenStream.videoTrack&&!r&&(c=!1),!this._localScreenStream.audioTrack&&n?(n instanceof uV&&(l=!0),d=!0):this._localScreenStream.audioTrack&&!n&&(d=!1),this._localScreenStream.videoTrack=r,this._localScreenStream.audioTrack=n,this._localScreenStream.videoEncodeConfig=t,i&&(kD(i)&&(this._localScreenStream.pubAudio=o===EH.PUB),TD(i)&&(this._localScreenStream.pubVideo=o===EH.PUB),wG.print("publishScreen mediaType","pubAudio: %o, pubVideo: %o",this._localScreenStream.pubAudio,this._localScreenStream.pubVideo)),this._localScreenStream.pubAudio||this._localScreenStream.pubVideo){e.next=18;break}if(null===(h=this._localScreenStream)||void 0===h||!h.hasPublished){e.next=17;break}return e.abrupt("return",this.unpublishScreen());case 17:return e.abrupt("return");case 18:if(this._localScreenStream.hasPublished){e.next=24;break}return null===(p=this._localScreenStream.observer)||void 0===p||p.setPublish(!0),e.next=22,this._mediaServerClient.publish(this._localScreenStream);case 22:e.next=28;break;case 24:return u?null===(v=this._localScreenStream.observer)||void 0===v||v.setPushVideo(c):null===(_=this._localScreenStream.observer)||void 0===_||_.setEnableVideo(c),l?null===(f=this._localScreenStream.observer)||void 0===f||f.setPushAudio(d):null===(m=this._localScreenStream.observer)||void 0===m||m.setEnableAudio(d),e.next=28,this.updatePubScreenTrack();case 28:this._localScreenStream.pubAudio||this._localScreenStream.pubVideo?this._localScreenStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localScreenStream.stopReport("unpublish screen");case 29:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,i){return R.apply(this,arguments)})},{key:"updatePubScreenTrack",value:(I=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("updatePubScreenTrack","Invoke updatePubScreenTrack"),!this._localScreenStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localScreenStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return I.apply(this,arguments)})},{key:"unpublishScreen",value:(T=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("unpublish","Invoke unpublishScreen"),!this._localScreenStream){e.next=8;break}return null===(t=this._localScreenStream.observer)||void 0===t||t.setPublish(!1),e.next=5,this._mediaServerClient.unpublish(this._localScreenStream);case 5:this._localScreenStream.stopReport("unpublish screen"),this._localScreenStream.clean(),this._localScreenStream=void 0;case 8:case"end":return e.stop()}}),e,this)}))),function(){return T.apply(this,arguments)})},{key:"liveControlMessage",value:(k=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wG.print("controlMessage","Invoke controlMessage"),null===(r=t.transcodeMeta)||void 0===r||r.layout.regions.forEach((function(e){n.roomInfo&&(e.roomID=n.roomInfo.roomId)})),e.next=4,this._mediaServerClient.controlMessage(t);case 4:this._mediaServerClient.setLiveControlMessage("stopped"===t.action?void 0:t);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"publicStreamControlMessage",value:(E=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"stopped"===t.action&&delete t.publicStreamMeta,e.next=3,this._mediaServerClient.controlMessage(t);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"subtitleControlMessage",value:(b=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._mediaServerClient.controlMessage(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return b.apply(this,arguments)})},{key:"updateUserAttributes",value:(S=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wG.print("updateUserAttributes","Invoke updateUserAttributes"),t.role&&this._roomInfo&&(this._roomInfo.userInfo.role=t.role),e.next=4,this._mediaServerClient.updateUserAttributes(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return S.apply(this,arguments)})},{key:"publish",value:(g=Rm(Tm().mark((function e(t,r,n,i,o,a){var s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=E.length>6&&void 0!==E[6]&&E[6],wG.print("publish","Invoke publish"),c=!1,this._localStream||(this._localStream=new eF(this._context),null!==(u=this._mediaServerClient)&&void 0!==u&&null!==(d=u.vendorConfig)&&void 0!==d&&d.enableMultiVendor&&(this._localStream.pcSessionId=ow()),this._mediaServerClient.handler&&(this._localStream.observer=new hG(this._localStream,this._mediaServerClient.handler)),c=!0,this._localStream.vendorCode=(null===(l=this._mediaServerClient.vendorConfig)||void 0===l?void 0:l.vendorCode)||0),this._localStream.videoTrack=n,this._localStream.audioTrack=i,this._localStream.videoEncodeConfig=t,this._localStream.enableSimulcast=r,o&&(kD(o)&&(this._localStream.pubAudio=a===EH.PUB),TD(o)&&(this._localStream.pubVideo=a===EH.PUB),wG.print("publish mediaType","pubAudio: %o, pubVideo: %o",this._localStream.pubAudio,this._localStream.pubVideo)),this._localStream.hasPublished){e.next=26;break}if(this._localStream.pubAudio||this._localStream.pubVideo){e.next=12;break}return e.abrupt("return");case 12:return e.prev=12,s?null===(h=this._localStream.observer)||void 0===h||h.setLogin(!0):c&&(p=!!this._localStream.videoTrack,v=!!this._localStream.audioTrack,_=this._localStream.videoTrack instanceof cV,f=this._localStream.audioTrack instanceof uV,this._roomConfig.isAutoPublish&&!this._hasPublished?(p&&(_?null===(m=this._localStream.observer)||void 0===m||m.setPushVideo(!0):null===(y=this._localStream.observer)||void 0===y||y.setEnableVideo(!0)),v&&(f?null===(g=this._localStream.observer)||void 0===g||g.setPushAudio(!0):null===(S=this._localStream.observer)||void 0===S||S.setEnableAudio(!0))):null===(b=this._localStream.observer)||void 0===b||b.setPublish(!0)),e.next=16,this._mediaServerClient.publish(this._localStream);case 16:this._hasPublished=!0,this.emit(SH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_SUCC}),e.next=24;break;case 20:throw e.prev=20,e.t0=e.catch(12),this.emit(SH.ON_PUBLISH_RESULT,{isScreen:!1,state:ol.PUBLISH_FAIL}),e.t0;case 24:e.next=28;break;case 26:return e.next=28,this.updatePubTrack();case 28:this._localStream.pubAudio||this._localStream.pubVideo?this._localStream.startReport(this._onLocalStreamStats.bind(this),this._mediaServerClient.handler):this._localStream.stopReport("unpublish");case 29:case"end":return e.stop()}}),e,this,[[12,20]])}))),function(e,t,r,n,i,o){return g.apply(this,arguments)})},{key:"updatePubTrack",value:(y=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("updatePubTrack","Invoke updatePubTrack"),!this._localStream){e.next=4;break}return e.next=4,this._mediaServerClient.updatePubTrack(this._localStream);case 4:case"end":return e.stop()}}),e,this)}))),function(){return y.apply(this,arguments)})},{key:"unpublish",value:(m=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("unpublish","Invoke unpublish"),!this._localStream){e.next=7;break}return e.next=4,this._mediaServerClient.unpublish(this._localStream);case 4:this._localStream.stopReport("unpublish"),this._localStream.clean(),this._localStream=void 0;case 7:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"subscribe",value:(f=Rm(Tm().mark((function e(t,r,n){var i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wG.print("subscribe","remoteStream %o",t),i=void 0,n&&(i=this._getSubLayer(n,t)),e.next=5,this._mediaServerClient.subscribe(t,r,i);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return f.apply(this,arguments)})},{key:"updateSubTrack",value:(_=Rm(Tm().mark((function e(t,r,n,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(wG.print("updateSubTrack","Invoke updateSubTrack"),!i){e.next=4;break}return e.next=4,null===(a=this._mediaServerClient)||void 0===a?void 0:a.updateSubTrackLayer(t,i);case 4:return e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrack(t,r,n));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return _.apply(this,arguments)})},{key:"updateSubVideoConfig",value:(v=Rm(Tm().mark((function e(t,r){var n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((a=this._findRemoteStreamByScreen(t,!1))&&a.hasSubscribed&&!((null==a||null===(n=a.attributes)||void 0===n||null===(i=n.videoDescriptions)||void 0===i?void 0:i.length)<=1)){e.next=3;break}return e.abrupt("return");case 3:return s=this._getSubLayer(r,a),a.originalStreamIndex=s.spatialLayer,e.abrupt("return",null===(o=this._mediaServerClient)||void 0===o?void 0:o.updateSubTrackLayer(a,s));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return v.apply(this,arguments)})},{key:"_getSubLayer",value:function(e,t){for(var r,n,i,o,a,s=null==t?void 0:t.attributes,c=s.videoDescriptions,u=s.subVideoDescriptions,d=Array.isArray(u)?u:c,l=-1,h=e.width*e.height,p=0;p<(null==d?void 0:d.length);p++){var v,_;if(h>=(null===(v=d[p])||void 0===v?void 0:v.width)*(null===(_=d[p])||void 0===_?void 0:_.height)){l=p;break}}var f=d[0];if(-1===l)f=d[l=d.length-1];else if(0!==l){var m=d[l-1].width*d[l-1].height,y=(m-h)/(m-d[l].width*d[l].height);f=y<.1?d[l-1]:d[l],l=y<.1?l-1:l}return a=null!==(r=null===(n=f)||void 0===n?void 0:n.sub_index)&&void 0!==r?r:-1,{spatialLayer:null!==(i=null===(o=f)||void 0===o?void 0:o.video_index)&&void 0!==i?i:l,spatialSubLayer:a}}},{key:"unsubscribe",value:(p=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wG.print("unsubscribe","Invoke unsubscribe"),e.next=3,this._mediaServerClient.unsubscribe(t,r);case 3:case"end":return e.stop()}}),e,this)}))),function(e,t){return p.apply(this,arguments)})},{key:"startSubtitle",value:(h=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._subtitleTool){e.next=5;break}return e.next=3,this._subtitleTool.start(t);case 3:e.next=6;break;case 5:throw new vA(hA.INVOKED_BEFORE_JOIN_ROOM,"join first");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return h.apply(this,arguments)})},{key:"stopSubtitle",value:(l=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:null===(t=this._subtitleTool)||void 0===t||t.stop();case 1:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"startForwardStream2Rooms",value:(d=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.startForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"updateForwardStream2Rooms",value:(u=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.updateForwardStream2Rooms(t));case 1:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"stopForwardStream2Rooms",value:(c=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.stopForwardStream2Rooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"pauseForwardStream2AllRooms",value:(s=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.pauseForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return s.apply(this,arguments)})},{key:"resumeForwardStream2AllRooms",value:(a=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this._forwardStreamManager.resumeForwardStream2AllRooms());case 1:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"leave",value:(o=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=h.length>0&&void 0!==h[0]&&h[0],wG.print("leave","Invoke leave"),n=aD(),null===(t=this._subtitleTool)||void 0===t||t.destroy(),delete this._subtitleTool,e.prev=5,s=$T(iR(a=this._remoteStreams).call(a));try{for(s.s();!(c=s.n()).done;)u=c.value,Array.isArray(u)&&u.forEach((function(e){var t;null===(t=e.observer)||void 0===t||t.setLogin(!1)}))}catch(p){s.e(p)}finally{s.f()}return this._localStream&&(null===(d=this._localStream.observer)||void 0===d||d.setLogin(!1)),e.next=11,this._mediaServerClient.leave().catch((function(){}));case 11:this.destroy(),null===(i=this._monitor)||void 0===i||i.report("rtc_leave_room",{error_code:0,message:"",elapse:aD()-n}),null===(o=this._monitor)||void 0===o||o.set({room_id:"",user_id:"",rtc_session_id:"",rtc_vid:""}),e.next=24;break;case 16:if(e.prev=16,e.t0=e.catch(5),!r){e.next=22;break}throw e.t0;case 22:this.destroy();case 23:e.t0 instanceof Error&&(null===(l=this._monitor)||void 0===l||l.report("rtc_leave_room",{error_code:-1,message:e.t0.message,elapse:aD()-n}));case 24:case"end":return e.stop()}}),e,this,[[5,16]])}))),function(){return o.apply(this,arguments)})},{key:"updateRemoteUserPriority",value:function(e){var t,r=this;null===(t=this.remoteStreams.get(e))||void 0===t||t.forEach((function(t){var n=(r._context||{}).userPriority;t.hasSubscribed&&n.has(e)&&r._mediaServerClient.updateSubPriority(t,n.get(e))}))}},{key:"destroy",value:function(){var e;wG.print("destroy","Invoke destroy"),LO(this.id,"room_destroy","".concat((new Error).stack)),null===(e=this._subtitleTool)||void 0===e||e.destroy(),delete this._subtitleTool,this._mediaServerClient.destroy(),this._removeHandlerEventHandler(),this._roomInfo=void 0,this._remoteUsers=new $S;var t,r,n,i=$T(this._remoteStreams);try{for(i.s();!(t=i.n()).done;){var o=eI(t.value,2)[1];Array.isArray(o)&&o.forEach((function(e){e&&e.destroy()}))}}catch(a){i.e(a)}finally{i.f()}(this._virtualStreams.forEach((function(e){null==e||e.clean()})),this._remoteStreams=new $S,this._localStream)&&(null===(r=this._localStream)||void 0===r||r.clean(),this._localStream=void 0);this._localScreenStream&&(null===(n=this._localScreenStream)||void 0===n||n.clean(),this._localScreenStream=void 0);this._removeHandlerEventHandler(),clearTimeout(this._connectionLostTimer),this._userDuplicateLoginTimerMap.forEach((function(e){clearTimeout(e)})),this._userDuplicateLoginTimerMap.clear(),this._networkQualityManager.destroy(),this._videoSizeObserver.destroy(),this._csrcUserIdMap={},this._virtualStreams=[],this._remoteStreamStreamIdUserIdMap={},this._forwardStreamManager.clear()}},{key:"updateToken",value:(i=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return wG.print("updateToken","Invoke updateToken"),this._roomInfo&&(this._roomInfo.token=t),e.prev=2,e.next=5,this._mediaServerClient.updateToken(t);case 5:e.next=11;break;case 7:throw e.prev=7,e.t0=e.catch(2),this.safeEmit(SH.ON_ROOM_ERROR,{errorCode:hA.UPDATE_TOKEN_WITH_INVALID_TOKEN}),e.t0;case 11:case"end":return e.stop()}}),e,this,[[2,7]])}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessage",value:function(e,t){var r;return null===(r=this._mediaServerClient)||void 0===r?void 0:r.sendUserMessage(e,t)}},{key:"setSessionId",value:function(){var e;this._sessionId=nw(),this._mediaServerClient._sessionId=this._sessionId,null===(e=this._monitor)||void 0===e||e.set({rtc_session_id:this._sessionId})}},{key:"sendRoomMessage",value:(n=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=s.length>1&&void 0!==s[1]&&s[1],a={clientId:null===(r=this._roomInfo)||void 0===r?void 0:r.userInfo.userId,binary:o,message:"",roomId:null===(n=this._roomInfo)||void 0===n?void 0:n.roomId},!o){e.next=8;break}return e.next=5,cD.ab2b64str(t);case 5:a.message=e.sent,e.next=9;break;case 8:a.message=t;case 9:return e.abrupt("return",null===(i=this._mediaServerClient)||void 0===i?void 0:i.sendRoomMessage(a));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"_onJoinSucc",value:function(e){var t,r,n,i=this,o=e.joinRes,a=e.reconnect;wG.print("_onJoinSucc()","invoke. ".concat(a?"[reconnect]":"")),this._serverConfig=o.config,this._mediaServerClient.roomAttributes=o.roomAttributes;var s=[],c=[],u=[],d=[],l=[];null===(t=o.clientsDetail)||void 0===t||t.forEach((function(e){if(e.attributes&&(e.attributes.serverMuteVideo&&i.safeEmit(SH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&i.safeEmit(SH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio})),e.clientId!==o.clientId){var t=i._remoteUsers.get(e.clientId);t?t._stillExist=!0:s.push(e)}}));var h,p=$T(iR(r=this._remoteUsers).call(r));try{for(p.s();!(h=p.n()).done;){var v=h.value;v._stillExist||c.push({clientId:v.userId}),delete v._stillExist}}catch(y){p.e(y)}finally{p.f()}o.streams.forEach((function(e){var t=i._findRemoteStreamByScreen(e.clientId,e.screen);t?(t.stillExist=!0,t.streamId=e.streamId,l.push(e)):d.push(e)}));var _,f=$T(iR(n=this._remoteStreams).call(n));try{for(f.s();!(_=f.n()).done;){var m=_.value;Array.isArray(m)&&m.forEach((function(e){e.stillExist?delete e.stillExist:u.push({clientId:e.userId,streamId:e.streamId,message:dH.clientDisconnected})}))}}catch(y){f.e(y)}finally{f.f()}c.forEach((function(e){return i._onUserDisconnection(e)})),s.forEach((function(e){return i._onUserConnection(e)})),u.forEach((function(e){return i._onRemoveStream(e)})),d.forEach((function(e){return i._onAddStream(e,{fromSignal:!1})})),l.forEach((function(e){return i._onUpdateStreamAttributes(e)})),a&&this._handleSendOrRecvStreamAfterReconnect()}},{key:"_handleSendOrRecvStreamAfterReconnect",value:function(){var e,t,r,n,i,o=this;this._localStream&&(this._localStream.clean(),this._localStream.vendorCode=(null===(r=this._mediaServerClient.vendorConfig)||void 0===r?void 0:r.vendorCode)||0,null===(n=this._localStream.observer)||void 0===n||n.setLogin(!0),this._mediaServerClient.publish(this._localStream).catch((function(e){})));this._localScreenStream&&(this._localScreenStream.clean(),null===(i=this._localScreenStream.observer)||void 0===i||i.setLogin(!0),this._mediaServerClient.publish(this._localScreenStream).catch((function(e){})));var a,s=$T(iR(t=this._remoteStreams).call(t));try{for(s.s();!(a=s.n()).done;){var c=a.value;Array.isArray(c)&&c.forEach(function(){var e=Rm(Tm().mark((function e(t){var r,n,i,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.hasSubscribed){e.next=15;break}return t.resetHasSubscribed(),e.prev=2,wG.print(Om(r="start resubscribe ".concat(t.userId," with ")).call(r,t.subMediaType)),e.next=6,o._mediaServerClient.subscribe(t,t.subMediaType);case 6:wG.print(Om(n="success resubscribe ".concat(t.userId," with ")).call(n,t.subMediaType)),o.safeEmit(SH.RESUBSCRIBE,{stream:t}),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),wG.print(Om(i=Om(a="failed resubscribe ".concat(t.userId," with ")).call(a,t.subMediaType,", error:")).call(i,e.t0)),t.clean(),null==t||t.resetHasSubscribed();case 15:case"end":return e.stop()}}),e,null,[[2,10]])})));return function(t){return e.apply(this,arguments)}}())}}catch(u){s.e(u)}finally{s.f()}null===(e=this._subtitleTool)||void 0===e||e.reconnect(),this._forwardStreamManager.resumeFromReconnect()}},{key:"_handleFFAudioTrack",value:function(){var e,t,r,n,i=null===(e=this._mediaServerClient)||void 0===e||null===(t=e.handler)||void 0===t?void 0:t.audioTrack4ff,o=null===(r=this._mediaServerClient)||void 0===r||null===(n=r.handler)||void 0===n?void 0:n.getTransceivers();if(i&&Array.isArray(o)){var a=gE(o).call(o,(function(e){var t;return(null==e||null===(t=e.receiver)||void 0===t?void 0:t.track)===i}));if(a){var s=new tF(this._context,"ff-stream","ff-stream",!1,!1,CG);s.virtual=!0,s.audioTransceiver=a,s.audioMid="0",s.audioTrack=TV(i),this._virtualStreams.push(s),this.safeEmit(SH.SUBSCRIBE_PUSH_TRACK,{stream:s})}}}},{key:"_findRemoteStream",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.streamId===t})):null}},{key:"_findRemoteStreamByScreen",value:function(e,t){var r=this._remoteStreams.get(e);return Array.isArray(r)?gE(r).call(r,(function(e){return e.isScreen===t})):null}},{key:"_onAddStream",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.needEmit,i=void 0===n||n,o=r.fromSignal,a=void 0===o||o,s=r.virtual,c=void 0!==s&&s;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var u=this._roomConfig,d=u.isAutoSubscribeAudio,l=u.isAutoSubscribeVideo,h=this._findRemoteStreamByScreen(e.clientId,e.screen);if(h&&h.streamId!==e.streamId){var p,v=null===(p=this._remoteStreams.get(e.clientId))||void 0===p?void 0:Hs(p).call(p,(function(e){return e.streamId!==h.streamId}));h.clean(),this._remoteStreams.set(e.clientId,v||[])}var _=this._findRemoteStream(e.clientId,e.streamId);if(this._remoteStreamStreamIdUserIdMap[e.streamId]=e.clientId,_)_.attributes=e.attributes;else if((_=new tF(this._context,e.clientId,e.streamId,e.screen,!1,e.attributes)).virtual=c,this._initStreamListeners(_),!c){var f=this._remoteStreams.get(e.clientId);f?f.push(_):this._remoteStreams.set(e.clientId,[_])}if(this._mediaServerClient.handler&&(_.observer=new dG(_,this._mediaServerClient.handler)),!_.isScreen&&l){var m,y,g,S,b,E,k,T;if(a&&_.hasVideo)if(_.attributes.extvideo)null===(m=_.observer)||void 0===m||m.setExternalVideoSource(!0),null===(y=_.observer)||void 0===y||y.setPushVideo(!0);else null===(g=_.observer)||void 0===g||g.setExternalVideoSource(!1),null===(S=_.observer)||void 0===S||S.setPublishVideo(!0);if(a&&_.hasAudio&&d&&!this._mediaServerClient.roomAttributes.multiChatMode)if(_.attributes.extaudio)null===(b=_.observer)||void 0===b||b.setExternalAudioSource(!0),null===(E=_.observer)||void 0===E||E.setPushAudio(!0);else null===(k=_.observer)||void 0===k||k.setExternalAudioSource(!1),null===(T=_.observer)||void 0===T||T.setPublishAudio(!0);if(!0===i&&!1===a){var I,R=this._roomConfig,A=R.isAutoSubscribeAudio,w=R.isAutoSubscribeVideo;null===(I=_.observer)||void 0===I||I.setLogin(!0,{audio:!!A&&!this.multiChatMode,video:!!w})}}return i&&this.safeEmit(hH.ON_ADD_STREAM,{stream:_}),_}}},{key:"_onUserConnection",value:function(e){var t;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var r=this._userDuplicateLoginTimerMap.get(e.clientId);if("number"==typeof r)return this._userDuplicateLoginTimerMap.delete(e.clientId),void self.clearTimeout(r);var n={userId:e.clientId,extraInfo:e.attributes.extra_info};this._remoteUsers.set(e.clientId,Zd({},n)),this.safeEmit(hH.USER_CONNECTION,{userInfo:n}),e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(SH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(SH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}}},{key:"_onUserDisconnection",value:function(e){var t,r=this,n=e.clientId,i=e.tag,o=e.code;if(n)if(n===(null===(t=this.roomInfo)||void 0===t?void 0:t.userInfo.userId)){var a=null;i===_H.kickedByAdmin?a=hA.KICKED_OUT:i===_H.onUserTokenDidExpire?a=hA.TOKEN_EXPIRED:i===_H.userDuplicateLogin&&(a=hA.DUPLICATE_LOGIN),o===fH.roomDismissByAdmin&&(a=hA.ROOM_DISMISS),a&&this.safeEmit(SH.ON_ROOM_ERROR,{errorCode:a})}else{var s=tl.DROPPED;i===_H.userLeave?s=tl.QUIT:i===_H.kickedByAdmin?s=tl.KICKED_BY_ADMIN:i===_H.roleChanged&&(s=tl.SWITCH_TO_INVISIBLE);var c=function(){var e;r._remoteUsers.delete(n),null===(e=r._remoteStreams.get(n))||void 0===e||e.forEach((function(e){r._onRemoveStream({clientId:e.userId,streamId:e.streamId,message:dH.clientDisconnected})})),r._remoteStreams.delete(n),r.safeEmit(SH.ON_USER_LEAVE,{userInfo:{userId:n},reason:s})};if(i===_H.userDuplicateLogin){var u=this._userDuplicateLoginTimerMap.get(n);u&&self.clearTimeout(u);var d=self.setTimeout(c,5e3);this._userDuplicateLoginTimerMap.set(n,d)}else c()}}},{key:"_onRemoveStream",value:function(e){var t,r=this;if(e.clientId!==(null===(t=this._roomInfo)||void 0===t?void 0:t.userInfo.userId)){var n=this._remoteStreams.get(e.clientId);if(n){var i=gE(n).call(n,(function(t){return t.streamId===e.streamId}));if(i){var o,a,s;if(null===(o=this._mediaServerClient)||void 0===o||o.handleRemoveStream(i,e).then((function(){var t=r._remoteStreams.get(e.clientId);t&&(t=Hs(t).call(t,(function(t){return t.streamId!==e.streamId||(t.clean(),!1)})),r._remoteStreams.set(e.clientId,t))})).finally((function(){r.safeEmit(hH.ON_REMOVE_STREAM,{stream:i,reason:e.message,callback:function(){return i.destroy()}})})),i.hasVideo)null===(a=i.observer)||void 0===a||a.setPublishVideo(!1);if(i.hasAudio&&!this._mediaServerClient.roomAttributes.multiChatMode)null===(s=i.observer)||void 0===s||s.setPublishAudio(!1)}}}}},{key:"_onUpdateUserAttributes",value:function(e){e.attributes&&(e.attributes.serverMuteVideo&&this.safeEmit(SH.ON_VIDEO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteVideo}),e.attributes.serverMuteAudio&&this.safeEmit(SH.ON_AUDIO_STREAM_BANNED,{uid:e.clientId,banned:1===e.attributes.serverMuteAudio}))}},{key:"_onUpdateRoomAttributes",value:function(e){var t;e.roomAttributes&&(this._mediaServerClient.roomAttributes=Zd(Zd({},this._mediaServerClient.roomAttributes),e.roomAttributes)),null!==(t=e.roomAttributes)&&void 0!==t&&t.multiChatMode&&this._handleFFAudioTrack()}},{key:"_onUpdateStreamAttributes",value:function(e){var t=this._roomConfig,r=t.isAutoSubscribeAudio,n=t.isAutoSubscribeVideo,i=e.clientId,o=e.streamId,a=e.attributes,s=this._findRemoteStream(i,o);if(s){var c,u,d=s.attributes,l=Zd(Zd({},d),a),h=!1,p=l.localaudio!==d.localaudio,v=!1,_=!1,f=l.localvideo!==d.localvideo,m=!1,y=NV.NONE,g=NV.NONE;if(l.audiostream!==d.audiostream&&(h=l.localaudio,v=!!l.audiostream,l.audiostream?y|=ul.AUDIO:g|=ul.AUDIO),l.videostream!==d.videostream&&(_=l.localvideo,m=!!l.videostream,l.videostream?y|=ul.VIDEO:g|=ul.VIDEO),y&&this.safeEmit(SH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:y,isScreen:s.isScreen,pubState:EH.PUB,remoteStream:s}),g&&this.safeEmit(SH.ON_USER_PUBLISH_STATE_CHANGE,{userId:i,mediaType:g,isScreen:s.isScreen,pubState:EH.UNPUB,remoteStream:s}),s.attributes=l,l.localaudio!==d.localaudio)if(l.localaudio){var S,b,E,k;if(r&&l.audiostream)if(l.extaudio)null===(S=s.observer)||void 0===S||S.setExternalAudioSource(!0),null===(b=s.observer)||void 0===b||b.setPushAudio(!0);else null===(E=s.observer)||void 0===E||E.setExternalAudioSource(!1),null===(k=s.observer)||void 0===k||k.setEnableAudio(!0);this.safeEmit(SH.ON_USER_START_AUDIO_CAPTURE,{userId:i},s)}else{var T,I,R,A;if(l.extaudio)null===(T=s.observer)||void 0===T||T.setExternalAudioSource(!0),null===(I=s.observer)||void 0===I||I.setPushAudio(!1);else null===(R=s.observer)||void 0===R||R.setExternalAudioSource(!1),null===(A=s.observer)||void 0===A||A.setEnableAudio(!1);!s.isScreen&&this.safeEmit(SH.ON_USER_STOP_AUDIO_CAPTURE,{userId:i})}if(l.localvideo!==d.localvideo)if(l.localvideo){var w,C,x,O;if(n&&l.videostream)if(l.extvideo)null===(w=s.observer)||void 0===w||w.setExternalVideoSource(!0),null===(C=s.observer)||void 0===C||C.setPushVideo(!0);else null===(x=s.observer)||void 0===x||x.setExternalVideoSource(!1),null===(O=s.observer)||void 0===O||O.setEnableVideo(!0);this.safeEmit(SH.ON_USER_START_VIDEO_CAPTURE,{userId:i})}else{var D,M,P,N;if(l.extvideo)null===(D=s.observer)||void 0===D||D.setExternalVideoSource(!0),null===(M=s.observer)||void 0===M||M.setPushVideo(!1);else null===(P=s.observer)||void 0===P||P.setExternalVideoSource(!1),null===(N=s.observer)||void 0===N||N.setEnableVideo(!1);!s.isScreen&&this.safeEmit(SH.ON_USER_STOP_VIDEO_CAPTURE,{userId:i})}if(h&&!p)null===(c=s.observer)||void 0===c||c.setRemoteUnmuteAudio(v);if(_&&!f)null===(u=s.observer)||void 0===u||u.setRemoteUnmuteVideo(m)}}},{key:"_onPushTrack",value:function(e){var t,r=this;if(null!==(t=e.streamId)&&void 0!==t&&lA(t).call(t,"audio_mux")){var n=this._onAddStream(Zd(Zd({},e),{},{attributes:CG}),{needEmit:!1,fromSignal:!1,virtual:!0});n&&this._mediaServerClient.subscribe4pushTrack(n,e).then((function(){r.safeEmit(SH.SUBSCRIBE_PUSH_TRACK,{stream:n}),r._virtualStreams.push(n)})).catch((function(e){wG.print("subscribe","push track failed %o",e)}))}else{var i,o;null===(i=this._monitor)||void 0===i||i.report("rtc_error",{message:Om(o="onPushTrack, userId: ".concat(e.clientId,", ")).call(o,e.streamId),error_code:AH.TRACK_ERROR})}}},{key:"_onRemoveTrack",value:function(e){var t,r=e.clientId,n=e.streamId,i=e.message,o=e.trackType;wG.print("_onRemoveTrack","remove track: %o",r);var a=this._findRemoteStream(r,n);a&&(null===(t=this._mediaServerClient)||void 0===t||t.unsubscribe4removeTrack(a,i,o),this.emit(SH.REMOVE_PUSH_TRACK,{stream:a,mediaType:o+1}))}},{key:"_onMeetingSpeakerChange",value:function(e){if(Array.isArray(null==e?void 0:e.speakerCsrcInfo)){var t={};null==e||e.speakerCsrcInfo.forEach((function(e){var r=e.csrc,n=e.userId;e.isScreen||(t[r]=n)})),this._csrcUserIdMap=t}Array.isArray(e.muxStreamInUse)&&this._virtualStreams.forEach((function(t){var r;null!==(r=e.muxStreamInUse)&&void 0!==r&&mk(r).call(r,t.streamId)?t.virtualOccupy=!0:t.virtualOccupy=!1}))}},{key:"getActiveSpeakerInMultiChatMode",value:function(){var e=this,t=[];return this._virtualStreams.forEach((function(r){var n,i=null===(n=r.audioTransceiver)||void 0===n?void 0:n.receiver;if(i){var o=eI(i.getContributingSources()||[],1)[0];if(o){var a=o.audioLevel,s=o.source;e._csrcUserIdMap[s]&&t.push({userId:e._csrcUserIdMap[s],audioLevel:a})}}})),t.length&&jR(t).call(t,(function(e,t){return e.audioLevel-t.audioLevel})),t}},{key:"_onReconnecting",value:function(){var e,t,r,n,i=this,o=$T(iR(r=this._remoteStreams).call(r));try{for(o.s();!(n=o.n()).done;){var a=n.value;Array.isArray(a)&&a.forEach((function(e){return e.clean()}))}}catch(s){o.e(s)}finally{o.f()}this._virtualStreams.forEach((function(e){i.emit(SH.REMOVE_PUSH_TRACK,{stream:e,mediaType:ul.AUDIO}),e.clean()})),this._virtualStreams=[],null===(e=this.localStream)||void 0===e||e.clean(),null===(t=this.localScreenStream)||void 0===t||t.clean()}},{key:"_onConnectionStateChange",value:function(e){var t,r=this;if(e.next===tG.DISCONNECTED)t=ll.CONNECTION_STATE_DISCONNECTED;else if(e.next===tG.CONNECTED)clearTimeout(this._connectionLostTimer),t=this._mediaServerClient.isReconnecting?ll.CONNECTION_STATE_RECONNECTED:ll.CONNECTION_STATE_CONNECTED;else{if(e.next!==tG.CONNECTING)return;this._mediaServerClient.isReconnecting?(t=ll.CONNECTION_STATE_RECONNECTING,this._onReconnecting()):t=ll.CONNECTION_STATE_CONNECTING}e.prev===tG.CONNECTED&&e.next===tG.DISCONNECTED&&(this._connectionLostTimer=window.setTimeout((function(){r.safeEmit(vH.ON_CONNECTION_STATE_CHANGE,{state:ll.CONNECTION_STATE_LOST})}),1e4)),this._networkQualityManager.setConnectionState(e.next),this.safeEmit(vH.ON_CONNECTION_STATE_CHANGE,{state:t})}},{key:"_initStreamListeners",value:function(e){var t=this;e.on("ontrack",(function(e){e.track})),e.on("onSEIMessage",(function(r){var n;t.emit(SH.ON_SEI_MESSAGED_RECEIVED,{sei:r,remoteStreamKey:{userId:e.userId,roomId:null===(n=t._roomInfo)||void 0===n?void 0:n.roomId,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN}})}))}},{key:"_onCustomMessage",value:function(e){this.safeEmit(hH.ON_CUSTOM_MESSAGE,e)}},{key:"_onUserMessageReceived",value:function(e){this.safeEmit(hH.USER_MESSAGE_RECEIVED,{userId:e.from,message:e.msg})}},{key:"_onUserBinaryMessageReceived",value:function(e){var t,r={userId:e.from,message:e.msg};null!==(t=this._subtitleTool)&&void 0!==t&&t.onMessageRecv(r)||this.safeEmit(hH.USER_BINARY_MESSAGE_RECEIVED,r)}},{key:"_initSubtitleTool",value:function(){var e=this;this._subtitleTool=new SG(this),this._subtitleTool.onEvent=function(t){e.emit(SH.ON_SUBTITLE_STATE_CHANGED,t)},this._subtitleTool.onMessage=function(t){e.emit(SH.ON_SUBTITLE_MESSAGE_RECEIVED,t)}}},{key:"_onPostProcessingMessage",value:function(e){if(e.body)if("subtitleCallback"!==e.type){var t=e.body,r=t.error||0,n=bH.START,i=["success","parameter error","subscription timeout","ffmpeg error","cdn error","publish error"];if("2.0"===t.protocol){switch(t.eventType){case"TranscodeStarted":0!==t.error&&(n=bH.START_FAILED);break;case"TranscodeStateChanged":n=0!==t.error?bH.START_FAILED:bH.START_SUCCESS;break;case"TranscodeStopped":n=0!==t.error?bH.STOP_FAILED:bH.STOP_SUCCESS;break;case"TranscodeUpdated":n=0!==t.error?bH.UPDATE_FAILED:bH.UPDATE_SUCCESS}this.safeEmit(hH.POST_PROCESSING_MESSAGE,{code:r,protocol:t.protocol,error:t.error,eventType:n,message:i[r]})}this.safeEmit(hH.POST_PROCESSING_MESSAGE,{code:r,message:i[r],type:e.type})}else{var o;null===(o=this._subtitleTool)||void 0===o||o.onResult(e)}}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(hH.ON_USER_TOKEN_WILL_EXPIRE,null)}},{key:"_onStreamFailed",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("publish"!==t.type){e.next=11;break}if(s=void 0,(null===(r=this.localStream)||void 0===r?void 0:r.streamId)===t.streamId?s=this.localStream:(null===(n=this.localScreenStream)||void 0===n?void 0:n.streamId)===t.streamId&&(s=this.localScreenStream),s){e.next=5;break}return e.abrupt("return");case 5:return null===(i=s)||void 0===i||i.clean(),e.next=8,null===(o=this._mediaServerClient)||void 0===o?void 0:o.unpublish(s).catch((function(){}));case 8:null===(a=this._mediaServerClient)||void 0===a||a.publish(s).catch((function(){})),e.next=20;break;case 11:if("subscribe"!==t.type){e.next=20;break}if(c=this._remoteStreamStreamIdUserIdMap[t.streamId],!(u=this._findRemoteStream(c,t.streamId))){e.next=20;break}return e.next=17,null===(d=this._mediaServerClient)||void 0===d?void 0:d.unsubscribe(u,ul.AUDIO_AND_VIDEO);case 17:return e.next=19,null===(l=this._mediaServerClient)||void 0===l?void 0:l.subscribe(u,u.subMediaType,u.subLayer);case 19:this.safeEmit(SH.RESUBSCRIBE,{stream:u});case 20:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_onStreamControlMessage",value:function(e){var t,r;e.type===lH.PushLimitWarn&&(null!==(t=this._localStream)&&void 0!==t&&t.pubAudio||null!==(r=this._localStream)&&void 0!==r&&r.pubVideo||this.unpublish())}},{key:"_onPublishOnDemand",value:(t=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._publishOnDemandBusy&&!1!==(null===(t=this._serverConfig)||void 0===t||null===(r=t.engine_VPM)||void 0===r||null===(n=r.ondemand)||void 0===n?void 0:n.enable)){e.next=2;break}return e.abrupt("return");case 2:if(a=this._publishOnDemandItem,this._publishOnDemandItem=void 0,a){e.next=6;break}return e.abrupt("return");case 6:if(null===(i=this._localStream)||void 0===i||!i.enableSimulcast||null===(o=this._localStream)||void 0===o||!o.videoTransceiver){e.next=16;break}return u=[],this._publishOnDemandBusy=!0,d=null===(s=this._localStream)||void 0===s?void 0:s.stream.id,l=null===(c=this._localStream)||void 0===c?void 0:c.videoTransceiver.sender,h=l.getParameters(),Array.isArray(h.encodings)&&Array.isArray(a)&&(v={},wG.print("_onPublishOnDemand exec","usedDescriptions: %o",a),a.forEach((function(e){var t;if(null!=e&&null!==(t=e.StreamIds)&&void 0!==t&&mk(t).call(t,d)){var r=null==e?void 0:e.Metadata.VideoIndex;v[r]=!0}})),h.encodings=jm(p=h.encodings).call(p,(function(e){if(e.rid){v[e.rid]?e.active=!0:e.active=!1;var t=+e.rid;u[t]=e.active}return e})),this._context&&(this._context.activeSimStreams=u)),e.next=15,l.setParameters(h);case 15:this._publishOnDemandBusy=!1;case 16:this._onPublishOnDemand();case 17:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_onRTT",value:function(e){var t=e.StreamIds,r=e.Metadata;if(t.length&&r){var n,i=t[0];null!==(n=this._context)&&void 0!==n&&n.streamRTT&&(this._context.streamRTT[i]={audio:r.audio_rtt,video:r.video_rtt})}}},{key:"_onSSC",value:function(e){var t=e.StreamIds,r=e.Metadata,n=t[0],i=this._remoteStreamStreamIdUserIdMap[n],o=this._findRemoteStream(i,n),a={userId:i,isScreen:!!o&&o.isScreen,beforeVideoIndex:r.ssc_items[0].prev_layer_id,afterVideoIndex:r.ssc_items[0].cur_layer_id,beforeEnable:0!==r.ssc_items[0].prev_video_open,afterEnable:0!==r.ssc_items[0].cur_video_open,reason:r.ssc_items[0].change_reason};this.emit(SH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,a)}},{key:"_reportNetworkQuality",value:function(e,t){this.emit(SH.ON_NETWORK_QUALITY,e,t)}},{key:"_emitVideoSizeChange",value:function(e,t,r,n){var i;this.emit(SH.ON_REMOTE_VIDEO_SIZE_CHANGED,{roomId:null===(i=this.roomInfo)||void 0===i?void 0:i.roomId,userId:e,streamIndex:t?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN},{width:r,height:n})}},{key:"multiChatMode",get:function(){var e;return null===(e=this._mediaServerClient)||void 0===e?void 0:e.multiChatMode()}}]),x}(tP),OG=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=document.createElement(e);return t.id&&(r.id=t.id),t.classList&&t.classList.forEach((function(e){r.classList.add(e)})),t.style&&wb(r.style,t.style),t.attributes&&kA(t.attributes).forEach((function(e){var t=eI(e,2),n=t[0],i=t[1];"muted"===n?r.muted=!0:r.setAttribute(n,i)})),r},DG=new yO("Player",0),MG=["play","playing","pause","ended","error","seeking","seeked","waiting","canplay","canplaythrough","durationchange","volumechange","loadedmetadata","loadeddata","loadstart","timeupdate"],PG={playsinline:"","webkit-playsinline":""},NG={playsinline:"","webkit-playsinline":"","x5-playsinline":"","x5-video-player-type":"h5","x-webkit-airplay":"allow",preload:"",muted:""},LG=function(e){MI(n,e);var t,r=JI(n);function n(e,t){var i;Vl(this,n),Jd(tI(i=r.call(this)),"_containerDom",void 0),Jd(tI(i),"_videoDom",void 0),Jd(tI(i),"__cumulativeTime",void 0),Jd(tI(i),"userId",void 0),Jd(tI(i),"renderMode",void 0),Jd(tI(i),"mirrorType",hl.MIRROR_TYPE_NONE),Jd(tI(i),"isScreen",void 0),Jd(tI(i),"isLocal",void 0),Jd(tI(i),"played",!1),Jd(tI(i),"_needLoad",!1),Jd(tI(i),"_emitPlayFailed",!1),Jd(tI(i),"_videoContainer",void 0),Jd(tI(i),"_safari15VideoTimer",void 0),Jd(tI(i),"_monitor",void 0),Jd(tI(i),"_onLocalTrackMute",void 0),Jd(tI(i),"_onInterruptionEnd",void 0),Jd(tI(i),"_needResume",!1),Jd(tI(i),"emitVideoEvent",(function(e){var t,r,n={type:"video",rawEvent:e,readyState:(null===(t=i._videoDom)||void 0===t?void 0:t.readyState)||0,userId:i.userId,eventName:e.type,currentTime:(null===(r=i._videoDom)||void 0===r?void 0:r.currentTime)||0,isScreen:i.isScreen};switch(i.emit("playback_event",n),e.type){case"canplay":case"loadeddata":i._internalPlay();break;case"playing":DG.print("VideoPlayerPlaying","[userId-".concat(i.userId,"] video element playing"));break;case"pause":DG.print("VideoPlayerPause","[userId-".concat(i.userId,"] video element pause")),i._needResume&&(DG.print("VideoPlayerPause","[userId-".concat(i.userId,"] video element resume")),i._internalPlay(),i._needResume=!1)}})),Jd(tI(i),"_internalPlay",(function(){var e;if(null!==(e=i._videoDom)&&void 0!==e&&e.paused){var t=i._videoDom.play();null!=t&&t.then&&t.then((function(){var e;i.isLocal&&HD&&!i._needLoad&&(null===(e=i._videoDom)||void 0===e||e.load(),i._needLoad=!0)})).catch((function(e){var t,r,n,o,a,s;i._emitPlayFailed||("AbortError"!==e.name?(i._emitPlayFailed=!0,null===(t=i._monitor)||void 0===t||t.report("rtc_error",{message:Om(r="video autoplay failed, userId: ".concat(i.userId,", ")).call(r,e.name),error_code:AH.AUTOPLAY_FAILED}),i.emit("playback_event",{type:"video",rawEvent:e,readyState:(null===(n=i._videoDom)||void 0===n?void 0:n.readyState)||0,userId:i.userId,eventName:"autoplay-error",currentTime:(null===(o=i._videoDom)||void 0===o?void 0:o.currentTime)||0,isScreen:i.isScreen})):null===(a=i._monitor)||void 0===a||a.report("rtc_error",{message:Om(s="video autoplay failed, userId: ".concat(i.userId,", ")).call(s,e.name),error_code:AH.AUTOPLAY_FAILED}))}))}})),i.engineId=e;var o=t.renderDom;i._monitor=MO(e);var a=t.userId,s=t.isScreen?sl.RENDER_MODE_FIT:sl.RENDER_MODE_HIDDEN;i.renderMode=void 0!==t.renderMode?t.renderMode:s;var c="string"==typeof o?document.getElementById(o):o;if(!c)throw new vA(hA.CANT_FIND_DOM,"can't find dom");return i._videoContainer=document.createElement("div"),i._videoContainer.style.width="100%",i._videoContainer.style.height="100%",i._videoContainer.style.position="relative",i._videoContainer.style.overflow="hidden",i._containerDom=c,i.userId=a,i.isLocal=!!t.isLocal,i.isScreen=!!t.isScreen,i._initVideo(),i}return Ul(n,[{key:"_initVideo",value:function(){var e,t=this;this._videoDom||(this._videoDom=OG("video",{style:{width:"100%",height:"100%"},attributes:NG}),this._videoDom.id=Om(e="".concat(this.userId,"_")).call(e,oD()),this.setRenderMode(this.renderMode),this.mirror(this.mirrorType===hl.MIRROR_TYPE_RENDER));this._videoContainer.appendChild(this._videoDom),this._containerDom.appendChild(this._videoContainer),this._initListeners(),this._onLocalTrackMute=function(){t._needResume=!0},this._onInterruptionEnd=function(){DG.print("resume player after iOS interruption"),t._internalPlay()},GU.on(jU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),GU.on(jU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),GU.on(jU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd)}},{key:"_initListeners",value:function(){var e=this;this._videoDom&&MG.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.addEventListener(t,e.emitVideoEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._videoDom&&MG.forEach((function(t){var r;null===(r=e._videoDom)||void 0===r||r.removeEventListener(t,e.emitVideoEvent)}))}},{key:"_recordFrame",value:function(e){var t=this,r=e.isScreen?1.5:.55;if(BD){var n;if(null===(n=this._videoDom)||void 0===n||!n.requestVideoFrameCallback)return;this._videoDom.requestVideoFrameCallback((function n(i,o){var a=o.presentationTime;if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t.__cumulativeTime){var s,c=(a-t.__cumulativeTime)%2e3,u=c>1e3*r;null===(s=e.recordedVideoFrames)||void 0===s||s.push({playTime:a,isStall:u,stallCount:u?1:0,stallDuration:c})}t.__cumulativeTime=a,t._videoDom.requestVideoFrameCallback(n)}))}else this.on("playback_event",(function(n){var i;if("timeupdate"===n.eventName){if(0===(null===(i=t._videoDom)||void 0===i?void 0:i.currentTime))return;if(void 0===t.__cumulativeTime)return void(t.__cumulativeTime=t._videoDom.currentTime);if(e.recordedVideoFrames||(e.recordedVideoFrames=[]),t._videoDom.currentTime>t.__cumulativeTime){var o=Math.floor(1e3*(t._videoDom.currentTime-t.__cumulativeTime)),a=t._videoDom.currentTime-t.__cumulativeTime>r;e.recordedVideoFrames.push({playTime:t._videoDom.currentTime,isStall:a,stallCount:a?1:0,stallDuration:o%2e3})}t.__cumulativeTime=t._videoDom.currentTime}}))}},{key:"_recordPause",value:function(e){var t=this;void 0===e.statsReport.isPaused&&this.on("playback_event",(function(r){if("pause"===r.eventName)e.statsReport.isPaused=!0,e.statsReport.pauseStart=aD();else if("timeupdate"===r.eventName){var n;if((null===(n=t._videoDom)||void 0===n||!n.paused)&&e.statsReport.isPaused){e.statsReport.isPaused=!1;var i=aD()-(e.statsReport.pauseStart||0);i>500&&(e.statsReport.pauseDuration+=i)}}}))}},{key:"setRenderMode",value:function(e){this.renderMode=e,this._videoDom&&(this.renderMode===sl.RENDER_MODE_FIT?this._videoDom.style.objectFit="contain":this.renderMode===sl.RENDER_MODE_FILL?this._videoDom.style.objectFit="fill":this._videoDom.style.objectFit="cover")}},{key:"playVideo",value:(t=Rm(Tm().mark((function e(t,r){var n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=this._videoDom,DG.print("playVideo","play video track: ".concat(this.userId)),!(o&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(n=t.getTrack())||void 0===n?void 0:n.id))){e.next=5;break}try{LO(this.engineId,"playVideo","play video repeatedly",0,this.userId)}catch(eq){}return e.abrupt("return");case 5:o||(this._initVideo(),o=this._videoDom),DG.print("playVideo","play video by dom: ".concat(null===(i=o)||void 0===i?void 0:i.id)),(a=new MediaStream).addTrack(t.getTrack("preprocessing")),o.srcObject=a,o&&!this._containerDom.contains(this._videoContainer)&&this._containerDom.appendChild(this._videoContainer),o&&!this._videoContainer.contains(o)&&this._videoContainer.appendChild(o),setTimeout((function(){return s._internalPlay()})),r&&TM.VIDEO_STALL&&(this._recordFrame(r),this._recordPause(r),r.statsReport.player=this),this.played=!0;case 15:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"updateSrcObject",value:function(e){var t=e.getTrack();if(t&&this._videoDom){var r=new MediaStream;r.addTrack(t),this._videoDom.srcObject=r}}},{key:"removeTrack",value:function(){var e,t=null===(e=this._videoDom)||void 0===e?void 0:e.srcObject;if(t){var r=t.getVideoTracks();null!=r&&r.length&&r.forEach((function(e){t.removeTrack(e)}))}}},{key:"manuallyPlay",value:function(){if(DG.print("Invoke VideoPlayer.manuallyPlay",this.userId,this.isScreen),this._emitPlayFailed=!1,!this._videoDom)throw new vA(hA.INVALID_PARAMS,"Player not found");return 0!==this._videoDom.readyState||YD?this._videoDom.play():Yf.resolve()}},{key:"mirror",value:function(e){var t;DG.print("mirror",Om(t="".concat(this.userId," set mirror: ")).call(t,e)),this.mirrorType=e?hl.MIRROR_TYPE_RENDER:hl.MIRROR_TYPE_NONE,this._videoDom&&(this._videoDom.style.transform=e?"rotateY(180deg)":"")}},{key:"stop",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=this._containerDom;(DG.print("stop","stop video track: ".concat(this.userId)),this._videoDom)&&(t||(this._videoDom.srcObject=null),null!=r&&r.contains(this._videoContainer)&&r.removeChild(this._videoContainer),null!==(e=this._videoContainer)&&void 0!==e&&e.contains(this._videoDom)&&this._videoContainer.removeChild(this._videoDom));this.__cumulativeTime=void 0,this.played=!1}},{key:"destroy",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];DG.print("destroy","video player: ".concat(this.userId)),this.stop(e),OI(CI(n.prototype),"removeAllListeners",this).call(this),this._removeListeners(),GU.off(jU.ON_IOS_LOCAL_TRACK_MUTE,this._onLocalTrackMute),GU.off(jU.ON_IOS_LOCAL_TRACK_UNMUTE,this._onInterruptionEnd),GU.off(jU.ON_IOS_INTERRUPTION_END,this._onInterruptionEnd),this._videoDom&&delete this._videoDom,this._safari15VideoTimer&&(window.clearInterval(this._safari15VideoTimer),this._safari15VideoTimer=void 0)}},{key:"domElement",get:function(){return this._videoDom}}]),n}(ZM.exports.EventEmitter),UG=function(e){MI(i,e);var t,r,n=JI(i);function i(e,t){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{divId:void 0,muted:!1,isScreen:!1},a=o.divId,s=o.muted,c=o.isScreen;if(Vl(this,i),Jd(tI(r=n.call(this)),"_containerDom",void 0),Jd(tI(r),"_audioDom",void 0),Jd(tI(r),"_fakeAudioDom",void 0),Jd(tI(r),"userId",void 0),Jd(tI(r),"muted",!1),Jd(tI(r),"_emitPlayFailed",!1),Jd(tI(r),"played",!1),Jd(tI(r),"isScreen",void 0),Jd(tI(r),"_wechatTimer",void 0),Jd(tI(r),"_edgeTimer",void 0),Jd(tI(r),"_monitor",void 0),Jd(tI(r),"_pasued",!0),Jd(tI(r),"emitAudioEvent",(function(e){var t,n,i={type:"audio",rawEvent:e,readyState:(null===(t=r._audioDom)||void 0===t?void 0:t.readyState)||0,userId:r.userId,eventName:e.type,currentTime:(null===(n=r._audioDom)||void 0===n?void 0:n.currentTime)||0};"playing"===e.type&&DG.print("AudioPlayerPlaying","[userId-".concat(r.userId,"] audio element playing")),"pause"===e.type&&(DG.print("AudioPlayerPause","[userId-".concat(r.userId,"] audio element pause")),r._pasued||r._internalPlay()),ZD&&YD&&("canplay"===e.type?(clearTimeout(r._wechatTimer),r._wechatTimer=window.setTimeout((function(){r._autoPlayError("wechat")}),500)):"playing"===e.type&&clearTimeout(r._wechatTimer)),JD&&XD&&"error"===e.type&&(clearTimeout(r._edgeTimer),r._edgeTimer=window.setTimeout((function(){var e;0===(null===(e=r._audioDom)||void 0===e?void 0:e.currentTime)&&r._autoPlayError("edge")}),500)),r.emit("playback_event",i)})),Jd(tI(r),"_internalPlay",(function(){var e,t;if(LO(r.engineId,"_internalPlay",{paused:null===(e=r._audioDom)||void 0===e?void 0:e.paused}),null!==(t=r._audioDom)&&void 0!==t&&t.paused)try{var n,i=r._audioDom.play(),o=WU.getAudioContextInstance();if("suspended"===o.state){var a=o.resume(),s=setTimeout((function(){var e;"suspended"===o.state&&(r._autoPlayError("AudioContext cannot resume"),null===(e=r._monitor)||void 0===e||e.report("rtc_error",{message:"audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - timeout"),error_code:-1e3}));clearTimeout(s)}));a.catch((function(e){var t,n,i;r._autoPlayError("AudioContext cannot resume"),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": Cannot resume the AudioContext - rejected by: [")).call(i,null==e?void 0:e.name,"]")).call(n,null==e?void 0:e.message),error_code:-1e3})})).finally((function(){clearTimeout(s)}))}null!==(n=i)&&void 0!==n&&n.then&&(ZD&&JD&&(i=i.then((function(){return new Yf((function(e){setTimeout(Rm(Tm().mark((function t(){var n;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return null===(n=r._audioDom)||void 0===n||n.pause(),r._audioDom.volume=1,t.next=4,r._audioDom.play();case 4:e();case 5:case"end":return t.stop()}}),t)}))),500)}))}))),i.then((function(){LO(r.engineId,"_internalPlay successfully",{userId:r.userId}),r._pasued=!1})).catch((function(e){var t,n,i;r._autoPlayError(e),null===(t=r._monitor)||void 0===t||t.report("rtc_error",{message:Om(n=Om(i="audio autoplay failed, userId: ".concat(r.userId,": ")).call(i,e.message," ")).call(n,e.name),error_code:AH.AUTOPLAY_FAILED})})))}catch(l){var c,u,d;r._autoPlayError(l),null===(c=r._monitor)||void 0===c||c.report("rtc_error",{message:Om(u=Om(d="audio autoplay failed, userId: ".concat(r.userId,": ")).call(d,l.message," ")).call(u,l.name),error_code:AH.AUTOPLAY_FAILED})}})),r.engineId=e,a){var u=document.getElementById(a);if(!u)throw new vA(hA.CANT_FIND_DOM,"can't find dom");r._containerDom=u}else r._containerDom=document.body;return r.userId=t,r.muted=s,r.isScreen=c,r._monitor=MO(e),r._initAudio(),r}return Ul(i,[{key:"_initAudio",value:function(){var e;this._audioDom||(this._audioDom=OG("audio",{style:{display:"none"},attributes:PG}),this._audioDom.volume=this.muted?0:1,this._audioDom.muted=this.muted,this._audioDom.id=Om(e="".concat(this.userId,"_")).call(e,oD()),this._containerDom.appendChild(this._audioDom));this._initListeners()}},{key:"_initListeners",value:function(){var e=this;this._audioDom&&MG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.addEventListener(t,e.emitAudioEvent)}))}},{key:"_removeListeners",value:function(){var e=this;this._audioDom&&(MG.forEach((function(t){var r;null===(r=e._audioDom)||void 0===r||r.removeEventListener(t,e.emitAudioEvent)})),this._audioDom.removeEventListener("canplay",this._internalPlay),this._audioDom.removeEventListener("loadeddata",this._internalPlay))}},{key:"playAudio",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(DG.print("playAudio","play audio track: ".concat(this.userId)),!((o=this._audioDom)&&o.srcObject instanceof MediaStream&&o.srcObject.getTrackById(null===(r=t.getTrack())||void 0===r?void 0:r.id))){e.next=4;break}return e.abrupt("return");case 4:o||(this._initAudio(),o=this._audioDom),a=new MediaStream,t instanceof PV?(this._fakeAudioDom=new Audio,this._fakeAudioDom.muted=!0,this._fakeAudioDom.srcObject=new MediaStream([t.getOrgTrack()]),a.addTrack(t.getTrack())):a.addTrack(t.getTrack("preprocessing")),ZD&&JD&&(this._audioDom.volume=0),o.srcObject=a,null===(n=o)||void 0===n||n.addEventListener("canplay",this._internalPlay),null===(i=o)||void 0===i||i.addEventListener("loadeddata",this._internalPlay),setTimeout((function(){return s._internalPlay()})),this.played=!0;case 13:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_autoPlayError",value:function(e){var t,r;this._emitPlayFailed||(this._emitPlayFailed=!0,this.emit("playback_event",{type:"audio",rawEvent:e,readyState:(null===(t=this._audioDom)||void 0===t?void 0:t.readyState)||0,userId:this.userId,eventName:"autoplay-error",currentTime:(null===(r=this._audioDom)||void 0===r?void 0:r.currentTime)||0}))}},{key:"pause",value:function(){if(!this._audioDom)throw new vA(hA.INVALID_PARAMS,"Player not found");this._pasued=!0,this._audioDom.pause()}},{key:"manuallyPlay",value:function(){var e,t=this;if(DG.print("Invoke AudioPlayer.manuallyPlay"),this._emitPlayFailed=!1,!this._audioDom)throw new vA(hA.INVALID_PARAMS,"Player not found");if(!this.played)return Yf.resolve();this._audioDom.volume=1,this._audioDom.muted=!1,null===(e=this._fakeAudioDom)||void 0===e||e.play();var r=[],n=this._audioDom.play();null!=n&&n.then&&r.push(n);var i=WU.getAudioContextInstance();if("suspended"===i.state){var o=i.resume();null!=o&&o.then&&r.push(o)}(r.length>0?Yf.all(r):Yf.resolve(n)).then((function(){t._pasued=!1}))}},{key:"setPlaybackDevice",value:(t=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DG.print("setPlaybackDevice","setPlaybackDevice: ".concat(t)),e.next=3,FU.enumerateAudioPlaybackDevices();case 3:if(r=e.sent,n=jm(r).call(r,(function(e){return e.deviceId})),mk(n).call(n,t)&&this._audioDom&&this._audioDom.setSinkId){e.next=7;break}return e.abrupt("return");case 7:return e.next=9,this._audioDom.setSinkId(t);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"stop",value:function(){var e=this._containerDom;DG.print("stopAudio","stop audio track: ".concat(this.userId)),this._audioDom&&(this._audioDom.srcObject=null,null!=e&&e.contains(this._audioDom)&&e.removeChild(this._audioDom)),this._fakeAudioDom&&(this._fakeAudioDom.srcObject=null,this._fakeAudioDom=void 0),this.played=!1}},{key:"domElement",get:function(){return this._audioDom}},{key:"destroy",value:function(){DG.print("destroy","audio player: ".concat(this.userId)),this.stop(),OI(CI(i.prototype),"removeAllListeners",this).call(this),this._removeListeners(),this._audioDom&&(this._audioDom.srcObject=null,delete this._audioDom),this._edgeTimer&&clearTimeout(this._edgeTimer)}}]),i}(ZM.exports.EventEmitter);function VG(e,t,r,n){var i=function(){var e=Rm(Tm().mark((function e(t,i){var o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=null==n?void 0:n.get(i),Array.isArray(o)&&(o=null===(a=o)||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===r}))),!t){e.next=9;break}if(!t.played){e.next=8;break}return e.next=6,t.manuallyPlay();case 6:e.next=9;break;case 8:o&&(t instanceof LG&&o.videoTrack&&t.playVideo(o.videoTrack,o),t instanceof UG&&o.audioTrack&&t.playAudio(o.audioTrack));case 9:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();if(t)return i(e.get(t),t);var o=[];return e.forEach((function(e,t){return o.push(i(e,t))})),Yf.all(o)}var FG=i,BG=lt("iterator"),jG=!FG((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,r="";return e.pathname="c%20d",t.forEach((function(e,n){t.delete("b"),r+=n+e})),!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[BG]||"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"!==r||"x"!==new URL("http://x",void 0).host})),HG=Jt,GG=E,zG=2147483647,KG=/[^\0-\u007E]/,XG=/[.\u3002\uFF0E\uFF61]/g,WG="Overflow: input needs wider integers to process",qG=RangeError,YG=GG(XG.exec),JG=Math.floor,QG=String.fromCharCode,ZG=GG("".charCodeAt),$G=GG([].join),ez=GG([].push),tz=GG("".replace),rz=GG("".split),nz=GG("".toLowerCase),iz=function(e){return e+22+75*(e<26)},oz=function(e,t,r){var n=0;for(e=r?JG(e/700):e>>1,e+=JG(e/t);e>455;)e=JG(e/35),n+=36;return JG(n+36*e/(e+38))},az=function(e){var t=[];e=function(e){for(var t=[],r=0,n=e.length;r<n;){var i=ZG(e,r++);if(i>=55296&&i<=56319&&r<n){var o=ZG(e,r++);56320==(64512&o)?ez(t,((1023&i)<<10)+(1023&o)+65536):(ez(t,i),r--)}else ez(t,i)}return t}(e);var r,n,i=e.length,o=128,a=0,s=72;for(r=0;r<e.length;r++)(n=e[r])<128&&ez(t,QG(n));var c=t.length,u=c;for(c&&ez(t,"-");u<i;){var d=zG;for(r=0;r<e.length;r++)(n=e[r])>=o&&n<d&&(d=n);var l=u+1;if(d-o>JG((zG-a)/l))throw qG(WG);for(a+=(d-o)*l,o=d,r=0;r<e.length;r++){if((n=e[r])<o&&++a>zG)throw qG(WG);if(n==o){for(var h=a,p=36;;){var v=p<=s?1:p>=s+26?26:p-s;if(h<v)break;var _=h-v,f=36-v;ez(t,QG(iz(v+_%f))),h=JG(_/f),p+=36}ez(t,QG(iz(h))),s=oz(a,l,u==c),a=0,u++}}a++,o++}return $G(t,"")},sz=Ar,cz=n,uz=O,dz=E,lz=w,hz=jG,pz=li,vz=Qy,_z=Ni,fz=Pc,mz=Zi,yz=mp,gz=R,Sz=Ye,bz=Yt,Ez=_n,kz=tr,Tz=$,Iz=yn,Rz=Gn,Az=V,wz=gh,Cz=hh,xz=wp,Oz=dR,Dz=lt("iterator"),Mz="URLSearchParams",Pz="URLSearchParamsIterator",Nz=mz.set,Lz=mz.getterFor(Mz),Uz=mz.getterFor(Pz),Vz=Object.getOwnPropertyDescriptor,Fz=function(e){if(!lz)return cz[e];var t=Vz(cz,e);return t&&t.value},Bz=Fz("fetch"),jz=Fz("Request"),Hz=Fz("Headers"),Gz=jz&&jz.prototype,zz=Hz&&Hz.prototype,Kz=cz.RegExp,Xz=cz.TypeError,Wz=cz.decodeURIComponent,qz=cz.encodeURIComponent,Yz=dz("".charAt),Jz=dz([].join),Qz=dz([].push),Zz=dz("".replace),$z=dz([].shift),eK=dz([].splice),tK=dz("".split),rK=dz("".slice),nK=/\+/g,iK=Array(4),oK=function(e){return iK[e-1]||(iK[e-1]=Kz("((?:%[\\da-f]{2}){"+e+"})","gi"))},aK=function(e){try{return Wz(e)}catch(eq){return e}},sK=function(e){var t=Zz(e,nK," "),r=4;try{return Wz(t)}catch(eq){for(;r;)t=Zz(t,oK(r--),aK);return t}},cK=/[!'()~]|%20/g,uK={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},dK=function(e){return uK[e]},lK=function(e){return Zz(qz(e),cK,dK)},hK=fz((function(e,t){Nz(this,{type:Pz,iterator:wz(Lz(e).entries),kind:t})}),"Iterator",(function(){var e=Uz(this),t=e.kind,r=e.iterator.next(),n=r.value;return r.done||(r.value="keys"===t?n.key:"values"===t?n.value:[n.key,n.value]),r}),!0),pK=function(e){this.entries=[],this.url=null,void 0!==e&&(Tz(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Yz(e,0)?rK(e,1):e:Iz(e)))};pK.prototype={type:Mz,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,n,i,o,a,s,c=Cz(e);if(c)for(r=(t=wz(e,c)).next;!(n=uz(r,t)).done;){if(o=(i=wz(kz(n.value))).next,(a=uz(o,i)).done||(s=uz(o,i)).done||!uz(o,i).done)throw Xz("Expected sequence with length 2");Qz(this.entries,{key:Iz(a.value),value:Iz(s.value)})}else for(var u in e)Sz(e,u)&&Qz(this.entries,{key:u,value:Iz(e[u])})},parseQuery:function(e){if(e)for(var t,r,n=tK(e,"&"),i=0;i<n.length;)(t=n[i++]).length&&(r=tK(t,"="),Qz(this.entries,{key:sK($z(r)),value:sK(Jz(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],n=0;n<t.length;)e=t[n++],Qz(r,lK(e.key)+"="+lK(e.value));return Jz(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var vK=function(){yz(this,_K);var e=arguments.length>0?arguments[0]:void 0;Nz(this,new pK(e))},_K=vK.prototype;if(vz(_K,{append:function(e,t){xz(arguments.length,2);var r=Lz(this);Qz(r.entries,{key:Iz(e),value:Iz(t)}),r.updateURL()},delete:function(e){xz(arguments.length,1);for(var t=Lz(this),r=t.entries,n=Iz(e),i=0;i<r.length;)r[i].key===n?eK(r,i,1):i++;t.updateURL()},get:function(e){xz(arguments.length,1);for(var t=Lz(this).entries,r=Iz(e),n=0;n<t.length;n++)if(t[n].key===r)return t[n].value;return null},getAll:function(e){xz(arguments.length,1);for(var t=Lz(this).entries,r=Iz(e),n=[],i=0;i<t.length;i++)t[i].key===r&&Qz(n,t[i].value);return n},has:function(e){xz(arguments.length,1);for(var t=Lz(this).entries,r=Iz(e),n=0;n<t.length;)if(t[n++].key===r)return!0;return!1},set:function(e,t){xz(arguments.length,1);for(var r,n=Lz(this),i=n.entries,o=!1,a=Iz(e),s=Iz(t),c=0;c<i.length;c++)(r=i[c]).key===a&&(o?eK(i,c--,1):(o=!0,r.value=s));o||Qz(i,{key:a,value:s}),n.updateURL()},sort:function(){var e=Lz(this);Oz(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=Lz(this).entries,n=bz(e,arguments.length>1?arguments[1]:void 0),i=0;i<r.length;)n((t=r[i++]).value,t.key,this)},keys:function(){return new hK(this,"keys")},values:function(){return new hK(this,"values")},entries:function(){return new hK(this,"entries")}},{enumerable:!0}),pz(_K,Dz,_K.entries,{name:"entries"}),pz(_K,"toString",(function(){return Lz(this).serialize()}),{enumerable:!0}),_z(vK,Mz),sz({global:!0,constructor:!0,forced:!hz},{URLSearchParams:vK}),!hz&&gz(Hz)){var fK=dz(zz.has),mK=dz(zz.set),yK=function(e){if(Tz(e)){var t,r=e.body;if(Ez(r)===Mz)return t=e.headers?new Hz(e.headers):new Hz,fK(t,"content-type")||mK(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),Rz(e,{body:Az(0,Iz(r)),headers:Az(0,t)})}return e};if(gz(Bz)&&sz({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return Bz(e,arguments.length>1?yK(arguments[1]):{})}}),gz(jz)){var gK=function(e){return yz(this,Gz),new jz(e,arguments.length>1?yK(arguments[1]):{})};Gz.constructor=gK,gK.prototype=Gz,sz({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:gK})}}var SK,bK=Ar,EK=w,kK=jG,TK=n,IK=Yt,RK=E,AK=li,wK=function(e,t,r){return HG.f(e,t,r)},CK=mp,xK=Ye,OK=Rb,DK=Xk,MK=ni,PK=Ud.codeAt,NK=function(e){var t,r,n=[],i=rz(tz(nz(e),XG,"."),".");for(t=0;t<i.length;t++)r=i[t],ez(n,YG(KG,r)?"xn--"+az(r):r);return $G(n,".")},LK=yn,UK=Ni,VK=wp,FK={URLSearchParams:vK,getState:Lz},BK=Zi,jK=BK.set,HK=BK.getterFor("URL"),GK=FK.URLSearchParams,zK=FK.getState,KK=TK.URL,XK=TK.TypeError,WK=TK.parseInt,qK=Math.floor,YK=Math.pow,JK=RK("".charAt),QK=RK(/./.exec),ZK=RK([].join),$K=RK(1..toString),eX=RK([].pop),tX=RK([].push),rX=RK("".replace),nX=RK([].shift),iX=RK("".split),oX=RK("".slice),aX=RK("".toLowerCase),sX=RK([].unshift),cX="Invalid scheme",uX="Invalid host",dX="Invalid port",lX=/[a-z]/i,hX=/[\d+-.a-z]/i,pX=/\d/,vX=/^0x/i,_X=/^[0-7]+$/,fX=/^\d+$/,mX=/^[\da-f]+$/i,yX=/[\0\t\n\r #%/:<>?@[\\\]^|]/,gX=/[\0\t\n\r #/:<>?@[\\\]^|]/,SX=/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g,bX=/[\t\n\r]/g,EX=function(e){var t,r,n,i;if("number"==typeof e){for(t=[],r=0;r<4;r++)sX(t,e%256),e=qK(e/256);return ZK(t,".")}if("object"==typeof e){for(t="",n=function(e){for(var t=null,r=1,n=null,i=0,o=0;o<8;o++)0!==e[o]?(i>r&&(t=n,r=i),n=null,i=0):(null===n&&(n=o),++i);return i>r&&(t=n,r=i),t}(e),r=0;r<8;r++)i&&0===e[r]||(i&&(i=!1),n===r?(t+=r?":":"::",i=!0):(t+=$K(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},kX={},TX=OK({},kX,{" ":1,'"':1,"<":1,">":1,"`":1}),IX=OK({},TX,{"#":1,"?":1,"{":1,"}":1}),RX=OK({},IX,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),AX=function(e,t){var r=PK(e,0);return r>32&&r<127&&!xK(t,e)?e:encodeURIComponent(e)},wX={ftp:21,file:null,http:80,https:443,ws:80,wss:443},CX=function(e,t){var r;return 2==e.length&&QK(lX,JK(e,0))&&(":"==(r=JK(e,1))||!t&&"|"==r)},xX=function(e){var t;return e.length>1&&CX(oX(e,0,2))&&(2==e.length||"/"===(t=JK(e,2))||"\\"===t||"?"===t||"#"===t)},OX=function(e){return"."===e||"%2e"===aX(e)},DX={},MX={},PX={},NX={},LX={},UX={},VX={},FX={},BX={},jX={},HX={},GX={},zX={},KX={},XX={},WX={},qX={},YX={},JX={},QX={},ZX={},$X=function(e,t,r){var n,i,o,a=LK(e);if(t){if(i=this.parse(a))throw XK(i);this.searchParams=null}else{if(void 0!==r&&(n=new $X(r,!0)),i=this.parse(a,null,n))throw XK(i);(o=zK(new GK)).bindURL(this),this.searchParams=o}};$X.prototype={type:"URL",parse:function(e,t,r){var n,i,o,a,s,c=this,u=t||DX,d=0,l="",h=!1,p=!1,v=!1;for(e=LK(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=rX(e,SX,"")),e=rX(e,bX,""),n=DK(e);d<=n.length;){switch(i=n[d],u){case DX:if(!i||!QK(lX,i)){if(t)return cX;u=PX;continue}l+=aX(i),u=MX;break;case MX:if(i&&(QK(hX,i)||"+"==i||"-"==i||"."==i))l+=aX(i);else{if(":"!=i){if(t)return cX;l="",u=PX,d=0;continue}if(t&&(c.isSpecial()!=xK(wX,l)||"file"==l&&(c.includesCredentials()||null!==c.port)||"file"==c.scheme&&!c.host))return;if(c.scheme=l,t)return void(c.isSpecial()&&wX[c.scheme]==c.port&&(c.port=null));l="","file"==c.scheme?u=KX:c.isSpecial()&&r&&r.scheme==c.scheme?u=NX:c.isSpecial()?u=FX:"/"==n[d+1]?(u=LX,d++):(c.cannotBeABaseURL=!0,tX(c.path,""),u=JX)}break;case PX:if(!r||r.cannotBeABaseURL&&"#"!=i)return cX;if(r.cannotBeABaseURL&&"#"==i){c.scheme=r.scheme,c.path=MK(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,u=ZX;break}u="file"==r.scheme?KX:UX;continue;case NX:if("/"!=i||"/"!=n[d+1]){u=UX;continue}u=BX,d++;break;case LX:if("/"==i){u=jX;break}u=YX;continue;case UX:if(c.scheme=r.scheme,i==SK)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=MK(r.path),c.query=r.query;else if("/"==i||"\\"==i&&c.isSpecial())u=VX;else if("?"==i)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=MK(r.path),c.query="",u=QX;else{if("#"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=MK(r.path),c.path.length--,u=YX;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=MK(r.path),c.query=r.query,c.fragment="",u=ZX}break;case VX:if(!c.isSpecial()||"/"!=i&&"\\"!=i){if("/"!=i){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,u=YX;continue}u=jX}else u=BX;break;case FX:if(u=BX,"/"!=i||"/"!=JK(l,d+1))continue;d++;break;case BX:if("/"!=i&&"\\"!=i){u=jX;continue}break;case jX:if("@"==i){h&&(l="%40"+l),h=!0,o=DK(l);for(var _=0;_<o.length;_++){var f=o[_];if(":"!=f||v){var m=AX(f,RX);v?c.password+=m:c.username+=m}else v=!0}l=""}else if(i==SK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(h&&""==l)return"Invalid authority";d-=DK(l).length+1,l="",u=HX}else l+=i;break;case HX:case GX:if(t&&"file"==c.scheme){u=WX;continue}if(":"!=i||p){if(i==SK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()){if(c.isSpecial()&&""==l)return uX;if(t&&""==l&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(l))return a;if(l="",u=qX,t)return;continue}"["==i?p=!0:"]"==i&&(p=!1),l+=i}else{if(""==l)return uX;if(a=c.parseHost(l))return a;if(l="",u=zX,t==GX)return}break;case zX:if(!QK(pX,i)){if(i==SK||"/"==i||"?"==i||"#"==i||"\\"==i&&c.isSpecial()||t){if(""!=l){var y=WK(l,10);if(y>65535)return dX;c.port=c.isSpecial()&&y===wX[c.scheme]?null:y,l=""}if(t)return;u=qX;continue}return dX}l+=i;break;case KX:if(c.scheme="file","/"==i||"\\"==i)u=XX;else{if(!r||"file"!=r.scheme){u=YX;continue}if(i==SK)c.host=r.host,c.path=MK(r.path),c.query=r.query;else if("?"==i)c.host=r.host,c.path=MK(r.path),c.query="",u=QX;else{if("#"!=i){xX(ZK(MK(n,d),""))||(c.host=r.host,c.path=MK(r.path),c.shortenPath()),u=YX;continue}c.host=r.host,c.path=MK(r.path),c.query=r.query,c.fragment="",u=ZX}}break;case XX:if("/"==i||"\\"==i){u=WX;break}r&&"file"==r.scheme&&!xX(ZK(MK(n,d),""))&&(CX(r.path[0],!0)?tX(c.path,r.path[0]):c.host=r.host),u=YX;continue;case WX:if(i==SK||"/"==i||"\\"==i||"?"==i||"#"==i){if(!t&&CX(l))u=YX;else if(""==l){if(c.host="",t)return;u=qX}else{if(a=c.parseHost(l))return a;if("localhost"==c.host&&(c.host=""),t)return;l="",u=qX}continue}l+=i;break;case qX:if(c.isSpecial()){if(u=YX,"/"!=i&&"\\"!=i)continue}else if(t||"?"!=i)if(t||"#"!=i){if(i!=SK&&(u=YX,"/"!=i))continue}else c.fragment="",u=ZX;else c.query="",u=QX;break;case YX:if(i==SK||"/"==i||"\\"==i&&c.isSpecial()||!t&&("?"==i||"#"==i)){if(".."===(s=aX(s=l))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"==i||"\\"==i&&c.isSpecial()||tX(c.path,"")):OX(l)?"/"==i||"\\"==i&&c.isSpecial()||tX(c.path,""):("file"==c.scheme&&!c.path.length&&CX(l)&&(c.host&&(c.host=""),l=JK(l,0)+":"),tX(c.path,l)),l="","file"==c.scheme&&(i==SK||"?"==i||"#"==i))for(;c.path.length>1&&""===c.path[0];)nX(c.path);"?"==i?(c.query="",u=QX):"#"==i&&(c.fragment="",u=ZX)}else l+=AX(i,IX);break;case JX:"?"==i?(c.query="",u=QX):"#"==i?(c.fragment="",u=ZX):i!=SK&&(c.path[0]+=AX(i,kX));break;case QX:t||"#"!=i?i!=SK&&("'"==i&&c.isSpecial()?c.query+="%27":c.query+="#"==i?"%23":AX(i,kX)):(c.fragment="",u=ZX);break;case ZX:i!=SK&&(c.fragment+=AX(i,TX))}d++}},parseHost:function(e){var t,r,n;if("["==JK(e,0)){if("]"!=JK(e,e.length-1))return uX;if(t=function(e){var t,r,n,i,o,a,s,c=[0,0,0,0,0,0,0,0],u=0,d=null,l=0,h=function(){return JK(e,l)};if(":"==h()){if(":"!=JK(e,1))return;l+=2,d=++u}for(;h();){if(8==u)return;if(":"!=h()){for(t=r=0;r<4&&QK(mX,h());)t=16*t+WK(h(),16),l++,r++;if("."==h()){if(0==r)return;if(l-=r,u>6)return;for(n=0;h();){if(i=null,n>0){if(!("."==h()&&n<4))return;l++}if(!QK(pX,h()))return;for(;QK(pX,h());){if(o=WK(h(),10),null===i)i=o;else{if(0==i)return;i=10*i+o}if(i>255)return;l++}c[u]=256*c[u]+i,2!=++n&&4!=n||u++}if(4!=n)return;break}if(":"==h()){if(l++,!h())return}else if(h())return;c[u++]=t}else{if(null!==d)return;l++,d=++u}}if(null!==d)for(a=u-d,u=7;0!=u&&a>0;)s=c[u],c[u--]=c[d+a-1],c[d+--a]=s;else if(8!=u)return;return c}(oX(e,1,-1)),!t)return uX;this.host=t}else if(this.isSpecial()){if(e=NK(e),QK(yX,e))return uX;if(t=function(e){var t,r,n,i,o,a,s,c=iX(e,".");if(c.length&&""==c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],n=0;n<t;n++){if(""==(i=c[n]))return e;if(o=10,i.length>1&&"0"==JK(i,0)&&(o=QK(vX,i)?16:8,i=oX(i,8==o?1:2)),""===i)a=0;else{if(!QK(10==o?fX:8==o?_X:mX,i))return e;a=WK(i,o)}tX(r,a)}for(n=0;n<t;n++)if(a=r[n],n==t-1){if(a>=YK(256,5-t))return null}else if(a>255)return null;for(s=eX(r),n=0;n<r.length;n++)s+=r[n]*YK(256,3-n);return s}(e),null===t)return uX;this.host=t}else{if(QK(gX,e))return uX;for(t="",r=DK(e),n=0;n<r.length;n++)t+=AX(r[n],kX);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"==this.scheme},includesCredentials:function(){return""!=this.username||""!=this.password},isSpecial:function(){return xK(wX,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"==this.scheme&&1==t&&CX(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,n=e.password,i=e.host,o=e.port,a=e.path,s=e.query,c=e.fragment,u=t+":";return null!==i?(u+="//",e.includesCredentials()&&(u+=r+(n?":"+n:"")+"@"),u+=EX(i),null!==o&&(u+=":"+o)):"file"==t&&(u+="//"),u+=e.cannotBeABaseURL?a[0]:a.length?"/"+ZK(a,"/"):"",null!==s&&(u+="?"+s),null!==c&&(u+="#"+c),u},setHref:function(e){var t=this.parse(e);if(t)throw XK(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"==e)try{return new eW(e.path[0]).origin}catch(eq){return"null"}return"file"!=e&&this.isSpecial()?e+"://"+EX(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(LK(e)+":",DX)},getUsername:function(){return this.username},setUsername:function(e){var t=DK(LK(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=AX(t[r],RX)}},getPassword:function(){return this.password},setPassword:function(e){var t=DK(LK(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=AX(t[r],RX)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?EX(e):EX(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,HX)},getHostname:function(){var e=this.host;return null===e?"":EX(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,GX)},getPort:function(){var e=this.port;return null===e?"":LK(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""==(e=LK(e))?this.port=null:this.parse(e,zX))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+ZK(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,qX))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""==(e=LK(e))?this.query=null:("?"==JK(e,0)&&(e=oX(e,1)),this.query="",this.parse(e,QX)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!=(e=LK(e))?("#"==JK(e,0)&&(e=oX(e,1)),this.fragment="",this.parse(e,ZX)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var eW=function(e){var t=CK(this,tW),r=VK(arguments.length,1)>1?arguments[1]:void 0,n=jK(t,new $X(e,!1,r));EK||(t.href=n.serialize(),t.origin=n.getOrigin(),t.protocol=n.getProtocol(),t.username=n.getUsername(),t.password=n.getPassword(),t.host=n.getHost(),t.hostname=n.getHostname(),t.port=n.getPort(),t.pathname=n.getPathname(),t.search=n.getSearch(),t.searchParams=n.getSearchParams(),t.hash=n.getHash())},tW=eW.prototype,rW=function(e,t){return{get:function(){return HK(this)[e]()},set:t&&function(e){return HK(this)[t](e)},configurable:!0,enumerable:!0}};if(EK&&(wK(tW,"href",rW("serialize","setHref")),wK(tW,"origin",rW("getOrigin")),wK(tW,"protocol",rW("getProtocol","setProtocol")),wK(tW,"username",rW("getUsername","setUsername")),wK(tW,"password",rW("getPassword","setPassword")),wK(tW,"host",rW("getHost","setHost")),wK(tW,"hostname",rW("getHostname","setHostname")),wK(tW,"port",rW("getPort","setPort")),wK(tW,"pathname",rW("getPathname","setPathname")),wK(tW,"search",rW("getSearch","setSearch")),wK(tW,"searchParams",rW("getSearchParams")),wK(tW,"hash",rW("getHash","setHash"))),AK(tW,"toJSON",(function(){return HK(this).serialize()}),{enumerable:!0}),AK(tW,"toString",(function(){return HK(this).serialize()}),{enumerable:!0}),KK){var nW=KK.createObjectURL,iW=KK.revokeObjectURL;nW&&AK(eW,"createObjectURL",IK(nW,KK)),iW&&AK(eW,"revokeObjectURL",IK(iW,KK))}UK(eW,"URL"),bK({global:!0,constructor:!0,forced:!kK,sham:!EK},{URL:eW});var oW=ee.URL,aW=function(){var e=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new Audio(oW.createObjectURL(new Blob([t],r))),e.prev=1,n.muted=!0,e.next=5,n.play();case 5:return n.pause(),e.abrupt("return",!0);case 9:return e.prev=9,e.t0=e.catch(1),e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,r){return e.apply(this,arguments)}}(),sW=ad,cW=tc,uW=function(e,t,r,n){for(var i,o=n>1?void 0:n?cW(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&sW(t,r,o),o},dW=function(){function e(t,r){Vl(this,e),Jd(this,"_sharedAudioContext",new AudioContext),Jd(this,"_audioDestination",this._sharedAudioContext.createMediaStreamDestination()),Jd(this,"_localGainNode",this._sharedAudioContext.createGain()),Jd(this,"_bufferGainNode",this._sharedAudioContext.createGain()),Jd(this,"_audioBufferSource",void 0),Jd(this,"_localSource",void 0),Jd(this,"_context",void 0),Jd(this,"_failedAudioList",[]),Jd(this,"_startingIds",new $S),Jd(this,"_revokeURLs",new KN),Jd(this,"mixingMap",new $S),Jd(this,"resourcesCache",new $S),Jd(this,"volumeConfig",new $S),Jd(this,"cachedBuffer",[]),Jd(this,"id","AudioMixingManager"),this.engineId=r,this._context=t,this._localGainNode.gain.value=1}var t,r,n;return Ul(e,[{key:"mixMediaStream",value:function(e){this._localSource&&this._localSource.disconnect(this._localGainNode),this._localSource=this._sharedAudioContext.createMediaStreamSource(e),this._localSource.connect(this._localGainNode).connect(this._audioDestination)}},{key:"startAudioMixing",value:(n=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===this._startingIds.get(t)){e.next=3;break}return console.warn("AudioMixing task id: ".concat(t," is starting")),e.abrupt("return");case 3:if(this._startingIds.set(t,t),i=n.playCount,MM(o=n.type,"mixingType",Hj(Dl)),a=this._context.getLocalAudioTrack()){e.next=9;break}return e.abrupt("return");case 9:if((s=a.getTrack("preprocessing"))&&this.mixMediaStream(new MediaStream([s])),null!=(c=this.mixingMap.get(t))&&c.audioNode){c.audioNode.pause(),this._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_STOPPED,error:pA.AUDIO_MIXING_ERROR_OK});try{c.gainNode.disconnect(this._audioDestination),c.audioSource.disconnect(c.gainNode)}catch(y){}}if(!(d=this.resourcesCache.get(t))||d.filePath!==r){e.next=18;break}u=d.getAudioNode(),e.next=31;break;case 18:return e.next=20,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw m._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_START_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,e.statusText)}));case 20:return l=e.sent,Qb(r).call(r,"mp3")?h={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(h={type:"audio/aac"}),e.next=24,aW(l,h);case 24:if(e.sent){e.next=28;break}throw this._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_START_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,"invalid audio resource");case 28:(u=new Audio).crossOrigin="anonymous",u.src=oW.createObjectURL(new Blob([l],h));case 31:return i<=0?u.loop=!0:i>0&&(p=i,u.onended=function(){--p>0?u.play():(m.mixingMap.delete(t),m._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_FINISHED,error:pA.AUDIO_MIXING_ERROR_OK}))}),e.prev=32,e.next=35,u.play();case 35:e.next=42;break;case 37:e.prev=37,e.t0=e.catch(32),console.error(e.t0),this._failedAudioList.push(u),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO});case 42:if(this._startingIds.delete(t),v=this._sharedAudioContext.createMediaElementSource(u),_=this._sharedAudioContext.createGain(),f=this.volumeConfig.get(t),_.gain.value=f?f/100:1,v.connect(_).connect(this._audioDestination),this.mixingMap.set(t,{audioSource:v,audioNode:u,gainNode:_,type:"file"}),o===Dl.PUBLISH)try{_.disconnect(this._sharedAudioContext.destination)}catch(y){}else _.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],n.type),this._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_PLAYING,error:pA.AUDIO_MIXING_ERROR_OK});case 52:case"end":return e.stop()}}),e,this,[[32,37]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"stopAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&"file"===t.type&&(this.mixingMap.delete(e),t.audioNode.pause(),t.audioSource.disconnect(t.gainNode),t.gainNode.disconnect(this._audioDestination),this._context.emitMessage({mixId:e,state:Ml.AUDIO_MIXING_STATE_STOPPED,error:pA.AUDIO_MIXING_ERROR_OK}))}},{key:"pauseAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Ml.AUDIO_MIXING_STATE_PAUSED,error:pA.AUDIO_MIXING_ERROR_OK}),t.audioNode.pause())}},{key:"resumeAudioMixing",value:function(e){var t=this.mixingMap.get(e);t&&(this._context.emitMessage({mixId:e,state:Ml.AUDIO_MIXING_STATE_PLAYING,error:pA.AUDIO_MIXING_ERROR_OK}),t.audioNode.play())}},{key:"preloadAudioMixing",value:(r=Rm(Tm().mark((function e(t,r){var n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.stopAudioMixing(t),e.next=3,fetch(r,{mode:"cors",credentials:"include"}).then((function(e){if(e.ok)return e.arrayBuffer();throw new vA(hA.LOAD_RESOURCES_FAILED,e.statusText)})).catch((function(e){if(o._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),e instanceof vA)throw e;throw new vA(hA.LOAD_RESOURCES_FAILED,"Load resources failed",e)}));case 3:return n=e.sent,Qb(r).call(r,"mp3")?i={type:"audio/mpeg"}:Qb(r).call(r,"aac")&&(i={type:"audio/aac"}),e.next=7,aW(n,i);case 7:if(e.sent){e.next=11;break}throw this._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_FAILED,error:pA.AUDIO_MIXING_ERROR_PRELOAD_FAILED}),new vA(hA.LOAD_RESOURCES_FAILED,"Load resources failed");case 11:return this._context.emitMessage({mixId:t,state:Ml.AUDIO_MIXING_STATE_PRELOADED,error:pA.AUDIO_MIXING_ERROR_OK}),this.resourcesCache.set(t,{getAudioNode:function(){var e=oW.createObjectURL(new Blob([n],i));return o._revokeURLs.add(e),new Audio(e)},filePath:r,duration:0}),e.next=15,new Yf((function(e){var r=oW.createObjectURL(new Blob([n],i)),a=new Audio(r);a.addEventListener("durationchange",(function(){var n=o.resourcesCache.get(t);n&&(n.duration=a.duration,o.resourcesCache.set(t,n)),oW.revokeObjectURL(r),e(null)}))}));case 15:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"unloadAudioMixing",value:function(e){this.resourcesCache.has(e)&&this.resourcesCache.delete(e)}},{key:"getAudioMixingVolume",value:function(e){var t=this.mixingMap.get(e);return t?100*t.gainNode.gain.value:0}},{key:"setAudioMixingVolume",value:function(e,t){t<0?t=0:t>400&&(t=400),this.volumeConfig.set(e,t);var r=this.mixingMap.get(e);r&&(r.gainNode.gain.value=Number(t)/100)}},{key:"getAudioMixingDuration",value:function(e){var t=this.mixingMap.get(e),r=this.resourcesCache.get(e);return t||r?t?1e3*t.audioNode.duration:r?1e3*r.duration:0:0}},{key:"getAudioMixingCurrentPosition",value:function(e){var t=this.mixingMap.get(e);return t?1e3*t.audioNode.currentTime:0}},{key:"setAudioMixingPosition",value:function(e,t){var r=this.mixingMap.get(e);r&&(r.audioNode.currentTime=t/1e3,r.audioNode.play())}},{key:"enableAudioMixingBuffer",value:function(e){MM(e,"type",Hj(Dl));var t=this._context.getLocalAudioTrack();if(t){var r=t.getTrack("preprocessing");if(r&&this.mixMediaStream(new MediaStream([r])),e===Dl.PUBLISH)try{this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(n){}else this._bufferGainNode.connect(this._sharedAudioContext.destination);this._context.updateLocalAudioTrack(this._audioDestination.stream.getAudioTracks()[0],e),this._bufferGainNode.connect(this._audioDestination),this._context.emitMessage({mixId:-1,state:Ml.AUDIO_MIXING_STATE_PCM_ENABLED,error:pA.AUDIO_MIXING_ERROR_OK})}}},{key:"disableAudioMixingBuffer",value:function(){if(this.cachedBuffer=[],this._audioBufferSource){try{this._audioBufferSource.disconnect(this._bufferGainNode),this._bufferGainNode.disconnect(this._audioDestination),this._bufferGainNode.disconnect(this._sharedAudioContext.destination)}catch(e){}finally{this._audioBufferSource=void 0}this._context.updateLocalAudioTrack(),this._context.emitMessage({mixId:-1,state:Ml.AUDIO_MIXING_STATE_PCM_DISABLED,error:pA.AUDIO_MIXING_ERROR_OK})}}},{key:"pushAudioMixingBuffer",value:function(e){var t=this;if(!(this._audioBufferSource&&(this.cachedBuffer.push(e),this.cachedBuffer.length>0))){this._audioBufferSource=this._sharedAudioContext.createBufferSource(),this._audioBufferSource.buffer=e,this._audioBufferSource.connect(this._bufferGainNode);try{this._audioBufferSource.start()}catch(r){this._failedAudioList.push(this._audioBufferSource)}this._audioBufferSource.onended=function(){var e;if(null===(e=t._audioBufferSource)||void 0===e||e.disconnect(t._bufferGainNode),t._audioBufferSource=void 0,t.cachedBuffer.length){var r=t.cachedBuffer.shift();r&&t.pushAudioMixingBuffer(r)}}}}},{key:"stopAll",value:function(){var e=this;if(this._localSource)try{this._localSource.disconnect(this._localGainNode),delete this._localSource}catch(t){}this.mixingMap.forEach((function(t,r){e.stopAudioMixing(r)}))}},{key:"mixTrack",get:function(){return this._audioDestination.stream.getAudioTracks()[0]}},{key:"sharedAudioContext",get:function(){return this._sharedAudioContext}},{key:"resumeLocalPlay",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=$T(this._failedAudioList),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=24;break}if(i=n.value,e.prev=6,!(i instanceof HTMLAudioElement)){e.next=13;break}return i.muted=!1,e.next=11,i.play();case 11:e.next=14;break;case 13:i.start();case 14:e.next=22;break;case 16:return e.prev=16,e.t0=e.catch(6),t.push(i),console.error(e.t0),this._context.onAutoPlayFailed({userId:this.id,kind:"audio",streamIndex:cl.STREAM_INDEX_MAIN,mediaType:ul.AUDIO}),e.abrupt("break",24);case 22:e.next=4;break;case 24:e.next=29;break;case 26:e.prev=26,e.t1=e.catch(2),r.e(e.t1);case 29:return e.prev=29,r.f(),e.finish(29);case 32:this._failedAudioList=t;case 33:case"end":return e.stop()}}),e,this,[[2,26,29,32],[6,16]])}))),function(){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e=this._sharedAudioContext;"closed"!==e.state&&"function"==typeof e.close&&e.close(),this.cachedBuffer=[],this.mixingMap.clear(),this.resourcesCache.clear(),this.volumeConfig.clear(),this._startingIds=new $S,this._revokeURLs.forEach((function(e){oW.revokeObjectURL(e)}))}}]),e}();uW([PO("id","filePath","options")],dW.prototype,"startAudioMixing",1),uW([PO("id")],dW.prototype,"stopAudioMixing",1),uW([PO("id")],dW.prototype,"pauseAudioMixing",1),uW([PO("id")],dW.prototype,"resumeAudioMixing",1),uW([PO("id")],dW.prototype,"preloadAudioMixing",1),uW([PO("id")],dW.prototype,"unloadAudioMixing",1),uW([PO("id")],dW.prototype,"getAudioMixingVolume",1),uW([PO("id","volume")],dW.prototype,"setAudioMixingVolume",1),uW([PO("id")],dW.prototype,"getAudioMixingDuration",1),uW([PO("id")],dW.prototype,"getAudioMixingCurrentPosition",1),uW([PO("id","position")],dW.prototype,"setAudioMixingPosition",1),uW([PO("type")],dW.prototype,"enableAudioMixingBuffer",1),uW([PO()],dW.prototype,"disableAudioMixingBuffer",1),uW([PO("buffer")],dW.prototype,"pushAudioMixingBuffer",1);var lW=function(e){return e.NORMAL_USER="normalUser",e.SILENT_USER="silentUser",e}(lW||{}),hW=new yO("RTMClient",1),pW=function(e){MI(c,e);var t,r,n,i,o,a,s=JI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_dataChannelSignal",void 0),Jd(tI(t),"_handler",void 0),Jd(tI(t),"_dataChannelSignalState",tG.DISCONNECTED),Jd(tI(t),"_loginSessionId",null),Jd(tI(t),"_userId",null),Jd(tI(t),"_token",null),Jd(tI(t),"_loginResolveCallback",void 0),Jd(tI(t),"_loginRejectCallback",void 0),Jd(tI(t),"_wait_login_token",!1),Jd(tI(t),"_serverParamsCache",void 0),Jd(tI(t),"id",void 0),Jd(tI(t),"_connectionManager",void 0),Jd(tI(t),"isReconnecting",!1),t._ctx=e,t.id=e.id,t._connectionManager=new YH(e),t._addConnectHandler(),t}return Ul(c,[{key:"login",value:function(e,t){var r=this;return new Yf((function(n,i){var o;if(hW.print("login","invoke login, token: %o, userId: %o",e,t),r._loginSessionId)throw new vA(hA.ALREADY_LOGIN,"Already logined");if(r._loginResolveCallback)throw new vA(hA.LOGIN_FAILED,"Is logging in, please try again later.");r._userId=t,r._token=e,null===(o=MO(r.id))||void 0===o||o.set({rtm_user_id:t}),r._loginResolveCallback=n,r._loginRejectCallback=i,r._dataChannelSignal?r._login():r.connect().then((function(){r._login()}))}))}},{key:"logout",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return e.next=4,null===(t=this._dataChannelSignal)||void 0===t?void 0:t.sendSignaling("logout",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId},{functionType:XH.C2RTM}).catch((function(){}));case 4:this._clearState();case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"updateLoginToken",value:(o=Rm(Tm().mark((function e(t){var r=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._token=t,e.abrupt("return",new Yf((function(e,t){r._wait_login_token?(r._loginResolveCallback=e,r._loginRejectCallback=t,r._login()):e()})));case 2:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.next=5,this._dataChannelSignal.sendSignaling("getPeerOnlineStatus",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,peerUserId:t},{functionType:XH.C2RTM});case 5:return r=e.sent,e.abrupt("return",null==r?void 0:r.status);case 7:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(n=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:t,room:"",msg:r}));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"setServerParams",value:(r=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,DM(t,"signature"),DM(r,"url"),this._loginSessionId&&this._userId){e.next=5;break}throw new vA(hA.NOT_LOGIN,"login first");case 5:return this._checkDataChannelSignal(),e.next=8,this._dataChannelSignal.sendSignaling("setServerParams",{loginSessionId:this._loginSessionId,userId:this._userId,appId:this._ctx.appId,signature:t,url:r},{functionType:XH.C2RTM}).catch((function(e){throw new vA(hA.UNEXPECTED_ERROR,e.msg)}));case 8:this._serverParamsCache={signature:t,url:r},this.emit("onServerParamsSetResult"),e.next=16;break;case 12:throw e.prev=12,e.t0=e.catch(0),this.emit("onServerParamsSetResult",e.t0),e.t0;case 16:case"end":return e.stop()}}),e,this,[[0,12]])}))),function(e,t){return r.apply(this,arguments)})},{key:"sendServerMessage",value:(t=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._loginSessionId&&this._userId){e.next=2;break}throw new vA(hA.NOT_LOGIN,"login first");case 2:return this._checkDataChannelSignal(),e.abrupt("return",this._dataChannelSignal.sendP2PMessage({from:this._userId,app:this._ctx.appId,to:"",room:"",type:BH.BUSINESS_SERVER,msg:t}));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"destroy",value:function(){var e;hW.print("destroy","invoke."),OI(CI(c.prototype),"removeAllListeners",this).call(this),this._loginResolveCallback&&this._loginRejectCallback&&(this._loginRejectCallback(new vA(hA.LOGIN_FAILED,"logout")),delete this._loginResolveCallback,delete this._loginRejectCallback),null===(e=this._dataChannelSignal)||void 0===e||e.destroy(),delete this._dataChannelSignal,this._clearState(),this._connectionManager.destroy(),delete this._serverParamsCache}},{key:"_login",value:function(){var e=this;if(this._userId){var t=oD();this._checkDataChannelSignal(),this._dataChannelSignal.sendSignaling("login",{Token:cD.token2auth(this._ctx.appId,null,this._userId,this._token),timestamp:Date.now(),loginSessionId:t,params:{deviceType:"web",userAgent:window.navigator.userAgent,sdkVersion:TM.VERSION,deviceId:mM.getDeviceId(),appId:this._ctx.appId,userId:this._userId},accessParams:Nm({requireICEUfragV2:!0})},{functionType:XH.C2RTM}).then((function(){"function"==typeof e._loginResolveCallback&&e._loginResolveCallback(),e._loginSessionId=t,kO.setRtsSessionId(e.id,t),e._wait_login_token=!1,e._serverParamsCache&&e.setServerParams(e._serverParamsCache.signature,e._serverParamsCache.url)})).catch((function(t){var r,n,i=t||{},o=i.code,a=i.message;e._wait_login_token=!1,o>=700&&o<800?708===o?(r=hA.INVALID_PARAMS,n="Invalid userId"):(r=hA.INVALID_TOKEN,n="Invalid token",e._wait_login_token=!0,e._loginRejectCallback||e.emit("onRTMTokenError")):(r=hA.LOGIN_FAILED,n="login failed"),"function"==typeof e._loginRejectCallback&&e._loginRejectCallback(new vA(r,a||n))})).finally((function(){delete e._loginResolveCallback,delete e._loginRejectCallback}))}}},{key:"connect",value:function(){var e=this;return new Yf((function(t,r){e._connectionManager.once("connected",(function(){return t()})),e._connectionManager.once("disconnected",r),e._connectionManager.connect()}))}},{key:"_checkDataChannelSignal",value:function(){if(!this._dataChannelSignal||this._dataChannelSignalState!==tG.CONNECTED)throw new vA(hA.NOT_CONNECTED_YET,"datachannel not connect")}},{key:"_addConnectHandler",value:function(){var e=this;this._connectionManager.on("connected",(function(t){var r,n;e._dataChannelSignalState=tG.CONNECTED,hW.print("connectStateChange","connected"),null===(r=e._handler)||void 0===r||r.destroy(),null===(n=e._dataChannelSignal)||void 0===n||n.destroy(),e._handler=uH(e._ctx,t.pc),e._dataChannelSignal=t.signaling,e._addSignalEventHandler(),e.isReconnecting&&e._login()})),this._connectionManager.on("disconnected",(function(t){e._dataChannelSignalState=tG.DISCONNECTED,hW.print("connectStateChange","disconnected. %o",t),e.isReconnecting&&(e.emit("onUserDisconnection"),e._clearState())})),this._connectionManager.on("connecting",(function(){var t;e.isReconnecting=!1,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=tG.CONNECTING,hW.print("connectStateChange","connecting")})),this._connectionManager.on("reconnecting",(function(){var t;e.isReconnecting=!0,null===(t=e._handler)||void 0===t||t.destroy(),delete e._handler,e._dataChannelSignalState=tG.CONNECTING,hW.print("connectStateChange","reconnecting")}))}},{key:"_addSignalEventHandler",value:function(){var e,t,r,n=this;null===(e=this._dataChannelSignal)||void 0===e||e.on(hH.USER_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(t=this._dataChannelSignal)||void 0===t||t.on(hH.USER_BINARY_MESSAGE_RECEIVED_OUTSIDE_ROOM,(function(e){n.emit("onUserBinaryMessageReceivedOutsideRoom",{userId:e.from,message:e.msg})})),null===(r=this._dataChannelSignal)||void 0===r||r.on(hH.USER_DISCONNECTION,(function(){n.emit("onUserDisconnection"),n._clearState()}))}},{key:"_clearState",value:function(){this._userId=null,this._token=null,this._loginSessionId=null,kO.setRtsSessionId(this.id,"")}}]),c}(ZM.exports.EventEmitter),vW=function(){function e(t){Vl(this,e),Jd(this,"_roomId",void 0),Jd(this,"_constraints",{}),Jd(this,"_profile",void 0),this._appId=t}return Ul(e,[{key:"setRoomId",value:function(e){this._roomId=e}},{key:"setAudioProfile",value:function(e){this._profile=e}},{key:"getOpusConfigStr",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=mM.getEngineWebConfig(this._appId,this._roomId||""),n=r.audio_encode,i=this.getConstraints(),o=i.sampleRate,a=i.channelCount,s="number"==typeof o?o:null==o?void 0:o.exact,c="number"==typeof a?a:null==a?void 0:a.exact,u={};t.split(";").forEach((function(e){var t=eI(e.split("="),2),r=t[0],n=t[1];r&&n&&(u[r]=n)}));var d=(null==n?void 0:n.bitrate)||this._getConfigByAudioProfile().bitrate;d&&(u.maxaveragebitrate=d);var l=(null==n?void 0:n.enc_sample_rate)||s;l&&(u["sprop-maxcapturerate"]=l);var h=(null==n?void 0:n.playback_rate)||s;return h&&(u.maxplaybackrate=h),(c&&c>1||null!=n&&n.stereo)&&(u["sprop-stereo"]=1,u.stereo=1),null!=n&&n.dtx&&(u.usedtx=1),jm(e=an(u)).call(e,(function(e){var t;return Om(t="".concat(e,"=")).call(t,u[e])})).join(";")}},{key:"updateConstraints",value:function(e){this._constraints=Zd(Zd({},this._constraints),e)}},{key:"getConstraints",value:function(){var e=Zd({},this._constraints),t=mM.getEngineWebConfig(this._appId,this._roomId||"").audio_capture;wD(null==t?void 0:t.sample_rate)||(e.sampleRate=t.sample_rate),wD(null==t?void 0:t.channel)||(e.channelCount=t.channel),wD(null==t?void 0:t.agc)||(e.autoGainControl=t.agc),wD(null==t?void 0:t.ans)||(e.noiseSuppression=t.ans),wD(null==t?void 0:t.aec)||(e.echoCancellation=t.aec);var r=this._getConfigByAudioProfile(),n=r.sampleRate,i=r.channel;return wD(e.sampleRate)&&!wD(n)&&(e.sampleRate=n),wD(e.channelCount)&&!wD(i)&&(e.channelCount=i),e}},{key:"_getConfigByAudioProfile",value:function(){var e={};switch(this._profile){case El.fluent:e.sampleRate=16e3,e.bitrate=24e3;break;case El.standard:e.sampleRate=48e3,e.bitrate=48e3;break;case El.hd:e.sampleRate=48e3,e.bitrate=128e3,e.channel=2;break;case El.standardStereo:e.sampleRate=48e3,e.bitrate=8e4,e.channel=2;break;case El.hdMono:e.sampleRate=48e3,e.bitrate=128e3}return e}}]),e}(),_W=function(e){MI(o,e);var t,r,n,i=JI(o);function o(e,t,r){var n,a=r.businessId;return Vl(this,o),Jd(tI(n=i.call(this)),"_mediaServerClient",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"remoteStreams",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_ctx",void 0),n.id=e,n._appId=t,n.remoteStreams=new $S,n._businessId=a,n._ctx={id:n.id,appId:n._appId,avSync:!0,audioProfileManager:new vW(n._appId),useCloudProxy:!1,userPriority:new $S,joinRoomConfig:new gM(n.id),enableFallbackHandler:LW(t),enableStandardHandler:UW(t),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},RM("PC_KILLSWITCH")),NW(n._appId))},n}return Ul(o,[{key:"connect",value:(n=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._mediaServerClient=new nG(this._ctx),this._businessId&&(this._mediaServerClient.businessId=this._businessId),this._bindEvents(),e.next=5,this._mediaServerClient.connect();case 5:case"end":return e.stop()}}),e,this)}))),function(){return n.apply(this,arguments)})},{key:"startPlayPublicStream",value:(r=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.remoteStreams.get(t)){e.next=2;break}throw new vA(hA.REPEAT_PLAY,"repeat play public media stream");case 2:return(r=new tF(this._ctx,t,t,!1,!0,{audiostream:!0,localaudio:!0,videostream:!0,localvideo:!0,extaudio:!1,extvideo:!1,videoDescriptions:[]})).on("onSEIMessage",(function(e){if(e instanceof Uint8Array)for(var t=RD(e),i=0;i<t.seiCount;i++)n.emit(SH.ON_SEI_MESSAGED_RECEIVED,{sei:t.seis[i],publicStreamId:r.streamId})})),e.next=6,this._mediaServerClient.subscribePublicStream(r);case 6:return this.remoteStreams.set(t,r),e.abrupt("return",r);case 8:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"stopPlayPublicStream",value:function(e){var t=this.remoteStreams.get(e);if(t)return this.remoteStreams.delete(e),this._mediaServerClient.unsubscribePublicStream(t)}},{key:"destroy",value:function(){var e;this.remoteStreams.forEach((function(e){e.clean()})),this.remoteStreams=new $S,null===(e=this._mediaServerClient)||void 0===e||e.destroy(),this.removeAllListeners()}},{key:"_handleReconnected",value:(t=Rm(Tm().mark((function e(){var t,r,n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=$T(this.remoteStreams);try{for(n=function(){var e=eI(r.value,1)[0];i.remoteStreams.delete(e),i.startPlayPublicStream(e).then((function(){var t=i.remoteStreams.get(e);i.safeEmit(SH.RESUBSCRIBE,{stream:t})}))},t.s();!(r=t.n()).done;)n()}catch(o){t.e(o)}finally{t.f()}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"_bindEvents",value:function(){var e,t,r=this;null===(e=this._mediaServerClient)||void 0===e||e.on("joinSuccess",(function(e){e.reconnect&&r._handleReconnected()})),null===(t=this._mediaServerClient)||void 0===t||t.on("onRemoteStreamStats",(function(e){r.emit("onRemoteStreamStats",e)}))}}]),o}(tP),fW=new yO("AudioDeviceManager",1),mW=function(e){MI(c,e);var t,r,n,i,o,a,s=JI(c);function c(e){var t;return Vl(this,c),Jd(tI(t=s.call(this)),"_audioLevelFetcher",void 0),Jd(tI(t),"_playbackDeviceTestTimer",void 0),Jd(tI(t),"_audioElement",void 0),Jd(tI(t),"_audioTrack",void 0),Jd(tI(t),"_mediaRecorder",void 0),Jd(tI(t),"_recoderTimer",void 0),Jd(tI(t),"_isAudioPlaybackDeviceTesting",!1),Jd(tI(t),"_isAudioDeviceRecordTesting",!1),Jd(tI(t),"_audioCaptureAndRecoderResolve",void 0),Jd(tI(t),"_onAutoplayFailed",void 0),Jd(tI(t),"_audioPlaybackDeviceId",void 0),t._extensionManager=e,t}return Ul(c,[{key:"audioTrack",get:function(){return this._audioTrack}},{key:"startAudioPlaybackDeviceTest",value:(a=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._isAudioPlaybackDeviceTesting&&!this._isAudioDeviceRecordTesting){e.next=2;break}throw new vA(hA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 2:return this._isAudioPlaybackDeviceTesting=!0,fW.print("startAudioPlaybackDeviceTest()","Invoke"),e.prev=4,e.next=7,this._playAudioFile(t,{loop:!0});case 7:e.next=14;break;case 9:throw e.prev=9,e.t0=e.catch(4),fW.print("startAudioPlaybackDeviceTest()","error",e.t0),this.stopAudioPlaybackDeviceTest(),e.t0;case 14:this._startEmitAudioPlaybackDeviceTestVolume(r);case 15:case"end":return e.stop()}}),e,this,[[4,9]])}))),function(e,t){return a.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){this._isAudioPlaybackDeviceTesting&&(fW.print("stopAudioPlaybackDeviceTest()","Invoke"),this._isAudioPlaybackDeviceTesting=!1,this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement())}},{key:"startAudioDeviceRecordTest",value:(o=Rm(Tm().mark((function e(t,r,n){var i,o=this,a=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=a.length>3&&void 0!==a[3]?a[3]:3e4,window.MediaRecorder){e.next=3;break}throw new vA(hA.NOT_SUPPORTED,"Your browser does not support MediaRecorder.");case 3:if(!this._isAudioDeviceRecordTesting&&!this._isAudioPlaybackDeviceTesting){e.next=5;break}throw new vA(hA.REPEAT_DEVICE_TEST,"device test cannot be called repeatedly at the same time.");case 5:return this._isAudioDeviceRecordTesting=!0,fW.print("startAudioDeviceRecordTest()","Invoke"),this._recoderTimer=window.setTimeout((function(){fW.print("startAudioDeviceRecordTest()","".concat(i,'ms automatic call method "stopAudioDeviceRecordAndPlayTest"')),o._stopAudioCaptureAndRecoder()}),i),e.prev=8,this._onAutoplayFailed=r,e.next=12,this._startAudioCaptureAndRecoder(t,null!=n?n:100);case 12:e.next=19;break;case 14:throw e.prev=14,e.t0=e.catch(8),this._isAudioDeviceRecordTesting=!1,delete this._onAutoplayFailed,e.t0;case 19:delete this._audioCaptureAndRecoderResolve;case 20:case"end":return e.stop()}}),e,this,[[8,14]])}))),function(e,t,r){return o.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){fW.print("stopAudioDeviceRecordAndPlayTest()","Invoke"),void 0!==this._recoderTimer&&(clearTimeout(this._recoderTimer),delete this._recoderTimer),this._stopAudioCaptureAndRecoder()}},{key:"stopAudioDevicePlayTest",value:function(){this._isAudioDeviceRecordTesting&&(fW.print("stopAudioDevicePlayTest()","Invoke"),this._isAudioDeviceRecordTesting=!1,this.stopAudioDeviceRecordAndPlayTest(),this._stopEmitAudioPlaybackDeviceTestVolume(),this._destroyAudioElement()),delete this._onAutoplayFailed}},{key:"getRecordTrack",value:function(){return this._audioTrack}},{key:"setSinkId",value:(i=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(fW.print("setSinkId()","Invoke"),void 0!==HTMLAudioElement.prototype.setSinkId){e.next=3;break}throw new vA(hA.NOT_SUPPORTED,"setSinkId not supported by current browser");case 3:return e.next=5,FU.getDeviceById(t);case 5:if(r=e.sent){e.next=8;break}throw new vA(hA.INVALID_DEVICE_ID,"audio playback device id ".concat(t," is invalid"));case 8:return this._audioPlaybackDeviceId=t,this._setAudioCtxSinkId(),e.abrupt("return",r);case 11:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"getSinkId",value:function(){return this._audioPlaybackDeviceId}},{key:"destroy",value:function(){fW.print("destroy()","Invoke"),OI(CI(c.prototype),"removeAllListeners",this).call(this),this.stopAudioPlaybackDeviceTest(),this.stopAudioDevicePlayTest()}},{key:"_playAudioFile",value:(n=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return fW.print("_playAudioFile()",Om(n="Invoke url=".concat(t,"; loop=")).call(n,r.loop)),e.abrupt("return",new Yf((function(e,n){var o=OG("audio",{attributes:{src:t,crossOrigin:"anonymous"}});i._audioElement=o,o.loop=r.loop,i._audioLevelFetcher=new XU(o),o.onplaying=function(){o.onplaying=null,fW.print("_playAudioFile()","onplaying"),e()},o.onerror=function(){var e=Rm(Tm().mark((function e(t){var r,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:fW.print("_playAudioFile()","onerror",t),i=t.message||(null==o||null===(r=o.error)||void 0===r?void 0:r.message),n(new vA(hA.LOAD_RESOURCES_FAILED,"Failed to play recorded audio"+(i?", reason: ".concat(i):".")));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i._setAudioCtxSinkId().then((function(){var e,t;return null===(e=o.play())||void 0===e||null===(t=e.catch)||void 0===t?void 0:t.call(e,(function(e){var t;fW.print("_playAudioFile()","autoplay error",e);var r=Om(t="Failed to play recorded audio, ".concat(e.name,": ")).call(t,e.message);"NotAllowedError"===e.name&&i._onAutoplayFailed?i._onAutoplayFailed((function(){var e;return Yf.all([null===(e=i._audioLevelFetcher)||void 0===e?void 0:e.resume(),o.play()])})):n(new vA(hA.LOAD_RESOURCES_FAILED,r))}))}))})));case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"_destroyAudioElement",value:function(){this._audioElement&&(fW.print("_destroyAudioElement()","Invoke"),this._audioElement.onplaying=null,this._audioElement.onerror=null,this._audioElement.src="",delete this._audioElement,"function"==typeof this._audioCaptureAndRecoderResolve&&this._audioCaptureAndRecoderResolve())}},{key:"_startEmitAudioPlaybackDeviceTestVolume",value:function(e){var t=this;e=Math.max(e,100),this._audioElement&&(fW.print("_startEmitAudioPlaybackDeviceTestVolume()","start timer(".concat(e,"ms)")),this._playbackDeviceTestTimer=self.setInterval((function(){t._audioLevelFetcher&&t.emit("onAudioPlaybackDeviceTestVolume",t._audioLevelFetcher.getAudioLevel())}),e))}},{key:"_stopEmitAudioPlaybackDeviceTestVolume",value:function(){var e;void 0!==this._playbackDeviceTestTimer&&(fW.print("_stopEmitAudioPlaybackDeviceTestVolume()","stop timer"),self.clearInterval(this._playbackDeviceTestTimer),delete this._playbackDeviceTestTimer),null===(e=this._audioLevelFetcher)||void 0===e||e.destroy(),delete this._audioLevelFetcher}},{key:"_startAudioCaptureAndRecoder",value:(r=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,SV({},this._extensionManager);case 2:return this._audioTrack=e.sent,this._audioTrack.setVolume(r),n=new MediaStream([this._audioTrack.getTrack("preprocessing")]),fW.print("startAudioDeviceRecordTest()","create microphone track success!"),e.abrupt("return",new Yf((function(e,r){var o,a;"function"==typeof MediaRecorder.isTypeSupported&&(o=gE(a=["audio/webm","audio/mp4"]).call(a,(function(e){return MediaRecorder.isTypeSupported(e)})),fW.print("startAudioDeviceRecordTest()","use mimeType: ".concat(o))),i._mediaRecorder=new MediaRecorder(n,o?{mimeType:o}:void 0);var s=i._mediaRecorder.mimeType;i._mediaRecorder.ondataavailable=function(){var n=Rm(Tm().mark((function n(o){var a,c;return Tm().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!i._isAudioDeviceRecordTesting){n.next=16;break}return fW.print("startAudioDeviceRecordTest()","get recorded file(mimeType: ".concat(s,").")),c=new Blob([o.data],{type:s}),n.prev=3,n.next=6,i._playAudioFile(oW.createObjectURL(c),{loop:!1});case 6:n.next=11;break;case 8:return n.prev=8,n.t0=n.catch(3),n.abrupt("return",r(n.t0));case 11:i._startEmitAudioPlaybackDeviceTestVolume(t),null===(a=i._audioElement)||void 0===a||a.addEventListener("ended",(function(){i.stopAudioDevicePlayTest(),e()})),i._audioCaptureAndRecoderResolve=e,n.next=17;break;case 16:e();case 17:case"end":return n.stop()}}),n,null,[[3,8]])})));return function(e){return n.apply(this,arguments)}}(),i._mediaRecorder.onerror=function(e){r(new vA(hA.AUDIO_DEVICE_TEST_FAILED,e.message||"mediaRecorder error"))},i._audioCaptureAndRecoderResolve=e,i._mediaRecorder.start()})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"_stopAudioCaptureAndRecoder",value:function(){var e;this._mediaRecorder&&("recording"===this._mediaRecorder.state&&this._mediaRecorder.stop(),delete this._mediaRecorder),null===(e=this._audioTrack)||void 0===e||e.close(),delete this._audioTrack}},{key:"_setAudioCtxSinkId",value:(t=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this._audioPlaybackDeviceId){"default"===t&&(t="");try{null===(r=WU.getAudioContextInstance())||void 0===r||null===(n=r.setSinkId)||void 0===n||n.call(r,t),fW.print("setSinkId","ctx.sinkId=".concat(t))}catch(o){fW.print("setSinkId",Om(i="failed, ".concat(o.name," - ")).call(i,o.message))}}case 2:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),c}(ZM.exports.EventEmitter),yW=new yO("VideoSnapshot",1),gW=function(e){var t=null==e?void 0:e.domElement;if(t&&!t.paused&&4===t.readyState)return t},SW=function(){var e=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=document.createElement("canvas"),o=i.getContext("2d")){e.next=4;break}throw new Error("canvas.getContext error");case 4:if(a=function(e,t,n){return t=t||e.width,n=n||e.height,i.width=t,i.height=n,r?o.setTransform(-1,0,0,1,t,0):o.setTransform(1,0,0,1,0,0),o.drawImage(e,0,0,t,n),o.getImageData(0,0,t,n)},s=Date.now(),!(c=gW(n))){e.next=16;break}return yW.print("takeSnapshot","VideoPlayer already set."),e.next=11,a(c,c.videoWidth,c.videoHeight);case 11:return u=e.sent,yW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",u);case 16:if(!window.ImageCapture){e.next=29;break}if("live"!==(d=new window.ImageCapture(t)).track.readyState||!d.track.enabled||d.track.muted){e.next=29;break}return yW.print("takeSnapshot","use ImageCapture"),e.t0=a,e.next=23,d.grabFrame();case 23:return e.t1=e.sent,e.next=26,(0,e.t0)(e.t1);case 26:return l=e.sent,yW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e.abrupt("return",l);case 29:return yW.print("takeSnapshot","use temp video"),e.abrupt("return",new Yf((function(e,r){var n=new MediaStream([t]),i=document.createElement("video");i.setAttribute("playsinline",""),i.muted=!0,document.body.appendChild(i),i.onplaying=function(){var r=a(i,i.videoWidth,i.videoHeight);yW.print("takeSnapshot","success, cost ".concat(Date.now()-s,"ms")),e(r),n.removeTrack(t),i.srcObject=null,i.load()},i.onerror=r,i.srcObject=n,i.play()})));case 31:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),bW=function(){return{url:"",video:{codec:Il.H264,width:640,height:360,fps:15,gop:2,kBitRate:EW(640,360,15)},audio:{codec:"AAC",kBitRate:64,sampleRate:48e3,channels:2,AACProfile:Tl.LC},layout:{regions:[],appData:"",backgroundColor:"#000000"}}};function EW(e,t,r){return e*t<=288e3?r<=15?800:1200:e*t<=864e3?r<=15?1200:1800:e*t<=1152e3?r<=15?1600:2400:e*t<=2592e3?r<=15?2500:3750:r<=15?3300:5e3}function kW(e){if("string"!=typeof e||!/^rtmps?:\/\//.test(e))throw new vA(hA.INVALID_PARAMS,"Invalid rtmp address")}function TW(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(null==e||!e.length)throw new vA(hA.INVALID_PARAMS,"regions should not be empty.");var t,r=$T(e);try{for(r.s();!(t=r.n()).done;){var n=t.value;if("string"!=typeof n.userId)throw new vA(hA.INVALID_PARAMS,"region.userId(".concat(n.userId,") should be a string."));if("boolean"!=typeof n.isScreenStream)throw new vA(hA.INVALID_PARAMS,"region.isScreenStream(".concat(n.isScreenStream,") should be a boolean."))}}catch(i){r.e(i)}finally{r.f()}}function IW(e,t){var r,n,i,o=function(e,r){var n=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),t),i=pb(e).call(e,(function(e,t){return null==e?void 0:e[t]}),bW());return n&&r(n)?n:i},a=function(e){return e%2==0?e:e+1},s=a(o(["video","width"],(function(e){return e>=2&&e<=1920}))),c=a(o(["video","height"],(function(e){return e>=2&&e<=1920}))),u=o(["video","fps"],(function(e){return e>=1&&e<=60})),d=(null===(r=t.video)||void 0===r?void 0:r.kBitRate)||0,l=o(["audio","sampleRate"],(function(e){var t;return!!gE(t=[32e3,44100,48e3]).call(t,(function(t){return t===e||t/1e3===e}))}));return{type:"transcode",action:e,transcodeMeta:{transcode:{url:t.url},control:{protocol:"2.0"},audio:{codec:o(["audio","codec"],(function(e){return"AAC"===e})),bitRate:1e3*o(["audio","kBitRate"],(function(e){return e>=32&&e<=192})),sampleRate:l<100?1e3*l:l,channels:o(["audio","channels"],(function(e){var t;return mk(t=[1,2]).call(t,e)})),profile:o(["audio","AACProfile"],(function(e){var t;return mk(t=[Tl.LC,Tl.HEv1,Tl.HEv2]).call(t,e)}))},video:{codec:o(["video","codec"],(function(e){var t;return mk(t=["H264","H265"]).call(t,e)})),fps:u,gop:o(["video","gop"],(function(e){return e>=1&&e<=5}))*u,bitRate:1e3*(d>=16&&d<=1e4?d:EW(s,c,u)),width:s,height:c},layout:{canvas:{bgnd:o(["layout","backgroundColor"],(function(e){return/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(e)}))},regions:(null===(n=t.layout)||void 0===n||null===(i=n.regions)||void 0===i?void 0:jm(i).call(i,(function(e){var t,r;return{alpha:!e.alpha||+e.alpha>1||+e.alpha<=0?1:+e.alpha,uid:e.userId,zorder:!e.zorder||+e.zorder<0||+e.zorder>100?0:+e.zorder,x:!e.x||+e.x>=1||+e.x<0?0:+e.x,y:!e.y||+e.y>=1||+e.y<0?0:+e.y,w:!e.w||+e.w>1||+e.w<=0?1:+e.w,h:!e.h||+e.h>1||+e.h<=0?1:+e.h,renderMode:e.renderMode&&mk(t=[1,2,3]).call(t,e.renderMode)?e.renderMode:1,contentControl:e.contentControl&&mk(r=[0,1,2]).call(r,e.contentControl)?e.contentControl:0,screen:!!e.isScreenStream}})))||[],app_data:o(["layout","appData"],(function(e){return"string"==typeof e}))}}}}var RW,AW={getDefaultValue:bW,checkStartParams:function(e){var t;kW(e.url),TW(null===(t=e.layout)||void 0===t?void 0:t.regions)},checckUpdateParams:function(e){var t;e.url&&kW(e.url),TW(null===(t=e.layout)||void 0===t?void 0:t.regions)},getStartParams:function(e){return IW("started",e)},getUpdateParams:function(e){return IW("layoutChanged",e)}},wW=ad,CW=tc,xW=function(e,t,r,n){for(var i,o=n>1?void 0:n?CW(t,r):t,a=e.length-1;a>=0;a--)(i=e[a])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&wW(t,r,o),o},OW=new yO("Engine",0),DW=function(e){MI(Ee,e);var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N,L,U,V,F,B,j,H,G,z,K,X,W,q,Y,J,Q,Z,$,ee,te,re,ne,ie,oe,ae,se,ce,ue,de,le,he,pe,ve,_e,fe,me,ye,ge,Se,be=JI(Ee);function Ee(e,t,r){var n;return Vl(this,Ee),Jd(tI(n=be.call(this)),"monitor",void 0),Jd(tI(n),"_room",void 0),Jd(tI(n),"_publicStreamManager",void 0),Jd(tI(n),"_appId",void 0),Jd(tI(n),"_businessId",void 0),Jd(tI(n),"_visibility",!0),Jd(tI(n),"_localVideoTrack",void 0),Jd(tI(n),"_localAudioTrack",void 0),Jd(tI(n),"_localImgVideoTrack",void 0),Jd(tI(n),"_localImgScreenTrack",void 0),Jd(tI(n),"_localScreenVideoTrack",void 0),Jd(tI(n),"_localScreenAudioTrack",void 0),Jd(tI(n),"_tempMixingAudioTrack",void 0),Jd(tI(n),"_localAudioVolume",100),Jd(tI(n),"_localScreenAudioVolume",100),Jd(tI(n),"_remoteAudioVolume",new $S),Jd(tI(n),"_remoteScreenAudioVolume",new $S),Jd(tI(n),"_publicAudioVolume",new $S),Jd(tI(n),"_videoPlayer",void 0),Jd(tI(n),"_screenPlayer",void 0),Jd(tI(n),"_remoteVideoPlayer",new $S),Jd(tI(n),"_remoteScreenPlayer",new $S),Jd(tI(n),"_remoteAudioPlayer",new $S),Jd(tI(n),"_remoteScreenAudioPlayer",new $S),Jd(tI(n),"_publicStreamAudioPlayer",new $S),Jd(tI(n),"_publicStreamVideoPlayer",new $S),Jd(tI(n),"_publicStreamIds",new $S),Jd(tI(n),"_roomConfig",void 0),Jd(tI(n),"_videoStreamConstraints",wM),Jd(tI(n),"_audioStreamConstraints",{}),Jd(tI(n),"_enableSimulcast",!1),Jd(tI(n),"_videoStreamEncodeConfig",[wM]),Jd(tI(n),"_screenStreamEncodeConfig",[CM]),Jd(tI(n),"_dummyMainImage",void 0),Jd(tI(n),"_dummyScreenImage",void 0),Jd(tI(n),"_trackSourceType",void 0),Jd(tI(n),"_liveTranscodeConfig",void 0),Jd(tI(n),"_startCloudProxyTimestamp",void 0),Jd(tI(n),"_localVideoDeviceId",void 0),Jd(tI(n),"_localAudioDeviceId",void 0),Jd(tI(n),"_pauseAllSubscribeState",{audio:void 0,video:void 0,resumeStreamIds:{}}),Jd(tI(n),"_audioVolumeIndicationTimer",void 0),Jd(tI(n),"_dummyMainTimer",void 0),Jd(tI(n),"_dummyScreenTimer",void 0),Jd(tI(n),"_audioPropertiesReportTimer",null),Jd(tI(n),"_mirrorType",hl.MIRROR_TYPE_RENDER),Jd(tI(n),"_audioMixingManager",void 0),Jd(tI(n),"_pubLock",void 0),Jd(tI(n),"_rtmClient",void 0),Jd(tI(n),"_messageStatisticsObserver",void 0),Jd(tI(n),"_tempRoomInfo",void 0),Jd(tI(n),"_originIceConfigRequestUrls",void 0),Jd(tI(n),"_originConfigServerUrls",void 0),Jd(tI(n),"_originLogServerUrl",void 0),Jd(tI(n),"_extensionManager",void 0),Jd(tI(n),"_audioDeviceManager",void 0),Jd(tI(n),"_remoteVideoConfig",new $S),Jd(tI(n),"_cameraCapturing",!1),Jd(tI(n),"_interruptCameraCapture",!1),Jd(tI(n),"_micCapturing",!1),Jd(tI(n),"_interruptMicCapture",!1),Jd(tI(n),"_config",void 0),Jd(tI(n),"_needClosePreTrack",!1),Jd(tI(n),"_ctx",void 0),Jd(tI(n),"_updateMixAudioTrack",function(){var e=Rm(Tm().mark((function e(t){var r,i,o=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.length>1&&void 0!==o[1]?o[1]:Dl.PLAYOUT_AND_PUBLISH,OW.print("_updateMixAudioTrack()"),n._localAudioTrack){e.next=5;break}return t&&(n._tempMixingAudioTrack={track:t,type:i}),e.abrupt("return");case 5:if(t?(n._localAudioTrack.mixType=i,n._localAudioTrack.mixedAudioTrack=t):(delete n._localAudioTrack.mixType,delete n._localAudioTrack.mixedAudioTrack),null===(r=n._room)||void 0===r||!r.hasPublished){e.next=9;break}return e.next=9,n._updatePublish();case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),Jd(tI(n),"_onAudioMixingMessage",(function(e){n.safeEmit(Nl.onAudioMixingStateChanged,e)})),Jd(tI(n),"_onAudioMixingAutoplayFailed",(function(e){n.safeEmit(Nl.onAutoplayFailed,e)})),n.id=t,n._appId=e,n._pubLock=new gH("pubLock"),n._addDeviceEventHandler(),n._extensionManager=new YU(t),n._audioDeviceManager=new mW(n._extensionManager),n._audioMixingManager=new dW({getLocalAudioTrack:function(){return n._localAudioTrack},updateLocalAudioTrack:n._updateMixAudioTrack,emitMessage:n._onAudioMixingMessage,onAutoPlayFailed:n._onAudioMixingAutoplayFailed},t),n._ctx={id:t,appId:e,avSync:!0,streamRTT:{},useCloudProxy:!1,audioProfileManager:new vW(e),userPriority:new $S,expectedIDC:null==r?void 0:r.expectedIDC,joinRoomConfig:new gM(t),enableFallbackHandler:LW(e),enableStandardHandler:UW(e),pcKillSwitch:Zd(Zd({ctor_sdpsemantics_add:!0,ctor_encodedinsetablestream_add:!0,sld_rtcpfb_rrtr_add:!0,sld_ext_sdesmid_remove:!0,sld_fmtp_sps_add:!0,sld_fmtp_bitrate_add:!0,sld_fmtp_opus_add:!0},RM("PC_KILLSWITCH")),NW(n._appId))},window.__rtc_engine__=tI(n),window["__rtc_engine__".concat(Math.floor(100*Math.random()+1))]=tI(n),n._trackSourceType={video:$d.VIDEO_SOURCE_TYPE_INTERNAL,screenVideo:$d.VIDEO_SOURCE_TYPE_INTERNAL,audio:el.AUDIO_SOURCE_TYPE_INTERNAL,screenAudio:el.AUDIO_SOURCE_TYPE_INTERNAL},n._config=r,n._rtmClient=new pW(n._ctx),n._handleRTMClient(n._rtmClient),n._handleAudioDeviceManager(),n._messageStatisticsObserver=new TO(t),n.monitor=MO(t),kO.createRTSMsgReportor(n.id),n._getServerConfig(),n}return Ul(Ee,[{key:"appId",get:function(){return this._appId},set:function(e){this._appId=e}},{key:"updateToken",value:(Se=Rm(Tm().mark((function e(t){var r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("updateToken()","token: %s",t),DM(t,"token"),!this.waitForNewToken||!this._tempRoomInfo){e.next=8;break}return n=this._tempRoomInfo,i=n.config,o=n.userInfo,a=n.roomId,delete this._tempRoomInfo,e.next=7,this.joinRoom(t,a,o,i);case 7:return e.abrupt("return",e.sent);case 8:if(this._room){e.next=10;break}throw new vA(hA.UPDATE_TOKEN_BEFORE_JOIN,"update token before join room");case 10:return e.next=12,null===(r=this._room)||void 0===r?void 0:r.updateToken(t);case 12:case"end":return e.stop()}}),e,this)}))),function(e){return Se.apply(this,arguments)})},{key:"setVideoCaptureDevice",value:(ge=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setVideoCaptureDevice()","deviceId: %s",t),DM(t,"deviceId"),this._localVideoDeviceId=t,this._localVideoTrack){e.next=5;break}return e.abrupt("return");case 5:return r=UB({},this._videoStreamConstraints),"user"===t||"environment"===t||"left"===t||"right"===t?(delete r.deviceId,r.facingMode=t):r.deviceId={exact:t},ZD&&jD&&cM>=85&&cM<=91&&(null===(n=this._videoPlayer)||void 0===n||n.removeTrack()),this._needClosePreTrack=this._needClosePreTrack||ZD&&jD,this._needClosePreTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),delete this._localVideoTrack),OW.print("setVideoCaptureDevice()","start createCameraVideoTrack..."),e.next=13,yV(r,this._extensionManager).catch((function(e){if(o._localVideoTrack&&!o._localVideoTrack.dummy)return OW.print("setVideoCaptureDevice()","createCameraVideoTrack failed, stop pre VideoTrack."),o._removeLocalTrackEvents(o._localVideoTrack),o._localVideoTrack.close(),delete o._localVideoTrack,yV(r,o._extensionManager).then((function(e){return o._needClosePreTrack=!0,e})).catch(Rm(Tm().mark((function t(){var r;return Tm().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return OW.print("setVideoCaptureDevice()","createCameraVideoTrack failed, rollback."),t.next=3,yV(o._videoStreamConstraints,o._extensionManager);case 3:throw r=t.sent,o._switchTrack(r),e;case 6:case"end":return t.stop()}}),t)}))));throw e}));case 13:return i=e.sent,OW.print("setVideoCaptureDevice()","createCameraVideoTrack success."),this._videoStreamConstraints=r,this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),e.next=19,this._switchTrack(i);case 19:case"end":return e.stop()}}),e,this)}))),function(e){return ge.apply(this,arguments)})},{key:"setAudioCaptureDevice",value:(ye=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setAudioCaptureDevice()","deviceId: %s",t),DM(t,"deviceId"),this._localAudioDeviceId=t,this._localAudioTrack){e.next=5;break}return e.abrupt("return");case 5:return this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),this._localAudioTrack.close(),this._removeLocalTrackEvents(this._localAudioTrack),e.prev=8,this._micCapturing=!0,e.next=12,SV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 12:if(i=e.sent,!this._interruptMicCapture){e.next=17;break}return this._interruptMicCapture=!1,i.close(),e.abrupt("return");case 17:if(this._initLocalTrackEvents(i),this._localAudioTrack=i,this._localAudioTrack.setVolume(this._localAudioVolume),this._room){e.next=22;break}return e.abrupt("return");case 22:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubAudio){e.next=25;break}return e.next=25,this._updatePublish();case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[8,,25,28]])}))),function(e){return ye.apply(this,arguments)})},{key:"_addDeviceEventHandler",value:function(){FU.on(Nl.onVideoDeviceStateChanged,this._onVideoDeviceStateChange.bind(this)),FU.on(Nl.onAudioDeviceStateChanged,this._onAudioDeviceStateChange.bind(this))}},{key:"_addHandlerEventHandler",value:function(){var e,t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A,w,C,x,O,D,M,P,N=this;null===(e=this._room)||void 0===e||e.on(hH.ON_ADD_STREAM,this._onAddStream.bind(this)),null===(t=this._room)||void 0===t||t.on(hH.ON_REMOVE_STREAM,this._onRemoveStream.bind(this)),null===(r=this._room)||void 0===r||r.on(hH.USER_CONNECTION,this._onUserConnection.bind(this)),null===(n=this._room)||void 0===n||n.on(SH.ON_USER_LEAVE,this._onUserLeave.bind(this)),null===(i=this._room)||void 0===i||i.on(SH.ON_ROOM_ERROR,this._onRoomError.bind(this)),null===(o=this._room)||void 0===o||o.on(SH.ON_NETWORK_QUALITY,this._onNetworkQuality.bind(this)),null===(a=this._room)||void 0===a||a.on(hH.ON_CUSTOM_MESSAGE,this._onCustomMessage.bind(this)),null===(s=this._room)||void 0===s||s.on(hH.USER_MESSAGE_RECEIVED,this._onUserMessageReceived.bind(this)),null===(c=this._room)||void 0===c||c.on(hH.USER_BINARY_MESSAGE_RECEIVED,this._onUserBinaryMessageReceived.bind(this)),null===(u=this._room)||void 0===u||u.on(hH.ON_USER_TOKEN_WILL_EXPIRE,this._onUserTokenWillExpire.bind(this)),null===(d=this._room)||void 0===d||d.on(hH.POST_PROCESSING_MESSAGE,(function(e){"2.0"===e.protocol?N._onStreamMixingEvent({error:e.error,event:e.eventType,message:e.message}):"publicStreamCallback"===e.type?N._onPushPublicStreamResult(e):"transcodeStatusCallback"===e.type&&N._onLiveTranscodingResult(e)})),null===(l=this._room)||void 0===l||l.on(vH.ON_CONNECTION_STATE_CHANGE,this._onConnectionStateChange.bind(this)),null===(h=this._room)||void 0===h||h.on(vH.ON_VENDOR_CONNECTION_STATE_CHANGE,(function(e){return N.safeEmit(Nl.onVendorConnectionStateChanged,e)})),null===(p=this._room)||void 0===p||p.on(SH.RESUBSCRIBE,this._onResubscribe.bind(this)),null===(v=this._room)||void 0===v||v.on(SH.SUBSCRIBE_PUSH_TRACK,this._onSubscribePushTrack.bind(this)),null===(_=this._room)||void 0===_||_.on(SH.REMOVE_PUSH_TRACK,this._onRemovePushTrack.bind(this)),null===(f=this._room)||void 0===f||f.on(SH.ON_PUBLISH_RESULT,(function(e){var t;null!==(t=N._room)&&void 0!==t&&t._roomConfig.isAutoPublish&&N.safeEmit(Nl.onAutoPublishResult,e)})),null===(m=this._room)||void 0===m||m.on(SH.ON_REMOTE_STREAM_STATS,(function(e){N.safeEmit(Nl.onRemoteStreamStats,e)})),null===(y=this._room)||void 0===y||y.on(SH.ON_LOCAL_STREAM_STATS,(function(e){N.safeEmit(Nl.onLocalStreamStats,e)})),null===(g=this._room)||void 0===g||g.on(SH.ON_SUBTITLE_STATE_CHANGED,(function(e){N.safeEmit(Nl.onSubtitleStateChanged,e)})),null===(S=this._room)||void 0===S||S.on(SH.ON_SUBTITLE_MESSAGE_RECEIVED,(function(e){N.safeEmit(Nl.onSubtitleMessageReceived,e)})),null===(b=this._room)||void 0===b||b.on(SH.ON_USER_PUBLISH_STATE_CHANGE,this._onUserPublishStateChange.bind(this)),null===(E=this._room)||void 0===E||E.on(SH.ON_USER_START_AUDIO_CAPTURE,(function(e,t){var r=e.userId;N._updateAudioPlayerState(t),N.safeEmit(Nl.onUserStartAudioCapture,{userId:r})})),null===(k=this._room)||void 0===k||k.on(SH.ON_USER_STOP_AUDIO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopAudioCapture,{userId:t})})),null===(T=this._room)||void 0===T||T.on(SH.ON_USER_START_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStartVideoCapture,{userId:t})})),null===(I=this._room)||void 0===I||I.on(SH.ON_USER_STOP_VIDEO_CAPTURE,(function(e){var t=e.userId;N.safeEmit(Nl.onUserStopVideoCapture,{userId:t})})),null===(R=this._room)||void 0===R||R.on(SH.ON_SEI_MESSAGED_RECEIVED,(function(e){N.safeEmit(Nl.onSEIMessageReceived,e)})),null===(A=this._room)||void 0===A||A.on(SH.ON_REMOTE_VIDEO_SIZE_CHANGED,(function(e,t){N.safeEmit(Nl.onRemoteVideoSizeChanged,e,t)})),null===(w=this._room)||void 0===w||w.on(SH.ON_SIMULCAST_SUBSCRIBE_FALLBACK,(function(e){return N.safeEmit(Nl.onSimulcastSubscribeFallback,e)})),null===(C=this._room)||void 0===C||C.on(SH.RECONNECT_FAILED,(function(){N.safeEmit(Nl.onError,{errorCode:hA.RECONNECT_FAILED})})),null===(x=this._room)||void 0===x||x.on(SH.ON_VIDEO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onVideoStreamBanned,{uid:e.uid,banned:e.banned})})),null===(O=this._room)||void 0===O||O.on(SH.ON_AUDIO_STREAM_BANNED,(function(e){N.safeEmit(Nl.onAudioStreamBanned,{uid:e.uid,banned:e.banned})})),null===(D=this._room)||void 0===D||D.on(SH.ON_FORWARD_STREAM_ERROR,(function(e){N.safeEmit(Nl.onForwardStreamError,e)})),null===(M=this._room)||void 0===M||M.on(SH.ON_REJOIN_WITH_TCP,(function(){N.safeEmit(Nl.onRejoinWithTcp)})),null===(P=this._room)||void 0===P||P.on(SH.ON_ICE_CONNECT_WITH_TCP,(function(){N.safeEmit(Nl.onIceConnectWithTcp)}))}},{key:"safeEmit",value:function(e){for(var t,r,n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return WM(e)&&NO(this.id,e,i),(t=OI(CI(Ee.prototype),"safeEmit",this)).call.apply(t,Om(r=[this,e]).call(r,i))}},{key:"_removeHandlerEventHandler",value:function(){var e;null===(e=this._room)||void 0===e||e.removeAllListeners()}},{key:"connect",value:(me=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._room){e.next=2;break}return e.abrupt("return",!1);case 2:return this._room=new xG({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},this._ctx),this._addHandlerEventHandler(),e.next=6,this._room.connect(this._appId);case 6:case"end":return e.stop()}}),e,this)}))),function(){return me.apply(this,arguments)})},{key:"joinRoom",value:(fe=Rm(Tm().mark((function e(t,r,n,i){var o,a,s,c,u,d,l;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("joinRoom()","token: %o roomId: %o, userInfo: %o, roomConfig: %o",t,r,n,i),FM(t)||DM(t,"token"),BM(r),GM(n),zM(i=UB({isAutoPublish:!0,isAutoSubscribeAudio:!0,isAutoSubscribeVideo:!0,roomProfileType:bl.communication},i)),(null===(o=this._room)||void 0===o?void 0:o.connectionState)!==tG.CONNECTED){e.next=8;break}throw new vA(hA.REPEAT_JOIN,"Already joined");case 8:return null===(a=this.monitor)||void 0===a||a.report("rtc_sdk_api_call",{sdk_api_name:"host",message:location.host,error_code:0}),this._room||(this._room=new xG(i,this._ctx),this._addHandlerEventHandler()),this._room.roomConfig=i,s=this._liveTranscodeConfig&&AW.getStartParams(this._liveTranscodeConfig),c=Zd(Zd({},n),{},{businessId:this._businessId,role:this._visibility?lW.NORMAL_USER:lW.SILENT_USER}),e.prev=13,this._ctx.useCloudProxy&&(this._startCloudProxyTimestamp=Date.now()),gG(c),e.next=18,this._room.join(this._appId,r,t,c,s);case 18:return d=e.sent,this._roomConfig=i,this._ctx.audioProfileManager.setRoomId(r),this._tempRoomInfo&&delete this._tempRoomInfo,null!==(u=i)&&void 0!==u&&u.isAutoPublish&&(this._visibility?this._updatePublish({invokeByJoinRoom:!0,mediaType:ul.AUDIO_AND_VIDEO}):this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),kO.setRoomId(this.id,r),kO.setUserId(this.id,n.userId),e.abrupt("return",d);case 28:throw e.prev=28,e.t0=e.catch(13),e.t0.code===hA.INVALID_TOKEN&&(this._tempRoomInfo={config:i,roomId:r,userInfo:c}),null===(l=this._room)||void 0===l||l.destroy(),delete this._room,e.t0;case 34:case"end":return e.stop()}}),e,this,[[13,28]])}))),function(e,t,r,n){return fe.apply(this,arguments)})},{key:"leaveRoom",value:(_e=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]&&i[0],OW.print("leaveRoom()"),!t){e.next=7;break}return e.next=5,null===(r=this._room)||void 0===r?void 0:r.leave(t);case 5:e.next=8;break;case 7:null===(n=this._room)||void 0===n||n.leave(t).catch();case 8:this._removeHandlerEventHandler(),this._ctx.audioProfileManager.setRoomId(),this._liveTranscodeConfig&&this.stopLiveTranscoding(),this._room=void 0,this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._roomConfig=void 0,this._publicStreamIds=new $S,kO.setRoomId(this.id,""),kO.setUserId(this.id,"");case 24:case"end":return e.stop()}}),e,this)}))),function(){return _e.apply(this,arguments)})},{key:"destroy",value:function(){var e,t,r;OW.print("destroy()"),this.removeAllListeners(),this._removeHandlerEventHandler(),null===(e=this._room)||void 0===e||e.destroy(),this._room=void 0,null===(t=this._videoPlayer)||void 0===t||t.destroy(),this._videoPlayer=void 0,this._screenPlayer=void 0,this._videoStreamConstraints={},this._videoStreamEncodeConfig=[wM],this._screenStreamEncodeConfig=[CM],this._pauseAllSubscribeState={audio:void 0,video:void 0,resumeStreamIds:{}},this._messageStatisticsObserver.destroy(),this.monitor.destroy(),kO.destroyRTSMsgReportor(this.id),clearInterval(this._audioVolumeIndicationTimer),clearInterval(this._dummyMainTimer),clearInterval(this._dummyScreenTimer),this._audioVolumeIndicationTimer=void 0,this._stopAudioPropertiesReport(),this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close(),this._localAudioTrack=void 0),this._localVideoTrack&&(this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localVideoTrack=void 0),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close(),this._localScreenAudioTrack=void 0),this._localScreenVideoTrack&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localScreenVideoTrack=void 0),this._localImgVideoTrack&&(this._localImgVideoTrack.stop(),this._localImgVideoTrack=void 0),this._localImgScreenTrack&&(this._localImgScreenTrack.stop(),this._localImgScreenTrack=void 0),this._remoteAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteAudioPlayer=new $S,this._remoteScreenAudioPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenAudioPlayer=new $S,this._remoteScreenPlayer.forEach((function(e){return e.destroy()})),this._remoteScreenPlayer=new $S,this._remoteVideoPlayer.forEach((function(e){return e.destroy()})),this._remoteVideoPlayer=new $S,this._publicStreamAudioPlayer.forEach((function(e){return e.destroy()})),this._publicStreamAudioPlayer=new $S,this._publicStreamVideoPlayer.forEach((function(e){return e.destroy()})),this._publicStreamVideoPlayer=new $S,this._roomConfig=void 0,this._audioMixingManager.destroy(),this._rtmClient.destroy(),null===(r=this._publicStreamManager)||void 0===r||r.destroy(),this._publicStreamIds=new $S,this._audioDeviceManager.destroy(),this._remoteVideoConfig=new $S,this._ctx.userPriority.clear(),this._extensionManager.destroy(),this._cameraCapturing=!1,this._micCapturing=!1,this._interruptCameraCapture=!1,this._interruptMicCapture=!1,this._ctx.avSync=!0,this._localAudioVolume=100,this._localScreenAudioVolume=100,this._remoteAudioVolume.clear(),this._remoteScreenAudioVolume.clear(),this._publicAudioVolume.clear()}},{key:"publishStream",value:(ve=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("publishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!TD(t)||this._localVideoTrack||!this._localImgVideoTrack){e.next=7;break}return e.next=6,vV(this._localImgVideoTrack,this._extensionManager);case 6:this._localVideoTrack=e.sent;case 7:return e.next=9,this._updatePublish({mediaType:t});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return ve.apply(this,arguments)})},{key:"unpublishStream",value:(pe=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("unpublishStream()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),!r){e.next=5;break}return e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.unpublish());case 5:return e.next=7,this._updatePublish({mediaType:t,pubState:EH.UNPUB});case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return pe.apply(this,arguments)})},{key:"publishScreen",value:(he=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("publishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.prev=3,!TD(t)||this._localScreenVideoTrack||!this._localImgScreenTrack){e.next=8;break}return e.next=7,fV(this._localImgScreenTrack,this._extensionManager);case 7:this._localScreenVideoTrack=e.sent;case 8:return e.next=10,this._updateScreenPublish({mediaType:t,pubState:EH.PUB});case 10:e.next=19;break;case 12:if(e.prev=12,e.t0=e.catch(3),!(e.t0 instanceof vA)){e.next=18;break}throw e.t0;case 18:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 19:case"end":return e.stop()}}),e,this,[[3,12]])}))),function(e){return he.apply(this,arguments)})},{key:"unpublishScreen",value:(le=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("unpublishScreen()","mediaType: %o",t),this._checkMediaType(t),this._assertNotInRoom(),e.next=5,this._updateScreenPublish({mediaType:t,pubState:EH.UNPUB});case 5:case"end":return e.stop()}}),e,this)}))),function(e){return le.apply(this,arguments)})},{key:"subscribeStream",value:(de=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("subscribeStream()","userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!1,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return de.apply(this,arguments)})},{key:"_subscribe",value:(ue=Rm(Tm().mark((function e(t,r,n){var i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._checkMediaType(n),this._assertNotInRoom(),n!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){e.next=5;break}return OW.print("subscribeStream()","due to multiChatMode return"),e.abrupt("return");case 5:if(u=this._room.remoteStreams.get(r),d=null==u?void 0:gE(u).call(u,(function(e){return e.isScreen===t}))){e.next=9;break}throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");case 9:return l=this._pauseAllSubscribeState.audio,h=this._pauseAllSubscribeState.video,this._pauseAllSubscribeState.audio&&(n-=n&ul.AUDIO),this._pauseAllSubscribeState.video&&(n-=n&ul.VIDEO),OW.print("subscribeStream()","due to pauseAll mediaType: %o",n),p=d.hasSubscribed,v=this._remoteVideoConfig.get(r)||(null===(o=this._roomConfig)||void 0===o?void 0:o.remoteVideoConfig),d.originalMediaType=n,e.next=19,this._room.subscribe(d,n,v);case 19:kD(n)&&this._updateAudioPlayerState(d),TD(n)&&this._updateVideoPlayerState(d),_=0,f=0,l!==this._pauseAllSubscribeState.audio&&(this._pauseAllSubscribeState.audio?_|=ul.AUDIO:f|=ul.AUDIO),h!==this._pauseAllSubscribeState.video&&(this._pauseAllSubscribeState.video?_|=ul.VIDEO:f|=ul.VIDEO),_&&this.pauseAllSubscribedStream(_),f&&this.resumeAllSubscribedStream(f),this._pauseAllSubscribeState.resumeStreamIds[d.streamId]=d.streamId,!t&&(null!==(a=this._roomConfig)&&void 0!==a&&a.isAutoSubscribeAudio||null!==(s=this._roomConfig)&&void 0!==s&&s.isAutoSubscribeVideo)&&(d.audioTrack||d.videoTrack)&&(m={userId:r,isScreen:!1,state:il.SUBSCRIBE_SUCC},this.safeEmit(Nl.onAutoSubscribeResult,m)),null!==(c=this._room)&&void 0!==c&&c.multiChatMode||p||!kD(n)||!d.hasAudio||null===(y=d.observer)||void 0===y||y.setSubscribeAudio(!0),!p&&TD(n)&&d.hasVideo&&(null===(g=d.observer)||void 0===g||g.setSubscribeVideo(!0));case 31:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return ue.apply(this,arguments)})},{key:"unsubscribeStream",value:(ce=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:OW.print("unsubscribeStream()","userId: %o, mediaType: %o",t,r),this._unsubscribe(!1,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ce.apply(this,arguments)})},{key:"subscribeScreen",value:(se=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("subscribeScreen() userId: %o, mediaType: %o",t,r),e.abrupt("return",this._subscribe(!0,t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return se.apply(this,arguments)})},{key:"unsubscribeScreen",value:(ae=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:OW.print("unsubscribeScreen() userId: %o, mediaType: %o",t,r),this._unsubscribe(!0,t,r);case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return ae.apply(this,arguments)})},{key:"_unsubscribe",value:function(e,t,r,n){var i,o=this;if(this._checkMediaType(r),this._assertNotInRoom(),r!==ul.AUDIO||null===(i=this._room)||void 0===i||!i.multiChatMode){var a,s=this._room.remoteStreams.get(t),c=null==s?void 0:gE(s).call(s,(function(t){return t.isScreen===e}));if(null==c||!c.hasSubscribed)throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");if(ZD&&cM&&cM>=85&&cM<=91&&r!==ul.AUDIO)null===(a=e?this._remoteScreenPlayer.get(t):this._remoteVideoPlayer.get(t))||void 0===a||a.stop();return this._room.unsubscribe(c,r).then((function(){n||delete o._pauseAllSubscribeState.resumeStreamIds[c.streamId]}))}OW.print("subscribeStream()","due to multiChatMode return")}},{key:"setRemoteVideoConfig",value:(oe=Rm(Tm().mark((function e(t,r){var n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("setRemoteVideoConfig() userId: %o, remoteVideoConfig: %o",t,r),jM(t),qM(r),this._remoteVideoConfig.set(t,r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.updateSubVideoConfig(t,r).then((function(){})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return oe.apply(this,arguments)})},{key:"startVideoCapture",value:(ie=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("startVideoCapture()","deviceId: %s",t),FM(t)||DM(t,"deviceId"),t=t||this._localVideoDeviceId,this._localVideoDeviceId=t,this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 6:if(!(this._cameraCapturing||this._localVideoTrack&&!this._localVideoTrack.dummy)){e.next=8;break}throw new vA(hA.REPEAT_CAPTURE,"Has already capture");case 8:return a=this._videoStreamConstraints,t&&("user"===t||"environment"===t||"left"===t||"right"===t?a.facingMode=t:a.deviceId={exact:t},this._videoStreamConstraints=a),s={},e.prev=11,this._cameraCapturing=!0,e.next=15,yV(a,this._extensionManager);case 15:if(u=e.sent,!this._interruptCameraCapture){e.next=21;break}throw this._interruptCameraCapture=!1,this._removeLocalTrackEvents(u),u.close(),new vA(hA.INTERRUPT,"interrupt by stopVideoCapture");case 21:if(this._initLocalTrackEvents(u),this._localVideoTrack=u,null===(c=this._videoPlayer)||void 0===c||c.playVideo(u),(d=null==u?void 0:u.getTrack())&&(s=d.getSettings(),l={width:s.width,height:s.height},this._localVideoTrack.resolution=l,setTimeout((function(){return p.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_MAIN,info:l})}))),this._room){e.next=28;break}return e.abrupt("return",s);case 28:return e.prev=28,this._cameraCapturing=!1,e.finish(28);case 31:return h=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubVideo||h)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableVideo(!0),e.abrupt("return",s);case 35:case"end":return e.stop()}}),e,this,[[11,,28,31]])}))),function(e){return ie.apply(this,arguments)})},{key:"stopVideoCapture",value:(ne=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("stopVideoCapture()"),!this._cameraCapturing){e.next=5;break}return this._interruptCameraCapture=!0,OW.print("stopVideoCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.video!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 7:if(null===(t=this._videoPlayer)||void 0===t||t.stop(),this._localVideoTrack&&(this._localVideoTrack.dummy||((s=this._extensionManager.getPluginByName(qU.PRE_PROCESSING,"RTCBeautyExtension"))&&s.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close(),this._localImgVideoTrack?(null===(c=this._localVideoTrack)||void 0===c||c.setTrack(this._localImgVideoTrack,this._extensionManager),this._localVideoTrack.dummy=!0):this._localVideoTrack=void 0)),this._room){e.next=11;break}return e.abrupt("return");case 11:if(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n||!n.pubVideo){e.next=14;break}return e.next=14,this._updatePublish();case 14:null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setEnableVideo(!1);case 15:case"end":return e.stop()}}),e,this)}))),function(){return ne.apply(this,arguments)})},{key:"startAudioCapture",value:(re=Rm(Tm().mark((function e(t){var r,n,i,o,a,s;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("startAudioCapture()","deviceId: $o",t),FM(t)||DM(t,"deviceId"),t=t||this._localAudioDeviceId,this._localAudioDeviceId=t,this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 6:if(!this._micCapturing&&!this._localAudioTrack){e.next=8;break}throw new vA(hA.REPEAT_CAPTURE,"Has already capture");case 8:return t&&this._ctx.audioProfileManager.updateConstraints({deviceId:{exact:t}}),e.prev=9,this._micCapturing=!0,e.next=13,SV(this._ctx.audioProfileManager.getConstraints(),this._extensionManager);case 13:if(a=e.sent,!this._interruptMicCapture){e.next=19;break}throw this._interruptMicCapture=!1,this._removeLocalTrackEvents(a),a.close(),new vA(hA.INTERRUPT,"interrupt by stopAudioCapture");case 19:if(this._initLocalTrackEvents(a),this._localAudioTrack=a,this._localAudioTrack.setVolume(this._localAudioVolume),this._tempMixingAudioTrack&&(this._localAudioTrack.mixType=this._tempMixingAudioTrack.type,this._localAudioTrack.mixedAudioTrack=this._tempMixingAudioTrack.track,delete this._tempMixingAudioTrack),this._room){e.next=25;break}return e.abrupt("return");case 25:return e.prev=25,this._micCapturing=!1,e.finish(25);case 28:s=this._room._roomConfig.isAutoPublish,(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localStream)&&void 0!==n&&n.pubAudio||s)&&(this._visibility?this._updatePublish():this.safeEmit(Nl.onAutoPublishResult,{isScreen:!1,state:ol.PUBLISH_FAIL})),null===(i=this._room.localStream)||void 0===i||null===(o=i.observer)||void 0===o||o.setEnableAudio(!0);case 31:case"end":return e.stop()}}),e,this,[[9,,25,28]])}))),function(e){return re.apply(this,arguments)})},{key:"stopAudioCapture",value:(te=Rm(Tm().mark((function e(){var t,r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("stopAudioCapture()"),!this._micCapturing){e.next=5;break}return this._interruptMicCapture=!0,OW.print("stopAudioCapture()","capturing"),e.abrupt("return");case 5:if(this._trackSourceType.audio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:if(this._localAudioTrack&&(this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,this._audioMixingManager.stopAll(),this._room){e.next=12;break}return e.abrupt("return");case 12:if(null===(t=this._room)||void 0===t||null===(r=t.localStream)||void 0===r||!r.pubAudio){e.next=15;break}return e.next=15,this._updatePublish();case 15:null===(n=this._room.localStream)||void 0===n||null===(i=n.observer)||void 0===i||i.setEnableAudio(!1);case 16:case"end":return e.stop()}}),e,this)}))),function(){return te.apply(this,arguments)})},{key:"getAudioMixingManager",value:function(){return OW.print("getAudioMixingManager()","invoke"),this._audioMixingManager}},{key:"startScreenCapture",value:(ee=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m=this,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c=y.length>0&&void 0!==y[0]?y[0]:{},OW.print("startScreenCapture()","config: %o",c),u=c.enableAudio,d=void 0!==u&&u,this._trackSourceType.screenVideo!==$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=5;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as internal first");case 5:if(this._trackSourceType.screenAudio!==el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=7;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as internal first");case 7:return e.next=9,EV(d,this._extensionManager,this._screenStreamEncodeConfig[0]);case 9:if(l=e.sent,h=eI(l,2),p=h[0],null==(v=h[1])||v.setVolume(this._localScreenAudioVolume),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(t=this._localScreenAudioTrack)||void 0===t||t.close(),delete this._localScreenAudioTrack,this._localScreenVideoTrack=p,null!==(r=this._screenStreamEncodeConfig[0])&&void 0!==r&&r.contentHint&&p.setContentHint(null===(_=this._screenStreamEncodeConfig[0])||void 0===_?void 0:_.contentHint),(f=null==p?void 0:p.getTrack())&&setTimeout((function(){var e=f.getSettings(),t={width:e.width,height:e.height};p.resolution=t,m.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:cl.STREAM_INDEX_SCREEN,info:{width:e.width,height:e.height}})}),500),v&&(this._localScreenAudioTrack=v,this._initLocalTrackEvents(v)),null===(n=this._screenPlayer)||void 0===n||n.playVideo(this._localScreenVideoTrack),this._initLocalTrackEvents(this._localScreenVideoTrack,!0),!(null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubAudio||null!==(a=this._room)&&void 0!==a&&null!==(s=a.localScreenStream)&&void 0!==s&&s.pubVideo)){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(){return ee.apply(this,arguments)})},{key:"stopScreenCapture",value:($=Rm(Tm().mark((function e(){var t,r,n,i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("stopScreenCapture()"),null===(t=this._screenPlayer)||void 0===t||t.stop(),this._localScreenVideoTrack&&(this._localScreenVideoTrack.dummy||(this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close(),this._localImgScreenTrack&&(null===(a=this._localScreenVideoTrack)||void 0===a||a.setTrack(this._localImgScreenTrack,this._extensionManager),this._localScreenVideoTrack.dummy=!0))),this._localScreenAudioTrack&&(this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,!(null!==(r=this._room)&&void 0!==r&&null!==(n=r.localScreenStream)&&void 0!==n&&n.pubAudio||null!==(i=this._room)&&void 0!==i&&null!==(o=i.localScreenStream)&&void 0!==o&&o.pubVideo)){e.next=8;break}return e.next=8,this._updateScreenPublish();case 8:case"end":return e.stop()}}),e,this)}))),function(){return $.apply(this,arguments)})},{key:"setLocalVideoPlayer",value:function(e,t){if(OW.print("setLocalVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),MM(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t&&t.renderDom){var r,n,i,o,a=Zd(Zd({userId:this._getUserId()},t),{},{isLocal:!0});if(KM(a),e===cl.STREAM_INDEX_MAIN&&!this._videoPlayer)return this._videoPlayer=new LG(this.id,a),this._initPlayerEvents(this._videoPlayer,!1,e),this._videoPlayer.mirror(!!this._mirrorType),this._localVideoTrack&&!this._localVideoTrack.dummy&&(null===(r=this._config)||void 0===r?void 0:r.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._videoPlayer.playVideo(this._localVideoTrack),(null===(n=this._room)||void 0===n?void 0:n.localStream)&&(this._room.localStream.videoDom=this._videoPlayer.domElement),this._videoPlayer.domElement;if(e===cl.STREAM_INDEX_SCREEN&&!this._screenPlayer)return this._screenPlayer=new LG(this.id,Zd(Zd({},a),{},{isScreen:!0,isLocal:!0})),this._initPlayerEvents(this._screenPlayer,!1,e),this._localScreenVideoTrack&&!this._localScreenVideoTrack.dummy&&(null===(i=this._config)||void 0===i?void 0:i.autoPlayPolicy)!==kl.PLAY_MANUALLY&&this._screenPlayer.playVideo(this._localScreenVideoTrack),(null===(o=this._room)||void 0===o?void 0:o.localScreenStream)&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),this._screenPlayer.domElement;if(t&&void 0!==t.renderMode){var s=e===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer;null==s||s.setRenderMode(t.renderMode)}}else{var c,u;e===cl.STREAM_INDEX_MAIN?(null===(c=this._videoPlayer)||void 0===c||c.destroy(!0),delete this._videoPlayer):(null===(u=this._screenPlayer)||void 0===u||u.destroy(),delete this._screenPlayer)}}},{key:"startLiveTranscoding",value:(Z=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("startLiveTranscoding()","transcode: %o",t),AW.checkStartParams(t),this._liveTranscodeConfig=t,!((n=null===(r=this._room)||void 0===r?void 0:r.roomInfo)&&n.roomId.length+n.userInfo.userId.length>126)){e.next=6;break}throw new vA(hA.INVALID_PARAMS,"The roomId+userId must be within 126 bytes");case 6:if(e.prev=6,this.safeEmit(Nl.onStreamMixingEvent,{event:bH.START,error:0,message:""}),!this._room||this._room.connectionState!==tG.CONNECTED){e.next=11;break}return e.next=11,null===(i=this._room)||void 0===i?void 0:i.liveControlMessage(AW.getStartParams(this._liveTranscodeConfig));case 11:e.next=20;break;case 13:if(e.prev=13,e.t0=e.catch(6),!(e.t0 instanceof vA)){e.next=19;break}throw e.t0;case 19:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 20:case"end":return e.stop()}}),e,this,[[6,13]])}))),function(e){return Z.apply(this,arguments)})},{key:"updateLiveTranscoding",value:(Q=Rm(Tm().mark((function e(t){var r,n,i,o;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("updateLiveTranscoding()","transcode: %o",t),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete(i=UB({},t)).audio,null===(r=i.video)||void 0===r||delete r.codec,null===(n=i.video)||void 0===n||delete n.gop,AW.checckUpdateParams(i),this._liveTranscodeConfig=UB(this._liveTranscodeConfig,i),e.prev=9,this.safeEmit(Nl.onStreamMixingEvent,{event:bH.UPDATE,error:0,message:""}),e.next=13,null===(o=this._room)||void 0===o?void 0:o.liveControlMessage(AW.getUpdateParams(this._liveTranscodeConfig));case 13:e.next=22;break;case 15:if(e.prev=15,e.t0=e.catch(9),!(e.t0 instanceof vA)){e.next=21;break}throw e.t0;case 21:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 22:case"end":return e.stop()}}),e,this,[[9,15]])}))),function(e){return Q.apply(this,arguments)})},{key:"stopLiveTranscoding",value:(J=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("stopLiveTranscoding()"),this._liveTranscodeConfig){e.next=3;break}return e.abrupt("return");case 3:return delete this._liveTranscodeConfig,e.prev=4,this.safeEmit(Nl.onStreamMixingEvent,{event:bH.STOP,error:0,message:""}),e.next=8,null===(t=this._room)||void 0===t?void 0:t.liveControlMessage({action:"stopped",type:"transcode"});case 8:e.next=17;break;case 10:if(e.prev=10,e.t0=e.catch(4),!(e.t0 instanceof vA)){e.next=16;break}throw e.t0;case 16:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 17:case"end":return e.stop()}}),e,this,[[4,10]])}))),function(){return J.apply(this,arguments)})},{key:"startSubtitle",value:(Y=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("startSubtitle()","config: %o",t),this._assertNotInRoom(),e.next=4,null===(r=this._room)||void 0===r?void 0:r.startSubtitle(t);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return Y.apply(this,arguments)})},{key:"stopSubtitle",value:function(){var e;OW.print("stopSubtitle()","invoke"),null===(e=this._room)||void 0===e||e.stopSubtitle()}},{key:"setBusinessId",value:function(e){return OW.print("setBusinessId()","businessId: %s",e),!function(e){return"string"!=typeof e}(e)&&!this._room&&(this.monitor.set({rtc_business_id:e}),this._businessId=e,!0)}},{key:"setUserVisibility",value:(q=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setUserVisibility()","enable: %o",t),t=!!t,this._visibility!==t){e.next=4;break}return e.abrupt("return");case 4:if(this._room){e.next=7;break}return this._visibility=t,e.abrupt("return");case 7:if(this._assertNotInRoom(),this._room.localStream&&(null===(n=this._room.localStream.observer)||void 0===n||n.setPublisher(t)),e.t0=!t,!e.t0){e.next=13;break}return e.next=13,this._room.unpublish();case 13:return e.next=15,this._room.updateUserAttributes({role:t?lW.NORMAL_USER:lW.SILENT_USER});case 15:this._visibility=t,t&&null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoPublish&&this._updatePublish({mediaType:ul.AUDIO_AND_VIDEO});case 17:case"end":return e.stop()}}),e,this)}))),function(e){return q.apply(this,arguments)})},{key:"_initPlayerEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:cl.STREAM_INDEX_MAIN,i=n===cl.STREAM_INDEX_SCREEN;e.on("playback_event",(function(n){switch(n.eventName){case"timeupdate":return;case"loadeddata":if("audio"===n.type){var o,a,s=e.userId.replace("_screen",""),c=null===(o=t._room)||void 0===o||null===(a=o.remoteStreams.get(s))||void 0===a?void 0:gE(a).call(a,(function(e){return e.isScreen===i})),u=function(){r?t.safeEmit(Nl.onFirstPublicStreamAudioFrameDecoded,{publicStreamId:s}):(t.safeEmit(Nl.onAudioFirstFrameDecoded,{userId:s,isScreen:i}),t.safeEmit(Nl.onRemoteAudioFirstFrame,{userId:s,isScreen:i})),t.monitor.report("first_remote_audio_render",{stream_id:"",stream_user_id:s||""},{isScreen:i})};c&&c.observer&&!c.observer.audioFirstFrameReceived?c.observer.once("recvAudioFirstFrame",u):u()}else{var d,l,h={userId:e.userId,height:(null===(d=e.domElement)||void 0===d?void 0:d.videoHeight)||0,width:(null===(l=e.domElement)||void 0===l?void 0:l.videoWidth)||0,isScreen:i};r?(h.publicStreamId=h.userId,delete h.userId,delete h.isScreen,t.safeEmit(Nl.onFirstPublicStreamVideoFrameRendered,h),t.safeEmit(Nl.onFirstPublicStreamVideoFrameDecoded,h)):e.isLocal||(t.safeEmit(Nl.onVideoFirstFrameRendered,h),t.safeEmit(Nl.onVideoFirstFrameDecoded,h),t.safeEmit(Nl.onRemoteVideoFirstFrame,h)),t.monitor.report("first_remote_video_render",{stream_id:"",stream_user_id:n.userId||""},{isScreen:i})}break;case"autoplay-error":return r&&(n.publicStreamId=n.userId),LO(t.id,"autoplay-error",e instanceof LG?"video":"audio",0,n.userId||""),void t.safeEmit(Nl.onAutoplayFailed,{userId:n.userId,kind:e instanceof LG?"video":"audio",mediaType:e instanceof LG?ul.VIDEO:ul.AUDIO,streamIndex:e.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN})}t.safeEmit(Nl.onPlayerEvent,n)}))}},{key:"_initLocalTrackEvents",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];["track-ended","track-mute","track-unmute"].forEach((function(r){e.on(r,function(){var e=Rm(Tm().mark((function e(n){var i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.monitor.report("rtc_error",{message:Om(i="track-".concat(r," mediaType: ")).call(i,n.getTrack().kind),error_code:AH.TRACK_ERROR}),o=!1,n!==t._localScreenAudioTrack&&n!==t._localScreenVideoTrack||(o=!0),a=n.getTrack().kind,t.safeEmit({"track-ended":Nl.onTrackEnded,"track-mute":Nl.onTrackMute,"track-unmute":Nl.onTrackUnmute}[r],{kind:a,isScreen:o}),!QD&&!WD){e.next=13;break}if("track-mute"!==r){e.next=12;break}if(GU.emit(jU.ON_IOS_LOCAL_TRACK_MUTE,a),"audio"!==a){e.next=12;break}return e.next=11,t.stopAudioCapture();case 11:t.startAudioCapture();case 12:"track-unmute"===r&&GU.emit(jU.ON_IOS_LOCAL_TRACK_UNMUTE,a);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())})),e.on("resolution-change",(function(e){t._extensionManager.getPluginsByType(qU.PRE_PROCESSING).forEach((function(t){var r;null==t||null===(r=t.applyConstraints)||void 0===r||r.call(t,e)})),t.safeEmit(Nl.onLocalVideoSizeChanged,{streamIndex:r?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,info:e})}))}},{key:"_removeLocalTrackEvents",value:function(e){e.removeAllListeners("track-ended"),e.removeAllListeners("track-mute"),e.removeAllListeners("track-unmute"),e.removeAllListeners("resolution-change")}},{key:"setRemoteVideoPlayer",value:function(e,t){OW.print("setRemoteVideoPlayer()","streamIndex: %o, videoPlayerOption: %o",e,t),MM(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),KM(t);var r,n,i,o=t.userId;if(e===cl.STREAM_INDEX_MAIN){var a,s,c;if(null===(a=this._remoteVideoPlayer.get(o))||void 0===a||a.destroy(),!t.renderDom)return;var u=new LG(this.id,t);this._initPlayerEvents(u,!1,e),this._remoteVideoPlayer.set(o,u);var d=null===(s=this._room)||void 0===s||null===(c=s.remoteStreams.get(o))||void 0===c?void 0:gE(c).call(c,(function(e){return!e.isScreen}));return d&&(this._updateVideoPlayerState(d),d.videoDom=u.domElement),u.domElement}if(null===(r=this._remoteScreenPlayer.get(o))||void 0===r||r.destroy(),t.renderDom){var l=new LG(this.id,Zd(Zd({},t),{},{isScreen:!0}));this._remoteScreenPlayer.set(o,l),this._initPlayerEvents(l,!1,e);var h=null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(o))||void 0===i?void 0:gE(i).call(i,(function(e){return e.isScreen}));return h&&(this._updateVideoPlayerState(h),h.videoDom=l.domElement),l.domElement}}},{key:"setLocalVideoMirrorType",value:function(e){OW.print("setLocalVideoMirrorType()","mirrorType: %o",e),MM(e,"mirrorType",[hl.MIRROR_TYPE_NONE,hl.MIRROR_TYPE_RENDER]),this._mirrorType=e,this._videoPlayer&&this._videoPlayer.mirror(!!e)}},{key:"setAudioPlaybackDevice",value:(W=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("setAudioPlaybackDevice()","deviceId: %s",t),DM(t,"deviceId"),e.next=4,this._audioDeviceManager.setSinkId(t);case 4:r=e.sent,this._remoteAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this._remoteScreenAudioPlayer.forEach((function(e){e.setPlaybackDevice(t)})),this.safeEmit(Nl.onAudioPlaybackDeviceChanged,r),this.monitor.report("rtc_audio_device",{audio_event:"playout_device_switch",message:Nm(r),error_code:0});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return W.apply(this,arguments)})},{key:"play",value:(X=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=y.length>1&&void 0!==y[1]?y[1]:ul.AUDIO_AND_VIDEO,a=y.length>2?y[2]:void 0,OW.print("play()","userId: %s, mediaType: %s, streamIndex: %s",t,o,a),s=!t||t===this._getUserId()||"local_user"===t,c=void 0===a||a===cl.STREAM_INDEX_MAIN,u=void 0===a||a===cl.STREAM_INDEX_SCREEN,d=o!==ul.VIDEO,l=o!==ul.AUDIO,h=[],s&&l&&(c&&this._localVideoTrack&&(null===(p=this._videoPlayer)||void 0===p||p.mirror(!!this._mirrorType),h.push(null===(v=this._videoPlayer)||void 0===v?void 0:v.manuallyPlay())),u&&this._localScreenVideoTrack&&h.push(null===(_=this._screenPlayer)||void 0===_?void 0:_.manuallyPlay())),t===(null===(r=this._audioMixingManager)||void 0===r?void 0:r.id)&&h.push(this._audioMixingManager.resumeLocalPlay()),f=null===(n=this._room)||void 0===n?void 0:n.remoteStreams,l&&c&&h.push(VG(this._remoteVideoPlayer,t,!1,f)),l&&u&&h.push(VG(this._remoteScreenPlayer,t,!0,f)),d&&c&&h.push(VG(this._remoteAudioPlayer,t,!1,f)),l&&u&&h.push(VG(this._remoteScreenAudioPlayer,t,!0,f)),m=null===(i=this._publicStreamManager)||void 0===i?void 0:i.remoteStreams,d&&h.push(VG(this._publicStreamVideoPlayer,t,!1,m)),l&&h.push(VG(this._publicStreamAudioPlayer,t,!1,m)),e.abrupt("return",Yf.all(h).then((function(){})));case 20:case"end":return e.stop()}}),e,this)}))),function(e){return X.apply(this,arguments)})},{key:"pauseAllSubscribedStream",value:(K=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("pauseAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),kD(t)&&(s._pauseAllSubscribeState.audio=!0),TD(t)&&(s._pauseAllSubscribeState.video=!0),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$T(iR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(e.hasSubscribed){s._pauseAllSubscribeState.resumeStreamIds[e.streamId]=e.streamId;var r=s._unsubscribe(e.isScreen,e.userId,t,!0);r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return K.apply(this,arguments)})},{key:"resumeAllSubscribedStream",value:(z=Rm(Tm().mark((function e(t){var r,n,i,o,a,s=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("resumeAllSubscribedStream()","mediaType: %o",t),this._checkMediaType(t),kD(t)&&(s._pauseAllSubscribeState.audio=!1),TD(t)&&(s._pauseAllSubscribeState.video=!1),this._room){e.next=6;break}return e.abrupt("return",Yf.resolve());case 6:n=[],i=$T(iR(r=this._room.remoteStreams).call(r));try{for(i.s();!(o=i.n()).done;)a=o.value,Array.isArray(a)&&a.forEach((function(e){if(s._pauseAllSubscribeState.resumeStreamIds[e.streamId]){var r=s._subscribe(e.isScreen,e.userId,t).then((function(){delete s._pauseAllSubscribeState.resumeStreamIds[e.streamId]}));r&&n.push(r)}}))}catch(c){i.e(c)}finally{i.f()}return e.abrupt("return",Yf.all(n).then((function(){var e,t;null===(e=s._room)||void 0===e||null===(t=e.remoteStreams)||void 0===t||t.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){s._updateAudioPlayerState(e),s._updateVideoPlayerState(e)}))}))})));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return z.apply(this,arguments)})},{key:"sendUserMessage",value:(G=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM(t),XM(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!1,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!1,o,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return G.apply(this,arguments)})},{key:"sendUserBinaryMessage",value:(H=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM(t),LM(r,"message"),XM(r),this._assertNotInRoom(),o=Date.now(),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.sendUserMessage(t,r))||void 0===i?void 0:i.then((function(e){return a._messageStatisticsObserver.countP2PMessage(!0,t,!0,o,e),e.id})).catch((function(e){throw a._messageStatisticsObserver.countP2PMessage(!1,t,!0,o,e),e})));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return H.apply(this,arguments)})},{key:"sendRoomMessage",value:(j=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!1,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return j.apply(this,arguments)})},{key:"sendRoomBinaryMessage",value:(B=Rm(Tm().mark((function e(t){var r,n,i,o=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return XM(t),this._assertNotInRoom(),i=Date.now(),e.abrupt("return",null===(r=this._room)||void 0===r||null===(n=r.sendRoomMessage(t,!0))||void 0===n?void 0:n.then((function(e){var t,r;return o._messageStatisticsObserver.countRoomMessage(!0,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})).catch((function(e){var t,r;throw o._messageStatisticsObserver.countRoomMessage(!1,null===(t=o._room)||void 0===t||null===(r=t.roomInfo)||void 0===r?void 0:r.roomId,!0,i),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return B.apply(this,arguments)})},{key:"setAudioCaptureConfig",value:(F=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=r.length>0&&void 0!==r[0]?r[0]:{},OW.print("setAudioCaptureConfig()","config: %o",t),delete t.deviceId,UM(t),this._shouldUpdateAudioConf("setAudioCaptureConfig")&&this._ctx.audioProfileManager.updateConstraints(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return F.apply(this,arguments)})},{key:"setVideoCaptureConfig",value:(V=Rm(Tm().mark((function e(){var t,r=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=r.length>0&&void 0!==r[0]?r[0]:{},OW.print("setVideoCaptureConfig()","config: %o",t),e.abrupt("return",this._setVideoCaptureConfig(t));case 3:case"end":return e.stop()}}),e,this)}))),function(){return V.apply(this,arguments)})},{key:"_setVideoCaptureConfig",value:(U=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(delete(r=i.length>0&&void 0!==i[0]?i[0]:{}).deviceId,UM(r),n=Zd(Zd({},r),{},{deviceId:this._videoStreamConstraints.deviceId}),!this._localVideoTrack){e.next=7;break}return e.next=7,this._localVideoTrack.updateVideoCaptureConfig(n);case 7:return this._videoStreamConstraints=n,e.abrupt("return",(null===(t=this._localVideoTrack)||void 0===t?void 0:t.getTrack().getSettings())||{});case 9:case"end":return e.stop()}}),e,this)}))),function(){return U.apply(this,arguments)})},{key:"enableSimulcastMode",value:function(e){var t;return OW.print("enableSimulcastMode()","enabled: %o",e),this._enableSimulcast=e,14!==(null==oM?void 0:oM[0])&&(null!==(t=this._room)&&void 0!==t&&t.hasPublished&&xD("You must call this API before publishing the video streams"),!0)}},{key:"setVideoEncoderConfig",value:(L=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(OW.print("setVideoEncoderConfig()"," descriptions: %o",t),Array.isArray(t)||(t=[t]),JM(t=Hs(t).call(t,(function(e){return!!e}))),t.length>3&&(xD("setVideoEncoderConfig: You can set parameters for up to 3 streams"),t=km(t).call(t,0,3)),n=1;n<t.length;n++)i=OD(t[0].width)/OD(t[n].width)||1,Math.floor(i)!==i&&xD("setVideoEncoderConfig: The resolution setting needs to be an integer multiple");jR(t).call(t,(function(e,t){return t.maxKbps-e.maxKbps})),this._setVideoCaptureConfig(Zd({},t[0])),this._videoStreamEncodeConfig=t,this._updateDummyCaptureImage(cl.STREAM_INDEX_MAIN),null!==(r=this._room)&&void 0!==r&&r.hasPublished&&this._updatePublish();case 11:case"end":return e.stop()}}),e,this)}))),function(e){return L.apply(this,arguments)})},{key:"setScreenEncoderConfig",value:(N=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:OW.print("setScreenEncoderConfig()","description: %o",t),this._screenStreamEncodeConfig=[t],this._localScreenVideoTrack&&(this._localScreenVideoTrack.updateVideoCaptureConfig(t),t.contentHint&&this._localScreenVideoTrack.setContentHint(t.contentHint)),this._updateDummyCaptureImage(cl.STREAM_INDEX_SCREEN),null!==(r=this._room)&&void 0!==r&&r.hasScreenPublished&&this._updateScreenPublish();case 5:case"end":return e.stop()}}),e,this)}))),function(e){return N.apply(this,arguments)})},{key:"sendSEIMessage",value:function(e,t,r){if(OW.print("sendSEIMessage()","streamIdex: %o, message: %o, repeatCount: %o",e,t,r),!iL())throw new vA(hA.NOT_SUPPORTED,"Browser does not support sending SEI");MM(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),OM(r,"repeatCount",0,30);var n="string"==typeof t?new Uint8Array(cD.str2ab(t)):t;if(t.length){var i;if(e===cl.STREAM_INDEX_MAIN){var o,a,s;if(null===(o=this._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.hasPublished)return;i=null===(s=this._room)||void 0===s?void 0:s.localStream}else{var c,u,d;if(null===(c=this._room)||void 0===c||null===(u=c.localScreenStream)||void 0===u||!u.hasPublished)return;i=null===(d=this._room)||void 0===d?void 0:d.localScreenStream}if(n.byteLength>4096)OW.print("sei size must not bigger than 4KB");else{var l=oD();i.seiList.push({content:n,uuid:l,repeatCount:r}),setTimeout((function(){var e;if(i){var t,r=JR(e=i.seiList).call(e,(function(e){return e.uuid===l}));if(r)rk(t=i.seiList).call(t,r,1)}}),2e3)}}else OW.print("sei message must not be empty")}},{key:"setAudioVolumeIndicationInterval",value:function(e){var t=this;OW.print("setAudioVolumeIndicationInterval()","interval %o: ",e),("number"!=typeof e||e<200)&&(e=200);var r=[];this._audioVolumeIndicationTimer&&clearInterval(this._audioVolumeIndicationTimer),this._audioVolumeIndicationTimer=setInterval((function(){var e,n;r=[],null===(e=t._room)||void 0===e||e.remoteStreams.forEach((function(e,t){var n;if(0!==e.length){var i=gE(e).call(e,(function(e){return!1===e.isScreen})),o=null==i||null===(n=i.audioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t,volume:o||0})}}));var i=null===(n=t._localAudioTrack)||void 0===n?void 0:n.getAudioLevel();r.push({userId:t._getUserId(),volume:i||0}),t.safeEmit(Nl.onAudioVolumeIndication,{speakers:r})}),e)}},{key:"_sendActiveSpeaker",value:function(e,t){if(this._room&&this._room.remoteUsers.size>=1){var r,n=e[0],i=pb(t).call(t,(function(e,t){return e&&e.audioPropertiesInfo.nonlinearVolume>t.audioPropertiesInfo.nonlinearVolume?e:t}),void 0);if((r=n?i?n.audioPropertiesInfo.nonlinearVolume>i.audioPropertiesInfo.nonlinearVolume?n:i:n:i)&&r.audioPropertiesInfo.nonlinearVolume>-35){var o,a;if(r.streamKey)o=this._room.remoteUsers.get(r.streamKey.userId);else o=null===(a=this._room._roomInfo)||void 0===a?void 0:a.userInfo;o&&this.safeEmit(Nl.onActiveSpeaker,{userId:o.userId,extraInfo:o.extraInfo})}}}},{key:"enableAudioPropertiesReport",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};OW.print("enableAudioPropertiesReport()","config %o: ",t);var r=t.enableInBackground,n=void 0===r||r,i=t.interval,o=void 0===i?100:i;this._stopAudioPropertiesReport(),o<=0||(o=Math.max(100,o),this._audioPropertiesReportTimer=self.setInterval((function(){if(n||"hidden"!==document.visibilityState){var t=[],r=e._audioDeviceManager.getRecordTrack()||e._localAudioTrack;if(r){var i=r.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_MAIN,audioPropertiesInfo:{linearVolume:i,nonlinearVolume:ED(i)}})}if(e._localScreenAudioTrack){var o=e._localScreenAudioTrack.getAudioLevel();t.push({streamIndex:cl.STREAM_INDEX_SCREEN,audioPropertiesInfo:{linearVolume:o,nonlinearVolume:ED(o)}})}if(e.safeEmit(Nl.onLocalAudioPropertiesReport,t),e._room){var a,s=[];if(null!==(a=e._room)&&void 0!==a&&a.multiChatMode)e._room.getActiveSpeakerInMultiChatMode().forEach((function(t){var r,n,i=255*t.audioLevel;s.push({streamKey:{userId:t.userId,streamIndex:cl.STREAM_INDEX_MAIN,roomId:null===(r=e._room)||void 0===r||null===(n=r._roomInfo)||void 0===n?void 0:n.roomId},audioPropertiesInfo:{linearVolume:i,nonlinearVolume:ED(i)}})}));else e._room.remoteStreams.forEach((function(t,r){t.forEach((function(t){if(t.audioTrack){var n,i,o=t.audioTrack.getAudioLevel();s.push({streamKey:{userId:r,streamIndex:t.isScreen?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN,roomId:null===(n=e._room)||void 0===n||null===(i=n.roomInfo)||void 0===i?void 0:i.roomId},audioPropertiesInfo:{linearVolume:o,nonlinearVolume:ED(o)}})}}))}));e.safeEmit(Nl.onRemoteAudioPropertiesReport,s),e._sendActiveSpeaker(t,Hs(s).call(s,(function(e){return e.streamKey.streamIndex!==cl.STREAM_INDEX_SCREEN})))}}}),o))}},{key:"setVideoSourceType",value:(P=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T,I,R,A;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setVideoSourceType()","index: %o, videoSourceType: %o",t,r),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),MM(r,"VideoSourceType",[$d.VIDEO_SOURCE_TYPE_EXTERNAL,$d.VIDEO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"video":"screenVideo",this._trackSourceType[n]===r){e.next=26;break}if(this._trackSourceType[n]=r,OW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localVideoTrack||t!==cl.STREAM_INDEX_MAIN){e.next=17;break}if(u=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(u=!0,(d=this._extensionManager.getPluginByName(qU.PRE_PROCESSING,"RTCBeautyExtension"))&&d.emit("stop"),this._removeLocalTrackEvents(this._localVideoTrack),this._localVideoTrack.close()),null===(o=this._videoPlayer)||void 0===o||o.stop(),this._localVideoTrack=void 0,l=null===(a=this._room)||void 0===a?void 0:a._roomConfig.isAutoPublish,u?null===(h=this._room)||void 0===h||null===(p=h.localStream)||void 0===p||null===(v=p.observer)||void 0===v||v.setEnableVideo(!1):null===(_=this._room)||void 0===_||null===(f=_.localStream)||void 0===f||null===(m=f.observer)||void 0===m||m.setPushVideo(!1),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubVideo||l)){e.next=17;break}return e.next=17,this._updatePublish();case 17:if(!this._localScreenVideoTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=26;break}if(b=!1,r===$d.VIDEO_SOURCE_TYPE_EXTERNAL&&(b=!0,this._removeLocalTrackEvents(this._localScreenVideoTrack),this._localScreenVideoTrack.close()),null===(y=this._screenPlayer)||void 0===y||y.stop(),this._localScreenVideoTrack=void 0,b?null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setEnableVideo(!1):null===(I=this._room)||void 0===I||null===(R=I.localScreenStream)||void 0===R||null===(A=R.observer)||void 0===A||A.setPushVideo(!1),null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||!S.pubVideo){e.next=26;break}return e.next=26,this._updateScreenPublish();case 26:case"end":return e.stop()}}),e,this)}))),function(e,t){return P.apply(this,arguments)})},{key:"setExternalVideoTrack",value:(M=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setExternalVideoTrack()","index: %o, track: %o",t,r),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),PM(r),t!==cl.STREAM_INDEX_MAIN){e.next=15;break}if(this._trackSourceType.video===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 6:return e.next=8,IV(r,this._extensionManager);case 8:if(this._localVideoTrack=e.sent,this._initLocalTrackEvents(this._localVideoTrack),null===(n=this._videoPlayer)||void 0===n||n.playVideo(this._localVideoTrack),s=null===(i=this._room)||void 0===i?void 0:i._roomConfig.isAutoPublish,!(null!==(o=this._room)&&void 0!==o&&null!==(a=o.localStream)&&void 0!==a&&a.pubVideo||s)){e.next=15;break}return e.next=15,this._updatePublish();case 15:if(t!==cl.STREAM_INDEX_SCREEN){e.next=27;break}if(this._trackSourceType.screenVideo===$d.VIDEO_SOURCE_TYPE_EXTERNAL){e.next=18;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setVideoSourceType as external first");case 18:return e.next=20,CV(r,this._extensionManager);case 20:if(this._localScreenVideoTrack=e.sent,this._initLocalTrackEvents(this._localScreenVideoTrack,!0),null===(c=this._screenPlayer)||void 0===c||c.playVideo(this._localScreenVideoTrack),null===(u=this._room)||void 0===u||null===(d=u.localScreenStream)||void 0===d||null===(l=d.observer)||void 0===l||l.setPushVideo(!0),null===(h=this._room)||void 0===h||null===(p=h.localScreenStream)||void 0===p||!p.pubVideo){e.next=27;break}return e.next=27,this._updateScreenPublish();case 27:case"end":return e.stop()}}),e,this)}))),function(e,t){return M.apply(this,arguments)})},{key:"setAudioSourceType",value:(D=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v,_,f,m,y,g,S,b,E,k,T;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setAudioSourceType()","index: %o, audioSourceType: %o",t,r),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),MM(r,"audioSourceType",[el.AUDIO_SOURCE_TYPE_EXTERNAL,el.AUDIO_SOURCE_TYPE_INTERNAL]),n=t===cl.STREAM_INDEX_MAIN?"audio":"screenAudio",this._trackSourceType[n]===r){e.next=24;break}if(this._trackSourceType[n]=r,OW.print("setVideoSourceType",Om(i="set ".concat(n," source type to ")).call(i,r)),!this._localAudioTrack||t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(c=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(c=!0,this._removeLocalTrackEvents(this._localAudioTrack),this._localAudioTrack.close()),this._localAudioTrack=void 0,u=null===(o=this._room)||void 0===o?void 0:o._roomConfig.isAutoPublish,c?null===(d=this._room)||void 0===d||null===(l=d.localStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setEnableAudio(!1):null===(p=this._room)||void 0===p||null===(v=p.localStream)||void 0===v||null===(_=v.observer)||void 0===_||_.setPushAudio(!1),!(null!==(a=this._room)&&void 0!==a&&null!==(s=a.localStream)&&void 0!==s&&s.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(!this._localScreenAudioTrack||t!==cl.STREAM_INDEX_SCREEN){e.next=24;break}if(y=!1,this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL&&(y=!0,this._removeLocalTrackEvents(this._localScreenAudioTrack),this._localScreenAudioTrack.close()),this._localScreenAudioTrack=void 0,y?null===(g=this._room)||void 0===g||null===(S=g.localScreenStream)||void 0===S||null===(b=S.observer)||void 0===b||b.setEnableAudio(!1):null===(E=this._room)||void 0===E||null===(k=E.localScreenStream)||void 0===k||null===(T=k.observer)||void 0===T||T.setPushAudio(!1),null===(f=this._room)||void 0===f||null===(m=f.localScreenStream)||void 0===m||!m.pubAudio){e.next=24;break}return e.next=24,this._updateScreenPublish();case 24:case"end":return e.stop()}}),e,this)}))),function(e,t){return D.apply(this,arguments)})},{key:"setExternalAudioTrack",value:(O=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c,u,d,l,h,p,v;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("setExternalAudioTrack()","index: %o, track: %o",t,r),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),PM(r),t!==cl.STREAM_INDEX_MAIN){e.next=16;break}if(this._trackSourceType.audio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=6;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 6:return e.next=8,AV(r,this._extensionManager);case 8:if(this._localAudioTrack=e.sent,this._localAudioTrack.setVolume(this._localAudioVolume),this._initLocalTrackEvents(this._localAudioTrack),u=null===(n=this._room)||void 0===n?void 0:n._roomConfig.isAutoPublish,null===(i=this._room)||void 0===i||null===(o=i.localStream)||void 0===o||null===(a=o.observer)||void 0===a||a.setPushAudio(!0),!(null!==(s=this._room)&&void 0!==s&&null!==(c=s.localStream)&&void 0!==c&&c.pubAudio||u)){e.next=16;break}return e.next=16,this._updatePublish();case 16:if(t!==cl.STREAM_INDEX_SCREEN){e.next=28;break}if(this._trackSourceType.screenAudio===el.AUDIO_SOURCE_TYPE_EXTERNAL){e.next=19;break}throw new vA(hA.STREAM_TYPE_NOT_MATCH,"setAudioSourceType as external first");case 19:return e.next=21,OV(r,this._extensionManager);case 21:if(this._localScreenAudioTrack=e.sent,this._localScreenAudioTrack.setVolume(this._localScreenAudioVolume),this._initLocalTrackEvents(this._localScreenAudioTrack),null===(d=this._room)||void 0===d||null===(l=d.localScreenStream)||void 0===l||null===(h=l.observer)||void 0===h||h.setPushAudio(!0),null===(p=this._room)||void 0===p||null===(v=p.localScreenStream)||void 0===v||!v.pubAudio){e.next=28;break}return e.next=28,this._updateScreenPublish();case 28:case"end":return e.stop()}}),e,this)}))),function(e,t){return O.apply(this,arguments)})},{key:"login",value:(x=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("login()","token: %o, userInfo: %o",t,r),FM(t)||DM(t,"token"),jM(r),e.abrupt("return",this._rtmClient.login(t,r));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return x.apply(this,arguments)})},{key:"logout",value:(C=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("logout()"),e.abrupt("return",this._rtmClient.logout());case 2:case"end":return e.stop()}}),e,this)}))),function(){return C.apply(this,arguments)})},{key:"updateLoginToken",value:(w=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("updateLoginToken()","token: %o",t),FM(t)||DM(t,"token"),e.abrupt("return",this._rtmClient.updateLoginToken(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"getPeerOnlineStatus",value:(A=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("getPeerOnlineStatus()","userId: %o",t),jM(t),e.abrupt("return",this._rtmClient.getPeerOnlineStatus(t));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"sendUserMessageOutsideRoom",value:(R=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM(t),XM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!1,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!1,n,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return R.apply(this,arguments)})},{key:"sendUserBinaryMessageOutsideRoom",value:(I=Rm(Tm().mark((function e(t,r){var n,i=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return jM(t),LM(r,"message"),XM(r),n=Date.now(),e.abrupt("return",this._rtmClient.sendUserMessageOutsideRoom(t,r).then((function(e){return i._messageStatisticsObserver.countUserMessageOutsideRoom(!0,t,!0,n,e),e.id})).catch((function(e){throw i._messageStatisticsObserver.countUserMessageOutsideRoom(!1,t,!0,n,e),e})));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return I.apply(this,arguments)})},{key:"setServerParams",value:(T=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("setServerParams()","signature: %o, url: %0",t,r),e.abrupt("return",this._rtmClient.setServerParams(t,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return T.apply(this,arguments)})},{key:"sendServerMessage",value:(k=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return DM(t,"message"),XM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!1,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!1,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return k.apply(this,arguments)})},{key:"sendServerBinaryMessage",value:(E=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return LM(t,"message"),XM(t),r=Date.now(),e.abrupt("return",this._rtmClient.sendServerMessage(t).then((function(e){n._messageStatisticsObserver.countServerMessage(!0,!0,r,e)})).catch((function(e){throw n._messageStatisticsObserver.countServerMessage(!1,!0,r,e),e})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return E.apply(this,arguments)})},{key:"startCloudProxy",value:function(e){if(this._room)throw new vA(hA.START_CLOUD_PROXY_AFTER_JOIN,"[startCloudProxy] should be invoke before join room ");OW.print("startCloudProxy()",e),DM(e.logProxy,"logProxy"),DM(e.accessProxy,"accessProxy"),DM(e.configProxy,"configProxy"),this._originIceConfigRequestUrls=RM("ICE_CONFIG_REQUEST_URLS"),this._originLogServerUrl=RM("LOG_SERVER_URL"),this._originConfigServerUrls=RM("CONFIG_REQUEST_DOMAINS"),IM("ICE_CONFIG_REQUEST_URLS",e.accessProxy),IM("LOG_SERVER_URL",function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return/^https?:\/\/.+/.test(e)||(e="https://"+e),"".concat(e,"/video/v1/webrtc_log/")}(e.logProxy)),IM("CONFIG_REQUEST_DOMAINS",[e.configProxy]),mM.clearAccessNode(this._appId),mM.clearAccessUrls(),this._ctx.useCloudProxy=!0}},{key:"stopCloudProxy",value:function(){var e;if(this._room)throw new vA(hA.STOP_CLOUD_PROXY_BEFORE_LEAVE,"[stopCloudProxy] should be invoke after leave room ");OW.print("stopCloudProxy()"),IM("ICE_CONFIG_REQUEST_URLS",null===(e=this._originIceConfigRequestUrls)||void 0===e?void 0:jm(e).call(e,(function(e){return e.replace("https://","").replace("/dispatch/v1/AccessInfo?Action=GetAccessInfo","")}))),IM("LOG_SERVER_URL",this._originLogServerUrl),IM("CONFIG_REQUEST_DOMAINS",this._originConfigServerUrls),mM.clearAccessNode(this._appId),mM.clearAccessUrls(),this._ctx.useCloudProxy=!1,this._startCloudProxyTimestamp=void 0}},{key:"startPushPublicStream",value:(b=Rm(Tm().mark((function e(t,r){var n,i,o,a=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),HM(t),this._assertNotInRoom(),!this._publicStreamIds.get(t)){e.next=5;break}throw new vA(hA.REPEAT_PUSH,"repeat push public media stream");case 5:return o=AM(t,"started",r),e.abrupt("return",null===(n=this._room)||void 0===n||null===(i=n.publicStreamControlMessage(o))||void 0===i?void 0:i.then((function(){a._publicStreamIds.set(t,t)})));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return b.apply(this,arguments)})},{key:"updatePublicStreamParam",value:(S=Rm(Tm().mark((function e(t,r){var n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("startPushPublicStream()","publicStreamId: %o, publicStreamParam: %o",t,r),HM(t),this._assertNotInRoom(),i=AM(t,"layoutChanged",r),e.abrupt("return",null===(n=this._room)||void 0===n?void 0:n.publicStreamControlMessage(i));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"stopPushPublicStream",value:(g=Rm(Tm().mark((function e(t){var r,n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("startPushPublicStream()","publicStreamId: %o",t),HM(t),this._assertNotInRoom(),e.abrupt("return",null===(r=this._room)||void 0===r?void 0:r.publicStreamControlMessage({type:"publicstream",action:"stopped",publicStreamID:t}).then((function(){n._publicStreamIds.delete(t)})));case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"startPlayPublicStream",value:(y=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(HM(t),this._publicStreamManager){e.next=8;break}return this._publicStreamManager=new _W(this.id,this._appId,{businessId:this._businessId}),this._publicStreamManager.on(SH.RESUBSCRIBE,(function(e){var t=e.stream;if(t){var r,n=c._publicStreamAudioPlayer.get(t.streamId);n&&t.audioTrack&&(n.stop(),n.playAudio(null===(r=e.stream)||void 0===r?void 0:r.audioTrack));var i,o=c._publicStreamVideoPlayer.get(t.streamId);o&&t.videoTrack&&o.playVideo(null===(i=e.stream)||void 0===i?void 0:i.videoTrack)}})),null===(r=this._publicStreamManager)||void 0===r||r.on("onRemoteStreamStats",(function(e){e.publicStreamId=e.userId,delete e.userId,delete e.isScreen,c.safeEmit(Nl.onPublicStreamStats,e)})),null===(n=this._publicStreamManager)||void 0===n||n.on(SH.ON_SEI_MESSAGED_RECEIVED,(function(e){c.safeEmit(Nl.onPublicStreamSEIMessageReceived,e)})),e.next=8,this._publicStreamManager.connect();case 8:return e.next=10,this._publicStreamManager.startPlayPublicStream(t);case 10:i=e.sent,(o=this._publicStreamVideoPlayer.get(t))&&null!=i&&i.videoTrack&&o.playVideo(i.videoTrack,i),!(a=this._publicStreamAudioPlayer.get(t))&&null!=i&&i.audioTrack&&(a=new UG(this.id,t,{muted:(null===(s=this._config)||void 0===s?void 0:s.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:!1}),this._initPlayerEvents(a,!0),a.playAudio(i.audioTrack),this._publicStreamAudioPlayer.set(t,a));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"stopPlayPublicStream",value:(m=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._publicStreamManager){e.next=2;break}return e.abrupt("return");case 2:this._publicStreamManager.stopPlayPublicStream(t),(r=this._publicStreamAudioPlayer.get(t))&&(r.destroy(),this._publicStreamAudioPlayer.delete(t));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"setAudioProfile",value:(f=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:OW.print("setAudioProfile()","profile: %o",t),this._shouldUpdateAudioConf("setAudioProfile")&&this._ctx.audioProfileManager.setAudioProfile(t);case 2:case"end":return e.stop()}}),e,this)}))),function(e){return f.apply(this,arguments)})},{key:"setPublicStreamVideoPlayer",value:function(e,t){var r,n,i,o;OW.print("setPublicStreamVideoPlayer()","publicStreamId: %o, videoPlayerOption: %o",e,t);var a=this._publicStreamVideoPlayer.get(e);if(null===(r=a)||void 0===r||r.destroy(),null!=t&&t.renderDom){a=new LG(this.id,Zd(Zd({},t),{},{userId:e})),this._initPlayerEvents(a,!0),this._publicStreamVideoPlayer.set(e,a);var s=null===(n=this._publicStreamManager)||void 0===n||null===(i=n.remoteStreams)||void 0===i?void 0:i.get(e);null!=s&&s.videoTrack&&(null===(o=this._config)||void 0===o?void 0:o.autoPlayPolicy)!==kl.PLAY_MANUALLY&&a.playVideo(s.videoTrack,s)}else this._publicStreamVideoPlayer.delete(e)}},{key:"setDummyCaptureImagePath",value:(_=Rm(Tm().mark((function e(t,r){var n=this;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Yf((function(e,i){DM(r,"filePath");var o=new Image;o.crossOrigin="anonymous",o.src=r,o.onload=function(){t===cl.STREAM_INDEX_MAIN?n._dummyMainImage=o:n._dummyScreenImage=o;try{n._updateDummyCaptureImage(t),e()}catch(r){i(new vA(hA.UNEXPECTED_ERROR,r.message))}},o.onerror=function(){i(new vA(hA.UNEXPECTED_ERROR,"Load image error"))}})));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return _.apply(this,arguments)})},{key:"_updateDummyCaptureImage",value:function(e){var t,r;if(e===cl.STREAM_INDEX_MAIN?(t=this._dummyMainImage,r=this._videoStreamEncodeConfig[0]):(t=this._dummyScreenImage,r=this._screenStreamEncodeConfig[0]),t){var n,i,o=document.createElement("canvas"),a=o.getContext("2d"),s=OD(r.width),c=OD(r.height);if(!a)throw new vA(hA.UNEXPECTED_ERROR,"Not support canvas");!s||!c||t.width<=s&&t.height<=c?(n=t.width,i=t.height):(n=Math.min(s,t.width*c/t.height),i=Math.min(c,t.height*s/t.width)),o.width=n,o.height=i,a.drawImage(t,0,0,t.width,t.height,0,0,n,i);var u=window.setInterval((function(){t&&a.drawImage(t,0,0,t.width,t.height,0,0,n,i)}),200);e===cl.STREAM_INDEX_MAIN?(clearInterval(this._dummyMainTimer),this._dummyMainTimer=u):(clearInterval(this._dummyScreenTimer),this._dummyScreenTimer=u);var d,l,h,p,v=o.captureStream(5).getVideoTracks()[0];if(e===cl.STREAM_INDEX_MAIN){if(this._localImgVideoTrack=v,null!==(d=this._localVideoTrack)&&void 0!==d&&d.dummy)null===(l=this._localVideoTrack)||void 0===l||l.setTrack(this._localImgVideoTrack,this._extensionManager)}else if(this._localImgScreenTrack=v,null!==(h=this._localScreenVideoTrack)&&void 0!==h&&h.dummy)null===(p=this._localScreenVideoTrack)||void 0===p||p.setTrack(this._localImgScreenTrack,this._extensionManager)}}},{key:"_addListenExtensionEvent",value:function(e){var t=this;e.on("re-capture-audio",(function(){t._localAudioTrack&&t.stopAudioCapture().then((function(){t.startAudioCapture()}))})),e.on("re-capture-video",(function(){t._localVideoTrack&&!t._localVideoTrack.dummy&&t.stopVideoCapture().then((function(){t.startVideoCapture()}))})),e.on("reset-video-effect",function(){var e=Rm(Tm().mark((function e(r,n){var i,o,a;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t._localVideoTrack||t._localVideoTrack.dummy){e.next=17;break}return t._localVideoTrack&&t._removeLocalTrackEvents(t._localVideoTrack),e.prev=2,e.next=5,t._localVideoTrack.generatePreProcessingTrack(t._extensionManager);case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n(e.t0);case 10:if(t._initLocalTrackEvents(t._localVideoTrack),null!==(i=t._videoPlayer)&&void 0!==i&&i.played&&(t._videoPlayer.stop(),t._videoPlayer.playVideo(t._localVideoTrack),t._videoPlayer.mirror(!!t._mirrorType)),t.safeEmit(Nl.onLocalStreamTrackChangedByExtension,{streamIndex:cl.STREAM_INDEX_MAIN,type:"video"}),r(),null===(o=t._room)||void 0===o||null===(a=o.localStream)||void 0===a||!a.pubVideo){e.next=17;break}return e.next=17,t._updatePublish();case 17:r();case 18:case"end":return e.stop()}}),e,null,[[2,7]])})));return function(t,r){return e.apply(this,arguments)}}())}},{key:"registerExtension",value:(v=Rm(Tm().mark((function e(t){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.monitor=this.monitor,e.prev=1,e.next=4,t.isSupported();case 4:if(e.sent){e.next=7;break}throw new Error("This extension is not supported.");case 7:e.next=12;break;case 9:throw e.prev=9,e.t0=e.catch(1),new Error("This extension is not supported.");case 12:return e.next=14,t.init({videoCaptureConfig:this._videoStreamConstraints});case 14:this._extensionManager.register(t),this._addListenExtensionEvent(t);case 16:case"end":return e.stop()}}),e,this,[[1,9]])}))),function(e){return v.apply(this,arguments)})},{key:"defaultTranscoding",value:function(){return JSON.parse(Nm(AW.getDefaultValue()))}},{key:"_updatePublish",value:(p=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:{},OW.print("_updatePublish()","config: %o",t),r={mediaType:void 0,invokeByJoinRoom:!1,pubState:EH.PUB},t=Zd(Zd({},r),t),this._visibility){e.next=6;break}throw new vA(hA.NO_PUBLISH_PERMISSION,"no publish permission");case 6:return e.next=8,this._pubLock.lock();case 8:if(n=e.sent,this._room&&this._room.connectionState===tG.CONNECTED){e.next=12;break}return n(),e.abrupt("return");case 12:return e.prev=12,e.next=15,this._room.publish(this._videoStreamEncodeConfig,this._enableSimulcast,this._localVideoTrack,this._localAudioTrack,t.mediaType,t.pubState,t.invokeByJoinRoom);case 15:this._videoPlayer&&this._room.localStream&&(this._room.localStream.videoDom=this._videoPlayer.domElement),e.next=25;break;case 18:if(e.prev=18,e.t0=e.catch(12),!(e.t0 instanceof vA)){e.next=24;break}throw e.t0;case 24:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 25:return e.prev=25,n(),e.finish(25);case 28:case"end":return e.stop()}}),e,this,[[12,18,25,28]])}))),function(){return p.apply(this,arguments)})},{key:"startAudioPlaybackDeviceTest",value:(h=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("startAudioPlaybackDeviceTest()","filePath: %o, indicationInterval: %o",t,r),DM(t,"filePath"),OM(r,"indicationInterval"),e.next=5,this._audioDeviceManager.startAudioPlaybackDeviceTest(t,r);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"stopAudioPlaybackDeviceTest",value:function(){OW.print("stopAudioPlaybackDeviceTest()"),this._audioDeviceManager.stopAudioPlaybackDeviceTest()}},{key:"startAudioDeviceRecordTest",value:(l=Rm(Tm().mark((function e(t,r){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return OW.print("startAudioDeviceRecordTest()","indicationInterval: %o",t),OM(t,"indicationInterval"),e.next=4,this._audioDeviceManager.startAudioDeviceRecordTest(t,r,this._localAudioVolume);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"stopAudioDeviceRecordAndPlayTest",value:function(){OW.print("stopAudioDeviceRecordAndPlayTest()"),this._audioDeviceManager.stopAudioDeviceRecordAndPlayTest()}},{key:"stopAudioDevicePlayTest",value:function(){OW.print("stopAudioDevicePlayTest()"),this._audioDeviceManager.stopAudioDevicePlayTest()}},{key:"setRemoteUserPriority",value:function(e,t){var r;OW.print("setRemoteUserPriority()","userId: %o, priority: %o",e,t);try{jM(e),MM(t,"priority",[yl.HIGH,yl.MEDIUM,yl.LOW])}catch(n){return console.warn(n),!1}return this._ctx.userPriority.set(e,t),null===(r=this._room)||void 0===r||r.updateRemoteUserPriority(e),!0}},{key:"takeLocalSnapshot",value:(d=Rm(Tm().mark((function e(t){var r,n;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("takeLocalSnapshot()","streamIndex: %o",t),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=t===cl.STREAM_INDEX_MAIN?this.localVideoTrack:this.localScreenVideoTrack){e.next=5;break}throw new vA(hA.INVOKED_BEFORE_CAPTURE,"capture first");case 5:return n=t===cl.STREAM_INDEX_MAIN?this._videoPlayer:this._screenPlayer,e.abrupt("return",SW(r.getTrack("preprocessing"),(null==n?void 0:n.mirrorType)===hl.MIRROR_TYPE_RENDER,n));case 7:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"takeRemoteSnapshot",value:(u=Rm(Tm().mark((function e(t,r){var n,i,o,a,s,c;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(OW.print("takeRemoteSnapshot()","id: %o, streamIndex: %o",t,r),DM(t,"id"),MM(r,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),c=(null===(n=this._room)||void 0===n||null===(i=n.remoteStreams.get(t))||void 0===i||null===(o=gE(i).call(i,(function(e){return e.isScreen===(r===cl.STREAM_INDEX_SCREEN)})))||void 0===o?void 0:o.videoTrack)||(null===(a=this._publicStreamManager)||void 0===a||null===(s=a.remoteStreams.get(t))||void 0===s?void 0:s.videoTrack)){e.next=6;break}throw new vA(hA.STREAM_NOT_EXIST,"stream not exist");case 6:return e.abrupt("return",SW(c.getTrack(),!1,r===cl.STREAM_INDEX_MAIN?this._remoteVideoPlayer.get(t):this._remoteScreenPlayer.get(t)));case 7:case"end":return e.stop()}}),e,this)}))),function(e,t){return u.apply(this,arguments)})},{key:"setSubscribeFallbackOption",value:function(e){OW.print("setSubscribeFallbackOption()","option: %o",e);try{MM(e,"option",[ml.DISABLE,ml.VIDEO_STREAM_LOW,ml.AUDIO_ONLY])}catch(t){return console.warn(t),!1}return!this._room&&(this._ctx.subscribeFallbackOption=e,!0)}},{key:"getLocalStreamTrack",value:function(e,t){var r,n,i,o=this;if(e===cl.STREAM_INDEX_MAIN?(n="video"===t?this.localVideoTrack:this.localAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localStream}):(n="video"===t?this.localScreenVideoTrack:this.localScreenAudioTrack,i=function(){var e;return null===(e=o._room)||void 0===e?void 0:e.localScreenStream}),n){var a=n instanceof MV&&n.mixedAudioTrack?n.mixedAudioTrack:n.getTrack("preprocessing");if(a){var s=i();return this._reportMsTrackEvent(a,(null==s||null===(r=s.stream)||void 0===r?void 0:r.id)||"local"),a}}}},{key:"getRemoteStreamTrack",value:function(e,t,r){var n,i,o=(null===(n=this._room)||void 0===n?void 0:n.remoteStreams.get(e))||[];if(o&&o.length){var a,s,c,u,d;if(t===cl.STREAM_INDEX_MAIN)a=gE(o).call(o,(function(e){return!e.isScreen})),i="video"===r?null===(s=a)||void 0===s?void 0:s.videoTrack:null===(c=a)||void 0===c?void 0:c.audioTrack;else a=gE(o).call(o,(function(e){return e.isScreen})),i="video"===r?null===(u=a)||void 0===u?void 0:u.videoTrack:null===(d=a)||void 0===d?void 0:d.audioTrack;if(i){var l=i.getTrack();if(l&&a){var h=a.streamId;return this._reportMsTrackEvent(l,h),l}}}}},{key:"getPublicStreamTrack",value:function(e,t){if(this._publicStreamManager&&this._publicStreamManager.remoteStreams){var r=this._publicStreamManager.remoteStreams.get(e);if(r){var n="video"===t?r.videoTrack:r.audioTrack;if(n){var i=n.getTrack();if(i){var o=r.streamId;return this._reportMsTrackEvent(i,o),i}}}}}},{key:"setRemoteStreamRenderSync",value:function(e){return!this._room&&(this._ctx.avSync=!!e,!0)}},{key:"setCaptureVolume",value:function(e,t){var r,n,i;(MM(e,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),t=QM(t,"volume",0,400),e===cl.STREAM_INDEX_SCREEN)?(null===(r=this._localScreenAudioTrack)||void 0===r||r.setVolume(t),this._localScreenAudioVolume=t):(null===(n=this._localAudioTrack)||void 0===n||n.setVolume(t),null===(i=this._audioDeviceManager.audioTrack)||void 0===i||i.setVolume(t),this._localAudioVolume=t)}},{key:"setPlaybackVolume",value:function(e,t,r){var n,i,o;if(jM(e),MM(t,"streamIndex",[cl.STREAM_INDEX_MAIN,cl.STREAM_INDEX_SCREEN]),r=QM(r,"volume",0,400),null!==(n=this._room)&&void 0!==n&&n.multiChatMode)xD("setPlaybackVolume is not supported in Conference mode");else{var a=t===cl.STREAM_INDEX_SCREEN;a?this._remoteScreenAudioVolume.set(e,r):this._remoteAudioVolume.set(e,r),null===(i=this._room)||void 0===i||null===(o=i.remoteStreams.get(e))||void 0===o||o.forEach((function(e){var t;e.isScreen===a&&(null===(t=e.audioTrack)||void 0===t||t.setVolume(r))}))}}},{key:"setPublicStreamVolume",value:function(e,t){var r,n,i;DM(e,"publicStreamId"),t=QM(t,"volume",0,400),this._publicAudioVolume.set(e,t),null===(r=this._publicStreamManager)||void 0===r||null===(n=r.remoteStreams.get(e))||void 0===n||null===(i=n.audioTrack)||void 0===i||i.setVolume(t)}},{key:"startForwardStreamToRooms",value:(c=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){BM(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.startForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return c.apply(this,arguments)})},{key:"updateForwardStreamToRooms",value:(s=Rm(Tm().mark((function e(t){var r;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.forEach((function(e){BM(e.roomId)})),this._assertNotInRoom(),e.next=4,this._room.updateForwardStream2Rooms(t);case 4:return r=e.sent,e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return s.apply(this,arguments)})},{key:"stopForwardStreamToRooms",value:(a=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.stopForwardStream2Rooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"pauseForwardStreamToAllRooms",value:(o=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.pauseForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return o.apply(this,arguments)})},{key:"resumeForwardStreamToAllRooms",value:(i=Rm(Tm().mark((function e(){var t;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._assertNotInRoom(),e.next=3,this._room.resumeForwardStream2AllRooms();case 3:return t=e.sent,e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_reportMsTrackEvent",value:function(e,t){var r=this;if(!e.hookStop){e.hookStop=!0;var n=e.stop;e.stop=function(){LO(r.id,"stop",t,0,t),n.call(e)}}}},{key:"_updateScreenPublish",value:(n=Rm(Tm().mark((function e(){var t,r,n,i=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:{},OW.print("_updateScreenPublish()"),r={mediaType:void 0,pubState:EH.PUB},t=Zd(Zd({},r),t),e.next=6,this._pubLock.lock();case 6:if(n=e.sent,this._room&&this._room.connectionState===tG.CONNECTED){e.next=10;break}return n(),e.abrupt("return");case 10:return e.prev=10,e.next=13,this._room.publishScreen(this._screenStreamEncodeConfig,this._localScreenVideoTrack,this._localScreenAudioTrack,t.mediaType,t.pubState);case 13:this._screenPlayer&&this._room.localScreenStream&&(this._room.localScreenStream.videoDom=this._screenPlayer.domElement),e.next=23;break;case 16:if(e.prev=16,e.t0=e.catch(10),!(e.t0 instanceof vA)){e.next=22;break}throw e.t0;case 22:throw new vA(hA.UNEXPECTED_ERROR,"unexpected error",e.t0);case 23:return e.prev=23,n(),e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[10,16,23,26]])}))),function(){return n.apply(this,arguments)})},{key:"_updateAudioPlayerState",value:function(e){OW.print("_updateAudioPlayerState()");var t,r=e.userId,n=e.isScreen,i=n?this._remoteScreenAudioPlayer:this._remoteAudioPlayer,o=i.get(r);if(e.audioTrack&&e.attributes.audiostream&&e.subAudio){var a,s,c,u=n?null!==(a=this._remoteScreenAudioVolume.get(r))&&void 0!==a?a:100:null!==(s=this._remoteAudioVolume.get(r))&&void 0!==s?s:100;if(e.audioTrack.setVolume(u),!o){var d;o=new UG(this.id,r,{muted:(null===(d=this._config)||void 0===d?void 0:d.autoPlayPolicy)===kl.VIDEO_ONLY,isScreen:n}),this._initPlayerEvents(o,!1,n?cl.STREAM_INDEX_SCREEN:cl.STREAM_INDEX_MAIN),i.set(r,o);var l=this._audioDeviceManager.getSinkId();l&&o.setPlaybackDevice(l)}(null===(c=this._config)||void 0===c?void 0:c.autoPlayPolicy)!==kl.PLAY_MANUALLY&&o.playAudio(e.audioTrack),BD&&WD&&(t=this._remoteAudioPlayer,RW&&clearTimeout(RW),RW=setTimeout((function(){var e,r=$T(t);try{for(r.s();!(e=r.n()).done;){var n=eI(e.value,2),i=n[0],o=n[1];null!=i&&lA(i).call(i,"mux")&&o.pause()}}catch(l){r.e(l)}finally{r.f()}var a,s=$T(t);try{for(s.s();!(a=s.n()).done;){var c=eI(a.value,2),u=c[0],d=c[1];null!=u&&lA(u).call(u,"mux")&&d.manuallyPlay()}}catch(l){s.e(l)}finally{s.f()}}),2e3))}else{var h;null===(h=o)||void 0===h||h.stop()}}},{key:"_updateVideoPlayerState",value:function(e){var t;OW.print("_updateVideoPlayerState()");var r,n,i=e.userId;if(r=e.isScreen?this._remoteScreenPlayer.get(i):this._remoteVideoPlayer.get(i),e.videoTrack)r&&(null===(n=this._config)||void 0===n?void 0:n.autoPlayPolicy)!==kl.PLAY_MANUALLY&&r.playVideo(e.videoTrack,e);else if(null!==(t=r)&&void 0!==t&&t.played){var o;null===(o=r)||void 0===o||o.stop()}}},{key:"_onAddStream",value:(r=Rm(Tm().mark((function e(t){var r,n,i,o,a,s,c,u,d;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=t.stream).videoDom=null===(r=this._remoteVideoPlayer.get(n.userId))||void 0===r?void 0:r.domElement,i=null==n?void 0:n.attributes,o=i.localaudio,a=i.audiostream,s=i.localvideo,c=i.videostream,u=NV.NONE,a&&(u|=ul.AUDIO),c&&(u|=ul.VIDEO),!u){e.next=12;break}return e.next=9,new Yf((function(e){return setTimeout(e)}));case 9:null!=n&&n.isScreen?this.safeEmit(Nl.onUserPublishScreen,{userId:n.userId,mediaType:u}):(this.safeEmit(Nl.onUserPublishStream,{userId:n.userId,mediaType:u,videoStreamDescriptions:null==n||null===(d=n.attributes)||void 0===d?void 0:d.videoDescriptions}),this._handleAutoSubscribe(n,!0)),this.safeEmit("onAddStream",{userId:n.userId,mediaType:u,isScreen:!(null==n||!n.isScreen)}),null!=n&&n.isScreen||(o&&this.safeEmit(Nl.onUserStartAudioCapture,{userId:n.userId}),s&&this.safeEmit(Nl.onUserStartVideoCapture,{userId:n.userId}));case 12:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"_handleAutoSubscribe",value:function(e,t){var r,n,i=NV.NONE;if(null!==(r=this._roomConfig)&&void 0!==r&&r.isAutoSubscribeAudio&&(i|=ul.AUDIO),null!==(n=this._roomConfig)&&void 0!==n&&n.isAutoSubscribeVideo&&(i|=ul.VIDEO),i){var o,a;if(t&&kD(i))null===(o=e.observer)||void 0===o||o.setAutoSubscribeAudio(!0);if(t&&TD(i))null===(a=e.observer)||void 0===a||a.setAutoSubscribeVideo(!0);this._subscribe(!1,e.userId,i)}}},{key:"_onRemoveStream",value:function(e){var t,r=this,n=e.stream,i=null!==(t=PW[e.reason])&&void 0!==t?t:dl.STREAM_REMOVE_REASON_OTHER,o=n.isScreen?Nl.onUserUnpublishScreen:Nl.onUserUnpublishStream,a=NV.NONE;n.attributes.audiostream&&(a|=ul.AUDIO),n.attributes.videostream&&(a|=ul.VIDEO),a!==NV.NONE&&(this.safeEmit(o,{userId:n.userId,mediaType:a,reason:i}),this.safeEmit("onRemoveStream",{userId:n.userId,isScreen:n.isScreen})),"function"==typeof e.callback&&e.callback(),this._getRemotePlayer(n.userId,n.isScreen).forEach((function(e){n.isScreen?(r._remoteScreenPlayer.delete(n.userId),r._remoteScreenAudioPlayer.delete(n.userId)):(r._remoteAudioPlayer.delete(n.userId),r._remoteVideoPlayer.delete(n.userId)),null==e||e.destroy()}))}},{key:"_onUserConnection",value:function(e){var t=this;setTimeout((function(){return t.safeEmit(Nl.onUserJoined,e)}))}},{key:"_onUserLeave",value:function(e){var t=this,r=e.userInfo;this._getRemotePlayer(r.userId,!0).forEach((function(e){t._remoteScreenAudioPlayer.delete(r.userId),t._remoteScreenPlayer.delete(r.userId),null==e||e.destroy()})),this._getRemotePlayer(r.userId,!1).forEach((function(e){t._remoteAudioPlayer.delete(r.userId),t._remoteVideoPlayer.delete(r.userId),null==e||e.destroy()})),this.safeEmit(Nl.onUserLeave,e)}},{key:"_onRoomError",value:function(e){var t;this.safeEmit(Nl.onError,e),null===(t=this._room)||void 0===t||t.destroy(),this._room=void 0}},{key:"_onNetworkQuality",value:function(){for(var e,t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];this.safeEmit.apply(this,Om(e=[Nl.onNetworkQuality]).call(e,r))}},{key:"_onConnectionStateChange",value:function(e){if(void 0!==this._startCloudProxyTimestamp&&this._ctx.useCloudProxy&&e.state===ll.CONNECTION_STATE_CONNECTED&&this.safeEmit(Nl.onCloudProxyConnected,{interval:Date.now()-this._startCloudProxyTimestamp}),this.safeEmit(Nl.onConnectionStateChanged,e),e.state===ll.CONNECTION_STATE_RECONNECTING){var t,r=$T(this._remoteAudioPlayer);try{for(r.s();!(t=r.n()).done;){var n=eI(t.value,2),i=n[0],o=n[1];null!=i&&lA(i).call(i,"mux")&&o.stop()}}catch(a){r.e(a)}finally{r.f()}}}},{key:"_getRemotePlayer",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ul.AUDIO_AND_VIDEO,n=(t?this._remoteScreenAudioPlayer:this._remoteAudioPlayer).get(e),i=(t?this._remoteScreenPlayer:this._remoteVideoPlayer).get(e),o=[];return r&ul.AUDIO&&o.push(n),r&ul.VIDEO&&o.push(i),o}},{key:"_stopAudioPropertiesReport",value:function(){null!==this._audioPropertiesReportTimer&&(clearInterval(this._audioPropertiesReportTimer),this._audioPropertiesReportTimer=null)}},{key:"_onResubscribe",value:function(e){e.stream&&(this._getRemotePlayer(e.stream.userId,e.stream.isScreen).forEach((function(e){return null==e?void 0:e.stop()})),this._updateAudioPlayerState(e.stream),this._updateVideoPlayerState(e.stream))}},{key:"_onSubscribePushTrack",value:function(e){e.stream&&this._updateAudioPlayerState(e.stream)}},{key:"_onRemovePushTrack",value:function(e){var t=this;if(e.stream){this._updateAudioPlayerState(e.stream);var r=e.stream;this._getRemotePlayer(r.userId,r.isScreen,e.mediaType).forEach((function(n){e.mediaType&ul.AUDIO&&(r.isScreen?t._remoteScreenAudioPlayer.delete(r.userId):t._remoteAudioPlayer.delete(r.userId)),r.isScreen?e.mediaType&ul.VIDEO&&t._remoteScreenPlayer.delete(r.userId):e.mediaType&ul.VIDEO&&t._remoteVideoPlayer.delete(r.userId),null==n||n.destroy()}))}}},{key:"_onVideoDeviceStateChange",value:function(e){this.safeEmit(Nl.onVideoDeviceStateChanged,e)}},{key:"_onAudioDeviceStateChange",value:function(e){this.safeEmit(Nl.onAudioDeviceStateChanged,e)}},{key:"_onUserPublishStateChange",value:function(e){var t,r=this,n=e.userId,i=e.isScreen,o=e.mediaType,a=e.pubState,s=e.remoteStream,c={userId:n,mediaType:o};(o&ul.AUDIO&&setTimeout((function(){r._updateAudioPlayerState(s)})),i)?a===EH.PUB?this.safeEmit(Nl.onUserPublishScreen,c):this.safeEmit(Nl.onUserUnpublishScreen,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH})):a===EH.PUB?(c.videoStreamDescriptions=null==s||null===(t=s.attributes)||void 0===t?void 0:t.videoDescriptions,this.safeEmit(Nl.onUserPublishStream,c),this._handleAutoSubscribe(s,!0)):this.safeEmit(Nl.onUserUnpublishStream,Zd(Zd({},c),{},{reason:dl.STREAM_REMOVE_REASON_UNPUBLISH}))}},{key:"_onCustomMessage",value:function(e){var t=e.message;e.binary?this.safeEmit(Nl.onRoomBinaryMessageReceived,{userId:e.clientId,message:t}):this.safeEmit(Nl.onRoomMessageReceived,{userId:e.clientId,message:t})}},{key:"_onUserMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserMessageReceived,e)}},{key:"_onUserBinaryMessageReceived",value:function(e){this._messageStatisticsObserver.recvP2PMessage(e.userId),this.safeEmit(Nl.onUserBinaryMessageReceived,e)}},{key:"_onLiveTranscodingResult",value:function(e){this.safeEmit(Nl.onLiveTranscodingResult,e)}},{key:"_onStreamMixingEvent",value:function(e){this.safeEmit(Nl.onStreamMixingEvent,e)}},{key:"_onUserTokenWillExpire",value:function(){this.safeEmit(Nl.onTokenWillExpire)}},{key:"_onPushPublicStreamResult",value:function(e){this.safeEmit(Nl.onPushPublicStreamResult,e)}},{key:"_handleRTMClient",value:function(e){var t=this;e.on("onUserMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserMessageReceivedOutsideRoom,e)})),e.on("onUserBinaryMessageReceivedOutsideRoom",(function(e){t._messageStatisticsObserver.recvP2POutRoomMessage(e.userId),t.safeEmit(Nl.onUserBinaryMessageReceivedOutsideRoom,e)})),e.on("onUserDisconnection",(function(){t.safeEmit(Nl.onError,{errorCode:hA.RTM_DUPLICATE_LOGIN})})),e.on("onRTMTokenError",(function(){t.safeEmit(Nl.onError,{errorCode:hA.RTM_TOKEN_ERROR})})),e.on("onServerParamsSetResult",(function(e){t.safeEmit(Nl.onServerParamsSetResult,null==e?void 0:e.code)}))}},{key:"waitForNewToken",get:function(){return!!this._tempRoomInfo}},{key:"localAudioTrack",get:function(){return this._localAudioTrack}},{key:"localVideoTrack",get:function(){return this._localVideoTrack}},{key:"localScreenAudioTrack",get:function(){return this._localScreenAudioTrack}},{key:"localScreenVideoTrack",get:function(){return this._localScreenVideoTrack}},{key:"remoteStreams",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteStreams&&(null===(t=this._room)||void 0===t||t.remoteStreams.forEach((function(e){Array.isArray(e)&&e.forEach((function(e){r.push({userId:e.userId,isScreen:e.isScreen,hasVideo:e.hasVideo,hasAudio:e.hasAudio,videoStreamDescriptions:e.attributes.videoDescriptions})}))})));return r}},{key:"iceState",get:function(){var e,t,r,n;return null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||null===(r=t.handler)||void 0===r||null===(n=r._peerConnection)||void 0===n?void 0:n.iceConnectionState}},{key:"remoteUsers",get:function(){var e,t,r=[];null!==(e=this._room)&&void 0!==e&&e.remoteUsers&&(null===(t=this._room)||void 0===t||t.remoteUsers.forEach((function(e){r.push({userId:e.userId})})));return r}},{key:"multiChatMode",get:function(){var e,t;return!(null===(e=this._room)||void 0===e||null===(t=e._mediaServerClient)||void 0===t||!t.roomAttributes.multiChatMode)}},{key:"_handleAudioDeviceManager",value:function(){var e=this;this._audioDeviceManager.on("onAudioPlaybackDeviceTestVolume",(function(t){e.safeEmit(Nl.onAudioPlaybackDeviceTestVolume,t)}))}},{key:"_assertNotInRoom",value:function(){if(!this._room||this._room.connectionState!==tG.CONNECTED)throw new vA(hA.NOT_CONNECTED_YET,"server not connected")}},{key:"_checkMediaType",value:function(e){MM(e,"mediaType",[ul.AUDIO,ul.VIDEO,ul.AUDIO_AND_VIDEO])}},{key:"_getUserId",value:function(){var e,t;return(null===(e=this._room)||void 0===e||null===(t=e.roomInfo)||void 0===t?void 0:t.userInfo.userId)||"local_user"}},{key:"_switchTrack",value:(t=Rm(Tm().mark((function e(t){var r,n,i;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._initLocalTrackEvents(t),this._localVideoTrack=t,null!==(r=this._videoPlayer)&&void 0!==r&&r.played&&(this._videoPlayer.stop(),this._videoPlayer.playVideo(t),this._videoPlayer.mirror(!!this._mirrorType)),null===(n=this._room)||void 0===n||null===(i=n.localStream)||void 0===i||!i.pubVideo){e.next=6;break}return e.next=6,this._updatePublish();case 6:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})},{key:"_shouldUpdateAudioConf",value:function(e){var t,r,n,i=(null===(t=this._room)||void 0===t?void 0:t.hasPublished)||(null===(r=this._room)||void 0===r||null===(n=r.localStream)||void 0===n?void 0:n.pubAudio)||this._localAudioTrack&&this._localAudioTrack.sourceType===JU.INTERNAL;if(i){var o="engine.".concat(e," should be called before publishing or capturing.");console.warn("[RTC WebSDK]: "+o),LO(this.id,e,o)}return!i}},{key:"_getServerConfig",value:function(){var e=this,t=mM.getServerConfig(this.appId);t.rts_report&&kO.setConfig(t.rts_report),this._ctx.joinRoomConfig.setServerConfig(t.web_join_room),VO({engineId:this.id,appId:this.appId,sdkVersion:RM("VERSION"),requestDomains:RM("CONFIG_REQUEST_DOMAINS"),keys:["rts_report","web_join_room","web_rtc_config"],deviceId:RM("DEVICE_ID")}).then((function(t){mM.setServerConfig(e.appId,t),e.safeEmit("__onGetServerConfigFinishHook")}))}}]),Ee}(tP);xW([PO()],DW.prototype,"updateToken",1),xW([PO()],DW.prototype,"setVideoCaptureDevice",1),xW([PO()],DW.prototype,"setAudioCaptureDevice",1),xW([function(e,t,r){if("function"==typeof r.value){var n=r.value;r.value=function(){for(var e,t=MO(this.id),r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return null==t||t.set({room_id:i[1],user_id:null===(e=i[2])||void 0===e?void 0:e.userId}),n.apply(this,i)}}},PO()],DW.prototype,"connect",1),xW([PO()],DW.prototype,"joinRoom",1),xW([PO()],DW.prototype,"leaveRoom",1),xW([PO()],DW.prototype,"destroy",1),xW([PO()],DW.prototype,"publishStream",1),xW([PO()],DW.prototype,"unpublishStream",1),xW([PO()],DW.prototype,"publishScreen",1),xW([PO()],DW.prototype,"unpublishScreen",1),xW([PO()],DW.prototype,"subscribeStream",1),xW([PO()],DW.prototype,"unsubscribeStream",1),xW([PO()],DW.prototype,"subscribeScreen",1),xW([PO()],DW.prototype,"unsubscribeScreen",1),xW([PO()],DW.prototype,"setRemoteVideoConfig",1),xW([PO()],DW.prototype,"startVideoCapture",1),xW([PO()],DW.prototype,"stopVideoCapture",1),xW([PO()],DW.prototype,"startAudioCapture",1),xW([PO()],DW.prototype,"stopAudioCapture",1),xW([PO()],DW.prototype,"getAudioMixingManager",1),xW([PO()],DW.prototype,"startScreenCapture",1),xW([PO()],DW.prototype,"stopScreenCapture",1),xW([PO()],DW.prototype,"setLocalVideoPlayer",1),xW([PO()],DW.prototype,"startLiveTranscoding",1),xW([PO()],DW.prototype,"updateLiveTranscoding",1),xW([PO()],DW.prototype,"stopLiveTranscoding",1),xW([PO()],DW.prototype,"startSubtitle",1),xW([PO()],DW.prototype,"stopSubtitle",1),xW([PO()],DW.prototype,"setBusinessId",1),xW([PO()],DW.prototype,"setUserVisibility",1),xW([PO()],DW.prototype,"setRemoteVideoPlayer",1),xW([PO()],DW.prototype,"setLocalVideoMirrorType",1),xW([PO()],DW.prototype,"setAudioPlaybackDevice",1),xW([PO()],DW.prototype,"play",1),xW([PO()],DW.prototype,"pauseAllSubscribedStream",1),xW([PO()],DW.prototype,"resumeAllSubscribedStream",1),xW([PO()],DW.prototype,"sendUserMessage",1),xW([PO()],DW.prototype,"sendUserBinaryMessage",1),xW([PO()],DW.prototype,"sendRoomMessage",1),xW([PO()],DW.prototype,"sendRoomBinaryMessage",1),xW([PO()],DW.prototype,"setAudioCaptureConfig",1),xW([CD("4.51"),PO()],DW.prototype,"setVideoCaptureConfig",1),xW([PO()],DW.prototype,"enableSimulcastMode",1),xW([PO()],DW.prototype,"setVideoEncoderConfig",1),xW([PO()],DW.prototype,"setScreenEncoderConfig",1),xW([PO()],DW.prototype,"sendSEIMessage",1),xW([CD("4.42"),PO()],DW.prototype,"setAudioVolumeIndicationInterval",1),xW([PO()],DW.prototype,"enableAudioPropertiesReport",1),xW([PO()],DW.prototype,"setVideoSourceType",1),xW([PO()],DW.prototype,"setExternalVideoTrack",1),xW([PO()],DW.prototype,"setAudioSourceType",1),xW([PO()],DW.prototype,"setExternalAudioTrack",1),xW([PO()],DW.prototype,"login",1),xW([PO()],DW.prototype,"logout",1),xW([PO()],DW.prototype,"updateLoginToken",1),xW([PO()],DW.prototype,"getPeerOnlineStatus",1),xW([PO()],DW.prototype,"sendUserMessageOutsideRoom",1),xW([PO()],DW.prototype,"sendUserBinaryMessageOutsideRoom",1),xW([PO()],DW.prototype,"setServerParams",1),xW([PO()],DW.prototype,"sendServerMessage",1),xW([PO()],DW.prototype,"sendServerBinaryMessage",1),xW([PO()],DW.prototype,"startCloudProxy",1),xW([PO()],DW.prototype,"stopCloudProxy",1),xW([PO()],DW.prototype,"startPushPublicStream",1),xW([PO()],DW.prototype,"updatePublicStreamParam",1),xW([PO()],DW.prototype,"stopPushPublicStream",1),xW([PO("streamId")],DW.prototype,"startPlayPublicStream",1),xW([PO("streamId")],DW.prototype,"stopPlayPublicStream",1),xW([PO()],DW.prototype,"setAudioProfile",1),xW([PO()],DW.prototype,"setPublicStreamVideoPlayer",1),xW([PO()],DW.prototype,"setDummyCaptureImagePath",1),xW([PO()],DW.prototype,"registerExtension",1),xW([PO()],DW.prototype,"startAudioPlaybackDeviceTest",1),xW([PO()],DW.prototype,"stopAudioPlaybackDeviceTest",1),xW([PO()],DW.prototype,"startAudioDeviceRecordTest",1),xW([PO()],DW.prototype,"stopAudioDeviceRecordAndPlayTest",1),xW([PO()],DW.prototype,"stopAudioDevicePlayTest",1),xW([PO()],DW.prototype,"setRemoteUserPriority",1),xW([PO()],DW.prototype,"takeLocalSnapshot",1),xW([PO()],DW.prototype,"takeRemoteSnapshot",1),xW([PO()],DW.prototype,"setSubscribeFallbackOption",1),xW([PO()],DW.prototype,"getLocalStreamTrack",1),xW([PO()],DW.prototype,"getRemoteStreamTrack",1),xW([PO()],DW.prototype,"getPublicStreamTrack",1),xW([PO()],DW.prototype,"setRemoteStreamRenderSync",1),xW([PO()],DW.prototype,"startForwardStreamToRooms",1),xW([PO()],DW.prototype,"updateForwardStreamToRooms",1),xW([PO()],DW.prototype,"stopForwardStreamToRooms",1),xW([PO()],DW.prototype,"pauseForwardStreamToAllRooms",1),xW([PO()],DW.prototype,"resumeForwardStreamToAllRooms",1);var MW,PW={"client unpublished":dl.STREAM_REMOVE_REASON_UNPUBLISH,"publish failed":dl.STREAM_REMOVE_REASON_PUBLISH_FAILED,"stream removed":dl.STREAM_REMOVE_REASON_KEEP_LIVE_FAILED,"client disconnected":dl.STREAM_REMOVE_REASON_CLIENT_DISCONNECTED,"client republish":dl.STREAM_REMOVE_REASON_REPUBLISH};function NW(e){var t=mM.getServerConfig(e).web_rtc_config;return null!=t&&t.web_pc_killswitch?null==t?void 0:t.web_pc_killswitch:{}}function LW(e){var t=mM.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.fallback)?!1!==t.fallback&&(!!Array.isArray(null==t?void 0:t.fallback_ua_reg)&&t.fallback_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!RM("ENABLE_FALLBACK_HANDLER")}function UW(e){var t=mM.getServerConfig(e).web_rtc_config;return"boolean"==typeof(null==t?void 0:t.standard)?!1!==t.standard&&(!!Array.isArray(null==t?void 0:t.standard_ua_reg)&&t.standard_ua_reg.every((function(e){return"string"==typeof e&&new RegExp(e).test(navigator.userAgent)}))):!!RM("ENABLE_STANDARD_HANDLER")}var VW=new yO("VERTC",0);vO.storeKey=Om(MW="".concat(Date.now(),"-")).call(MW,mM.getDeviceId()),IO({rtc_sdk_version:TM.VERSION,device_id:mM.getDeviceId(),log_cache_key:vO.storeKey}),RO(TM.LOG_SERVER_URL);var FW=1,BW=function(e,t){VW.print("createEngine","Invoke VERTC.createEngine"),DM(e,"appId");var r=(FW++).toString();return function(e,t){var r=new Yx(e);r.set(Zd(Zd({},t),{},{engine_session_id:ow()})),r.report("sdk_init_engine",{start:Date.now(),type:"begin"}),DO.set(e,r)}(r,{rtc_app_id:e,auto_play_policy:null==t?void 0:t.autoPlayPolicy}),new DW(e,r,t)},jW=function(e){if(VW.print("destroyEngine","Invoke VERTC.destroyEngine"),!(e instanceof DW))throw new vA(hA.INVALID_ENGINE,"Invalid engine object");var t;e.destroy(),(t=e.monitor).report("sdk_init_engine",{start:Date.now(),type:"end"}),DO.delete(t.id)},HW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),GW=function(){var e=Rm(Tm().mark((function e(){var t,r,n,i,o,a,s=arguments;return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=s.length>0&&void 0!==s[0]?s[0]:{video:!0,audio:!0},r=t.video,n=t.audio,i={video:!1,audio:!1},!r){e.next=13;break}return e.prev=4,e.next=7,FU.getPermissions({video:!0,force:!0});case 7:o=e.sent,i.video=o.video,e.next=13;break;case 11:e.prev=11,e.t0=e.catch(4);case 13:if(!n){e.next=23;break}return e.prev=14,e.next=17,FU.getPermissions({audio:!0,force:!0});case 17:a=e.sent,i.audio=a.audio,e.next=23;break;case 21:e.prev=21,e.t1=e.catch(14);case 23:return e.abrupt("return",i);case 24:case"end":return e.stop()}}),e,null,[[4,11],[14,21]])})));return function(){return e.apply(this,arguments)}}(),zW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateAudioCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),KW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateVideoCaptureDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),XW=function(){var e=Rm(Tm().mark((function e(){return Tm().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",FU.enumerateAudioPlaybackDevices());case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),WW=function(){return TM.VERSION},qW=function(){return wO("isSupported",0,""),XN()},YW=function(){return wO("getSupportedCodecs",0,""),qN()},JW=function(e){var t=e.logLevel,r=e.LogfileSize;t&&(vO.logLevel=t),r&&(vO.LogfileSize=r)},QW=function(e){vO.download(e)};function ZW(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Nm(jm(t).call(t,(function(e){return e instanceof DW?"[ENGINE]":e})))}function $W(e,t){return function(){wO(t,0,ZW.apply(void 0,arguments));var r=e.apply(void 0,arguments);return"function"==typeof(null==r?void 0:r.then)?r.then((function(e){return CO(t,0,ZW(e)),e})).catch((function(e){throw CO(t,e.code,e.message),e})):(CO(t,0,ZW(r)),r)}}return Zd(Zd(Zd(Zd({},new(Ul((function e(){Vl(this,e),Jd(this,"getSdkVersion",$W(WW,"getSdkVersion")),Jd(this,"createEngine",$W(BW,"createEngine")),Jd(this,"destroyEngine",$W(jW,"destroyEngine")),Jd(this,"enumerateDevices",$W(HW,"enumerateDevices")),Jd(this,"enableDevices",$W(GW,"enableDevices")),Jd(this,"enumerateAudioCaptureDevices",$W(zW,"enumerateAudioCaptureDevices")),Jd(this,"enumerateVideoCaptureDevices",$W(KW,"enumerateVideoCaptureDevices")),Jd(this,"enumerateAudioPlaybackDevices",$W(XW,"enumerateAudioPlaybackDevices")),Jd(this,"getParameter",RM),Jd(this,"setParameter",IM),Jd(this,"isSupported",$W(qW,"isSupported")),Jd(this,"getSupportedCodecs",$W(YW,"getSupportedCodecs")),Jd(this,"events",Nl),Jd(this,"ErrorCode",hA),Jd(this,"platform","BytePlus"),Jd(this,"commitInfo","release_454<bdd00c4*>"),Jd(this,"downloadLog",$W(QW,"downloadLog")),Jd(this,"setLogConfig",$W(JW,"setLogConfig"))})))),xl),Pl),{},{events:Nl})}));