trtc-sdk-v5 5.14.2-wasm.2 → 5.14.2-wasm.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/trtc.js CHANGED
@@ -1,17 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e){return e&&e.Math===Math&&e},i=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof e&&e)||t("object"==typeof e&&e)||function(){return this}()||Function("return this")(),r={},o=function(e){try{return!!e()}catch(t){return!0}},n=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,c=Function.prototype.call,l=s?c.bind(c):function(){return c.apply(c,arguments)},d={},u={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,p=h&&!u.call({1:2},1);d.f=p?function(e){var t=h(this,e);return!!t&&t.enumerable}:u;var m,f,_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},g=a,v=Function.prototype,E=v.call,y=g&&v.bind.bind(E,E),T=g?y:function(e){return function(){return E.apply(e,arguments)}},I=T,A=I({}.toString),b=I("".slice),S=function(e){return b(A(e),8,-1)},w=o,R=S,k=Object,C=T("".split),D=w((function(){return!k("z").propertyIsEnumerable(0)}))?function(e){return"String"===R(e)?C(e,""):k(e)}:k,N=function(e){return null==e},O=N,M=TypeError,L=function(e){if(O(e))throw new M("Can't call method on "+e);return e},P=D,x=L,U=function(e){return P(x(e))},V="object"==typeof document&&document.all,F=void 0===V&&void 0!==V?function(e){return"function"==typeof e||e===V}:function(e){return"function"==typeof e},B=F,H=function(e){return"object"==typeof e?null!==e:B(e)},W=i,j=F,G=function(e,t){return arguments.length<2?(i=W[e],j(i)?i:void 0):W[e]&&W[e][t];var i},z=T({}.isPrototypeOf),q=i.navigator,K=q&&q.userAgent,Y=K?String(K):"",X=i,J=Y,Q=X.process,$=X.Deno,Z=Q&&Q.versions||$&&$.version,ee=Z&&Z.v8;ee&&(f=(m=ee.split("."))[0]>0&&m[0]<4?1:+(m[0]+m[1])),!f&&J&&(!(m=J.match(/Edge\/(\d+)/))||m[1]>=74)&&(m=J.match(/Chrome\/(\d+)/))&&(f=+m[1]);var te=f,ie=te,re=o,oe=i.String,ne=!!Object.getOwnPropertySymbols&&!re((function(){var e=Symbol("symbol detection");return!oe(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&ie&&ie<41})),ae=ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=G,ce=F,le=z,de=Object,ue=ae?function(e){return"symbol"==typeof e}:function(e){var t=se("Symbol");return ce(t)&&le(t.prototype,de(e))},he=String,pe=function(e){try{return he(e)}catch(t){return"Object"}},me=F,fe=pe,_e=TypeError,ge=function(e){if(me(e))return e;throw new _e(fe(e)+" is not a function")},ve=ge,Ee=N,ye=function(e,t){var i=e[t];return Ee(i)?void 0:ve(i)},Te=l,Ie=F,Ae=H,be=TypeError,Se={exports:{}},we=i,Re=Object.defineProperty,ke=function(e,t){try{Re(we,e,{value:t,configurable:!0,writable:!0})}catch(i){we[e]=t}return t},Ce=i,De=ke,Ne="__core-js_shared__",Oe=Se.exports=Ce[Ne]||De(Ne,{});(Oe.versions||(Oe.versions=[])).push({version:"3.40.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Me=Se.exports,Le=Me,Pe=function(e,t){return Le[e]||(Le[e]=t||{})},xe=L,Ue=Object,Ve=function(e){return Ue(xe(e))},Fe=Ve,Be=T({}.hasOwnProperty),He=Object.hasOwn||function(e,t){return Be(Fe(e),t)},We=T,je=0,Ge=Math.random(),ze=We(1..toString),qe=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ze(++je+Ge,36)},Ke=Pe,Ye=He,Xe=qe,Je=ne,Qe=ae,$e=i.Symbol,Ze=Ke("wks"),et=Qe?$e.for||$e:$e&&$e.withoutSetter||Xe,tt=function(e){return Ye(Ze,e)||(Ze[e]=Je&&Ye($e,e)?$e[e]:et("Symbol."+e)),Ze[e]},it=l,rt=H,ot=ue,nt=ye,at=function(e,t){var i,r;if("string"===t&&Ie(i=e.toString)&&!Ae(r=Te(i,e)))return r;if(Ie(i=e.valueOf)&&!Ae(r=Te(i,e)))return r;if("string"!==t&&Ie(i=e.toString)&&!Ae(r=Te(i,e)))return r;throw new be("Can't convert object to primitive value")},st=TypeError,ct=tt("toPrimitive"),lt=function(e,t){if(!rt(e)||ot(e))return e;var i,r=nt(e,ct);if(r){if(void 0===t&&(t="default"),i=it(r,e,t),!rt(i)||ot(i))return i;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),at(e,t)},dt=lt,ut=ue,ht=function(e){var t=dt(e,"string");return ut(t)?t:t+""},pt=H,mt=i.document,ft=pt(mt)&&pt(mt.createElement),_t=function(e){return ft?mt.createElement(e):{}},gt=_t,vt=!n&&!o((function(){return 7!==Object.defineProperty(gt("div"),"a",{get:function(){return 7}}).a})),Et=n,yt=l,Tt=d,It=_,At=U,bt=ht,St=He,wt=vt,Rt=Object.getOwnPropertyDescriptor;r.f=Et?Rt:function(e,t){if(e=At(e),t=bt(t),wt)try{return Rt(e,t)}catch(i){}if(St(e,t))return It(!yt(Tt.f,e,t),e[t])};var kt={},Ct=n&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Dt=H,Nt=String,Ot=TypeError,Mt=function(e){if(Dt(e))return e;throw new Ot(Nt(e)+" is not an object")},Lt=n,Pt=vt,xt=Ct,Ut=Mt,Vt=ht,Ft=TypeError,Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Wt="enumerable",jt="configurable",Gt="writable";kt.f=Lt?xt?function(e,t,i){if(Ut(e),t=Vt(t),Ut(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Gt in i&&!i[Gt]){var r=Ht(e,t);r&&r[Gt]&&(e[t]=i.value,i={configurable:jt in i?i[jt]:r[jt],enumerable:Wt in i?i[Wt]:r[Wt],writable:!1})}return Bt(e,t,i)}:Bt:function(e,t,i){if(Ut(e),t=Vt(t),Ut(i),Pt)try{return Bt(e,t,i)}catch(r){}if("get"in i||"set"in i)throw new Ft("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var zt=kt,qt=_,Kt=n?function(e,t,i){return zt.f(e,t,qt(1,i))}:function(e,t,i){return e[t]=i,e},Yt={exports:{}},Xt=n,Jt=He,Qt=Function.prototype,$t=Xt&&Object.getOwnPropertyDescriptor,Zt=Jt(Qt,"name"),ei={EXISTS:Zt,PROPER:Zt&&"something"===function(){}.name,CONFIGURABLE:Zt&&(!Xt||Xt&&$t(Qt,"name").configurable)},ti=F,ii=Me,ri=T(Function.toString);ti(ii.inspectSource)||(ii.inspectSource=function(e){return ri(e)});var oi,ni,ai,si=ii.inspectSource,ci=F,li=i.WeakMap,di=ci(li)&&/native code/.test(String(li)),ui=qe,hi=Pe("keys"),pi=function(e){return hi[e]||(hi[e]=ui(e))},mi={},fi=di,_i=i,gi=H,vi=Kt,Ei=He,yi=Me,Ti=pi,Ii=mi,Ai="Object already initialized",bi=_i.TypeError,Si=_i.WeakMap;if(fi||yi.state){var wi=yi.state||(yi.state=new Si);wi.get=wi.get,wi.has=wi.has,wi.set=wi.set,oi=function(e,t){if(wi.has(e))throw new bi(Ai);return t.facade=e,wi.set(e,t),t},ni=function(e){return wi.get(e)||{}},ai=function(e){return wi.has(e)}}else{var Ri=Ti("state");Ii[Ri]=!0,oi=function(e,t){if(Ei(e,Ri))throw new bi(Ai);return t.facade=e,vi(e,Ri,t),t},ni=function(e){return Ei(e,Ri)?e[Ri]:{}},ai=function(e){return Ei(e,Ri)}}var ki={set:oi,get:ni,has:ai,enforce:function(e){return ai(e)?ni(e):oi(e,{})},getterFor:function(e){return function(t){var i;if(!gi(t)||(i=ni(t)).type!==e)throw new bi("Incompatible receiver, "+e+" required");return i}}},Ci=T,Di=o,Ni=F,Oi=He,Mi=n,Li=ei.CONFIGURABLE,Pi=si,xi=ki.enforce,Ui=ki.get,Vi=String,Fi=Object.defineProperty,Bi=Ci("".slice),Hi=Ci("".replace),Wi=Ci([].join),ji=Mi&&!Di((function(){return 8!==Fi((function(){}),"length",{value:8}).length})),Gi=String(String).split("String"),zi=Yt.exports=function(e,t,i){"Symbol("===Bi(Vi(t),0,7)&&(t="["+Hi(Vi(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),i&&i.getter&&(t="get "+t),i&&i.setter&&(t="set "+t),(!Oi(e,"name")||Li&&e.name!==t)&&(Mi?Fi(e,"name",{value:t,configurable:!0}):e.name=t),ji&&i&&Oi(i,"arity")&&e.length!==i.arity&&Fi(e,"length",{value:i.arity});try{i&&Oi(i,"constructor")&&i.constructor?Mi&&Fi(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var r=xi(e);return Oi(r,"source")||(r.source=Wi(Gi,"string"==typeof t?t:"")),e};Function.prototype.toString=zi((function(){return Ni(this)&&Ui(this).source||Pi(this)}),"toString");var qi=Yt.exports,Ki=F,Yi=kt,Xi=qi,Ji=ke,Qi=function(e,t,i,r){r||(r={});var o=r.enumerable,n=void 0!==r.name?r.name:t;if(Ki(i)&&Xi(i,n,r),r.global)o?e[t]=i:Ji(t,i);else{try{r.unsafe?e[t]&&(o=!0):delete e[t]}catch(a){}o?e[t]=i:Yi.f(e,t,{value:i,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return e},$i={},Zi=Math.ceil,er=Math.floor,tr=Math.trunc||function(e){var t=+e;return(t>0?er:Zi)(t)},ir=tr,rr=function(e){var t=+e;return t!=t||0===t?0:ir(t)},or=rr,nr=Math.max,ar=Math.min,sr=function(e,t){var i=or(e);return i<0?nr(i+t,0):ar(i,t)},cr=rr,lr=Math.min,dr=function(e){var t=cr(e);return t>0?lr(t,9007199254740991):0},ur=dr,hr=function(e){return ur(e.length)},pr=U,mr=sr,fr=hr,_r=function(e){return function(t,i,r){var o=pr(t),n=fr(o);if(0===n)return!e&&-1;var a,s=mr(r,n);if(e&&i!=i){for(;n>s;)if((a=o[s++])!=a)return!0}else for(;n>s;s++)if((e||s in o)&&o[s]===i)return e||s||0;return!e&&-1}},gr={includes:_r(!0),indexOf:_r(!1)},vr=He,Er=U,yr=gr.indexOf,Tr=mi,Ir=T([].push),Ar=function(e,t){var i,r=Er(e),o=0,n=[];for(i in r)!vr(Tr,i)&&vr(r,i)&&Ir(n,i);for(;t.length>o;)vr(r,i=t[o++])&&(~yr(n,i)||Ir(n,i));return n},br=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Sr=Ar,wr=br.concat("length","prototype");$i.f=Object.getOwnPropertyNames||function(e){return Sr(e,wr)};var Rr={};Rr.f=Object.getOwnPropertySymbols;var kr=G,Cr=$i,Dr=Rr,Nr=Mt,Or=T([].concat),Mr=kr("Reflect","ownKeys")||function(e){var t=Cr.f(Nr(e)),i=Dr.f;return i?Or(t,i(e)):t},Lr=He,Pr=Mr,xr=r,Ur=kt,Vr=function(e,t,i){for(var r=Pr(t),o=Ur.f,n=xr.f,a=0;a<r.length;a++){var s=r[a];Lr(e,s)||i&&Lr(i,s)||o(e,s,n(t,s))}},Fr=o,Br=F,Hr=/#|\.prototype\./,Wr=function(e,t){var i=Gr[jr(e)];return i===qr||i!==zr&&(Br(t)?Fr(t):!!t)},jr=Wr.normalize=function(e){return String(e).replace(Hr,".").toLowerCase()},Gr=Wr.data={},zr=Wr.NATIVE="N",qr=Wr.POLYFILL="P",Kr=Wr,Yr=i,Xr=r.f,Jr=Kt,Qr=Qi,$r=ke,Zr=Vr,eo=Kr,to=function(e,t){var i,r,o,n,a,s=e.target,c=e.global,l=e.stat;if(i=c?Yr:l?Yr[s]||$r(s,{}):Yr[s]&&Yr[s].prototype)for(r in t){if(n=t[r],o=e.dontCallGetSet?(a=Xr(i,r))&&a.value:i[r],!eo(c?r:s+(l?".":"#")+r,e.forced)&&void 0!==o){if(typeof n==typeof o)continue;Zr(n,o)}(e.sham||o&&o.sham)&&Jr(n,"sham",!0),Qr(i,r,n,e)}},io={};io[tt("toStringTag")]="z";var ro="[object z]"===String(io),oo=F,no=S,ao=tt("toStringTag"),so=Object,co="Arguments"===no(function(){return arguments}()),lo=ro?no:function(e){var t,i,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(i){}}(t=so(e),ao))?i:co?no(t):"Object"===(r=no(t))&&oo(t.callee)?"Arguments":r},uo=lo,ho=String,po=function(e){if("Symbol"===uo(e))throw new TypeError("Cannot convert a Symbol value to a string");return ho(e)},mo=qi,fo=kt,_o=function(e,t,i){return i.get&&mo(i.get,t,{getter:!0}),i.set&&mo(i.set,t,{setter:!0}),fo.f(e,t,i)},go=to,vo=n,Eo=T,yo=He,To=F,Io=z,Ao=po,bo=_o,So=Vr,wo=i.Symbol,Ro=wo&&wo.prototype;if(vo&&To(wo)&&(!("description"in Ro)||void 0!==wo().description)){var ko={},Co=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Ao(arguments[0]),t=Io(Ro,this)?new wo(e):void 0===e?wo():wo(e);return""===e&&(ko[t]=!0),t};So(Co,wo),Co.prototype=Ro,Ro.constructor=Co;var Do="Symbol(description detection)"===String(wo("description detection")),No=Eo(Ro.valueOf),Oo=Eo(Ro.toString),Mo=/^Symbol\((.*)\)[^)]+$/,Lo=Eo("".replace),Po=Eo("".slice);bo(Ro,"description",{configurable:!0,get:function(){var e=No(this);if(yo(ko,e))return"";var t=Oo(e),i=Do?Po(t,7,-1):Lo(t,Mo,"$1");return""===i?void 0:i}}),go({global:!0,constructor:!0,forced:!0},{Symbol:Co})}var xo=i,Uo={},Vo=tt;Uo.f=Vo;var Fo=xo,Bo=He,Ho=Uo,Wo=kt.f,jo=function(e){var t=Fo.Symbol||(Fo.Symbol={});Bo(t,e)||Wo(t,e,{value:Ho.f(e)})};jo("asyncIterator");var Go=S,zo=Array.isArray||function(e){return"Array"===Go(e)},qo=TypeError,Ko=S,Yo=T,Xo=function(e){if("Function"===Ko(e))return Yo(e)},Jo=ge,Qo=a,$o=Xo(Xo.bind),Zo=function(e,t){return Jo(e),void 0===t?e:Qo?$o(e,t):function(){return e.apply(t,arguments)}},en=zo,tn=hr,rn=function(e){if(e>9007199254740991)throw qo("Maximum allowed index exceeded");return e},on=Zo,nn=function(e,t,i,r,o,n,a,s){for(var c,l,d=o,u=0,h=!!a&&on(a,s);u<r;)u in i&&(c=h?h(i[u],u,t):i[u],n>0&&en(c)?(l=tn(c),d=nn(e,t,c,l,d,n-1)-1):(rn(d+1),e[d]=c),d++),u++;return d},an=nn,sn=T,cn=o,ln=F,dn=lo,un=si,hn=function(){},pn=G("Reflect","construct"),mn=/^\s*(?:class|function)\b/,fn=sn(mn.exec),_n=!mn.test(hn),gn=function(e){if(!ln(e))return!1;try{return pn(hn,[],e),!0}catch(t){return!1}},vn=function(e){if(!ln(e))return!1;switch(dn(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _n||!!fn(mn,un(e))}catch(t){return!0}};vn.sham=!0;var En=!pn||cn((function(){var e;return gn(gn.call)||!gn(Object)||!gn((function(){e=!0}))||e}))?vn:gn,yn=zo,Tn=En,In=H,An=tt("species"),bn=Array,Sn=function(e){var t;return yn(e)&&(t=e.constructor,(Tn(t)&&(t===bn||yn(t.prototype))||In(t)&&null===(t=t[An]))&&(t=void 0)),void 0===t?bn:t},wn=function(e,t){return new(Sn(e))(0===t?0:t)},Rn=an,kn=Ve,Cn=hr,Dn=rr,Nn=wn;to({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=kn(this),i=Cn(t),r=Nn(t,0);return r.length=Rn(r,t,t,i,0,void 0===e?1:Dn(e)),r}});var On={},Mn=Ar,Ln=br,Pn=Object.keys||function(e){return Mn(e,Ln)},xn=n,Un=Ct,Vn=kt,Fn=Mt,Bn=U,Hn=Pn;On.f=xn&&!Un?Object.defineProperties:function(e,t){Fn(e);for(var i,r=Bn(t),o=Hn(t),n=o.length,a=0;n>a;)Vn.f(e,i=o[a++],r[i]);return e};var Wn,jn=G("document","documentElement"),Gn=Mt,zn=On,qn=br,Kn=mi,Yn=jn,Xn=_t,Jn="prototype",Qn="script",$n=pi("IE_PROTO"),Zn=function(){},ea=function(e){return"<"+Qn+">"+e+"</"+Qn+">"},ta=function(e){e.write(ea("")),e.close();var t=e.parentWindow.Object;return e=null,t},ia=function(){try{Wn=new ActiveXObject("htmlfile")}catch(t){}ia="undefined"!=typeof document?document.domain&&Wn?ta(Wn):function(){var e,t=Xn("iframe"),i="java"+Qn+":";return t.style.display="none",Yn.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(ea("document.F=Object")),e.close(),e.F}():ta(Wn);for(var e=qn.length;e--;)delete ia[Jn][qn[e]];return ia()};Kn[$n]=!0;var ra=Object.create||function(e,t){var i;return null!==e?(Zn[Jn]=Gn(e),i=new Zn,Zn[Jn]=null,i[$n]=e):i=ia(),void 0===t?i:zn.f(i,t)},oa=tt,na=ra,aa=kt.f,sa=oa("unscopables"),ca=Array.prototype;void 0===ca[sa]&&aa(ca,sa,{configurable:!0,value:na(null)});var la=function(e){ca[sa][e]=!0},da=gr.includes,ua=la;to({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return da(this,e,arguments.length>1?arguments[1]:void 0)}}),ua("includes");var ha,pa,ma,fa={},_a=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),ga=He,va=F,Ea=Ve,ya=_a,Ta=pi("IE_PROTO"),Ia=Object,Aa=Ia.prototype,ba=ya?Ia.getPrototypeOf:function(e){var t=Ea(e);if(ga(t,Ta))return t[Ta];var i=t.constructor;return va(i)&&t instanceof i?i.prototype:t instanceof Ia?Aa:null},Sa=o,wa=F,Ra=H,ka=ba,Ca=Qi,Da=tt("iterator"),Na=!1;[].keys&&("next"in(ma=[].keys())?(pa=ka(ka(ma)))!==Object.prototype&&(ha=pa):Na=!0);var Oa=!Ra(ha)||Sa((function(){var e={};return ha[Da].call(e)!==e}));Oa&&(ha={}),wa(ha[Da])||Ca(ha,Da,(function(){return this}));var Ma={IteratorPrototype:ha,BUGGY_SAFARI_ITERATORS:Na},La=kt.f,Pa=He,xa=tt("toStringTag"),Ua=function(e,t,i){e&&!i&&(e=e.prototype),e&&!Pa(e,xa)&&La(e,xa,{configurable:!0,value:t})},Va=Ma.IteratorPrototype,Fa=ra,Ba=_,Ha=Ua,Wa=fa,ja=function(){return this},Ga=function(e,t,i,r){var o=t+" Iterator";return e.prototype=Fa(Va,{next:Ba(+!r,i)}),Ha(e,o,!1),Wa[o]=ja,e},za=T,qa=ge,Ka=H,Ya=function(e){return Ka(e)||null===e},Xa=String,Ja=TypeError,Qa=function(e,t,i){try{return za(qa(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(r){}},$a=H,Za=L,es=function(e){if(Ya(e))return e;throw new Ja("Can't set "+Xa(e)+" as a prototype")},ts=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Qa(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(r){}return function(i,r){return Za(i),es(r),$a(i)?(t?e(i,r):i.__proto__=r,i):i}}():void 0),is=to,rs=l,os=F,ns=Ga,as=ba,ss=ts,cs=Ua,ls=Kt,ds=Qi,us=fa,hs=ei.PROPER,ps=ei.CONFIGURABLE,ms=Ma.IteratorPrototype,fs=Ma.BUGGY_SAFARI_ITERATORS,_s=tt("iterator"),gs="keys",vs="values",Es="entries",ys=function(){return this},Ts=function(e,t,i,r,o,n,a){ns(i,t,r);var s,c,l,d=function(e){if(e===o&&f)return f;if(!fs&&e&&e in p)return p[e];switch(e){case gs:case vs:case Es:return function(){return new i(this,e)}}return function(){return new i(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[_s]||p["@@iterator"]||o&&p[o],f=!fs&&m||d(o),_="Array"===t&&p.entries||m;if(_&&(s=as(_.call(new e)))!==Object.prototype&&s.next&&(as(s)!==ms&&(ss?ss(s,ms):os(s[_s])||ds(s,_s,ys)),cs(s,u,!0)),hs&&o===vs&&m&&m.name!==vs&&(ps?ls(p,"name",vs):(h=!0,f=function(){return rs(m,this)})),o)if(c={values:d(vs),keys:n?f:d(gs),entries:d(Es)},a)for(l in c)(fs||h||!(l in p))&&ds(p,l,c[l]);else is({target:t,proto:!0,forced:fs||h},c);return p[_s]!==f&&ds(p,_s,f,{name:o}),us[t]=f,c},Is=function(e,t){return{value:e,done:t}},As=U,bs=la,Ss=fa,ws=ki,Rs=kt.f,ks=Ts,Cs=Is,Ds=n,Ns="Array Iterator",Os=ws.set,Ms=ws.getterFor(Ns),Ls=ks(Array,"Array",(function(e,t){Os(this,{type:Ns,target:As(e),index:0,kind:t})}),(function(){var e=Ms(this),t=e.target,i=e.index++;if(!t||i>=t.length)return e.target=null,Cs(void 0,!0);switch(e.kind){case"keys":return Cs(i,!1);case"values":return Cs(t[i],!1)}return Cs([i,t[i]],!1)}),"values"),Ps=Ss.Arguments=Ss.Array;if(bs("keys"),bs("values"),bs("entries"),Ds&&"values"!==Ps.name)try{Rs(Ps,"name",{value:"values"})}catch(oY){}var xs=ge,Us=Ve,Vs=D,Fs=hr,Bs=TypeError,Hs="Reduce of empty array with no initial value",Ws=function(e){return function(t,i,r,o){var n=Us(t),a=Vs(n),s=Fs(n);if(xs(i),0===s&&r<2)throw new Bs(Hs);var c=e?s-1:0,l=e?-1:1;if(r<2)for(;;){if(c in a){o=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw new Bs(Hs)}for(;e?c>=0:s>c;c+=l)c in a&&(o=i(o,a[c],c,n));return o}},js={left:Ws(!1),right:Ws(!0)},Gs=o,zs=function(e,t){var i=[][e];return!!i&&Gs((function(){i.call(null,t||function(){return 1},1)}))},qs=i,Ks=Y,Ys=S,Xs=function(e){return Ks.slice(0,e.length)===e},Js=Xs("Bun/")?"BUN":Xs("Cloudflare-Workers")?"CLOUDFLARE":Xs("Deno/")?"DENO":Xs("Node.js/")?"NODE":qs.Bun&&"string"==typeof Bun.version?"BUN":qs.Deno&&"object"==typeof Deno.version?"DENO":"process"===Ys(qs.process)?"NODE":qs.window&&qs.document?"BROWSER":"REST",Qs="NODE"===Js,$s=js.left;to({target:"Array",proto:!0,forced:!Qs&&te>79&&te<83||!zs("reduce")},{reduce:function(e){var t=arguments.length;return $s(this,e,t,t>1?arguments[1]:void 0)}});var Zs=js.right;to({target:"Array",proto:!0,forced:!Qs&&te>79&&te<83||!zs("reduceRight")},{reduceRight:function(e){return Zs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ec=to,tc=zo,ic=T([].reverse),rc=[1,2];ec({target:"Array",proto:!0,forced:String(rc)===String(rc.reverse())},{reverse:function(){return tc(this)&&(this.length=this.length),ic(this)}});var oc=pe,nc=TypeError,ac=T([].slice),sc=ac,cc=Math.floor,lc=function(e,t){var i=e.length;if(i<8)for(var r,o,n=1;n<i;){for(o=n,r=e[n];o&&t(e[o-1],r)>0;)e[o]=e[--o];o!==n++&&(e[o]=r)}else for(var a=cc(i/2),s=lc(sc(e,0,a),t),c=lc(sc(e,a),t),l=s.length,d=c.length,u=0,h=0;u<l||h<d;)e[u+h]=u<l&&h<d?t(s[u],c[h])<=0?s[u++]:c[h++]:u<l?s[u++]:c[h++];return e},dc=lc,uc=Y.match(/firefox\/(\d+)/i),hc=!!uc&&+uc[1],pc=/MSIE|Trident/.test(Y),mc=Y.match(/AppleWebKit\/(\d+)\./),fc=!!mc&&+mc[1],_c=to,gc=T,vc=ge,Ec=Ve,yc=hr,Tc=function(e,t){if(!delete e[t])throw new nc("Cannot delete property "+oc(t)+" of "+oc(e))},Ic=po,Ac=o,bc=dc,Sc=zs,wc=hc,Rc=pc,kc=te,Cc=fc,Dc=[],Nc=gc(Dc.sort),Oc=gc(Dc.push),Mc=Ac((function(){Dc.sort(void 0)})),Lc=Ac((function(){Dc.sort(null)})),Pc=Sc("sort"),xc=!Ac((function(){if(kc)return kc<70;if(!(wc&&wc>3)){if(Rc)return!0;if(Cc)return Cc<603;var e,t,i,r,o="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:i=3;break;case 68:case 71:i=4;break;default:i=2}for(r=0;r<47;r++)Dc.push({k:t+r,v:i})}for(Dc.sort((function(e,t){return t.v-e.v})),r=0;r<Dc.length;r++)t=Dc[r].k.charAt(0),o.charAt(o.length-1)!==t&&(o+=t);return"DGBEFHACIJK"!==o}}));_c({target:"Array",proto:!0,forced:Mc||!Lc||!Pc||!xc},{sort:function(e){void 0!==e&&vc(e);var t=Ec(this);if(xc)return void 0===e?Nc(t):Nc(t,e);var i,r,o=[],n=yc(t);for(r=0;r<n;r++)r in t&&Oc(o,t[r]);for(bc(o,function(e){return function(t,i){return void 0===i?-1:void 0===t?1:void 0!==e?+e(t,i)||0:Ic(t)>Ic(i)?1:-1}}(e)),i=yc(o),r=0;r<i;)t[r]=o[r++];for(;r<n;)Tc(t,r++);return t}}),la("flat");var Uc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Vc=Qi,Fc=function(e,t,i){for(var r in t)Vc(e,r,t[r],i);return e},Bc=z,Hc=TypeError,Wc=function(e,t){if(Bc(t,e))return e;throw new Hc("Incorrect invocation")},jc=rr,Gc=dr,zc=RangeError,qc=function(e){if(void 0===e)return 0;var t=jc(e),i=Gc(t);if(t!==i)throw new zc("Wrong length or index");return i},Kc=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},Yc=4503599627370496,Xc=Kc,Jc=function(e){return e+Yc-Yc},Qc=Math.abs,$c=function(e,t,i,r){var o=+e,n=Qc(o),a=Xc(o);if(n<r)return a*Jc(n/r/t)*r*t;var s=(1+t/2220446049250313e-31)*n,c=s-(s-n);return c>i||c!=c?Infinity*a:a*c},Zc=Math.fround||function(e){return $c(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},el=Array,tl=Math.abs,il=Math.pow,rl=Math.floor,ol=Math.log,nl=Math.LN2,al={pack:function(e,t,i){var r,o,n,a=el(i),s=8*i-t-1,c=(1<<s)-1,l=c>>1,d=23===t?il(2,-24)-il(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=tl(e))!=e||Infinity===e?(o=e!=e?1:0,r=c):(r=rl(ol(e)/nl),e*(n=il(2,-r))<1&&(r--,n*=2),(e+=r+l>=1?d/n:d*il(2,1-l))*n>=2&&(r++,n/=2),r+l>=c?(o=0,r=c):r+l>=1?(o=(e*n-1)*il(2,t),r+=l):(o=e*il(2,l-1)*il(2,t),r=0));t>=8;)a[h++]=255&o,o/=256,t-=8;for(r=r<<t|o,s+=t;s>0;)a[h++]=255&r,r/=256,s-=8;return a[h-1]|=128*u,a},unpack:function(e,t){var i,r=e.length,o=8*r-t-1,n=(1<<o)-1,a=n>>1,s=o-7,c=r-1,l=e[c--],d=127&l;for(l>>=7;s>0;)d=256*d+e[c--],s-=8;for(i=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)i=256*i+e[c--],s-=8;if(0===d)d=1-a;else{if(d===n)return i?NaN:l?-Infinity:Infinity;i+=il(2,t),d-=a}return(l?-1:1)*i*il(2,d-t)}},sl=Ve,cl=sr,ll=hr,dl=function(e){for(var t=sl(this),i=ll(t),r=arguments.length,o=cl(r>1?arguments[1]:void 0,i),n=r>2?arguments[2]:void 0,a=void 0===n?i:cl(n,i);a>o;)t[o++]=e;return t},ul=F,hl=H,pl=ts,ml=function(e,t,i){var r,o;return pl&&ul(r=t.constructor)&&r!==i&&hl(o=r.prototype)&&o!==i.prototype&&pl(e,o),e},fl=i,_l=T,gl=n,vl=Uc,El=Kt,yl=_o,Tl=Fc,Il=o,Al=Wc,bl=rr,Sl=dr,wl=qc,Rl=Zc,kl=al,Cl=ba,Dl=ts,Nl=dl,Ol=ac,Ml=ml,Ll=Vr,Pl=Ua,xl=ki,Ul=ei.PROPER,Vl=ei.CONFIGURABLE,Fl="ArrayBuffer",Bl="DataView",Hl="prototype",Wl="Wrong index",jl=xl.getterFor(Fl),Gl=xl.getterFor(Bl),zl=xl.set,ql=fl[Fl],Kl=ql,Yl=Kl&&Kl[Hl],Xl=fl[Bl],Jl=Xl&&Xl[Hl],Ql=Object.prototype,$l=fl.Array,Zl=fl.RangeError,ed=_l(Nl),td=_l([].reverse),id=kl.pack,rd=kl.unpack,od=function(e){return[255&e]},nd=function(e){return[255&e,e>>8&255]},ad=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},sd=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},cd=function(e){return id(Rl(e),23,4)},ld=function(e){return id(e,52,8)},dd=function(e,t,i){yl(e[Hl],t,{configurable:!0,get:function(){return i(this)[t]}})},ud=function(e,t,i,r){var o=Gl(e),n=wl(i),a=!!r;if(n+t>o.byteLength)throw new Zl(Wl);var s=o.bytes,c=n+o.byteOffset,l=Ol(s,c,c+t);return a?l:td(l)},hd=function(e,t,i,r,o,n){var a=Gl(e),s=wl(i),c=r(+o),l=!!n;if(s+t>a.byteLength)throw new Zl(Wl);for(var d=a.bytes,u=s+a.byteOffset,h=0;h<t;h++)d[u+h]=c[l?h:t-h-1]};if(vl){var pd=Ul&&ql.name!==Fl;Il((function(){ql(1)}))&&Il((function(){new ql(-1)}))&&!Il((function(){return new ql,new ql(1.5),new ql(NaN),1!==ql.length||pd&&!Vl}))?pd&&Vl&&El(ql,"name",Fl):((Kl=function(e){return Al(this,Yl),Ml(new ql(wl(e)),this,Kl)})[Hl]=Yl,Yl.constructor=Kl,Ll(Kl,ql)),Dl&&Cl(Jl)!==Ql&&Dl(Jl,Ql);var md=new Xl(new Kl(2)),fd=_l(Jl.setInt8);md.setInt8(0,2147483648),md.setInt8(1,2147483649),!md.getInt8(0)&&md.getInt8(1)||Tl(Jl,{setInt8:function(e,t){fd(this,e,t<<24>>24)},setUint8:function(e,t){fd(this,e,t<<24>>24)}},{unsafe:!0})}else Yl=(Kl=function(e){Al(this,Yl);var t=wl(e);zl(this,{type:Fl,bytes:ed($l(t),0),byteLength:t}),gl||(this.byteLength=t,this.detached=!1)})[Hl],Jl=(Xl=function(e,t,i){Al(this,Jl),Al(e,Yl);var r=jl(e),o=r.byteLength,n=bl(t);if(n<0||n>o)throw new Zl("Wrong offset");if(n+(i=void 0===i?o-n:Sl(i))>o)throw new Zl("Wrong length");zl(this,{type:Bl,buffer:e,byteLength:i,byteOffset:n,bytes:r.bytes}),gl||(this.buffer=e,this.byteLength=i,this.byteOffset=n)})[Hl],gl&&(dd(Kl,"byteLength",jl),dd(Xl,"buffer",Gl),dd(Xl,"byteLength",Gl),dd(Xl,"byteOffset",Gl)),Tl(Jl,{getInt8:function(e){return ud(this,1,e)[0]<<24>>24},getUint8:function(e){return ud(this,1,e)[0]},getInt16:function(e){var t=ud(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ud(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return sd(ud(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return sd(ud(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return rd(ud(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return rd(ud(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){hd(this,1,e,od,t)},setUint8:function(e,t){hd(this,1,e,od,t)},setInt16:function(e,t){hd(this,2,e,nd,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){hd(this,2,e,nd,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){hd(this,4,e,ad,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){hd(this,4,e,ad,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){hd(this,4,e,cd,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){hd(this,8,e,ld,t,arguments.length>2&&arguments[2])}});Pl(Kl,Fl),Pl(Xl,Bl);var _d={ArrayBuffer:Kl,DataView:Xl},gd=G,vd=_o,Ed=n,yd=tt("species"),Td=function(e){var t=gd(e);Ed&&t&&!t[yd]&&vd(t,yd,{configurable:!0,get:function(){return this}})},Id=Td,Ad="ArrayBuffer",bd=_d[Ad];to({global:!0,constructor:!0,forced:i[Ad]!==bd},{ArrayBuffer:bd}),Id(Ad);var Sd=to,wd=Xo,Rd=o,kd=Mt,Cd=sr,Dd=dr,Nd=_d.ArrayBuffer,Od=_d.DataView,Md=Od.prototype,Ld=wd(Nd.prototype.slice),Pd=wd(Md.getUint8),xd=wd(Md.setUint8);Sd({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:Rd((function(){return!new Nd(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Ld&&void 0===t)return Ld(kd(this),e);for(var i=kd(this).byteLength,r=Cd(e,i),o=Cd(void 0===t?i:t,i),n=new Nd(Dd(o-r)),a=new Od(this),s=new Od(n),c=0;r<o;)xd(s,c++,Pd(a,r++));return n}});var Ud,Vd,Fd,Bd,Hd=En,Wd=pe,jd=TypeError,Gd=function(e){if(Hd(e))return e;throw new jd(Wd(e)+" is not a constructor")},zd=Mt,qd=Gd,Kd=N,Yd=tt("species"),Xd=function(e,t){var i,r=zd(e).constructor;return void 0===r||Kd(i=zd(r)[Yd])?t:qd(i)},Jd=a,Qd=Function.prototype,$d=Qd.apply,Zd=Qd.call,eu="object"==typeof Reflect&&Reflect.apply||(Jd?Zd.bind($d):function(){return Zd.apply($d,arguments)}),tu=TypeError,iu=function(e,t){if(e<t)throw new tu("Not enough arguments");return e},ru=/(?:ipad|iphone|ipod).*applewebkit/i.test(Y),ou=i,nu=eu,au=Zo,su=F,cu=He,lu=o,du=jn,uu=ac,hu=_t,pu=iu,mu=ru,fu=Qs,_u=ou.setImmediate,gu=ou.clearImmediate,vu=ou.process,Eu=ou.Dispatch,yu=ou.Function,Tu=ou.MessageChannel,Iu=ou.String,Au=0,bu={},Su="onreadystatechange";lu((function(){Ud=ou.location}));var wu=function(e){if(cu(bu,e)){var t=bu[e];delete bu[e],t()}},Ru=function(e){return function(){wu(e)}},ku=function(e){wu(e.data)},Cu=function(e){ou.postMessage(Iu(e),Ud.protocol+"//"+Ud.host)};_u&&gu||(_u=function(e){pu(arguments.length,1);var t=su(e)?e:yu(e),i=uu(arguments,1);return bu[++Au]=function(){nu(t,void 0,i)},Vd(Au),Au},gu=function(e){delete bu[e]},fu?Vd=function(e){vu.nextTick(Ru(e))}:Eu&&Eu.now?Vd=function(e){Eu.now(Ru(e))}:Tu&&!mu?(Bd=(Fd=new Tu).port2,Fd.port1.onmessage=ku,Vd=au(Bd.postMessage,Bd)):ou.addEventListener&&su(ou.postMessage)&&!ou.importScripts&&Ud&&"file:"!==Ud.protocol&&!lu(Cu)?(Vd=Cu,ou.addEventListener("message",ku,!1)):Vd=Su in hu("script")?function(e){du.appendChild(hu("script"))[Su]=function(){du.removeChild(this),wu(e)}}:function(e){setTimeout(Ru(e),0)});var Du={set:_u,clear:gu},Nu=i,Ou=n,Mu=Object.getOwnPropertyDescriptor,Lu=function(e){if(!Ou)return Nu[e];var t=Mu(Nu,e);return t&&t.value},Pu=function(){this.head=null,this.tail=null};Pu.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var xu,Uu,Vu,Fu,Bu,Hu=Pu,Wu=/ipad|iphone|ipod/i.test(Y)&&"undefined"!=typeof Pebble,ju=/web0s(?!.*chrome)/i.test(Y),Gu=i,zu=Lu,qu=Zo,Ku=Du.set,Yu=Hu,Xu=ru,Ju=Wu,Qu=ju,$u=Qs,Zu=Gu.MutationObserver||Gu.WebKitMutationObserver,eh=Gu.document,th=Gu.process,ih=Gu.Promise,rh=zu("queueMicrotask");if(!rh){var oh=new Yu,nh=function(){var e,t;for($u&&(e=th.domain)&&e.exit();t=oh.get();)try{t()}catch(oY){throw oh.head&&xu(),oY}e&&e.enter()};Xu||$u||Qu||!Zu||!eh?!Ju&&ih&&ih.resolve?((Fu=ih.resolve(void 0)).constructor=ih,Bu=qu(Fu.then,Fu),xu=function(){Bu(nh)}):$u?xu=function(){th.nextTick(nh)}:(Ku=qu(Ku,Gu),xu=function(){Ku(nh)}):(Uu=!0,Vu=eh.createTextNode(""),new Zu(nh).observe(Vu,{characterData:!0}),xu=function(){Vu.data=Uu=!Uu}),rh=function(e){oh.head||xu(),oh.add(e)}}var ah=rh,sh=function(e){try{return{error:!1,value:e()}}catch(oY){return{error:!0,value:oY}}},ch=i.Promise,lh=i,dh=ch,uh=F,hh=Kr,ph=si,mh=tt,fh=Js,_h=te;dh&&dh.prototype;var gh=mh("species"),vh=!1,Eh=uh(lh.PromiseRejectionEvent),yh=hh("Promise",(function(){var e=ph(dh),t=e!==String(dh);if(!t&&66===_h)return!0;if(!_h||_h<51||!/native code/.test(e)){var i=new dh((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[gh]=r,!(vh=i.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==fh&&"DENO"!==fh||Eh)})),Th={CONSTRUCTOR:yh,REJECTION_EVENT:Eh,SUBCLASSING:vh},Ih={},Ah=ge,bh=TypeError,Sh=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw new bh("Bad Promise constructor");t=e,i=r})),this.resolve=Ah(t),this.reject=Ah(i)};Ih.f=function(e){return new Sh(e)};var wh,Rh,kh,Ch=to,Dh=Qs,Nh=i,Oh=l,Mh=Qi,Lh=ts,Ph=Ua,xh=Td,Uh=ge,Vh=F,Fh=H,Bh=Wc,Hh=Xd,Wh=Du.set,jh=ah,Gh=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(oY){}},zh=sh,qh=Hu,Kh=ki,Yh=ch,Xh=Ih,Jh="Promise",Qh=Th.CONSTRUCTOR,$h=Th.REJECTION_EVENT,Zh=Th.SUBCLASSING,ep=Kh.getterFor(Jh),tp=Kh.set,ip=Yh&&Yh.prototype,rp=Yh,op=ip,np=Nh.TypeError,ap=Nh.document,sp=Nh.process,cp=Xh.f,lp=cp,dp=!!(ap&&ap.createEvent&&Nh.dispatchEvent),up="unhandledrejection",hp=function(e){var t;return!(!Fh(e)||!Vh(t=e.then))&&t},pp=function(e,t){var i,r,o,n=t.value,a=1===t.state,s=a?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&vp(t),t.rejection=1),!0===s?i=n:(d&&d.enter(),i=s(n),d&&(d.exit(),o=!0)),i===e.promise?l(new np("Promise-chain cycle")):(r=hp(i))?Oh(r,i,c,l):c(i)):l(n)}catch(oY){d&&!o&&d.exit(),l(oY)}},mp=function(e,t){e.notified||(e.notified=!0,jh((function(){for(var i,r=e.reactions;i=r.get();)pp(i,e);e.notified=!1,t&&!e.rejection&&_p(e)})))},fp=function(e,t,i){var r,o;dp?((r=ap.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),Nh.dispatchEvent(r)):r={promise:t,reason:i},!$h&&(o=Nh["on"+e])?o(r):e===up&&Gh("Unhandled promise rejection",i)},_p=function(e){Oh(Wh,Nh,(function(){var t,i=e.facade,r=e.value;if(gp(e)&&(t=zh((function(){Dh?sp.emit("unhandledRejection",r,i):fp(up,i,r)})),e.rejection=Dh||gp(e)?2:1,t.error))throw t.value}))},gp=function(e){return 1!==e.rejection&&!e.parent},vp=function(e){Oh(Wh,Nh,(function(){var t=e.facade;Dh?sp.emit("rejectionHandled",t):fp("rejectionhandled",t,e.value)}))},Ep=function(e,t,i){return function(r){e(t,r,i)}},yp=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,mp(e,!0))},Tp=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw new np("Promise can't be resolved itself");var r=hp(t);r?jh((function(){var i={done:!1};try{Oh(r,t,Ep(Tp,i,e),Ep(yp,i,e))}catch(oY){yp(i,oY,e)}})):(e.value=t,e.state=1,mp(e,!1))}catch(oY){yp({done:!1},oY,e)}}};if(Qh&&(op=(rp=function(e){Bh(this,op),Uh(e),Oh(wh,this);var t=ep(this);try{e(Ep(Tp,t),Ep(yp,t))}catch(oY){yp(t,oY)}}).prototype,(wh=function(e){tp(this,{type:Jh,done:!1,notified:!1,parent:!1,reactions:new qh,rejection:!1,state:0,value:null})}).prototype=Mh(op,"then",(function(e,t){var i=ep(this),r=cp(Hh(this,rp));return i.parent=!0,r.ok=!Vh(e)||e,r.fail=Vh(t)&&t,r.domain=Dh?sp.domain:void 0,0===i.state?i.reactions.add(r):jh((function(){pp(r,i)})),r.promise})),Rh=function(){var e=new wh,t=ep(e);this.promise=e,this.resolve=Ep(Tp,t),this.reject=Ep(yp,t)},Xh.f=cp=function(e){return e===rp||undefined===e?new Rh(e):lp(e)},Vh(Yh)&&ip!==Object.prototype)){kh=ip.then,Zh||Mh(ip,"then",(function(e,t){var i=this;return new rp((function(e,t){Oh(kh,i,e,t)})).then(e,t)}),{unsafe:!0});try{delete ip.constructor}catch(oY){}Lh&&Lh(ip,op)}Ch({global:!0,constructor:!0,wrap:!0,forced:Qh},{Promise:rp}),Ph(rp,Jh,!1),xh(Jh);var Ip=fa,Ap=tt("iterator"),bp=Array.prototype,Sp=function(e){return void 0!==e&&(Ip.Array===e||bp[Ap]===e)},wp=lo,Rp=ye,kp=N,Cp=fa,Dp=tt("iterator"),Np=function(e){if(!kp(e))return Rp(e,Dp)||Rp(e,"@@iterator")||Cp[wp(e)]},Op=l,Mp=ge,Lp=Mt,Pp=pe,xp=Np,Up=TypeError,Vp=function(e,t){var i=arguments.length<2?xp(e):t;if(Mp(i))return Lp(Op(i,e));throw new Up(Pp(e)+" is not iterable")},Fp=l,Bp=Mt,Hp=ye,Wp=function(e,t,i){var r,o;Bp(e);try{if(!(r=Hp(e,"return"))){if("throw"===t)throw i;return i}r=Fp(r,e)}catch(oY){o=!0,r=oY}if("throw"===t)throw i;if(o)throw r;return Bp(r),i},jp=Zo,Gp=l,zp=Mt,qp=pe,Kp=Sp,Yp=hr,Xp=z,Jp=Vp,Qp=Np,$p=Wp,Zp=TypeError,em=function(e,t){this.stopped=e,this.result=t},tm=em.prototype,im=function(e,t,i){var r,o,n,a,s,c,l,d=i&&i.that,u=!(!i||!i.AS_ENTRIES),h=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),m=!(!i||!i.INTERRUPTED),f=jp(t,d),_=function(e){return r&&$p(r,"normal",e),new em(!0,e)},g=function(e){return u?(zp(e),m?f(e[0],e[1],_):f(e[0],e[1])):m?f(e,_):f(e)};if(h)r=e.iterator;else if(p)r=e;else{if(!(o=Qp(e)))throw new Zp(qp(e)+" is not iterable");if(Kp(o)){for(n=0,a=Yp(e);a>n;n++)if((s=g(e[n]))&&Xp(tm,s))return s;return new em(!1)}r=Jp(e,o)}for(c=h?e.next:r.next;!(l=Gp(c,r)).done;){try{s=g(l.value)}catch(oY){$p(r,"throw",oY)}if("object"==typeof s&&s&&Xp(tm,s))return s}return new em(!1)},rm=tt("iterator"),om=!1;try{var nm=0,am={next:function(){return{done:!!nm++}},return:function(){om=!0}};am[rm]=function(){return this},Array.from(am,(function(){throw 2}))}catch(oY){}var sm=function(e,t){try{if(!t&&!om)return!1}catch(oY){return!1}var i=!1;try{var r={};r[rm]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(oY){}return i},cm=ch,lm=Th.CONSTRUCTOR||!sm((function(e){cm.all(e).then(void 0,(function(){}))})),dm=l,um=ge,hm=Ih,pm=sh,mm=im;to({target:"Promise",stat:!0,forced:lm},{all:function(e){var t=this,i=hm.f(t),r=i.resolve,o=i.reject,n=pm((function(){var i=um(t.resolve),n=[],a=0,s=1;mm(e,(function(e){var c=a++,l=!1;s++,dm(i,t,e).then((function(e){l||(l=!0,n[c]=e,--s||r(n))}),o)})),--s||r(n)}));return n.error&&o(n.value),i.promise}});var fm=to,_m=Th.CONSTRUCTOR,gm=ch,vm=G,Em=F,ym=Qi,Tm=gm&&gm.prototype;if(fm({target:"Promise",proto:!0,forced:_m,real:!0},{catch:function(e){return this.then(void 0,e)}}),Em(gm)){var Im=vm("Promise").prototype.catch;Tm.catch!==Im&&ym(Tm,"catch",Im,{unsafe:!0})}var Am=l,bm=ge,Sm=Ih,wm=sh,Rm=im;to({target:"Promise",stat:!0,forced:lm},{race:function(e){var t=this,i=Sm.f(t),r=i.reject,o=wm((function(){var o=bm(t.resolve);Rm(e,(function(e){Am(o,t,e).then(i.resolve,r)}))}));return o.error&&r(o.value),i.promise}});var km=Ih;to({target:"Promise",stat:!0,forced:Th.CONSTRUCTOR},{reject:function(e){var t=km.f(this);return(0,t.reject)(e),t.promise}});var Cm=Mt,Dm=H,Nm=Ih,Om=function(e,t){if(Cm(e),Dm(t)&&t.constructor===e)return t;var i=Nm.f(e);return(0,i.resolve)(t),i.promise},Mm=to,Lm=Th.CONSTRUCTOR,Pm=Om;G("Promise"),Mm({target:"Promise",stat:!0,forced:Lm},{resolve:function(e){return Pm(this,e)}});var xm=to,Um=ch,Vm=o,Fm=G,Bm=F,Hm=Xd,Wm=Om,jm=Qi,Gm=Um&&Um.prototype;if(xm({target:"Promise",proto:!0,real:!0,forced:!!Um&&Vm((function(){Gm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hm(this,Fm("Promise")),i=Bm(e);return this.then(i?function(i){return Wm(t,e()).then((function(){return i}))}:e,i?function(i){return Wm(t,e()).then((function(){throw i}))}:e)}}),Bm(Um)){var zm=Fm("Promise").prototype.finally;Gm.finally!==zm&&jm(Gm,"finally",zm,{unsafe:!0})}var qm=H,Km=S,Ym=tt("match"),Xm=function(e){var t;return qm(e)&&(void 0!==(t=e[Ym])?!!t:"RegExp"===Km(e))},Jm=Mt,Qm=function(){var e=Jm(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},$m=l,Zm=He,ef=z,tf=Qm,rf=RegExp.prototype,of=function(e){var t=e.flags;return void 0!==t||"flags"in rf||Zm(e,"flags")||!ef(rf,e)?t:$m(tf,e)},nf=o,af=i.RegExp,sf=nf((function(){var e=af("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),cf=sf||nf((function(){return!af("a","y").sticky})),lf=sf||nf((function(){var e=af("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),df={BROKEN_CARET:lf,MISSED_STICKY:cf,UNSUPPORTED_Y:sf},uf=kt.f,hf=o,pf=i.RegExp,mf=hf((function(){var e=pf(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),ff=o,_f=i.RegExp,gf=ff((function(){var e=_f("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),vf=n,Ef=i,yf=T,Tf=Kr,If=ml,Af=Kt,bf=ra,Sf=$i.f,wf=z,Rf=Xm,kf=po,Cf=of,Df=df,Nf=function(e,t,i){i in e||uf(e,i,{configurable:!0,get:function(){return t[i]},set:function(e){t[i]=e}})},Of=Qi,Mf=o,Lf=He,Pf=ki.enforce,xf=Td,Uf=mf,Vf=gf,Ff=tt("match"),Bf=Ef.RegExp,Hf=Bf.prototype,Wf=Ef.SyntaxError,jf=yf(Hf.exec),Gf=yf("".charAt),zf=yf("".replace),qf=yf("".indexOf),Kf=yf("".slice),Yf=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Xf=/a/g,Jf=/a/g,Qf=new Bf(Xf)!==Xf,$f=Df.MISSED_STICKY,Zf=Df.UNSUPPORTED_Y,e_=vf&&(!Qf||$f||Uf||Vf||Mf((function(){return Jf[Ff]=!1,Bf(Xf)!==Xf||Bf(Jf)===Jf||"/a/i"!==String(Bf(Xf,"i"))})));if(Tf("RegExp",e_)){for(var t_=function(e,t){var i,r,o,n,a,s,c=wf(Hf,this),l=Rf(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===t_)return e;if((l||wf(Hf,e))&&(e=e.source,d&&(t=Cf(h))),e=void 0===e?"":kf(e),t=void 0===t?"":kf(t),h=e,Uf&&"dotAll"in Xf&&(r=!!t&&qf(t,"s")>-1)&&(t=zf(t,/s/g,"")),i=t,$f&&"sticky"in Xf&&(o=!!t&&qf(t,"y")>-1)&&Zf&&(t=zf(t,/y/g,"")),Vf&&(n=function(e){for(var t,i=e.length,r=0,o="",n=[],a=bf(null),s=!1,c=!1,l=0,d="";r<=i;r++){if("\\"===(t=Gf(e,r)))t+=Gf(e,++r);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(o+=t,"?:"===Kf(e,r+1,r+3))continue;jf(Yf,Kf(e,r+1))&&(r+=2,c=!0),l++;continue;case">"===t&&c:if(""===d||Lf(a,d))throw new Wf("Invalid capture group name");a[d]=!0,n[n.length]=[d,l],c=!1,d="";continue}c?d+=t:o+=t}return[o,n]}(e),e=n[0],u=n[1]),a=If(Bf(e,t),c?this:Hf,t_),(r||o||u.length)&&(s=Pf(a),r&&(s.dotAll=!0,s.raw=t_(function(e){for(var t,i=e.length,r=0,o="",n=!1;r<=i;r++)"\\"!==(t=Gf(e,r))?n||"."!==t?("["===t?n=!0:"]"===t&&(n=!1),o+=t):o+="[\\s\\S]":o+=t+Gf(e,++r);return o}(e),i)),o&&(s.sticky=!0),u.length&&(s.groups=u)),e!==h)try{Af(a,"source",""===h?"(?:)":h)}catch(oY){}return a},i_=Sf(Bf),r_=0;i_.length>r_;)Nf(t_,Bf,i_[r_++]);Hf.constructor=t_,t_.prototype=Hf,Of(Ef,"RegExp",t_,{constructor:!0})}xf("RegExp");var o_=l,n_=T,a_=po,s_=Qm,c_=df,l_=ra,d_=ki.get,u_=mf,h_=gf,p_=Pe("native-string-replace",String.prototype.replace),m_=RegExp.prototype.exec,f_=m_,__=n_("".charAt),g_=n_("".indexOf),v_=n_("".replace),E_=n_("".slice),y_=function(){var e=/a/,t=/b*/g;return o_(m_,e,"a"),o_(m_,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),T_=c_.BROKEN_CARET,I_=void 0!==/()??/.exec("")[1];(y_||I_||T_||u_||h_)&&(f_=function(e){var t,i,r,o,n,a,s,c=this,l=d_(c),d=a_(e),u=l.raw;if(u)return u.lastIndex=c.lastIndex,t=o_(f_,u,d),c.lastIndex=u.lastIndex,t;var h=l.groups,p=T_&&c.sticky,m=o_(s_,c),f=c.source,_=0,g=d;if(p&&(m=v_(m,"y",""),-1===g_(m,"g")&&(m+="g"),g=E_(d,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==__(d,c.lastIndex-1))&&(f="(?: "+f+")",g=" "+g,_++),i=new RegExp("^(?:"+f+")",m)),I_&&(i=new RegExp("^"+f+"$(?!\\s)",m)),y_&&(r=c.lastIndex),o=o_(m_,p?i:c,g),p?o?(o.input=E_(o.input,_),o[0]=E_(o[0],_),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:y_&&o&&(c.lastIndex=c.global?o.index+o[0].length:r),I_&&o&&o.length>1&&o_(p_,o[0],i,(function(){for(n=1;n<arguments.length-2;n++)void 0===arguments[n]&&(o[n]=void 0)})),o&&h)for(o.groups=a=l_(null),n=0;n<h.length;n++)a[(s=h[n])[0]]=o[s[1]];return o});var A_=f_;to({target:"RegExp",proto:!0,forced:/./.exec!==A_},{exec:A_});var b_=n,S_=_o,w_=Qm,R_=o,k_=i.RegExp,C_=k_.prototype,D_=b_&&R_((function(){var e=!0;try{k_(".","d")}catch(oY){e=!1}var t={},i="",r=e?"dgimsy":"gimsy",o=function(e,r){Object.defineProperty(t,e,{get:function(){return i+=r,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(n.hasIndices="d"),n)o(a,n[a]);return Object.getOwnPropertyDescriptor(C_,"flags").get.call(t)!==r||i!==r}));D_&&S_(C_,"flags",{configurable:!0,get:w_});var N_=rr,O_=po,M_=L,L_=RangeError,P_=T,x_=dr,U_=po,V_=function(e){var t=O_(M_(this)),i="",r=N_(e);if(r<0||Infinity===r)throw new L_("Wrong number of repetitions");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(i+=t);return i},F_=L,B_=P_(V_),H_=P_("".slice),W_=Math.ceil,j_=function(e){return function(t,i,r){var o,n,a=U_(F_(t)),s=x_(i),c=a.length,l=void 0===r?" ":U_(r);return s<=c||""===l?a:((n=B_(l,W_((o=s-c)/l.length))).length>o&&(n=H_(n,0,o)),e?a+n:n+a)}},G_={start:j_(!1),end:j_(!0)},z_=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Y),q_=G_.start;to({target:"String",proto:!0,forced:z_},{padStart:function(e){return q_(this,e,arguments.length>1?arguments[1]:void 0)}});var K_=l,Y_=Qi,X_=A_,J_=o,Q_=tt,$_=Kt,Z_=Q_("species"),eg=RegExp.prototype,tg=T,ig=rr,rg=po,og=L,ng=tg("".charAt),ag=tg("".charCodeAt),sg=tg("".slice),cg=function(e){return function(t,i){var r,o,n=rg(og(t)),a=ig(i),s=n.length;return a<0||a>=s?e?"":void 0:(r=ag(n,a))<55296||r>56319||a+1===s||(o=ag(n,a+1))<56320||o>57343?e?ng(n,a):r:e?sg(n,a,a+2):o-56320+(r-55296<<10)+65536}},lg={codeAt:cg(!1),charAt:cg(!0)},dg=lg.charAt,ug=T,hg=Ve,pg=Math.floor,mg=ug("".charAt),fg=ug("".replace),_g=ug("".slice),gg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,vg=/\$([$&'`]|\d{1,2})/g,Eg=function(e,t,i,r,o,n){var a=i+e.length,s=r.length,c=vg;return void 0!==o&&(o=hg(o),c=gg),fg(n,c,(function(n,c){var l;switch(mg(c,0)){case"$":return"$";case"&":return e;case"`":return _g(t,0,i);case"'":return _g(t,a);case"<":l=o[_g(c,1,-1)];break;default:var d=+c;if(0===d)return n;if(d>s){var u=pg(d/10);return 0===u?n:u<=s?void 0===r[u-1]?mg(c,1):r[u-1]+mg(c,1):n}l=r[d-1]}return void 0===l?"":l}))},yg=l,Tg=Mt,Ig=F,Ag=S,bg=A_,Sg=TypeError,wg=eu,Rg=l,kg=T,Cg=function(e,t,i,r){var o=Q_(e),n=!J_((function(){var t={};return t[o]=function(){return 7},7!==""[e](t)})),a=n&&!J_((function(){var t=!1,i=/a/;return"split"===e&&((i={}).constructor={},i.constructor[Z_]=function(){return i},i.flags="",i[o]=/./[o]),i.exec=function(){return t=!0,null},i[o](""),!t}));if(!n||!a||i){var s=/./[o],c=t(o,""[e],(function(e,t,i,r,o){var a=t.exec;return a===X_||a===eg.exec?n&&!o?{done:!0,value:K_(s,t,i,r)}:{done:!0,value:K_(e,i,t,r)}:{done:!1}}));Y_(String.prototype,e,c[0]),Y_(eg,o,c[1])}r&&$_(eg[o],"sham",!0)},Dg=o,Ng=Mt,Og=F,Mg=N,Lg=rr,Pg=dr,xg=po,Ug=L,Vg=function(e,t,i){return t+(i?dg(e,t).length:1)},Fg=ye,Bg=Eg,Hg=function(e,t){var i=e.exec;if(Ig(i)){var r=yg(i,e,t);return null!==r&&Tg(r),r}if("RegExp"===Ag(e))return yg(bg,e,t);throw new Sg("RegExp#exec called on incompatible receiver")},Wg=tt("replace"),jg=Math.max,Gg=Math.min,zg=kg([].concat),qg=kg([].push),Kg=kg("".indexOf),Yg=kg("".slice),Xg="$0"==="a".replace(/./,"$0"),Jg=!!/./[Wg]&&""===/./[Wg]("a","$0"),Qg=!Dg((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));Cg("replace",(function(e,t,i){var r=Jg?"$":"$0";return[function(e,i){var r=Ug(this),o=Mg(e)?void 0:Fg(e,Wg);return o?Rg(o,e,r,i):Rg(t,xg(r),e,i)},function(e,o){var n=Ng(this),a=xg(e);if("string"==typeof o&&-1===Kg(o,r)&&-1===Kg(o,"$<")){var s=i(t,n,a,o);if(s.done)return s.value}var c=Og(o);c||(o=xg(o));var l,d=n.global;d&&(l=n.unicode,n.lastIndex=0);for(var u,h=[];null!==(u=Hg(n,a))&&(qg(h,u),d);){""===xg(u[0])&&(n.lastIndex=Vg(a,Pg(n.lastIndex),l))}for(var p,m="",f=0,_=0;_<h.length;_++){for(var g,v=xg((u=h[_])[0]),E=jg(Gg(Lg(u.index),a.length),0),y=[],T=1;T<u.length;T++)qg(y,void 0===(p=u[T])?p:String(p));var I=u.groups;if(c){var A=zg([v],y,E,a);void 0!==I&&qg(A,I),g=xg(wg(o,void 0,A))}else g=Bg(v,a,E,y,I,o);E>=f&&(m+=Yg(a,f,E)+g,f=E+v.length)}return m+Yg(a,f)}]}),!Qg||!Xg||Jg);var $g="\t\n\v\f\r                 \u2028\u2029\ufeff",Zg=L,ev=po,tv=$g,iv=T("".replace),rv=RegExp("^["+tv+"]+"),ov=RegExp("(^|[^"+tv+"])["+tv+"]+$"),nv=function(e){return function(t){var i=ev(Zg(t));return 1&e&&(i=iv(i,rv,"")),2&e&&(i=iv(i,ov,"$1")),i}},av={start:nv(1),end:nv(2),trim:nv(3)},sv=ei.PROPER,cv=o,lv=$g,dv=av.trim;to({target:"String",proto:!0,forced:function(e){return cv((function(){return!!lv[e]()||"​…᠎"!=="​…᠎"[e]()||sv&&lv[e].name!==e}))}("trim")},{trim:function(){return dv(this)}});var uv,hv,pv,mv={exports:{}},fv=Uc,_v=n,gv=i,vv=F,Ev=H,yv=He,Tv=lo,Iv=pe,Av=Kt,bv=Qi,Sv=_o,wv=z,Rv=ba,kv=ts,Cv=tt,Dv=qe,Nv=ki.enforce,Ov=ki.get,Mv=gv.Int8Array,Lv=Mv&&Mv.prototype,Pv=gv.Uint8ClampedArray,xv=Pv&&Pv.prototype,Uv=Mv&&Rv(Mv),Vv=Lv&&Rv(Lv),Fv=Object.prototype,Bv=gv.TypeError,Hv=Cv("toStringTag"),Wv=Dv("TYPED_ARRAY_TAG"),jv="TypedArrayConstructor",Gv=fv&&!!kv&&"Opera"!==Tv(gv.opera),zv=!1,qv={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Kv={BigInt64Array:8,BigUint64Array:8},Yv=function(e){var t=Rv(e);if(Ev(t)){var i=Ov(t);return i&&yv(i,jv)?i[jv]:Yv(t)}},Xv=function(e){if(!Ev(e))return!1;var t=Tv(e);return yv(qv,t)||yv(Kv,t)};for(uv in qv)(pv=(hv=gv[uv])&&hv.prototype)?Nv(pv)[jv]=hv:Gv=!1;for(uv in Kv)(pv=(hv=gv[uv])&&hv.prototype)&&(Nv(pv)[jv]=hv);if((!Gv||!vv(Uv)||Uv===Function.prototype)&&(Uv=function(){throw new Bv("Incorrect invocation")},Gv))for(uv in qv)gv[uv]&&kv(gv[uv],Uv);if((!Gv||!Vv||Vv===Fv)&&(Vv=Uv.prototype,Gv))for(uv in qv)gv[uv]&&kv(gv[uv].prototype,Vv);if(Gv&&Rv(xv)!==Vv&&kv(xv,Vv),_v&&!yv(Vv,Hv))for(uv in zv=!0,Sv(Vv,Hv,{configurable:!0,get:function(){return Ev(this)?this[Wv]:void 0}}),qv)gv[uv]&&Av(gv[uv],Wv,uv);var Jv={NATIVE_ARRAY_BUFFER_VIEWS:Gv,TYPED_ARRAY_TAG:zv&&Wv,aTypedArray:function(e){if(Xv(e))return e;throw new Bv("Target is not a typed array")},aTypedArrayConstructor:function(e){if(vv(e)&&(!kv||wv(Uv,e)))return e;throw new Bv(Iv(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,i,r){if(_v){if(i)for(var o in qv){var n=gv[o];if(n&&yv(n.prototype,e))try{delete n.prototype[e]}catch(oY){try{n.prototype[e]=t}catch(a){}}}Vv[e]&&!i||bv(Vv,e,i?t:Gv&&Lv[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,i){var r,o;if(_v){if(kv){if(i)for(r in qv)if((o=gv[r])&&yv(o,e))try{delete o[e]}catch(oY){}if(Uv[e]&&!i)return;try{return bv(Uv,e,i?t:Gv&&Uv[e]||t)}catch(oY){}}for(r in qv)!(o=gv[r])||o[e]&&!i||bv(o,e,t)}},getTypedArrayConstructor:Yv,isView:function(e){if(!Ev(e))return!1;var t=Tv(e);return"DataView"===t||yv(qv,t)||yv(Kv,t)},isTypedArray:Xv,TypedArray:Uv,TypedArrayPrototype:Vv},Qv=i,$v=o,Zv=sm,eE=Jv.NATIVE_ARRAY_BUFFER_VIEWS,tE=Qv.ArrayBuffer,iE=Qv.Int8Array,rE=!eE||!$v((function(){iE(1)}))||!$v((function(){new iE(-1)}))||!Zv((function(e){new iE,new iE(null),new iE(1.5),new iE(e)}),!0)||$v((function(){return 1!==new iE(new tE(2),1,void 0).length})),oE=H,nE=Math.floor,aE=Number.isInteger||function(e){return!oE(e)&&isFinite(e)&&nE(e)===e},sE=rr,cE=RangeError,lE=function(e){var t=sE(e);if(t<0)throw new cE("The argument can't be less than 0");return t},dE=RangeError,uE=function(e,t){var i=lE(e);if(i%t)throw new dE("Wrong offset");return i},hE=Math.round,pE=lo,mE=lt,fE=TypeError,_E=function(e){var t=mE(e,"number");if("number"==typeof t)throw new fE("Can't convert number to bigint");return BigInt(t)},gE=Zo,vE=l,EE=Gd,yE=Ve,TE=hr,IE=Vp,AE=Np,bE=Sp,SE=function(e){var t=pE(e);return"BigInt64Array"===t||"BigUint64Array"===t},wE=Jv.aTypedArrayConstructor,RE=_E,kE=function(e){var t,i,r,o,n,a,s,c,l=EE(this),d=yE(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=AE(d);if(m&&!bE(m))for(c=(s=IE(d,m)).next,d=[];!(a=vE(c,s)).done;)d.push(a.value);for(p&&u>2&&(h=gE(h,arguments[2])),i=TE(d),r=new(wE(l))(i),o=SE(r),t=0;i>t;t++)n=p?h(d[t],t):d[t],r[t]=o?RE(n):+n;return r},CE=Zo,DE=D,NE=Ve,OE=hr,ME=wn,LE=T([].push),PE=function(e){var t=1===e,i=2===e,r=3===e,o=4===e,n=6===e,a=7===e,s=5===e||n;return function(c,l,d,u){for(var h,p,m=NE(c),f=DE(m),_=OE(f),g=CE(l,d),v=0,E=u||ME,y=t?E(c,_):i||a?E(c,0):void 0;_>v;v++)if((s||v in f)&&(p=g(h=f[v],v,m),e))if(t)y[v]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return v;case 2:LE(y,h)}else switch(e){case 4:return!1;case 7:LE(y,h)}return n?-1:r||o?o:y}},xE={forEach:PE(0),map:PE(1),filter:PE(2),some:PE(3),every:PE(4),find:PE(5),findIndex:PE(6),filterReject:PE(7)},UE=hr,VE=to,FE=i,BE=l,HE=n,WE=rE,jE=Jv,GE=_d,zE=Wc,qE=_,KE=Kt,YE=aE,XE=dr,JE=qc,QE=uE,$E=function(e){var t=hE(e);return t<0?0:t>255?255:255&t},ZE=ht,ey=He,ty=lo,iy=H,ry=ue,oy=ra,ny=z,ay=ts,sy=$i.f,cy=kE,ly=xE.forEach,dy=Td,uy=_o,hy=kt,py=r,my=function(e,t,i){for(var r=0,o=arguments.length>2?i:UE(t),n=new e(o);o>r;)n[r]=t[r++];return n},fy=ml,_y=ki.get,gy=ki.set,vy=ki.enforce,Ey=hy.f,yy=py.f,Ty=FE.RangeError,Iy=GE.ArrayBuffer,Ay=Iy.prototype,by=GE.DataView,Sy=jE.NATIVE_ARRAY_BUFFER_VIEWS,wy=jE.TYPED_ARRAY_TAG,Ry=jE.TypedArray,ky=jE.TypedArrayPrototype,Cy=jE.isTypedArray,Dy="BYTES_PER_ELEMENT",Ny="Wrong length",Oy=function(e,t){uy(e,t,{configurable:!0,get:function(){return _y(this)[t]}})},My=function(e){var t;return ny(Ay,e)||"ArrayBuffer"===(t=ty(e))||"SharedArrayBuffer"===t},Ly=function(e,t){return Cy(e)&&!ry(t)&&t in e&&YE(+t)&&t>=0},Py=function(e,t){return t=ZE(t),Ly(e,t)?qE(2,e[t]):yy(e,t)},xy=function(e,t,i){return t=ZE(t),!(Ly(e,t)&&iy(i)&&ey(i,"value"))||ey(i,"get")||ey(i,"set")||i.configurable||ey(i,"writable")&&!i.writable||ey(i,"enumerable")&&!i.enumerable?Ey(e,t,i):(e[t]=i.value,e)};HE?(Sy||(py.f=Py,hy.f=xy,Oy(ky,"buffer"),Oy(ky,"byteOffset"),Oy(ky,"byteLength"),Oy(ky,"length")),VE({target:"Object",stat:!0,forced:!Sy},{getOwnPropertyDescriptor:Py,defineProperty:xy}),mv.exports=function(e,t,i){var r=e.match(/\d+/)[0]/8,o=e+(i?"Clamped":"")+"Array",n="get"+e,a="set"+e,s=FE[o],c=s,l=c&&c.prototype,d={},u=function(e,t){Ey(e,t,{get:function(){return function(e,t){var i=_y(e);return i.view[n](t*r+i.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,o){var n=_y(e);n.view[a](t*r+n.byteOffset,i?$E(o):o,!0)}(this,t,e)},enumerable:!0})};Sy?WE&&(c=t((function(e,t,i,o){return zE(e,l),fy(iy(t)?My(t)?void 0!==o?new s(t,QE(i,r),o):void 0!==i?new s(t,QE(i,r)):new s(t):Cy(t)?my(c,t):BE(cy,c,t):new s(JE(t)),e,c)})),ay&&ay(c,Ry),ly(sy(s),(function(e){e in c||KE(c,e,s[e])})),c.prototype=l):(c=t((function(e,t,i,o){zE(e,l);var n,a,s,d=0,h=0;if(iy(t)){if(!My(t))return Cy(t)?my(c,t):BE(cy,c,t);n=t,h=QE(i,r);var p=t.byteLength;if(void 0===o){if(p%r)throw new Ty(Ny);if((a=p-h)<0)throw new Ty(Ny)}else if((a=XE(o)*r)+h>p)throw new Ty(Ny);s=a/r}else s=JE(t),n=new Iy(a=s*r);for(gy(e,{buffer:n,byteOffset:h,byteLength:a,length:s,view:new by(n)});d<s;)u(e,d++)})),ay&&ay(c,Ry),l=c.prototype=oy(ky)),l.constructor!==c&&KE(l,"constructor",c),vy(l).TypedArrayConstructor=c,wy&&KE(l,wy,o);var h=c!==s;d[o]=c,VE({global:!0,constructor:!0,forced:h,sham:!Sy},d),Dy in c||KE(c,Dy,r),Dy in l||KE(l,Dy,r),dy(o)}):mv.exports=function(){};var Uy=mv.exports;Uy("Float32",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Float64",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Int8",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Int16",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Int32",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Uint8",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Uint8",(function(e){return function(t,i,r){return e(this,t,i,r)}}),!0),Uy("Uint16",(function(e){return function(t,i,r){return e(this,t,i,r)}})),Uy("Uint32",(function(e){return function(t,i,r){return e(this,t,i,r)}}));var Vy=dl,Fy=_E,By=lo,Hy=l,Wy=o,jy=Jv.aTypedArray,Gy=Jv.exportTypedArrayMethod,zy=T("".slice);Gy("fill",(function(e){var t=arguments.length;jy(this);var i="Big"===zy(By(this),0,3)?Fy(e):+e;return Hy(Vy,this,i,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),Wy((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))),(0,Jv.exportTypedArrayStaticMethod)("from",kE,rE);var qy=i,Ky=l,Yy=Jv,Xy=hr,Jy=uE,Qy=Ve,$y=o,Zy=qy.RangeError,eT=qy.Int8Array,tT=eT&&eT.prototype,iT=tT&&tT.set,rT=Yy.aTypedArray,oT=Yy.exportTypedArrayMethod,nT=!$y((function(){var e=new Uint8ClampedArray(2);return Ky(iT,e,{length:1,0:3},1),3!==e[1]})),aT=nT&&Yy.NATIVE_ARRAY_BUFFER_VIEWS&&$y((function(){var e=new eT(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));oT("set",(function(e){rT(this);var t=Jy(arguments.length>1?arguments[1]:void 0,1),i=Qy(e);if(nT)return Ky(iT,this,i,t);var r=this.length,o=Xy(i),n=0;if(o+t>r)throw new Zy("Wrong length");for(;n<o;)this[t+n]=i[n++]}),!nT||aT);var sT=Xo,cT=o,lT=ge,dT=dc,uT=hc,hT=pc,pT=te,mT=fc,fT=Jv.aTypedArray,_T=Jv.exportTypedArrayMethod,gT=i.Uint16Array,vT=gT&&sT(gT.prototype.sort),ET=!(!vT||cT((function(){vT(new gT(2),null)}))&&cT((function(){vT(new gT(2),{})}))),yT=!!vT&&!cT((function(){if(pT)return pT<74;if(uT)return uT<67;if(hT)return!0;if(mT)return mT<602;var e,t,i=new gT(516),r=Array(516);for(e=0;e<516;e++)t=e%4,i[e]=515-e,r[e]=e-2*t+3;for(vT(i,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(i[e]!==r[e])return!0}));_T("sort",(function(e){return void 0!==e&&lT(e),yT?vT(this,e):dT(fT(this),function(e){return function(t,i){return void 0!==e?+e(t,i)||0:i!=i?-1:t!=t?1:0===t&&0===i?1/t>0&&1/i<0?1:-1:t>i}}(e))}),!yT||ET);var TT=to,IT=l,AT=T,bT=L,ST=F,wT=N,RT=Xm,kT=po,CT=ye,DT=of,NT=Eg,OT=tt("replace"),MT=TypeError,LT=AT("".indexOf);AT("".replace);var PT=AT("".slice),xT=Math.max;TT({target:"String",proto:!0},{replaceAll:function(e,t){var i,r,o,n,a,s,c,l,d,u=bT(this),h=0,p="";if(!wT(e)){if(RT(e)&&(i=kT(bT(DT(e))),!~LT(i,"g")))throw new MT("`.replaceAll` does not allow non-global regexes");if(r=CT(e,OT))return IT(r,e,u,t)}for(o=kT(u),n=kT(e),(a=ST(t))||(t=kT(t)),s=n.length,c=xT(1,s),l=LT(o,n);-1!==l;)d=a?kT(t(n,l,o)):NT(n,o,l,[],void 0,t),p+=PT(o,h,l)+d,h=l+s,l=l+c>o.length?-1:LT(o,n,l+c);return h<o.length&&(p+=PT(o,h)),p}});var UT={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},VT=_t("span").classList,FT=VT&&VT.constructor&&VT.constructor.prototype,BT=FT===Object.prototype?void 0:FT,HT=xE.forEach,WT=zs("forEach")?[].forEach:function(e){return HT(this,e,arguments.length>1?arguments[1]:void 0)},jT=i,GT=UT,zT=BT,qT=WT,KT=Kt,YT=function(e){if(e&&e.forEach!==qT)try{KT(e,"forEach",qT)}catch(oY){e.forEach=qT}};for(var XT in GT)GT[XT]&&YT(jT[XT]&&jT[XT].prototype);YT(zT);var JT=i,QT=UT,$T=BT,ZT=Ls,eI=Kt,tI=Ua,iI=tt("iterator"),rI=ZT.values,oI=function(e,t){if(e){if(e[iI]!==rI)try{eI(e,iI,rI)}catch(oY){e[iI]=rI}if(tI(e,t,!0),QT[t])for(var i in ZT)if(e[i]!==ZT[i])try{eI(e,i,ZT[i])}catch(oY){e[i]=ZT[i]}}};for(var nI in QT)oI(JT[nI]&&JT[nI].prototype,nI);oI($T,"DOMTokenList");var aI=Du.clear;to({global:!0,bind:!0,enumerable:!0,forced:i.clearImmediate!==aI},{clearImmediate:aI});var sI=i,cI=eu,lI=F,dI=Js,uI=Y,hI=ac,pI=iu,mI=sI.Function,fI=/MSIE .\./.test(uI)||"BUN"===dI&&function(){var e=sI.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),_I=to,gI=i,vI=Du.set,EI=function(e,t){var i=t?2:1;return fI?function(r,o){var n=pI(arguments.length,1)>i,a=lI(r)?r:mI(r),s=n?hI(arguments,i):[],c=n?function(){cI(a,this,s)}:a;return t?e(c,o):e(c)}:e},yI=gI.setImmediate?EI(vI,!1):vI;_I({global:!0,bind:!0,enumerable:!0,forced:gI.setImmediate!==yI},{setImmediate:yI});var TI=lg.charAt,II=po,AI=ki,bI=Ts,SI=Is,wI="String Iterator",RI=AI.set,kI=AI.getterFor(wI);bI(String,"String",(function(e){RI(this,{type:wI,string:II(e),index:0})}),(function(){var e,t=kI(this),i=t.string,r=t.index;return r>=i.length?SI(void 0,!0):(e=TI(i,r),t.index+=e.length,SI(e,!1))}));var CI=o,DI=n,NI=tt("iterator"),OI=!CI((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,i=new URLSearchParams("a=1&a=2&b=3"),r="";return e.pathname="c%20d",t.forEach((function(e,i){t.delete("b"),r+=i+e})),i.delete("a",2),i.delete("b",void 0),!t.size&&!DI||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[NI]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==r||"x"!==new URL("https://x",void 0).host})),MI=n,LI=T,PI=l,xI=o,UI=Pn,VI=Rr,FI=d,BI=Ve,HI=D,WI=Object.assign,jI=Object.defineProperty,GI=LI([].concat),zI=!WI||xI((function(){if(MI&&1!==WI({b:1},WI(jI({},"a",{enumerable:!0,get:function(){jI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},i=Symbol("assign detection"),r="abcdefghijklmnopqrst";return e[i]=7,r.split("").forEach((function(e){t[e]=e})),7!==WI({},e)[i]||UI(WI({},t)).join("")!==r}))?function(e,t){for(var i=BI(e),r=arguments.length,o=1,n=VI.f,a=FI.f;r>o;)for(var s,c=HI(arguments[o++]),l=n?GI(UI(c),n(c)):UI(c),d=l.length,u=0;d>u;)s=l[u++],MI&&!PI(a,c,s)||(i[s]=c[s]);return i}:WI,qI=Mt,KI=Wp,YI=n,XI=kt,JI=_,QI=Zo,$I=l,ZI=Ve,eA=function(e,t,i,r){try{return r?t(qI(i)[0],i[1]):t(i)}catch(oY){KI(e,"throw",oY)}},tA=Sp,iA=En,rA=hr,oA=function(e,t,i){YI?XI.f(e,t,JI(0,i)):e[t]=i},nA=Vp,aA=Np,sA=Array,cA=T,lA=2147483647,dA=/[^\0-\u007E]/,uA=/[.\u3002\uFF0E\uFF61]/g,hA="Overflow: input needs wider integers to process",pA=RangeError,mA=cA(uA.exec),fA=Math.floor,_A=String.fromCharCode,gA=cA("".charCodeAt),vA=cA([].join),EA=cA([].push),yA=cA("".replace),TA=cA("".split),IA=cA("".toLowerCase),AA=function(e){return e+22+75*(e<26)},bA=function(e,t,i){var r=0;for(e=i?fA(e/700):e>>1,e+=fA(e/t);e>455;)e=fA(e/35),r+=36;return fA(r+36*e/(e+38))},SA=function(e){var t=[];e=function(e){for(var t=[],i=0,r=e.length;i<r;){var o=gA(e,i++);if(o>=55296&&o<=56319&&i<r){var n=gA(e,i++);56320==(64512&n)?EA(t,((1023&o)<<10)+(1023&n)+65536):(EA(t,o),i--)}else EA(t,o)}return t}(e);var i,r,o=e.length,n=128,a=0,s=72;for(i=0;i<e.length;i++)(r=e[i])<128&&EA(t,_A(r));var c=t.length,l=c;for(c&&EA(t,"-");l<o;){var d=lA;for(i=0;i<e.length;i++)(r=e[i])>=n&&r<d&&(d=r);var u=l+1;if(d-n>fA((lA-a)/u))throw new pA(hA);for(a+=(d-n)*u,n=d,i=0;i<e.length;i++){if((r=e[i])<n&&++a>lA)throw new pA(hA);if(r===n){for(var h=a,p=36;;){var m=p<=s?1:p>=s+26?26:p-s;if(h<m)break;var f=h-m,_=36-m;EA(t,_A(AA(m+f%_))),h=fA(f/_),p+=36}EA(t,_A(AA(h))),s=bA(a,u,l===c),a=0,l++}}a++,n++}return vA(t,"")},wA=to,RA=T,kA=sr,CA=RangeError,DA=String.fromCharCode,NA=String.fromCodePoint,OA=RA([].join);wA({target:"String",stat:!0,arity:1,forced:!!NA&&1!==NA.length},{fromCodePoint:function(e){for(var t,i=[],r=arguments.length,o=0;r>o;){if(t=+arguments[o++],kA(t,1114111)!==t)throw new CA(t+" is not a valid code point");i[o]=t<65536?DA(t):DA(55296+((t-=65536)>>10),t%1024+56320)}return OA(i,"")}});var MA=to,LA=i,PA=Lu,xA=G,UA=l,VA=T,FA=n,BA=OI,HA=Qi,WA=_o,jA=Fc,GA=Ua,zA=Ga,qA=ki,KA=Wc,YA=F,XA=He,JA=Zo,QA=lo,$A=Mt,ZA=H,eb=po,tb=ra,ib=_,rb=Vp,ob=Np,nb=Is,ab=iu,sb=dc,cb=tt("iterator"),lb="URLSearchParams",db=lb+"Iterator",ub=qA.set,hb=qA.getterFor(lb),pb=qA.getterFor(db),mb=PA("fetch"),fb=PA("Request"),_b=PA("Headers"),gb=fb&&fb.prototype,vb=_b&&_b.prototype,Eb=LA.TypeError,yb=LA.encodeURIComponent,Tb=String.fromCharCode,Ib=xA("String","fromCodePoint"),Ab=parseInt,bb=VA("".charAt),Sb=VA([].join),wb=VA([].push),Rb=VA("".replace),kb=VA([].shift),Cb=VA([].splice),Db=VA("".split),Nb=VA("".slice),Ob=VA(/./.exec),Mb=/\+/g,Lb=/^[0-9a-f]+$/i,Pb=function(e,t){var i=Nb(e,t,t+2);return Ob(Lb,i)?Ab(i,16):NaN},xb=function(e){for(var t=0,i=128;i>0&&e&i;i>>=1)t++;return t},Ub=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},Vb=function(e){for(var t=(e=Rb(e,Mb," ")).length,i="",r=0;r<t;){var o=bb(e,r);if("%"===o){if("%"===bb(e,r+1)||r+3>t){i+="%",r++;continue}var n=Pb(e,r+1);if(n!=n){i+=o,r++;continue}r+=2;var a=xb(n);if(0===a)o=Tb(n);else{if(1===a||a>4){i+="�",r++;continue}for(var s=[n],c=1;c<a&&!(++r+3>t||"%"!==bb(e,r));){var l=Pb(e,r+1);if(l!=l){r+=3;break}if(l>191||l<128)break;wb(s,l),r+=2,c++}if(s.length!==a){i+="�";continue}var d=Ub(s);null===d?i+="�":o=Ib(d)}}i+=o,r++}return i},Fb=/[!'()~]|%20/g,Bb={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Hb=function(e){return Bb[e]},Wb=function(e){return Rb(yb(e),Fb,Hb)},jb=zA((function(e,t){ub(this,{type:db,target:hb(e).entries,index:0,kind:t})}),lb,(function(){var e=pb(this),t=e.target,i=e.index++;if(!t||i>=t.length)return e.target=null,nb(void 0,!0);var r=t[i];switch(e.kind){case"keys":return nb(r.key,!1);case"values":return nb(r.value,!1)}return nb([r.key,r.value],!1)}),!0),Gb=function(e){this.entries=[],this.url=null,void 0!==e&&(ZA(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===bb(e,0)?Nb(e,1):e:eb(e)))};Gb.prototype={type:lb,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,i,r,o,n,a,s,c=this.entries,l=ob(e);if(l)for(i=(t=rb(e,l)).next;!(r=UA(i,t)).done;){if(n=(o=rb($A(r.value))).next,(a=UA(n,o)).done||(s=UA(n,o)).done||!UA(n,o).done)throw new Eb("Expected sequence with length 2");wb(c,{key:eb(a.value),value:eb(s.value)})}else for(var d in e)XA(e,d)&&wb(c,{key:d,value:eb(e[d])})},parseQuery:function(e){if(e)for(var t,i,r=this.entries,o=Db(e,"&"),n=0;n<o.length;)(t=o[n++]).length&&(i=Db(t,"="),wb(r,{key:Vb(kb(i)),value:Vb(Sb(i,"="))}))},serialize:function(){for(var e,t=this.entries,i=[],r=0;r<t.length;)e=t[r++],wb(i,Wb(e.key)+"="+Wb(e.value));return Sb(i,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var zb=function(){KA(this,qb);var e=ub(this,new Gb(arguments.length>0?arguments[0]:void 0));FA||(this.size=e.entries.length)},qb=zb.prototype;if(jA(qb,{append:function(e,t){var i=hb(this);ab(arguments.length,2),wb(i.entries,{key:eb(e),value:eb(t)}),FA||this.length++,i.updateURL()},delete:function(e){for(var t=hb(this),i=ab(arguments.length,1),r=t.entries,o=eb(e),n=i<2?void 0:arguments[1],a=void 0===n?n:eb(n),s=0;s<r.length;){var c=r[s];if(c.key!==o||void 0!==a&&c.value!==a)s++;else if(Cb(r,s,1),void 0!==a)break}FA||(this.size=r.length),t.updateURL()},get:function(e){var t=hb(this).entries;ab(arguments.length,1);for(var i=eb(e),r=0;r<t.length;r++)if(t[r].key===i)return t[r].value;return null},getAll:function(e){var t=hb(this).entries;ab(arguments.length,1);for(var i=eb(e),r=[],o=0;o<t.length;o++)t[o].key===i&&wb(r,t[o].value);return r},has:function(e){for(var t=hb(this).entries,i=ab(arguments.length,1),r=eb(e),o=i<2?void 0:arguments[1],n=void 0===o?o:eb(o),a=0;a<t.length;){var s=t[a++];if(s.key===r&&(void 0===n||s.value===n))return!0}return!1},set:function(e,t){var i=hb(this);ab(arguments.length,1);for(var r,o=i.entries,n=!1,a=eb(e),s=eb(t),c=0;c<o.length;c++)(r=o[c]).key===a&&(n?Cb(o,c--,1):(n=!0,r.value=s));n||wb(o,{key:a,value:s}),FA||(this.size=o.length),i.updateURL()},sort:function(){var e=hb(this);sb(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,i=hb(this).entries,r=JA(e,arguments.length>1?arguments[1]:void 0),o=0;o<i.length;)r((t=i[o++]).value,t.key,this)},keys:function(){return new jb(this,"keys")},values:function(){return new jb(this,"values")},entries:function(){return new jb(this,"entries")}},{enumerable:!0}),HA(qb,cb,qb.entries,{name:"entries"}),HA(qb,"toString",(function(){return hb(this).serialize()}),{enumerable:!0}),FA&&WA(qb,"size",{get:function(){return hb(this).entries.length},configurable:!0,enumerable:!0}),GA(zb,lb),MA({global:!0,constructor:!0,forced:!BA},{URLSearchParams:zb}),!BA&&YA(_b)){var Kb=VA(vb.has),Yb=VA(vb.set),Xb=function(e){if(ZA(e)){var t,i=e.body;if(QA(i)===lb)return t=e.headers?new _b(e.headers):new _b,Kb(t,"content-type")||Yb(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),tb(e,{body:ib(0,eb(i)),headers:ib(0,t)})}return e};if(YA(mb)&&MA({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return mb(e,arguments.length>1?Xb(arguments[1]):{})}}),YA(fb)){var Jb=function(e){return KA(this,gb),new fb(e,arguments.length>1?Xb(arguments[1]):{})};gb.constructor=Jb,Jb.prototype=gb,MA({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Jb})}}var Qb,$b=to,Zb=n,eS=OI,tS=i,iS=Zo,rS=T,oS=Qi,nS=_o,aS=Wc,sS=He,cS=zI,lS=function(e){var t=ZI(e),i=iA(this),r=arguments.length,o=r>1?arguments[1]:void 0,n=void 0!==o;n&&(o=QI(o,r>2?arguments[2]:void 0));var a,s,c,l,d,u,h=aA(t),p=0;if(!h||this===sA&&tA(h))for(a=rA(t),s=i?new this(a):sA(a);a>p;p++)u=n?o(t[p],p):t[p],oA(s,p,u);else for(s=i?new this:[],d=(l=nA(t,h)).next;!(c=$I(d,l)).done;p++)u=n?eA(l,o,[c.value,p],!0):c.value,oA(s,p,u);return s.length=p,s},dS=ac,uS=lg.codeAt,hS=function(e){var t,i,r=[],o=TA(yA(IA(e),uA,"."),".");for(t=0;t<o.length;t++)i=o[t],EA(r,mA(dA,i)?"xn--"+SA(i):i);return vA(r,".")},pS=po,mS=Ua,fS=iu,_S={URLSearchParams:zb,getState:hb},gS=ki,vS=gS.set,ES=gS.getterFor("URL"),yS=_S.URLSearchParams,TS=_S.getState,IS=tS.URL,AS=tS.TypeError,bS=tS.parseInt,SS=Math.floor,wS=Math.pow,RS=rS("".charAt),kS=rS(/./.exec),CS=rS([].join),DS=rS(1..toString),NS=rS([].pop),OS=rS([].push),MS=rS("".replace),LS=rS([].shift),PS=rS("".split),xS=rS("".slice),US=rS("".toLowerCase),VS=rS([].unshift),FS="Invalid scheme",BS="Invalid host",HS="Invalid port",WS=/[a-z]/i,jS=/[\d+-.a-z]/i,GS=/\d/,zS=/^0x/i,qS=/^[0-7]+$/,KS=/^\d+$/,YS=/^[\da-f]+$/i,XS=/[\0\t\n\r #%/:<>?@[\\\]^|]/,JS=/[\0\t\n\r #/:<>?@[\\\]^|]/,QS=/^[\u0000-\u0020]+/,$S=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ZS=/[\t\n\r]/g,ew=function(e){var t,i,r,o;if("number"==typeof e){for(t=[],i=0;i<4;i++)VS(t,e%256),e=SS(e/256);return CS(t,".")}if("object"==typeof e){for(t="",r=function(e){for(var t=null,i=1,r=null,o=0,n=0;n<8;n++)0!==e[n]?(o>i&&(t=r,i=o),r=null,o=0):(null===r&&(r=n),++o);return o>i?r:t}(e),i=0;i<8;i++)o&&0===e[i]||(o&&(o=!1),r===i?(t+=i?":":"::",o=!0):(t+=DS(e[i],16),i<7&&(t+=":")));return"["+t+"]"}return e},tw={},iw=cS({},tw,{" ":1,'"':1,"<":1,">":1,"`":1}),rw=cS({},iw,{"#":1,"?":1,"{":1,"}":1}),ow=cS({},rw,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),nw=function(e,t){var i=uS(e,0);return i>32&&i<127&&!sS(t,e)?e:encodeURIComponent(e)},aw={ftp:21,file:null,http:80,https:443,ws:80,wss:443},sw=function(e,t){var i;return 2===e.length&&kS(WS,RS(e,0))&&(":"===(i=RS(e,1))||!t&&"|"===i)},cw=function(e){var t;return e.length>1&&sw(xS(e,0,2))&&(2===e.length||"/"===(t=RS(e,2))||"\\"===t||"?"===t||"#"===t)},lw=function(e){return"."===e||"%2e"===US(e)},dw={},uw={},hw={},pw={},mw={},fw={},_w={},gw={},vw={},Ew={},yw={},Tw={},Iw={},Aw={},bw={},Sw={},ww={},Rw={},kw={},Cw={},Dw={},Nw=function(e,t,i){var r,o,n,a=pS(e);if(t){if(o=this.parse(a))throw new AS(o);this.searchParams=null}else{if(void 0!==i&&(r=new Nw(i,!0)),o=this.parse(a,null,r))throw new AS(o);(n=TS(new yS)).bindURL(this),this.searchParams=n}};Nw.prototype={type:"URL",parse:function(e,t,i){var r,o,n,a,s,c=this,l=t||dw,d=0,u="",h=!1,p=!1,m=!1;for(e=pS(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=MS(e,QS,""),e=MS(e,$S,"$1")),e=MS(e,ZS,""),r=lS(e);d<=r.length;){switch(o=r[d],l){case dw:if(!o||!kS(WS,o)){if(t)return FS;l=hw;continue}u+=US(o),l=uw;break;case uw:if(o&&(kS(jS,o)||"+"===o||"-"===o||"."===o))u+=US(o);else{if(":"!==o){if(t)return FS;u="",l=hw,d=0;continue}if(t&&(c.isSpecial()!==sS(aw,u)||"file"===u&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=u,t)return void(c.isSpecial()&&aw[c.scheme]===c.port&&(c.port=null));u="","file"===c.scheme?l=Aw:c.isSpecial()&&i&&i.scheme===c.scheme?l=pw:c.isSpecial()?l=gw:"/"===r[d+1]?(l=mw,d++):(c.cannotBeABaseURL=!0,OS(c.path,""),l=kw)}break;case hw:if(!i||i.cannotBeABaseURL&&"#"!==o)return FS;if(i.cannotBeABaseURL&&"#"===o){c.scheme=i.scheme,c.path=dS(i.path),c.query=i.query,c.fragment="",c.cannotBeABaseURL=!0,l=Dw;break}l="file"===i.scheme?Aw:fw;continue;case pw:if("/"!==o||"/"!==r[d+1]){l=fw;continue}l=vw,d++;break;case mw:if("/"===o){l=Ew;break}l=Rw;continue;case fw:if(c.scheme=i.scheme,o===Qb)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=dS(i.path),c.query=i.query;else if("/"===o||"\\"===o&&c.isSpecial())l=_w;else if("?"===o)c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=dS(i.path),c.query="",l=Cw;else{if("#"!==o){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=dS(i.path),c.path.length--,l=Rw;continue}c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,c.path=dS(i.path),c.query=i.query,c.fragment="",l=Dw}break;case _w:if(!c.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){c.username=i.username,c.password=i.password,c.host=i.host,c.port=i.port,l=Rw;continue}l=Ew}else l=vw;break;case gw:if(l=vw,"/"!==o||"/"!==RS(u,d+1))continue;d++;break;case vw:if("/"!==o&&"\\"!==o){l=Ew;continue}break;case Ew:if("@"===o){h&&(u="%40"+u),h=!0,n=lS(u);for(var f=0;f<n.length;f++){var _=n[f];if(":"!==_||m){var g=nw(_,ow);m?c.password+=g:c.username+=g}else m=!0}u=""}else if(o===Qb||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(h&&""===u)return"Invalid authority";d-=lS(u).length+1,u="",l=yw}else u+=o;break;case yw:case Tw:if(t&&"file"===c.scheme){l=Sw;continue}if(":"!==o||p){if(o===Qb||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(c.isSpecial()&&""===u)return BS;if(t&&""===u&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(u))return a;if(u="",l=ww,t)return;continue}"["===o?p=!0:"]"===o&&(p=!1),u+=o}else{if(""===u)return BS;if(a=c.parseHost(u))return a;if(u="",l=Iw,t===Tw)return}break;case Iw:if(!kS(GS,o)){if(o===Qb||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()||t){if(""!==u){var v=bS(u,10);if(v>65535)return HS;c.port=c.isSpecial()&&v===aw[c.scheme]?null:v,u=""}if(t)return;l=ww;continue}return HS}u+=o;break;case Aw:if(c.scheme="file","/"===o||"\\"===o)l=bw;else{if(!i||"file"!==i.scheme){l=Rw;continue}switch(o){case Qb:c.host=i.host,c.path=dS(i.path),c.query=i.query;break;case"?":c.host=i.host,c.path=dS(i.path),c.query="",l=Cw;break;case"#":c.host=i.host,c.path=dS(i.path),c.query=i.query,c.fragment="",l=Dw;break;default:cw(CS(dS(r,d),""))||(c.host=i.host,c.path=dS(i.path),c.shortenPath()),l=Rw;continue}}break;case bw:if("/"===o||"\\"===o){l=Sw;break}i&&"file"===i.scheme&&!cw(CS(dS(r,d),""))&&(sw(i.path[0],!0)?OS(c.path,i.path[0]):c.host=i.host),l=Rw;continue;case Sw:if(o===Qb||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&sw(u))l=Rw;else if(""===u){if(c.host="",t)return;l=ww}else{if(a=c.parseHost(u))return a;if("localhost"===c.host&&(c.host=""),t)return;u="",l=ww}continue}u+=o;break;case ww:if(c.isSpecial()){if(l=Rw,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==Qb&&(l=Rw,"/"!==o))continue}else c.fragment="",l=Dw;else c.query="",l=Cw;break;case Rw:if(o===Qb||"/"===o||"\\"===o&&c.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(s=US(s=u))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===o||"\\"===o&&c.isSpecial()||OS(c.path,"")):lw(u)?"/"===o||"\\"===o&&c.isSpecial()||OS(c.path,""):("file"===c.scheme&&!c.path.length&&sw(u)&&(c.host&&(c.host=""),u=RS(u,0)+":"),OS(c.path,u)),u="","file"===c.scheme&&(o===Qb||"?"===o||"#"===o))for(;c.path.length>1&&""===c.path[0];)LS(c.path);"?"===o?(c.query="",l=Cw):"#"===o&&(c.fragment="",l=Dw)}else u+=nw(o,rw);break;case kw:"?"===o?(c.query="",l=Cw):"#"===o?(c.fragment="",l=Dw):o!==Qb&&(c.path[0]+=nw(o,tw));break;case Cw:t||"#"!==o?o!==Qb&&("'"===o&&c.isSpecial()?c.query+="%27":c.query+="#"===o?"%23":nw(o,tw)):(c.fragment="",l=Dw);break;case Dw:o!==Qb&&(c.fragment+=nw(o,iw))}d++}},parseHost:function(e){var t,i,r;if("["===RS(e,0)){if("]"!==RS(e,e.length-1))return BS;if(t=function(e){var t,i,r,o,n,a,s,c=[0,0,0,0,0,0,0,0],l=0,d=null,u=0,h=function(){return RS(e,u)};if(":"===h()){if(":"!==RS(e,1))return;u+=2,d=++l}for(;h();){if(8===l)return;if(":"!==h()){for(t=i=0;i<4&&kS(YS,h());)t=16*t+bS(h(),16),u++,i++;if("."===h()){if(0===i)return;if(u-=i,l>6)return;for(r=0;h();){if(o=null,r>0){if(!("."===h()&&r<4))return;u++}if(!kS(GS,h()))return;for(;kS(GS,h());){if(n=bS(h(),10),null===o)o=n;else{if(0===o)return;o=10*o+n}if(o>255)return;u++}c[l]=256*c[l]+o,2!=++r&&4!==r||l++}if(4!==r)return;break}if(":"===h()){if(u++,!h())return}else if(h())return;c[l++]=t}else{if(null!==d)return;u++,d=++l}}if(null!==d)for(a=l-d,l=7;0!==l&&a>0;)s=c[l],c[l--]=c[d+a-1],c[d+--a]=s;else if(8!==l)return;return c}(xS(e,1,-1)),!t)return BS;this.host=t}else if(this.isSpecial()){if(e=hS(e),kS(XS,e))return BS;if(t=function(e){var t,i,r,o,n,a,s,c=PS(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(i=[],r=0;r<t;r++){if(""===(o=c[r]))return e;if(n=10,o.length>1&&"0"===RS(o,0)&&(n=kS(zS,o)?16:8,o=xS(o,8===n?1:2)),""===o)a=0;else{if(!kS(10===n?KS:8===n?qS:YS,o))return e;a=bS(o,n)}OS(i,a)}for(r=0;r<t;r++)if(a=i[r],r===t-1){if(a>=wS(256,5-t))return null}else if(a>255)return null;for(s=NS(i),r=0;r<i.length;r++)s+=i[r]*wS(256,3-r);return s}(e),null===t)return BS;this.host=t}else{if(kS(JS,e))return BS;for(t="",i=lS(e),r=0;r<i.length;r++)t+=nw(i[r],tw);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return sS(aw,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&sw(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,i=e.username,r=e.password,o=e.host,n=e.port,a=e.path,s=e.query,c=e.fragment,l=t+":";return null!==o?(l+="//",e.includesCredentials()&&(l+=i+(r?":"+r:"")+"@"),l+=ew(o),null!==n&&(l+=":"+n)):"file"===t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+CS(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw new AS(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new Ow(e.path[0]).origin}catch(oY){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+ew(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(pS(e)+":",dw)},getUsername:function(){return this.username},setUsername:function(e){var t=lS(pS(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var i=0;i<t.length;i++)this.username+=nw(t[i],ow)}},getPassword:function(){return this.password},setPassword:function(e){var t=lS(pS(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var i=0;i<t.length;i++)this.password+=nw(t[i],ow)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?ew(e):ew(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,yw)},getHostname:function(){var e=this.host;return null===e?"":ew(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,Tw)},getPort:function(){var e=this.port;return null===e?"":pS(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=pS(e))?this.port=null:this.parse(e,Iw))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+CS(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,ww))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=pS(e))?this.query=null:("?"===RS(e,0)&&(e=xS(e,1)),this.query="",this.parse(e,Cw)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=pS(e))?("#"===RS(e,0)&&(e=xS(e,1)),this.fragment="",this.parse(e,Dw)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Ow=function(e){var t=aS(this,Mw),i=fS(arguments.length,1)>1?arguments[1]:void 0,r=vS(t,new Nw(e,!1,i));Zb||(t.href=r.serialize(),t.origin=r.getOrigin(),t.protocol=r.getProtocol(),t.username=r.getUsername(),t.password=r.getPassword(),t.host=r.getHost(),t.hostname=r.getHostname(),t.port=r.getPort(),t.pathname=r.getPathname(),t.search=r.getSearch(),t.searchParams=r.getSearchParams(),t.hash=r.getHash())},Mw=Ow.prototype,Lw=function(e,t){return{get:function(){return ES(this)[e]()},set:t&&function(e){return ES(this)[t](e)},configurable:!0,enumerable:!0}};if(Zb&&(nS(Mw,"href",Lw("serialize","setHref")),nS(Mw,"origin",Lw("getOrigin")),nS(Mw,"protocol",Lw("getProtocol","setProtocol")),nS(Mw,"username",Lw("getUsername","setUsername")),nS(Mw,"password",Lw("getPassword","setPassword")),nS(Mw,"host",Lw("getHost","setHost")),nS(Mw,"hostname",Lw("getHostname","setHostname")),nS(Mw,"port",Lw("getPort","setPort")),nS(Mw,"pathname",Lw("getPathname","setPathname")),nS(Mw,"search",Lw("getSearch","setSearch")),nS(Mw,"searchParams",Lw("getSearchParams")),nS(Mw,"hash",Lw("getHash","setHash"))),oS(Mw,"toJSON",(function(){return ES(this).serialize()}),{enumerable:!0}),oS(Mw,"toString",(function(){return ES(this).serialize()}),{enumerable:!0}),IS){var Pw=IS.createObjectURL,xw=IS.revokeObjectURL;Pw&&oS(Ow,"createObjectURL",iS(Pw,IS)),xw&&oS(Ow,"revokeObjectURL",iS(xw,IS))}mS(Ow,"URL"),$b({global:!0,constructor:!0,forced:!eS,sham:!Zb},{URL:Ow});var Uw=l;to({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return Uw(URL.prototype.toString,this)}});var Vw,Fw,Bw=Object.create,Hw=Object.defineProperty,Ww=Object.defineProperties,jw=Object.getOwnPropertyDescriptor,Gw=Object.getOwnPropertyDescriptors,zw=Object.getOwnPropertyNames,qw=Object.getOwnPropertySymbols,Kw=Object.getPrototypeOf,Yw=Object.prototype.hasOwnProperty,Xw=Object.prototype.propertyIsEnumerable,Jw=Reflect.get,Qw=Math.pow,$w=(e,t,i)=>t in e?Hw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Zw=(e,t)=>{for(var i in t||(t={}))Yw.call(t,i)&&$w(e,i,t[i]);if(qw)for(var i of qw(t))Xw.call(t,i)&&$w(e,i,t[i]);return e},eR=(e,t)=>Ww(e,Gw(t)),tR=(Vw=function(e){if("undefined"!=typeof require)return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')},"undefined"!=typeof require?require:"undefined"!=typeof Proxy?new Proxy(Vw,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):Vw),iR=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rR=(e,t)=>{for(var i in t)Hw(e,i,{get:t[i],enumerable:!0})},oR=(e,t,i)=>(i=null!=e?Bw(Kw(e)):{},((e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of zw(t))!Yw.call(e,o)&&o!==i&&Hw(e,o,{get:()=>t[o],enumerable:!(r=jw(t,o))||r.enumerable});return e})(!t&&e&&e.__esModule?i:Hw(i,"default",{value:e,enumerable:!0}),e)),nR=(e,t,i,r)=>{for(var o,n=r>1?void 0:r?jw(t,i):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r?o(t,i,n):o(n))||n);return r&&n&&Hw(t,i,n),n},aR=(e,t,i)=>$w(e,"symbol"!=typeof t?t+"":t,i),sR=(e,t,i)=>Jw(Kw(e),i,t),cR=(e,t,i)=>new Promise(((r,o)=>{var n=e=>{try{s(i.next(e))}catch(lM){o(lM)}},a=e=>{try{s(i.throw(e))}catch(lM){o(lM)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(n,a);s((i=i.apply(e,t)).next())})),lR=iR(((e,t)=>{var i=Object.prototype.hasOwnProperty,r="~";function o(){}function n(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,i,o,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new n(i,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 s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)i.call(e,t)&&o.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,n=i.length,a=new Array(n);o<n;o++)a[o]=i[o].fn;return a},c.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,o,n,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,l,d=this._events[s],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,o),!0;case 5:return d.fn.call(d.context,t,i,o,n),!0;case 6:return d.fn.call(d.context,t,i,o,n,a),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,o);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,o){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn===t&&(!o||a.once)&&(!i||a.context===i)&&s(this,n);else{for(var c=0,l=[],d=a.length;c<d;c++)(a[c].fn!==t||o&&!a[c].once||i&&a[c].context!==i)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),dR=iR(((e,t)=>{var i=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(i).forEach((function(e){i[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),uR=iR((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},i=function(e,i,r){var o=e.name&&e.names;e.push&&!i[e.push]?i[e.push]=[]:o&&!i[e.name]&&(i[e.name]={});var n=e.push?{}:o?i[e.name]:i;(function(e,i,r,o){if(o&&!r)i[o]=t(e[1]);else for(var n=0;n<r.length;n+=1)null!=e[n+1]&&(i[r[n]]=t(e[n+1]))})(r.match(e.reg),n,e.names,e.name),e.push&&i[e.push].push(n)},r=dR(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},n=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(o).forEach((function(e){var t=e[0],o=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),a=n[n.length-1]);for(var s=0;s<(r[t]||[]).length;s+=1){var c=r[t][s];if(c.reg.test(o))return i(c,a,o)}})),t.media=n,t};var n=function(e,i){var r=i.split(/=(.+)/,2);return 2===r.length?e[r[0]]=t(r[1]):1===r.length&&i.length>1&&(e[r[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(n,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var i=[],r=e.split(" ").map(t),o=0;o<r.length;o+=3)i.push({component:r[o],ip:r[o+1],port:r[o+2]});return i},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(n,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var i,r=!1;return"~"!==e[0]?i=t(e):(i=t(e.substring(1,e.length)),r=!0),{scid:i,paused:r}}))}))}})),hR=iR(((e,t)=>{var i=dR(),r=/%[sdv%]/g,o=function(e){var t=1,i=arguments,o=i.length;return e.replace(r,(function(e){if(t>=o)return e;var r=i[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(r);case"%d":return Number(r);case"%v":return""}}))},n=function(e,t,i){var r=[e+"="+(t.format instanceof Function?t.format(t.push?i:i[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var a=t.names[n];t.name?r.push(i[t.name][a]):r.push(i[t.names[n]])}else r.push(i[t.name]);return o.apply(null,r)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var r=t.outerOrder||a,o=t.innerOrder||s,c=[];return r.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(n(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(n(t,i,e))}))}))})),e.media.forEach((function(e){c.push(n("m",i.m[0],e)),o.forEach((function(t){i[t].forEach((function(i){i.name in e&&null!=e[i.name]?c.push(n(t,i,e)):i.push in e&&null!=e[i.push]&&e[i.push].forEach((function(e){c.push(n(t,i,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),pR=iR((e=>{var t=uR(),i=hR(),r=dR();e.grammar=r,e.write=i,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),mR=iR(((e,t)=>{!function(i){"object"==typeof e&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define([],i):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=i()}((function(){return function e(t,i,r){function o(a,s){if(!i[a]){if(!t[a]){var c="function"==typeof tR&&tR;if(!s&&c)return c(a,!0);if(n)return n(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var d=i[a]={exports:{}};t[a][0].call(d.exports,(function(e){return o(t[a][1][e]||e)}),d,d.exports,e,t,i,r)}return i[a].exports}for(var n="function"==typeof tR&&tR,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,i){var r=e("./utils"),o=e("./support"),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(e){for(var t,i,o,a,s,c,l,d=[],u=0,h=e.length,p=h,m="string"!==r.getTypeOf(e);u<e.length;)p=h-u,o=m?(t=e[u++],i=u<h?e[u++]:0,u<h?e[u++]:0):(t=e.charCodeAt(u++),i=u<h?e.charCodeAt(u++):0,u<h?e.charCodeAt(u++):0),a=t>>2,s=(3&t)<<4|i>>4,c=1<p?(15&i)<<2|o>>6:64,l=2<p?63&o:64,d.push(n.charAt(a)+n.charAt(s)+n.charAt(c)+n.charAt(l));return d.join("")},i.decode=function(e){var t,i,r,a,s,c,l=0,d=0,u="data:";if(e.substr(0,5)===u)throw new Error("Invalid base64 input, it looks like a data url.");var h,p=3*(e=e.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(e.charAt(e.length-1)===n.charAt(64)&&p--,e.charAt(e.length-2)===n.charAt(64)&&p--,p%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=o.uint8array?new Uint8Array(0|p):new Array(0|p);l<e.length;)t=n.indexOf(e.charAt(l++))<<2|(a=n.indexOf(e.charAt(l++)))>>4,i=(15&a)<<4|(s=n.indexOf(e.charAt(l++)))>>2,r=(3&s)<<6|(c=n.indexOf(e.charAt(l++))),h[d++]=t,64!==s&&(h[d++]=i),64!==c&&(h[d++]=r);return h}},{"./support":30,"./utils":32}],2:[function(e,t,i){var r=e("./external"),o=e("./stream/DataWorker"),n=e("./stream/Crc32Probe"),a=e("./stream/DataLengthProbe");function s(e,t,i,r,o){this.compressedSize=e,this.uncompressedSize=t,this.crc32=i,this.compression=r,this.compressedContent=o}s.prototype={getContentWorker:function(){var e=new o(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),t=this;return e.on("end",(function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")})),e},getCompressedWorker:function(){return new o(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},s.createWorkerFrom=function(e,t,i){return e.pipe(new n).pipe(new a("uncompressedSize")).pipe(t.compressWorker(i)).pipe(new a("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,i){var r=e("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},i.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,i){var r=e("./utils"),o=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==r.getTypeOf(e)?function(e,t,i){var r=o,n=0+i;e^=-1;for(var a=0;a<n;a++)e=e>>>8^r[255&(e^t[a])];return~e}(0|t,e,e.length):function(e,t,i){var r=o,n=0+i;e^=-1;for(var a=0;a<n;a++)e=e>>>8^r[255&(e^t.charCodeAt(a))];return~e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(e,t,i){var r;r="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:r}},{lie:37}],7:[function(e,t,i){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,o=e("pako"),n=e("./utils"),a=e("./stream/GenericWorker"),s=r?"uint8array":"array";function c(e,t){a.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}i.magic="\b\0",n.inherits(c,a),c.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(n.transformTo(s,e.data),!1)},c.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},i.compressWorker=function(e){return new c("Deflate",e)},i.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,i){function r(e,t){var i,r="";for(i=0;i<t;i++)r+=String.fromCharCode(255&e),e>>>=8;return r}function o(e,t,i,o,a,d){var u,h,p=e.file,m=e.compression,f=d!==s.utf8encode,_=n.transformTo("string",d(p.name)),g=n.transformTo("string",s.utf8encode(p.name)),v=p.comment,E=n.transformTo("string",d(v)),y=n.transformTo("string",s.utf8encode(v)),T=g.length!==p.name.length,I=y.length!==v.length,A="",b="",S="",w=p.dir,R=p.date,k={crc32:0,compressedSize:0,uncompressedSize:0};t&&!i||(k.crc32=e.crc32,k.compressedSize=e.compressedSize,k.uncompressedSize=e.uncompressedSize);var C=0;t&&(C|=8),f||!T&&!I||(C|=2048);var D,N,O,M=0,L=0;w&&(M|=16),"UNIX"===a?(L=798,M|=(D=p.unixPermissions,N=w,O=D,D||(O=N?16893:33204),(65535&O)<<16)):(L=20,M|=function(e){return 63&(e||0)}(p.dosPermissions)),u=R.getUTCHours(),u<<=6,u|=R.getUTCMinutes(),u<<=5,u|=R.getUTCSeconds()/2,h=R.getUTCFullYear()-1980,h<<=4,h|=R.getUTCMonth()+1,h<<=5,h|=R.getUTCDate(),T&&(b=r(1,1)+r(c(_),4)+g,A+="up"+r(b.length,2)+b),I&&(S=r(1,1)+r(c(E),4)+y,A+="uc"+r(S.length,2)+S);var P="";return P+="\n\0",P+=r(C,2),P+=m.magic,P+=r(u,2),P+=r(h,2),P+=r(k.crc32,4),P+=r(k.compressedSize,4),P+=r(k.uncompressedSize,4),P+=r(_.length,2),P+=r(A.length,2),{fileRecord:l.LOCAL_FILE_HEADER+P+_+A,dirRecord:l.CENTRAL_FILE_HEADER+r(L,2)+P+r(E.length,2)+"\0\0\0\0"+r(M,4)+r(o,4)+_+A+E}}var n=e("../utils"),a=e("../stream/GenericWorker"),s=e("../utf8"),c=e("../crc32"),l=e("../signature");function d(e,t,i,r){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=i,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}n.inherits(d,a),d.prototype.push=function(e){var t=e.meta.percent||0,i=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,a.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:i?(t+100*(i-r-1))/i:100}}))},d.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var i=o(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:i.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(e){this.accumulate=!1;var t,i=this.streamFiles&&!e.file.dir,n=o(e,i,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),i)this.push({data:(t=e,l.DATA_DESCRIPTOR+r(t.crc32,4)+r(t.compressedSize,4)+r(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var i,o,a,s,c,d,u=this.bytesWritten-e,h=(i=this.dirRecords.length,o=u,a=e,s=this.zipComment,c=this.encodeFileName,d=n.transformTo("string",c(s)),l.CENTRAL_DIRECTORY_END+"\0\0\0\0"+r(i,2)+r(i,2)+r(o,4)+r(a,4)+r(d.length,2)+d);this.push({data:h,meta:{percent:100}})},d.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},d.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()})),e.on("error",(function(e){t.error(e)})),this},d.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},d.prototype.error=function(e){var t=this._sources;if(!a.prototype.error.call(this,e))return!1;for(var i=0;i<t.length;i++)try{t[i].error(e)}catch(r){}return!0},d.prototype.lock=function(){a.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()},t.exports=d},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,t,i){var r=e("../compressions"),o=e("./ZipFileWorker");i.generateWorker=function(e,t,i){var n=new o(t.streamFiles,i,t.platform,t.encodeFileName),a=0;try{e.forEach((function(e,i){a++;var o=function(e,t){var i=e||t,o=r[i];if(!o)throw new Error(i+" is not a valid compression method !");return o}(i.options.compression,t.compression),s=i.options.compressionOptions||t.compressionOptions||{},c=i.dir,l=i.date;i._compressWorker(o,s).withStreamInfo("file",{name:e,dir:c,date:l,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(n)})),n.entriesCount=a}catch(s){n.error(s)}return n}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,i){function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new r;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(r.prototype=e("./object")).loadAsync=e("./load"),r.support=e("./support"),r.defaults=e("./defaults"),r.version="3.10.1",r.loadAsync=function(e,t){return(new r).loadAsync(e,t)},r.external=e("./external"),t.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,i){var r=e("./utils"),o=e("./external"),n=e("./utf8"),a=e("./zipEntries"),s=e("./stream/Crc32Probe"),c=e("./nodejsUtils");function l(e){return new o.Promise((function(t,i){var r=e.decompressed.getContentWorker().pipe(new s);r.on("error",(function(e){i(e)})).on("end",(function(){r.streamInfo.crc32!==e.decompressed.crc32?i(new Error("Corrupted zip : CRC32 mismatch")):t()})).resume()}))}t.exports=function(e,t){var i=this;return t=r.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),c.isNode&&c.isStream(e)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then((function(e){var i=new a(t);return i.load(e),i})).then((function(e){var i=[o.Promise.resolve(e)],r=e.files;if(t.checkCRC32)for(var n=0;n<r.length;n++)i.push(l(r[n]));return o.Promise.all(i)})).then((function(e){for(var o=e.shift(),n=o.files,a=0;a<n.length;a++){var s=n[a],c=s.fileNameStr,l=r.resolve(s.fileNameStr);i.file(l,s.decompressed,{binary:!0,optimizedBinaryString:!0,date:s.date,dir:s.dir,comment:s.fileCommentStr.length?s.fileCommentStr:null,unixPermissions:s.unixPermissions,dosPermissions:s.dosPermissions,createFolders:t.createFolders}),s.dir||(i.file(l).unsafeOriginalName=c)}return o.zipComment.length&&(i.comment=o.zipComment),i}))}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,i){var r=e("../utils"),o=e("../stream/GenericWorker");function n(e,t){o.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}r.inherits(n,o),n.prototype._bindStream=function(e){var t=this;(this._stream=e).pause(),e.on("data",(function(e){t.push({data:e,meta:{percent:0}})})).on("error",(function(e){t.isPaused?this.generatedError=e:t.error(e)})).on("end",(function(){t.isPaused?t._upstreamEnded=!0:t.end()}))},n.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},n.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=n},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,i){var r=e("readable-stream").Readable;function o(e,t,i){r.call(this,t),this._helper=e;var o=this;e.on("data",(function(e,t){o.push(e)||o._helper.pause(),i&&i(t)})).on("error",(function(e){o.emit("error",e)})).on("end",(function(){o.push(null)}))}e("../utils").inherits(o,r),o.prototype._read=function(){this._helper.resume()},t.exports=o},{"../utils":32,"readable-stream":16}],14:[function(e,t,i){t.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if("number"==typeof e)throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&"function"==typeof e.on&&"function"==typeof e.pause&&"function"==typeof e.resume}}},{}],15:[function(e,t,i){function r(e,t,i){var r,o=n.getTypeOf(t),s=n.extend(i||{},c);s.date=s.date||new Date,null!==s.compression&&(s.compression=s.compression.toUpperCase()),"string"==typeof s.unixPermissions&&(s.unixPermissions=parseInt(s.unixPermissions,8)),s.unixPermissions&&16384&s.unixPermissions&&(s.dir=!0),s.dosPermissions&&16&s.dosPermissions&&(s.dir=!0),s.dir&&(e=f(e)),s.createFolders&&(r=m(e))&&_.call(this,r,!0);var u="string"===o&&!1===s.binary&&!1===s.base64;i&&void 0!==i.binary||(s.binary=!u),(t instanceof l&&0===t.uncompressedSize||s.dir||!t||0===t.length)&&(s.base64=!1,s.binary=!0,t="",s.compression="STORE",o="string");var g;g=t instanceof l||t instanceof a?t:h.isNode&&h.isStream(t)?new p(e,t):n.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var v=new d(e,g,s);this.files[e]=v}var o=e("./utf8"),n=e("./utils"),a=e("./stream/GenericWorker"),s=e("./stream/StreamHelper"),c=e("./defaults"),l=e("./compressedObject"),d=e("./zipObject"),u=e("./generate"),h=e("./nodejsUtils"),p=e("./nodejs/NodejsStreamInputAdapter"),m=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},f=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},_=function(e,t){return t=void 0!==t?t:c.createFolders,e=f(e),this.files[e]||r.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function g(e){return"[object RegExp]"===Object.prototype.toString.call(e)}var v={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,i,r;for(t in this.files)r=this.files[t],(i=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(i,r)},filter:function(e){var t=[];return this.forEach((function(i,r){e(i,r)&&t.push(r)})),t},file:function(e,t,i){if(1!==arguments.length)return e=this.root+e,r.call(this,e,t,i),this;if(g(e)){var o=e;return this.filter((function(e,t){return!t.dir&&o.test(e)}))}var n=this.files[this.root+e];return n&&!n.dir?n:null},folder:function(e){if(!e)return this;if(g(e))return this.filter((function(t,i){return i.dir&&e.test(t)}));var t=this.root+e,i=_.call(this,t),r=this.clone();return r.root=i.name,r},remove:function(e){e=this.root+e;var t=this.files[e];if(t||("/"!==e.slice(-1)&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var i=this.filter((function(t,i){return i.name.slice(0,e.length)===e})),r=0;r<i.length;r++)delete this.files[i[r].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,i={};try{if((i=n.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=i.type.toLowerCase(),i.compression=i.compression.toUpperCase(),"binarystring"===i.type&&(i.type="string"),!i.type)throw new Error("No output type specified.");n.checkSupport(i.type),"darwin"!==i.platform&&"freebsd"!==i.platform&&"linux"!==i.platform&&"sunos"!==i.platform||(i.platform="UNIX"),"win32"===i.platform&&(i.platform="DOS");var r=i.comment||this.comment||"";t=u.generateWorker(this,i,r)}catch(c){(t=new a("error")).error(c)}return new s(t,i.type||"string",i.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return(e=e||{}).type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};t.exports=v},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(e,t,i){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,i){var r=e("./DataReader");function o(e){r.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(o,r),o.prototype.byteAt=function(e){return this.data[this.zero+e]},o.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),i=e.charCodeAt(1),r=e.charCodeAt(2),o=e.charCodeAt(3),n=this.length-4;0<=n;--n)if(this.data[n]===t&&this.data[n+1]===i&&this.data[n+2]===r&&this.data[n+3]===o)return n-this.zero;return-1},o.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),i=e.charCodeAt(1),r=e.charCodeAt(2),o=e.charCodeAt(3),n=this.readData(4);return t===n[0]&&i===n[1]&&r===n[2]&&o===n[3]},o.prototype.readData=function(e){if(this.checkOffset(e),0===e)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=o},{"../utils":32,"./DataReader":18}],18:[function(e,t,i){var r=e("../utils");function o(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t,i=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)i=(i<<8)+this.byteAt(t);return this.index+=e,i},readString:function(e){return r.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=o},{"../utils":32}],19:[function(e,t,i){var r=e("./Uint8ArrayReader");function o(e){r.call(this,e)}e("../utils").inherits(o,r),o.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,i){var r=e("./DataReader");function o(e){r.call(this,e)}e("../utils").inherits(o,r),o.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},o.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},o.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},o.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,t,i){var r=e("./ArrayReader");function o(e){r.call(this,e)}e("../utils").inherits(o,r),o.prototype.readData=function(e){if(this.checkOffset(e),0===e)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,i){var r=e("../utils"),o=e("../support"),n=e("./ArrayReader"),a=e("./StringReader"),s=e("./NodeBufferReader"),c=e("./Uint8ArrayReader");t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),"string"!==t||o.uint8array?"nodebuffer"===t?new s(e):o.uint8array?new c(r.transformTo("uint8array",e)):new n(r.transformTo("array",e)):new a(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,i){var r=e("./GenericWorker"),o=e("../utils");function n(e){r.call(this,"ConvertWorker to "+e),this.destType=e}o.inherits(n,r),n.prototype.processChunk=function(e){this.push({data:o.transformTo(this.destType,e.data),meta:e.meta})},t.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,i){var r=e("./GenericWorker"),o=e("../crc32");function n(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(n,r),n.prototype.processChunk=function(e){this.streamInfo.crc32=o(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,i){var r=e("../utils"),o=e("./GenericWorker");function n(e){o.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(n,o),n.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}o.prototype.processChunk.call(this,e)},t.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,i){var r=e("../utils"),o=e("./GenericWorker");function n(e){o.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then((function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()}),(function(e){t.error(e)}))}r.inherits(n,o),n.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":e=this.data.substring(this.index,t);break;case"uint8array":e=this.data.subarray(this.index,t);break;case"array":case"nodebuffer":e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,i){function r(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(pM){this.emit("error",pM)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var i=0;i<this._listeners[e].length;i++)this._listeners[e][i].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",(function(e){t.processChunk(e)})),e.on("end",(function(){t.end()})),e.on("error",(function(e){t.error(e)})),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var e=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}},t.exports=r},{}],29:[function(e,t,i){var r=e("../utils"),o=e("./ConvertWorker"),n=e("./GenericWorker"),a=e("../base64"),s=e("../support"),c=e("../external"),l=null;if(s.nodestream)try{l=e("../nodejs/NodejsStreamOutputAdapter")}catch(cM){}function d(e,t,i){var a=t;switch(t){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=t,this._mimeType=i,r.checkSupport(a),this._worker=e.pipe(new o(a)),e.lock()}catch(gM){this._worker=new n("error"),this._worker.error(gM)}}d.prototype={accumulate:function(e){return function(e,t){return new c.Promise((function(i,o){var n=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on("data",(function(e,i){n.push(e),t&&t(i)})).on("error",(function(e){n=[],o(e)})).on("end",(function(){try{var e=function(e,t,i){switch(e){case"blob":return r.newBlob(r.transformTo("arraybuffer",t),i);case"base64":return a.encode(t);default:return r.transformTo(e,t)}}(c,function(e,t){var i,r=0,o=null,n=0;for(i=0;i<t.length;i++)n+=t[i].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(o=new Uint8Array(n),i=0;i<t.length;i++)o.set(t[i],r),r+=t[i].length;return o;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(s,n),l);i(e)}catch(t){o(t)}n=[]})).resume()}))}(this,e)},on:function(e,t){var i=this;return"data"===e?this._worker.on(e,(function(e){t.call(i,e.data,e.meta)})):this._worker.on(e,(function(){r.delay(t,arguments,i)})),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(r.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new l(this,{objectMode:"nodebuffer"!==this._outputType},e)}},t.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,t,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,i.nodebuffer="undefined"!=typeof Buffer,i.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)i.blob=!1;else{var r=new ArrayBuffer(0);try{i.blob=0===new Blob([r],{type:"application/zip"}).size}catch(_M){try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(r),i.blob=0===o.getBlob("application/zip").size}catch(CR){i.blob=!1}}}try{i.nodestream=!!e("readable-stream").Readable}catch(_M){i.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,i){for(var r=e("./utils"),o=e("./support"),n=e("./nodejsUtils"),a=e("./stream/GenericWorker"),s=new Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function l(){a.call(this,"utf-8 decode"),this.leftOver=null}function d(){a.call(this,"utf-8 encode")}s[254]=s[254]=1,i.utf8encode=function(e){return o.nodebuffer?n.newBufferFrom(e,"utf-8"):function(e){var t,i,r,n,a,s=e.length,c=0;for(n=0;n<s;n++)55296==(64512&(i=e.charCodeAt(n)))&&n+1<s&&56320==(64512&(r=e.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),c+=i<128?1:i<2048?2:i<65536?3:4;for(t=o.uint8array?new Uint8Array(c):new Array(c),n=a=0;a<c;n++)55296==(64512&(i=e.charCodeAt(n)))&&n+1<s&&56320==(64512&(r=e.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(r-56320),n++),i<128?t[a++]=i:(i<2048?t[a++]=192|i>>>6:(i<65536?t[a++]=224|i>>>12:(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63),t[a++]=128|i>>>6&63),t[a++]=128|63&i);return t}(e)},i.utf8decode=function(e){return o.nodebuffer?r.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,i,o,n,a=e.length,c=new Array(2*a);for(t=i=0;t<a;)if((o=e[t++])<128)c[i++]=o;else if(4<(n=s[o]))c[i++]=65533,t+=n-1;else{for(o&=2===n?31:3===n?15:7;1<n&&t<a;)o=o<<6|63&e[t++],n--;1<n?c[i++]=65533:o<65536?c[i++]=o:(o-=65536,c[i++]=55296|o>>10&1023,c[i++]=56320|1023&o)}return c.length!==i&&(c.subarray?c=c.subarray(0,i):c.length=i),r.applyFromCharCode(c)}(e=r.transformTo(o.uint8array?"uint8array":"array",e))},r.inherits(l,a),l.prototype.processChunk=function(e){var t=r.transformTo(o.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var n=t;(t=new Uint8Array(n.length+this.leftOver.length)).set(this.leftOver,0),t.set(n,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var a=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+s[e[i]]>t?i:t}(t),c=t;a!==t.length&&(o.uint8array?(c=t.subarray(0,a),this.leftOver=t.subarray(a,t.length)):(c=t.slice(0,a),this.leftOver=t.slice(a,t.length))),this.push({data:i.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=l,r.inherits(d,a),d.prototype.processChunk=function(e){this.push({data:i.utf8encode(e.data),meta:e.meta})},i.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,i){var r=e("./support"),o=e("./base64"),n=e("./nodejsUtils"),a=e("./external");function s(e){return e}function c(e,t){for(var i=0;i<e.length;++i)t[i]=255&e.charCodeAt(i);return t}e("setimmediate"),i.newBlob=function(e,t){i.checkSupport("blob");try{return new Blob([e],{type:t})}catch(gM){try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return r.append(e),r.getBlob(t)}catch(o){throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(e,t,i){var r=[],o=0,n=e.length;if(n<=i)return String.fromCharCode.apply(null,e);for(;o<n;)"array"===t||"nodebuffer"===t?r.push(String.fromCharCode.apply(null,e.slice(o,Math.min(o+i,n)))):r.push(String.fromCharCode.apply(null,e.subarray(o,Math.min(o+i,n)))),o+=i;return r.join("")},stringifyByChar:function(e){for(var t="",i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&1===String.fromCharCode.apply(null,n.allocBuffer(1)).length}catch(e){return!1}}()}};function d(e){var t=65536,r=i.getTypeOf(e),o=!0;if("uint8array"===r?o=l.applyCanBeUsed.uint8array:"nodebuffer"===r&&(o=l.applyCanBeUsed.nodebuffer),o)for(;1<t;)try{return l.stringifyByChunk(e,r,t)}catch(n){t=Math.floor(t/2)}return l.stringifyByChar(e)}function u(e,t){for(var i=0;i<e.length;i++)t[i]=e[i];return t}i.applyFromCharCode=d;var h={};h.string={string:s,array:function(e){return c(e,new Array(e.length))},arraybuffer:function(e){return h.string.uint8array(e).buffer},uint8array:function(e){return c(e,new Uint8Array(e.length))},nodebuffer:function(e){return c(e,n.allocBuffer(e.length))}},h.array={string:d,array:s,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(e)}},h.arraybuffer={string:function(e){return d(new Uint8Array(e))},array:function(e){return u(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:s,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return n.newBufferFrom(new Uint8Array(e))}},h.uint8array={string:d,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:s,nodebuffer:function(e){return n.newBufferFrom(e)}},h.nodebuffer={string:d,array:function(e){return u(e,new Array(e.length))},arraybuffer:function(e){return h.nodebuffer.uint8array(e).buffer},uint8array:function(e){return u(e,new Uint8Array(e.length))},nodebuffer:s},i.transformTo=function(e,t){if(t=t||"",!e)return t;i.checkSupport(e);var r=i.getTypeOf(t);return h[r][e](t)},i.resolve=function(e){for(var t=e.split("/"),i=[],r=0;r<t.length;r++){var o=t[r];"."===o||""===o&&0!==r&&r!==t.length-1||(".."===o?i.pop():i.push(o))}return i.join("/")},i.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":r.nodebuffer&&n.isBuffer(e)?"nodebuffer":r.uint8array&&e instanceof Uint8Array?"uint8array":r.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(e){if(!r[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(e){var t,i,r="";for(i=0;i<(e||"").length;i++)r+="\\x"+((t=e.charCodeAt(i))<16?"0":"")+t.toString(16).toUpperCase();return r},i.delay=function(e,t,i){setImmediate((function(){e.apply(i||null,t||[])}))},i.inherits=function(e,t){function i(){}i.prototype=t.prototype,e.prototype=new i},i.extend=function(){var e,t,i={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===i[t]&&(i[t]=arguments[e][t]);return i},i.prepareContent=function(e,t,n,s,l){return a.Promise.resolve(t).then((function(e){return r.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new a.Promise((function(t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onerror=function(e){i(e.target.error)},r.readAsArrayBuffer(e)})):e})).then((function(t){var d,u=i.getTypeOf(t);return u?("arraybuffer"===u?t=i.transformTo("uint8array",t):"string"===u&&(l?t=o.decode(t):n&&!0!==s&&(t=c(d=t,r.uint8array?new Uint8Array(d.length):new Array(d.length)))),t):a.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))}))}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,t,i){var r=e("./reader/readerFor"),o=e("./utils"),n=e("./signature"),a=e("./zipEntry"),s=e("./support");function c(e){this.files=[],this.loadOptions=e}c.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(t)+", expected "+o.pretty(e)+")")}},isSignature:function(e,t){var i=this.reader.index;this.reader.setIndex(e);var r=this.reader.readString(4)===t;return this.reader.setIndex(i),r},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=s.uint8array?"uint8array":"array",i=o.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(i)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e,t,i,r=this.zip64EndOfCentralSize-44;0<r;)e=this.reader.readInt(2),t=this.reader.readInt(4),i=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(n.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(n.CENTRAL_FILE_HEADER);)(e=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(n.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,n.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(e);var t=e;if(this.checkSignature(n.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,n.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var r=t-i;if(0<r)this.isSignature(t,n.CENTRAL_FILE_HEADER)||(this.reader.zero=r);else if(r<0)throw new Error("Corrupted zip: missing "+Math.abs(r)+" bytes.")},prepareReader:function(e){this.reader=r(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},t.exports=c},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,t,i){var r=e("./reader/readerFor"),o=e("./utils"),n=e("./compressedObject"),a=e("./crc32"),s=e("./utf8"),c=e("./compressions"),l=e("./support");function d(e,t){this.options=e,this.loadOptions=t}d.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(e){var t,i;if(e.skip(22),this.fileNameLength=e.readInt(2),i=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(i),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(t=function(e){for(var t in c)if(Object.prototype.hasOwnProperty.call(c,t)&&c[t].magic===e)return c[t];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new n(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==e&&(this.dosPermissions=63&this.externalFileAttributes),3==e&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,i,r,o=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<o;)t=e.readInt(2),i=e.readInt(2),r=e.readData(i),this.extraFields[t]={id:t,length:i,value:r};e.setIndex(o)},handleUTF8:function(){var e=l.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=s.utf8decode(this.fileName),this.fileCommentStr=s.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(null!==t)this.fileNameStr=t;else{var i=o.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(i)}var r=this.findExtraFieldUnicodeComment();if(null!==r)this.fileCommentStr=r;else{var n=o.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(n)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=r(e.value);return 1!==t.readInt(1)||a(this.fileName)!==t.readInt(4)?null:s.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=r(e.value);return 1!==t.readInt(1)||a(this.fileComment)!==t.readInt(4)?null:s.utf8decode(t.readData(e.length-5))}return null}},t.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,t,i){function r(e,t,i){this.name=e,this.dir=i.dir,this.date=i.date,this.comment=i.comment,this.unixPermissions=i.unixPermissions,this.dosPermissions=i.dosPermissions,this._data=t,this._dataBinary=i.binary,this.options={compression:i.compression,compressionOptions:i.compressionOptions}}var o=e("./stream/StreamHelper"),n=e("./stream/DataWorker"),a=e("./utf8"),s=e("./compressedObject"),c=e("./stream/GenericWorker");r.prototype={internalStream:function(e){var t=null,i="string";try{if(!e)throw new Error("No output type specified.");var r="string"===(i=e.toLowerCase())||"text"===i;"binarystring"!==i&&"text"!==i||(i="string"),t=this._decompressWorker();var n=!this._dataBinary;n&&!r&&(t=t.pipe(new a.Utf8EncodeWorker)),!n&&r&&(t=t.pipe(new a.Utf8DecodeWorker))}catch(s){(t=new c("error")).error(s)}return new o(t,i,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof s&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var i=this._decompressWorker();return this._dataBinary||(i=i.pipe(new a.Utf8EncodeWorker)),s.createWorkerFrom(i,e,t)},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof c?this._data:new n(this._data)}};for(var l=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],d=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},u=0;u<l.length;u++)r.prototype[l[u]]=d;t.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,i){(function(e){var i,r,o=e.MutationObserver||e.WebKitMutationObserver;if(o){var n=0,a=new o(d),s=e.document.createTextNode("");a.observe(s,{characterData:!0}),i=function(){s.data=n=++n%2}}else if(e.setImmediate||void 0===e.MessageChannel)i="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){d(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(d,0)};else{var c=new e.MessageChannel;c.port1.onmessage=d,i=function(){c.port2.postMessage(0)}}var l=[];function d(){var e,t;r=!0;for(var i=l.length;i;){for(t=l,l=[],e=-1;++e<i;)t[e]();i=l.length}r=!1}t.exports=function(e){1!==l.push(e)||r||i()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,i){var r=e("immediate");function o(){}var n={},a=["REJECTED"],s=["FULFILLED"],c=["PENDING"];function l(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=c,this.queue=[],this.outcome=void 0,e!==o&&p(this,e)}function d(e,t,i){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof i&&(this.onRejected=i,this.callRejected=this.otherCallRejected)}function u(e,t,i){r((function(){var r;try{r=t(i)}catch(EL){return n.reject(e,EL)}r===e?n.reject(e,new TypeError("Cannot resolve promise with itself")):n.resolve(e,r)}))}function h(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function p(e,t){var i=!1;function r(t){i||(i=!0,n.reject(e,t))}function o(t){i||(i=!0,n.resolve(e,t))}var a=m((function(){t(o,r)}));"error"===a.status&&r(a.value)}function m(e,t){var i={};try{i.value=e(t),i.status="success"}catch(r){i.status="error",i.value=r}return i}(t.exports=l).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then((function(i){return t.resolve(e()).then((function(){return i}))}),(function(i){return t.resolve(e()).then((function(){throw i}))}))},l.prototype.catch=function(e){return this.then(null,e)},l.prototype.then=function(e,t){if("function"!=typeof e&&this.state===s||"function"!=typeof t&&this.state===a)return this;var i=new this.constructor(o);return this.state!==c?u(i,this.state===s?e:t,this.outcome):this.queue.push(new d(i,e,t)),i},d.prototype.callFulfilled=function(e){n.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){n.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},n.resolve=function(e,t){var i=m(h,t);if("error"===i.status)return n.reject(e,i.value);var r=i.value;if(r)p(e,r);else{e.state=s,e.outcome=t;for(var o=-1,a=e.queue.length;++o<a;)e.queue[o].callFulfilled(t)}return e},n.reject=function(e,t){e.state=a,e.outcome=t;for(var i=-1,r=e.queue.length;++i<r;)e.queue[i].callRejected(t);return e},l.resolve=function(e){return e instanceof this?e:n.resolve(new this(o),e)},l.reject=function(e){var t=new this(o);return n.reject(t,e)},l.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var i=e.length,r=!1;if(!i)return this.resolve([]);for(var a=new Array(i),s=0,c=-1,l=new this(o);++c<i;)d(e[c],c);return l;function d(e,o){t.resolve(e).then((function(e){a[o]=e,++s!==i||r||(r=!0,n.resolve(l,a))}),(function(e){r||(r=!0,n.reject(l,e))}))}},l.race=function(e){if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var t,i=e.length,r=!1;if(!i)return this.resolve([]);for(var a=-1,s=new this(o);++a<i;)t=e[a],this.resolve(t).then((function(e){r||(r=!0,n.resolve(s,e))}),(function(e){r||(r=!0,n.reject(s,e))}));return s}},{immediate:36}],38:[function(e,t,i){var r={};(0,e("./lib/utils/common").assign)(r,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,i){var r=e("./zlib/deflate"),o=e("./utils/common"),n=e("./utils/strings"),a=e("./zlib/messages"),s=e("./zlib/zstream"),c=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=o.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},e||{});var t=this.options;t.raw&&0<t.windowBits?t.windowBits=-t.windowBits:t.gzip&&0<t.windowBits&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new s,this.strm.avail_out=0;var i=r.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==i)throw new Error(a[i]);if(t.header&&r.deflateSetHeader(this.strm,t.header),t.dictionary){var d;if(d="string"==typeof t.dictionary?n.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(i=r.deflateSetDictionary(this.strm,d)))throw new Error(a[i]);this._dict_set=!0}}function d(e,t){var i=new l(t);if(i.push(e,!0),i.err)throw i.msg||a[i.err];return i.result}l.prototype.push=function(e,t){var i,a,s=this.strm,l=this.options.chunkSize;if(this.ended)return!1;a=t===~~t?t:!0===t?4:0,"string"==typeof e?s.input=n.string2buf(e):"[object ArrayBuffer]"===c.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 o.Buf8(l),s.next_out=0,s.avail_out=l),1!==(i=r.deflate(s,a))&&0!==i)return this.onEnd(i),!(this.ended=!0);0!==s.avail_out&&(0!==s.avail_in||4!==a&&2!==a)||("string"===this.options.to?this.onData(n.buf2binstring(o.shrinkBuf(s.output,s.next_out))):this.onData(o.shrinkBuf(s.output,s.next_out)))}while((0<s.avail_in||0===s.avail_out)&&1!==i);return 4===a?(i=r.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,0===i):2!==a||(this.onEnd(0),!(s.avail_out=0))},l.prototype.onData=function(e){this.chunks.push(e)},l.prototype.onEnd=function(e){0===e&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},i.Deflate=l,i.deflate=d,i.deflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},i.gzip=function(e,t){return(t=t||{}).gzip=!0,d(e,t)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,t,i){var r=e("./zlib/inflate"),o=e("./utils/common"),n=e("./utils/strings"),a=e("./zlib/constants"),s=e("./zlib/messages"),c=e("./zlib/zstream"),l=e("./zlib/gzheader"),d=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var i=r.inflateInit2(this.strm,t.windowBits);if(i!==a.Z_OK)throw new Error(s[i]);this.header=new l,r.inflateGetHeader(this.strm,this.header)}function h(e,t){var i=new u(t);if(i.push(e,!0),i.err)throw i.msg||s[i.err];return i.result}u.prototype.push=function(e,t){var i,s,c,l,u,h,p=this.strm,m=this.options.chunkSize,f=this.options.dictionary,_=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?a.Z_FINISH:a.Z_NO_FLUSH,"string"==typeof e?p.input=n.binstring2buf(e):"[object ArrayBuffer]"===d.call(e)?p.input=new Uint8Array(e):p.input=e,p.next_in=0,p.avail_in=p.input.length;do{if(0===p.avail_out&&(p.output=new o.Buf8(m),p.next_out=0,p.avail_out=m),(i=r.inflate(p,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&f&&(h="string"==typeof f?n.string2buf(f):"[object ArrayBuffer]"===d.call(f)?new Uint8Array(f):f,i=r.inflateSetDictionary(this.strm,h)),i===a.Z_BUF_ERROR&&!0===_&&(i=a.Z_OK,_=!1),i!==a.Z_STREAM_END&&i!==a.Z_OK)return this.onEnd(i),!(this.ended=!0);p.next_out&&(0!==p.avail_out&&i!==a.Z_STREAM_END&&(0!==p.avail_in||s!==a.Z_FINISH&&s!==a.Z_SYNC_FLUSH)||("string"===this.options.to?(c=n.utf8border(p.output,p.next_out),l=p.next_out-c,u=n.buf2string(p.output,c),p.next_out=l,p.avail_out=m-l,l&&o.arraySet(p.output,p.output,c,l,0),this.onData(u)):this.onData(o.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(_=!0)}while((0<p.avail_in||0===p.avail_out)&&i!==a.Z_STREAM_END);return i===a.Z_STREAM_END&&(s=a.Z_FINISH),s===a.Z_FINISH?(i=r.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===a.Z_OK):s!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(p.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===a.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},i.Inflate=u,i.inflate=h,i.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},i.ungzip=h},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,t,i){var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;i.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}}return e},i.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,i,r,o){if(t.subarray&&e.subarray)e.set(t.subarray(i,i+r),o);else for(var n=0;n<r;n++)e[o+n]=t[i+n]},flattenChunks:function(e){var t,i,r,o,n,a;for(t=r=0,i=e.length;t<i;t++)r+=e[t].length;for(a=new Uint8Array(r),t=o=0,i=e.length;t<i;t++)n=e[t],a.set(n,o),o+=n.length;return a}},n={arraySet:function(e,t,i,r,o){for(var n=0;n<r;n++)e[o+n]=t[i+n]},flattenChunks:function(e){return[].concat.apply([],e)}};i.setTyped=function(e){e?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,n))},i.setTyped(r)},{}],42:[function(e,t,i){var r=e("./common"),o=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch(lM){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(lM){n=!1}for(var a=new r.Buf8(256),s=0;s<256;s++)a[s]=252<=s?6:248<=s?5:240<=s?4:224<=s?3:192<=s?2:1;function c(e,t){if(t<65537&&(e.subarray&&n||!e.subarray&&o))return String.fromCharCode.apply(null,r.shrinkBuf(e,t));for(var i="",a=0;a<t;a++)i+=String.fromCharCode(e[a]);return i}a[254]=a[254]=1,i.string2buf=function(e){var t,i,o,n,a,s=e.length,c=0;for(n=0;n<s;n++)55296==(64512&(i=e.charCodeAt(n)))&&n+1<s&&56320==(64512&(o=e.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(o-56320),n++),c+=i<128?1:i<2048?2:i<65536?3:4;for(t=new r.Buf8(c),n=a=0;a<c;n++)55296==(64512&(i=e.charCodeAt(n)))&&n+1<s&&56320==(64512&(o=e.charCodeAt(n+1)))&&(i=65536+(i-55296<<10)+(o-56320),n++),i<128?t[a++]=i:(i<2048?t[a++]=192|i>>>6:(i<65536?t[a++]=224|i>>>12:(t[a++]=240|i>>>18,t[a++]=128|i>>>12&63),t[a++]=128|i>>>6&63),t[a++]=128|63&i);return t},i.buf2binstring=function(e){return c(e,e.length)},i.binstring2buf=function(e){for(var t=new r.Buf8(e.length),i=0,o=t.length;i<o;i++)t[i]=e.charCodeAt(i);return t},i.buf2string=function(e,t){var i,r,o,n,s=t||e.length,l=new Array(2*s);for(i=r=0;i<s;)if((o=e[i++])<128)l[r++]=o;else if(4<(n=a[o]))l[r++]=65533,i+=n-1;else{for(o&=2===n?31:3===n?15:7;1<n&&i<s;)o=o<<6|63&e[i++],n--;1<n?l[r++]=65533:o<65536?l[r++]=o:(o-=65536,l[r++]=55296|o>>10&1023,l[r++]=56320|1023&o)}return c(l,r)},i.utf8border=function(e,t){var i;for((t=t||e.length)>e.length&&(t=e.length),i=t-1;0<=i&&128==(192&e[i]);)i--;return i<0||0===i?t:i+a[e[i]]>t?i:t}},{"./common":41}],43:[function(e,t,i){t.exports=function(e,t,i,r){for(var o=65535&e,n=e>>>16&65535,a=0;0!==i;){for(i-=a=2e3<i?2e3:i;n=n+(o=o+t[r++]|0)|0,--a;);o%=65521,n%=65521}return o|n<<16}},{}],44:[function(e,t,i){t.exports={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}},{}],45:[function(e,t,i){var r=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();t.exports=function(e,t,i,o){var n=r,a=o+i;e^=-1;for(var s=o;s<a;s++)e=e>>>8^n[255&(e^t[s])];return~e}},{}],46:[function(e,t,i){var r,o=e("../utils/common"),n=e("./trees"),a=e("./adler32"),s=e("./crc32"),c=e("./messages"),l=-2,d=258,u=262,h=113;function p(e,t){return e.msg=c[t],t}function m(e){return(e<<1)-(4<e?9:0)}function f(e){for(var t=e.length;0<=--t;)e[t]=0}function _(e){var t=e.state,i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(o.arraySet(e.output,t.pending_buf,t.pending_out,i,e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))}function g(e,t){n._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,_(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function E(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function y(e,t){var i,r,o=e.max_chain_length,n=e.strstart,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-u?e.strstart-(e.w_size-u):0,l=e.window,h=e.w_mask,p=e.prev,m=e.strstart+d,f=l[n+a-1],_=l[n+a];e.prev_length>=e.good_match&&(o>>=2),s>e.lookahead&&(s=e.lookahead);do{if(l[(i=t)+a]===_&&l[i+a-1]===f&&l[i]===l[n]&&l[++i]===l[n+1]){n+=2,i++;do{}while(l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&l[++n]===l[++i]&&n<m);if(r=d-(m-n),n=m-d,a<r){if(e.match_start=t,s<=(a=r))break;f=l[n+a-1],_=l[n+a]}}}while((t=p[t&h])>c&&0!=--o);return a<=e.lookahead?a:e.lookahead}function T(e){var t,i,r,n,c,l,d,h,p,m,f=e.w_size;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=f+(f-u)){for(o.arraySet(e.window,e.window,f,f,0),e.match_start-=f,e.strstart-=f,e.block_start-=f,t=i=e.hash_size;r=e.head[--t],e.head[t]=f<=r?r-f:0,--i;);for(t=i=f;r=e.prev[--t],e.prev[t]=f<=r?r-f:0,--i;);n+=f}if(0===e.strm.avail_in)break;if(l=e.strm,d=e.window,h=e.strstart+e.lookahead,m=void 0,(p=n)<(m=l.avail_in)&&(m=p),i=0===m?0:(l.avail_in-=m,o.arraySet(d,l.input,l.next_in,m,h),1===l.state.wrap?l.adler=a(l.adler,d,m,h):2===l.state.wrap&&(l.adler=s(l.adler,d,m,h)),l.next_in+=m,l.total_in+=m,m),e.lookahead+=i,e.lookahead+e.insert>=3)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[c+3-1])&e.hash_mask,e.prev[c&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=c,c++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<u&&0!==e.strm.avail_in)}function I(e,t){for(var i,r;;){if(e.lookahead<u){if(T(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-u&&(e.match_length=y(e,i)),e.match_length>=3)if(r=n._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){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart,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 r=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}function A(e,t){for(var i,r,o;;){if(e.lookahead<u){if(T(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=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!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-u&&(e.match_length=y(e,i),e.match_length<=5&&(1===e.strategy||3===e.match_length&&4096<e.strstart-e.match_start)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){for(o=e.strstart+e.lookahead-3,r=n._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=o&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(g(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((r=n._tr_tally(e,0,e.window[e.strstart-1]))&&g(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&&(r=n._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}function b(e,t,i,r,o){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=o}function S(){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 o.Buf16(1146),this.dyn_dtree=new o.Buf16(122),this.bl_tree=new o.Buf16(78),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(16),this.heap=new o.Buf16(573),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(573),f(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 w(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:h,e.adler=2===t.wrap?0:1,t.last_flush=0,n._tr_init(t),0):p(e,l)}function R(e){var t,i=w(e);return 0===i&&((t=e.state).window_size=2*t.w_size,f(t.head),t.max_lazy_match=r[t.level].max_lazy,t.good_match=r[t.level].good_length,t.nice_match=r[t.level].nice_length,t.max_chain_length=r[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),i}function k(e,t,i,r,n,a){if(!e)return l;var s=1;if(-1===t&&(t=6),r<0?(s=0,r=-r):15<r&&(s=2,r-=16),n<1||9<n||8!==i||r<8||15<r||t<0||9<t||a<0||4<a)return p(e,l);8===r&&(r=9);var c=new S;return(e.state=c).strm=e,c.wrap=s,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=n+7,c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+3-1)/3),c.window=new o.Buf8(2*c.w_size),c.head=new o.Buf16(c.hash_size),c.prev=new o.Buf16(c.w_size),c.lit_bufsize=1<<n+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new o.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=a,c.method=i,R(e)}r=[new b(0,0,0,0,(function(e,t){var i=65535;for(i>e.pending_buf_size-5&&(i=e.pending_buf_size-5);;){if(e.lookahead<=1){if(T(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+i;if((0===e.strstart||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,g(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-u&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(g(e,!1),e.strm.avail_out),1)})),new b(4,4,8,4,I),new b(4,5,16,8,I),new b(4,6,32,32,I),new b(4,4,16,16,A),new b(8,16,32,32,A),new b(8,16,128,128,A),new b(8,32,128,256,A),new b(32,128,258,1024,A),new b(32,258,258,4096,A)],i.deflateInit=function(e,t){return k(e,t,8,15,8,0)},i.deflateInit2=k,i.deflateReset=R,i.deflateResetKeep=w,i.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?l:(e.state.gzhead=t,0):l},i.deflate=function(e,t){var i,o,a,c;if(!e||!e.state||5<t||t<0)return e?p(e,l):l;if(o=e.state,!e.output||!e.input&&0!==e.avail_in||666===o.status&&4!==t)return p(e,0===e.avail_out?-5:l);if(o.strm=e,i=o.last_flush,o.last_flush=t,42===o.status)if(2===o.wrap)e.adler=0,v(o,31),v(o,139),v(o,8),o.gzhead?(v(o,(o.gzhead.text?1:0)+(o.gzhead.hcrc?2:0)+(o.gzhead.extra?4:0)+(o.gzhead.name?8:0)+(o.gzhead.comment?16:0)),v(o,255&o.gzhead.time),v(o,o.gzhead.time>>8&255),v(o,o.gzhead.time>>16&255),v(o,o.gzhead.time>>24&255),v(o,9===o.level?2:2<=o.strategy||o.level<2?4:0),v(o,255&o.gzhead.os),o.gzhead.extra&&o.gzhead.extra.length&&(v(o,255&o.gzhead.extra.length),v(o,o.gzhead.extra.length>>8&255)),o.gzhead.hcrc&&(e.adler=s(e.adler,o.pending_buf,o.pending,0)),o.gzindex=0,o.status=69):(v(o,0),v(o,0),v(o,0),v(o,0),v(o,0),v(o,9===o.level?2:2<=o.strategy||o.level<2?4:0),v(o,3),o.status=h);else{var u=8+(o.w_bits-8<<4)<<8;u|=(2<=o.strategy||o.level<2?0:o.level<6?1:6===o.level?2:3)<<6,0!==o.strstart&&(u|=32),u+=31-u%31,o.status=h,E(o,u),0!==o.strstart&&(E(o,e.adler>>>16),E(o,65535&e.adler)),e.adler=1}if(69===o.status)if(o.gzhead.extra){for(a=o.pending;o.gzindex<(65535&o.gzhead.extra.length)&&(o.pending!==o.pending_buf_size||(o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),_(e),a=o.pending,o.pending!==o.pending_buf_size));)v(o,255&o.gzhead.extra[o.gzindex]),o.gzindex++;o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),o.gzindex===o.gzhead.extra.length&&(o.gzindex=0,o.status=73)}else o.status=73;if(73===o.status)if(o.gzhead.name){a=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),_(e),a=o.pending,o.pending===o.pending_buf_size)){c=1;break}c=o.gzindex<o.gzhead.name.length?255&o.gzhead.name.charCodeAt(o.gzindex++):0,v(o,c)}while(0!==c);o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),0===c&&(o.gzindex=0,o.status=91)}else o.status=91;if(91===o.status)if(o.gzhead.comment){a=o.pending;do{if(o.pending===o.pending_buf_size&&(o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),_(e),a=o.pending,o.pending===o.pending_buf_size)){c=1;break}c=o.gzindex<o.gzhead.comment.length?255&o.gzhead.comment.charCodeAt(o.gzindex++):0,v(o,c)}while(0!==c);o.gzhead.hcrc&&o.pending>a&&(e.adler=s(e.adler,o.pending_buf,o.pending-a,a)),0===c&&(o.status=103)}else o.status=103;if(103===o.status&&(o.gzhead.hcrc?(o.pending+2>o.pending_buf_size&&_(e),o.pending+2<=o.pending_buf_size&&(v(o,255&e.adler),v(o,e.adler>>8&255),e.adler=0,o.status=h)):o.status=h),0!==o.pending){if(_(e),0===e.avail_out)return o.last_flush=-1,0}else if(0===e.avail_in&&m(t)<=m(i)&&4!==t)return p(e,-5);if(666===o.status&&0!==e.avail_in)return p(e,-5);if(0!==e.avail_in||0!==o.lookahead||0!==t&&666!==o.status){var y=2===o.strategy?function(e,t){for(var i;;){if(0===e.lookahead&&(T(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,i=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(o,t):3===o.strategy?function(e,t){for(var i,r,o,a,s=e.window;;){if(e.lookahead<=d){if(T(e),e.lookahead<=d&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0<e.strstart&&(r=s[o=e.strstart-1])===s[++o]&&r===s[++o]&&r===s[++o]){a=e.strstart+d;do{}while(r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&r===s[++o]&&o<a);e.match_length=d-(a-o),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=n._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=n._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(g(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(g(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(g(e,!1),0===e.strm.avail_out)?1:2}(o,t):r[o.level].func(o,t);if(3!==y&&4!==y||(o.status=666),1===y||3===y)return 0===e.avail_out&&(o.last_flush=-1),0;if(2===y&&(1===t?n._tr_align(o):5!==t&&(n._tr_stored_block(o,0,0,!1),3===t&&(f(o.head),0===o.lookahead&&(o.strstart=0,o.block_start=0,o.insert=0))),_(e),0===e.avail_out))return o.last_flush=-1,0}return 4!==t?0:o.wrap<=0?1:(2===o.wrap?(v(o,255&e.adler),v(o,e.adler>>8&255),v(o,e.adler>>16&255),v(o,e.adler>>24&255),v(o,255&e.total_in),v(o,e.total_in>>8&255),v(o,e.total_in>>16&255),v(o,e.total_in>>24&255)):(E(o,e.adler>>>16),E(o,65535&e.adler)),_(e),0<o.wrap&&(o.wrap=-o.wrap),0!==o.pending?0:1)},i.deflateEnd=function(e){var t;return e&&e.state?42!==(t=e.state.status)&&69!==t&&73!==t&&91!==t&&103!==t&&t!==h&&666!==t?p(e,l):(e.state=null,t===h?p(e,-3):0):l},i.deflateSetDictionary=function(e,t){var i,r,n,s,c,d,u,h,p=t.length;if(!e||!e.state||2===(s=(i=e.state).wrap)||1===s&&42!==i.status||i.lookahead)return l;for(1===s&&(e.adler=a(e.adler,t,p,0)),i.wrap=0,p>=i.w_size&&(0===s&&(f(i.head),i.strstart=0,i.block_start=0,i.insert=0),h=new o.Buf8(i.w_size),o.arraySet(h,t,p-i.w_size,i.w_size,0),t=h,p=i.w_size),c=e.avail_in,d=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,T(i);i.lookahead>=3;){for(r=i.strstart,n=i.lookahead-2;i.ins_h=(i.ins_h<<i.hash_shift^i.window[r+3-1])&i.hash_mask,i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++,--n;);i.strstart=r,i.lookahead=2,T(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,e.next_in=d,e.input=u,e.avail_in=c,i.wrap=s,0},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,i){t.exports=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}},{}],48:[function(e,t,i){t.exports=function(e,t){var i,r,o,n,a,s,c,l,d,u,h,p,m,f,_,g,v,E,y,T,I,A,b,S,w;i=e.state,r=e.next_in,S=e.input,o=r+(e.avail_in-5),n=e.next_out,w=e.output,a=n-(t-e.avail_out),s=n+(e.avail_out-257),c=i.dmax,l=i.wsize,d=i.whave,u=i.wnext,h=i.window,p=i.hold,m=i.bits,f=i.lencode,_=i.distcode,g=(1<<i.lenbits)-1,v=(1<<i.distbits)-1;e:do{m<15&&(p+=S[r++]<<m,m+=8,p+=S[r++]<<m,m+=8),E=f[p&g];t:for(;;){if(p>>>=y=E>>>24,m-=y,0==(y=E>>>16&255))w[n++]=65535&E;else{if(!(16&y)){if(!(64&y)){E=f[(65535&E)+(p&(1<<y)-1)];continue t}if(32&y){i.mode=12;break e}e.msg="invalid literal/length code",i.mode=30;break e}T=65535&E,(y&=15)&&(m<y&&(p+=S[r++]<<m,m+=8),T+=p&(1<<y)-1,p>>>=y,m-=y),m<15&&(p+=S[r++]<<m,m+=8,p+=S[r++]<<m,m+=8),E=_[p&v];i:for(;;){if(p>>>=y=E>>>24,m-=y,!(16&(y=E>>>16&255))){if(!(64&y)){E=_[(65535&E)+(p&(1<<y)-1)];continue i}e.msg="invalid distance code",i.mode=30;break e}if(I=65535&E,m<(y&=15)&&(p+=S[r++]<<m,(m+=8)<y&&(p+=S[r++]<<m,m+=8)),c<(I+=p&(1<<y)-1)){e.msg="invalid distance too far back",i.mode=30;break e}if(p>>>=y,m-=y,(y=n-a)<I){if(d<(y=I-y)&&i.sane){e.msg="invalid distance too far back",i.mode=30;break e}if(b=h,(A=0)===u){if(A+=l-y,y<T){for(T-=y;w[n++]=h[A++],--y;);A=n-I,b=w}}else if(u<y){if(A+=l+u-y,(y-=u)<T){for(T-=y;w[n++]=h[A++],--y;);if(A=0,u<T){for(T-=y=u;w[n++]=h[A++],--y;);A=n-I,b=w}}}else if(A+=u-y,y<T){for(T-=y;w[n++]=h[A++],--y;);A=n-I,b=w}for(;2<T;)w[n++]=b[A++],w[n++]=b[A++],w[n++]=b[A++],T-=3;T&&(w[n++]=b[A++],1<T&&(w[n++]=b[A++]))}else{for(A=n-I;w[n++]=w[A++],w[n++]=w[A++],w[n++]=w[A++],2<(T-=3););T&&(w[n++]=w[A++],1<T&&(w[n++]=w[A++]))}break}}break}}while(r<o&&n<s);r-=T=m>>3,p&=(1<<(m-=T<<3))-1,e.next_in=r,e.next_out=n,e.avail_in=r<o?o-r+5:5-(r-o),e.avail_out=n<s?s-n+257:257-(n-s),i.hold=p,i.bits=m}},{}],49:[function(e,t,i){var r=e("../utils/common"),o=e("./adler32"),n=e("./crc32"),a=e("./inffast"),s=e("./inftrees"),c=-2;function l(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function d(){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 r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function u(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 r.Buf32(852),t.distcode=t.distdyn=new r.Buf32(592),t.sane=1,t.back=-1,0):c}function h(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,u(e)):c}function p(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?c:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,h(e))):c}function m(e,t){var i,r;return e?(r=new d,(e.state=r).window=null,0!==(i=p(e,t))&&(e.state=null),i):c}var f,_,g=!0;function v(e){if(g){var t;for(f=new r.Buf32(512),_=new r.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(s(1,e.lens,0,288,f,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(2,e.lens,0,32,_,0,e.work,{bits:5}),g=!1}e.lencode=f,e.lenbits=9,e.distcode=_,e.distbits=5}function E(e,t,i,o){var n,a=e.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new r.Buf8(a.wsize)),o>=a.wsize?(r.arraySet(a.window,t,i-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):(o<(n=a.wsize-a.wnext)&&(n=o),r.arraySet(a.window,t,i-o,n,a.wnext),(o-=n)?(r.arraySet(a.window,t,i-o,o,0),a.wnext=o,a.whave=a.wsize):(a.wnext+=n,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=n))),0}i.inflateReset=h,i.inflateReset2=p,i.inflateResetKeep=u,i.inflateInit=function(e){return m(e,15)},i.inflateInit2=m,i.inflate=function(e,t){var i,d,u,h,p,m,f,_,g,y,T,I,A,b,S,w,R,k,C,D,N,O,M,L,P=0,x=new r.Buf8(4),U=[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 c;12===(i=e.state).mode&&(i.mode=13),p=e.next_out,u=e.output,f=e.avail_out,h=e.next_in,d=e.input,m=e.avail_in,_=i.hold,g=i.bits,y=m,T=f,O=0;e:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;g<16;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(2&i.wrap&&35615===_){x[i.check=0]=255&_,x[1]=_>>>8&255,i.check=n(i.check,x,2,0),g=_=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&_)<<8)+(_>>8))%31){e.msg="incorrect header check",i.mode=30;break}if(8!=(15&_)){e.msg="unknown compression method",i.mode=30;break}if(g-=4,N=8+(15&(_>>>=4)),0===i.wbits)i.wbits=N;else if(N>i.wbits){e.msg="invalid window size",i.mode=30;break}i.dmax=1<<N,e.adler=i.check=1,i.mode=512&_?10:12,g=_=0;break;case 2:for(;g<16;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(i.flags=_,8!=(255&i.flags)){e.msg="unknown compression method",i.mode=30;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=30;break}i.head&&(i.head.text=_>>8&1),512&i.flags&&(x[0]=255&_,x[1]=_>>>8&255,i.check=n(i.check,x,2,0)),g=_=0,i.mode=3;case 3:for(;g<32;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.head&&(i.head.time=_),512&i.flags&&(x[0]=255&_,x[1]=_>>>8&255,x[2]=_>>>16&255,x[3]=_>>>24&255,i.check=n(i.check,x,4,0)),g=_=0,i.mode=4;case 4:for(;g<16;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.head&&(i.head.xflags=255&_,i.head.os=_>>8),512&i.flags&&(x[0]=255&_,x[1]=_>>>8&255,i.check=n(i.check,x,2,0)),g=_=0,i.mode=5;case 5:if(1024&i.flags){for(;g<16;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.length=_,i.head&&(i.head.extra_len=_),512&i.flags&&(x[0]=255&_,x[1]=_>>>8&255,i.check=n(i.check,x,2,0)),g=_=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(m<(I=i.length)&&(I=m),I&&(i.head&&(N=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),r.arraySet(i.head.extra,d,h,I,N)),512&i.flags&&(i.check=n(i.check,d,I,h)),m-=I,h+=I,i.length-=I),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===m)break e;for(I=0;N=d[h+I++],i.head&&N&&i.length<65536&&(i.head.name+=String.fromCharCode(N)),N&&I<m;);if(512&i.flags&&(i.check=n(i.check,d,I,h)),m-=I,h+=I,N)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===m)break e;for(I=0;N=d[h+I++],i.head&&N&&i.length<65536&&(i.head.comment+=String.fromCharCode(N)),N&&I<m;);if(512&i.flags&&(i.check=n(i.check,d,I,h)),m-=I,h+=I,N)break e}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;g<16;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(_!==(65535&i.check)){e.msg="header crc mismatch",i.mode=30;break}g=_=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=12;break;case 10:for(;g<32;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}e.adler=i.check=l(_),g=_=0,i.mode=11;case 11:if(0===i.havedict)return e.next_out=p,e.avail_out=f,e.next_in=h,e.avail_in=m,i.hold=_,i.bits=g,2;e.adler=i.check=1,i.mode=12;case 12:if(5===t||6===t)break e;case 13:if(i.last){_>>>=7&g,g-=7&g,i.mode=27;break}for(;g<3;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}switch(i.last=1&_,g-=1,3&(_>>>=1)){case 0:i.mode=14;break;case 1:if(v(i),i.mode=20,6!==t)break;_>>>=2,g-=2;break e;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=30}_>>>=2,g-=2;break;case 14:for(_>>>=7&g,g-=7&g;g<32;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if((65535&_)!=(_>>>16^65535)){e.msg="invalid stored block lengths",i.mode=30;break}if(i.length=65535&_,g=_=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(I=i.length){if(m<I&&(I=m),f<I&&(I=f),0===I)break e;r.arraySet(u,d,h,I,p),m-=I,h+=I,f-=I,p+=I,i.length-=I;break}i.mode=12;break;case 17:for(;g<14;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(i.nlen=257+(31&_),_>>>=5,g-=5,i.ndist=1+(31&_),_>>>=5,g-=5,i.ncode=4+(15&_),_>>>=4,g-=4,286<i.nlen||30<i.ndist){e.msg="too many length or distance symbols",i.mode=30;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;g<3;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.lens[U[i.have++]]=7&_,_>>>=3,g-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,M={bits:i.lenbits},O=s(0,i.lens,0,19,i.lencode,0,i.work,M),i.lenbits=M.bits,O){e.msg="invalid code lengths set",i.mode=30;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;w=(P=i.lencode[_&(1<<i.lenbits)-1])>>>16&255,R=65535&P,!((S=P>>>24)<=g);){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(R<16)_>>>=S,g-=S,i.lens[i.have++]=R;else{if(16===R){for(L=S+2;g<L;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(_>>>=S,g-=S,0===i.have){e.msg="invalid bit length repeat",i.mode=30;break}N=i.lens[i.have-1],I=3+(3&_),_>>>=2,g-=2}else if(17===R){for(L=S+3;g<L;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}g-=S,N=0,I=3+(7&(_>>>=S)),_>>>=3,g-=3}else{for(L=S+7;g<L;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}g-=S,N=0,I=11+(127&(_>>>=S)),_>>>=7,g-=7}if(i.have+I>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=30;break}for(;I--;)i.lens[i.have++]=N}}if(30===i.mode)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=30;break}if(i.lenbits=9,M={bits:i.lenbits},O=s(1,i.lens,0,i.nlen,i.lencode,0,i.work,M),i.lenbits=M.bits,O){e.msg="invalid literal/lengths set",i.mode=30;break}if(i.distbits=6,i.distcode=i.distdyn,M={bits:i.distbits},O=s(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,M),i.distbits=M.bits,O){e.msg="invalid distances set",i.mode=30;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(6<=m&&258<=f){e.next_out=p,e.avail_out=f,e.next_in=h,e.avail_in=m,i.hold=_,i.bits=g,a(e,T),p=e.next_out,u=e.output,f=e.avail_out,h=e.next_in,d=e.input,m=e.avail_in,_=i.hold,g=i.bits,12===i.mode&&(i.back=-1);break}for(i.back=0;w=(P=i.lencode[_&(1<<i.lenbits)-1])>>>16&255,R=65535&P,!((S=P>>>24)<=g);){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(w&&!(240&w)){for(k=S,C=w,D=R;w=(P=i.lencode[D+((_&(1<<k+C)-1)>>k)])>>>16&255,R=65535&P,!(k+(S=P>>>24)<=g);){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}_>>>=k,g-=k,i.back+=k}if(_>>>=S,g-=S,i.back+=S,i.length=R,0===w){i.mode=26;break}if(32&w){i.back=-1,i.mode=12;break}if(64&w){e.msg="invalid literal/length code",i.mode=30;break}i.extra=15&w,i.mode=22;case 22:if(i.extra){for(L=i.extra;g<L;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.length+=_&(1<<i.extra)-1,_>>>=i.extra,g-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;w=(P=i.distcode[_&(1<<i.distbits)-1])>>>16&255,R=65535&P,!((S=P>>>24)<=g);){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(!(240&w)){for(k=S,C=w,D=R;w=(P=i.distcode[D+((_&(1<<k+C)-1)>>k)])>>>16&255,R=65535&P,!(k+(S=P>>>24)<=g);){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}_>>>=k,g-=k,i.back+=k}if(_>>>=S,g-=S,i.back+=S,64&w){e.msg="invalid distance code",i.mode=30;break}i.offset=R,i.extra=15&w,i.mode=24;case 24:if(i.extra){for(L=i.extra;g<L;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}i.offset+=_&(1<<i.extra)-1,_>>>=i.extra,g-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=30;break}i.mode=25;case 25:if(0===f)break e;if(I=T-f,i.offset>I){if((I=i.offset-I)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=30;break}A=I>i.wnext?(I-=i.wnext,i.wsize-I):i.wnext-I,I>i.length&&(I=i.length),b=i.window}else b=u,A=p-i.offset,I=i.length;for(f<I&&(I=f),f-=I,i.length-=I;u[p++]=b[A++],--I;);0===i.length&&(i.mode=21);break;case 26:if(0===f)break e;u[p++]=i.length,f--,i.mode=21;break;case 27:if(i.wrap){for(;g<32;){if(0===m)break e;m--,_|=d[h++]<<g,g+=8}if(T-=f,e.total_out+=T,i.total+=T,T&&(e.adler=i.check=i.flags?n(i.check,u,T,p-T):o(i.check,u,T,p-T)),T=f,(i.flags?_:l(_))!==i.check){e.msg="incorrect data check",i.mode=30;break}g=_=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;g<32;){if(0===m)break e;m--,_+=d[h++]<<g,g+=8}if(_!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=30;break}g=_=0}i.mode=29;case 29:O=1;break e;case 30:O=-3;break e;case 31:return-4;default:return c}return e.next_out=p,e.avail_out=f,e.next_in=h,e.avail_in=m,i.hold=_,i.bits=g,(i.wsize||T!==e.avail_out&&i.mode<30&&(i.mode<27||4!==t))&&E(e,e.output,e.next_out,T-e.avail_out)?(i.mode=31,-4):(y-=e.avail_in,T-=e.avail_out,e.total_in+=y,e.total_out+=T,i.total+=T,i.wrap&&T&&(e.adler=i.check=i.flags?n(i.check,u,T,e.next_out-T):o(i.check,u,T,e.next_out-T)),e.data_type=i.bits+(i.last?64:0)+(12===i.mode?128:0)+(20===i.mode||15===i.mode?256:0),(0==y&&0===T||4===t)&&0===O&&(O=-5),O)},i.inflateEnd=function(e){if(!e||!e.state)return c;var t=e.state;return t.window&&(t.window=null),e.state=null,0},i.inflateGetHeader=function(e,t){var i;return e&&e.state&&2&(i=e.state).wrap?((i.head=t).done=!1,0):c},i.inflateSetDictionary=function(e,t){var i,r=t.length;return e&&e.state?0!==(i=e.state).wrap&&11!==i.mode?c:11===i.mode&&o(1,t,r,0)!==i.check?-3:E(e,t,r,r)?(i.mode=31,-4):(i.havedict=1,0):c},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,i){var r=e("../utils/common"),o=[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],n=[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],a=[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],s=[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];t.exports=function(e,t,i,c,l,d,u,h){var p,m,f,_,g,v,E,y,T,I=h.bits,A=0,b=0,S=0,w=0,R=0,k=0,C=0,D=0,N=0,O=0,M=null,L=0,P=new r.Buf16(16),x=new r.Buf16(16),U=null,V=0;for(A=0;A<=15;A++)P[A]=0;for(b=0;b<c;b++)P[t[i+b]]++;for(R=I,w=15;1<=w&&0===P[w];w--);if(w<R&&(R=w),0===w)return l[d++]=20971520,l[d++]=20971520,h.bits=1,0;for(S=1;S<w&&0===P[S];S++);for(R<S&&(R=S),A=D=1;A<=15;A++)if(D<<=1,(D-=P[A])<0)return-1;if(0<D&&(0===e||1!==w))return-1;for(x[1]=0,A=1;A<15;A++)x[A+1]=x[A]+P[A];for(b=0;b<c;b++)0!==t[i+b]&&(u[x[t[i+b]]++]=b);if(v=0===e?(M=U=u,19):1===e?(M=o,L-=257,U=n,V-=257,256):(M=a,U=s,-1),A=S,g=d,C=b=O=0,f=-1,_=(N=1<<(k=R))-1,1===e&&852<N||2===e&&592<N)return 1;for(;;){for(E=A-C,T=u[b]<v?(y=0,u[b]):u[b]>v?(y=U[V+u[b]],M[L+u[b]]):(y=96,0),p=1<<A-C,S=m=1<<k;l[g+(O>>C)+(m-=p)]=E<<24|y<<16|T,0!==m;);for(p=1<<A-1;O&p;)p>>=1;if(0!==p?(O&=p-1,O+=p):O=0,b++,0==--P[A]){if(A===w)break;A=t[i+u[b]]}if(R<A&&(O&_)!==f){for(0===C&&(C=R),g+=S,D=1<<(k=A-C);k+C<w&&!((D-=P[k+C])<=0);)k++,D<<=1;if(N+=1<<k,1===e&&852<N||2===e&&592<N)return 1;l[f=O&_]=R<<24|k<<16|g-d}}return 0!==O&&(l[g+O]=A-C<<24|64<<16),h.bits=R,0}},{"../utils/common":41}],51:[function(e,t,i){t.exports={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"}},{}],52:[function(e,t,i){var r=e("../utils/common");function o(e){for(var t=e.length;0<=--t;)e[t]=0}var n=256,a=286,s=30,c=15,l=[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],d=[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],u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],h=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],p=new Array(576);o(p);var m=new Array(60);o(m);var f=new Array(512);o(f);var _=new Array(256);o(_);var g=new Array(29);o(g);var v,E,y,T=new Array(s);function I(e,t,i,r,o){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=o,this.has_stree=e&&e.length}function A(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function b(e){return e<256?f[e]:f[256+(e>>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function w(e,t,i){e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,S(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)}function R(e,t,i){w(e,i[2*t],i[2*t+1])}function k(e,t){for(var i=0;i|=1&e,e>>>=1,i<<=1,0<--t;);return i>>>1}function C(e,t,i){var r,o,n=new Array(16),a=0;for(r=1;r<=c;r++)n[r]=a=a+i[r-1]<<1;for(o=0;o<=t;o++){var s=e[2*o+1];0!==s&&(e[2*o]=k(n[s]++,s))}}function D(e){var t;for(t=0;t<a;t++)e.dyn_ltree[2*t]=0;for(t=0;t<s;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 N(e){8<e.bi_valid?S(e,e.bi_buf):0<e.bi_valid&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function O(e,t,i,r){var o=2*t,n=2*i;return e[o]<e[n]||e[o]===e[n]&&r[t]<=r[i]}function M(e,t,i){for(var r=e.heap[i],o=i<<1;o<=e.heap_len&&(o<e.heap_len&&O(t,e.heap[o+1],e.heap[o],e.depth)&&o++,!O(t,r,e.heap[o],e.depth));)e.heap[i]=e.heap[o],i=o,o<<=1;e.heap[i]=r}function L(e,t,i){var r,o,a,s,c=0;if(0!==e.last_lit)for(;r=e.pending_buf[e.d_buf+2*c]<<8|e.pending_buf[e.d_buf+2*c+1],o=e.pending_buf[e.l_buf+c],c++,0===r?R(e,o,t):(R(e,(a=_[o])+n+1,t),0!==(s=l[a])&&w(e,o-=g[a],s),R(e,a=b(--r),i),0!==(s=d[a])&&w(e,r-=T[a],s)),c<e.last_lit;);R(e,256,t)}function P(e,t){var i,r,o,n=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,l=t.stat_desc.elems,d=-1;for(e.heap_len=0,e.heap_max=573,i=0;i<l;i++)0!==n[2*i]?(e.heap[++e.heap_len]=d=i,e.depth[i]=0):n[2*i+1]=0;for(;e.heap_len<2;)n[2*(o=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[o]=0,e.opt_len--,s&&(e.static_len-=a[2*o+1]);for(t.max_code=d,i=e.heap_len>>1;1<=i;i--)M(e,n,i);for(o=l;i=e.heap[1],e.heap[1]=e.heap[e.heap_len--],M(e,n,1),r=e.heap[1],e.heap[--e.heap_max]=i,e.heap[--e.heap_max]=r,n[2*o]=n[2*i]+n[2*r],e.depth[o]=(e.depth[i]>=e.depth[r]?e.depth[i]:e.depth[r])+1,n[2*i+1]=n[2*r+1]=o,e.heap[1]=o++,M(e,n,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var i,r,o,n,a,s,l=t.dyn_tree,d=t.max_code,u=t.stat_desc.static_tree,h=t.stat_desc.has_stree,p=t.stat_desc.extra_bits,m=t.stat_desc.extra_base,f=t.stat_desc.max_length,_=0;for(n=0;n<=c;n++)e.bl_count[n]=0;for(l[2*e.heap[e.heap_max]+1]=0,i=e.heap_max+1;i<573;i++)f<(n=l[2*l[2*(r=e.heap[i])+1]+1]+1)&&(n=f,_++),l[2*r+1]=n,d<r||(e.bl_count[n]++,a=0,m<=r&&(a=p[r-m]),s=l[2*r],e.opt_len+=s*(n+a),h&&(e.static_len+=s*(u[2*r+1]+a)));if(0!==_){do{for(n=f-1;0===e.bl_count[n];)n--;e.bl_count[n]--,e.bl_count[n+1]+=2,e.bl_count[f]--,_-=2}while(0<_);for(n=f;0!==n;n--)for(r=e.bl_count[n];0!==r;)d<(o=e.heap[--i])||(l[2*o+1]!==n&&(e.opt_len+=(n-l[2*o+1])*l[2*o],l[2*o+1]=n),r--)}}(e,t),C(n,d,e.bl_count)}function x(e,t,i){var r,o,n=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)o=a,a=t[2*(r+1)+1],++s<c&&o===a||(s<l?e.bl_tree[2*o]+=s:0!==o?(o!==n&&e.bl_tree[2*o]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,n=o,l=(s=0)===a?(c=138,3):o===a?(c=6,3):(c=7,4))}function U(e,t,i){var r,o,n=-1,a=t[1],s=0,c=7,l=4;for(0===a&&(c=138,l=3),r=0;r<=i;r++)if(o=a,a=t[2*(r+1)+1],!(++s<c&&o===a)){if(s<l)for(;R(e,o,e.bl_tree),0!=--s;);else 0!==o?(o!==n&&(R(e,o,e.bl_tree),s--),R(e,16,e.bl_tree),w(e,s-3,2)):s<=10?(R(e,17,e.bl_tree),w(e,s-3,3)):(R(e,18,e.bl_tree),w(e,s-11,7));n=o,l=(s=0)===a?(c=138,3):o===a?(c=6,3):(c=7,4)}}o(T);var V=!1;function F(e,t,i,o){var n,a,s;w(e,0+(o?1:0),3),a=t,s=i,N(n=e),S(n,s),S(n,~s),r.arraySet(n.pending_buf,n.window,a,s,n.pending),n.pending+=s}i._tr_init=function(e){V||(function(){var e,t,i,r,o,n=new Array(16);for(r=i=0;r<28;r++)for(g[r]=i,e=0;e<1<<l[r];e++)_[i++]=r;for(_[i-1]=r,r=o=0;r<16;r++)for(T[r]=o,e=0;e<1<<d[r];e++)f[o++]=r;for(o>>=7;r<s;r++)for(T[r]=o<<7,e=0;e<1<<d[r]-7;e++)f[256+o++]=r;for(t=0;t<=c;t++)n[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,n[8]++;for(;e<=255;)p[2*e+1]=9,e++,n[9]++;for(;e<=279;)p[2*e+1]=7,e++,n[7]++;for(;e<=287;)p[2*e+1]=8,e++,n[8]++;for(C(p,287,n),e=0;e<s;e++)m[2*e+1]=5,m[2*e]=k(e,5);v=new I(p,l,257,a,c),E=new I(m,d,0,s,c),y=new I(new Array(0),u,0,19,7)}(),V=!0),e.l_desc=new A(e.dyn_ltree,v),e.d_desc=new A(e.dyn_dtree,E),e.bl_desc=new A(e.bl_tree,y),e.bi_buf=0,e.bi_valid=0,D(e)},i._tr_stored_block=F,i._tr_flush_block=function(e,t,i,r){var o,a,s=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&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<n;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0}(e)),P(e,e.l_desc),P(e,e.d_desc),s=function(e){var t;for(x(e,e.dyn_ltree,e.l_desc.max_code),x(e,e.dyn_dtree,e.d_desc.max_code),P(e,e.bl_desc),t=18;3<=t&&0===e.bl_tree[2*h[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(e),o=e.opt_len+3+7>>>3,(a=e.static_len+3+7>>>3)<=o&&(o=a)):o=a=i+5,i+4<=o&&-1!==t?F(e,t,i,r):4===e.strategy||a===o?(w(e,2+(r?1:0),3),L(e,p,m)):(w(e,4+(r?1:0),3),function(e,t,i,r){var o;for(w(e,t-257,5),w(e,i-1,5),w(e,r-4,4),o=0;o<r;o++)w(e,e.bl_tree[2*h[o]+1],3);U(e,e.dyn_ltree,t-1),U(e,e.dyn_dtree,i-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),L(e,e.dyn_ltree,e.dyn_dtree)),D(e),r&&N(e)},i._tr_tally=function(e,t,i){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&i,e.last_lit++,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(_[i]+n+1)]++,e.dyn_dtree[2*b(t)]++),e.last_lit===e.lit_bufsize-1},i._tr_align=function(e){var t;w(e,2,3),R(e,256,p),16===(t=e).bi_valid?(S(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,t,i){t.exports=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}},{}],54:[function(e,t,i){(function(e){!function(e){if(!e.setImmediate){var t,i,r,o,n=1,a={},s=!1,c=e.document,l=Object.getPrototypeOf&&Object.getPrototypeOf(e);l=l&&l.setTimeout?l:e,t="[object process]"==={}.toString.call(e.process)?function(e){process.nextTick((function(){u(e)}))}:function(){if(e.postMessage&&!e.importScripts){var t=!0,i=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=i,t}}()?(o="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",h,!1):e.attachEvent("onmessage",h),function(t){e.postMessage(o+t,"*")}):e.MessageChannel?((r=new MessageChannel).port1.onmessage=function(e){u(e.data)},function(e){r.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(i=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){u(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):function(e){setTimeout(u,0,e)},l.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var i=new Array(arguments.length-1),r=0;r<i.length;r++)i[r]=arguments[r+1];var o={callback:e,args:i};return a[n]=o,t(n),n++},l.clearImmediate=d}function d(e){delete a[e]}function u(e){if(s)setTimeout(u,0,e);else{var t=a[e];if(t){s=!0;try{!function(e){var t=e.callback,i=e.args;switch(i.length){case 0:t();break;case 1:t(i[0]);break;case 2:t(i[0],i[1]);break;case 3:t(i[0],i[1],i[2]);break;default:t.apply(undefined,i)}}(t)}finally{d(e),s=!1}}}}function h(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(o)&&u(+t.data.slice(o.length))}}("undefined"==typeof self?void 0===e?this:e:self)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[10])(10)}))})),fR=((Fw=fR||{})[Fw.INVALID_PARAMETER=4096]="INVALID_PARAMETER",Fw[Fw.INVALID_OPERATION=4097]="INVALID_OPERATION",Fw[Fw.NOT_SUPPORTED=4098]="NOT_SUPPORTED",Fw[Fw.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",Fw[Fw.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",Fw[Fw.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",Fw[Fw.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",Fw[Fw.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",Fw[Fw.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",Fw[Fw.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",Fw[Fw.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",Fw[Fw.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",Fw[Fw.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",Fw[Fw.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",Fw[Fw.CLIENT_BANNED=16448]="CLIENT_BANNED",Fw[Fw.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",Fw[Fw.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",Fw[Fw.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",Fw[Fw.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",Fw[Fw.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",Fw[Fw.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",Fw[Fw.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",Fw[Fw.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",Fw[Fw.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",Fw[Fw.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",Fw[Fw.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",Fw[Fw.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",Fw[Fw.API_CALL_ABORTED=16461]="API_CALL_ABORTED",Fw[Fw.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",Fw[Fw.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",Fw[Fw.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",Fw[Fw.VIDEO_ENCODE_FAILED=16465]="VIDEO_ENCODE_FAILED",Fw[Fw.AUDIO_ENCODE_FAILED=16466]="AUDIO_ENCODE_FAILED",Fw[Fw.UNKNOWN=65535]="UNKNOWN",Fw),_R=fR,gR=class extends Error{constructor(e){let{name:t="RtcError",message:i,code:r=_R.UNKNOWN,extraCode:o=0,constraint:n}=e,a="<".concat(function(e){for(let t in _R)if(_R[t]===e)return t;return"UNKNOWN"}(r)," 0x").concat(r.toString(16),">"),s="".concat(i).concat(n?" constraint: ".concat(n):"").concat(null!=i&&i.includes(a)?"":" ".concat(a));super(s),aR(this,"code"),aR(this,"extraCode"),aR(this,"message"),aR(this,"originMessage"),aR(this,"name"),aR(this,"constraint"),this.code=r,this.extraCode=o,this.name=t,this.message=s,this.constraint=n,this.originMessage=i}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},vR=gR,ER=function(){return 0},yR=function(){return Date.now()+0},TR=function(){let e=new Date;return e.setTime(yR()),e.toLocaleString()},IR=function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},AR={};rR(AR,{REPORT_TYPE:()=>xD,buildSSOPackage:()=>UD,bytes2ms:()=>UC,calculateScaleResolutionDownNumber:()=>OD,concatArrayBuffers:()=>VD,convertObjectNumberToInt:()=>RD,copyProperties:()=>xC,deepClone:()=>gD,deepCloneBasic:()=>PD,deepMerge:()=>_D,delay:()=>kD,fibonacci:()=>GC,formatedTime:()=>yD,getConstructorName:()=>oD,getContainerFromElement:()=>ED,getEnv:()=>wC,getFirst16Bits:()=>BD,getInternalVersion:()=>dD,getLast16Bits:()=>FD,getLoggerUrl:()=>kC,getMediaStreamTrackInfo:()=>ND,getMuteStateFromFlag:()=>pD,getNetworkType:()=>DC,getNumNetworkType:()=>PC,getReconnectionTimeout:()=>zC,getStringByteLength:()=>AD,getTurnServer:()=>mD,getUint32Version:()=>wD,getValueType:()=>qC,getViewListFromView:()=>vD,glog:()=>HC,ipv4ToUint32:()=>fD,isArray:()=>ZC,isAudioWorkletSupported:()=>nD,isBoolean:()=>QC,isConstructor:()=>rD,isEmpty:()=>hD,isFunction:()=>KC,isLangChinese:()=>WC,isMediaStreamTrack:()=>eD,isNumber:()=>JC,isObject:()=>$C,isOverseaSdkAppId:()=>RC,isPlainObject:()=>jC,isPortrait:()=>bD,isPromise:()=>iD,isRemoteTrack:()=>tD,isRotate90Or270:()=>MD,isSetSinkIdSupported:()=>aD,isString:()=>XC,isUndefined:()=>YC,loadImage:()=>SD,loadVideo:()=>LD,ms2bytes:()=>FC,ms2samples:()=>BC,normalizeUrl:()=>DD,performanceNow:()=>cD,promiseAny:()=>sD,samples2ms:()=>VC,setNetworkTypeFromWebRTC:()=>LC,stringify:()=>TD,stringifyIncludeValue:()=>ID,throttlePromise:()=>CD});var bR={};rR(bR,{AUDIO_MUTE_BIT:()=>hk,AUDIO_STAT_BIT:()=>uk,AUX_STAT_BIT:()=>dk,AUX_STREAM_MSID:()=>gk,BACKEND_ENV:()=>ak,BASE_DOC_URL:()=>FR,BASE_HOST:()=>PR,CAPABILITIES_KEYS:()=>oC,CLASS_NAME:()=>Xk,CLOUD_CONSOLE_URL:()=>VR,CROSS_ROOM_BIT:()=>fk,DATA_FREEZE_TIMING:()=>Wk,DOC_BILLING_CN:()=>HR,DOC_BILLING_OVERSEA:()=>WR,DOC_URL:()=>BR,DTLS_STATE_UNKNOWN:()=>Rk,ENV_NAME:()=>KR,EXCHANGE_SDP_TIMEOUT:()=>Uk,IS_WORKER:()=>DR,IS_WORKLET:()=>NR,KIBANA_EVENT:()=>Lk,LOCAL_STREAM_PUBLISH_STATE:()=>Hk,LOGGER_CMD_TYPE:()=>qR,LOGGER_DOMAIN:()=>jR,LOGGER_DOMAIN_OVERSEA:()=>GR,LOG_LEVEL:()=>YR,LOG_LEVEL_NAME:()=>eC,MAIN_STREAM_MSID:()=>_k,MAX_RTT:()=>nC,MICROPHONE_COMMUNICATIONS:()=>Zk,MICROPHONE_DEFAULT:()=>Qk,MUTE_ALL_BIT:()=>mk,NAME:()=>ok,NETWORK_TYPE:()=>QR,NOT_SUPPORTED_H264:()=>Bk,PAUSED_RETRY_COUNT:()=>Jk,PEERCONNECTION_CONNECTING_TIMEOUT:()=>qk,PEER_CONNECTION_STATE:()=>kk,PEER_LEAVE_REASON:()=>tC,RECOVER_CAPTURE_INTERVAL:()=>rC,REMOTE_STREAM_TYPE_AUX:()=>Ek,REMOTE_STREAM_TYPE_MAIN:()=>vk,RENDER_FREEZE_TIMING:()=>jk,SCHEDULE_DOMAIN:()=>Kk,SCHEDULE_TIMEOUT:()=>Yk,SDP_SEMANTICS_PLAN_B:()=>Fk,SDP_SEMANTICS_UNIFIED_PLAN:()=>Vk,SECOND_HOST:()=>xR,SIGNAL_PING_PONG_INTERVAL:()=>JR,SIGNAL_PING_TIMEOUT:()=>XR,SIGNAL_RECONNECTION_COUNT:()=>Mk,SMALL_STAT_BIT:()=>lk,SPEAKER_DEFAULT:()=>$k,STORAGE_EXPIRES_TIME:()=>$R,STREAM_TYPE_BIG:()=>Gk,STREAM_TYPE_SMALL:()=>zk,SUBSCRIBE_SMALL_RETRY_COUNT:()=>iC,SYNC_USER_LIST_INTERVAL:()=>Pk,Scene:()=>sk,THIRD_HOST:()=>UR,TRANSPORT_DIRECTION:()=>nk,TRTC_ERROR_ASSISTANCE:()=>zR,TRTC_QUALITY_BAD:()=>bk,TRTC_QUALITY_DISCONNECTED:()=>wk,TRTC_QUALITY_EXCELLENT:()=>Tk,TRTC_QUALITY_GOOD:()=>Ik,TRTC_QUALITY_POOR:()=>Ak,TRTC_QUALITY_UNKNOWN:()=>yk,TRTC_QUALITY_VERY_BAD:()=>Sk,UPDATE_OFFER_TIMEOUT:()=>xk,VIDEO_MUTE_BIT:()=>pk,VIDEO_STAT_BIT:()=>ck,audioProfileMap:()=>ZR,defaultBigVideoProfile:()=>tk,defaultSmallVideoProfile:()=>ik,getRetryCount:()=>Nk,getScriptDir:()=>OR,innerVersion:()=>SR,loggerProxy:()=>MR,screenProfileMap:()=>rk,setLoggerProxy:()=>LR,setRetryCount:()=>Dk,setVersion:()=>RR,version:()=>wR,videoProfileMap:()=>ek});var SR="4.15.00.1600",wR="5.0.0";function RR(e){wR=e;let[t,i,r]=e.split(".").map((e=>parseInt(e,10)));SR="".concat(t,".").concat(Math.min(15,i),".").concat(Math.min(15,r),".").concat(i.toString().padStart(2,"0")).concat(r.toString().padStart(2,"0"))}var kR,CR,DR="undefined"!=typeof importScripts,NR="undefined"!=typeof registerProcessor,OR=()=>{let e=DR?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},MR="",LR=e=>MR=e,PR="web.sdk.qcloud.com",xR="web.sdk.tencent.cn",UR="web.sdk.cloud.tencent.cn",VR="https://console.cloud.tencent.com/trtc",FR="https://".concat(PR,"/trtc/webrtc/doc"),BR="".concat(FR,"/zh-cn/"),HR="https://cloud.tencent.com/document/product/647/85386",WR="https://trtc.io/document/56025",jR="https://yun.tim.qq.com",GR="https://apisgp.my-imcloud.com",zR="trtc_error_assistance",qR={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},KR={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},YR=((CR=YR||{})[CR.TRACE=0]="TRACE",CR[CR.DEBUG=1]="DEBUG",CR[CR.INFO=2]="INFO",CR[CR.WARN=3]="WARN",CR[CR.ERROR=4]="ERROR",CR[CR.NONE=5]="NONE",CR),XR=18e3,JR=2e3,QR={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5,"5g":6},$R=6048e5,ZR={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},ek={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},tk=ek["480p_2"],ik=ek["120p_2"],rk={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},ok={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},nk={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},ak={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},sk=((kR=sk||{}).LIVE="live",kR.RTC="rtc",kR),ck=1,lk=2,dk=4,uk=8,hk=64,pk=16,mk=112,fk=128,_k="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",gk="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",vk=ok.MAIN,Ek=ok.AUXILIARY,yk=0,Tk=1,Ik=2,Ak=3,bk=4,Sk=5,wk=6,Rk="unknown",kk={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},Ck=1/0;function Dk(e){Ck=e}function Nk(){return Ck}var Ok,Mk=30,Lk={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry",VIDEO_ENCODE_FAILED_DURING_CALL:"video-encode-failed-during-call",AUDIO_ENCODE_FAILED_DURING_CALL:"audio-encode-failed-during-call"},Pk=1e4,xk=1e4,Uk=1e4,Vk="unified-plan",Fk="plan-b",Bk=1028,Hk=((Ok=Hk||{})[Ok.UNPUBLISH=-1]="UNPUBLISH",Ok[Ok.PUBLISHING=0]="PUBLISHING",Ok[Ok.PUBLISHED=1]="PUBLISHED",Ok),Wk=500,jk=1e3,Gk=ok.BIG,zk=ok.SMALL,qk=1e4,Kk={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},Yk=2e3,Xk={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},Jk=5,Qk="default",$k=Qk,Zk="communications",eC=Object.keys(YR),tC=["normal leave","timeout leave","kick","role change"],iC=10,rC=2e3,oC=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],nC=1e4,aC=function(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{c(r.next(e))}catch(t){n(t)}}function s(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){e.done?o(e.value):function(e){return e instanceof i?e:new i((function(t){t(e)}))}(e.value).then(a,s)}c((r=r.apply(e,t||[])).next())}))},sC=Symbol(32),cC=Symbol(16),lC=Symbol(8),dC=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return aC(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,i)=>{var r;this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(e,!0)||null===(r=this.pull)||void 0===r||r.call(this,e)}))}))}readU32(){return this.read(sC)}readU16(){return this.read(cC)}readU8(){return this.read(lC)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null,t=this.buffer.subarray(this.consumed),i=0,r=e=>t.length<(i=e);if("number"==typeof this.need){if(r(this.need))return;e=t.subarray(0,i)}else if(this.need===sC){if(r(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===cC){if(r(2))return;e=t[0]<<8|t[1]}else if(this.need===lC){if(r(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(r(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,i)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(r(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,i)),e=this.need}return this.consumed+=i,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){let t=this.buffer.length,i=t+e;if(i<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,i);else{let e=new Uint8Array(i);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,i)}return this.buffer=new Uint8Array(e),this.buffer}};dC.U32=sC,dC.U16=cC,dC.U8=lC;var uC=128;function hC(e){let t=new dC;for(;e>=128;)t.malloc(1)[0]=255&e|uC,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function pC(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new dC,r=t<<3;switch(typeof e){case"boolean":let o=i.malloc(2);o[0]=r,o[1]=e?1:0;break;case"number":i.malloc(1)[0]=r,i.write(hC(e));break;case"string":i.malloc(1)[0]=2|r;let n=(new TextEncoder).encode(e);i.write(hC(n.length));let a=i.malloc(n.length);for(let e=0;e<n.length;e++)a[e]=n[e];break;case"object":let s=new dC;if(Array.isArray(e))for(let t=0;t<e.length;t++){let i=pC(e[t],t+1);i&&s.write(i)}else{let t=1;for(let i in e){let r=pC(e[i],t++);r&&s.write(r)}}0===t?s.buffer&&i.write(s.buffer):(i.malloc(1)[0]=2|r,s.buffer&&(i.write(hC(s.buffer.length)),i.write(s.buffer)))}return i.buffer||new Uint8Array(0)}var mC=class{constructor(){aR(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function fC(e,t,i){e[i]=t>>>24&255,e[i+1]=t>>>16&255,e[i+2]=t>>>8&255,e[i+3]=255&t}function _C(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function gC(e,t){return e[t]}function vC(e,t,i){return(new TextDecoder).decode(function(e,t,i){return e.slice(t,t+i)}(e,t,i))}var EC=0,yC=2654435769,TC=16,IC=2,AC=7;function bC(e,t){let i=new mC,r=function(e,t,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,uin:"",uinLen:0,reqHead:{seqNumber:i,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:r,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}(t,e,EC);EC=EC+1&2147483647,i.writeInt32(0),i.writeInt32(r.version),i.writeByte(r.encryption);let o=(new TextEncoder).encode(r.d2);i.writeInt32(o.length+4),o&&i.writeBytes(o),i.writeByte(r.uinType);let n=(new TextEncoder).encode(r.uin);i.writeInt32(n.length+4),n.length&&i.writeBytes(n);let a=new mC;a.writeInt32(0),a.writeInt32(r.reqHead.seqNumber),a.writeInt32(r.reqHead.appId),a.writeByte(r.reqHead.appId>>>24&255),a.writeByte(r.reqHead.appId>>>16&255),a.writeByte(r.reqHead.appId>>>8&255),a.writeByte(255&r.reqHead.appId);for(let v=4;v<16;v++)a.writeByte(0);let s=(new TextEncoder).encode(r.reqHead.a2);a.writeInt32(s.length+4),s.length&&a.writeBytes(s);let c=(new TextEncoder).encode(r.reqHead.serviceCmd);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);let l=(new TextEncoder).encode(r.reqHead.cookie);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);let d=(new TextEncoder).encode(r.reqHead.imei);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);let u=(new TextEncoder).encode(r.reqHead.ksid);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);let h=(new TextEncoder).encode(r.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);let p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,XC(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);let m=new Uint8Array(a.data),f=null;1===r.encryption?f=(new TextEncoder).encode(r.uin):2===r.encryption&&(f=new Uint8Array(16)),f&&(m=function(e,t){let i=e.length,r=(i+1+IC+AC)%8;r&&(r=8-r);let o=i+1+IC+AC+r,n=new Uint8Array(o),a=0,s=new Uint8Array(8),c=new Uint8Array(8),l=new Uint8Array(8),d=0;s[0]=248&Math.floor(256*Math.random())|r,d=1;for(let h=0;h<r;h++)s[d]=255&Math.floor(256*Math.random()),d+=1;for(let h=0;h<IC;)if(d<8&&(s[d]=255&Math.floor(256*Math.random()),d+=1,h+=1),8===d){SC(s,t,c,l,n,a),a+=8,d=0;for(let e=0;e<8;e++)l[e]=n[a-8+e]}let u=0;for(;u<i;)if(d<8&&(s[d]=e[u],d+=1,u+=1),8===d){SC(s,t,c,l,n,a),a+=8,d=0;for(let e=0;e<8;e++)l[e]=n[a-8+e]}for(let h=0;h<AC;)if(d<8&&(s[d]=0,d+=1,h+=1),8===d){SC(s,t,c,l,n,a),a+=8,d=0;for(let e=0;e<8;e++)l[e]=n[a-8+e]}return n}(m,f)),i.writeBytes(m);let _=new Uint8Array(i.data),g=_.length;return _[0]=g>>>24&255,_[1]=g>>>16&255,_[2]=g>>>8&255,_[3]=255&g,_}function SC(e,t,i,r,o,n){for(let a=0;a<8;a++)e[a]^=r[a];!function(e,t,i,r){let o=_C(e,0),n=_C(e,4),a=[];for(let c=0;c<4;c++)a[c]=_C(t,4*c);let s=0;for(let c=0;c<TC;c++)s+=yC,s>>>=0,o+=(n<<4)+a[0]^n+s^(n>>>5)+a[1],o>>>=0,n+=(o<<4)+a[2]^o+s^(o>>>5)+a[3],n>>>=0;fC(i,o,r),fC(i,n,r+4)}(e,t,o,n);for(let a=0;a<8;a++)o[n+a]^=i[a];for(let a=0;a<8;a++)i[a]=e[a]}var wC=function(){return new URLSearchParams(location.search).get("trtc_env")||""},RC=e=>Number(e)<14e8,kC=function(e,t){let i;i=MR||(RC(e)?GR:jR);let r=Math.floor(Math.random()*Qw(2,31));return"".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(r,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},CC="unknown";function DC(){!function(){var e;OC||(OC=!0,null==(e=navigator.connection)||e.addEventListener("typechange",NC))}();let{userAgent:e,connection:t}=navigator,i=(e.match(/NetType\/\S+/)||[])[0]||"";i=i.toLowerCase().replace("nettype/",""),"3gnet"===i&&(i="3g");let r=t&&t.type&&t.type.toLowerCase(),o=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===o&&(o="2g"),r?MC(r,o):CC}function NC(){rM.warn("netType changed",DC())}var OC=!1;function MC(e,t){if(QR[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function LC(e){CC=MC(e)}function PC(){return QR[DC()]}function xC(e,t){for(let i of Reflect.ownKeys(t))if("constructor"!==i&&"prototype"!==i&&"name"!==i){let r=Object.getOwnPropertyDescriptor(t,i)||"";Object.defineProperty(e,i,r)}return e}function UC(e){return VC(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function VC(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function FC(e){return 4*BC(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function BC(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var HC="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},WC=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},jC=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};function GC(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:GC(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function zC(e){return e>8?3e4:1e3*GC(e)}function qC(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var KC=e=>"function"==typeof e,YC=e=>void 0===e,XC=e=>"string"==typeof e,JC=e=>"number"==typeof e,QC=e=>"boolean"==typeof e,$C=e=>"object"===qC(e),ZC=e=>"array"===qC(e),eD=e=>qC(e)==="MediaStreamTrack".toLowerCase(),tD=e=>e.isRemote,iD=e=>"promise"===qC(e),rD=e=>KC(e)&&e.prototype.constructor===e,oD=e=>rD(e)?e.prototype.constructor.name:"",nD="undefined"!=typeof AudioWorkletNode,aD="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function sD(e){return new Promise(((t,i)=>{let r=[];e.forEach((o=>{o.then(t).catch((t=>{r.push(t),r.length===e.length&&i(r)}))}))}))}function cD(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var lD=e=>+e<10?"0".concat(e):e,dD=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let i=t.split("."),r=lD(i[1])+lD(i[2]);return i[1]-15>0&&(i[1]="15"),i[2]-15>0&&(i[2]="15"),"".concat(i.join("."),".").concat(r)},uD=Object.prototype.hasOwnProperty;function hD(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(jC(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(uD.call(e,t))return!1;return!0}return!1}function pD(e,t){return{userId:t,hasAudio:!!(e&uk),hasVideo:!!(e&ck),hasAuxiliary:!!(e&dk),hasSmall:!!(e&lk),audioMuted:!!(e&hk),videoMuted:!!(e&pk),audioAvailable:!(!(e&uk)||e&hk),videoAvailable:!(!(e&ck)||e&pk)}}function mD(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!YC(e.username)&&!YC(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",YC(e.credentialType)||(t.credentialType=e.credentialType)),t}function fD(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!XC(e))return 0;let i=e.split(".");return t?(Number(i[0])<<24|Number(i[1])<<16|Number(i[2])<<8|Number(i[3]))>>>0:(Number(i[3])<<24|Number(i[2])<<16|Number(i[1])<<8|Number(i[0]))>>>0}var _D=function(e,t,i,r){if(!$C(e)||!$C(t))return 0;let o,n=0,a=Object.keys(t);for(let s=0,c=a.length;s<c;s++)if(o=a[s],!(YC(t[o])||i&&i.includes(o)))if($C(e[o])&&$C(t[o]))n+=_D(e[o],t[o],i,r);else{if(r&&r.includes(t[o]))continue;e[o]!==t[o]&&(e[o]=gD(t[o]),n+=1)}return n};function gD(e){if(ZC(e)){let t=[];return e.forEach(((e,i)=>{t[i]=gD(e)})),t}if($C(e)){let t={};return Object.keys(e).forEach((i=>{t[i]=gD(e[i])})),t}return e}var vD=e=>{let t=[];if(ZC(e))t=[...e];else if(XC(e)){let i=document.getElementById(e);i&&t.push(i)}else e&&t.push(e);return t},ED=e=>XC(e)?document.getElementById(e):e,yD=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),i=e.getFullYear(),r=e.getMonth()+1,o=e.getDate(),n=t(e.getHours()),a=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(i,"/").concat(r,"/").concat(o," ").concat(n,":").concat(a,":").concat(s)})(new Date);function TD(e,t){let{keysToInclude:i,keysToExclude:r}=t;try{if(ZC(e))return"[".concat(e.map((e=>TD(e,{keysToInclude:i,keysToExclude:r}))).join(","),"]");if(!jC(e)||!ZC(i)&&!ZC(r))return JSON.stringify(e);let t={},o=new Set(i),n=new Set(r);return Object.keys(e).forEach((a=>{(0===n.size&&o.has(a)||0===o.size&&!n.has(a))&&(t[a]=jC(e[a])||ZC(e[a])?JSON.parse(TD(e[a],{keysToExclude:r,keysToInclude:i})):e[a])})),JSON.stringify(t)}catch(Ok){return"{}"}}function ID(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=[];return Object.keys(e).forEach((r=>{t===e[r]&&i.push(r)})),TD(e,{keysToInclude:i})}function AD(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var bD=()=>{var e,t,i,r;return null!=(e=window.screen)&&e.orientation?!(null==(r=null==(i=null==(t=window.screen)?void 0:t.orientation)?void 0:i.type)||!r.includes("portrait")):0===window.orientation||180===window.orientation},SD=e=>cR(void 0,null,(function*(){return new Promise(((t,i)=>{let r;if(XC(e))r=new Image,r.crossOrigin="anonymous",r.src=e;else if(r=e,r.complete)return void t(r);r.onload=()=>t(r),r.onerror=()=>{i(new vR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}))})),wD=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},RD=e=>(Object.keys(e).forEach((t=>{JC(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(jC(e[t])||ZC(e[t]))&&RD(e[t])})),e);function kD(e,t){return new Promise((i=>{let r=setTimeout(i,e);t&&t(r)}))}function CD(e,t){let i=null;return function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];return i||(i=e.apply(t||this,o),i.finally((()=>i=null)),i)}}function DD(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function ND(e){var t;try{let{width:i,height:r,frameRate:o,sampleRate:n,sampleSize:a,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),c=e.kind===ok.AUDIO?"".concat(n,"x").concat(a,"@").concat(s):"".concat(i,"x").concat(r,"@").concat(o),l=e.stats?" stats: ".concat(JSON.stringify(e.stats).replaceAll('"',"")):"";return"".concat(e.id," ").concat(e.readyState," muted:").concat(e.muted," ").concat(e.kind," ").concat(e.label," ").concat(c).concat(l)}catch(kR){return""}}function OD(e,t){return e.width*e.height==t.width*t.height?1:bD()&&t.width>t.height&&e.height>t.width?Math.max(e.width/t.height,e.height/t.width,1):Math.max(e.width/t.width,e.height/t.height,1)}function MD(e){return 90===e||270===e}function LD(e){return cR(this,null,(function*(){return new Promise(((t,i)=>{let r=document.createElement("video");r.crossOrigin="anonymous",r.src=e,r.muted=!0,r.loop=!0,r.playsInline=!0,r.play().then((()=>t(r))),r.onerror=()=>{i(r.error)}}))}))}function PD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let i=[];return t.set(e,i),e.forEach(((e,r)=>{i[r]=PD(e,t)})),i}if("[object Object]"===Object.prototype.toString.call(e)){let i={};return t.set(e,i),Reflect.ownKeys(e).forEach((r=>{i[r]=PD(e[r],t)})),i}return e}var xD=(e=>(e[e.END_REPORT=2001]="END_REPORT",e[e.LOG=2002]="LOG",e[e.KEY_METRIC_REPORT=2003]="KEY_METRIC_REPORT",e))(xD||{});function UD(e,t,i,r){try{let o=function(e,t,i,r){let o={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:i};return YC(r)||(o=eR(Zw({},o),{gzip:+r})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}(e,t,i,r);return bC(pC(o),i)}catch(pM){return JSON.stringify(e)}}function VD(e,t){let i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e),0),i.set(new Uint8Array(t),e.byteLength),i.buffer}function FD(e){return(65535&e)>>>0}function BD(e){return(4294901760&e)>>>0}function HD(e){let t=function(e){try{let t={},i=0;t.totalLength=_C(e,i),i+=4,t.version=_C(e,i),i+=4,t.encryption=gC(e,i),i+=1,t.uinType=gC(e,i),i+=1,t.uinLength=_C(e,i),i+=4,t.uin=t.uinLength>4?vC(e,i,t.uinLength-4):"",i+=t.uinLength-4;let r=e.slice(i);if(2===t.encryption){e=function(e,t){let i=0,r=new Uint8Array(8).fill(0),o=new Uint8Array(e.slice(0,8)),n=WD(o,t),a=7&n[0],s=e.length-1-a-IC-AC,c=new Uint8Array(s),l=0,d=r,u=e.slice(0,8);i=8;let h=1;h+=a;for(let m=1;m<=IC;)if(h<8)h++,m++;else if(8===h){let r=jD(e,i,d,u,n,t);d=r.ivPreCrypt,u=r.ivCurCrypt,n=r.debiBuf,i=r.bufPos,h=0}let p=s;for(;p>0;)if(h<8)c[l++]=n[h]^d[h],h++,p--;else if(8===h){let r=jD(e,i,d,u,n,t);d=r.ivPreCrypt,u=r.ivCurCrypt,n=r.debiBuf,i=r.bufPos,h=0}for(let m=1;m<=AC;)if(h<8)n[h],d[h],h++,m++;else if(8===h){if(i>=e.length)break;let r=jD(e,i,d,u,n,t);if(!r.success)break;d=r.ivPreCrypt,u=r.ivCurCrypt,n=r.debiBuf,i=r.bufPos,h=0}return c}(r,new Uint8Array(16).fill(0)),t.decrypted=!0,i=0}else e=r,i=0;return t.rspHeadLength=_C(e,i),i+=4,t.seqNo=_C(e,i),i+=4,t.retCode=_C(e,i),i+=4,t.retStrLength=_C(e,i),i+=4,t.retStr=t.retStrLength?vC(e,i,t.retStrLength-4):"",i+=t.retStrLength-4,t.serviceCmdLength=_C(e,i),i+=4,t.serviceCmd=t.serviceCmdLength?vC(e,i,t.serviceCmdLength-4):"",i+=t.serviceCmdLength-4,t.cookieLength=_C(e,i),i+=4,t.cookie=t.cookieLength?vC(e,i,t.cookieLength-4):"",i+=t.cookieLength-4,t.flag=_C(e,i),i+=4,t.busiBuffLength=_C(e,i),i+=4,t.busiBuff=t.busiBuffLength?vC(e,i,t.busiBuffLength-4):"",i+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function WD(e,t){let i=e[0]<<24|e[1]<<16|e[2]<<8|e[3],r=e[4]<<24|e[5]<<16|e[6]<<8|e[7];i>>>=0,r>>>=0;let o=yC*TC>>>0;for(let n=0;n<TC;n++)r-=(i<<4)+t[2]^i+o^(i>>>5)+t[3],r>>>=0,i-=(r<<4)+t[0]^r+o^(r>>>5)+t[1],i>>>=0,o-=yC,o>>>=0;return new Uint8Array([i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}function jD(e,t,i,r,o,n){if(t+8>e.length)return{success:!1};let a=new Uint8Array(r),s=e.slice(t,t+8),c=new Uint8Array(8);for(let l=0;l<8;l++)c[l]=o[l]^s[l];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:WD(c,n),bufPos:t+8}}var GD="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function zD(e){let{url:t,body:i,method:r="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:r,body:i,priority:n}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:HD(new Uint8Array(e))||(GD?GD.decode(e):e)}))))))).then(e,a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(fM){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(r,t,!0),s.send(i)}))}function qD(e){return cR(this,null,(function*(){let t=cD(),i=JSON.stringify(e);try{if(!CompressionStream||i.length<=2800)return i;let e=new Blob([i],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),r=yield(yield(yield new Response(e)).blob()).arrayBuffer();return rM.debug("compressJSON ".concat(i.length," -> ").concat(r.byteLength," ").concat(cD()-t,"ms")),r}catch(Ok){return i}}))}var KD=Object.prototype.hasOwnProperty,YD=e=>"function"==typeof e,XD=e=>void 0===e,JD=e=>e.isRemote,QD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)};var $D=function(e){let{retryFunction:t,settings:i,onError:r,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:d=5,timeout:u=1e3}=i,h=0,p=-1,m=0,f=(e,i)=>cR(this,null,(function*(){let l=s||this;try{let i=yield t.apply(l,c);h>0&&a&&a.call(this,h),h=0,e(i)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,i(_)},a=()=>{2!==m&&h<(YD(d)?d():d)?(h++,m=1,YD(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,i)}),YD(u)?u(h):u)):(t(),YD(n)&&n.call(this,_))};YD(r)?r.call(this,{error:_,retry:a,reject:i,retryFuncArgs:c,retriedCount:h}):a()}}));return new Promise(f)}},ZD=class e{constructor(e){aR(this,"_parentPath"),aR(this,"userId"),aR(this,"remoteUserId"),aR(this,"id"),aR(this,"sdkAppId"),aR(this,"type"),aR(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!(e=>"boolean"==typeof e)(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}createChild(t){let i=new e({id:t.id,userId:XD(t.userId)?this.userId:t.userId,sdkAppId:XD(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:XD(t.type)?this.type:t.type,isLocal:XD(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:XD(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return i.bindParent(this),i}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let i=this.isLocal?this.userId:this.remoteUserId,r=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(r).concat(i?"|".concat(i):"","]")),rM.log(e,t,XD(this.userId)||function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(QD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(KD.call(e,t))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}},eN={};rR(eN,{ANDROID_VERSION:()=>pN,CHROME_MAJOR_VERSION:()=>vO,CHROME_VERSION:()=>EO,EDGE_VERSION:()=>yN,EDG_MAJOR_VERSION:()=>AN,EDG_VERSION:()=>IN,ELECTRON_MAJOR_VERSION:()=>yO,FIREFOX_MAJOR_VERSION:()=>vN,FIREFOX_VERSION:()=>gN,HUAWEI_VERSION:()=>oO,IE_VERSION:()=>LN,IOS_MAIN_VERSION:()=>kO,IOS_VERSION:()=>SO,IPADQQB_VERSION:()=>zN,IS_ANDROID:()=>hN,IS_ANDROID_WEBVIEW:()=>bO,IS_ANY_SAFARI:()=>IO,IS_CHROME:()=>_O,IS_CHROME_OS:()=>XN,IS_CHROMIUM_BASE:()=>fO,IS_DESKTOP_IOS_CHROME:()=>OO,IS_EDG:()=>TN,IS_EDGE:()=>EN,IS_ELECTRON:()=>$N,IS_FIREFOX:()=>_N,IS_HEADLESS_CHROME:()=>gO,IS_HONOR:()=>rO,IS_HUAWEI:()=>iO,IS_HUAWEIBROWSER:()=>tO,IS_IE:()=>MN,IS_IE8:()=>ON,IS_IOS:()=>uN,IS_IOS_13_OR_14:()=>NO,IS_IOS_15_1:()=>DO,IS_IOS_CHROME:()=>mO,IS_IPAD:()=>sN,IS_IPADQQB:()=>GN,IS_IPAD_PRO:()=>cN,IS_IPHONE:()=>lN,IS_IPOD:()=>dN,IS_LINUX:()=>YN,IS_LOCAL:()=>MO,IS_MAC:()=>KN,IS_MACQQB:()=>WN,IS_MIBROWSER:()=>ZN,IS_MQQB:()=>VN,IS_NATIVE_ANDROID:()=>fN,IS_OLD_ANDROID:()=>mN,IS_OPENHARMONY:()=>uO,IS_OPPOBROWSER:()=>sO,IS_SAFARI:()=>TO,IS_SAFARI_15_1:()=>CO,IS_SAMSUNGBROWSER:()=>nO,IS_SOGOU:()=>wN,IS_SOGOUM:()=>bN,IS_TBS:()=>kN,IS_UCBROWSER:()=>QN,IS_VIVOBROWSER:()=>lO,IS_WECHAT:()=>PN,IS_WIN:()=>qN,IS_WQQB:()=>BN,IS_WX:()=>JN,IS_X5MQQB:()=>UN,IS_XWEB:()=>DN,MACQQB_VERSION:()=>jN,MI_VERSION:()=>eO,MQQB_VERSION:()=>FN,OPENHARMONY_VERSION:()=>hO,OPPO_VERSION:()=>cO,SAFARI_VERSION:()=>AO,SAMSUNG_VERSION:()=>aO,SOGOUM_VERSION:()=>SN,SOGOU_VERSION:()=>RN,TBS_VERSION:()=>CN,UA_DATA_STRING:()=>FO,USER_AGENT:()=>tN,VIVO_VERSION:()=>dO,WECHAT_VERSION:()=>xN,WQQB_VERSION:()=>HN,XWEB_VERSION:()=>NN,browserInfo:()=>PO,getBrowserCoreNumber:()=>KO,getBrowserInfo:()=>xO,getChromeMajorVersion:()=>pO,getDeviceModel:()=>WO,getDeviceModelFromUA:()=>jO,getGPUInfo:()=>HO,getOSName:()=>zO,getOSNumber:()=>qO,getOSString:()=>YO,getOSType:()=>JO,getTerminalType:()=>XO,getUserAgentData:()=>BO,isLocalStorageEnabled:()=>LO,isMobile:()=>VO,isVersionLargerThan:()=>RO,isVersionSmallerThan:()=>wO});var tN="undefined"==typeof navigator?"":navigator.userAgent,iN=e=>new RegExp(e,"i").test(tN),rN=e=>{if(iN(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=tN.match(t);if(i&&i[1])return i[1]}return""},oN=e=>{if(iN(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=tN.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},nN=/AppleWebKit\/([\d.]+)/i.exec(tN),aN=nN?parseFloat(nN[1]):NaN,sN=iN("iPad"),cN="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&iN("Macintosh"),lN=iN("iPhone")&&!sN,dN=iN("iPod"),uN=lN||sN||dN||cN,hN=iN("Android"),pN=function(){if(hN){let e=tN.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),mN=hN&&iN("webkit")&&pN<2.3,fN=hN&&pN<5&&aN<537,_N=iN("Firefox"),gN=rN("Firefox"),vN=oN("Firefox"),EN=iN("Edge"),yN=rN("Edge"),TN=iN("Edg"),IN=rN("Edg"),AN=oN("Edg"),bN=iN("SogouMobileBrowser"),SN=rN("SogouMobileBrowser"),wN=iN("MetaSr\\s"),RN=rN("MetaSr\\s"),kN=iN("TBS"),CN=rN("TBS"),DN=iN("XWEB"),NN=rN("XWEB"),ON=iN("MSIE\\s8\\.0"),MN=iN("MSIE\\/\\d+"),LN=function(){if(MN){let e=/MSIE\s(\d+)\.\d/.exec(tN),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(tN)&&/rv:11.0/.test(tN)&&(t=11),t}return NaN}(),PN=iN("(micromessenger|webbrowser)"),xN=rN("MicroMessenger"),UN=!kN&&iN("MQQBrowser")&&iN("COVC"),VN=!kN&&iN("MQQBrowser")&&!iN("COVC"),FN=VN||UN?rN("MQQBrowser"):"",BN=!kN&&iN(" QQBrowser"),HN=rN(" QQBrowser"),WN=!kN&&iN("QQBrowserLite"),jN=rN("QQBrowserLite"),GN=!kN&&iN("MQBHD"),zN=rN("MQBHD"),qN=iN("Windows"),KN=!uN&&iN("MAC OS X"),YN=!hN&&iN("Linux"),XN=iN("CrOS"),JN=iN("MicroMessenger"),QN=iN("UCBrowser"),$N=iN("Electron"),ZN=iN("MiuiBrowser"),eO=rN("MiuiBrowser"),tO=iN("HuaweiBrowser"),iO=iN("Huawei")||iN("HUAWEI"),rO=iN("Honor")||iN("HONOR"),oO=rN("HuaweiBrowser"),nO=iN("SamsungBrowser"),aO=rN("SamsungBrowser"),sO=iN("HeyTapBrowser"),cO=rN("HeyTapBrowser"),lO=iN("VivoBrowser"),dO=rN("VivoBrowser"),uO=iN("OpenHarmony"),hO=rN("OpenHarmony"),pO=()=>oN("Chrome"),mO=iN("CriOS"),fO=iN("Chrome"),_O=!EN&&!wN&&!bN&&!kN&&!DN&&!TN&&!BN&&!ZN&&!tO&&!nO&&!sO&&!lO&&fO,gO=iN("HeadlessChrome"),vO=pO(),EO=rN("Chrome"),yO=oN("Electron"),TO=!fO&&!VN&&!UN&&!WN&&!GN&&iN("Safari"),IO=TO||uN,AO=rN("Version"),bO=/Android.*(wv|.0.0.0)/.test(tN),SO=(()=>{if(cN)return AO;if(uN){let e=tN.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function wO(e,t){let i=e.split(".").map((e=>Number(e))),r=t.split(".").map((e=>Number(e)));for(let o=0;o<Math.max(i.length,r.length);o++){let e=i[o]||0,t=r[o]||0;if(e<t)return!0;if(e>t)return!1}return!1}function RO(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=e.split(".").map((e=>Number(e))),o=t.split(".").map((e=>Number(e)));for(let n=0;n<Math.max(r.length,o.length);n++){let e=r[n]||0,t=o[n]||0;if(e>t)return!0;if(e<t)return!1}return i}var kO=Number(SO.split(".")[0]),CO="15.1"===AO,DO="15.1"===SO,NO=(()=>{let e=Number(SO.split(".")[0]);return 14===e||13===e})(),OO=mO&&"11.1.1"===AO,MO="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),LO=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(uM){e=!1}return e}})(),PO=xO();function xO(){let e=new Map([[_N,["Firefox",gN]],[TN,["Edg",IN]],[_O,["Chrome",EO]],[mO,["ChiOS",rN("CriOS")]],[TO&&!mO,["Safari",AO]],[kN,["TBS",CN]],[DN,["XWEB",NN]],[PN&&lN,["WeChat",xN]],[BN,["QQ(Win)",HN]],[VN,["QQ(Mobile)",FN]],[UN,["QQ(Mobile X5)",FN]],[WN,["QQ(Mac)",jN]],[GN,["QQ(iPad)",zN]],[ZN,["MI",eO]],[tO,["HW",oO]],[nO,["Samsung",aO]],[sO,["OPPO",cO]],[lO,["VIVO",dO]],[EN,["EDGE",yN]],[bN,["SogouMobile",SN]],[wN,["Sogou",RN]]]),t="unknown",i="unknown";return e.has(!0)&&([t,i]=e.get(!0)),{name:t,version:i}}var UO=null;function VO(){return UO&&"boolean"==typeof UO.mobile?UO.mobile:hN||uN||lN||sN||uO}var FO="";function BO(){return cR(this,null,(function*(){if(UO)return UO;if(!navigator.userAgentData||"function"!=typeof navigator.userAgentData.getHighEntropyValues)return null;try{return(UO=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]))&&!FO&&(FO="UAData: ".concat(UO.platform,"/").concat(UO.platformVersion),UO.architecture&&UO.bitness&&(FO+=" ".concat(UO.architecture,"/").concat(UO.bitness)),UO.mobile&&(FO+=" mobile"),UO.model&&(FO+=" model: ".concat(UO.model.replace(/\s+/g,"/"))),UO.fullVersionList&&(FO+=" ".concat(UO.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(",")))),UO}catch(Vw){return null}}))}function HO(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return"";let i=t.getExtension("WEBGL_debug_renderer_info");if(i){let e=t.getParameter(i.UNMASKED_VENDOR_WEBGL),r=t.getParameter(i.UNMASKED_RENDERER_WEBGL);return"".concat(e," ").concat(r)}return""}catch(Vw){return""}}function WO(){return(null==UO?void 0:UO.model)||jO()||""}function jO(){let e=tN.match(/;\s*([^;)]+)\s+Build\//);return null!=e&&e[1]?e[1].trim():null}var GO=new Map([[hN,"Android"],[uN,"iOS"],[qN,"Windows"],[KN,"MacOS"],[YN,"Linux"],[XN,"ChromeOS"]]),zO=function(){return GO.get(!0)?GO.get(!0):UO?UO.platform:"unknown"};function qO(){return qN?1:hN?2:KN?3:uN?4:YN?5:XN?6:uO?7:0}function KO(){return PN||DN?4:fO?1:TO?2:_N?3:0}var YO=()=>{let e=zO();return null!=UO&&UO.platformVersion?e+="/".concat(UO.platformVersion):uN?e+="/".concat(SO):hN&&(e+="/".concat(pN)),e+="/".concat(PO.name,"/").concat(TO&&!mO?PO.version:PO.version.split(".")[0]),null!=UO&&UO.architecture&&(e+="/".concat(UO.architecture)),e};function XO(){return hN?4:lN?2:sN?3:KN?12:qN?5:YN?13:uO?22:1}function JO(){return hN?"Android":lN?"iPhone":sN?"iPad":KN?"Mac":qN?"Windows":YN?"Linux":"unknown"}var QO,$O=new(oR(lR(),1).default),ZO=((QO=ZO||{}).ROOM_DESTROY="1",QO.JOIN_START="21",QO.JOIN_SCHEDULE_SUCCESS="22",QO.JOIN_SIGNAL_CONNECTION_START="23",QO.JOIN_SIGNAL_CONNECTION_END="24",QO.JOIN_SEND_CMD="25",QO.JOIN_RECEIVED_CMD_RES="26",QO.JOIN_SUCCESS="27",QO.JOIN_FAILED="28",QO.LEAVE_START="51",QO.LEAVE_SEND_CMD="52",QO.LEAVE_SUCCESS="53",QO.PUBLISH_START="61",QO.SEND_FIRST_VIDEO_FRAME="62",QO.PUBLISH_FAILED="63",QO.SUBSCRIBE_START="81",QO.SUBSCRIBE_SUCCESS="82",QO.SUBSCRIBE_FAILED="84",QO.UNSUBSCRIBE_SUCCESS="83",QO.LOCAL_TRACK_CAPTURE_START="101",QO.LOCAL_TRACK_CAPTURE_SUCCESS="102",QO.LOCAL_TRACK_CAPTURE_FAILED="103",QO.LOCAL_TRACK_PUBLISHED="104",QO.LOCAL_TRACK_UNPUBLISHED="105",QO.LOCAL_TRACK_REPLACED="106",QO.SWITCH_DEVICE_SUCCESS="107",QO.TRACK_MUTED="108",QO.TRACK_UNMUTED="109",QO.REMOTE_TRACK_SUBSCRIBED="110",QO.REMOTE_TRACK_UNSUBSCRIBED="111",QO.LOCAL_TRACK_RECAPTURE="112",QO.LOCAL_AUDIO_STARTED="113",QO.LOCAL_AUDIO_STOPPED="114",QO.REMOTE_AUDIO_STARTED="115",QO.REMOTE_AUDIO_STOPPED="116",QO.PLAY_TRACK_START="151",QO.PLAYER_STATE_CHANGED="152",QO.VIDEO_LOADED_DATA="153",QO.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",QO.AUDIO_CONTEXT_LONG_SUSPENDED="155",QO.REMOTE_VIDEO_PLAY_START="156",QO.REMOTE_VIDEO_PLAY_FINISH="157",QO.SIGNAL_CONNECTION_STATE_CHANGED="201",QO.PEER_CONNECTION_STATE_CHANGED="202",QO.SINGLE_CONNECTION_STAT="203",QO.SPC_RECONNECTED="204",QO.HEARTBEAT_REPORT="251",QO.RECEIVED_PUBLISHED_USER_LIST="252",QO.REMOTE_PUBLISH_STATE_CHANGED="253",QO.AUDIO_LEVEL_INTERVAL="260",QO.NETWORK_QUALITY="261",QO.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",QO.QUALITY_LIMITATION_CHANGED="263",QO.LOG="264",QO.AUDIO_PROCESSOR_DEBUG="265",QO.SSO_SWITCH="266",QO.SWITCH_ROOM_START="401",QO.SWITCH_ROOM_SUCCESS="407",QO.SWITCH_ROOM_FAILED="408",QO),eM=ZO,tM=new class{constructor(){aR(this,"enable",!1),aR(this,"ssoFailCount",0),$O.on("22",(e=>{let{schedule:t}=e;var i;null!=(i=null==t?void 0:t.config)&&i.sso&&$O.emit("266",{enable:!0})})),$O.on("266",(e=>{let{enable:t}=e;this.enable=t}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&$O.emit("266",{enable:!1})}},iM=class e{constructor(){aR(this,"_isEnableUploadLog",!0),aR(this,"_localJoinedUser",new Map),aR(this,"_queue",[]),aR(this,"_timeoutId",-1),aR(this,"_logLevel",1),aR(this,"_logLevelToUpload",2),!DR&&!NR&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){$O.on(eM.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;null!=(i=null==t?void 0:t.config)&&i.logLevelToUpload&&YR[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),$O.on(eM.JOIN_START,(e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),$O.on(eM.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:r,sdkAppId:o}=t;e.map.has(r)?e.map.get(r).logs.push(i):e.map.set(r,{userId:r,sdkAppId:o,logs:[i]})}));else if(XC(i.userId)&&JC(i.sdkAppId)){let{userId:t,sdkAppId:r}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:r,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return cR(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:r,logs:o}=t[e],n={timestamp:TR(),sdkAppId:String(r),userId:i,version:wR,log:o.map((e=>e.log)).join("\n")},a=JSON.stringify(n),s=tM.enable?UD(n,2002,r):a;yield this.uploadLogWithRetry(s,r,s instanceof Uint8Array,a),o.forEach((e=>e.uploaded=!0))}}catch(pM){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t,i,r){return $D({retryFunction:()=>zD({url:kC(t,qR.LOG),body:e,timeout:5e3,priority:"low"}).then((e=>{i&&"ok"!==e.data&&(tM.handleUploadFailed(),this.uploadLogWithRetry(r,t,!1,r))})),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(yR()),"[".concat(IR(t),"] <").concat(YR[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){YC(YR[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(XC(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(kR){return""}}addLogToQueue(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n={log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:r,sdkAppId:o,forAllJoinedClients:i};$O.emit(eM.LOG,{log:n}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(n)}log(t,i){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;if(i.unshift(this.getPrefix(t)),this.addLogToQueue(t,i,r,o,n),t<this._logLevel)return;let s=(null==(a=YR[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...i):console[s](...i)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){if(e.parent instanceof ZD){let t=e,{parent:i}=t,r=((e,t)=>{var i={};for(var r in e)Yw.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&qw)for(var r of qw(e))t.indexOf(r)<0&&Xw.call(e,r)&&(i[r]=e[r]);return i})(t,["parent"]),o=new ZD(r);return o.bindParent(i),o}return new ZD(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;YR[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};aR(iM,"PRINT_LOG_TAG",!(uN||hN||gO));var rM=new iM,oM=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},nM=new class{constructor(){aR(this,"_prefix","TRTC"),aR(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){LO()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix))try{let t=localStorage.getItem(e);if(!t)return!1;let i=JSON.parse(t);if(i&&i.expiresIn<Date.now())return!0}catch(pM){return!1}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(LO())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(uM){rM.warn(uM)}}getItem(e){if(!LO())return null;try{let t=localStorage.getItem(this.getRealKey(e));if(!t)return null;let i=JSON.parse(t);return i&&i.expiresIn>=Date.now()?i.value:null}catch(kR){rM.warn(kR)}}setItem(e,t){if(LO())try{let i={expiresIn:Date.now()+$R,value:t};this._queue.set(this.getRealKey(e),i)}catch(Ok){rM.warn(Ok)}}deleteItem(e){if(!LO())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(kR){return rM.warn(kR),!1}}clear(){if(LO())try{localStorage.clear()}catch(uM){rM.warn(uM)}}},aM={};rR(aM,{HTTPS_API:()=>YL,IS_GET_CAPABILITIES_FROM_INPUTDEVICE_SUPPORTED:()=>_P,IS_GET_CAPABILITIES_SUPPORTED:()=>fP,IS_GET_SETTINGS_SUPPORTED:()=>mP,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>pP,IS_INSERTABLE_STREAM_SUPPORTED:()=>gP,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>DP,IS_RTC_RTP_SENDER_SUPPORTED:()=>dP,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>vP,IS_SEI_SUPPORTED:()=>EP,IS_SPC_SUPPORTED:()=>cP,basis:()=>SP,capabilityCheck:()=>kP,checkSystemRequirementsInternal:()=>WL,decodeSupportStatus:()=>HL,detectVideoCodecCapabilities:()=>MP,detectVideoDecoderCapabilities:()=>PP,detectVideoEncoderCapabilities:()=>LP,encodeSupportStatus:()=>BL,getBrowserInfo:()=>OL,getDisplayResolution:()=>JL,getH264ProfileLevelIds:()=>xP,isAddTransceiverSupported:()=>sP,isBrowserSupported:()=>ML,isCanvasCaptureStreamAPISupported:()=>ZL,isCanvasSmallStreamSupported:()=>eP,isGetReceiversSupported:()=>oP,isGetSendersSupported:()=>nP,isGetTransceiversSupported:()=>aP,isGetUserMediaSupported:()=>QL,isMediaDevicesSupported:()=>PL,isMediaSessionSupported:()=>IP,isMediaStreamTrackGeneratorSupported:()=>FL,isMediaStreamTrackProcessorSupported:()=>VL,isReplaceTrackSupported:()=>uP,isRequestVideoFrameCallbackSupported:()=>CP,isSIMDSupported:()=>bP,isScaleResolutionDownBySupported:()=>tP,isScreenCaptureApiAvailable:()=>GL,isSelectedCandidatePair:()=>XL,isSetParametersSupported:()=>hP,isSetSinkIdSupported:()=>zL,isSmallStreamSupported:()=>iP,isStopTransceiverSupported:()=>lP,isTRTCSupported:()=>jL,isUnifiedPlanDefault:()=>rP,isUsedInHttpProtocol:()=>UL,isWebAudioSupported:()=>$L,isWebCodecSupported:()=>TP,isWebCodecsSupported:()=>LL,isWebRTCSupported:()=>yP,isWebTransportSupported:()=>AP});var sM={};rR(sM,{AUDIO_LEVEL_SCALE:()=>ZM,AlphaStitchingType:()=>pL,AudioCodecPipelineType:()=>nL,AudioDecoderDowngradeState:()=>LM,AudioPlayerMode:()=>JM,AudioType:()=>BM,BASIC_TYPE:()=>iL,BannedReason:()=>QM,CONNECTION_CLOSED_REASON:()=>TM,CheckPermissionType:()=>uL,ClientEvent:()=>IM,CodecType:()=>aL,ConnectionEvent:()=>yM,ConnectionState:()=>MM,DECODE_FAILED_ERROR_CODE:()=>sL,DenoiserMode:()=>eL,DeviceType:()=>hL,FacingMode:()=>YM,FrameWorkType:()=>EM,LeaveReason:()=>$M,LocalTrackEvent:()=>bM,MULTI_VIDEO_DATA_TYPE:()=>GM,MediaType:()=>VM,MediaTypeLabel:()=>FM,MonitorEventId:()=>zM,MutedFlag:()=>CM,NetworkQualityValue:()=>qM,PlayerState:()=>SM,ReceiveMode:()=>KM,RemoteStreamType:()=>jM,RemoteTrackEvent:()=>kM,RoomEvent:()=>wM,SMALL_MODE:()=>dL,SceneNumber:()=>DM,StreamEvent:()=>AM,StreamType:()=>WM,SubscribeMediaType:()=>tL,TIMER_TYPE:()=>lL,TRACK_ACTION:()=>UM,TRACK_KIND:()=>xM,TrackEvent:()=>RM,UserRole:()=>OM,UserRoleNumber:()=>NM,VideoCodec:()=>rL,VideoCodecPipelineType:()=>oL,VideoContentHint:()=>cL,VideoDecoderDowngradeState:()=>PM,VideoPlayerMode:()=>XM,VideoType:()=>HM});var cM,lM,dM,uM,hM,pM,mM,fM,_M,gM,vM,EM=(e=>(e[e.WEBRTC=30]="WEBRTC",e[e.WASM=37]="WASM",e))(EM||{}),yM=((vM=yM||{}).TRACK_ADDED="track-added",vM.TRACK_UPDATED="track-updated",vM.TRACK_SUBSCRIBED="track-subscribed",vM.STREAM_ADDED="stream-added",vM.STREAM_REMOVED="stream-removed",vM.STREAM_UPDATED="stream-updated",vM.STREAM_PUBLISHED="stream-published",vM.STREAM_SUBSCRIBED="stream-subscribed",vM.STREAM_UNSUBSCRIBED="stream-unsubscribed",vM.STATE_CHANGED="state-changed",vM.ERROR="error",vM.CONNECTION_STATE_CHANGED="connection-state-changed",vM.FIREWALL_RESTRICTION="firewall-restriction",vM.SEI_MESSAGE="sei-message",vM.CLOSED="closed",vM),TM=(e=>(e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e))(TM||{}),IM=((gM=IM||{}).STREAM_ADDED="stream-added",gM.STREAM_REMOVED="stream-removed",gM.STREAM_UPDATED="stream-updated",gM.STREAM_SUBSCRIBED="stream-subscribed",gM.CONNECTION_STATE_CHANGED="connection-state-changed",gM.PEER_JOIN="peer-join",gM.PEER_LEAVE="peer-leave",gM.MUTE_AUDIO="mute-audio",gM.MUTE_VIDEO="mute-video",gM.UNMUTE_AUDIO="unmute-audio",gM.UNMUTE_VIDEO="unmute-video",gM.CLIENT_BANNED="client-banned",gM.NETWORK_QUALITY="network-quality",gM.AUDIO_VOLUME="audio-volume",gM.SEI_MESSAGE="sei-message",gM.ERROR="error",gM),AM=((_M=AM||{}).PLAYER_STATE_CHANGED="player-state-changed",_M.SCREEN_SHARING_STOPPED="screen-sharing-stopped",_M.CONNECTION_STATE_CHANGED="connection-state-changed",_M.DEVICE_AUTO_RECOVERED="device-auto-recovered",_M.ERROR="error",_M),bM=((fM=bM||{}).DEVICE_AUTO_RECOVERED="1",fM.DEVICE_RECOVER_FAILED="5",fM.DEVICE_CHANGED="2",fM.ERROR="3",fM.PUBLISH_STATE_CHANGED="4",fM.ENCODE_FAILED="6",fM.TRACK_ENDED="7",fM.RENDER="render",fM),SM=(e=>(e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e))(SM||{}),wM=((mM=wM||{}).PEER_JOIN="peer-join",mM.PEER_LEAVE="peer-leave",mM.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",mM.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",mM.BANNED="banned",mM.NETWORK_QUALITY="network-quality",mM.AUDIO_VOLUME="audio-volume",mM.SEI_MESSAGE="sei-message",mM.ERROR="error",mM.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",mM.REMOTE_PUBLISHED="remote-published",mM.REMOTE_UNPUBLISHED="remote-unpublished",mM.FIREWALL_RESTRICTION="firewall-restriction",mM.HEARTBEAT_REPORT="heartbeat-report",mM.CUSTOM_MESSAGE="custom-message",mM.LAYER_DATA="layerData",mM.FIRST_VIDEO_FRAME="first-video-frame",mM.DUMP="dump",mM.AUDIO_FRAME="audio-frame",mM.SUBSCRIBE_SMALL_VIDEO_CHANGED="subscribe-small-video-changed",mM.LOCAL_PUBLISH_FLAG_CHANGED="local-publish-flag-changed",mM.NTP_TIME_UPDATED="ntp-time-updated",mM),RM=(e=>(e.PLAYER_STATE_CHANGED="player-state-changed",e.MUTE="mute",e.UNMUTE="unmute",e.ERROR="error",e.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",e.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",e.FIRST_VIDEO_FRAME="first-video-frame",e.VIDEO_SIZE_CHANGED="video-size-changed",e))(RM||{}),kM=((pM=kM||{}).DECODE_FAILED="decode-failed",pM.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",pM.REMOTE_PUBLISH_CHANGED="remote-publish-changed",pM.AUDIO_FRAME_WITH_NTP="audio-frame-with-ntp",pM),CM=((hM=CM||{})[hM.VIDEO=1]="VIDEO",hM[hM.SMALL=2]="SMALL",hM[hM.AUX=4]="AUX",hM[hM.AUDIO=8]="AUDIO",hM[hM.VIDEO_MUTE=16]="VIDEO_MUTE",hM[hM.AUX_MUTE=32]="AUX_MUTE",hM[hM.AUDIO_MUTE=64]="AUDIO_MUTE",hM),DM=(e=>(e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e))(DM||{}),NM=(e=>(e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e))(NM||{}),OM=(e=>(e.ANCHOR="anchor",e.AUDIENCE="audience",e))(OM||{}),MM=(e=>(e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e))(MM||{}),LM=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(LM||{}),PM=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(PM||{}),xM=(e=>(e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e))(xM||{}),UM=(e=>(e.ADD="add",e.REMOVE="remove",e))(UM||{}),VM=(e=>(e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e))(VM||{}),FM={1:"audio",2:"auxVideo",4:"video"},BM=((uM=BM||{})[uM.opus=111]="opus",uM),HM=(e=>(e[e.h264=100]="h264",e[e.vp8=101]="vp8",e))(HM||{}),WM=(e=>(e.Big="big",e.Small="small",e))(WM||{}),jM=(e=>(e.Main="main",e.Aux="auxiliary",e))(jM||{}),GM=(e=>(e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e))(GM||{}),zM=((dM=zM||{})[dM.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",dM[dM.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",dM[dM.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",dM[dM.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",dM[dM.MUTE_AUDIO=32772]="MUTE_AUDIO",dM[dM.MUTE_VIDEO=32773]="MUTE_VIDEO",dM[dM.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",dM[dM.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",dM[dM.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",dM[dM.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",dM[dM.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",dM[dM.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",dM[dM.SWITCH_CAMERA=32780]="SWITCH_CAMERA",dM[dM.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",dM[dM.REPLACE_VIDEO=32782]="REPLACE_VIDEO",dM[dM.REPLACE_AUDIO=32783]="REPLACE_AUDIO",dM[dM.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",dM[dM.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",dM[dM.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",dM[dM.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",dM[dM.JOIN=32788]="JOIN",dM[dM.LEAVE=32789]="LEAVE",dM[dM.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",dM[dM.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",dM[dM.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",dM[dM.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",dM[dM.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",dM[dM.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",dM[dM.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",dM[dM.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",dM[dM.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",dM[dM.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",dM[dM.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",dM[dM.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",dM[dM.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",dM[dM.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",dM[dM.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",dM[dM.PUBLISH_AUX=32805]="PUBLISH_AUX",dM[dM.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",dM[dM.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",dM[dM.VIDEO_ENCODER=4004]="VIDEO_ENCODER",dM[dM.VIDEO_DECODER=4005]="VIDEO_DECODER",dM),qM=(e=>(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.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e))(qM||{}),KM=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e))(KM||{}),YM=(e=>(e.user="user",e.environment="environment",e))(YM||{}),XM=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e))(XM||{}),JM=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e))(JM||{}),QM=(e=>(e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e))(QM||{}),$M=((lM=$M||{})[lM.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",lM[lM.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",lM[lM.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",lM[lM.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",lM[lM.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",lM[lM.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",lM[lM.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",lM[lM.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",lM[lM.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",lM),ZM=1e8,eL=(e=>(e[e.NORMAL=0]="NORMAL",e[e.FAR_FIELD_REDUCTION=1]="FAR_FIELD_REDUCTION",e))(eL||{}),tL=class{constructor(){aR(this,"mediaType",0)}set audio(e){e?this.mediaType|=1:this.mediaType&=-2}get audio(){return!!(1&this.mediaType)}set video(e){e?this.mediaType|=4:this.mediaType&=-5}get video(){return!!(4&this.mediaType)}set auxiliary(e){e?this.mediaType|=2:this.mediaType&=-3}get auxiliary(){return!!(2&this.mediaType)}set smallVideo(e){e?this.mediaType|=8:this.mediaType&=-9}get smallVideo(){return!!(8&this.mediaType)}},iL=(e=>(e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e))(iL||{}),rL=(e=>(e.H264="h264",e.H265="h265",e.VP8="vp8",e.VP9="vp9",e.AV1="av1",e))(rL||{}),oL=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(oL||{}),nL=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(nL||{}),aL=(e=>(e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e))(aL||{}),sL=((cM=sL||{})[cM.SUCCESS=0]="SUCCESS",cM[cM.FAILED=1]="FAILED",cM[cM.WEBCODEC_INIT=2]="WEBCODEC_INIT",cM[cM.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",cM[cM.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",cM[cM.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",cM[cM.WASM_INIT=6]="WASM_INIT",cM[cM.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",cM[cM.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",cM[cM.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",cM[cM.TEST=10]="TEST",cM[cM.RENDER_2D_ERROR=11]="RENDER_2D_ERROR",cM),cL=(e=>(e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e))(cL||{}),lL=(e=>(e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e))(lL||{}),dL=(e=>(e.CANVAS="canvas",e.API="api",e))(dL||{}),uL=(e=>(e[e.NONE=0]="NONE",e[e.MICROPHONE=1]="MICROPHONE",e[e.CAMERA=2]="CAMERA",e[e.BOTH=3]="BOTH",e))(uL||{}),hL=(e=>(e.CAMERA="camera",e.MICROPHONE="microphone",e))(hL||{}),pL=(e=>(e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e))(pL||{}),mL={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},fL={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:o}=e,n="".concat(t||i.name),a="";return a=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(qC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' cannot be '").concat(o,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:o}=e,n="".concat(t||i.name),a="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(qC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(o,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,fnName:r,value:o}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(o,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,fnName:r,value:o}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(o,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:i}=e;return"Failed to join room - ".concat(t," code: ").concat(i)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:i,streamType:r}=e;return"failed to subscribe ".concat(i," ").concat(r," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},PLAY_FAILED:e=>"".concat(e.media," play failed, browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:i}=e;return"an error was caught in ".concat(t,".on('").concat(i,"', handler), please check your code in 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"please avoid repeated join.",CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:i,timesInSecond:r,maxSizeInSecond:o}=e;return"api ".concat(i," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(o," bytes"):r," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},_L=(e,t)=>t?"".concat(FR,"/").concat(e,"/").concat(t):"".concat(FR,"/").concat(e,"/index.html"),gL=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=null==localStorage?void 0:localStorage.getItem(zR);if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let i=window.TRTC_ERROR_INFO,r=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:i,TRTC_ERROR_LINK:r}}return{}};function vL(e){let{key:t,data:i,link:r,addDocLink:o=!0}=e,n="",a="",s="";KC(fL[t])?n=fL[t](i):XC(fL[t])&&(n=fL[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=gL();r?s="".concat(r.className,".html#").concat(r.fnName):l&&l[t]&&(KC(l[t])?s=l[t](i):XC(l[t])&&(s=l[t]));let d=n;return WC()&&(c&&c[t]&&(KC(c[t])?a=c[t](i):XC(c[t])&&(a=c[t])),a&&(d=o?"".concat(a,"\n请查看文档: ").concat(_L("zh-cn",s),"\n\n"):"".concat(a,"\n\n"),d+=n)),o&&(d+=" \nRefer to: ".concat(_L("en",s),"\n")),d}var EL,yL=oR(pR(),1),TL=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];aR(this,"countMap",new Map),aR(this,"distributionMap",new Map),aR(this,"version"),aR(this,"log",rM.createLogger({id:"kv"})),e&&($O.on("102",(e=>{let{track:t,cost:i}=e;this.addSuccessEvent({key:t.kind===ok.AUDIO?501700:511700,cost:i})})),$O.on("103",(e=>{let{track:t,error:i}=e;this.addFailedEvent({key:t.kind===ok.AUDIO?501700:511700,error:i})})),$O.on("266",(e=>{let{enable:t}=e;this.log.info("".concat(t?"enable":"disable"," sso")),t?this.addSuccessEvent({key:525701}):this.addFailedEvent({key:525701})})))}getReportData(e,t){let i={msg_sdk_basic_info:{uint32_sdk_version:wD(this.version||wR),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:[...this.countMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,uint32_count:i}})),stats_distribution:[...this.distributionMap.entries()].map((e=>{let[t,i]=e;return{uint32_key:t,distribution_items:[...i.entries()].map((e=>{let[t,i]=e;return{uint32_item_key:t,uint32_item_value:i}}))}})),str_user_sig:e,bytes_report_token:t};return this.countMap.clear(),this.distributionMap.clear(),i}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:i=!1}=e;this.isCountKey(t)?i&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:i,useUV:r=!0}=e;var o;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(r&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let n=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map;n.set(i,(n.get(i)||0)+1),this.distributionMap.set(t,n)}addNumber(e){let{key:t,value:i,split:r=100,useUV:o=!1,max:n=5e3}=e;var a;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(o&&this.countMap.has(t))return;i>n&&(i=n),this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(a=this.distributionMap)?void 0:a.get(t))||new Map,c=0;if(JC(r))c=Math.floor(i/r);else for(let l=r.length-1;l>0;l--)if(i>r[l]){c=l;break}s.set(c,(s.get(c)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:i,timeKey:r,split:o}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),i)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:r||t+100,value:i,split:o}):r||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:i}=e;if(!t)return;let r=_R.UNKNOWN;i&&(JC(i)?r=i:(!YC(i.extraCode)||!YC(i.code))&&(r=i.extraCode||i.code)),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:Math.abs(r),useUV:!1})}},IL=(e=>(e[e.enterRoom=500700]="enterRoom",e[e.exitRoom=500701]="exitRoom",e[e.switchRole=500702]="switchRole",e[e.destroy=500703]="destroy",e[e.startLocalAudio=500704]="startLocalAudio",e[e.updateLocalAudio=500705]="updateLocalAudio",e[e.stopLocalAudio=500706]="stopLocalAudio",e[e.startLocalVideo=500707]="startLocalVideo",e[e.updateLocalVideo=500708]="updateLocalVideo",e[e.stopLocalVideo=500709]="stopLocalVideo",e[e.startScreenShare=500710]="startScreenShare",e[e.updateScreenShare=500711]="updateScreenShare",e[e.stopScreenShare=500712]="stopScreenShare",e[e.startRemoteVideo=500713]="startRemoteVideo",e[e.updateRemoteVideo=500714]="updateRemoteVideo",e[e.stopRemoteVideo=500715]="stopRemoteVideo",e[e.muteRemoteAudio=500716]="muteRemoteAudio",e[e.setRemoteAudioVolume=500717]="setRemoteAudioVolume",e[e.use=500718]="use",e[e.switchRoom=500719]="switchRoom",e[e.sendSEIMessage=5e5]="sendSEIMessage",e[e.sendCustomMessage=500001]="sendCustomMessage",e))(IL||{}),AL=(e=>(e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e[e.SmallStreamAutoSwitcher=593700]="SmallStreamAutoSwitcher",e[e.VideoMixer=594700]="VideoMixer",e[e.AudioProcessor=595700]="AudioProcessor",e))(AL||{}),bL=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e[e.SmallStreamAutoSwitcher=593701]="SmallStreamAutoSwitcher",e[e.VideoMixer=594701]="VideoMixer",e[e.AudioProcessor=595701]="AudioProcessor",e))(bL||{}),SL=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e[e.SmallStreamAutoSwitcher=593702]="SmallStreamAutoSwitcher",e[e.VideoMixer=594702]="VideoMixer",e[e.AudioProcessor=595702]="AudioProcessor",e))(SL||{}),wL=((EL=wL||{})[EL.DECODER_TYPE=514700]="DECODER_TYPE",EL[EL.DECODER_HW_SW=514701]="DECODER_HW_SW",EL[EL.DECODE_RESULT=514702]="DECODE_RESULT",EL[EL.DECODE_FAILED_OS=514703]="DECODE_FAILED_OS",EL[EL.DOWNGRADE_RESULT=514704]="DOWNGRADE_RESULT",EL[EL.DOWNGRADE_WEBCODECS_VIDEO=514705]="DOWNGRADE_WEBCODECS_VIDEO",EL[EL.DOWNGRADE_WEBCODECS_2D=514706]="DOWNGRADE_WEBCODECS_2D",EL[EL.DOWNGRADE_WASM_WEGBL=514707]="DOWNGRADE_WASM_WEGBL",EL[EL.DOWNGRADE_WASM_VIDEO=514708]="DOWNGRADE_WASM_VIDEO",EL[EL.DOWNGRADE_WASM_2D=514709]="DOWNGRADE_WASM_2D",EL[EL.DECODE_H264_RESULT=514710]="DECODE_H264_RESULT",EL[EL.DECODE_H265_RESULT=514711]="DECODE_H265_RESULT",EL[EL.DECODE_VP8_RESULT=514712]="DECODE_VP8_RESULT",EL[EL.DECODE_CAPABILITIES=514713]="DECODE_CAPABILITIES",EL[EL.H264_PROFILE_LEVEL_ID_HIGH=514714]="H264_PROFILE_LEVEL_ID_HIGH",EL[EL.H264_PROFILE_LEVEL_ID_MAIN=514715]="H264_PROFILE_LEVEL_ID_MAIN",EL[EL.RENDER_FREEZE_RATE=514850]="RENDER_FREEZE_RATE",EL[EL.DATA_FREEZE_RATE=514851]="DATA_FREEZE_RATE",EL[EL.VIDEO_CONSUME_RENDER_RATE=514852]="VIDEO_CONSUME_RENDER_RATE",EL),RL=new TL(!0),kL=new TL(!1),CL=RL,DL={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}},NL=new Map([[_N,["Firefox",gN]],[TN,["Edg",IN]],[_O,["Chrome",EO]],[TO,["Safari",AO]],[kN,["TBS",CN]],[DN,["XWEB",NN]],[PN&&lN,["WeChat",xN]],[BN,["QQ(Win)",HN]],[VN,["QQ(Mobile)",FN]],[UN,["QQ(Mobile X5)",FN]],[WN,["QQ(Mac)",jN]],[GN,["QQ(iPad)",zN]],[ZN,["MI",eO]],[tO,["HW",oO]],[nO,["Samsung",aO]],[sO,["OPPO",cO]],[lO,["VIVO",dO]],[EN,["EDGE",yN]],[bN,["SogouMobile",SN]],[wN,["Sogou",RN]]]);function OL(){let e=NL.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var ML=function(){return!(QN||EN||TN&&AN<80||_N&&vN<56)},LL=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every((e=>e in window))},PL=function(){if(!navigator.mediaDevices)return UL()||rM.error(fL.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},xL=!1;function UL(){return"http:"===location.protocol&&!MO&&(xL||rM.error(vL({key:mL.NOT_SUPPORTED_HTTP})),xL=!0,!0)}var VL=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},FL=function(){return!(null==window||!window.MediaStreamTrackGenerator)},BL=function(){return cR(this,null,(function*(){var e,t,i;if(DL.detail.isH264EncodeSupported&&DL.detail.isVp8EncodeSupported)return{isH264EncodeSupported:DL.detail.isH264EncodeSupported,isVp8EncodeSupported:DL.detail.isVp8EncodeSupported,isH265EncodeSupported:DL.detail.isH265EncodeSupported};let r,o=!1,n=!1,a=!1;try{let s=new RTCPeerConnection,c=document.createElement(ok.CANVAS);c.getContext("2d");let l=c.captureStream(0);return s.addTrack(l.getVideoTracks()[0],l),r=yield s.createOffer(),o=-1!==(null==(e=r.sdp)?void 0:e.toLowerCase().indexOf("h264")),n=-1!==(null==(t=r.sdp)?void 0:t.toLowerCase().indexOf("vp8")),a=-1!==(null==(i=r.sdp)?void 0:i.toLowerCase().indexOf("h265")),s.close(),{isH264EncodeSupported:o,isVp8EncodeSupported:n,isH265EncodeSupported:a}}catch(hM){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1}}}))},HL=function(){return cR(this,null,(function*(){var e;if(DL.detail.isH264DecodeSupported&&DL.detail.isVp8DecodeSupported)return{isH264DecodeSupported:DL.detail.isH264DecodeSupported,isVp8DecodeSupported:DL.detail.isVp8DecodeSupported,isH265DecodeSupported:DL.detail.isH265DecodeSupported};let t,i=!1,r=!1;try{let o=new RTCPeerConnection;sP()?(o.addTransceiver(ok.VIDEO,{direction:"recvonly"}),t=yield o.createOffer()):t=yield o.createOffer({offerToReceiveVideo:!0}),-1!==t.sdp.toLowerCase().indexOf("h264")&&(i=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(r=!0);let n=-1!==(null==(e=t.sdp)?void 0:e.toLowerCase().indexOf("h265"));return o.close(),{isH264DecodeSupported:i,isVp8DecodeSupported:r,isH265DecodeSupported:n}}catch(pM){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}}}))};var WL=CD((e=>cR(void 0,null,(function*(){let t=Date.now(),i=yP(),r=PL(),o=LL();if(DL.detail.isWebRTCSupported=i,DL.detail.isMediaDevicesSupported=r,DL.detail.isWebCodecsSupported=o,DL.detail.isScreenShareSupported=GL(),DL.detail.isSmallStreamSupported=iP(),37===e)return Object.assign(DL.detail,yield function(){return cR(this,null,(function*(){return KL||(KL=new Promise((e=>cR(this,null,(function*(){let t={isH264EncodeSupported:!1,isH264DecodeSupported:!1,isVp8EncodeSupported:!1,isVp8DecodeSupported:!1};if(!LL())return void e(t);let i=null,r=null,o=null,n=()=>{o&&clearTimeout(o),i=null,r=null};try{i=document.createElement("canvas"),r=i.getContext("2d"),i.width=320,i.height=240;let a=0,s=()=>{!r||!i||(r.fillStyle="hsl(".concat(a%360,", 50%, 50%)"),r.fillRect(0,0,i.width,i.height),r.fillStyle="white",r.font="20px Arial",r.fillText("Frame ".concat(a),10,30),a++)};o=setTimeout((()=>{n(),e(t)}),5e3);let c=[{type:"h264",encodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"},width:320,height:240,bitrate:1e6},decodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"}}},{type:"vp8",encodeConfig:{codec:"vp8",width:320,height:240,bitrate:1e6},decodeConfig:{codec:"vp8"}}];(yield Promise.all(c.map((e=>cR(this,null,(function*(){let t,r={type:e.type,encodeSupported:!1,decodeSupported:!1};try{t=yield new Promise(((t,o)=>cR(this,null,(function*(){try{let n=new VideoEncoder({output:e=>{t(e),r.encodeSupported=!0},error:o});n.configure(e.encodeConfig),s();let a=new VideoFrame(i,{timestamp:0});n.encode(a,{keyFrame:!0}),a.close(),yield n.flush(),n.close()}catch(vM){o(vM)}}))))}catch(p){return rM.warn("".concat(e.type," encoder error:"),p),r}try{yield new Promise(((i,o)=>cR(this,null,(function*(){try{let n=new VideoDecoder({output:e=>{r.decodeSupported=!0,i(0),e.close()},error:o});n.configure(e.decodeConfig),n.decode(t),yield n.flush(),n.close()}catch(vM){o(vM)}}))))}catch(p){rM.warn("".concat(e.type," decoder error:"),p)}return r})))))).forEach((e=>{"h264"===e.type?(t.isH264EncodeSupported=e.encodeSupported,t.isH264DecodeSupported=e.decodeSupported):"vp8"===e.type&&(t.isVp8EncodeSupported=e.encodeSupported,t.isVp8DecodeSupported=e.decodeSupported)})),n(),e(t)}catch(a){n(),rM.warn("detectWebCodecsSupported failed:",a),e(t)}})))),KL)}))}()),DL.detail.isBrowserSupported=o,DL.result=r&&o,DL.result||rM.error("".concat(navigator.userAgent," ").concat(ID(DL.detail,!1))),RP(e),CL.addNumber({key:523800,value:Date.now()-t}),DL;if(DL.result&&DL.detail.isH264EncodeSupported&&DL.detail.isVp8EncodeSupported&&DL.detail.isH265EncodeSupported&&DL.detail.isH264DecodeSupported&&DL.detail.isVp8DecodeSupported&&DL.detail.isH265DecodeSupported)return DL;let n=ML(),{encode:a,decode:s}=yield function(){return cR(this,null,(function*(){let[e,t]=yield Promise.all([BL(),HL()]);return{encode:{h264:e.isH264EncodeSupported,vp8:e.isVp8EncodeSupported,h265:e.isH265EncodeSupported},decode:{h264:t.isH264DecodeSupported,vp8:t.isVp8DecodeSupported,h265:t.isH265DecodeSupported}}}))}(),{h264:c,vp8:l}=a,{h264:d}=s,{h265:u}=a,{vp8:h,h265:p}=s;if(!c||!l){let e=yield BL();rM.warn("detect encode again h264:".concat(c," vp8:").concat(l," result: ").concat(JSON.stringify(e))),c=e.isH264EncodeSupported,l=e.isVp8EncodeSupported}if(c&&d&&hN&&fO&&!DN&&!kN&&(!sO||115!==vO)){let{encode:e,decode:t}=yield function(){return cR(this,null,(function*(){return qL||(qL=new Promise((e=>cR(this,null,(function*(){let t={encode:!1,decode:!1},i=()=>{};try{let r=document.createElement("canvas"),o=r.getContext("2d");r.width=640,r.height=480;let n=setInterval((()=>{o.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))}),66),a=-1,s=-1;i=()=>{clearInterval(a),clearInterval(n),clearTimeout(s),l.close(),d.close(),c.getTracks().forEach((e=>e.stop()))},s=setTimeout((()=>{i(),e(t)}),2e3);let c=r.captureStream(),l=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});l.addEventListener("icecandidate",(e=>d.addIceCandidate(e.candidate))),d.addEventListener("icecandidate",(e=>l.addIceCandidate(e.candidate))),l.addTrack(c.getVideoTracks()[0],c);let u=yield l.createOffer();yield l.setLocalDescription(u),yield d.setRemoteDescription(u);let h=yield d.createAnswer(),p=yL.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=yL.default.write(p),yield d.setLocalDescription(h),yield l.setRemoteDescription(h),a=setInterval((()=>cR(this,null,(function*(){t.encode&&t.decode&&(i(),e(t));let[r,o]=yield Promise.all([l.getSenders()[0].getStats(),d.getReceivers()[0].getStats()]);t.encode||r.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===ok.VIDEO&&e.bytesSent>0&&(t.encode=!0)})),t.decode||o.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===ok.VIDEO&&e.bytesReceived>0&&(t.decode=!0)}))}))),100)}catch(r){i(),rM.warn("detectH264Supported failed",r),e({encode:!0,decode:!0})}})))).then((e=>(e.encode||(e.decode=!0),(!e.encode||!e.decode)&&rM.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(FO)),e))),qL)}))}();c=e,d=t}return DL.result=n&&i&&r&&(c||l)&&(d||h),DL.detail.isBrowserSupported=n,DL.detail.isWebRTCSupported=i,DL.detail.isH264EncodeSupported=c,DL.detail.isVp8EncodeSupported=l,DL.detail.isH265EncodeSupported=u,DL.detail.isH264DecodeSupported=d,DL.detail.isVp8DecodeSupported=h,DL.detail.isH265DecodeSupported=p,DL.result||rM.error("".concat(navigator.userAgent," ").concat(ID(DL.detail,!1))),RP(),CL.addNumber({key:523800,value:Date.now()-t}),DL})))),jL=function(){return DL.result},GL=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},zL="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype,qL=null;var KL=null;var YL=(e,t,i)=>{"http:"===location.protocol&&!MO&&(e[t]=()=>{throw new vR({code:_R.INVALID_OPERATION,message:fL.NOT_SUPPORTED_HTTP})})},XL=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(QC(e.selected)&&!e.selected)};function JL(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",i=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(i)}return e}function QL(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function $L(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let i=0;i<t.length;i++)if(t[i]in window){e.isSupported=!0;break}return e.isSupported}function ZL(){return"captureStream"in HTMLCanvasElement.prototype}function eP(){return!(PN||uN||vO&&vO<63)&&!(!ML()||!ZL())}function tP(){return!(vO<74||EN||kO<11||vN<46)}function iP(){return eP()||tP()}var rP=function(){if(YC(window.RTCRtpTransceiver)||!sP()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:Vk}),e.addTransceiver(ok.AUDIO),t=!0}catch(kR){}return null==e||e.close(),t};function oP(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function nP(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function aP(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function sP(){return!(11===kO&&!OO)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var cP=!(!sP()||fO&&vO<86);function lP(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var dP="RTCRtpSender"in window;function uP(){return dP&&"replaceTrack"in window.RTCRtpSender.prototype}function hP(){return dP&&"setParameters"in window.RTCRtpSender.prototype&&nP()}var pP="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,mP=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,fP=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,_P="undefined"!=typeof InputDeviceInfo&&"getCapabilities"in InputDeviceInfo.prototype,gP=dP&&"createEncodedStreams"in window.RTCRtpSender.prototype&&pO()>=86,vP="RTCRtpScriptTransform"in window,EP=dP&&(gP||vP),yP=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function TP(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return YC(window.AudioDecoder)||(e.AudioDecoder=!0),YC(window.AudioEncoder)||(e.AudioEncoder=!0),YC(window.VideoDecoder)||(e.VideoDecoder=!0),YC(window.VideoEncoder)||(e.VideoEncoder=!0),YC(window.ImageDecoder)||(e.ImageDecoder=!0),e}function IP(){return"mediaSession"in navigator&&!YC(navigator.mediaSession.setActionHandler)}function AP(){return!YC(window.WebTransport)}function bP(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function SP(){let e={browser:"".concat(PO.name,"/").concat(PO.version),os:zO(),displayResolution:JL(),isScreenShareSupported:GL(),isWebRTCSupported:yP(),isGetUserMediaSupported:QL(),isWebAudioSupported:$L(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:TP(),isMediaSessionSupported:IP(),isWebTransportSupported:AP()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var wP="checkResult";function RP(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;nM.setItem(wP+e,{ua:navigator.userAgent,checkResult:DL})}function kP(e){UL();let t=nM.getItem(wP+e);t&&t.ua===navigator.userAgent&&t.checkResult&&function(e,t){return!!$C(e)&&Object.keys(t).every((t=>t in e))}(t.checkResult.detail,DL.detail)&&(DL=t.checkResult),WL(e)}function CP(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var DP="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype;function NP(e){return{h264:1,h265:2,vp8:3,vp9:4,av1:5}[e]}var OP=!1;function MP(){return cR(this,null,(function*(){var e;try{if(OP||null==(e=null==navigator?void 0:navigator.mediaCapabilities)||!e.encodingInfo)return;let t=qO(),i=KO();if(0===t||0===i)return;OP=!0;let r=["H264","VP8","VP9","AV1","H265"],[o,n]=yield Promise.all([LP(r),PP(r)]);o&&Object.keys(o).forEach((e=>{let r=NP(e.toLowerCase());CL.addEnum({key:513707,value:+"".concat(r).concat(+o[e].supported).concat(+o[e].powerEfficient).concat(t).concat(i),useUV:!1})})),n&&Object.keys(n).forEach((e=>{let r=NP(e.toLowerCase());CL.addEnum({key:514713,value:+"".concat(r).concat(+n[e].supported).concat(+n[e].powerEfficient).concat(t).concat(i),useUV:!1})}));let{sender:a,receiver:s}=xP();CL.addEnum({key:513708,value:+"".concat(t).concat(i).concat(+a.high),useUV:!1}),CL.addEnum({key:513709,value:+"".concat(t).concat(i).concat(+a.main),useUV:!1}),CL.addEnum({key:514714,value:+"".concat(t).concat(i).concat(+s.high),useUV:!1}),CL.addEnum({key:514715,value:+"".concat(t).concat(i).concat(+s.main),useUV:!1})}catch(uM){rM.info("detectVideoCodecCapabilities failed",uM)}}))}function LP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return cR(this,null,(function*(){let n={};try{for(let a of e){let e=yield navigator.mediaCapabilities.encodingInfo({type:"webrtc",video:{contentType:"video/".concat(a),width:t,height:i,bitrate:o,framerate:r}});n[a]=e}}catch(CR){}return n}))}function PP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return cR(this,null,(function*(){let n={};try{for(let a of e){let e=yield navigator.mediaCapabilities.decodingInfo({type:"webrtc",video:{contentType:"video/".concat(a),width:t,height:i,bitrate:o,framerate:r}});n[a]=e}}catch(CR){}return n}))}function xP(){let e={sender:{base:!1,main:!1,high:!1},receiver:{base:!1,main:!1,high:!1}};try{if(RTCRtpSender&&"function"==typeof RTCRtpSender.getCapabilities){let t=RTCRtpSender.getCapabilities("video");t&&t.codecs&&t.codecs.filter((e=>"video/h264"===e.mimeType.toLowerCase())).forEach((t=>{if(t.sdpFmtpLine){let i=t.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(i&&i[1])switch(i[1].slice(0,2)){case"42":e.sender.base=!0;break;case"4d":e.sender.main=!0;break;case"64":e.sender.high=!0}}}))}if(RTCRtpReceiver&&"function"==typeof RTCRtpReceiver.getCapabilities){let t=RTCRtpReceiver.getCapabilities("video");t&&t.codecs&&t.codecs.filter((e=>"video/h264"===e.mimeType.toLowerCase())).forEach((t=>{if(t.sdpFmtpLine){let i=t.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(i&&i[1])switch(i[1].slice(0,2)){case"42":e.receiver.base=!0;break;case"4d":e.receiver.main=!0;break;case"64":e.receiver.high=!0}}}))}}catch(uM){rM.warn("get H264 profile levelId failed",uM)}return e}var UP=oR(lR(),1),VP=Symbol("instance"),FP=Symbol("cacheResult"),BP=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,zP.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},HP=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}};var WP=new Map;function jP(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,o,n)=>{let a=i.action||o;if(!i.context){let i=WP.get(r)||[];WP.has(r)||WP.set(r,i),i.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let r=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(i.context&&(r=qP.get("function"==typeof i.context?i.context.call(this,...n):i.context)),r.state===t)return i.sync?r[FP]:Promise.resolve(r[FP]);r.state instanceof BP&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;Array.isArray(e)?0==e.length?r.state instanceof BP&&r.state.abort(r):("string"!=typeof r.state||!e.includes(r.state))&&(l=new HP(r._state,"".concat(r.name," ").concat(a," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e.join("|")))):e!==r.state&&(l=new HP(r._state,"".concat(r.name," ").concat(a," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e)));let d=e=>{if(i.fail&&i.fail.call(this,e),i.sync){if(i.ignoreError)return e;throw e}return i.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);let u=r.state,h=new BP(u,t,a);zP.call(r,h);let p=e=>{var o;return r[FP]=e,h.aborted||(zP.call(r,t),null===(o=i.success)||void 0===o||o.call(this,r[FP])),e},m=e=>(zP.call(r,u,e),d(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):i.sync?p(e):Promise.resolve(p(e))}catch(gM){return m(new HP(r._state,"".concat(r.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(gM),gM instanceof Error?gM:new Error(String(gM))))}}}}var GP="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function zP(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(qP.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var qP=class e extends UP.default{constructor(t,i,r){super(),this.name=t,this.groupName=i,this._state=e.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),i||(this.groupName=this.constructor.name);let o=r[VP];o?this.name=o.name+"-"+o.count++:r[VP]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=WP.get(e)||[],i=new Set,r=[],o=[],n=new Set,a=Object.getPrototypeOf(e);WP.has(a)&&(a.stateDiagram.forEach((e=>i.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:i,action:n}=e;"string"==typeof t?r.push({from:t,to:i,action:n}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:n})})):o.push({to:i,action:n})})),r.forEach((e=>{let{from:t,to:r,action:o}=e;n.add(t),n.add(r),n.add(o+"ing"),i.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),i.add("".concat(o,"ing --\x3e ").concat(r," : ").concat(o," 🟢")),i.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),n.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let s=[...i];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let i;return"string"==typeof t?(i=e.instances.get(t),i||e.instances.set(t,i=new e(t,void 0,Object.create(e.prototype)))):(i=e.instances2.get(t),i||e.instances2.set(t,i=new e(t.constructor.name,void 0,Object.create(e.prototype)))),i}static getState(t){var i;return null===(i=e.get(t))||void 0===i?void 0:i.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};GP(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){zP.call(this,e)}};qP.STATECHANGED="stateChanged",qP.UPDATEAFSM="updateAFSM",qP.INIT="[*]",qP.ON="on",qP.OFF="off",qP.instances=new Map,qP.instances2=new WeakMap;var KP="undefined"!=typeof window,YP=KP&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},XP=KP&&window.cancelIdleCallback||function(e){clearTimeout(e)},JP=KP&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),QP=class e{static generateTaskID(){return this.currentTaskID++}static run(e,t,i){null!=i&&i.fps&&(i.delay=i.delay||Number((1e3/i.fps).toFixed(2))),i=Zw("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:"ric"===e?{delay:1e4,count:0}:"raf"===e?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},i);let r=eR(Zw({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},i),{delay:i.delay});return this.taskMap.set(r.taskID,r),this[e](r),r.taskID}static interval(t){return t.intervalID=setInterval((()=>{t.callback(),t.loopCount+=1,e.isBreakLoop(t)}),t.delay)}static intervalInWorker(t){e.sharedWorker||(e.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),e.sharedWorker.onmessage=t=>{var i;if("tick"===t.data.type){let r=e.workerTasks.get(t.data.taskId);r&&(e.isBreakLoop(r)?(null==(i=e.sharedWorker)||i.postMessage({type:"stop",taskId:r.taskID}),e.workerTasks.delete(r.taskID)):(r.callback(),r.loopCount+=1))}}),e.workerTasks.set(t.taskID,t),e.sharedWorker.postMessage({taskId:t.taskID,delay:t.delay,type:"start"})}static timeout(t){let i=()=>{if(t.callback(),t.loopCount+=1,!e.isBreakLoop(t))return t.timeoutID=setTimeout(i,t.delay)};return t.timeoutID=setTimeout(i,t.delay)}static ric(t){let i,r=cD(),o=()=>{if(i=cD()-r,i>=t.delay&&(r=cD()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=YP(o,{timeout:t.delay})};return t.ricID=YP(o,{timeout:t.delay})}static raf(t){let i,r=cD(),o=()=>document.hidden&&t.backgroundTask?(i=cD()-r,r=cD(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(o,t.delay-Math.floor(i%t.delay))):(i=cD()-r,i>=t.delay&&(r=cD()-Math.floor(i%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(o));if(t.rafID=requestAnimationFrame(o),t.backgroundTask){let e=()=>{if(document.hidden){let e=cD()-r;e>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-e)}};document.addEventListener("visibilitychange",e),t.onVisibilitychange=e,document.hidden&&e()}return t.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:i,rafID:r,ricID:o,onVisibilitychange:n}=this.taskMap.get(e);return t&&clearInterval(t),i&&clearTimeout(i),r&&JP&&JP(r),o&&XP(o),n&&document.removeEventListener("visibilitychange",n),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.hasTask(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};aR(QP,"taskMap",new Map),aR(QP,"currentTaskID",1),aR(QP,"sharedWorker",null),aR(QP,"workerTasks",new Map);var $P=QP;ok.SEI_MESSAGE;var ZP={LOADED_DATA:ok.LOADEDDATA,LOADED_META_DATA:ok.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error",RESIZE:ok.RESIZE,TIME_UPDATE:"time-update"},ex={};rR(ex,{create:()=>ix,remove:()=>rx});var tx=new WeakMap;function ix(e,t){tx.has(e)||tx.set(e,[]);let i=tx.get(e),r={add:(e,o)=>("addEventListener"in t?(i.push(t.removeEventListener.bind(t,e,o)),t.addEventListener(e,o)):(i.push(t.off.bind(t,e,o)),t.on(e,o)),r)};return r}function rx(e){let t=tx.get(e);t&&(t.forEach((e=>e())),tx.delete(e))}var ox=new class{constructor(){aR(this,"_roomIdMap",new Map),aR(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:wR,env:KR.QCLOUD,browserVersion:PO.name+PO.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:i,userId:r,roomId:o}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=i,this._configs.userId=r,this._roomIdMap.set(r,String(o))}logSuccessEvent(e){MO||!rM.isAbleToUpload||this._configs.env===KR.QCLOUD&&this.uploadEventToKibana(eR(Zw({},e),{result:"success"}))}logFailedEvent(e){if(MO||!rM.isAbleToUpload)return;let{eventType:t,code:i,error:r,userId:o}=e,n={roomId:this._roomIdMap.get(o||this._configs.userId),userId:o,eventType:t,result:"failed",code:i||(null==r?void 0:r.extraCode)||(null==r?void 0:r.code)||_R.UNKNOWN};this._configs.env===KR.QCLOUD&&this.uploadEventToKibana(eR(Zw({},n),{error:r}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:i,error:r}=e,o={timestamp:TR(),sdkAppId:this._configs.sdkAppId,userId:i||this._configs.userId,version:wR,log:t};r&&(o.errorInfo=r.message,r.stack&&(o.errorInfo+="\n".concat(r.stack)));let n=tM.enable?UD(o,2002,Number(this._configs.sdkAppId)):JSON.stringify(o);this.sendRequest(kC(this._configs.sdkAppId,qR.LOG),n)}sendRequest(e,t){setTimeout((()=>zD({url:e,body:t,priority:"low"}).catch((()=>{}))),2e3)}},nx=new WeakMap;function ax(e){let{settings:t={retries:5,timeout:2e3},onError:i,onRetrying:r,onRetryFailed:o}=e;return function(e,n,a){let s=$D({retryFunction:a.value,settings:t,onError(t){let{error:r,retry:o,reject:a,retryFuncArgs:s}=t;var c;i?i.call(this,r,(()=>{var t;null!=(t=nx.get(e))&&t.has(n)?o():a(r)}),a,s):null!=(c=nx.get(e))&&c.has(n)?o():a(r)},onRetrying(t,i){var o;YD(r)&&r.call(this,t,i),null!=(o=nx.get(e))&&o.has(n)&&(nx.get(e).get(n).stopRetry=i)},onRetryFailed:o});return a.value=function(){let t=nx.get(e);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return t?t.set(n,{args:r}):nx.set(e,new Map([[n,{args:r}]])),s.apply(this,r).finally((()=>{var t;return null==(t=nx.get(e))?void 0:t.delete(n)}))},a}}var sx=class extends qP{constructor(e,t){super(e.id,"".concat(t,"-player")),this.options=e,this.kind=t,aR(this,"id"),aR(this,"element",null),aR(this,"track"),aR(this,"url"),aR(this,"attr"),aR(this,"mode"),aR(this,"muted"),aR(this,"_log"),aR(this,"_isPausedByUserCall",!1),aR(this,"_pausedRetryCount"),aR(this,"_isElementPlayingFired",!1),aR(this,"_interval"),aR(this,"_delayDestroyTimeoutId",0),aR(this,"_playSuccessResolve"),aR(this,"_isReplayByRecreateMediaStreamCalled",!1),aR(this,"isInAutoPlayFailedState",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=Jk,this._state="STOPPED",this.bindTrackEvents(),this._log.info("create ".concat(t,"-player ").concat(this.id))}get isPlaying(){var e;return"PLAYING"===this._state&&!1===(null==(e=this.element)?void 0:e.paused)}get isPaused(){var e;return"PAUSED"===this._state||!0===(null==(e=this.element)?void 0:e.paused)}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return cR(this,null,(function*(){if(!this.isPlaying)try{this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),yield new Promise(((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)}))}catch(kR){let t=vL({key:mL.PLAY_FAILED,data:{media:this.kind,error:kR}});if(this._log.warn(kR),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new vR({code:_R.PLAY_NOT_ALLOWED,message:t})}}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!IO?this._delayDestroyTimeoutId||(null==(t=this.element)||t.remove(),this._log.info("destroy element after 3 * ".concat(e)),this._delayDestroyTimeoutId=setTimeout((()=>this.destroyElement()),3*e)):this.destroyElement(),this.handleStopped(ok.ENDED),this._interval>0&&$P.clearTask(this._interval)}destroyElement(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.src="",this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}pause(){var e;this._log.info("pause"),null==(e=this.element)||e.pause(),this._isPausedByUserCall=!0,this instanceof Mx&&fO&&vO>=128&&this.setPoster(this.getVideoFrame())}resume(){return this._isPausedByUserCall=!1,this.doResume()}doResume(){return this._log.info("resume"),this._isPausedByUserCall||this.isPlaying?Promise.resolve():DO?this.replay():(this.element&&this.track&&fO&&vO>=128&&(this.element.srcObject=new MediaStream([this.track])),this.play().catch((()=>{})))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);return ix(this.element,this.element).add(ok.PLAYING,e).add(ok.ENDED,e).add(ok.PAUSE,e).add(ok.ERROR,e).add(ok.LOADEDDATA,e).add(ok.LOADEDMETADATA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==ex||ex.create(e,e).add(ok.ENDED,t).add(ok.MUTE,t).add(ok.UNMUTE,t),e.readyState===ok.ENDED&&this.handleTrackEvent({type:ok.ENDED}),e.muted&&this.handleTrackEvent({type:ok.MUTE})}}bindAutoPlayEvent(){$O.on(eM.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&rx(e)}unbindEvents(){this.element&&rx(this.element),this.unbindTrackEvents(),$O.off(eM.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){switch(e.type){case ok.PLAYING:Sx()||(this.isInAutoPlayFailedState=!1),this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(ok.PLAYING),this._interval&&($P.clearTask(this._interval),this._interval=-1);break;case ok.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(ok.ENDED);break;case ok.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(ok.PAUSE),uN&&(this._interval=$P.run("timeout",(()=>{this.element&&"PAUSED"===this._state&&this.doResume()}),{delay:3e3}));break;case ok.ERROR:if(this.element&&this.element.error){this.handlePaused(ok.ERROR);let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),ox.uploadEvent({log:"stat-".concat(this.kind,"-").concat(Lk.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),rO||iO?this.emit(ZP.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case ok.LOADEDDATA:this.kind===ok.VIDEO&&this.emit(ZP.LOADED_DATA);break;case ok.LOADEDMETADATA:this.kind===ok.VIDEO&&this.emit(ZP.LOADED_META_DATA)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((()=>{this._log.warn("replayByRecreateMediaStream success"),ox.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),CL.addSuccessEvent({key:this.kind===ok.AUDIO?506700:516700})})).catch((()=>{var t;this._log.error("replayByRecreateMediaStream failed"),ox.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),CL.addFailedEvent({key:this.kind===ok.AUDIO?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(ZP.ERROR,e)}))}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise(((t,i)=>{kD(e).then((()=>{this.element&&(this.element.srcObject=null,this.element.srcObject=new MediaStream([this.track]),this._log.warn("recreated mediaStream"),this.element.onerror=()=>{var e,t,r;this._log.warn("element onerror ".concat(null==(t=null==(e=this.element)?void 0:e.error)?void 0:t.code," fired after recreated mediaStream")),i(null==(r=this.element)?void 0:r.error)}),kD(5e3).then((()=>{var e,r;(!this.isPlaying||null!=(e=this.element)&&e.error)&&i(null==(r=this.element)?void 0:r.error),t()}))}))})).finally((()=>{this.element&&(this.element.onerror=null)}))}handleTrackEvent(e){return cR(this,null,(function*(){switch(e.type){case ok.ENDED:this.handleStopped(ok.ENDED);break;case ok.MUTE:this.handlePaused(ok.MUTE);break;case ok.UNMUTE:this.mode>0?this.handlePlaying(this.mode.toString()):this.element&&(this.element.paused&&(this._log.warn("track unmuted and element is paused, resume"),yield this.doResume()),!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(ok.UNMUTE))}}))}handlePlaying(e){var t;return this._log.debug("handlePlaying",e),null==(t=this._playSuccessResolve)||t.call(this,e),e}handlePaused(e){return this._log.debug("handlePaused",e),e}handleStopped(e){return this._log.debug("handleStopped",e),e}getElement(){return this.element}};aR(sx,"PlayerEvent",ZP),nR([ax({settings:{retries:2,timeout:0},onError(e,t,i,r){r[0]=(r[0]||1e3)+1e3,t()}})],sx.prototype,"doReplayByRecreateMediaStream",1),nR([jP([],"PLAYING",{sync:!0,success(e){this.emit(ZP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}})],sx.prototype,"handlePlaying",1),nR([jP("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(e){this.emit(ZP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}})],sx.prototype,"handlePaused",1),nR([jP([],"STOPPED",{sync:!0,success(e){this.emit(ZP.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}})],sx.prototype,"handleStopped",1);var cx="trtc_autoplay",lx="".concat(cx,"_mask"),dx="".concat(cx,"_wrapper"),ux="".concat(cx,"_header"),hx="".concat(cx,"_content"),px="".concat(cx,"_action_wrapper"),mx="".concat(cx,"_question"),fx="".concat(cx,"_collapse"),_x="".concat(cx,"_action_confirm"),gx="".concat(cx,"_detail"),vx="#2473E8",Ex="dialog",yx="".concat(Ex,"-show"),Tx="".concat(Ex,"-1"),Ix="".concat(Ex,"-2"),Ax=!1,bx=!1,Sx=()=>bx,wx="".concat(FR,"/").concat(WC()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),Rx="<br><a href='".concat(wx,"' target='_blank'>").concat(WC()?"其他方案?":"Any other solution?","</a>"),kx="".concat(WC()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(Rx):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(Rx)),Cx=class{constructor(){if(aR(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),aR(this,"_dialogNode",null),aR(this,"_bodyPosition",""),aR(this,"_showDetail",!1),aR(this,"_isCollapseClicked",!1),aR(this,"_isQuestionClicked",!1),WC()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!Ax){let e=document.createElement("style");e.innerHTML=".".concat(lx,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(lx," div:not(.").concat(px,"){display:block !important;}.").concat(dx,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(dx," a{color:").concat(vx,";}.").concat(ux,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(hx,"{margin:8px 0;}.").concat(px,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(fx,"{margin-right:auto;cursor:pointer}.").concat(mx,"{height:100%;line-height:16px;cursor:pointer;}.").concat(_x,"{margin-left:8px;color:#fff;background:").concat(vx,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(_x,":hover{opacity:0.9;}.").concat(fx,",.").concat(_x,",.").concat(hx,",.").concat(mx,"{font-size:14px;}@media screen and (max-width:750px){.").concat(dx,"{width:80vw;}}"),document.head.appendChild(e),Ax=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(lx,"\"><div class='").concat(dx,"'><div class='").concat(ux,"'>").concat(location.host,"</div><div class='").concat(hx,"'>").concat(this.content,"</div><div class='").concat(gx,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(kx,"</div><div class='").concat(px,"'></div></div></div>").trim();let t=document.createElement("button");t.className=_x,t.innerText=WC()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let i=document.createElement("div");i.className=mx,i.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',i.onclick=this.onQuestionClick.bind(this);let r=document.createElement("div");r.className=fx,r.innerText="".concat(WC()?"详情 >":"Detail >"),r.onclick=this.onCollapseClick.bind(this);let o=e.content.firstChild,n=o.querySelector(".".concat(px));return n.appendChild(r),n.appendChild(i),n.appendChild(t),o}addDiaLog(){Sx()||(bx=!0,this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(dx)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",rM.info("show autoplay dialog"),ox.uploadEvent({log:yx}))}deleteDialog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null,bx=!1)}onConfirm(){rM.warn("confirm clicked, try resume stream"),$O.emit(eM.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDialog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(gx));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||ox.uploadEvent({log:Tx}),this._isCollapseClicked=!0}onQuestionClick(){window.open(wx,"_blank"),this._isQuestionClicked||ox.uploadEvent({log:Ix}),this._isQuestionClicked=!0}},Dx=null;function Nx(){Dx||(Dx=new Cx)}var Ox,Mx=class extends sx{constructor(e){super(e,ok.VIDEO),aR(this,"stat",{}),aR(this,"_calculateTimeout",-1),aR(this,"viewMirror",!1),aR(this,"objectFit"),aR(this,"container"),aR(this,"canvas"),aR(this,"shouldRenderAlpha",!1),aR(this,"_preSize",{width:0,height:0}),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,YC(e.viewMirror)||(this.viewMirror=e.viewMirror),YC(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}get isPlaying(){var e;return!("PLAYING"!==this._state||this.element&&this.element.paused)&&("live"===(null==(e=this.track)?void 0:e.readyState)&&!this.track.muted)}initializeElement(){var e;let t=document.createElement(ok.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,hN&&(t.poster="noposter"),null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color: black",";");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(ok.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(ok.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent).add(ok.RESIZE,this.handleElementEvent)}handleTrackEvent(e){var t;return e.type===ok.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0),super.handleTrackEvent(e)}handleElementEvent(e){var t,i,r,o,n,a;if(2===this.mode)return;super.handleElementEvent(e);let s=e.type;if(s===ok.PAUSE&&(this.container&&!this.container.isConnected&&(this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(this.container.id)),kD(500).then((()=>{var e;null!=(e=this.container)&&e.isConnected&&(this._pausedRetryCount=Jk,this._log.info("view container ".concat(this.container.id," is in dom, reset pausedRetryCount")))}))),this._pausedRetryCount>0&&!Sx()&&!this._isPausedByUserCall&&(this._log.info("[".concat(Jk-this._pausedRetryCount+1,"/").concat(Jk,"] ").concat(this.kind," player auto resume when paused")),this.doResume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;s===ok.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):s===ok.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}s===ok.RESIZE&&(this._preSize.height!==(null==(t=this.element)?void 0:t.videoHeight)||this._preSize.width!==(null==(i=this.element)?void 0:i.videoWidth))&&(this._log.info("video size changed to ".concat(null==(r=this.element)?void 0:r.videoWidth,"x").concat(null==(o=this.element)?void 0:o.videoHeight)),this._preSize.height=(null==(n=this.element)?void 0:n.videoHeight)||0,this._preSize.width=(null==(a=this.element)?void 0:a.videoWidth)||0,this.emit(ZP.RESIZE,{newWidth:this._preSize.width,newHeight:this._preSize.height}))}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var i,r,o,n;this.canvas!==e&&(null==(i=this.canvas)||i.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?t:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(r=this.element)||r.remove(),null==(o=this.container)||o.appendChild(e)):this.element&&(null==(n=this.container)||n.appendChild(this.element)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}setPoster(e){this.element&&(this.element.poster=e)}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;super.stop(e),null==(t=this.canvas)||t.remove()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(ZP.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}calculateStat(){try{if(CP()&&this.element&&this._calculateTimeout<0){let e=0,t=null,i=(r,o)=>{this.stat.width=o.width,this.stat.height=o.height,t&&(this.stat.fps=Math.round((o.presentedFrames-t.presentedFrames)/(r-e)*1e3)),e=r,t=o,this._calculateTimeout=-1,this.element&&(this._calculateTimeout=setTimeout((()=>{var e;return null==(e=this.element)?void 0:e.requestVideoFrameCallback(i)}),2e3))};this.element.requestVideoFrameCallback(i)}}catch(kR){this._log.warn("init stat failed",kR)}}};function Lx(e,t){return cR(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),rM.info("worklet addModule success")}catch(kR){throw rM.info("worklet addModule catch error. ".concat(kR.message)),kR}}))}"undefined"!=typeof AudioContext?Ox=AudioContext:"undefined"!=typeof webkitAudioContext?Ox=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(Ox=mozAudioContext);var Px,xx=1500,Ux=-1,Vx=0,Fx=-1,Bx=!1,Hx=0,Wx=-1,jx=-1;!function e(){try{if(Px)return;(Px=new Ox({sampleRate:48e3})).onstatechange=()=>{rM.info("context state: ".concat(Px.state).concat("running"!==Px.state?" visibilityState: ".concat(document.visibilityState):"")),Gx()},clearTimeout(Ux)}catch(Vw){rM.error("initAudioContext failed: ".concat(Vw," typeof AudioContextClass: ").concat(typeof Ox)),Ux=setTimeout(e,1e3)}}();var Gx=()=>{"suspended"===Px.state?(Vx=cD(),-1===Fx&&(Fx=setTimeout((()=>{"suspended"===Px.state&&(Bx=!0,$O.emit("155",{isSuspended:!0}))}),xx)),Kx(),document.addEventListener("click",Gx)):"interrupted"===Px.state?Kx():(Vx&&(CL.addNumber({key:507800,value:cD()-Vx,split:[0,500,1e3,1500,2e3,3e3,4e3,5e3,1e4,3e4],max:6e4}),Vx=0),-1!==Fx&&(clearTimeout(Fx),Fx=-1,Bx&&(Bx=!1,$O.emit("155",{isSuspended:!1}))),document.removeEventListener("visibilitychange",Gx),document.removeEventListener("click",Gx))},zx=0,qx=-1;function Kx(){return new Promise(((e,t)=>{if("running"===Px.state)return e();Date.now()-zx<1e3?(clearTimeout(qx),qx=setTimeout((()=>{zx=Date.now(),Px.resume().then(e,t)}),1e3)):(clearTimeout(qx),zx=Date.now(),Px.resume().then(e,t))})).catch((e=>{rM.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",Gx)}))}document.addEventListener("click",Gx);var Yx=e=>Px,Xx=class{constructor(e){this.name=e,aR(this,"node"),aR(this,"node2"),aR(this,"pre",new Set),aR(this,"next",new Set),aR(this,"context"),aR(this,"connectedNodes",new Set),aR(this,"nextInputChannelMap",new Map),aR(this,"_channelCount",1)}get channelCount(){return this._channelCount}set channelCount(e){this._channelCount=e,this.setChannelCount(this.node,e),this.setChannelCount(this.node2,e),this.next.forEach((t=>t.channelCount=e))}setChannelCount(e,t){!e||e instanceof ScriptProcessorNode||(e.channelCountMode="explicit",e.channelCount=t||this.channelCount||1)}setContext(e){this.context=e,this.node&&e.addMixWeight()}removeContext(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}replaceNode(e){var t;if(e!==this.node)try{this.node?this._disconnect():null==(t=this.context)||t.addMixWeight(),this.node=e,this.setChannelCount(this.node),this.preNodeReconnect(),this.reconnect()}catch(Ok){rM.error(Ok)}}setNode(e,t){var i;if(!this.node)try{null==(i=this.context)||i.addMixWeight(),this.node=e,this.setChannelCount(this.node),t&&(this.node2=t,this.setChannelCount(this.node2)),this.preNodeReconnect(),this.reconnect(),CL.addSuccessEvent({key:502701})}catch(pM){rM.error(pM),CL.addFailedEvent({key:502701,error:pM})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),CL.addSuccessEvent({key:502702})}catch(kR){rM.error(kR),CL.addFailedEvent({key:502702,error:kR})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>{let i=this.nextInputChannelMap.get(t);e._connect(t.node,i)||t.connectNext(e)}))}_connect(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!this.node||!e)&&((this.node2||this.node).connect(e,0,t),this.connectedNodes.add(e),!0)}_disconnect(){this.connectedNodes.forEach((e=>{var t;return null==(t=this.node2||this.node)?void 0:t.disconnect(e)})),this.connectedNodes.clear()}reconnect(){this._disconnect(),this.connectNext(this)}pipeTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.next.add(e),e.pre.add(this),this.nextInputChannelMap.set(e,t),e}},Jx=class extends Xx{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,aR(this,"dataArray",new Uint8Array(0))}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,i=0,r="M".concat(t,",").concat(i);for(let o=0;o<e.length;o++)i=e[o]/128*100/2,r+="L".concat(t,",").concat(i),t+=1;return r}},Qx=class{constructor(){aR(this,"source",new Xx),aR(this,"gain",new Xx),aR(this,"destination",new Xx)}get volume(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(Yx().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){let t=tU(e);t&&this.source.replaceNode(t)}get track(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}get stream(){var e;return null==(e=this.destination.node)?void 0:e.stream}},$x=class extends Qx{constructor(e){super(),this.context=e,aR(this,"aec",new Xx("aec")),aR(this,"mixNode",new Xx("mixNode")),aR(this,"silentNode",new Xx("silentNode")),aR(this,"denoiser",new Xx("denoiser")),aR(this,"voiceChanger",new Xx("voiceChanger")),this.source.pipeTo(this.aec).pipeTo(this.denoiser).pipeTo(this.voiceChanger).pipeTo(this.gain).pipeTo(this.destination),this.silentNode.pipeTo(this.mixNode).pipeTo(this.aec,1)}get isProcessEnabled(){return this.aec.node||this.denoiser.node||this.voiceChanger.node||this.gain.node}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.aec.setContext(this.context),this.silentNode.setContext(this.context),this.mixNode.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.aec.removeContext(),this.silentNode.removeContext(),this.mixNode.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.aec.deleteNode(),this.silentNode.deleteNode(),this.mixNode.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},Zx=class{constructor(){aR(this,"audioContext",Yx()),aR(this,"destination",this.audioContext.createMediaStreamDestination()),aR(this,"inputs",new Set),aR(this,"mixWeight",0),this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},eU=new WeakMap;function tU(e){try{let t=eU.get(e);if(t)return t;let i=Yx();if(e instanceof HTMLAudioElement)t=i.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=i.createMediaStreamSource(new MediaStream([e]))}return eU.set(e,t),t}catch(uM){if(!(_N&&uM instanceof Error&&"NotSupportedError"===uM.name))throw uM;rM.warn(uM)}}var iU=class e{constructor(e){aR(this,"_volume",0),aR(this,"_volumeDb",0),aR(this,"_log"),aR(this,"_scriptProcessorNode",null),aR(this,"_audioWorkletNode",null),aR(this,"_interval",200),aR(this,"ready",this.preload());let{log:t}=e;this._log=t,$O.on(eM.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(!e.workletReady){let t='class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);';e.workletReady=Lx(e.audioContext,URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}return e.workletReady.then((()=>this.initAudioWorklet())).catch((e=>(this._log.error("volumeMeter preload error: ".concat(e)),this.initScriptProcessor())))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");let t=!1;this._audioWorkletNode.port.onmessage=i=>{e.lastMessageTime=Date.now(),this._volume=i.data.volume||0,this._volumeDb=i.data.volumeDb||0,!t&&i.data.cacheLen&&i.data.outputLen&&(this._log.warn("worklet play success"),t=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(uM){this._log.error("volumeMeter init audio worklet error: ".concat(uM)),ox.logFailedEvent({userId:this._log.userId,eventType:Lk.LOAD_WORKLET,error:uM}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=Yx().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let i=t.inputBuffer.getChannelData(0),r=0;for(let e=0;e<i.length;++e)r+=i[e]*i[e];this._volume=Math.sqrt(r/i.length)||0}}catch(uM){this._log.error("volumeMeter init script processor error: ".concat(uM))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,$O.off(eM.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}getVolumeDb(){return Math.floor(100*this._volumeDb)}handleAudioLevelInterval(e){var t;let{interval:i}=e;this._interval=i,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:i})}};aR(iU,"lastMessageTime",0),aR(iU,"audioContext",Yx()),aR(iU,"workletReady");var rU=iU,oU=class extends Xx{constructor(e){super(),aR(this,"_volumeMeter"),this._volumeMeter=new rU(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}init(){return cR(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}getVolumeDb(){return this._volumeMeter.getVolumeDb()}write(e){if(this.node){let t=e.allocationSize({planeIndex:0}),i=new Float32Array(t>>2);e.copyTo(i,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:i},[i.buffer]),e.close()}}},nU=rU,aU=oR(lR(),1),sU=e=>t=>t.deviceId===e,cU=class{constructor(e,t){aR(this,"kind"),aR(this,"type"),aR(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let i=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));1===this.devices.length&&uU(this.devices[0])||t&&(i.forEach((e=>{if(e.deviceId&&!this.devices.find(sU(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Added");rM.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!i.find(sU(e.deviceId))){let i="".concat(this.kind).concat(this.type,"Removed");rM.warn("".concat(i,": ").concat(JSON.stringify(e))),t.emit(i,e)}}))),this.devices=i}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},lU=class extends aU.EventEmitter{constructor(){super(),aR(this,"audioInputs",new cU(ok.AUDIO,"Input")),aR(this,"videoInputs",new cU(ok.VIDEO,"Input")),aR(this,"audioOutputs",new cU(ok.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||$P.run("interval",(()=>{this.update()}),{delay:1e4}))}init(){hU().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return cR(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let i=yield hU(t);return e.audioInputs.update(i,e),e.videoInputs.update(i,e),e.audioOutputs.update(i,e),e}()}))}hasBlueTooth(){var e;if(1e3*(null==(e=Yx())?void 0:e.outputLatency)>150)return!0;let t=["bluetooth","air","wireless","bt","tws","buds","headset","headphone"];return this.audioOutputs.devices.some((e=>t.some((t=>e.label.toLowerCase().includes(t)))))||this.audioInputs.devices.some((e=>t.some((t=>e.label.toLowerCase().includes(t)))))}},dU=NR||DR?null:new lU;function uU(e){return e.deviceId===e.groupId&&""===e.groupId}function hU(){return cR(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(UL()||!PL())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let i={audio:!1,video:!1};if(t.forEach((e=>{uU(e)&&(e.kind===ok.AUDIO_INPUT?i.audio=!0:e.kind===ok.VIDEO_INPUT&&(i.video=!0))})),2===e&&(i.audio=!1),1===e&&(i.video=!1),i.audio||i.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(i),i.audio&&Kx()}catch(pM){rM.debug("capture before getDevices failed: ",pM)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let i={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&gU.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(i.getCapabilities=()=>e.getCapabilities()),i}))}()}))}function pU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return dU.update(e?1:0).then((e=>e.audioInputs.devices))}function mU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return dU.update(e?2:0).then((e=>e.videoInputs.devices))}var fU=!1;function _U(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return cR(this,null,(function*(){return(uN||TO)&&(e=!1),dU.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var gU=new Set;function vU(e,t){return cR(this,null,(function*(){let i=(yield pU()).find((e=>e.deviceId===Qk));return!t&&(null==i?void 0:i.groupId)===e||(null==i?void 0:i.groupId)===e&&i.label===t}))}var EU,yU=class extends Qx{constructor(e){super(),this.log=e,aR(this,"volumeMeter"),aR(this,"volumeMeterAfter3A"),aR(this,"volumeDestination"),aR(this,"analyser",new Jx),this.volumeMeter=new oU({log:this.log}),this.volumeMeterAfter3A=new oU({log:this.log}),this.volumeDestination=new Xx,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},TU=class e extends sx{constructor(e){super(e,ok.AUDIO),aR(this,"_outputDeviceId"),aR(this,"_volume",1),aR(this,"_destination",Yx().createMediaStreamDestination()),aR(this,"pipeline"),aR(this,"volumeMeterMode","worklet"),aR(this,"enableVolumeControlInIOS"),this.enableVolumeControlInIOS=e.enableVolumeControlInIOS,this.mode=0,e.url&&(this.url=e.url),this.pipeline=new yU(this._log)}get duration(){var e;return Math.floor(1e3*((null==(e=this.element)?void 0:e.duration)||0))}get currentTime(){var e;return Math.floor(1e3*((null==(e=this.element)?void 0:e.currentTime)||0))}set currentTime(e){this.element&&(this.element.currentTime=e/1e3)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(e){if(("15.2"===SO||"15.3"===SO||"15.4"===SO)&&this.muted)return void this._log.info("audioElement is muted.");let t=EU||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.url&&(t.crossOrigin="anonymous",t.src=this.url),this.element=t,JC(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===EU&&(EU=void 0),this.options.enableTimeupdateEvent&&(this.element.ontimeupdate=()=>this.emit(ZP.TIME_UPDATE,this.currentTime)),this.bindElementEvents()}play(t){return cR(this,null,(function*(){if(this.track||this.url)return!this.pipeline.source.node&&this.track&&this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==t?void 0:t.volume),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?(this.pipeline.volumeMeter.init(),this.pipeline.volumeMeterAfter3A.init()):"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(Yx().createAnalyser()),function(){cR(this,null,(function*(){try{fU||(fU=!0,rM.info("speakers:".concat((yield _U()).map((e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label))))))}catch(e){}}))}(),sR(e.prototype,this,"play").call(this)}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}setSinkId(e){return cR(this,null,(function*(){var t,i;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(i=(t=this.element).setSinkId)?void 0:i.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){this.element&&(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}getInternalAudioLevelAfter3A(){return this.pipeline.volumeMeterAfter3A.getInternalAudioLevel()}},IU=class extends TU{setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(ZP.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}},AU=class extends TU{constructor(e){super(e),aR(this,"_sourceElement"),aR(this,"_output",new Xx),this.pipeline.source.pipeTo(this.pipeline.gain),this.pipeline.gain.pipeTo(this.pipeline.volumeMeter).pipeTo(this._output),this.pipeline.gain.pipeTo(this.pipeline.destination)}setOutput(){this.mode=1,this._output.setNode(Yx().destination)}write(e){this.pipeline.volumeMeter.write(e)}setTrack(e){var t,i,r;(null==(i=null==(t=this.element)?void 0:t.error)?void 0:i.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(ZP.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.source.channelCount=(null==(r=e.getSettings())?void 0:r.channelCount)||1,this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}setVolume(e){if(this._volume=e,this.useDestination)this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e));else if(e<=1&&!uN)this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element");else{if(uN){if(!this.enableVolumeControlInIOS)return;!function(){if(!uN||-1!==jx)return;let e=()=>{cD()-Hx<500||(Px&&"running"===Px.state&&Px.currentTime===Wx&&(rM.warn("context is fake running, auto resume"),Px.suspend().catch((e=>{rM.warn("context suspend failed: ".concat(e))}))),Wx=Px.currentTime,Hx=cD())};jx=setInterval((()=>{e()}),2e3),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&e()}))}()}if(_N&&!this.pipeline.source.node)return void this._log.warn("set pipeline volume failed: no source node");this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),rx(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play())}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&IO&&(EU=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},bU=class extends qP{constructor(e){let{userId:t,sdkAppId:i,mediaType:r,room:o,PlayerClass:n=(1===r?AU:Mx)}=e;var a;super(),aR(this,"id",oM()),aR(this,"userId",""),aR(this,"isRemote"),aR(this,"mediaType"),aR(this,"room"),aR(this,"user"),aR(this,"_log"),aR(this,"_inputTrack"),aR(this,"_outputTrack"),aR(this,"isPlayCalled"),aR(this,"container",null),aR(this,"player"),aR(this,"subVideoPlayerMap"),aR(this,"muted",!1),aR(this,"abortCtrl"),aR(this,"objectFit","cover"),aR(this,"mirror"),aR(this,"rotation"),aR(this,"isScreen",!1),aR(this,"manager"),aR(this,"trackSettings"),aR(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=r,this._log=rM.createLogger({parent:null==o?void 0:o.getLogger(),id:"".concat(this.kind[0],"t"),userId:null==(a=o||this.room)?void 0:a.userId,remoteUserId:this instanceof cB?void 0:this.userId,sdkAppId:i,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof cB}),this.player=new n({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log,enableVolumeControlInIOS:null==o?void 0:o.enableVolumeControlInIOS}),this.player.on(ZP.PLAYER_STATE_CHANGED,(e=>{if($O.emit(eM.PLAYER_STATE_CHANGED,Zw({track:this},e)),this.emit("player-state-changed",e),"PLAYING"===e.state&&this.room){let e=!0;for(let{remoteAudioTrack:t,remoteVideoTrack:i,remoteAuxiliaryTrack:r}of[...this.room.remotePublishedUserMap.values()])if(t.isAvailable&&!t.player.isPlaying||i.isAvailable&&!i.player.isPlaying||r.isAvailable&&!r.player.isPlaying){e=!1;break}e&&Sx()&&Dx&&(Dx.deleteDialog(),Dx=null)}})),this.kind===ok.VIDEO&&(this.player.on(ZP.LOADED_DATA,(()=>{this.emitFirstVideoFrameEvent(ZP.LOADED_DATA),$O.emit(eM.VIDEO_LOADED_DATA,{track:this})})),this.player.on(ZP.LOADED_META_DATA,(()=>{this.emitFirstVideoFrameEvent(ZP.LOADED_META_DATA)})),this.player.on(ZP.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))})),this.player.on(ZP.RESIZE,(e=>{this.emitFirstVideoFrameEvent(ZP.RESIZE),this.emit("video-size-changed",Zw({userId:this.userId,streamType:2===this.mediaType?"auxiliary":"main"},e))}))),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this),this.onPlayerError&&this.player.on(ZP.ERROR,this.onPlayerError.bind(this))}get log(){return this._log||rM}get kind(){return 1===this.mediaType?ok.AUDIO:ok.VIDEO}get isAudio(){return this.kind===ok.AUDIO}get strMediaType(){return 4===this.mediaType?ok.VIDEO:2===this.mediaType?ok.SCREEN:ok.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}play(e,t){return cR(this,null,(function*(){let i=ZC(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!YC(t.muted)&&this.setPlayerMute(t.muted),t&&!YC(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof Mx&&(this.player.setObjectFit(this.objectFit),this.container!==i&&i&&(this.container=i,this.player.setContainer(i)),ZC(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!YC(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===ok.VIDEO)&&this.setPlayerMute(!0),t&&!YC(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof Mx&&(this.player.setObjectFit(this.objectFit),t&&!YC(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,i&&(this.container=i,this.player instanceof Mx&&this.player.setContainer(i)),$O.emit(eM.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(t),ZC(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(_M){throw this.handleAutoPlayFailed(_M),_M}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==ok.VIDEO||YC(e)||e===this.mirror)return;this.mirror=e;let i=this.player;t&&(i=t);let r=this.manager;if(QC(this.mirror))return i.setViewMirror(this.mirror),void(!this.isRemote&&r&&(r.mirror=!1));switch(this.mirror){case"view":r&&(r.mirror=!1),i.setViewMirror(!0);break;case"publish":r&&(r.mirror=!0),i.setViewMirror(!0);break;case"both":r&&(r.mirror=!0),i.setViewMirror(!1)}}playSubContainer(e,t){return cR(this,null,(function*(){if(!this._outputTrack||this.kind===ok.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,i)=>{var r;e.find((e=>i===e))||(t.stop(),null==(r=this.subVideoPlayerMap)||r.delete(i))}));for(let[r,o]of e.entries()){let e=this.subVideoPlayerMap.get(o);e?t&&(YC(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(o,new Mx({id:this.userId||this.id,track:this.playerMediaTrack,container:o,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(r+1)})}))}let i=[...this.subVideoPlayerMap.values()];for(let e of i)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(JD(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return cR(this,null,(function*(){var e;this.isPlayCalled&&(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),$O.emit(e?eM.TRACK_MUTED:eM.TRACK_UNMUTED,{track:this})}setPlayerMute(e){this.player.setMuted(e)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}get playerMediaTrack(){return this.outMediaTrack}installTrackEvent(e){ix(e,e).add(ok.MUTE,this.onTrackMuted).add(ok.UNMUTE,this.onTrackUnmuted).add(ok.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===ok.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){rx(e)}setInputMediaStreamTrack(e){var t;let i=this._inputTrack;if(e!==i)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,i&&this.uninstallTrackEvent(i),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,i||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((e=>this.handleAutoPlayFailed(e))),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(JD(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(e){return cR(this,null,(function*(){var t;this.log.warn("handleAutoPlayFailed",e);let i=()=>{this.resume().then((()=>{document.removeEventListener("click",i,!0)}))};if(this.room&&this.room.enableAutoPlayDialog){if((DN||PN)&&(yield kD(100),null!=(t=this.player)&&t.isPlaying))return;Nx()}else document.addEventListener("click",i,!0);$O.once(eM.LOCAL_TRACK_CAPTURE_SUCCESS,(e=>{let{track:t}=e;"audio"===t.kind&&Sx()&&!this.player.isPlaying&&this.isRemote&&this.isAvailable&&i()})),this.emit("error",e)}))}getVideoFrame(){return this.player instanceof Mx?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,i,r;if(this.isFirstVideoFrameEmitted)return;let o=null==(t=this.mediaTrack)?void 0:t.getSettings(),n=(null==o?void 0:o.width)||(null==(i=this.player.element)?void 0:i.videoWidth)||0,a=(null==o?void 0:o.height)||(null==(r=this.player.element)?void 0:r.videoHeight)||0;e===ZP.RESIZE&&!n&&!a||e===ZP.LOADED_META_DATA&&!n&&!a||(e===ZP.LOADED_DATA&&!n&&!a&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,MD(this.rotation)&&([n,a]=[a,n]),this.emit("first-video-frame",{width:n,height:a,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}onTrackMuted(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}onTrackUnmuted(){this._log.info("".concat(this.kind," track is able to provide media output"))}onTrackEnded(){this._log.warn("".concat(this.kind," track ended"))}};nR([jP([],qP.INIT,{sync:!0})],bU.prototype,"close",1);var SU=Object.prototype.hasOwnProperty;var wU=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(jC(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(SU.call(e,t))return!1;return!0}return!1},RU=$D({retryFunction:function(e){return cR(this,null,(function*(){let t=function(e){return{audio:CU(e),video:DU(e)}}(e);rM.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let i=[],r=[],o=["label","deviceId","groupId"];if(t.audio&&(i=yield pU(),rM.info("microphones: ".concat(TD(i.map((e=>eR(Zw({},e),{groupId:e.groupId.substring(0,8)}))),{keysToInclude:o})))),t.video&&(r=yield mU(),rM.info("cameras: ".concat(TD(r,{keysToInclude:o}))),!QC(t.video)&&"user"===t.video.facingMode&&!t.video.deviceId)){let e=r.filter((e=>!e.label.includes("infrared"))).find((e=>e.label.includes("facing front")));e&&(t.video.deviceId=e.deviceId,rM.info("exclude infrared camera: ".concat(JSON.stringify(t))))}try{let i=yield navigator.mediaDevices.getUserMedia(t);return fP&&i.getTracks().forEach((t=>{var i;let r=t.getCapabilities();rM.info("".concat(t.kind," capabilities: ").concat(TD(r,{keysToInclude:oC}))),!YC(e.echoCancellation)&&-1===(null==(i=r.echoCancellation)?void 0:i.indexOf(e.echoCancellation))&&rM.warn("Invalid argument for 'echoCancellation'. Expected one of [".concat(JSON.stringify(r.echoCancellation),"], but received '").concat(e.echoCancellation,"'"))})),t.audio&&Kx(),i}catch(_M){let{message:o}=_M;throw"NotFoundError"===_M.name&&(e.video&&r&&0===r.length&&(o=vL({key:mL.CAMERA_NOT_FOUND})),e.audio&&i&&0===i.length&&(o=vL({key:mL.MICROPHONE_NOT_FOUND}))),new vR({code:_R.INITIALIZE_FAILED,name:_M.name,message:o,constraint:_M.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:i,reject:r,retryFuncArgs:o,retriedCount:n}=e,a=n+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name||"AbortError"===t.name?(1===a?(o[0].video&&(o[0].maxResolution=!1,(!TO||o[0].width*o[0].height<=2073600)&&o[0].frameRate&&(o[0].frameRate=o[0].frameRate>10?10:5)),o[0].retryWhenExactFailed&&o[0].useExactDeviceId&&(o[0].useExactDeviceId=!1)):2===a?o[0].useDeviceIdOnly=!0:3===a&&!o[0].useExactDeviceId&&(o[0].useTrueAsConstraint=!0),i()):r(t),o[0].microphoneId&&kU(o[0].microphoneId,!1),o[0].cameraId&&kU(o[0].cameraId,!0)},onRetrying:e=>{rM.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{ox.logFailedEvent({eventType:Lk.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{ox.logSuccessEvent({eventType:Lk.GET_USER_MEDIA_RETRY}),ox.uploadEvent({log:"stat-".concat(Lk.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function kU(e,t){return cR(this,null,(function*(){let i=(t?yield mU():yield pU()).find((t=>t.deviceId===e));i&&KC(i.getCapabilities)&&rM.warn(TD(i.getCapabilities(),{keysToInclude:oC}))}))}function CU(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!wU(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(JC(e.channelCount)&&(t.channelCount=e.channelCount),(QC(e.echoCancellation)||"remote-only"===e.echoCancellation||"all"===e.echoCancellation)&&(t.echoCancellation=e.echoCancellation),QC(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),QC(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!wU(t)||t)}function DU(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;let{maxResolution:t=!0}=e,i={};return e.cameraId?i.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(i.facingMode=e.facingMode),e.useDeviceIdOnly&&!wU(i)?i:(e.width&&(i.width={ideal:e.width},t&&!_N&&(i.width.max=e.width)),e.height&&(i.height={ideal:e.height},t&&!_N&&(i.height.max=e.height)),_N&&KN&&e.width&&e.height&&e.width*e.height<101376&&(i.width=e.width,i.height=e.height),e.frameRate&&(i.frameRate=e.frameRate),!!wU(i)||i)}var NU=RU;function OU(e){return MU(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return cR(this,null,(function*(){let i=yield t.apply(this,r);return yield e.call(this,...r),i}))}))}function MU(e){return function(t,i,r){return r.value=e(r.value,i),r}}var LU=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&rM.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{rM.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),PU=0,xU=class{constructor(){aR(this,"log",rM.createLogger({id:"fq".concat(++PU)})),aR(this,"isRunning",!1),aR(this,"queue",[])}get length(){return this.queue.length}get lastQueueItem(){return 0===this.length?null:this.queue[this.length-1]}push(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i,r;let o=Zw({},e),n=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));return o.promise=n,t?this.length<=1?this.queue.push(o):null==(r=null==(i=this.lastQueueItem)?void 0:i.promise)||r.then(o.resolve,o.reject):this.queue.push(o),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),n}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}callNext(){if(this.isRunning||0===this.length)return;this.log.debug("callNext ",this.length);let{fn:e,args:t,context:i,resolve:r,reject:o}=this.queue[0];this.isRunning=!0,e.apply(i,t).then(r,o).finally((()=>{this.isRunning=!1,this.shift(),this.callNext()}))}},UU=new WeakMap,VU=new WeakMap;function FU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,i,r){let o=r.value;return r.value=function(){let t=UU.get(this)||new xU;for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return UU.set(this,t),t.push({fn:o,args:r,context:this},e)},r}}function BU(e){return function(t,i,r){let o=r.value,n=t=>e(...t);return r.value=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];let r=VU.get(this)||new Map,a=r.get(n(t))||new xU;return r.set(n(t),a),VU.set(this,r),a.push({fn:o,args:t,context:this})},r}}function HU(e,t){return MU(((i,r)=>function(){let r=e;try{for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let e=i.apply(this,n),s=cD();return iD(e)?e.then((e=>(t?CL.addSuccessEvent({key:r,cost:cD()-s}):CL.addSuccessEvent({key:r}),e))).catch((e=>{throw CL.addFailedEvent({key:r,error:e}),e})):(CL.addSuccessEvent({key:r}),e)}catch(CR){throw CL.addFailedEvent({key:r,error:CR}),CR}}))}var WU={};function jU(){}rR(WU,{Events:()=>oV,Inspect:()=>XU,LastSink:()=>JU,Sink:()=>QU,Subscribe:()=>$U,TimeoutError:()=>nV,audit:()=>hF,bindCallback:()=>HV,bindNodeCallback:()=>WV,buffer:()=>vV,bufferCount:()=>gV,bufferTime:()=>XF,call:()=>GU,catchError:()=>QF,combineLatest:()=>pV,concat:()=>dV,concatMap:()=>UF,concatMapTo:()=>VF,count:()=>YV,create:()=>eV,debounce:()=>fF,debounceTime:()=>_F,defer:()=>TV,delay:()=>JF,deliver:()=>tV,dispose:()=>qU,elementAt:()=>gF,empty:()=>zV,every:()=>IF,exhaustMap:()=>zF,exhaustMapTo:()=>qF,expand:()=>ZF,filter:()=>$V,find:()=>vF,findIndex:()=>EF,first:()=>yF,fromAnimationFrame:()=>FV,fromArray:()=>kV,fromEvent:()=>MV,fromEventPattern:()=>OV,fromFetch:()=>PV,fromIterable:()=>xV,fromPromise:()=>LV,fromReadableStream:()=>VV,fromReader:()=>UV,groupBy:()=>KF,identity:()=>zU,ignoreElements:()=>ZV,iif:()=>hV,inspect:()=>KU,interval:()=>CV,last:()=>TF,map:()=>wF,mapTo:()=>RF,max:()=>XV,merge:()=>cV,mergeMap:()=>HF,mergeMapTo:()=>WF,min:()=>JV,never:()=>jV,nothing:()=>jU,of:()=>RV,pairwise:()=>bF,pipe:()=>ZU,race:()=>lV,range:()=>BV,reduce:()=>KV,retry:()=>nB,scan:()=>AF,setAsapScheduler:()=>SV,share:()=>sV,shareReplay:()=>uV,skip:()=>oF,skipUntil:()=>nF,skipWhile:()=>aF,startWith:()=>fV,subject:()=>yV,subscribe:()=>iB,sum:()=>QV,switchMap:()=>OF,switchMapTo:()=>LF,take:()=>eF,takeLast:()=>rF,takeUntil:()=>tF,takeWhile:()=>iF,tap:()=>rB,throttle:()=>dF,throwError:()=>GV,timeInterval:()=>YF,timeout:()=>oB,timer:()=>DV,toPromise:()=>eB,toReadableStream:()=>tB,withLatestFrom:()=>_V,zip:()=>mV});var GU=e=>e(),zU=e=>e;function qU(){this.dispose()}var KU=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,YU=1,XU=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new rV(e,this,this.streamId++);return oV.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},JU=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=jU,this.error=jU,this.next=jU,this.dispose=jU,this.subscribe=jU,this.doDefer()}subscribe(e){return e instanceof XU?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(GU),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},QU=class extends JU{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}},$U=class extends JU{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jU,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:jU,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:jU;if(super(),this._next=t,this._error=i,this._complete=r,this.then=jU,e instanceof XU){let o={toString:()=>"subscribe",id:0,source:e};this.defer((()=>{oV.defer(o,0)})),oV.create(o),oV.pipe(o),this.sourceId=o.id,this.subscribe(e),oV.subscribe({id:o.id,end:!0}),t==jU?this._next=e=>oV.next(o,0,e):this.next=e=>{oV.next(o,0,e),t(e)},r==jU?this._complete=()=>oV.complete(o,0):this.complete=()=>{this.dispose(),oV.complete(o,0),r()},i==jU?this._error=e=>oV.complete(o,0,e):this.error=e=>{this.dispose(),oV.complete(o,0,e),i(e)}}else this.subscribe(e)}next(e){this._next(e)}complete(){this.dispose(),this._complete()}error(e){this.dispose(),this._error(e)}};function ZU(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return i.reduce(((e,t)=>t(e)),e)}function eV(e,t,i){if(KU()){let r=Object.defineProperties(Object.setPrototypeOf(e,XU.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:i,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});oV.create(r);for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t&&t instanceof XU&&oV.addSource(r,t)}return r}return e}function tV(e,t){return function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return i=>{if(i instanceof XU){let o=eV((t=>{let n=new e(t,...r);n.sourceId=o.id,n.subscribe(i)}),t,arguments);return o.source=i,oV.pipe(o),o}return t=>i(new e(t,...r))}}}function iV(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var rV=class extends QU{constructor(e,t,i){super(e),this.source=t,this.id=i,this.sourceId=e.sourceId,this.defer((()=>{oV.defer(this.source,this.id)}))}next(e){oV.next(this.source,this.id,e),this.sink.next(e)}complete(){oV.complete(this.source,this.id),this.sink.complete()}error(e){oV.complete(this.source,this.id,e),this.sink.error(e)}},oV={addSource(e,t){iV("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,i){iV("next",{id:e.id,streamId:t,data:i&&i.toString()})},subscribe(e,t){let{id:i,end:r}=e;iV("subscribe",{id:i,end:r,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,i){iV("complete",{id:e.id,streamId:t,err:i?i.toString():null})},defer(e,t){iV("defer",{id:e.id,streamId:t})},pipe(e){iV("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){iV("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=YU++),iV("create",{name:e.toString(),id:e.id})}},nV=class extends Error{constructor(e){super("timeout after ".concat(e,"ms")),this.timeout=e}},aV=class extends JU{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}};function sV(){return e=>{let t=new aV(e);if(e instanceof XU){let i=eV((e=>{t.add(e)}),"share",arguments);return t.sourceId=i.id,i.source=e,oV.pipe(i),i}return eV(t.add.bind(t),"share",arguments)}}function cV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV((e=>{let i=new QU(e),r=t.length;i.complete=()=>{0==--r&&e.complete()},t.forEach(i.bindSubscribe)}),"merge",arguments)}function lV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV((e=>{let i=new Map;t.forEach((t=>{let r=new QU(e);i.set(t,r),r.complete=()=>{i.delete(t),0===i.size?e.complete():r.dispose()},r.next=e=>{i.delete(t),i.forEach((e=>e.dispose())),r.resetNext(),r.resetComplete(),r.next(e)}})),t.forEach((e=>i.get(e).subscribe(e)))}),"race",arguments)}function dV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV((e=>{let i=0,r=t.length,o=new QU(e);o.complete=()=>{i<r&&!o.disposed?(o.doDefer(),o.subscribe(t[i++])):e.complete()},o.complete()}),"concat",arguments)}function uV(e){return t=>{let i=new aV(t),r=[];return i.next=function(t){r.push(t),r.length>e&&r.shift(),this.sinks.forEach((e=>e.next(t)))},eV((e=>{e.defer((()=>i.remove(e))),r.forEach((t=>e.next(t))),i.add(e)}),"shareReplay",arguments)}}function hV(e,t,i){return eV((r=>e()?t(r):i(r)),"iif",arguments)}function pV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV((e=>{let i=t.length,r=i,o=i,n=new Array(i),a=()=>{0==--o&&e.complete()};t.forEach(((t,i)=>{let o=new QU(e);o.next=t=>{r--,o.next=t=>{n[i]=t,0===r&&e.next(n)},o.next(t)},o.complete=a,o.subscribe(t)}))}),"combineLatest",arguments)}function mV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV((e=>{let i=t.length,r=i,o=new Array(i),n=()=>{0==--r&&e.complete()};t.forEach(((t,i)=>{let r=new QU(e),a=[];o[i]=a,r.next=t=>{a.push(t),o.every((e=>e.length))&&e.next(o.map((e=>e.shift())))},r.complete=n,r.subscribe(t)}))}),"zip",arguments)}function fV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return e=>eV((function(i){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;r<o&&!i.disposed;)i.next(t[r++]);i.disposed||i.subscribe(e)}),"startWith",arguments)}var _V=tV(class extends QU{constructor(e){super(e);let t=new QU(this.sink);for(var i=arguments.length,r=new Array(i>1?i-1:0),o=1;o<i;o++)r[o-1]=arguments[o];t.next=e=>this.buffer=e,t.complete=jU,t.subscribe(pV(...r))}next(e){this.buffer&&this.sink.next([e,...this.buffer])}},"withLatestFrom"),gV=tV(class extends QU{constructor(e,t,i){super(e),this.bufferSize=t,this.startBufferEvery=i,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((t=>{t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((e=>this.sink.next(e))),super.complete()}},"bufferCount"),vV=tV(class extends QU{constructor(e,t){super(e),this.buffer=[];let i=new QU(e);i.next=t=>{e.next(this.buffer),this.buffer=[]},i.complete=jU,i.subscribe(t)}next(e){this.buffer.push(e)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},"buffer"),EV=function(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{c(r.next(e))}catch(t){n(t)}}function s(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){e.done?o(e.value):function(e){return e instanceof i?e:new i((function(t){t(e)}))}(e.value).then(a,s)}c((r=r.apply(e,t||[])).next())}))};function yV(e){let t=arguments,i=sV()(eV((t=>{i.next=e=>t.next(e),i.complete=()=>t.complete(),i.error=e=>t.error(e),e&&t.subscribe(e)}),"subject",t));return i.next=jU,i.complete=jU,i.error=jU,i}function TV(e){return eV((t=>t.subscribe(e())),"defer",arguments)}var IV={promise:e=>{Promise.resolve().then(e)},setImmediate:"undefined"!=typeof setImmediate?e=>setImmediate(e):null,setTimeout:e=>setTimeout(e,0)},AV="undefined"!=typeof Promise?IV.promise:IV.setImmediate?IV.setImmediate:IV.setTimeout,bV=e=>t=>{AV((()=>e(t)))},SV=e=>{"function"==typeof e?AV=e:IV[e]&&(AV=IV[e])},wV=e=>bV((t=>{for(let i=0;!t.disposed&&i<e.length;i++)t.next(e[i]);t.complete()}));function RV(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return eV(wV(t),"of",arguments)}function kV(e){return eV(wV(e),"fromArray",arguments)}function CV(e){return eV((t=>{let i=0,r=setInterval((()=>t.next(i++)),e);return t.defer((()=>{clearInterval(r)})),"interval"}),"interval",arguments)}function DV(e,t){return eV((i=>{let r=0,o=setTimeout((()=>{if(i.removeDefer(n),i.next(r++),t){let e=setInterval((()=>i.next(r++)),t);i.defer((()=>{clearInterval(e)}))}else i.complete()}),e),n=()=>clearTimeout(o);i.defer(n)}),"timer",arguments)}function NV(e,t){return i=>{let r=e=>i.next(e);i.defer((()=>t(r))),e(r)}}function OV(e,t){return eV(NV(e,t),"fromEventPattern",arguments)}function MV(e,t){if("on"in e&&"off"in e)return eV(NV((i=>e.on(t,i)),(i=>e.off(t,i))),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return eV(NV((i=>e.addListener(t,i)),(i=>e.removeListener(t,i))),"fromEvent",arguments);if("addEventListener"in e)return eV(NV((i=>e.addEventListener(t,i)),(i=>e.removeEventListener(t,i))),"fromEvent",arguments);throw"target is not a EventDispachter"}function LV(e){return eV((t=>{e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function PV(e,t){return eV(TV((()=>LV(fetch(e,t)))),"fromFetch",arguments)}function xV(e){return eV(bV((t=>{try{for(let i of e){if(t.disposed)return;t.next(i)}t.complete()}catch(kR){t.error(kR)}})),"fromIterable",arguments)}function UV(e){let t=i=>EV(this,void 0,void 0,(function*(){if(i.disposed)return;let{done:r,value:o}=yield e.read();r?i.complete():(i.next(o),t(i))}));return eV((e=>{t(e)}),"fromReader",arguments)}function VV(e){return eV((t=>{let i=new AbortController,r=i.signal;t.defer((()=>i.abort("cancelled"))),e.pipeTo(new WritableStream({write(e){t.next(e)},close(){t.complete()},abort(e){t.error(e)}}),{signal:r}).then((()=>t.complete()),(e=>t.error(e)))}),"fromReadableStream",arguments)}function FV(){return eV((e=>{let t=requestAnimationFrame((function i(r){e.disposed||(e.next(r),t=requestAnimationFrame(i))}));e.defer((()=>cancelAnimationFrame(t)))}),"fromAnimationFrame",arguments)}function BV(e,t){return eV((function(i){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;for(;r<o&&!i.disposed;)i.next(r++);return i.complete(),"range"}),"range",arguments)}function HV(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return eV((i=>{let o=r.concat((e=>(i.next(e),i.complete())));e.apply(t,o)}),"bindCallback",arguments)}function WV(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return eV((i=>{let o=r.concat(((e,t)=>e?i.error(e):(i.next(t),i.complete())));e.apply(t,o)}),"bindNodeCallback",arguments)}function jV(){return eV((()=>{}),"never",arguments)}function GV(e){return eV((t=>t.error(e)),"throwError",arguments)}function zV(){return eV((e=>e.complete()),"empty",arguments)}var qV=class extends QU{constructor(e,t,i){super(e),this.f=t;let r=()=>{this.sink.next(this.acc),this.sink.complete()};void 0===i?this.next=e=>{this.acc=e,this.complete=r,this.resetNext()}:(this.acc=i,this.complete=r)}next(e){this.acc=this.f(this.acc,e)}},KV=tV(qV,"reduce"),YV=e=>tV(qV,"count")(((t,i)=>e(i)?t+1:t),0),XV=()=>tV(qV,"max")(Math.max),JV=()=>tV(qV,"min")(Math.min),QV=()=>tV(qV,"sum")(((e,t)=>e+t),0),$V=tV(class extends QU{constructor(e,t,i){super(e),this.filter=t,this.thisArg=i}next(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}},"filter"),ZV=tV(class extends QU{next(e){}},"ignoreElements"),eF=tV(class extends QU{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0==--this.count&&(this.doDefer(),this.complete())}},"take"),tF=tV(class extends QU{constructor(e,t){super(e);let i=new QU(e);i.next=()=>{i.doDefer(),e.complete()},i.complete=qU,i.subscribe(t)}},"takeUntil"),iF=tV(class extends QU{constructor(e,t){super(e),this.f=t}next(e){this.f(e)?this.sink.next(e):(this.doDefer(),this.complete())}},"takeWhile"),rF=e=>KV(((t,i)=>(t.push(i),t.length>e&&t.shift(),t)),[]),oF=tV(class extends QU{constructor(e,t){super(e),this.count=t}next(e){0==--this.count&&(this.next=super.next)}},"skip"),nF=tV(class extends QU{constructor(e,t){super(e),e.next=jU;let i=new QU(e);i.next=()=>{i.doDefer(),e.resetNext()},i.complete=qU,i.subscribe(t)}},"skipUntil"),aF=tV(class extends QU{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),sF={leading:!0,trailing:!1},cF=class extends QU{constructor(e,t,i){super(e),this.durationSelector=t,this.trailing=i}cacheValue(e){this.last=e,this.disposed&&this.throttle(e)}send(e){this.sink.next(e),this.throttle(e)}throttle(e){this.reset(),this.subscribe(this.durationSelector(e))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},lF=class extends QU{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sF;super(e),this.durationSelector=t,this.config=i,this._throttle=new cF(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}complete(){this._throttle.throttle=jU,this._throttle.complete(),super.complete()}},dF=tV(lF,"throttle"),uF={leading:!1,trailing:!0},hF=e=>tV(lF,"audit")(e,uF),pF=class extends QU{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},mF=class extends QU{constructor(e,t){super(e),this.durationSelector=t,this._debounce=new pF(this.sink),this._debounce.dispose()}next(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}complete(){this._debounce.complete(),super.complete()}},fF=tV(mF,"debounce"),_F=e=>tV(mF,"debounceTime")((t=>DV(e))),gF=tV(class extends QU{constructor(e,t,i){super(e),this.count=t,this.defaultValue=i}next(e){0==this.count--&&(this.defaultValue=e,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("not enough elements in sequence"))}},"elementAt"),vF=e=>t=>eF(1)(aF((t=>!e(t)))(t)),EF=tV(class extends QU{constructor(e,t){super(e),this.f=t,this.i=0}next(e){this.f(e)?(this.sink.next(this.i++),this.doDefer(),this.complete()):++this.i}},"findIndex"),yF=tV(class extends QU{constructor(e,t,i){super(e),this.f=t,this.defaultValue=i,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"first"),TF=tV(class extends QU{constructor(e,t,i){super(e),this.f=t,this.defaultValue=i,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"last"),IF=tV(class extends QU{constructor(e,t){super(e),this.predicate=t,this.index=0}next(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.doDefer(),this.complete())}complete(){void 0!==this.result?(this.sink.next(this.result),super.complete()):this.error(new Error("no elements in sequence"))}},"every"),AF=tV(class extends QU{constructor(e,t,i){super(e),this.f=t,void 0===i?this.next=e=>{this.acc=e,this.resetNext(),this.sink.next(this.acc)}:this.acc=i}next(e){this.sink.next(this.acc=this.f(this.acc,e))}},"scan"),bF=tV(class extends QU{constructor(){super(...arguments),this.hasLast=!1}next(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}},"pairwise"),SF=class extends QU{constructor(e,t,i){super(e),this.mapper=t,this.thisArg=i}next(e){super.next(this.mapper.call(this.thisArg,e))}},wF=tV(SF,"map"),RF=e=>tV(SF,"mapTo")((t=>e)),kF=class extends QU{constructor(e,t,i){super(e),this.data=t,this.context=i}next(e){let t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}tryComplete(){this.context.resetComplete(),this.dispose()}},CF=class e extends QU{constructor(e,t,i){super(e),this.makeSource=t,this.combineResults=i,this.index=0}subInner(t,i){let r=this.currentSink=new i(this.sink,t,this);this.complete===e.prototype.complete&&(this.complete=this.tryComplete),r.complete=r.tryComplete,r.subscribe(this.makeSource(t,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},DF=class extends kF{},NF=class extends CF{next(e){this.subInner(e,DF),this.next=e=>{this.currentSink.dispose(),this.subInner(e,DF)}}},OF=tV(NF,"switchMap");function MF(e){return(t,i)=>e((()=>t),i)}var LF=MF(tV(NF,"switchMapTo")),PF=class extends kF{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},xF=class extends CF{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(e){this.next2(e),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),PF),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}tryComplete(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}},UF=tV(xF,"concatMap"),VF=MF(tV(xF,"concatMapTo")),FF=class extends kF{tryComplete(){this.context.inners.delete(this),super.dispose(),0===this.context.inners.size&&this.context.resetComplete()}},BF=class extends CF{constructor(){super(...arguments),this.inners=new Set}next(e){this.subInner(e,FF),this.inners.add(this.currentSink)}tryComplete(){1===this.inners.size?this.inners.forEach((e=>e.resetComplete())):this.dispose()}},HF=tV(BF,"mergeMap"),WF=MF(tV(BF,"mergeMapTo")),jF=class extends kF{dispose(){this.context.resetNext(),super.dispose()}},GF=class extends CF{next(e){this.next=jU,this.subInner(e,jF)}},zF=tV(GF,"exhaustMap"),qF=MF(tV(GF,"exhaustMapTo")),KF=tV(class extends QU{constructor(e,t){super(e),this.f=t,this.groups=new Map}next(e){let t=this.f(e),i=this.groups.get(t);void 0===i&&(i=yV(),i.key=t,this.groups.set(t,i),super.next(i)),i.next(e)}complete(){this.groups.forEach((e=>e.complete())),super.complete()}error(e){this.groups.forEach((t=>t.error(e))),super.error(e)}},"groupBy"),YF=tV(class extends QU{constructor(){super(...arguments),this.start=new Date}next(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},"timeInterval"),XF=tV(class extends QU{constructor(e,t){super(e),this.miniseconds=t,this.buffer=[],this.id=setInterval((()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0}),this.miniseconds)}next(e){this.buffer.push(e)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},"bufferTime"),JF=tV(class extends QU{constructor(e,t){super(e),this.buffer=[],this.delayTime=t}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(e){this.timeoutId=setTimeout((()=>{let e=this.buffer.shift();if(e){let{time:t,data:i}=e;super.next(i),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(t))}}),e)}next(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}complete(){this.timeoutId=setTimeout((()=>super.complete()),this.delayTime)}},"delay"),QF=tV(class extends QU{constructor(e,t){super(e),this.selector=t}error(e){this.dispose(),this.selector(e)(this.sink)}},"catchError"),$F=class extends kF{tryComplete(){let e=this.context.inners.delete(this);super.dispose(),e&&this.context.checkComplete()}next(e){this.sink.next(e),this.context.expandValue(e)}},ZF=tV(class extends CF{constructor(e,t){super(e,t),this.project=t,this.inners=new Set,this.sourceCompleted=!1}next(e){this.sink.next(e),this.expandValue(e)}expandValue(e){let t=new $F(this.sink,e,this);this.currentSink=t,this.complete=this.tryComplete,t.complete=t.tryComplete,this.inners.add(t),t.subscribe(this.makeSource(e,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&0===this.inners.size&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}},"expand"),eB=()=>e=>new Promise(((t,i)=>{let r;new $U(e,(e=>r=e),i,(()=>t(r)))})),tB=()=>e=>{let t;return new ReadableStream({start(i){t=new $U(e,i.enqueue.bind(i),i.error.bind(i),i.close.bind(i))},cancel(){t.dispose()}})},iB=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:jU,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:jU,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:jU;return r=>new $U(r,e,t,i)},rB=tV(class extends QU{constructor(e,t){super(e),t instanceof Function?this.next=i=>{t(i),e.next(i)}:(t.next&&(this.next=i=>{t.next(i),e.next(i)}),t.complete&&(this.complete=()=>{t.complete(),e.complete()}),t.error&&(this.error=i=>{t.error(i),e.error(i)}))}},"tap"),oB=tV(class extends QU{constructor(e,t){super(e),this.timeout=t,this.id=setTimeout((()=>this.error(new nV(this.timeout))),this.timeout)}next(e){super.next(e),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},"timeout"),nB=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return t=>{if(t instanceof XU){let i=eV((r=>{let o=e,n=new QU(r);n.error=e=>{o-- >0?n.subscribe(t):r.error(e)},n.sourceId=i.id,n.subscribe(t)}),"retry",[e]);return i.source=t,oV.pipe(i),i}return i=>{let r=e,o=new QU(i);o.error=e=>{r-- >0?t(o):i.error(e)},t(o)}}},aB=(e=>(e[e.AUTO_SWITCH_NEW_DEVICE=0]="AUTO_SWITCH_NEW_DEVICE",e[e.WAIT_CURRENT_DEVICE=1]="WAIT_CURRENT_DEVICE",e))(aB||{}),sB=class e extends bU{constructor(e,t){super({mediaType:e,PlayerClass:t}),aR(this,"isRemote",!1),aR(this,"deviceId"),aR(this,"groupId",""),aR(this,"label",""),aR(this,"sourceTrack"),aR(this,"enableAutoSwitchWhenRecapturing",!0),aR(this,"_isRecapturing",!1),aR(this,"_lastRecaptureTime",0),aR(this,"_onMuteTimeoutId",-1),aR(this,"_encodeCheckTimeoutId",-1),aR(this,"recaptureMode",0),aR(this,"profile"),aR(this,"retryEncodeFailed")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}get isUseCustomSource(){return this.sourceTrack&&this.mediaTrack&&this.sourceTrack!==this.mediaTrack}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){e.addEventListener(ok.MUTE,this.onTrackMuted),e.addEventListener(ok.UNMUTE,this.onTrackUnmuted),e.addEventListener(ok.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===ok.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){e.removeEventListener(ok.MUTE,this.onTrackMuted),e.removeEventListener(ok.UNMUTE,this.onTrackUnmuted),e.removeEventListener(ok.ENDED,this.onTrackEnded)}setStateToReady(){}capture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return cR(this,null,(function*(){var i;let r=this.sourceTrack;try{let r,o=cD();$O.emit(eM.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(r=new MediaStream,r.addTrack(e.customSource)):(t||null==(i=this.sourceTrack)||i.stop(),r=yield NU(e));let n=r.getTracks()[0];return yield this.setInputMediaStreamTrack(n),e.customSource||(this.sourceTrack=n,this.updateDeviceIdInUse(),this.listenDeviceChange()),$O.emit(eM.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:cD()-o}),r}catch(CR){throw $O.emit(eM.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:CR}),this.log.error("getUserMedia error observed ".concat(CR)),CR}finally{t&&(null==r||r.stop())}}))}setOutputMediaStreamTrack(e){var t;if(super.setOutputMediaStreamTrack(e),this.setStateToReady(),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}get hasFlag(){var e,t;let i=pD((null==(e=this.room)?void 0:e.localPublishFlag)||0,(null==(t=this.room)?void 0:t.userId)||"");return 4===this.mediaType&&i.hasVideo||1===this.mediaType&&i.hasAudio||2===this.mediaType&&i.hasAuxiliary}publish(e,t){return cR(this,null,(function*(){return this.room=e,this.room.localTracks.add(this),this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.bindParent(e.getLogger()),yield t,this._checkPublishFlag(e)}))}_checkPublishFlag(e){return new Promise(((t,i)=>cR(this,null,(function*(){var r,o,n,a;let s=()=>i(new vR({code:_R.API_CALL_ABORTED,message:"publish aborted"}));if(this.hasFlag||this.muted?t():((this.state===qP.INIT||"ready"===this.state)&&s(),ZU(MV(e,"local-publish-flag-changed"),$V((()=>this.hasFlag)),tF(cV(MV(this,qP.INIT),MV(this,"ready"))),iB(t,i,s))),((null==(o=null==(r=this.room)?void 0:r.networkQuality)?void 0:o.uplinkNetworkQuality)||0)>3)return t();let c=e.heartbeatCount,l=(null==(a=null==(n=this.mediaTrack)?void 0:n.stats)?void 0:a.totalFrames)||0;this._encodeCheckTimeoutId=setTimeout((()=>cR(this,null,(function*(){var r,o,n,a,s,d,u;if(((null==(o=null==(r=this.room)?void 0:r.networkQuality)?void 0:o.uplinkNetworkQuality)||0)>3||e.heartbeatCount-c<3)return t();if((this.isPublished||this.isPublishing)&&this.isMediaTrackActive){if(null!=(n=this.mediaTrack)&&n.stats){let e=this.mediaTrack.stats.totalFrames||0;e-l==0&&this.log.warn("capture totalFrames is 0 during encode check, totalFrames",e)}let e=this.kind===ok.AUDIO,r=this.stat.bytesSent>0;if(CL[r?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),!e){let e={H264:513704,H265:513705,VP8:513706}[(null==(s=null==(a=this.room)?void 0:a.videoCodec)?void 0:s.toUpperCase())||"H264"];e&&CL[r?"addSuccessEvent":"addFailedEvent"]({key:e})}if(!r){if(CL.addEnum({key:e?503701:513703,value:qO()}),ox.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(WO()||YO()),userId:this.userId}),this.log.warn(e?"encode failed":"".concat(null==(u=null==(d=this.room)?void 0:d.videoCodec)?void 0:u.toUpperCase()," encode failed")),this.retryEncodeFailed&&(this.log.warn("retry encode"),yield this.retryEncodeFailed(this),this.stat.bytesSent>0||this.hasFlag||(yield kD(5e3),this.stat.bytesSent>0||this.hasFlag)))return t();this.emit("6",this),i(new vR({message:"".concat(this.strMediaType," encode failed"),code:e?_R.AUDIO_ENCODE_FAILED:_R.VIDEO_ENCODE_FAILED}))}}}))),1e4)}))))}unpublish(){this.room&&this.room.localTracks.delete(this),this.log.info("unpublish"),$O.emit(eM.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return cR(this,null,(function*(){if(this.sourceTrack&&mP){let{deviceId:e,groupId:t}=this.sourceTrack.getSettings(),{label:i}=this.sourceTrack;(yield function(e){return cR(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:i,oldGroupId:r,oldLabel:o,kind:n}=e;return function*(){return t===i&&(n!==ok.AUDIO||t!==Qk||(yield vU(r,o)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=i,t&&(this.groupId=t),hU().then((i=>{let r=i.find((i=>{let r=i.deviceId===e;return t&&(r=r&&i.groupId===t),r}));r&&this.emit("2",r)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.sourceTrack||this.kind===ok.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(ok.AUDIO_INPUT);return!!gU.has(i)}(this.sourceTrack)||this.kind===ok.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let i="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(ok.VIDEO_INPUT);return!!gU.has(i)}(this.sourceTrack)||this._isRecapturing||e&&KN&&TO)}onTrackMuted(){if(super.onTrackMuted(),LU(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<rC)return void setTimeout((()=>this.onTrackMuted()),rC);this._onMuteTimeoutId=setTimeout((()=>cR(this,null,(function*(){var e;if(null!=(e=this.sourceTrack)&&e.muted){if((uN||hN)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return cR(this,null,(function*(){if(sR(e.prototype,this,"onTrackEnded").call(this),this.isNeedToRecapture()&&0===this.recaptureMode){if(Date.now()-this._lastRecaptureTime<rC)return void setTimeout((()=>this.onTrackEnded()),rC);this.emit("7"),this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return cR(this,null,(function*(){var i;if(this._isRecapturing||!this.sourceTrack)return;this.log.warn("recapture trying");let r=this.sourceTrack;t||null==(i=this.sourceTrack)||i.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let o={useExactDeviceId:!0};if("user"===e||"environment"===e)o.facingMode=e;else{let t;("audio"===this.kind?yield pU():yield mU()).find((t=>t.deviceId===e))&&(t=e),o.deviceId=t}return this.capture(o,t).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),$O.emit(eM.LOCAL_TRACK_RECAPTURE,{track:this})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),$O.emit(eM.LOCAL_TRACK_RECAPTURE,{track:this,error:e})})).finally((()=>{t&&(null==r||r.stop())}))}))}getRecoverCaptureDeviceId(){return cR(this,null,(function*(){let e=this instanceof mB;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let i=(lB.get(t)||0)+1;if(lB.set(t,i),i>=3&&this.enableAutoSwitchWhenRecapturing){let r=e?(yield mU()).find((e=>!lB.has(e.deviceId))):(yield pU()).find((e=>!lB.has(e.deviceId)));r&&(this.log.warn("".concat(t," capture fail ").concat(i," times, change new ").concat(r.deviceId)),t=r.deviceId)}}return t}))}stopCapture(){var e;this.sourceTrack&&(this.sourceTrack.stop(),this.uninstallTrackEvent(this.sourceTrack)),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack),null==(e=this.manager)||e.removeInput(this)}close(){super.close(),this.stopCapture()}};nR([jP(qP.INIT,"ready",{ignoreError:!0,sync:!0})],sB.prototype,"setStateToReady",1),nR([FU()],sB.prototype,"capture",1),nR([jP("ready","publish",{ignoreError:!0,success(){$O.emit(eM.LOCAL_TRACK_PUBLISHED,{track:this,room:this.room}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),this.log.info("published")},fail(e){var t;null==(t=this.room)||t.localTracks.delete(this);let i="error",r=e instanceof vR?e:e.cause instanceof vR?e.cause:e,o=!1;r instanceof vR&&(r.message.includes("timeout")?i="timeout":r.code===_R.API_CALL_ABORTED&&(o=!0,i="api-call")),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:i,error:r}),this.log[o?"info":"error"]("publish failed",r)}}),HU(521714,!1)],sB.prototype,"publish",1),nR([MU((e=>function(){return cR(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId)}))})),jP([],"ready",{sync:!0})],sB.prototype,"unpublish",1);var cB=sB,lB=new Map;$O.on(eM.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&lB.delete(e.track.deviceId)}));var dB=class e extends cB{constructor(e){super(1,IU),aR(this,"mediaType",1),aR(this,"volume",0),aR(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),aR(this,"playerMuted",!0),aR(this,"pipeline"),aR(this,"earMonitorGainNode",new Xx),aR(this,"_output",new Xx),aR(this,"codecPipeline",[]),aR(this,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),aR(this,"mixedAudioReferenceMap",new Map),aR(this,"isAudioContextLongSuspended",!1),aR(this,"after3aSilenceStartTime",0),this.manager=e,this.pipeline=new $x(e),this.pipeline.source.pipeTo(this.player.pipeline.volumeMeter),this.pipeline.gain.pipeTo(this.earMonitorGainNode).pipeTo(this._output),this.pipeline.gain.pipeTo(this.player.pipeline.volumeMeterAfter3A),this.handleMicrophoneAdded=this.handleMicrophoneAdded.bind(this),this.handleMicrophoneRemoved=this.handleMicrophoneRemoved.bind(this),$O.on(eM.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this)}get dbVolume(){return nU.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}getInternalAudioLevelAfter3A(){if(this.pipeline.aec.node||this.pipeline.denoiser.node)return this.player.getInternalAudioLevelAfter3A()}updateAfter3aSilenceStartTime(e){YC(e)||(0!==e||this.after3aSilenceStartTime?e>0&&(this.after3aSilenceStartTime=0):this.after3aSilenceStartTime=cD())}setInputMediaStreamTrack(t){return cR(this,null,(function*(){let i=this.trackSettings||{};CL.addEnum({key:501701,value:i.channelCount||0,useUV:!1}),CL.addEnum({key:501702,value:i.sampleRate||0,useUV:!1}),CL.addEnum({key:502700,value:0});let{sampleRate:r,channelCount:o}=i;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:r,channelCount:o}))),this.pipeline.source.channelCount=o||1,this.pipeline.replaceSource(t),yield sR(e.prototype,this,"setInputMediaStreamTrack").call(this,t),this.updatePlayingState(!!t)}))}capture(t){return cR(this,arguments,(function(t){var i=this;let{deviceId:r,customSource:o,useExactDeviceId:n=!0,retryWhenExactFailed:a}=t,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function*(){let t=yield sR(e.prototype,i,"capture").call(i,{video:!1,audio:!0,microphoneId:r,echoCancellation:i.profile.echoCancellation,autoGainControl:i.profile.autoGainControl,noiseSuppression:i.profile.noiseSuppression,sampleRate:i.profile.sampleRate,channelCount:i.profile.channelCount,useExactDeviceId:n,retryWhenExactFailed:a,customSource:o},s);return Kx(),t}()}))}switchDevice(e){return cR(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e&&!this.isUseCustomSource){if(e!==Qk)return;if(yield vU(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.sourceTrack&&this.sourceTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1}),$O.emit(eM.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(Ok){throw this.log.error("switch microphone failed ".concat(Ok)),this.deviceId&&this.recapture(this.deviceId),Ok}}}))}listenDeviceChange(){dU&&!dU.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&dU.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return cR(this,null,(function*(){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(aB[this.recaptureMode],". Current microphone is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){iH(this.userId,{eventId:2003,param1:6,streamType:1});let e=yield pU();e[0]?this.recapture(e[0].deviceId):t=!0}t&&dU.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){1===this.recaptureMode&&e.deviceId!==this.deviceId||(dU.off("audioInputAdded",this.handleMicrophoneAdded,this),this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId))}update3A(e){return cR(this,arguments,(function(e){var t=this;let{echoCancellation:i,noiseSuppression:r,autoGainControl:o}=e;return function*(){let e=t.sourceTrack||t.mediaTrack;if(!e)return;let n=e.getConstraints(),a=!1;!YC(i)&&i!==t.profile.echoCancellation&&(t.profile.echoCancellation=i,n.echoCancellation=i,a=!0),!YC(r)&&r!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=r,n.noiseSuppression=r,a=!0),!YC(o)&&o!==t.profile.autoGainControl&&(t.profile.autoGainControl=o,n.autoGainControl=o,a=!0),a&&(_N||TO?yield e.applyConstraints(n).catch((e=>t._log.warn("update3A failed: ",e))):t.deviceId&&(yield t.recapture(t.deviceId,!0)))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&CL.addEnum({key:502700,value:2})}setAudioVolume(e){super.setAudioVolume(0),uN&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(Yx().createGain()),this._output.setNode(Yx().destination)),this.earMonitorGainNode.node.gain.value=e}enableTrackANS(e){return this.update3A({noiseSuppression:e})}enableTrackAEC(e){if(this.sourceTrack&&!TO&&!uN)return this.update3A({echoCancellation:e})}addDenoiser(e){var t;vO<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(CL.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}mixAudioReference(e,t){if(this.mixedAudioReferenceMap.has(t))return;this.log.info("mixAudioReference() => ".concat(t));let i=tU(e);if(!i)return;let r=new Xx,o=Yx().createGain();o.gain.value=1;let n=new Xx;r.pipeTo(n).pipeTo(this.pipeline.mixNode),r.setNode(i),n.setNode(o),this.mixedAudioReferenceMap.set(t,[r,n])}unMixAudioReference(e){let[t,i]=this.mixedAudioReferenceMap.get(e)||[];t&&(this.log.info("unMixAudioReference() => ".concat(e)),t.deleteNode(),null==i||i.deleteNode(),this.mixedAudioReferenceMap.delete(e))}setAudioReferenceVolume(e,t){let[i,r]=this.mixedAudioReferenceMap.get(e)||[];null!=r&&r.node&&(r.node.gain.value=t/100,this.log.info("setAudioReferenceVolume() => ".concat(e," ").concat(r.node.gain.value)))}addAudioProcessor(e,t,i){this.pipeline.silentNode.setNode(i),this.pipeline.mixNode.setNode(t),this.pipeline.aec.setNode(e)}removeDenoiser(e){if(this.pipeline.denoiser.node===e)return this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0)}removeAudioProcessor(e){this.pipeline.aec.node===e&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode())}close(){this.mixedAudioReferenceMap.forEach((e=>{let[t,i]=e;t.deleteNode(),i.deleteNode()})),this.mixedAudioReferenceMap.clear(),this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),dU.off("audioInputAdded",this.handleMicrophoneAdded,this),dU.off("audioInputRemoved",this.handleMicrophoneRemoved,this),$O.off(eM.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this),super.close()}recapture(t){let i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return cR(this,null,(function*(){try{yield sR(e.prototype,this,"recapture").call(this,t,i)}catch(pM){let r=(yield pU()).find((e=>e.deviceId!==t));if(!r)throw pM;yield sR(e.prototype,this,"recapture").call(this,r.deviceId)}}))}encodeFrame(e){return this.manager?this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e,ntp:yR()}):e),e):e}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}get enableEncryptFrame(){return this.manager&&!!this.manager.encodePipeline[0]}handleAudioContextLongSuspended(e){let{isSuspended:t}=e;if(this.pipeline.isProcessEnabled)if(t){this.isAudioContextLongSuspended=!0,this.log.warn("context has suspended for ".concat(1.5," seconds, change to source audio").concat(IO?"":", non-Safari"));let e=this.sourceTrack||this.mediaTrack;e&&this.setOutputMediaStreamTrack(e)}else this.isAudioContextLongSuspended=!1,this.log.warn("context has resumed, change to processed audio"),this.pipeline.track&&this.setOutputMediaStreamTrack(this.pipeline.track)}setOutputMediaStreamTrack(e){if(this.isAudioContextLongSuspended){let t=this.sourceTrack||this.mediaTrack;t&&(e=t)}super.setOutputMediaStreamTrack(e)}},uB=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,i=[],r=0;for(let n=e;n<=t;n++){let e=this.dataView.getInt8(n);switch(e){case 0:case 1:case 2:case 3:2===r&&(i.push(3),r=0),0==e?r++:r=0,i.push(e);break;default:r=0,i.push(e)}}i.push(this.dataView.getInt8(this.dataView.byteLength-1));let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=o}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,i=[],r=0;for(let n=e;n<=t;n++)switch(this.dataView.getInt8(n)){case 0:r++,i.push(this.dataView.getInt8(n));break;case 3:2!==r&&i.push(this.dataView.getInt8(n)),r=0;break;default:i.push(this.dataView.getInt8(n)),r=0}let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...i]).buffer);this.dataView=o}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let o=6;o<this.dataView.buffer.byteLength;o++){let i=this.dataView.getUint8(o);if(t++,255!==i){e+=i;break}e+=255}let i=new ArrayBuffer(e),r=new DataView(i);for(let o=0;o<i.byteLength;o++,t++)r.setInt8(o,this.dataView.getInt8(t));return r}},hB=class{constructor(){aR(this,"_seiMessageList",[]),aR(this,"_smallSeiMessageList",[]),aR(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,i=parseInt(String(t/255),10),r=t%255,o=[];o.push(0,0,0,1,6,this._seiPayloadType);for(let a=0;a<i;a++)o.push(255);o.push(r);let n=new DataView(e);return o.push(...new Uint8Array(n.buffer)),o.push(128),new uB(new DataView(new Uint8Array(o).buffer),!0)}sendSEI(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}isEmpty(){return!this._seiMessageList.length}getNaluCount(e){let t=0,i=0,r=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(r.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}encode(e,t){let i=t?this._smallSeiMessageList:this._seiMessageList;if(i.length>0&&e.data.byteLength>0){let t=9-this.getNaluCount(e.data);if(t<=0)return 0;let r=i.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),o=r.reduce(((e,t)=>e+t.dataView.byteLength),0),n=new ArrayBuffer(o+e.data.byteLength),a=new DataView(n),s=new DataView(e.data),c=0;for(let e=0;e<r.length;e++)for(let t=0;t<r[e].dataView.byteLength;t++)a.setInt8(c++,r[e].dataView.getInt8(t));for(let i=0;i<e.data.byteLength;i++)a.setInt8(c++,s.getInt8(i));return e.data=n,r.length}return 0}},pB=class e extends cB{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,Mx),aR(this,"profile",Zw({},tk)),aR(this,"avoidCropping",!1),aR(this,"_scaleResolutionDownBy"),aR(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0,framesCaptured:0}),aR(this,"small"),aR(this,"isNeedToSetBandwidth"),aR(this,"muteImage"),aR(this,"manager"),aR(this,"_seiCodec",new hB),this.manager=e;let t=()=>{var e;if(this.isAllowed2k4k(this.profile))this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1});else{let t=RC((null==(e=this.room)?void 0:e.sdkAppId)||0)?WR:HR;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(t)),this.setProfile(eR(Zw({},this.profile),{width:1920,height:1080})),this.applyProfile()}};this.on("input-media-track-changed",t),this.on("publish",t),this.handleCameraAdded=this.handleCameraAdded.bind(this),this.handleCameraRemoved=this.handleCameraRemoved.bind(this)}get facingMode(){if(mP&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e;return(null==(e=this._inputTrack)?void 0:e.contentHint)||""}get isQosClearFirst(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}get hasSmall(){var e;return!(null==(e=this.manager)||!e.hasSmall)}setMute(t){return cR(this,null,(function*(){var i,r,o;if(XC(t)){if(this.muteImage===t)return;yield null==(i=this.manager)?void 0:i.deleteWatermark("mute"),yield null==(r=this.manager)?void 0:r.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:t,fillVideo:!0}),this.muteImage=t,sR(e.prototype,this,"setMute").call(this,!1)}else this.muteImage&&(yield null==(o=this.manager)?void 0:o.deleteWatermark("mute"),this.muteImage=void 0),sR(e.prototype,this,"setMute").call(this,t)}))}capture(t){return cR(this,arguments,(function(t){var i=this;let{deviceId:r,facingMode:o,useExactDeviceId:n=!0,customSource:a,retryWhenExactFailed:s=!0}=t;return function*(){let t={audio:!1,video:!0,facingMode:o||i.facingMode,cameraId:r,width:i.profile.width,height:i.profile.height,frameRate:i.profile.frameRate,useExactDeviceId:n,retryWhenExactFailed:s,customSource:a};if("environment"===t.facingMode){let e=yield i.getDeviceIdWhenUsingBackCamera();e&&(t.cameraId=e)}return sR(e.prototype,i,"capture").call(i,t)}()}))}setProfile(e){var t;let i=this.fallbackProfile(e);if(i.bitrate&&(this.isNeedToSetBandwidth=i.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile))super.setProfile(i);else{let e=RC((null==(t=this.room)?void 0:t.sdkAppId)||0)?WR:HR;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(e)),super.setProfile(eR(Zw({},this.profile),{width:1920,height:1080}))}}applyProfile(){return cR(this,null,(function*(){var e;if(!this.mediaTrack)return;let{width:t=0,height:i=0}=(this.sourceTrack||this.mediaTrack).getSettings(),r=t*i,o=this.settings,n=o.height!==this.profile.height||o.width!==this.profile.width||o.frameRate!==this.profile.frameRate;if(n&&(16===kO&&this.deviceId?yield this.recapture(this.deviceId):(yield null==(e=this.sourceTrack||this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}),this.manager&&this.manager.changeInput(this)),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1})),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth){this.isNeedToSetBandwidth=!1;let{width:e=0,height:t=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=e*t;return n&&i&&r&&i===r?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:ok.VIDEO,videoType:ok.BIG})}}))}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return mP&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:OD(this.settings,this.profile)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return cR(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e)&&!this.isUseCustomSource)return;let t={useExactDeviceId:!0,retryWhenExactFailed:!1};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.sourceTrack&&this.sourceTrack.stop(),yield this.capture(t),$O.emit(eM.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(Ok){throw this.log.error("switch camera failed ".concat(Ok)),this.deviceId&&this.recapture(this.deviceId),Ok}}))}getDeviceIdWhenUsingBackCamera(){return cR(this,null,(function*(){let e;try{if(iO&&!uO&&_P){let t=(yield mU(!0)).map((e=>{var t;return eR(Zw({},e),{capabilities:null==(t=e.getCapabilities)?void 0:t.call(e)})})).filter((e=>{var t,i;return null==(i=null==(t=e.capabilities)?void 0:t.facingMode)?void 0:i.includes("environment")})),i=t[0];t.forEach((e=>{var t,r,o,n;let{capabilities:a}=e;(null!=(t=a.width)&&t.max&&null!=(r=a.height)&&r.max?a.width.max*a.height.max:0)>(null!=(o=i.capabilities.width)&&o.max&&null!=(n=i.capabilities.height)&&n.max?i.capabilities.width.max*i.capabilities.height.max:0)&&(i=e)})),null!=i&&i.capabilities&&(this._log.info("use max resolution back camera",i),e=i.deviceId)}}catch(Ok){this._log.warn("get max res camera failed",Ok)}return e}))}updateSmallConfig(e){var t,i;this._log.info("update small stream config: ".concat(JSON.stringify(e)));let r=!this.small;this.small=this.fallbackProfile(e,!0),null==(t=this.manager)||t.update(),r&&(null==(i=this.room)||i.enableSmall(!0)),this.log.info("update small stream config success")}fallbackProfile(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e.width>e.height,r=Zw({},e);return e.width*e.height<=19200&&hN&&fO&&(this.log.warn("".concat(t?"small ":"","resolution is ").concat(e.width,"*").concat(e.height,", fallback to 240*180 for android chrome")),r.width=i?240:180,r.height=i?180:240,r.bitrate=Math.max(e.bitrate,150)),e.width*e.height>921600&&NO&&(r.width=i?1280:720,r.height=i?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),wO(SO,"14.3")&&RO(SO,"14.0",!0)&&this.on("7",(()=>{let e=this.profile.width>this.profile.height;this.profile.width*this.profile.height>307200?(this.profile.width=e?640:480,this.profile.height=e?480:640,this.log.warn("reduce the resolution to 480p on iOS 14.0 ~ 14.2")):this.profile.width*this.profile.height>230400&&(this.profile.width=e?640:360,this.profile.height=e?360:640,this.log.warn("reduce the resolution to 360p on iOS 14.0 ~ 14.2"))})),!t&&this.avoidCropping&&(fO||_N)&&!VO()&&e.width*e.height<=230400&&e.width/e.height==16/9&&(this._scaleResolutionDownBy=1280/e.width,e.width=1280,e.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),r}stopSmall(){var e,t;this.small&&(delete this.small,null==(e=this.manager)||e.update(),null==(t=this.room)||t.enableSmall(!1))}listenDeviceChange(){dU&&!dU.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&dU.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return cR(this,null,(function*(){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(aB[this.recaptureMode],". Current camera is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){iH(this.userId,{eventId:2003,param1:7,streamType:2});let e=yield mU();e[0]?this.recapture(e[0].deviceId):t=!0}t&&dU.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return cR(this,null,(function*(){1===this.recaptureMode&&e.deviceId!==this.deviceId||(dU.off("videoInputAdded",this.handleCameraAdded,this),this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId))}))}encodeFrame(e,t){if(!this.manager)return e;let i=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e,mediaType:i}):e),e)}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}play(e,t){return YC(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){dU.off("videoInputAdded",this.handleCameraAdded,this),dU.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}recapture(t){return cR(this,null,(function*(){try{yield sR(e.prototype,this,"recapture").call(this,t)}catch(Ok){let r=(yield mU()).find((e=>e.deviceId!==t));if(!r)throw Ok;yield sR(e.prototype,this,"recapture").call(this,r.deviceId)}}))}setContentHint(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}setRotation(e){this.manager&&(this.isScreen||YC(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}};nR([OU((function(e){this.setContentHint(e.contentHint||"motion")}))],pB.prototype,"capture",1);var mB=pB,fB={};rR(fB,{REPORT_TYPE:()=>xD,buildSSOPackage:()=>UD,bytes2ms:()=>UC,calculateScaleResolutionDownNumber:()=>OD,concatArrayBuffers:()=>VD,convertObjectNumberToInt:()=>RD,copyProperties:()=>xC,deepClone:()=>gD,deepCloneBasic:()=>PD,deepMerge:()=>_D,delay:()=>kD,fibonacci:()=>GC,formatedTime:()=>yD,getConstructorName:()=>oD,getContainerFromElement:()=>ED,getEnv:()=>wC,getFirst16Bits:()=>BD,getInternalVersion:()=>dD,getLast16Bits:()=>FD,getLoggerUrl:()=>kC,getMediaStreamTrackInfo:()=>ND,getMuteStateFromFlag:()=>pD,getNetworkType:()=>DC,getNumNetworkType:()=>PC,getReconnectionTimeout:()=>zC,getStringByteLength:()=>AD,getTurnServer:()=>mD,getUint32Version:()=>wD,getValueType:()=>qC,getViewListFromView:()=>vD,glog:()=>HC,ipv4ToUint32:()=>fD,isArray:()=>ZC,isAudioWorkletSupported:()=>nD,isBoolean:()=>QC,isConstructor:()=>rD,isEmpty:()=>hD,isFunction:()=>KC,isLangChinese:()=>WC,isMediaStreamTrack:()=>eD,isNumber:()=>JC,isObject:()=>$C,isOverseaSdkAppId:()=>RC,isPlainObject:()=>jC,isPortrait:()=>bD,isPromise:()=>iD,isRemoteTrack:()=>tD,isRotate90Or270:()=>MD,isSetSinkIdSupported:()=>aD,isString:()=>XC,isUndefined:()=>YC,loadImage:()=>SD,loadVideo:()=>LD,ms2bytes:()=>FC,ms2samples:()=>BC,normalizeUrl:()=>DD,performanceNow:()=>cD,promiseAny:()=>sD,samples2ms:()=>VC,setNetworkTypeFromWebRTC:()=>LC,stringify:()=>TD,stringifyIncludeValue:()=>ID,throttlePromise:()=>CD});var _B=[-1,-1,1,-1,-1,1,1,1],gB=[0,0,1,0,0,1,1,1],vB=class e extends qP{constructor(e,t){if(super(),this.context=e,aR(this,"name"),aR(this,"input"),aR(this,"output"),aR(this,"texture"),aR(this,"ctx2d",null),aR(this,"fbo"),aR(this,"width",0),aR(this,"height",0),aR(this,"x",0),aR(this,"y",0),aR(this,"program"),aR(this,"vertexShader"),aR(this,"fragmentShader"),aR(this,"totalFrames",0),aR(this,"dropFrames",0),aR(this,"matchInputSize",!0),aR(this,"texCoordBuffer"),aR(this,"positionBuffer"),aR(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),aR(this,"cost",0),aR(this,"_canvas",null),aR(this,"_image"),aR(this,"log"),this.context.on("disconnect",this.close,this),this.name=t.name,this.log=t.logger,this.matchInputSize=!1!==t.matchInputSize,this.width=t.width||e.width,this.height=t.height||e.height,this._image=t.image,e instanceof PB)e.ctx&&t.create2d&&("function"==typeof OffscreenCanvas&&16!==kO?this._canvas=new OffscreenCanvas(this.width,this.height):(this._canvas=document.createElement("canvas"),this._canvas.width=this.width,this._canvas.height=this.height),this.ctx2d=this._canvas.getContext("2d"),this._image=this._canvas);else try{let i=e.ctx;this.texCoordBuffer=this.createBuffer(gB),this.positionBuffer=this.createBuffer(_B),!1!==t.createTexture&&(this.texture=i.createTexture(),this.useTexture(),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.pixelStorei(i.UNPACK_ALIGNMENT,1)),t.useFbo&&(this.fbo=i.createFramebuffer(),this.useBufferFrame(),this.useTexture(),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.texture,0)),t.useDefaultProgram?this.program=e.defaultProgam:(t.vertexShaderSource||t.fragmentShaderSource)&&(this.vertexShader=t.vertexShaderSource?e.createShader(i.VERTEX_SHADER,t.vertexShaderSource):e.defaultVShader,this.fragmentShader=t.fragmentShaderSource?e.createShader(i.FRAGMENT_SHADER,t.fragmentShaderSource):e.defaultFShader,this.program=e.createProgram(this.vertexShader,this.fragmentShader))}catch(pM){this.context.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(pM.message||pM)}))}}get image(){return this._image}set image(e){this._image=e}createFramebuffer(e){let t=this.context.ctx,i=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,i),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),i}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return e.addInput(this,...i),this.output=e,e}addInput(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}requestFrame(e){let t=Date.now();return!!(this.context instanceof LB&&this.render(e)||this.context instanceof PB&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}render2d(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;null==(t=this.output)||t.update(e)}disconnect(){for(var e,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];null==(e=this.output)||e.removeInput(this,...i),delete this.output}removeInput(e){delete this.input}close(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof LB){let e=this.context.ctx;e.deleteBuffer(this.texCoordBuffer),e.deleteBuffer(this.positionBuffer),this.fbo&&e.deleteFramebuffer(this.fbo),this.texture&&e.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&e.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&e.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&e.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}useTexture(){this.useTextures(this.texture)}useInputTexture(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}useTextures(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{t&&(e.activeTexture(e.TEXTURE0+i),e.bindTexture(e.TEXTURE_2D,t))}))}useProgram(){this.context.ctx.useProgram(this.program)}useBufferFrame(){let e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}createBuffer(e){let t=this.context.ctx,i=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),i}setTexBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setPosBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}changeBufferData(e,t){let i=this.context.ctx;i.bindBuffer(i.ARRAY_BUFFER,e),i.bufferData(i.ARRAY_BUFFER,new Float32Array(t),i.STATIC_DRAW)}setAttributes(){let e=this.context.ctx;for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];i.forEach(((t,i)=>{e.enableVertexAttribArray(i),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(i,2,e.FLOAT,!1,0,0)}))}getVertexPoint(e,t){return[e/this.width*2-1,t/this.height*2-1]}layout2texCoords(e){return[...this.getVertexPoint(e.x,e.y),...this.getVertexPoint(e.x+e.width,e.y),...this.getVertexPoint(e.x,e.y+e.height),...this.getVertexPoint(e.x+e.width,e.y+e.height)]}resize(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();let i=this.context.ctx;i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}draw(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);let i=this.context.ctx;i.drawArrays(i.TRIANGLE_STRIP,0,4)}draw2d(t,i,r,o,n,a,s,c,l){let d=!(YC(a)||YC(s)||YC(c)||YC(l));return!(!this.ctx2d||!t)&&(t instanceof ImageData?(d?this.ctx2d.putImageData(t,i,r,a,s,c,l):this.ctx2d.putImageData(t,i,r),this.emit(e.RENDER,this.ctx2d.canvas)):(d?this.ctx2d.drawImage(t,a,s,c,l,i,r,o,n):this.ctx2d.drawImage(t,i,r,o,n),this.emit(e.RENDER,t)),"undefined"!=typeof VideoFrame&&t instanceof VideoFrame&&t.close(),!0)}drawBackGround2d(e){this.ctx2d&&(this.ctx2d.save(),this.ctx2d.fillStyle=e,this.ctx2d.fillRect(0,0,this.width,this.height),this.ctx2d.restore())}getInfo(){var e;let{totalFrames:t,x:i,y:r,width:o,height:n,name:a,cost:s}=this,c=Date.now(),l=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:i,y:r,width:o,height:n,timestamp:c,fps:l,name:a,cost:s},Zw({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}createTexture(e){let t=this.context.ctx,i=t.createTexture();return this.useTextures(i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),i}};aR(vB,"RENDER","render"),nR([jP(qP.INIT,"connected",{sync:!0})],vB.prototype,"connect",1),nR([jP("connected",qP.INIT,{ignoreError:!0,sync:!0})],vB.prototype,"disconnect",1),nR([jP([],"closed",{sync:!0})],vB.prototype,"close",1);var EB=vB,yB=ZU(CV(250),wF((()=>performance.now())),sV()),TB=e=>t=>{let i=performance.now();ZU(yB,aF((t=>t-i<e)),eF(1))(t)},IB=[0,1,1,1,0,0,1,0],AB=class extends EB{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),aR(this,"_intervalId",0),aR(this,"_sequence",0),aR(this,"checkGLError",!1),aR(this,"checkVisibilityChange"),e instanceof PB?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(IB)}start(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),$P.clearTask(this._intervalId),this._intervalId=$P.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&($P.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof LB){let e=this.context.ctx.getError();e&&this.context.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(e)}))}}),{fps:this.context.frameRate})}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),this.emit(EB.RENDER,this.context._canvas),!0)}addInput(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];super.addInput(e,...i),this.start(this.context.frameRate)}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;"closed"!==this.state&&(this._intervalId&&($P.clearTask(this._intervalId),this._intervalId=0,1===e&&(this.log.info("".concat(this.name," use requestVideoFrameCallback")),this.checkVisibilityChange=()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")),document.removeEventListener("visibilitychange",this.checkVisibilityChange))},document.addEventListener("visibilitychange",this.checkVisibilityChange))),this.requestFrame(this._sequence++))}removeInput(e){super.removeInput(e),$P.clearTask(this._intervalId)}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}close(){super.close(),$P.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}},bB=class extends AB{constructor(e,t){super(e,t),aR(this,"_videoTrack"),aR(this,"_muteOb"),aR(this,"_closedOb",MV(this,"closed")),aR(this,"_subscription"),aR(this,"_canvasContainer"),Number(AO)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),[this._videoTrack]=e.canvas.captureStream().getVideoTracks(),this._muteOb=MV(this._videoTrack,"mute"),ZU(MV(this._videoTrack,"ended"),tF(this._closedOb),iB((()=>{this.context.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})))}enableCheckMute(){this._subscription=ZU(this._muteOb,tF(this._closedOb),LF(TB(5e3)),$V((()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)})),iB((()=>{this.context.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}disableCheckMute(){var e;null==(e=this._subscription)||e.dispose()}get videoTrack(){return this._videoTrack}putCanvasIntoDom(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}render(e){return this.putCanvasIntoDom(),super.render(e)}render2d(e){return this.putCanvasIntoDom(),super.render2d(e)}close(){var e,t;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},SB=class extends bB{render(e){var t;let i=!(null==(t=this.input)||!t.requestFrame(e));if(this.context._canvas2d){let e=this.context._canvas2d.getContext("2d");e.clearRect(0,0,this.context._canvas2d.width,this.context._canvas2d.height),e.drawImage(this.context._canvas,0,0,this.context._canvas2d.width,this.context._canvas2d.height)}return i}},wB=class extends bB{constructor(e,t,i){super(e,{name:"smallDestination",logger:i}),this.resolution=t}resize(e,t){let i,r=e*t,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),r>o?i=r/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),i=r/19200),super.resize(e/Math.sqrt(i),t/Math.sqrt(i))}},RB=class extends EB{constructor(e,t){super(e,Zw({name:"imageSource"},t)),aR(this,"_lastImage"),aR(this,"_totalFrames",0),aR(this,"_autoResize",!1),aR(this,"_canvasRendered"),aR(this,"videoCallbackId",0),aR(this,"waitingFirstFrame",!0),aR(this,"shouldUpdate",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===kO&&(this._canvasRendered=yV(),ZU(this._canvasRendered,fV(this._image),OF((e=>e instanceof HTMLCanvasElement?MV(e,"rendered"):zV())),tF(MV(this,"closed")),iB((()=>{this.update()}))))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){if(!this.shouldUpdate)return;let e=this.image;this.videoCallbackId&&e.cancelVideoFrameCallback(this.videoCallbackId),CP()&&!document.hidden&&(this.videoCallbackId=e.requestVideoFrameCallback(((e,t)=>{this.waitingFirstFrame&&this.onFirstFrame(),document.hidden||(this._totalFrames=t.presentedFrames,this.update(1))})))}_render(e,t){var i;let{width:r,height:o}=this,{image:n}=this;if(n instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:r,videoHeight:o}=n),!r||!o)return!1;n.width=r,n.height=o}else if(n instanceof HTMLImageElement||n instanceof ImageData||n instanceof ImageBitmap){if(({width:r,height:o}=n),n!==this._lastImage)this._lastImage=n;else if(r===this.width&&o===this.height)return!0}else n instanceof HTMLCanvasElement||n instanceof OffscreenCanvas?(({width:r,height:o}=n),this._lastImage=n):"undefined"!=typeof VideoFrame&&n instanceof VideoFrame&&(({displayWidth:r,displayHeight:o}=n),null==(i=this._lastImage)||i.close(),this._lastImage=n);if(!this._autoResize)return!0;if(this.width===r&&this.height===o&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}this.resize(r,o)}return!0}get image(){return this._image}set image(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},kB=class extends RB{constructor(e,t,i){super(e,i),this._player=t,this.name="videoPlayerSource",ZU(MV(this._player,ZP.PLAYER_STATE_CHANGED),tF(MV(this,"closed")),$V((e=>{let{state:t}=e;return"PLAYING"===t})),iB((()=>{this.tryVideoFrameCallback()})))}get image(){return this._player.element}},CB=class extends kB{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,i){super(e,new Mx({id:i.name,track:t,muted:!0,container:null,objectFit:"contain",log:i.logger}),i),this.name="videoTrackSource",this._player.play()}replaceTrack(e){this.waitingFirstFrame=!0,this._player.setTrack(e),this._player.play()}close(){super.close(),this._player.stop()}},DB=class extends EB{constructor(e,t,i){super(e,eR(Zw({name:"textSource"},i),{create2d:!0})),aR(this,"hasChange",!0),aR(this,"content",""),this.ctx2d.textBaseline="top",this.content=t.content||"",t.font&&(this.font=t.font),t.color&&(this.color=t.color)}set font(e){this.ctx2d&&(this.ctx2d.font=e,this.hasChange=!0)}get font(){var e;return(null==(e=this.ctx2d)?void 0:e.font)||""}set color(e){this.ctx2d&&(this.ctx2d.fillStyle=e,this.hasChange=!0)}get color(){var e;return(null==(e=this.ctx2d)?void 0:e.fillStyle)||""}render2d(e){return!(!this.ctx2d||!this.hasChange)&&(this.ctx2d.clearRect(0,0,this.width,this.height),this.drawMultilineText(0,0),this.hasChange=!1,!0)}render(e){return!1}resize(e,t){if(!this.ctx2d)return;let{color:i,font:r}=this;super.resize(e,t),this.color=i,this.font=r}drawMultilineText(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.2;if(!this.ctx2d)return;let r=this.ctx2d.measureText(this.content);t+=r.fontBoundingBoxAscent||r.actualBoundingBoxAscent||0;let o=this.font.match(/(\d+)px/),n=(o?parseInt(o[1],10):16)*i,a=this.content.split("\n");for(let s=0;s<a.length;s++)this.ctx2d.fillText(a[s],e,t+s*n)}},NB=class extends qP{constructor(e){super(),aR(this,"frameRate"),aR(this,"_canvas"),aR(this,"log"),aR(this,"hasAlpha",!1),aR(this,"name"),aR(this,"error"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}get canvas(){return this._canvas}set width(e){this._canvas&&(this._canvas.width=e)}get width(){var e;return(null==(e=this._canvas)?void 0:e.width)||0}set height(e){this._canvas&&(this._canvas.height=e)}get height(){var e;return(null==(e=this._canvas)?void 0:e.height)||0}setSize(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}createVideoTrackSource(e,t){return new CB(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new bB(this,e)}createVideoImageSource(e,t){return new RB(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new kB(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}createTextSource(e,t){return new DB(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};aR(NB,"_ids",0);var OB={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},MB=class extends NB{constructor(){super(...arguments),aR(this,"defaultProgam"),aR(this,"defaultVShader"),aR(this,"defaultFShader"),aR(this,"ctx"),aR(this,"_canvas2d")}get canvas(){return this._canvas2d||this._canvas}create(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(NB._ids++)),e&&(this._canvas2d=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",OB),!this.ctx)throw new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(()=>{this.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}destroy(e){let t="";return e&&(t=e.message,this.error=e,CL.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}set width(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),super.width=e,this._canvas2d&&(this._canvas2d.width=e)}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e,this._canvas2d&&(this._canvas2d.height=e)}setSize(e,t){var i;null==(i=this.ctx)||i.viewport(0,0,e,t),super.setSize(e,t),this._canvas2d&&(this._canvas2d.width=e,this._canvas2d.height=t)}createShader(e,t){let i=this.ctx,r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),r}createProgram(e,t){let i=this.ctx,r=i.createProgram();return i.attachShader(r,e),i.attachShader(r,t),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||this.log.error(i.getProgramInfoLog(r)),r}};aR(MB,"UNAVAILABLE","unavailable"),nR([jP(qP.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),CL.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),CL.addSuccessEvent({key:512700})}})],MB.prototype,"create",1),nR([jP("created",qP.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(MB.UNAVAILABLE,e),this.removeAllListeners()}})],MB.prototype,"destroy",1);var LB=MB,PB=class extends NB{constructor(){super(...arguments),aR(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(NB._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha,willReadFrequently:e.willReadFrequently}),!this.ctx)throw new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(()=>{this.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(()=>{this.log.warn("2d context restored")}))}destroy(e){let t="";e&&(t=e.message,this.error=e,CL.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),CL.addSuccessEvent({key:512703})}};function xB(e,t,i,r,o){arguments.length>5&&void 0!==arguments[5]&&arguments[5]&&([i,r]=[r,i]);let n={sWidth:e,sHeight:t,dWidth:i,dHeight:r,sx:0,sy:0,dx:0,dy:0};if(0===e||0===t)return n;switch(o){case void 0:case"fill":break;case"contain":{let o=Math.min(i/e,r/t);n.dWidth=e*o,n.dHeight=t*o,n.dx=(i-n.dWidth)/2,n.dy=(r-n.dHeight)/2;break}case"cover":{let o=Math.max(i/e,r/t),a=i/o,s=r/o;n.sx=(e-a)/2,n.sy=(t-s)/2,n.sWidth=a,n.sHeight=s;break}}return n}nR([jP(qP.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),CL.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d"),CL.addSuccessEvent({key:512701})}})],PB.prototype,"create",1),nR([jP("created",qP.INIT,{ignoreError:!0,sync:!0})],PB.prototype,"destroy",1);var UB=class{constructor(e,t){this.node=e,this.layout=t,aR(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get fillMode(){return this.layout.fillMode}get rotation(){return this.layout.rotation}get hidden(){return!!this.layout.hidden}},VB=class extends EB{constructor(e,t){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:t}),aR(this,"inputs",[]),aR(this,"backgroundColor","black")}addInput(e,t){let i=0,r=this.inputs.length;for(;i<r;){let e=Math.floor((i+r)/2);if(this.inputs[e].layout.zIndex<t.zIndex)i=e+1;else{if(!(this.inputs[e].layout.zIndex>t.zIndex))throw new Error("input already exists at zIndex ".concat(t.zIndex));r=e}}let o=new UB(e,t);this.inputs.splice(i,0,o)}changeInputLayout(e,t){let i=this.inputs.findIndex((t=>t.node===e));if(i<0)return;let{x:r,y:o,width:n,height:a,zIndex:s,fillMode:c,rotation:l,hidden:d}=t;if(!YC(s)&&this.inputs.some((t=>t.layout.zIndex===s&&t.node!==e)))throw new Error("input already exists at zIndex ".concat(t.zIndex));let u=this.inputs[i];YC(r)||(u.layout.x=r),YC(o)||(u.layout.y=o),YC(n)||(u.layout.width=n),YC(a)||(u.layout.height=a),YC(l)||(u.layout.rotation=l),YC(d)||(u.layout.hidden=d),c&&(u.layout.fillMode=c),!YC(s)&&s!==u.layout.zIndex&&(u.layout.zIndex=s,this.inputs.sort(((e,t)=>e.layout.zIndex-t.layout.zIndex)))}hasInput(e){return this.inputs.some((t=>t.node===e))}hasNoInput(){return 0===this.inputs.length}resize(e,t){if(!this.matchInputSize)return void super.resize(e,t);let i=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(i.width,i.height),this.context instanceof LB&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return super.connect(e,...i),this.drawBackGround2d(this.backgroundColor),this.matchInputSize&&this.resize(0,0),e}removeInput(e){this.inputs=this.inputs.filter((t=>t.node!==e)),0===this.inputs.length&&this.drawBackGround2d(this.backgroundColor)}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),this.inputs.reduce(((t,i)=>i.node.requestFrame(e)||t),!1)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(this.inputs.forEach((t=>t.node.requestFrame(e))),this.ctx2d){this.drawBackGround2d(this.backgroundColor);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];if(t.hidden)continue;let i=xB(t.node.width,t.node.height,t.width,t.height,t.fillMode,MD(t.rotation));this.draw2d(t.node.image,t.x+i.dx,t.y+i.dy,i.dWidth,i.dHeight,i.sx,i.sy,i.sWidth,i.sHeight)}return!0}return!1}debugLayout(e,t,i,r){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];this.ctx2d&&(o&&([i,r]=[r,i]),this.ctx2d.save(),this.ctx2d.strokeStyle="red",this.ctx2d.lineWidth=2,this.ctx2d.strokeRect(e,t,i,r),this.ctx2d.restore())}getInfo(){let{totalFrames:e,x:t,y:i,width:r,height:o,name:n}=this,a=Date.now(),s=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:i,width:r,height:o,timestamp:a,fps:s,name:n},Zw({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}removeAllInputs(){this.inputs.forEach((e=>{var t;if(e.node.disconnect(),e.positionBuffer&&this.context instanceof LB)try{null==(t=this.context.ctx)||t.deleteBuffer(e.positionBuffer)}catch(pM){}}))}close(){super.close(),this.removeAllInputs()}},FB=[1,0,0,0,1,1,0,1],BB=class extends EB{constructor(e,t,i,r){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:t}),aR(this,"mirror",!1),aR(this,"rotation",0),i&&(this.mirror=i),r&&(this.rotation=r),e instanceof LB)try{this.setTexBuffer(FB)}catch(CR){e.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(CR.message||CR)}))}}draw2d(e,t,i,r,o){if(this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height),this.ctx2d.save(),this.mirror&&(this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0)),90===this.rotation?(this.ctx2d.translate(r,0),this.ctx2d.rotate(Math.PI/2),this.ctx2d.scale(o/r,r/o)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,o),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(o/r,r/o));let n=super.draw2d(e,t,i,r,o);return this.ctx2d.restore(),n}return!1}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}resize(e,t){MD(this.rotation)&&([e,t]=[t,e]),super.resize(e,t)}},HB=class extends cB{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,Mx),aR(this,"inputLocalVideoTracks",new Map),aR(this,"inputLocalScreenTracks",new Map),aR(this,"cameraNodeMap",new Map),aR(this,"screenNodeMap",new Map),aR(this,"textNodeMap",new Map),aR(this,"imageNodeMap",new Map),aR(this,"videoNodeMap",new Map),aR(this,"endedIds",new Set),aR(this,"videoContext"),aR(this,"mixNode"),aR(this,"destination"),aR(this,"manager"),aR(this,"stat"),aR(this,"_checkId",0),aR(this,"autoSetFps",!0),this.manager=e,this.log.id+="mix",this.create2dVideoContext(),this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(EB.RENDER,(e=>{this.emit("render",e)})),this.mixNode=new VB(this.videoContext,this.log),this.mixNode.matchInputSize=!1}listenDeviceChange(){throw new Error("Method not implemented.")}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=$P.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}create2dVideoContext(){this.videoContext?this.videoContext.destroy():this.videoContext=new PB({frameRate:15,logger:this.log,name:"mix-ctx"}),this.videoContext.create({alpha:!1})}setFps(e){this.autoSetFps=!1,this.videoContext.frameRate=e;for(let t of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])t.shouldUpdate=!1;setTimeout((()=>{var e;return null==(e=this.destination)?void 0:e.start(this.videoContext.frameRate)}),500)}setFpsAuto(){var e;if(!this.autoSetFps)return;for(let o of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])o.shouldUpdate=!1;let t=null,i=0,r=!0;for(let[o,n]of this.inputLocalVideoTracks)if(n.profile.frameRate>i){if(this.endedIds.has(o)){let e=this.cameraNodeMap.get(o);e&&e.image.cancelVideoFrameCallback(e.videoCallbackId);continue}i=n.profile.frameRate,t=o}for(let[o,n]of this.inputLocalScreenTracks)if(n.profile.frameRate>i){if(this.endedIds.has(o)){let e=this.screenNodeMap.get(o);e&&e.image.cancelVideoFrameCallback(e.videoCallbackId);continue}i=n.profile.frameRate,t=o,r=!1}if(null!==t){let e=r?this.cameraNodeMap.get(t):this.screenNodeMap.get(t);e&&(e.shouldUpdate=!0,e.tryVideoFrameCallback()),this.log.info("set mix fps: ",i)}else null==(e=this.destination)||e.start(this.videoContext.frameRate),this.log.info("fallback to timer, fps: ",this.videoContext.frameRate)}setMixBackground(e){this.mixNode&&(this.mixNode.backgroundColor=e)}resizeMixCanvas(e,t){var i;null==(i=this.mixNode)||i.resize(e,t)}startMix(){return cR(this,null,(function*(){var e;if(!this.mixNode||!this.destination)throw new Error("can't mix without necessary conditions");this.mixNode.disconnect(),this.mixNode.connect(this.destination),IO&&this.player.setCanvas(this.videoContext._canvas),this.setOutputMediaStreamTrack(this.destination.videoTrack),null==(e=this.manager)||e.changeInput(this)}))}addCameraSource(e,t,i){if(this.inputLocalVideoTracks.has(e)||this.cameraNodeMap.has(e))throw new Error("There is already a cameraSource with the same ID: ".concat(e));let r,{mediaTrack:o}=t;if(!o)throw new Error("no mediaTrack, add cameraSource failed");t.recaptureMode=1,ix(this,dU).add("videoInputRemoved",(i=>{i.deviceId===t.deviceId&&(this.endedIds.add(e),this.setFpsAuto())})),t.on("output-media-track-changed",(()=>{this.endedIds.delete(e),this.updateCameraSource(e,i,t.mediaTrack)})),r=16===kO&&o instanceof CanvasCaptureMediaStreamTrack?this.videoContext.createVideoImageSource(o.canvas,{name:"cameraCanvasSource",logger:this.log}):this.videoContext.createVideoTrackSource(o,"cameraNodeSource"),r.resize(t.settings.width,t.settings.height),r.shouldUpdate=!1,this._connectMix(r,i,"cover"),this.inputLocalVideoTracks.set(e,t),this.cameraNodeMap.set(e,r),this.setFpsAuto()}addScreenSource(e,t,i){if(this.inputLocalScreenTracks.has(e)||this.screenNodeMap.has(e))throw new Error("There is already a screenSource with the same ID: ".concat(e));let{mediaTrack:r}=t;if(!r)throw new Error("no mediaTrack, add cameraSource failed");let o=this.videoContext.createVideoTrackSource(r,"screenNodeSource");o.resize(t.settings.width,t.settings.height),o.shouldUpdate=!1,this._connectMix(o,i),this.inputLocalScreenTracks.set(e,t),this.screenNodeMap.set(e,o),this.setFpsAuto()}addTextSource(e){let{id:t,content:i="",font:r,color:o,layout:n}=e;if(this.textNodeMap.has(t))throw new Error("There is already a textSource with the same ID: ".concat(t));let a=this.videoContext.createTextSource({content:i,font:r,color:o});a.resize(n.width,n.height),this._connectMix(a,n),this.textNodeMap.set(t,a)}addImageSource(e,t,i){if(this.imageNodeMap.has(e))throw new Error("There is already a imageSource with the same ID: ".concat(e));let r=this.videoContext.createVideoImageSource(t,{autoResize:!1,logger:this.log});r.resize(t.width,t.height),this._connectMix(r,i),this.imageNodeMap.set(e,r)}addVideoSource(e,t,i){if(this.videoNodeMap.has(e))throw new Error("There is already a videoSource with the same ID: ".concat(e));let r=this.videoContext.createVideoImageSource(t,{autoResize:!1,logger:this.log});r.resize(t.videoWidth,t.videoHeight),r.shouldUpdate=!1,this._connectMix(r,i),this.videoNodeMap.set(e,r)}updateCameraSource(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3?arguments[3]:void 0,o=this.cameraNodeMap.get(e);if(o){if(i){if(16===kO&&i instanceof CanvasCaptureMediaStreamTrack)if(o instanceof CB){let t=o.output;o.close(),o=this.videoContext.createVideoImageSource(i.canvas,{name:"cameraCanvasSource",logger:this.log}),o.connect(t),this.cameraNodeMap.set(e,o)}else o.image=i.canvas;else if(o instanceof CB)o.replaceTrack(i);else{let t=o.output;o.close(),o=this.videoContext.createVideoTrackSource(i,"cameraNodeSource"),o.connect(t),this.cameraNodeMap.set(e,o)}let{width:t,height:r}=i.getSettings();t&&r&&o.resize(t,r)}r&&o.resize(r.width,r.height),(r||i)&&this.setFpsAuto(),this._changeMixLayout(o,t)}}updateScreenSource(e,t){let i=this.screenNodeMap.get(e);i&&this._changeMixLayout(i,t)}updateTextSource(e){let{id:t,content:i,font:r,color:o,layout:n}=e,a=this.textNodeMap.get(t);a&&(YC(i)||(a.content=i),YC(r)||(a.font=r),YC(o)||(a.color=o),a.resize(n.width,n.height),this._changeMixLayout(a,n))}updateImageSource(e,t,i){let r=this.imageNodeMap.get(e);r&&(i&&(r.image=i,r.resize(i.width,i.height)),this._changeMixLayout(r,t))}updateVideoSource(e,t,i){let r=this.videoNodeMap.get(e);if(r){if(i){let e=r.image;e instanceof HTMLVideoElement&&this.stopVideoElement(e),r.image=i,r.resize(i.videoWidth,i.videoHeight)}this._changeMixLayout(r,t)}}_connectMix(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"contain";if(!this.mixNode)return;let{mirror:r,rotation:o}=t;e.disconnect();let n=new BB(this.videoContext,this.log,r,o);n=e.connect(n),t.fillMode||(t.fillMode=i),n.connect(this.mixNode,t)}_changeMixLayout(e,t){if(!this.mixNode)return;let{mirror:i,rotation:r}=t,o=e.output||e;o instanceof BB&&(YC(i)||(o.mirror=i),YC(r)||(o.rotation=r),o.resize(e.width,e.height)),this.mixNode.changeInputLayout(o,t)}removeCameraSource(e){let t=this.inputLocalVideoTracks.get(e);if(!t)return;t.close(),this.inputLocalVideoTracks.delete(e);let i=this.cameraNodeMap.get(e);i&&(i.output instanceof BB&&i.output.close(),i.close(),this.cameraNodeMap.delete(e)),this.checkAfterRemove(!0)}removeScreenSource(e){let t=this.inputLocalScreenTracks.get(e);if(!t)return;t.close(),this.inputLocalScreenTracks.delete(e);let i=this.screenNodeMap.get(e);i&&(i.output instanceof BB&&i.output.close(),i.close(),this.screenNodeMap.delete(e)),this.checkAfterRemove(!0)}removeTextSource(e){let t=this.textNodeMap.get(e);t&&(t.output instanceof BB&&t.output.close(),t.close(),this.textNodeMap.delete(e)),this.checkAfterRemove()}removeImageSource(e){let t=this.imageNodeMap.get(e);t&&(t.output instanceof BB&&t.output.close(),t.close(),this.imageNodeMap.delete(e)),this.checkAfterRemove()}removeVideoSource(e){let t=this.videoNodeMap.get(e);t&&(t.output instanceof BB&&t.output.close(),t.image instanceof HTMLVideoElement&&this.stopVideoElement(t.image),t.close(),this.videoNodeMap.delete(e)),this.checkAfterRemove()}checkAfterRemove(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.setFpsAuto()}stopVideoElement(e){e.pause(),e.src="",e.srcObject=null,e.remove()}close(){var e;super.close(),$P.clearTask(this._checkId),null==(e=this.videoContext)||e.destroy(),delete this.mixNode,delete this.destination;for(let t of[...this.inputLocalVideoTracks.values(),...this.inputLocalScreenTracks.values()])t.close();this.inputLocalVideoTracks.clear(),this.inputLocalScreenTracks.clear(),this.cameraNodeMap.clear(),this.screenNodeMap.clear(),this.textNodeMap.clear(),this.imageNodeMap.clear(),rx(this);for(let t of this.videoNodeMap.values())t.image instanceof HTMLVideoElement&&this.stopVideoElement(t.image);this.videoNodeMap.clear(),this.log.info("localMixVideoTrack close, stop mix")}},WB=oM();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:WB,exposeOrigin:!0,permittedOrigins:["*"]})}catch(Vw){}var jB=function(e){return cR(this,null,(function*(){let t=null,i=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},i={width:TO?{max:e.width}:{ideal:e.width,max:e.width},height:TO?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=i,e.systemAudio){let{echoCancellation:i=!0,noiseSuppression:r=!1,autoGainControl:o=!1}=e;t.audio={echoCancellation:i,noiseSuppression:r,autoGainControl:o,sampleRate:48e3}}return t}(e);rM.info("getDisplayMedia with constraints: ".concat(JSON.stringify(i)));let r=yield navigator.mediaDevices.getDisplayMedia(i);e.systemAudio&&0===r.getAudioTracks().length&&(_O&&vO<74||TO||_N)&&rM.warn("Your browser not support capture system audio");let o=r.getVideoTracks()[0];if(o){if(e.frameRate)try{yield o.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(_M){rM.warn("screen applyConstraints failed: ".concat(_M))}e.captureElement&&(yield function(e,t){return cR(this,null,(function*(){var i;if("CropTarget"in window&&"fromElement"in CropTarget&&KC(e.cropTo))try{if((null==(i=e.getCaptureHandle())?void 0:i.handle)!==WB)return;let r=yield CropTarget.fromElement(t);yield e.cropTo(r)}catch(r){rM.warn("cropTo target failed ".concat(r))}}))}(o,e.captureElement))}if(e.audio){let i=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return YC(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);rM.info("getUserMedia with constraints: ".concat(JSON.stringify(i))),t=yield navigator.mediaDevices.getUserMedia(i),r.addTrack(t.getAudioTracks()[0])}return r}))},GB=class extends mB{constructor(e){super(e,2),aR(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),aR(this,"objectFit","contain"),aR(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}get isShareCurrentTab(){var e,t;try{return WB===(null==(t=null==(e=this.mediaTrack)?void 0:e.getCaptureHandle())?void 0:t.handle)}catch(pM){return}}capture(e){return cR(this,arguments,(function(e){var t=this;let{systemAudio:i=!1,autoGainControl:r,echoCancellation:o,noiseSuppression:n,audioTrack:a,videoTrack:s,captureElement:c,preferDisplaySurface:l}=e;return function*(){try{let e;return s||a?(e=new MediaStream,s&&e.addTrack(s),a&&e.addTrack(a)):(e=yield jB({audio:!1,systemAudio:i,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:r,echoCancellation:o,noiseSuppression:n,captureElement:c,preferDisplaySurface:l}),t.sourceTrack=e.getVideoTracks()[0]),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(e){throw t.log.error("getDisplayMedia error observed ".concat(e)),e instanceof vR?e:new vR({code:_R.INITIALIZE_FAILED,name:e.name,message:e.message})}}()}))}switchDevice(e){return cR(this,null,(function*(){throw new Error("Method not implemented.")}))}};nR([OU((function(e){this.setContentHint(e.contentHint||"detail")}))],GB.prototype,"capture",1);var zB,qB=class extends dB{constructor(e){super(e),this._log.id="s-".concat(this._log.id),this.isScreen=!0}addAudioProcessor(e,t,i){this.pipeline.silentNode.setNode(i),this.pipeline.mixNode.setNode(t),this.pipeline.aec.setNode(e),this.enableTrackAEC(!1)}removeAudioProcessor(e){this.pipeline.aec.node===e&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode(),this.enableTrackAEC(!0))}};function KB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3?arguments[3]:void 0;return cR(this,null,(function*(){let o=Yx();zB||(zB=Lx(o,URL.createObjectURL(new Blob(['registerProcessor("dumper",class extends AudioWorkletProcessor{constructor(e){super(),this.sourceSampleRate=e.processorOptions.sourceSampleRate||48e3,this.targetSampleRate=e.processorOptions.targetSampleRate||48e3,this.port.onmessage=e=>{this.port2=e.data.port}}process(e){return(this.port2||this.port).postMessage(this.resampleAll(e,this.sourceSampleRate,this.targetSampleRate)),!0}resampleAll(r,s,a){if(s===a)return r;var o=[];for(let t=0;t<r.length;t++){o[t]=[];for(let e=0;e<r[t].length;e++)o[t][e]=this.resample(r[t][e],s,a)}return o}resample(t,e,r){if(e===r)return t;var s=Math.round(t.length*(this.targetSampleRate/this.sourceSampleRate)),a=new Float32Array(s),o=(t.length-1)/(s-1);a[0]=t[0];for(let e=1;e<s-1;e++){var l=e*o,p=Math.floor(l),h=Math.ceil(l);a[e]=t[p]+(t[h]-t[p])*(l-p)}return a[s-1]=t[t.length-1],a}});'],{type:"application/javascript"})))),yield zB;let n=o.sampleRate,a=new AudioWorkletNode(o,"dumper",{numberOfInputs:e.length,numberOfOutputs:0,processorOptions:{sourceSampleRate:n,targetSampleRate:t}});return a.channelCountMode="explicit",a.channelCount=i,r&&a.port.postMessage({port:r},[r]),e.forEach(((e,t)=>e.connect(a,0,t))),new ReadableStream({start(e){a.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(a))),a.port.close()}})}))}var YB=class extends Zx{constructor(e){super(),this.room=e,aR(this,"_localAudioTrack"),aR(this,"_localScreenAudioTrack"),aR(this,"log"),aR(this,"denoiser"),aR(this,"voiceChanger"),aR(this,"mixChangedDebounce"),aR(this,"audioProcessor"),aR(this,"encodePipeline",[]),aR(this,"decodePipeline",[]),aR(this,"getPCMAbortCtrlMap",new Map),aR(this,"audioFrameEventConfigMap",new Map),aR(this,"audioReferenceMap",new Map),aR(this,"isLocalAudioNeedAudioProcess",!1),aR(this,"isScreenAudioNeedAudioProcess",!1),this.log=rM.createLogger({parent:null==e?void 0:e.getLogger(),id:"am",userId:null==e?void 0:e.userId,sdkAppId:null==e?void 0:e.sdkAppId}),this.installEvent()}get localAudioTrack(){return this._localAudioTrack}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}get _localScreenAudioPipeline(){var e;return null==(e=this._localScreenAudioTrack)?void 0:e.pipeline}dump(e){var t,i;if(!this._localAudioTrack)return;let r=[],o=[];null!=(t=this._localAudioPipline)&&t.source.node&&(r.push(this._localAudioPipline.source.node),o.push("mic")),null!=(i=this._localAudioPipline)&&i.denoiser.node&&(r.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(r.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(e));let n=new AbortController,a=[],s=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),n.abort("timeout")}),1e3*e),c=()=>{for(let e=0;e<o.length;e++){let t=URL.createObjectURL(new Blob(a[e])),i=document.createElement("a");i.href=t,i.download="".concat(o[e],".pcm"),i.style.display="none",document.body.appendChild(i),i.click(),URL.revokeObjectURL(t),i.remove()}clearTimeout(s),n.abort("download")},l=KB(r).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>a[t]=a[t]?a[t].concat(e[0]):[e[0]]))}}),n).catch((e=>c))));return{then:l.then.bind(l),download:c}}getPCM(e,t){var i,r,o;if("undefined"==typeof WritableStream)return void this.log.warn("getPCM failed: browser not support WritableStream");let{enable:n,sampleRate:a=48e3,channelCount:s=1,port:c}=(""===t?this.audioFrameEventConfigMap.get(""):this.audioFrameEventConfigMap.get(t)||this.audioFrameEventConfigMap.get("*"))||{};if(!n)return;this.log.info("getPCM ".concat(t||"local"));let l,d,u=Math.floor(.04*a),h=new Float32Array(u),p=new Float32Array(u),m=0,f=new AbortController,_=""===t?null==(i=this._localAudioTrack)?void 0:i.mediaTrack:null==(o=null==(r=this.room)?void 0:r.remotePublishedUserMap.get(t))?void 0:o.remoteAudioTrack.mediaTrack;if(_)return KB([Yx().createMediaStreamSource(new MediaStream([_]))],a,s,c).then((i=>i.pipeTo(new WritableStream({write(i){i[0][0]&&(m+i[0][0].length>u?(h.set(i[0][0].subarray(0,u-m),m),l=i[0][0].subarray(u-m),i[0][1]&&(p.set(i[0][1].subarray(0,u-m),m),d=i[0][1].subarray(u-m)),m+=u-m):(l&&(h.set(l,m),m+=l.length,l=void 0),d&&(p.set(d,m),d=void 0),h.set(i[0][0],m),i[0][1]&&p.set(i[0][1],m),m+=i[0][0].length),m>=u&&(m=0,e({userId:t,sampleRate:a,channelCount:s,data:1===s?h:[h,p]}),h=new Float32Array(u),p=new Float32Array(u)))}}),f).catch((e=>this.log.warn("stop getPCM reason:".concat(e)))))),f;this.log.info("getPCM failed: ".concat(t||"local"," has no audio track"))}get hasScreenAudioTrack(){return!YC(this._localScreenAudioTrack)}get hasAudioTrack(){return!YC(this._localAudioTrack)}changeInput(e){var t,i;return e instanceof qB?(this._localScreenAudioTrack=e,this.isScreenAudioNeedAudioProcess&&null!=(t=this.audioProcessor)&&t.screenAudioWorkletNode&&(e.addAudioProcessor(this.audioProcessor.screenAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach(((t,i)=>{e.mixAudioReference(t,i)}))),e.pipeline.connect(),this.mixOnChange()):e instanceof dB?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),this.isLocalAudioNeedAudioProcess&&null!=(i=this.audioProcessor)&&i.localAudioWorkletNode&&(e.addAudioProcessor(this.audioProcessor.localAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach(((t,i)=>{e.mixAudioReference(t,i)}))),e.pipeline.connect(),this.mixOnChange()):e instanceof QB?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}mixAudioReference(e,t){var i;null==(i=this._localAudioTrack)||i.mixAudioReference(e,t)}unMixAudioReference(e){var t;null==(t=this._localAudioTrack)||t.unMixAudioReference(e)}setAudioReferenceVolume(e,t){var i;null==(i=this._localAudioTrack)||i.setAudioReferenceVolume(e,t)}mixOnChange(){return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((()=>{var e,t;return delete this.mixChangedDebounce,Promise.all([null==(e=this._localAudioTrack)?void 0:e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)?void 0:t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}removeInput(e){e instanceof qB?delete this._localScreenAudioTrack:e instanceof dB&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}addAudioProcessor(e,t,i,r){var o;this.audioProcessor={localAudioWorkletNode:i,mixNode:e,silentNode:t,screenAudioWorkletNode:r},this.isLocalAudioNeedAudioProcess&&this._localAudioTrack&&i&&(this._localAudioTrack.addAudioProcessor(i,e,t),this.audioReferenceMap.forEach(((e,t)=>{var i;null==(i=this._localAudioTrack)||i.mixAudioReference(e,t)}))),this.isScreenAudioNeedAudioProcess&&this._localScreenAudioTrack&&r&&(null==(o=this._localScreenAudioTrack)||o.addAudioProcessor(r,e,t),this.audioReferenceMap.forEach(((e,t)=>{var i;null==(i=this._localScreenAudioTrack)||i.mixAudioReference(e,t)})))}removeDenoiser(e){var t;return delete this.denoiser,null==(t=this._localAudioTrack)?void 0:t.removeDenoiser(e)}addVoiceChanger(e,t){var i;this.voiceChanger=[e,t],null==(i=this._localAudioTrack)||i.pipeline.voiceChanger.setNode(e,t)}removeVoiceChanger(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}removeAudioProcessor(e,t){var i,r;delete this.audioProcessor,null==(i=this._localAudioTrack)||i.removeAudioProcessor(e),null==(r=this._localScreenAudioTrack)||r.removeAudioProcessor(t)}destroy(){this.close(),this.audioReferenceMap.clear(),this.getPCMAbortCtrlMap.forEach((e=>null==e?void 0:e.abort("destroy"))),this.getPCMAbortCtrlMap.clear(),this.audioFrameEventConfigMap.clear(),this.uninstallEvent()}addEncodeProcessor(e){let{processor:t,type:i}=e;var r;this.encodePipeline.includes(t)||(this.encodePipeline[i]=t,null==(r=this.room)||r.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:i}=e;var r;this.decodePipeline.includes(t)||(this.decodePipeline[i]=t,null==(r=this.room)||r.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}handleLocalTrackStarted(e){let{room:t,userId:i}=e;var r;if(t!==this.room||this.getPCMAbortCtrlMap.get(i))return;let o=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),"");this.getPCMAbortCtrlMap.set(i,o),this.getPCMAbortCtrlMap.get(i)&&(null==(r=this._localAudioTrack)||r.on("input-media-track-changed",(()=>{let e=this.getPCMAbortCtrlMap.get(i);e&&(e.abort("inputMediaTrackChanged"),e=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),""),this.getPCMAbortCtrlMap.set(i,e))})))}handleLocalTrackStopped(e){let{room:t,userId:i}=e;if(t!==this.room)return;let r=this.getPCMAbortCtrlMap.get(i);r&&(r.abort("stopLocalAudio"),this.getPCMAbortCtrlMap.delete(i))}handleRemoteTrackStarted(e){let{room:t,userId:i}=e;if(t===this.room&&!this.getPCMAbortCtrlMap.get(i)){let e=this.room.audioManager.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),i);this.getPCMAbortCtrlMap.set(i,e)}}handleRemoteTrackStopped(e){let{room:t,userId:i}=e;if(t!==this.room)return;let r=this.getPCMAbortCtrlMap.get(i);r&&(r.abort("stopRemoteAudio"),this.getPCMAbortCtrlMap.delete(i))}installEvent(){$O.on("113",this.handleLocalTrackStarted,this),$O.on("114",this.handleLocalTrackStopped,this),$O.on("115",this.handleRemoteTrackStarted,this),$O.on("116",this.handleRemoteTrackStopped,this)}uninstallEvent(){$O.off("113",this.handleLocalTrackStarted),$O.off("114",this.handleLocalTrackStopped),$O.off("115",this.handleRemoteTrackStarted),$O.off("116",this.handleRemoteTrackStopped)}updateAudioReference(e){let{type:t,audioReference:i,refId:r,volume:o}=e;if("add"===t){if(this.audioReferenceMap.get(r)||!i||(this.audioReferenceMap.set(r,i),!this.audioProcessor))return;this.mixAudioReference(i,r)}else if("remove"===t)this.audioReferenceMap.get(r)&&(this.audioReferenceMap.delete(r),this.unMixAudioReference(r));else if("updateVolume"===t){if(!this.audioProcessor||YC(o))return;this.setAudioReferenceVolume(r,o)}}};var XB=class e extends bU{constructor(t,i,r){super({userId:i.userId,sdkAppId:t.sdkAppId,mediaType:r,room:t}),this.room=t,this.user=i,aR(this,"tinyId"),aR(this,"isRemote",!0),aR(this,"jitterBufferDelay",0),aR(this,"availableState"),aR(this,"remotePublishState"),aR(this,"_triggerCheckDecodeSubject",yV(MV(this,e.STATE_SUBSCRIBE))),this.tinyId=i.tinyId,this.availableState=new qP("".concat(i.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new qP("".concat(i.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),ZU(cV(MV(this,qP.STATECHANGED),MV(this.remotePublishState,qP.STATECHANGED)),wF((()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing))),iB((e=>{this.availableState.state!==(e?qP.ON:qP.OFF)&&(this.availableState.state=e?qP.ON:qP.OFF),this.updatePlayingState(e)})));let o=ZU(MV(this.player,ZP.ERROR),$V((e=>e.code===MediaError.MEDIA_ERR_DECODE))),n=ZU(DV(5e3),$V((()=>!(this.ignoreDecodeError||!this.isSubscribed||!this.isPlayCalled||!this.stat.bytesReceived)&&(!this.player.isPlaying&&!(this.kind===ok.AUDIO?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1))))),a=ZU(lV(o,n),tF(MV(this,qP.INIT)));ZU(this._triggerCheckDecodeSubject,$V((()=>!this.ignoreDecodeError)),LF(a),iB((e=>{this.reportDecodeResult(!1,e)})))}setMute(e){this.isRemotePublished&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}checkDecodeResult(){this._triggerCheckDecodeSubject.next(!0)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get ignoreDecodeError(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===qP.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){var i,r;let o=this.kind===ok.AUDIO;if(CL[e?"addSuccessEvent":"addFailedEvent"]({key:o?504700:514702}),!o){let t=(null==(i=this.room)?void 0:i.downlinkVideoCodec.toUpperCase())||"H264";CL[e?"addSuccessEvent":"addFailedEvent"]({key:wL["DECODE_".concat(t,"_RESULT")]}),e||this.log.warn("".concat(null==(r=this.room)?void 0:r.downlinkVideoCodec," decode failed"))}e||(CL.addEnum({key:o?504701:514703,value:qO()}),ox.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(WO()||YO()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===ok.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));super.updatePlayingState(e)}}close(){super.close(),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}onFlagChanged(){this.remotePublishState.state=this.isRemotePublished?qP.ON:qP.OFF,this.emit("remote-publish-changed",this.isRemotePublished)}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};aR(XB,"STATE_SUBSCRIBE","subscribe"),nR([function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return MU(((i,r)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return new Promise(((o,a)=>{let s=setTimeout((()=>{let i=new vR({code:_R.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(r,"() timeout ").concat(e,"s")});(this.log||this._log||rM).warn(i),2===t?a(i):1===t&&o()}),1e3*e);this._checkPendingPromiseSet||(this._checkPendingPromiseSet=new Set),this._checkPendingPromiseSet.add(s),i.apply(this,n).then(o,a).finally((()=>{clearTimeout(s),this._checkPendingPromiseSet&&s&&this._checkPendingPromiseSet.delete(s)}))}))}))}(5,1)],XB.prototype,"waitHasMediaTrack",1),nR([jP(qP.INIT,XB.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),$O.emit(eM.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),HU(521716,!1)],XB.prototype,"subscribe",1),nR([jP(XB.STATE_SUBSCRIBE,qP.INIT,{sync:!0,success(){this.log.info("unsubscribed"),$O.emit(eM.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],XB.prototype,"unsubscribe",1);var JB=XB,QB=class extends JB{constructor(e,t){super(e,t,1),aR(this,"volume",0),aR(this,"mediaType",1),aR(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}get dbVolume(){return nU.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}onPlayerError(e){this.enableDecodeFrame&&(this._log.warn("use audio decoder"),this.room.enableInsertableStreams())}get enableDecodeFrame(){var e,t;return!!this.manager&&(this.manager.decodePipeline.some((e=>e))||(null==(t=null==(e=this.player.element)?void 0:e.error)?void 0:t.code)===MediaError.MEDIA_ERR_DECODE&&TP().AudioDecoder&&gP)}get enableDecryptFrame(){return this.manager&&!!this.manager.decodePipeline[0]}decodeFrame(e){if(!this.manager)return e;let t=e;for(let[i,r]of this.manager.decodePipeline.entries()){if(!r)continue;let o={frame:e,track:this};if(1===i&&this.isAvailable&&"audience"===this.room.role&&(o.onAudioFrameNTPTime=e=>{let{ntp:t,frame:i,hasLeavingTag:r}=e;this.emit("audio-frame-with-ntp",{ntp:t,frame:i,hasLeavingTag:r})}),t=r(o),!t)return}return t}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get isRemotePublished(){return this.user.muteState.audioAvailable}},$B=class extends EB{constructor(e,t,i,r,o){super(e,{useDefaultProgram:!0,useFbo:!0,name:"alpha",create2d:!0,logger:t}),this.setContainer=r,aR(this,"initStat",{alphaStitchingType:1}),aR(this,"end",yV()),aR(this,"minSize",320),aR(this,"maxSize",1280),aR(this,"draggable",!1),aR(this,"startDragX",0),aR(this,"startDragY",0),aR(this,"left",0),aR(this,"top",0),aR(this,"baseWidth",320),aR(this,"baseRatio"),aR(this,"container"),this.initStat=o,this.draggable=i,this.bindDragEvents()}bindDragEvents(){let e=this.context._canvas;if(e)if(this.draggable){let t=tF(this.end);ZU(MV(e,"mousedown"),rB(this.startDrag.bind(this)),OF((()=>ZU(MV(window,"mousemove"),tF(MV(window,"mouseup"))))),t,iB(this.doDrag.bind(this))),ZU(MV(e,"dblclick"),t,iB(this.resetPosition.bind(this))),ZU(MV(e,"wheel"),t,iB(this.handleZoom.bind(this))),this.renderCanvas()}else{if(!this.container)return;this.container.style.removeProperty("left"),this.container.style.removeProperty("top"),this.end.next()}}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}startDrag(e){e.preventDefault(),0===e.button&&(this.startDragX=e.clientX-this.left,this.startDragY=e.clientY-this.top)}renderCanvas(){let{container:e}=this;e||this.setContainer(),e&&this.baseRatio&&this.draggable&&(e.style.setProperty("width","".concat(this.baseWidth,"px")),e.style.setProperty("height","".concat(this.baseWidth/this.baseRatio,"px")),e.style.setProperty("position","fixed"),e.style.setProperty("left","".concat(this.left,"px")),e.style.setProperty("top","".concat(this.top,"px")))}doDrag(e){e.preventDefault(),this.left=e.clientX-this.startDragX,this.top=e.clientY-this.startDragY,this.renderCanvas()}handleZoom(e){e.preventDefault();let t=e.deltaY,i=this.context._canvas;i&&(this.baseWidth||(this.baseWidth=i.offsetWidth),this.baseWidth=t<0?Math.min(1.1*this.baseWidth,this.maxSize):Math.max(.9*this.baseWidth,this.minSize),this.renderCanvas())}resetPosition(){this.left=0,this.top=0,this.renderCanvas()}onRatioReset(){this.renderCanvas()}draw2d(e,t,i,r,o){var n;let{ctx2d:a}=this,s=this.context._canvas;if(!a||!s)return!1;let c=super.draw2d(e,t,i,r,o),l=a.getImageData(0,0,r,o),{data:d}=l,u=!1;if(1===this.initStat.alphaStitchingType){let e=Math.floor(r/2);for(let t=0;t<o;t++)for(let i=0;i<e;i++){let o=4*(t*r+i),n=4*(t*r+(i+e)),a=d[n];d[n+3]=0;let s=a>=100;d[o+3]=s?255:0}u=super.draw2d(l,0,0,0,0,e,o),s.width=e}else if(2===this.initStat.alphaStitchingType){let e=Math.floor(o/2);for(let t=0;t<e;t++)for(let i=0;i<r;i++){let o=4*(t*r+i),n=4*((t+e)*r+i),a=d[n];d[n+3]=0;let s=a>=100;d[o+3]=s?255:0}u=super.draw2d(l,0,0,0,0,r,e),s.height=e}return null==(n=this.context.ctx)||n.clearRect(0,0,r,o),c&&u}close(){this.baseRatio=void 0,this.end.next(),this.end.complete()}};var ZB=class extends JB{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),aR(this,"mediaType",4),aR(this,"source"),aR(this,"shouldRenderAlpha",!1),aR(this,"alphaNode"),aR(this,"shouldBeDraggable",!0),aR(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager,this.once("first-video-frame",(e=>{this.room.emit("first-video-frame",e)}))}isAlphaSei(e){if(this.userId!==e.userId||50!==e.seiPayloadType)return!1;let t=new Uint8Array(e.data);return t.length%3==0&&0===t[0]&&1===t[1]&&t}play(e,t){return(QC(null==t?void 0:t.canvasRender)?t.canvasRender:17===kO)&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then((()=>{this.player.calculateStat(),$O.emit("156",{track:this,player:this.player})}))}updateAlphaRenderInfo(e){let t=this.isAlphaSei(e);if(t)if(this.alphaNode){let e=t[2];if(this.alphaNode.baseRatio&&this.alphaNode.initStat.alphaStitchingType===e)return;this.alphaNode.initStat={alphaStitchingType:e};let i=this.player.getElement();if(i){let t=i.videoWidth/i.videoHeight;t&&(this.alphaNode.baseRatio=t*(1===e?.5:2),this.alphaNode.onRatioReset())}this.player.canvas&&(this.player.canvas.id=this.generateAlphaCanvasName(e))}else this.shouldRenderAlpha=!0,this.player.shouldRenderAlpha=!0,this.useCanvasPlayer(t[2])}generateAlphaCanvasName(e){let t=pL[e];return"".concat("alpha","_").concat(t,"_").concat(this.userId)}useCanvasPlayer(e){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),!this.player.element)return;let t=new PB({frameRate:15,logger:this.log,name:this.shouldRenderAlpha&&e?this.generateAlphaCanvasName(e):this.userId});t.create({alpha:this.shouldRenderAlpha,willReadFrequently:this.shouldRenderAlpha});let i=new AB(t,{name:"remotePlayer",logger:this.log});if(this.source=t.createVideoPlayerSource(this.player),this.player.setCanvas(t._canvas),this.shouldRenderAlpha&&e){let r=()=>{!this.player.container||!this.alphaNode||(this.alphaNode.container=this.player.container,this.alphaNode.renderCanvas())},o=new $B(t,this.log,this.shouldBeDraggable,r,{alphaStitchingType:e});this.source.connect(o),o.connect(i),this.alphaNode=o}else this.source.connect(i);CP()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,t),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,i=function(e){return[15,30,45,60].reduce(((t,i)=>Math.abs(i-e)<Math.abs(t-e)?i:t))}(t);!JC(t)||t<=0?this.log.debug("updateCanvasPlayerFPS() ignore decoder: ".concat(t," ")):i!==e.frameRate?(this.log.info("updateCanvasPlayerFPS() decoder: ".concat(t,", closest: ").concat(i,", current: ").concat(e.frameRate)),e.frameRate=i):this.log.debug("updateCanvasPlayerFPS() ignore ClosestFPS ".concat(i," == ").concat(e.frameRate))}get decodeFPS(){var e;let{msg_video_status:t}=(null==(e=this.room.heartbeatReport)?void 0:e.msg_down_stream_info.find((e=>e.msg_user_info.str_identifier===this.userId)))||{},i=2===this.mediaType?7:this.isSmall?3:2;if(!t||0===t.length)return 0;let r=t.find((e=>e.uint32_video_stream_type===i));return(null==r?void 0:r.uint32_video_dec_fps)||0}stop(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),$O.emit("157",{track:this,player:this.player}),this.alphaNode&&this.alphaNode.close(),super.stop()}decodeFrame(e){if(!this.manager)return e;for(let t of this.manager.decodePipeline)if(t&&!(e=t({frame:e,track:this})))return;return e}get isBig(){return 4===this.mediaType}get isSmall(){return 8===this.mediaType}changeType(e){this.room.changeType(e,this.user)}get isRemotePublished(){return this.user.muteState.videoAvailable}setMirror(e){"publish"===e||"both"===e||super.setMirror(e)}setDraggable(e){this.shouldBeDraggable=e,this.alphaNode&&(this.alphaNode.draggable=e,this.alphaNode.bindDragEvents())}onDecodeDowngradeStateChanged(e){this.emit("decode-downgrade-state-changed",e)}},eH=class extends ZB{constructor(e,t){super(e,t,2),aR(this,"mediaType",2),aR(this,"objectFit","contain")}get isRemotePublished(){return this.user.muteState.hasAuxiliary}},tH=new Map;function iH(e,t){let i=eR(Zw({},t),{timestamp:yR()});tH.has(e)?tH.get(e).push(i):tH.set(e,[i])}function rH(e){if(tH.has(e)){let t=tH.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType})));return tH.delete(e),t}return[]}function oH(e,t,i,r){try{if(ZC(e))for(let o=0;o<e.length;o++)nH.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:i,className:r});else nH.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:r})}catch(pM){throw rM.error(pM),pM}}function nH(e){let{rule:t,value:i,key:r,fnName:o,className:n}=e;if(YC(i)){if(t.required)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_REQUIRED,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(YC(t.defaultValue))return;i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let r=0;r<t.type.length;r++)null===t.type[r]&&null===i&&(e=!0),KC(t.type[r])&&i instanceof t.type[r]&&(e=!0),XC(t.type[r])&&qC(i)===t.type[r].toLowerCase()&&(e=!0);if(!e)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_TYPE,data:{key:r,rule:{type:t.type.map((e=>rD(e)?oD(e):XC(e)?e:qC(e)))},fnName:o,value:i},link:{className:n,fnName:o}})})}else if(!YC(t.type)&&qC(i)!==t.type)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_TYPE,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(!1===t.allowEmpty){let e=JC(i)&&(0===i||Number.isNaN(i)),a=XC(i)&&""===i.trim();if(e||a)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_EMPTY,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})})}if(t.notLessThanZero&&JC(i)&&i<0)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.CANNOT_LESS_THAN_ZERO,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(!YC(t.min)&&JC(i)&&i<t.min)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_MIN,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(!YC(t.max)&&JC(i)&&i>t.max)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_MAX,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(XC(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_INSTANCE,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})})}else if(KC(t.instanceOf)&&!(i instanceof t.instanceOf))throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_INSTANCE,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});if(t.values&&!t.values.includes(i))throw new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.INVALID_PARAMETER_RANGE,data:{key:r,rule:t,fnName:o,value:i},link:{className:n,fnName:o}})});let{properties:a}=t;jC(a)&&$C(i)&&Object.keys(a).forEach((e=>{nH.call(this,{rule:a[e],value:i&&i[e],key:"".concat(r,".").concat(e),fnName:o,className:n})}));let{arrayItem:s}=t;jC(s)&&ZC(i)&&i.forEach(((e,t)=>{nH.call(this,{rule:s,value:e,key:"".concat(r,"[").concat(t,"]"),fnName:o,className:n})})),KC(t.validate)&&t.validate.call(this,i,r,o,n,this)}$O.on(eM.JOIN_SUCCESS,(e=>{let{room:t}=e;iH(t.userId,{eventId:32788})})),$O.on(eM.LEAVE_START,(e=>{let{room:t}=e;iH(t.userId,{eventId:32789})})),$O.on(eM.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),iH(t.room.userId,{eventId:e})}})),$O.on(eM.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),iH(t.room.userId,{eventId:e})}})),$O.on(eM.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===ok.AUDIO?iH(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):iH(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),$O.on(eM.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===ok.AUDIO?iH(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):iH(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),$O.on(eM.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&iH(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&iH(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&iH(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),$O.on(eM.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&iH(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&iH(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&iH(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),$O.on(eM.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&iH(t.room.userId,{eventId:t.kind===ok.VIDEO?32780:32781})})),$O.on(eM.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&iH(t.room.userId,{eventId:t.kind===ok.VIDEO?32782:32783})})),$O.on(eM.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,{room:i,prevState:r,state:o}=e;switch(o){case"CONNECTED":t="RECONNECTING"===r?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===r?32796:32790;break;case"RECONNECTING":t=32794}t&&iH(i.userId,{eventId:t})})),$O.on(eM.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,{room:i,prevState:r,state:o,remoteUserId:n}=e,a=!!n;switch(o){case"CONNECTED":t="RECONNECTING"===r?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===r&&(t=a?32802:32799);break;case"RECONNECTING":t=a?32800:32797}t&&iH(i.userId,{eventId:t,remoteUserId:n})})),$O.on(eM.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(e=>{let{implementation:t,userId:i,remoteUserId:r,codec:o,isHWCodec:n,prevImplementation:a,streamType:s}=e,c=n?1:0;a||(c=n?3:2);let l={H264:0,H265:1,VP8:2}[o.toUpperCase()],d={eventId:4004,param1:c,param2:l,streamType:s||2};r&&(d.remoteUserId=r,d.eventId=4005),iH(i,d),CL.addEnum({key:r?514701:513701,value:c}),CL.addEnum({key:r?514700:513700,value:l})})),$O.on(eM.LOCAL_TRACK_RECAPTURE,(e=>{let{track:t,error:i}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===ok.AUDIO?(e.streamType=1,i&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,i&&(e.param1=8)),iH(t.userId,e)}})),oR(lR(),1);var aH=Object.create,sH=Object.defineProperty,cH=Object.defineProperties,lH=Object.getOwnPropertyDescriptor,dH=Object.getOwnPropertyDescriptors,uH=Object.getOwnPropertyNames,hH=Object.getOwnPropertySymbols,pH=Object.getPrototypeOf,mH=Object.prototype.hasOwnProperty,fH=Object.prototype.propertyIsEnumerable,_H=(e,t,i)=>t in e?sH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,gH=(e,t)=>{for(var i in t||(t={}))mH.call(t,i)&&_H(e,i,t[i]);if(hH)for(var i of hH(t))fH.call(t,i)&&_H(e,i,t[i]);return e},vH=(e,t)=>cH(e,dH(t)),EH=(e,t,i)=>(i=null!=e?aH(pH(e)):{},((e,t,i,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of uH(t))mH.call(e,o)||o===i||sH(e,o,{get:()=>t[o],enumerable:!(r=lH(t,o))||r.enumerable});return e})(!t&&e&&e.__esModule?i:sH(i,"default",{value:e,enumerable:!0}),e)),yH=(e,t,i,r)=>{for(var o,n=r>1?void 0:r?lH(t,i):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(r?o(t,i,n):o(n))||n);return r&&n&&sH(t,i,n),n},TH=(e,t,i)=>_H(e,"symbol"!=typeof t?t+"":t,i),IH=((e,t)=>function(){return t||(0,e[uH(e)[0]])((t={exports:{}}).exports,t),t.exports})({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){var i=Object.prototype.hasOwnProperty,r="~";function o(){}function n(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function a(e,t,i,o,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new n(i,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 s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(r=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)i.call(e,t)&&o.push(r?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},c.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var o=0,n=i.length,a=new Array(n);o<n;o++)a[o]=i[o].fn;return a},c.prototype.listenerCount=function(e){var t=r?r+e:e,i=this._events[t];return i?i.fn?1:i.length:0},c.prototype.emit=function(e,t,i,o,n,a){var s=r?r+e:e;if(!this._events[s])return!1;var c,l,d=this._events[s],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,o),!0;case 5:return d.fn.call(d.context,t,i,o,n),!0;case 6:return d.fn.call(d.context,t,i,o,n,a),!0}for(l=1,c=new Array(u-1);l<u;l++)c[l-1]=arguments[l];d.fn.apply(d.context,c)}else{var h,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),u){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,i);break;case 4:d[l].fn.call(d[l].context,t,i,o);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,i){return a(this,e,t,i,!1)},c.prototype.once=function(e,t,i){return a(this,e,t,i,!0)},c.prototype.removeListener=function(e,t,i,o){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||o&&!a.once||i&&a.context!==i||s(this,n);else{for(var c=0,l=[],d=a.length;c<d;c++)(a[c].fn!==t||o&&!a[c].once||i&&a[c].context!==i)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,void 0!==t&&(t.exports=c)}}),AH=EH(IH(),1),bH=Symbol("instance"),SH=Symbol("cacheResult"),wH=class{constructor(e,t,i){this.oldState=e,this.newState=t,this.action=i,this.aborted=!1}abort(e){this.aborted=!0,NH.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},RH=class extends Error{constructor(e,t,i){super(t),this.state=e,this.message=t,this.cause=i}};var kH=new Map;function CH(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(r,o,n)=>{let a=i.action||o;if(!i.context){let i=kH.get(r)||[];kH.has(r)||kH.set(r,i),i.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let r=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(i.context&&(r=OH.get("function"==typeof i.context?i.context.call(this,...n):i.context)),r.state===t)return i.sync?r[SH]:Promise.resolve(r[SH]);r.state instanceof wH&&r.state.action==i.abortAction&&r.state.abort(r);let l=null;Array.isArray(e)?0==e.length?r.state instanceof wH&&r.state.abort(r):"string"==typeof r.state&&e.includes(r.state)||(l=new RH(r._state,"".concat(r.name," ").concat(a," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e.join("|")))):e!==r.state&&(l=new RH(r._state,"".concat(r.name," ").concat(a," to ").concat(t," failed: current state ").concat(r._state," not from ").concat(e)));let d=e=>{if(i.fail&&i.fail.call(this,e),i.sync){if(i.ignoreError)return e;throw e}return i.ignoreError?Promise.resolve(e):Promise.reject(e)};if(l)return d(l);let u=r.state,h=new wH(u,t,a);NH.call(r,h);let p=e=>{var o;return r[SH]=e,h.aborted||(NH.call(r,t),null===(o=i.success)||void 0===o||o.call(this,r[SH])),e},m=e=>(NH.call(r,u,e),d(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):i.sync?p(e):Promise.resolve(p(e))}catch(gM){return m(new RH(r._state,"".concat(r.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(gM),gM instanceof Error?gM:new Error(String(gM))))}}}}var DH="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function NH(e,t){let i=this._state;this._state=e;let r=e.toString();e&&this.emit(r,i),this.emit(OH.STATECHANGED,e,i,t),this.updateDevTools({value:e,old:i,err:t instanceof Error?t.message:String(t)})}var OH=class e extends AH.default{constructor(t,i,r){super(),this.name=t,this.groupName=i,this._state=e.INIT,t||(t=Date.now().toString(36)),r?Object.setPrototypeOf(this,r):r=Object.getPrototypeOf(this),i||(this.groupName=this.constructor.name);let o=r[bH];o?this.name=o.name+"-"+o.count++:r[bH]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=kH.get(e)||[],i=new Set,r=[],o=[],n=new Set,a=Object.getPrototypeOf(e);kH.has(a)&&(a.stateDiagram.forEach((e=>i.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:i,action:n}=e;"string"==typeof t?r.push({from:t,to:i,action:n}):t.length?t.forEach((e=>{r.push({from:e,to:i,action:n})})):o.push({to:i,action:n})})),r.forEach((e=>{let{from:t,to:r,action:o}=e;n.add(t),n.add(r),n.add(o+"ing"),i.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),i.add("".concat(o,"ing --\x3e ").concat(r," : ").concat(o," 🟢")),i.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:r}=e;i.add("".concat(r,"ing --\x3e ").concat(t," : ").concat(r," 🟢")),n.forEach((e=>{e!==t&&i.add("".concat(e," --\x3e ").concat(r,"ing : ").concat(r))}))}));let s=[...i];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let i;return"string"==typeof t?(i=e.instances.get(t),i||e.instances.set(t,i=new e(t,void 0,Object.create(e.prototype)))):(i=e.instances2.get(t),i||e.instances2.set(t,i=new e(t.constructor.name,void 0,Object.create(e.prototype)))),i}static getState(t){var i;return null===(i=e.get(t))||void 0===i?void 0:i.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};DH(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){NH.call(this,e)}};OH.STATECHANGED="stateChanged",OH.UPDATEAFSM="updateAFSM",OH.INIT="[*]",OH.ON="on",OH.OFF="off",OH.instances=new Map,OH.instances2=new WeakMap;var MH=class extends OH{constructor(){super(...arguments),TH(this,"decoder"),TH(this,"config")}initialize(){return cR(this,null,(function*(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}))}configure(e){this.config=e,this.decoder.configure(vH(gH({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function LH(){var e;self.onmessage=t=>{if("init"===t.data.type){let{canvas:i,wasmScript:r,wasmBinary:o}=t.data,n=null==i?void 0:i.getContext("2d"),a=0,s=0,c={wasmBinary:o,postRun:()=>{e=new c.VideoDecoder({videoInfo(e,t){a=e,s=t,console.log("video info",e,t)},yuvData(e,t){let r=a*s,o=r>>2,l=c.HEAPU32[e>>2],d=c.HEAPU32[1+(e>>2)],u=c.HEAPU32[2+(e>>2)],h=c.HEAPU8.subarray(l,l+r),p=c.HEAPU8.subarray(d,d+o),m=c.HEAPU8.subarray(u,u+o),f=new Uint8Array(r+o+o);f.set(h),f.set(p,r),f.set(m,r+o);let _=new VideoFrame(f,{codedWidth:a,codedHeight:s,format:"I420",timestamp:t});i?(null==n||n.drawImage(_,0,0,i.width,i.height),null==n||n.commit()):self.postMessage({type:"yuvData",videoFrame:_},[_])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+r)()(c)}else if("decode"===t.data.type){let{packet:i}=t.data;null==e||e.decode(i.data,"key"==i.type,i.timestamp)}else if("setCodec"===t.data.type){let{codec:i,format:r,description:o}=t.data;null==e||e.setCodec(i,r,null!=o?o:"")}}}yH([CH([OH.INIT,"closed"],"initialized")],MH.prototype,"initialize",1),yH([CH("initialized","configured",{sync:!0})],MH.prototype,"configure",1),yH([function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return(e,i,r)=>{let o=r.value,n=i;r.value=function(){if(!t.includes(this.state.toString()))throw new RH(this.state,"".concat(this.name," ").concat(n," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,i=new Array(e),r=0;r<e;r++)i[r]=arguments[r];return o.apply(this,i)}}}("configured")],MH.prototype,"decode",1),yH([CH([],OH.INIT,{sync:!0})],MH.prototype,"reset",1),yH([CH([],"closed",{ignoreError:!0,sync:!0})],MH.prototype,"close",1);var PH=class extends OH{constructor(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.createModule=e,this.wasmBinary=t,this.workerMode=i,this.canvas=r,this.yuvMode=o,TH(this,"worker"),TH(this,"decoder"),TH(this,"config"),TH(this,"module",{}),TH(this,"width",0),TH(this,"height",0)}initialize(e){return cR(this,null,(function*(){var t;if(this.workerMode){let e=new RegExp("\\{(.+)\\}","s").exec(LH.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));let i=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),r=yield this.wasmBinary;return console.warn("worker mode",r),this.worker.postMessage({type:"init",canvas:i,wasmScript:this.createModule.toString(),wasmBinary:r},i?[i,r]:[r]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){let{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}let i=this.module;return this.wasmBinary&&(i.wasmBinary=yield this.wasmBinary),i.print=e=>console.log(e),i.printErr=e=>console.log("[JS] ERROR: ".concat(e)),i.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{i.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(i,e),this.createModule(i)}))}))}configure(e){var t,i,r;this.config=e;let o=this.config.codec.startsWith("avc")?"avc":"hevc",n=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(i=this.decoder)||i.setCodec(o,n,null!=(t=this.config.description)?t:""),null==(r=this.worker)||r.postMessage({type:"setCodec",codec:o,format:n,description:this.config.description})}decode(e){var t,i;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(i=this.worker)||i.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let i={width:e,height:t};this.emit("videoCodecInfo",i)}yuvData(e,t){if(!this.module)return;let i=this.width*this.height,r=i>>2,o=this.module.HEAPU32[e>>2],n=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+i),c=this.module.HEAPU8.subarray(n,n+r),l=this.module.HEAPU8.subarray(a,a+r);if(this.yuvMode)return void this.emit("videoFrame",{y:s,u:c,v:l,timestamp:t});let d=new Uint8Array(i+r+r);d.set(s),d.set(c,i),d.set(l,i+r),this.emit("videoFrame",new VideoFrame(d,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};yH([CH([OH.INIT,"closed"],"initialized")],PH.prototype,"initialize",1),yH([CH("initialized","configured",{sync:!0})],PH.prototype,"configure",1),yH([CH([],OH.INIT,{sync:!0})],PH.prototype,"reset",1),yH([CH([],"closed",{sync:!0})],PH.prototype,"close",1);var xH=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,r,o=t;o.ready=new Promise(((e,t)=>{i=e,r=t}));var n,a,s,c=Object.assign({},o),l="./this.program",d="object"==typeof window,u="function"==typeof importScripts,h=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(d||u)&&(u?h=self.location.href:"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),e&&(h=e),h=0!==h.indexOf("blob:")?h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):"",n=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},u&&(s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),a=(e,t,i)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):i()},r.onerror=i,r.send(null)});var p,m,f=o.print||console.log.bind(console),_=o.printErr||console.error.bind(console);Object.assign(o,c),c=null,o.arguments&&o.arguments,o.thisProgram&&(l=o.thisProgram),o.quit&&o.quit,o.wasmBinary&&(p=o.wasmBinary),o.noExitRuntime,"object"!=typeof WebAssembly&&V("no native wasm support detected");var g,v,E,y,T,I,A,b,S,w,R,k,C,D=!1,N=[],O=[],M=[],L=0,P=null;function x(e){L++,o.monitorRunDependencies&&o.monitorRunDependencies(L)}function U(e){if(L--,o.monitorRunDependencies&&o.monitorRunDependencies(L),0==L&&P){var t=P;P=null,t()}}function V(e){o.onAbort&&o.onAbort(e),_(e="Aborted("+e+")"),D=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function F(e){return e.startsWith("data:application/octet-stream;base64,")}function B(e){if(e==w&&p)return new Uint8Array(p);if(s)return s(e);throw"both async and sync fetching of the wasm failed"}function H(e,t,i){return(r=e,p||!d&&!u||"function"!=typeof fetch?Promise.resolve().then((()=>B(r))):fetch(r,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+r+"'";return e.arrayBuffer()})).catch((()=>B(r)))).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(i,(e=>{_("failed to asynchronously prepare wasm: "+e),V(e)}));var r}F(w="videodec.wasm")||(R=w,w=o.locateFile?o.locateFile(R,h):h+R);var W=e=>{for(;e.length>0;)e.shift()(o)};function j(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){I[this.ptr+4>>2]=e},this.get_type=function(){return I[this.ptr+4>>2]},this.set_destructor=function(e){I[this.ptr+8>>2]=e},this.get_destructor=function(){return I[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,g[this.ptr+12|0]=e},this.get_caught=function(){return 0!=g[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,g[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=g[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){I[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return I[this.ptr+16>>2]},this.get_exception_ptr=function(){if(wt(this.get_type()))return I[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var G={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var i=0,r=e.length-1;r>=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),i++):i&&(e.splice(r,1),i--)}if(t)for(;i;i--)e.unshift("..");return e},normalize:e=>{var t=G.isAbs(e),i="/"===e.substr(-1);return(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&i&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=G.splitPath(e),i=t[0],r=t[1];return i||r?(r&&(r=r.substr(0,r.length-1)),i+r):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=G.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return G.normalize(e.join("/"))},join2:(e,t)=>G.normalize(e+"/"+t)},z=e=>(z=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);V("initRandomDevice")})())(e),q={resolve:function(){for(var e="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var r=i>=0?arguments[i]:oe.cwd();if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");if(!r)return"";e=r+"/"+e,t=G.isAbs(r)}return(t?"/":"")+(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function i(e){for(var t=0;t<e.length&&""===e[t];t++);for(var i=e.length-1;i>=0&&""===e[i];i--);return t>i?[]:e.slice(t,i-t+1)}e=q.resolve(e).substr(1),t=q.resolve(t).substr(1);for(var r=i(e.split("/")),o=i(t.split("/")),n=Math.min(r.length,o.length),a=n,s=0;s<n;s++)if(r[s]!==o[s]){a=s;break}var c=[];for(s=a;s<r.length;s++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}},K="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,Y=(e,t,i)=>{for(var r=t+i,o=t;e[o]&&!(o>=r);)++o;if(o-t>16&&e.buffer&&K)return K.decode(e.subarray(t,o));for(var n="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var c=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|c:(7&a)<<18|s<<12|c<<6|63&e[t++])<65536)n+=String.fromCharCode(a);else{var l=a-65536;n+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else n+=String.fromCharCode((31&a)<<6|s)}else n+=String.fromCharCode(a)}return n},X=[],J=e=>{for(var t=0,i=0;i<e.length;++i){var r=e.charCodeAt(i);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++i):t+=3}return t},Q=(e,t,i,r)=>{if(!(r>0))return 0;for(var o=i,n=i+r-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(i>=n)break;t[i++]=s}else if(s<=2047){if(i+1>=n)break;t[i++]=192|s>>6,t[i++]=128|63&s}else if(s<=65535){if(i+2>=n)break;t[i++]=224|s>>12,t[i++]=128|s>>6&63,t[i++]=128|63&s}else{if(i+3>=n)break;t[i++]=240|s>>18,t[i++]=128|s>>12&63,t[i++]=128|s>>6&63,t[i++]=128|63&s}}return t[i]=0,i-o};function $(e,t,i){var r=i>0?i:J(e)+1,o=new Array(r),n=Q(e,o,0,o.length);return t&&(o.length=n),o}var Z={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){Z.ttys[e]={input:[],output:[],ops:t},oe.registerDevice(e,Z.stream_ops)},stream_ops:{open:function(e){var t=Z.ttys[e.node.rdev];if(!t)throw new oe.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,i,r,o){if(!e.tty||!e.tty.ops.get_char)throw new oe.ErrnoError(60);for(var n=0,a=0;a<r;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(c){throw new oe.ErrnoError(29)}if(void 0===s&&0===n)throw new oe.ErrnoError(6);if(null==s)break;n++,t[i+a]=s}return n&&(e.node.timestamp=Date.now()),n},write:function(e,t,i,r,o){if(!e.tty||!e.tty.ops.put_char)throw new oe.ErrnoError(60);try{for(var n=0;n<r;n++)e.tty.ops.put_char(e.tty,t[i+n])}catch(a){throw new oe.ErrnoError(29)}return r&&(e.node.timestamp=Date.now()),n}},default_tty_ops:{get_char:function(e){return(()=>{if(!X.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;X=$(e,!0)}return X.shift()})()},put_char:function(e,t){null===t||10===t?(f(Y(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(f(Y(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,i){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(_(Y(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(_(Y(e.output,0)),e.output=[])}}},ee=e=>{V()},te={ops_table:null,mount:e=>te.createNode(null,"/",16895,0),createNode(e,t,i,r){if(oe.isBlkdev(i)||oe.isFIFO(i))throw new oe.ErrnoError(63);te.ops_table||(te.ops_table={dir:{node:{getattr:te.node_ops.getattr,setattr:te.node_ops.setattr,lookup:te.node_ops.lookup,mknod:te.node_ops.mknod,rename:te.node_ops.rename,unlink:te.node_ops.unlink,rmdir:te.node_ops.rmdir,readdir:te.node_ops.readdir,symlink:te.node_ops.symlink},stream:{llseek:te.stream_ops.llseek}},file:{node:{getattr:te.node_ops.getattr,setattr:te.node_ops.setattr},stream:{llseek:te.stream_ops.llseek,read:te.stream_ops.read,write:te.stream_ops.write,allocate:te.stream_ops.allocate,mmap:te.stream_ops.mmap,msync:te.stream_ops.msync}},link:{node:{getattr:te.node_ops.getattr,setattr:te.node_ops.setattr,readlink:te.node_ops.readlink},stream:{}},chrdev:{node:{getattr:te.node_ops.getattr,setattr:te.node_ops.setattr},stream:oe.chrdev_stream_ops}});var o=oe.createNode(e,t,i,r);return oe.isDir(o.mode)?(o.node_ops=te.ops_table.dir.node,o.stream_ops=te.ops_table.dir.stream,o.contents={}):oe.isFile(o.mode)?(o.node_ops=te.ops_table.file.node,o.stream_ops=te.ops_table.file.stream,o.usedBytes=0,o.contents=null):oe.isLink(o.mode)?(o.node_ops=te.ops_table.link.node,o.stream_ops=te.ops_table.link.stream):oe.isChrdev(o.mode)&&(o.node_ops=te.ops_table.chrdev.node,o.stream_ops=te.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var i=e.contents?e.contents.length:0;if(!(i>=t)){t=Math.max(t,i*(i<1048576?2:1.125)>>>0),0!=i&&(t=Math.max(t,256));var r=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(r.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var i=e.contents;e.contents=new Uint8Array(t),i&&e.contents.set(i.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=oe.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,oe.isDir(e.mode)?t.size=4096:oe.isFile(e.mode)?t.size=e.usedBytes:oe.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&te.resizeFileStorage(e,t.size)},lookup(e,t){throw oe.genericErrors[44]},mknod:(e,t,i,r)=>te.createNode(e,t,i,r),rename(e,t,i){if(oe.isDir(e.mode)){var r;try{r=oe.lookupNode(t,i)}catch(n){}if(r)for(var o in r.contents)throw new oe.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=i,t.contents[i]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var i=oe.lookupNode(e,t);for(var r in i.contents)throw new oe.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var i in e.contents)e.contents.hasOwnProperty(i)&&t.push(i);return t},symlink(e,t,i){var r=te.createNode(e,t,41471,0);return r.link=i,r},readlink(e){if(!oe.isLink(e.mode))throw new oe.ErrnoError(28);return e.link}},stream_ops:{read(e,t,i,r,o){var n=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,r);if(a>8&&n.subarray)t.set(n.subarray(o,o+a),i);else for(var s=0;s<a;s++)t[i+s]=n[o+s];return a},write(e,t,i,r,o,n){if(!r)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(n)return a.contents=t.subarray(i,i+r),a.usedBytes=r,r;if(0===a.usedBytes&&0===o)return a.contents=t.slice(i,i+r),a.usedBytes=r,r;if(o+r<=a.usedBytes)return a.contents.set(t.subarray(i,i+r),o),r}if(te.expandFileStorage(a,o+r),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(i,i+r),o);else for(var s=0;s<r;s++)a.contents[o+s]=t[i+s];return a.usedBytes=Math.max(a.usedBytes,o+r),r},llseek(e,t,i){var r=t;if(1===i?r+=e.position:2===i&&oe.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new oe.ErrnoError(28);return r},allocate(e,t,i){te.expandFileStorage(e.node,t+i),e.node.usedBytes=Math.max(e.node.usedBytes,t+i)},mmap(e,t,i,r,o){if(!oe.isFile(e.node.mode))throw new oe.ErrnoError(43);var n,a,s=e.node.contents;if(2&o||s.buffer!==g.buffer){if((i>0||i+t<s.length)&&(s=s.subarray?s.subarray(i,i+t):Array.prototype.slice.call(s,i,i+t)),a=!0,!(n=ee()))throw new oe.ErrnoError(48);g.set(s,n)}else a=!1,n=s.byteOffset;return{ptr:n,allocated:a}},msync:(e,t,i,r,o)=>(te.stream_ops.write(e,t,0,r,i,!1),0)}},ie=o.preloadPlugins||[];function re(e,t){var i=0;return e&&(i|=365),t&&(i|=146),i}var oe={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=q.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new oe.ErrnoError(32);for(var i=e.split("/").filter((e=>!!e)),r=oe.root,o="/",n=0;n<i.length;n++){var a=n===i.length-1;if(a&&t.parent)break;if(r=oe.lookupNode(r,i[n]),o=G.join2(o,i[n]),oe.isMountpoint(r)&&(!a||a&&t.follow_mount)&&(r=r.mounted.root),!a||t.follow)for(var s=0;oe.isLink(r.mode);){var c=oe.readlink(o);if(o=q.resolve(G.dirname(o),c),r=oe.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new oe.ErrnoError(32)}}return{path:o,node:r}},getPath:e=>{for(var t;;){if(oe.isRoot(e)){var i=e.mount.mountpoint;return t?"/"!==i[i.length-1]?"".concat(i,"/").concat(t):i+t:i}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:(e,t)=>{for(var i=0,r=0;r<t.length;r++)i=(i<<5)-i+t.charCodeAt(r)|0;return(e+i>>>0)%oe.nameTable.length},hashAddNode:e=>{var t=oe.hashName(e.parent.id,e.name);e.name_next=oe.nameTable[t],oe.nameTable[t]=e},hashRemoveNode:e=>{var t=oe.hashName(e.parent.id,e.name);if(oe.nameTable[t]===e)oe.nameTable[t]=e.name_next;else for(var i=oe.nameTable[t];i;){if(i.name_next===e){i.name_next=e.name_next;break}i=i.name_next}},lookupNode:(e,t)=>{var i=oe.mayLookup(e);if(i)throw new oe.ErrnoError(i,e);for(var r=oe.hashName(e.id,t),o=oe.nameTable[r];o;o=o.name_next){var n=o.name;if(o.parent.id===e.id&&n===t)return o}return oe.lookup(e,t)},createNode:(e,t,i,r)=>{var o=new oe.FSNode(e,t,i,r);return oe.hashAddNode(o),o},destroyNode:e=>{oe.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>oe.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>oe.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,t)=>{try{return oe.lookupNode(e,t),20}catch(i){}return oe.nodePermissions(e,"wx")},mayDelete:(e,t,i)=>{var r;try{r=oe.lookupNode(e,t)}catch(n){return n.errno}var o=oe.nodePermissions(e,"wx");if(o)return o;if(i){if(!oe.isDir(r.mode))return 54;if(oe.isRoot(r)||oe.getPath(r)===oe.cwd())return 10}else if(oe.isDir(r.mode))return 31;return 0},mayOpen:(e,t)=>e?oe.isLink(e.mode)?32:oe.isDir(e.mode)&&("r"!==oe.flagsToPermissionString(t)||512&t)?31:oe.nodePermissions(e,oe.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=oe.MAX_OPEN_FDS;e++)if(!oe.streams[e])return e;throw new oe.ErrnoError(33)},getStreamChecked:e=>{var t=oe.getStream(e);if(!t)throw new oe.ErrnoError(8);return t},getStream:e=>oe.streams[e],createStream:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return oe.FSStream||(oe.FSStream=function(){this.shared={}},oe.FSStream.prototype={},Object.defineProperties(oe.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new oe.FSStream,e),-1==t&&(t=oe.nextfd()),e.fd=t,oe.streams[t]=e,e},closeStream:e=>{oe.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=oe.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new oe.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{oe.devices[e]={stream_ops:t}},getDevice:e=>oe.devices[e],getMounts:e=>{for(var t=[],i=[e];i.length;){var r=i.pop();t.push(r),i.push.apply(i,r.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),oe.syncFSRequests++,oe.syncFSRequests>1&&_("warning: ".concat(oe.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var i=oe.getMounts(oe.root.mount),r=0;function o(e){return oe.syncFSRequests--,t(e)}function n(e){if(e)return n.errored?void 0:(n.errored=!0,o(e));++r>=i.length&&o(null)}i.forEach((t=>{if(!t.type.syncfs)return n(null);t.type.syncfs(t,e,n)}))},mount:(e,t,i)=>{var r,o="/"===i,n=!i;if(o&&oe.root)throw new oe.ErrnoError(10);if(!o&&!n){var a=oe.lookupPath(i,{follow_mount:!1});if(i=a.path,r=a.node,oe.isMountpoint(r))throw new oe.ErrnoError(10);if(!oe.isDir(r.mode))throw new oe.ErrnoError(54)}var s={type:e,opts:t,mountpoint:i,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,o?oe.root=c:r&&(r.mounted=s,r.mount&&r.mount.mounts.push(s)),c},unmount:e=>{var t=oe.lookupPath(e,{follow_mount:!1});if(!oe.isMountpoint(t.node))throw new oe.ErrnoError(28);var i=t.node,r=i.mounted,o=oe.getMounts(r);Object.keys(oe.nameTable).forEach((e=>{for(var t=oe.nameTable[e];t;){var i=t.name_next;o.includes(t.mount)&&oe.destroyNode(t),t=i}})),i.mounted=null;var n=i.mount.mounts.indexOf(r);i.mount.mounts.splice(n,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,i)=>{var r=oe.lookupPath(e,{parent:!0}).node,o=G.basename(e);if(!o||"."===o||".."===o)throw new oe.ErrnoError(28);var n=oe.mayCreate(r,o);if(n)throw new oe.ErrnoError(n);if(!r.node_ops.mknod)throw new oe.ErrnoError(63);return r.node_ops.mknod(r,o,t,i)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,oe.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,oe.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var i=e.split("/"),r="",o=0;o<i.length;++o)if(i[o]){r+="/"+i[o];try{oe.mkdir(r,t)}catch(n){if(20!=n.errno)throw n}}},mkdev:(e,t,i)=>(void 0===i&&(i=t,t=438),t|=8192,oe.mknod(e,t,i)),symlink:(e,t)=>{if(!q.resolve(e))throw new oe.ErrnoError(44);var i=oe.lookupPath(t,{parent:!0}).node;if(!i)throw new oe.ErrnoError(44);var r=G.basename(t),o=oe.mayCreate(i,r);if(o)throw new oe.ErrnoError(o);if(!i.node_ops.symlink)throw new oe.ErrnoError(63);return i.node_ops.symlink(i,r,e)},rename:(e,t)=>{var i,r,o=G.dirname(e),n=G.dirname(t),a=G.basename(e),s=G.basename(t);if(i=oe.lookupPath(e,{parent:!0}).node,r=oe.lookupPath(t,{parent:!0}).node,!i||!r)throw new oe.ErrnoError(44);if(i.mount!==r.mount)throw new oe.ErrnoError(75);var c,l=oe.lookupNode(i,a),d=q.relative(e,n);if("."!==d.charAt(0))throw new oe.ErrnoError(28);if("."!==(d=q.relative(t,o)).charAt(0))throw new oe.ErrnoError(55);try{c=oe.lookupNode(r,s)}catch(p){}if(l!==c){var u=oe.isDir(l.mode),h=oe.mayDelete(i,a,u);if(h)throw new oe.ErrnoError(h);if(h=c?oe.mayDelete(r,s,u):oe.mayCreate(r,s))throw new oe.ErrnoError(h);if(!i.node_ops.rename)throw new oe.ErrnoError(63);if(oe.isMountpoint(l)||c&&oe.isMountpoint(c))throw new oe.ErrnoError(10);if(r!==i&&(h=oe.nodePermissions(i,"w")))throw new oe.ErrnoError(h);oe.hashRemoveNode(l);try{i.node_ops.rename(l,r,s)}catch(p){throw p}finally{oe.hashAddNode(l)}}},rmdir:e=>{var t=oe.lookupPath(e,{parent:!0}).node,i=G.basename(e),r=oe.lookupNode(t,i),o=oe.mayDelete(t,i,!0);if(o)throw new oe.ErrnoError(o);if(!t.node_ops.rmdir)throw new oe.ErrnoError(63);if(oe.isMountpoint(r))throw new oe.ErrnoError(10);t.node_ops.rmdir(t,i),oe.destroyNode(r)},readdir:e=>{var t=oe.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new oe.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=oe.lookupPath(e,{parent:!0}).node;if(!t)throw new oe.ErrnoError(44);var i=G.basename(e),r=oe.lookupNode(t,i),o=oe.mayDelete(t,i,!1);if(o)throw new oe.ErrnoError(o);if(!t.node_ops.unlink)throw new oe.ErrnoError(63);if(oe.isMountpoint(r))throw new oe.ErrnoError(10);t.node_ops.unlink(t,i),oe.destroyNode(r)},readlink:e=>{var t=oe.lookupPath(e).node;if(!t)throw new oe.ErrnoError(44);if(!t.node_ops.readlink)throw new oe.ErrnoError(28);return q.resolve(oe.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var i=oe.lookupPath(e,{follow:!t}).node;if(!i)throw new oe.ErrnoError(44);if(!i.node_ops.getattr)throw new oe.ErrnoError(63);return i.node_ops.getattr(i)},lstat:e=>oe.stat(e,!0),chmod:(e,t,i)=>{var r;if(!(r="string"==typeof e?oe.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new oe.ErrnoError(63);r.node_ops.setattr(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})},lchmod:(e,t)=>{oe.chmod(e,t,!0)},fchmod:(e,t)=>{var i=oe.getStreamChecked(e);oe.chmod(i.node,t)},chown:(e,t,i,r)=>{var o;if(!(o="string"==typeof e?oe.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new oe.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,i)=>{oe.chown(e,t,i,!0)},fchown:(e,t,i)=>{var r=oe.getStreamChecked(e);oe.chown(r.node,t,i)},truncate:(e,t)=>{if(t<0)throw new oe.ErrnoError(28);var i;if(!(i="string"==typeof e?oe.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new oe.ErrnoError(63);if(oe.isDir(i.mode))throw new oe.ErrnoError(31);if(!oe.isFile(i.mode))throw new oe.ErrnoError(28);var r=oe.nodePermissions(i,"w");if(r)throw new oe.ErrnoError(r);i.node_ops.setattr(i,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var i=oe.getStreamChecked(e);if(!(2097155&i.flags))throw new oe.ErrnoError(28);oe.truncate(i.node,t)},utime:(e,t,i)=>{var r=oe.lookupPath(e,{follow:!0}).node;r.node_ops.setattr(r,{timestamp:Math.max(t,i)})},open:(e,t,i)=>{if(""===e)throw new oe.ErrnoError(44);var r;if(i=void 0===i?438:i,i=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error("Unknown file open mode: ".concat(e));return t}(t):t)?4095&i|32768:0,"object"==typeof e)r=e;else{e=G.normalize(e);try{r=oe.lookupPath(e,{follow:!(131072&t)}).node}catch(c){}}var n=!1;if(64&t)if(r){if(128&t)throw new oe.ErrnoError(20)}else r=oe.mknod(e,i,0),n=!0;if(!r)throw new oe.ErrnoError(44);if(oe.isChrdev(r.mode)&&(t&=-513),65536&t&&!oe.isDir(r.mode))throw new oe.ErrnoError(54);if(!n){var a=oe.mayOpen(r,t);if(a)throw new oe.ErrnoError(a)}512&t&&!n&&oe.truncate(r,0),t&=-131713;var s=oe.createStream({node:r,path:oe.getPath(r),flags:t,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!o.logReadFiles||1&t||(oe.readFiles||(oe.readFiles={}),e in oe.readFiles||(oe.readFiles[e]=1)),s},close:e=>{if(oe.isClosed(e))throw new oe.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{oe.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,i)=>{if(oe.isClosed(e))throw new oe.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new oe.ErrnoError(70);if(0!=i&&1!=i&&2!=i)throw new oe.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,i),e.ungotten=[],e.position},read:(e,t,i,r,o)=>{if(r<0||o<0)throw new oe.ErrnoError(28);if(oe.isClosed(e))throw new oe.ErrnoError(8);if(1==(2097155&e.flags))throw new oe.ErrnoError(8);if(oe.isDir(e.node.mode))throw new oe.ErrnoError(31);if(!e.stream_ops.read)throw new oe.ErrnoError(28);var n=void 0!==o;if(n){if(!e.seekable)throw new oe.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,i,r,o);return n||(e.position+=a),a},write:(e,t,i,r,o,n)=>{if(r<0||o<0)throw new oe.ErrnoError(28);if(oe.isClosed(e))throw new oe.ErrnoError(8);if(!(2097155&e.flags))throw new oe.ErrnoError(8);if(oe.isDir(e.node.mode))throw new oe.ErrnoError(31);if(!e.stream_ops.write)throw new oe.ErrnoError(28);e.seekable&&1024&e.flags&&oe.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new oe.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,i,r,o,n);return a||(e.position+=s),s},allocate:(e,t,i)=>{if(oe.isClosed(e))throw new oe.ErrnoError(8);if(t<0||i<=0)throw new oe.ErrnoError(28);if(!(2097155&e.flags))throw new oe.ErrnoError(8);if(!oe.isFile(e.node.mode)&&!oe.isDir(e.node.mode))throw new oe.ErrnoError(43);if(!e.stream_ops.allocate)throw new oe.ErrnoError(138);e.stream_ops.allocate(e,t,i)},mmap:(e,t,i,r,o)=>{if(2&r&&!(2&o)&&2!=(2097155&e.flags))throw new oe.ErrnoError(2);if(1==(2097155&e.flags))throw new oe.ErrnoError(2);if(!e.stream_ops.mmap)throw new oe.ErrnoError(43);return e.stream_ops.mmap(e,t,i,r,o)},msync:(e,t,i,r,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,i,r,o):0,munmap:e=>0,ioctl:(e,t,i)=>{if(!e.stream_ops.ioctl)throw new oe.ErrnoError(59);return e.stream_ops.ioctl(e,t,i)},readFile:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'.concat(t.encoding,'"'));var i,r=oe.open(e,t.flags),o=oe.stat(e).size,n=new Uint8Array(o);return oe.read(r,n,0,o,0),"utf8"===t.encoding?i=Y(n,0):"binary"===t.encoding&&(i=n),oe.close(r),i},writeFile:function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i.flags=i.flags||577;var r=oe.open(e,i.flags,i.mode);if("string"==typeof t){var o=new Uint8Array(J(t)+1),n=Q(t,o,0,o.length);oe.write(r,o,0,n,void 0,i.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");oe.write(r,t,0,t.byteLength,void 0,i.canOwn)}oe.close(r)},cwd:()=>oe.currentPath,chdir:e=>{var t=oe.lookupPath(e,{follow:!0});if(null===t.node)throw new oe.ErrnoError(44);if(!oe.isDir(t.node.mode))throw new oe.ErrnoError(54);var i=oe.nodePermissions(t.node,"x");if(i)throw new oe.ErrnoError(i);oe.currentPath=t.path},createDefaultDirectories:()=>{oe.mkdir("/tmp"),oe.mkdir("/home"),oe.mkdir("/home/web_user")},createDefaultDevices:()=>{oe.mkdir("/dev"),oe.registerDevice(oe.makedev(1,3),{read:()=>0,write:(e,t,i,r,o)=>r}),oe.mkdev("/dev/null",oe.makedev(1,3)),Z.register(oe.makedev(5,0),Z.default_tty_ops),Z.register(oe.makedev(6,0),Z.default_tty1_ops),oe.mkdev("/dev/tty",oe.makedev(5,0)),oe.mkdev("/dev/tty1",oe.makedev(6,0));var e=new Uint8Array(1024),t=0,i=()=>(0===t&&(t=z(e).byteLength),e[--t]);oe.createDevice("/dev","random",i),oe.createDevice("/dev","urandom",i),oe.mkdir("/dev/shm"),oe.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{oe.mkdir("/proc");var e=oe.mkdir("/proc/self");oe.mkdir("/proc/self/fd"),oe.mount({mount:()=>{var t=oe.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var i=+t,r=oe.getStreamChecked(i),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{o.stdin?oe.createDevice("/dev","stdin",o.stdin):oe.symlink("/dev/tty","/dev/stdin"),o.stdout?oe.createDevice("/dev","stdout",null,o.stdout):oe.symlink("/dev/tty","/dev/stdout"),o.stderr?oe.createDevice("/dev","stderr",null,o.stderr):oe.symlink("/dev/tty1","/dev/stderr"),oe.open("/dev/stdin",0),oe.open("/dev/stdout",1),oe.open("/dev/stderr",1)},ensureErrnoError:()=>{oe.ErrnoError||(oe.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},oe.ErrnoError.prototype=new Error,oe.ErrnoError.prototype.constructor=oe.ErrnoError,[44].forEach((e=>{oe.genericErrors[e]=new oe.ErrnoError(e),oe.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{oe.ensureErrnoError(),oe.nameTable=new Array(4096),oe.mount(te,{},"/"),oe.createDefaultDirectories(),oe.createDefaultDevices(),oe.createSpecialDirectories(),oe.filesystems={MEMFS:te}},init:(e,t,i)=>{oe.init.initialized=!0,oe.ensureErrnoError(),o.stdin=e||o.stdin,o.stdout=t||o.stdout,o.stderr=i||o.stderr,oe.createStandardStreams()},quit:()=>{oe.init.initialized=!1;for(var e=0;e<oe.streams.length;e++){var t=oe.streams[e];t&&oe.close(t)}},findObject:(e,t)=>{var i=oe.analyzePath(e,t);return i.exists?i.object:null},analyzePath:(e,t)=>{try{e=(r=oe.lookupPath(e,{follow:!t})).path}catch(o){}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var r=oe.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=r.path,i.parentObject=r.node,i.name=G.basename(e),r=oe.lookupPath(e,{follow:!t}),i.exists=!0,i.path=r.path,i.object=r.node,i.name=r.node.name,i.isRoot="/"===r.path}catch(o){i.error=o.errno}return i},createPath:(e,t,i,r)=>{e="string"==typeof e?e:oe.getPath(e);for(var o=t.split("/").reverse();o.length;){var n=o.pop();if(n){var a=G.join2(e,n);try{oe.mkdir(a)}catch(s){}e=a}}return a},createFile:(e,t,i,r,o)=>{var n=G.join2("string"==typeof e?e:oe.getPath(e),t),a=re(r,o);return oe.create(n,a)},createDataFile:(e,t,i,r,o,n)=>{var a=t;e&&(e="string"==typeof e?e:oe.getPath(e),a=t?G.join2(e,t):e);var s=re(r,o),c=oe.create(a,s);if(i){if("string"==typeof i){for(var l=new Array(i.length),d=0,u=i.length;d<u;++d)l[d]=i.charCodeAt(d);i=l}oe.chmod(c,146|s);var h=oe.open(c,577);oe.write(h,i,0,i.length,0,n),oe.close(h),oe.chmod(c,s)}return c},createDevice:(e,t,i,r)=>{var o=G.join2("string"==typeof e?e:oe.getPath(e),t),n=re(!!i,!!r);oe.createDevice.major||(oe.createDevice.major=64);var a=oe.makedev(oe.createDevice.major++,0);return oe.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{r&&r.buffer&&r.buffer.length&&r(10)},read:(e,t,r,o,n)=>{for(var a=0,s=0;s<o;s++){var c;try{c=i()}catch(l){throw new oe.ErrnoError(29)}if(void 0===c&&0===a)throw new oe.ErrnoError(6);if(null==c)break;a++,t[r+s]=c}return a&&(e.node.timestamp=Date.now()),a},write:(e,t,i,o,n)=>{for(var a=0;a<o;a++)try{r(t[i+a])}catch(s){throw new oe.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),oe.mkdev(o,n,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!n)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=$(n(e.url),!0),e.usedBytes=e.contents.length}catch(t){throw new oe.ErrnoError(29)}},createLazyFile:(e,t,i,r,o)=>{function n(){this.lengthKnown=!1,this.chunks=[]}if(n.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,i=e/this.chunkSize|0;return this.getter(i)[t]}},n.prototype.setDataGetter=function(e){this.getter=e},n.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",i,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+i+". Status: "+e.status);var t,r=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,n=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,a=1048576;o||(a=r);var s=this;s.setDataGetter((e=>{var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,r-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>r-1)throw new Error("only "+r+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",i,!1),r!==a&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+i+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):$(o.responseText||"",!0)})(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!n&&r||(a=r=1,r=this.getter(0).length,a=r,f("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=r,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!u)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new n;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:i};var c=oe.createFile(e,t,s,r,o);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};function d(e,t,i,r,o){var n=e.node.contents;if(o>=n.length)return 0;var a=Math.min(n.length-o,r);if(n.slice)for(var s=0;s<a;s++)t[i+s]=n[o+s];else for(s=0;s<a;s++)t[i+s]=n.get(o+s);return a}return Object.keys(c.stream_ops).forEach((e=>{var t=c.stream_ops[e];l[e]=function(){return oe.forceLoadFile(c),t.apply(null,arguments)}})),l.read=(e,t,i,r,o)=>(oe.forceLoadFile(c),d(e,t,i,r,o)),l.mmap=(e,t,i,r,o)=>{oe.forceLoadFile(c);var n=ee();if(!n)throw new oe.ErrnoError(48);return d(e,g,n,t,i),{ptr:n,allocated:!0}},c.stream_ops=l,c}},ne=(e,t)=>e?Y(v,e,t):"",ae={DEFAULT_POLLMASK:5,calculateAt:function(e,t,i){if(G.isAbs(t))return t;var r;if(r=-100===e?oe.cwd():ae.getStreamFromFD(e).path,0==t.length){if(!i)throw new oe.ErrnoError(44);return r}return G.join2(r,t)},doStat:function(e,t,i){try{var r=e(t)}catch(s){if(s&&s.node&&G.normalize(t)!==G.normalize(oe.getPath(s.node)))return-54;throw s}T[i>>2]=r.dev,T[i+4>>2]=r.mode,I[i+8>>2]=r.nlink,T[i+12>>2]=r.uid,T[i+16>>2]=r.gid,T[i+20>>2]=r.rdev,C=[r.size>>>0,(k=r.size,+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[i+24>>2]=C[0],T[i+28>>2]=C[1],T[i+32>>2]=4096,T[i+36>>2]=r.blocks;var o=r.atime.getTime(),n=r.mtime.getTime(),a=r.ctime.getTime();return C=[Math.floor(o/1e3)>>>0,(k=Math.floor(o/1e3),+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[i+40>>2]=C[0],T[i+44>>2]=C[1],I[i+48>>2]=o%1e3*1e3,C=[Math.floor(n/1e3)>>>0,(k=Math.floor(n/1e3),+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[i+56>>2]=C[0],T[i+60>>2]=C[1],I[i+64>>2]=n%1e3*1e3,C=[Math.floor(a/1e3)>>>0,(k=Math.floor(a/1e3),+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[i+72>>2]=C[0],T[i+76>>2]=C[1],I[i+80>>2]=a%1e3*1e3,C=[r.ino>>>0,(k=r.ino,+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[i+88>>2]=C[0],T[i+92>>2]=C[1],0},doMsync:function(e,t,i,r,o){if(!oe.isFile(t.node.mode))throw new oe.ErrnoError(43);if(2&r)return 0;var n=v.slice(e,e+i);oe.msync(t,n,o,i,r)},varargs:void 0,get:()=>(ae.varargs+=4,T[ae.varargs-4>>2]),getStr:e=>ne(e),getStreamFromFD:function(e){return oe.getStreamChecked(e)}};function se(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: ".concat(e))}}var ce=void 0;function le(e){for(var t="",i=e;v[i];)t+=ce[v[i++]];return t}var de={},ue={},he={},pe=void 0;function me(e){throw new pe(e)}var fe=void 0;function _e(e){throw new fe(e)}function ge(e,t,i){function r(t){var r=i(t);r.length!==e.length&&_e("Mismatched type converter count");for(var o=0;o<e.length;++o)ve(e[o],r[o])}e.forEach((function(e){he[e]=t}));var o=new Array(t.length),n=[],a=0;t.forEach(((e,t)=>{ue.hasOwnProperty(e)?o[t]=ue[e]:(n.push(e),de.hasOwnProperty(e)||(de[e]=[]),de[e].push((()=>{o[t]=ue[e],++a===n.length&&r(o)})))})),0===n.length&&r(o)}function ve(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var r=t.name;if(e||me('type "'.concat(r,'" must have a positive integer typeid pointer')),ue.hasOwnProperty(e)){if(i.ignoreDuplicateRegistrations)return;me("Cannot register type '".concat(r,"' twice"))}if(ue[e]=t,delete he[e],de.hasOwnProperty(e)){var o=de[e];delete de[e],o.forEach((e=>e()))}}(e,t,i)}function Ee(e){me(e.$$.ptrType.registeredClass.name+" instance already deleted")}var ye=!1;function Te(e){}function Ie(e){var t;e.count.value-=1,0===e.count.value&&((t=e).smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr))}function Ae(e,t,i){if(t===i)return e;if(void 0===i.baseClass)return null;var r=Ae(e,t,i.baseClass);return null===r?null:i.downcast(r)}var be={};var Se=[];function we(){for(;Se.length;){var e=Se.pop();e.$$.deleteScheduled=!1,e.delete()}}var Re=void 0;var ke={};function Ce(e,t){return t.ptrType&&t.ptr||_e("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&_e("Both smartPtrType and smartPtr must be specified"),t.count={value:1},De(Object.create(e,{$$:{value:t}}))}var De=function(e){return"undefined"==typeof FinalizationRegistry?(De=e=>e,e):(ye=new FinalizationRegistry((e=>{Ie(e.$$)})),Te=e=>ye.unregister(e),(De=e=>{var t=e.$$;if(t.smartPtr){var i={$$:t};ye.register(e,i,e)}return e})(e))};function Ne(){}function Oe(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function Me(e,t){return e=Oe(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Le(e,t,i){if(void 0===e[t].overloadTable){var r=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||me("Function '".concat(i,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[r.argCount]=r}}function Pe(e,t,i,r,o,n,a,s){this.name=e,this.constructor=t,this.instancePrototype=i,this.rawDestructor=r,this.baseClass=o,this.getActualType=n,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function xe(e,t,i){for(;t!==i;)t.upcast||me("Expected null or instance of ".concat(i.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function Ue(e,t){if(null===t)return this.isReference&&me("null is not a valid ".concat(this.name)),0;t.$$||me('Cannot pass "'.concat(it(t),'" as a ').concat(this.name)),t.$$.ptr||me("Cannot pass deleted object as a pointer of type ".concat(this.name));var i=t.$$.ptrType.registeredClass;return xe(t.$$.ptr,i,this.registeredClass)}function Ve(e,t){var i;if(null===t)return this.isReference&&me("null is not a valid ".concat(this.name)),this.isSmartPointer?(i=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,i),i):0;t.$$||me('Cannot pass "'.concat(it(t),'" as a ').concat(this.name)),t.$$.ptr||me("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&me("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;if(i=xe(t.$$.ptr,r,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&me("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?i=t.$$.smartPtr:me("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:i=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)i=t.$$.smartPtr;else{var o=t.clone();i=this.rawShare(i,tt.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,i)}break;default:me("Unsupporting sharing policy")}return i}function Fe(e,t){if(null===t)return this.isReference&&me("null is not a valid ".concat(this.name)),0;t.$$||me('Cannot pass "'.concat(it(t),'" as a ').concat(this.name)),t.$$.ptr||me("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&me("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var i=t.$$.ptrType.registeredClass;return xe(t.$$.ptr,i,this.registeredClass)}function Be(e){return this.fromWireType(T[e>>2])}function He(e,t,i,r,o,n,a,s,c,l,d){this.name=e,this.registeredClass=t,this.isReference=i,this.isConst=r,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=d,o||void 0!==t.baseClass?this.toWireType=Ve:r?(this.toWireType=Ue,this.destructorFunction=null):(this.toWireType=Fe,this.destructorFunction=null)}var We=[],je=e=>{var t=We[e];return t||(e>=We.length&&(We.length=e+1),We[e]=t=S.get(e)),t};function Ge(e,t){var i,r,n,a=(e=le(e)).includes("j")?(i=e,r=t,n=[],function(){return n.length=0,Object.assign(n,arguments),((e,t,i)=>{return e.includes("j")?(r=t,n=i,a=o["dynCall_"+e],n&&n.length?a.apply(null,[r].concat(n)):a.call(null,r)):je(t).apply(null,i);var r,n,a})(i,r,n)}):je(t);return"function"!=typeof a&&me("unknown function pointer with signature ".concat(e,": ").concat(t)),a}var ze=void 0;function qe(e){var t=St(e),i=le(t);return At(t),i}function Ke(e,t){var i=[],r={};throw t.forEach((function e(t){r[t]||ue[t]||(he[t]?he[t].forEach(e):(i.push(t),r[t]=!0))})),new ze("".concat(e,": ")+i.map(qe).join([", "]))}function Ye(e,t){for(var i=[],r=0;r<e;r++)i.push(I[t+4*r>>2]);return i}function Xe(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Je(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var i=Me(e.name||"unknownFunctionName",(function(){}));i.prototype=e.prototype;var r=new i,o=e.apply(r,t);return o instanceof Object?o:r}function Qe(e,t,i,r,o,n){var a=t.length;a<2&&me("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==t[1]&&null!==i,c=!1,l=1;l<t.length;++l)if(null!==t[l]&&void 0===t[l].destructorFunction){c=!0;break}var d="void"!==t[0].name,u="",h="";for(l=0;l<a-2;++l)u+=(0!==l?", ":"")+"arg"+l,h+=(0!==l?", ":"")+"arg"+l+"Wired";var p="\n return function ".concat(Oe(e),"(").concat(u,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");c&&(p+="var destructors = [];\n");var m=c?"destructors":"null",f=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[me,r,o,Xe,t[0],t[1]];for(s&&(p+="var thisWired = classParam.toWireType("+m+", this);\n"),l=0;l<a-2;++l)p+="var arg"+l+"Wired = argType"+l+".toWireType("+m+", arg"+l+"); // "+t[l+2].name+"\n",f.push("argType"+l),_.push(t[l+2]);if(s&&(h="thisWired"+(h.length>0?", ":"")+h),p+=(d||n?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",c)p+="runDestructors(destructors);\n";else for(l=s?1:2;l<t.length;++l){var g=1===l?"thisWired":"arg"+(l-2)+"Wired";null!==t[l].destructorFunction&&(p+=g+"_dtor("+g+"); // "+t[l].name+"\n",f.push(g+"_dtor"),_.push(t[l].destructorFunction))}return d&&(p+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),p+="}\n",f.push(p),Je(Function,f).apply(null,_)}function $e(){this.allocated=[void 0],this.freelist=[]}var Ze=new $e;function et(e){e>=Ze.reserved&&0==--Ze.get(e).refcount&&Ze.free(e)}var tt={toValue:e=>(e||me("Cannot use deleted val. handle = "+e),Ze.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Ze.allocate({refcount:1,value:e})}}};function it(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function rt(e,t){switch(t){case 2:return function(e){return this.fromWireType(A[e>>2])};case 3:return function(e){return this.fromWireType(b[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function ot(e,t,i){switch(t){case 0:return i?function(e){return g[e]}:function(e){return v[e]};case 1:return i?function(e){return E[e>>1]}:function(e){return y[e>>1]};case 2:return i?function(e){return T[e>>2]}:function(e){return I[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var nt,at,st="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,ct=(e,t)=>{for(var i=e,r=i>>1,o=r+t/2;!(r>=o)&&y[r];)++r;if((i=r<<1)-e>32&&st)return st.decode(v.subarray(e,i));for(var n="",a=0;!(a>=t/2);++a){var s=E[e+2*a>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},lt=(e,t,i)=>{if(void 0===i&&(i=2147483647),i<2)return 0;for(var r=t,o=(i-=2)<2*e.length?i/2:e.length,n=0;n<o;++n){var a=e.charCodeAt(n);E[t>>1]=a,t+=2}return E[t>>1]=0,t-r},dt=e=>2*e.length,ut=(e,t)=>{for(var i=0,r="";!(i>=t/4);){var o=T[e+4*i>>2];if(0==o)break;if(++i,o>=65536){var n=o-65536;r+=String.fromCharCode(55296|n>>10,56320|1023&n)}else r+=String.fromCharCode(o)}return r},ht=(e,t,i)=>{if(void 0===i&&(i=2147483647),i<4)return 0;for(var r=t,o=r+i-4,n=0;n<e.length;++n){var a=e.charCodeAt(n);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++n)),T[t>>2]=a,(t+=4)+4>o)break}return T[t>>2]=0,t-r},pt=e=>{for(var t=0,i=0;i<e.length;++i){var r=e.charCodeAt(i);r>=55296&&r<=57343&&++i,t+=4}return t},mt={},ft=[],_t=[],gt={},vt=()=>{if(!vt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(var t in gt)void 0===gt[t]?delete e[t]:e[t]=gt[t];var i=[];for(var t in e)i.push("".concat(t,"=").concat(e[t]));vt.strings=i}return vt.strings},Et=function(e,t,i,r){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=oe.nextInode++,this.name=t,this.mode=i,this.node_ops={},this.stream_ops={},this.rdev=r};Object.defineProperties(Et.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return oe.isDir(this.mode)}},isDevice:{get:function(){return oe.isChrdev(this.mode)}}}),oe.FSNode=Et,oe.createPreloadedFile=function(e,t,i,r,o,n,s,c,l,d){var u=t?q.resolve(G.join2(e,t)):e;function h(i){function a(i){d&&d(),c||oe.createDataFile(e,t,i,r,o,l),n&&n(),U()}(function(e,t,i,r){"undefined"!=typeof Browser&&Browser.init();var o=!1;return ie.forEach((function(n){o||n.canHandle(t)&&(n.handle(e,t,i,r),o=!0)})),o})(i,u,a,(()=>{s&&s(),U()}))||a(i)}x(),"string"==typeof i?((e,t,i,r)=>{var o=r?"":"al ".concat(e);a(e,(i=>{var r;r='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),i||V(r),t(new Uint8Array(i)),o&&U()}),(t=>{if(!i)throw'Loading data file "'.concat(e,'" failed.');i()})),o&&x()})(i,(e=>h(e)),s):h(i)},oe.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);ce=e}(),pe=o.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},fe=o.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Ne.prototype.isAliasOf=function(e){if(!(this instanceof Ne&&e instanceof Ne))return!1;for(var t=this.$$.ptrType.registeredClass,i=this.$$.ptr,r=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)i=t.upcast(i),t=t.baseClass;for(;r.baseClass;)o=r.upcast(o),r=r.baseClass;return t===r&&i===o},Ne.prototype.clone=function(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=De(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},Ne.prototype.delete=function(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&me("Object already scheduled for deletion"),Te(this),Ie(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},Ne.prototype.isDeleted=function(){return!this.$$.ptr},Ne.prototype.deleteLater=function(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&me("Object already scheduled for deletion"),Se.push(this),1===Se.length&&Re&&Re(we),this.$$.deleteScheduled=!0,this},o.getInheritedInstanceCount=function(){return Object.keys(ke).length},o.getLiveInheritedInstances=function(){var e=[];for(var t in ke)ke.hasOwnProperty(t)&&e.push(ke[t]);return e},o.flushPendingDeletes=we,o.setDelayFunction=function(e){Re=e,Se.length&&Re&&Re(we)},He.prototype.getPointee=function(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},He.prototype.destructor=function(e){this.rawDestructor&&this.rawDestructor(e)},He.prototype.argPackAdvance=8,He.prototype.readValueFromPointer=Be,He.prototype.deleteObject=function(e){null!==e&&e.delete()},He.prototype.fromWireType=function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var i=function(e,t){return t=function(e,t){for(void 0===t&&me("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),ke[t]}(this.registeredClass,t);if(void 0!==i){if(0===i.$$.count.value)return i.$$.ptr=t,i.$$.smartPtr=e,i.clone();var r=i.clone();return this.destructor(e),r}function o(){return this.isSmartPointer?Ce(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Ce(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var n,a=this.registeredClass.getActualType(t),s=be[a];if(!s)return o.call(this);n=this.isConst?s.constPointerType:s.pointerType;var c=Ae(t,this.registeredClass,n.registeredClass);return null===c?o.call(this):this.isSmartPointer?Ce(n.registeredClass.instancePrototype,{ptrType:n,ptr:c,smartPtrType:this,smartPtr:e}):Ce(n.registeredClass.instancePrototype,{ptrType:n,ptr:c})},ze=o.UnboundTypeError=(nt=Error,(at=Me("UnboundTypeError",(function(e){this.name="UnboundTypeError",this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(nt.prototype),at.prototype.constructor=at,at.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},at),Object.assign($e.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Ze.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Ze.reserved=Ze.allocated.length,o.count_emval_handles=function(){for(var e=0,t=Ze.reserved;t<Ze.allocated.length;++t)void 0!==Ze.allocated[t]&&++e;return e};var yt,Tt={p:function(e,t,i){throw new j(e).init(t,i),e},C:function(e,t,i){ae.varargs=i;try{var r=ae.getStreamFromFD(e);switch(t){case 0:return(o=ae.get())<0?-28:oe.createStream(r,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return r.flags;case 4:var o=ae.get();return r.flags|=o,0;case 5:return o=ae.get(),E[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return T[bt()>>2]=28,-1}}catch(n){if(void 0===oe||"ErrnoError"!==n.name)throw n;return-n.errno}},w:function(e,t,i,r){ae.varargs=r;try{t=ae.getStr(t),t=ae.calculateAt(e,t);var o=r?ae.get():0;return oe.open(t,i,o).fd}catch(n){if(void 0===oe||"ErrnoError"!==n.name)throw n;return-n.errno}},t:function(e,t,i,r,o){},n:function(e,t,i,r,o){var n=se(i);ve(e,{name:t=le(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:o},argPackAdvance:8,readValueFromPointer:function(e){var r;if(1===i)r=g;else if(2===i)r=E;else{if(4!==i)throw new TypeError("Unknown boolean type size: "+t);r=T}return this.fromWireType(r[e>>n])},destructorFunction:null})},r:function(e,t,i,r,n,a,s,c,l,d,u,h,p){u=le(u),a=Ge(n,a),c&&(c=Ge(s,c)),d&&(d=Ge(l,d)),p=Ge(h,p);var m,f,_,g=Oe(u);m=g,f=function(){Ke("Cannot construct ".concat(u," due to unbound types"),[r])},o.hasOwnProperty(m)?(me("Cannot register public name '".concat(m,"' twice")),Le(o,m,m),o.hasOwnProperty(_)&&me("Cannot register multiple overloads of a function with the same number of arguments (".concat(_,")!")),o[m].overloadTable[_]=f):o[m]=f,ge([e,t,i],r?[r]:[],(function(t){var i,n;t=t[0],n=r?(i=t.registeredClass).instancePrototype:Ne.prototype;var s=Me(g,(function(){if(Object.getPrototypeOf(this)!==l)throw new pe("Use 'new' to construct "+u);if(void 0===h.constructor_body)throw new pe(u+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new pe("Tried to invoke ctor of ".concat(u," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(h.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:s}});s.prototype=l;var h=new Pe(u,s,l,p,i,a,c,d);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m,f,_,v=new He(u,h,!0,!1,!1),E=new He(u+"*",h,!1,!1,!1),y=new He(u+" const*",h,!1,!0,!1);return be[e]={pointerType:E,constPointerType:y},m=g,f=s,o.hasOwnProperty(m)||_e("Replacing nonexistant public symbol"),o[m].overloadTable,o[m]=f,o[m].argCount=_,[v,E,y]}))},q:function(e,t,i,r,o,n){var a=Ye(t,i);o=Ge(r,o),ge([],[e],(function(e){var i="constructor ".concat((e=e[0]).name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new pe("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=()=>{Ke("Cannot construct ".concat(e.name," due to unbound types"),a)},ge([],a,(function(r){return r.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Qe(i,r,null,o,n),[]})),[]}))},d:function(e,t,i,r,o,n,a,s,c){var l=Ye(i,r);t=le(t),n=Ge(o,n),ge([],[e],(function(e){var r="".concat((e=e[0]).name,".").concat(t);function o(){Ke("Cannot call ".concat(r," due to unbound types"),l)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var d=e.registeredClass.instancePrototype,u=d[t];return void 0===u||void 0===u.overloadTable&&u.className!==e.name&&u.argCount===i-2?(o.argCount=i-2,o.className=e.name,d[t]=o):(Le(d,t,r),d[t].overloadTable[i-2]=o),ge([],l,(function(o){var s=Qe(r,o,e,n,a,c);return void 0===d[t].overloadTable?(s.argCount=i-2,d[t]=s):d[t].overloadTable[i-2]=s,[]})),[]}))},D:function(e,t){ve(e,{name:t=le(t),fromWireType:function(e){var t=tt.toValue(e);return et(e),t},toWireType:function(e,t){return tt.toHandle(t)},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:null})},k:function(e,t,i){var r=se(i);ve(e,{name:t=le(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:rt(t,r),destructorFunction:null})},c:function(e,t,i,r,o){t=le(t);var n=se(i),a=e=>e;if(0===r){var s=32-8*i;a=e=>e<<s>>>s}var c=t.includes("unsigned");ve(e,{name:t,fromWireType:a,toWireType:c?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:ot(t,n,0!==r),destructorFunction:null})},b:function(e,t,i){var r=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=I,i=t[e>>=2],o=t[e+1];return new r(t.buffer,o,i)}ve(e,{name:i=le(i),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var i="std::string"===(t=le(t));ve(e,{name:t,fromWireType:function(e){var t,r=I[e>>2],o=e+4;if(i)for(var n=o,a=0;a<=r;++a){var s=o+a;if(a==r||0==v[s]){var c=ne(n,s-n);void 0===t?t=c:(t+="\0",t+=c),n=s+1}}else{var l=new Array(r);for(a=0;a<r;++a)l[a]=String.fromCharCode(v[o+a]);t=l.join("")}return At(e),t},toWireType:function(e,t){var r;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||me("Cannot pass non-string to std::string"),r=i&&o?J(t):t.length;var n=It(4+r+1),a=n+4;if(I[n>>2]=r,i&&o)Q(t,v,a,r+1);else if(o)for(var s=0;s<r;++s){var c=t.charCodeAt(s);c>255&&(At(a),me("String has UTF-16 code units that do not fit in 8 bits")),v[a+s]=c}else for(s=0;s<r;++s)v[a+s]=t[s];return null!==e&&e.push(At,n),n},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:function(e){At(e)}})},f:function(e,t,i){var r,o,n,a,s;i=le(i),2===t?(r=ct,o=lt,a=dt,n=()=>y,s=1):4===t&&(r=ut,o=ht,a=pt,n=()=>I,s=2),ve(e,{name:i,fromWireType:function(e){for(var i,o=I[e>>2],a=n(),c=e+4,l=0;l<=o;++l){var d=e+4+l*t;if(l==o||0==a[d>>s]){var u=r(c,d-c);void 0===i?i=u:(i+="\0",i+=u),c=d+t}}return At(e),i},toWireType:function(e,r){"string"!=typeof r&&me("Cannot pass non-string to C++ string type ".concat(i));var n=a(r),c=It(4+n+t);return I[c>>2]=n>>s,o(r,c+4,n+t),null!==e&&e.push(At,c),c},argPackAdvance:8,readValueFromPointer:Be,destructorFunction:function(e){At(e)}})},o:function(e,t){ve(e,{isVoid:!0,name:t=le(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,i,r){var o,n;(e=ft[e])(t=tt.toValue(t),i=void 0===(n=mt[o=i])?le(o):n,null,r)},m:et,l:function(e,t){var i=function(e,t){for(var i,r,o,n=new Array(e),a=0;a<e;++a)n[a]=(i=I[t+4*a>>2],r="parameter "+a,void 0,void 0===(o=ue[i])&&me(r+" has unknown type "+qe(i)),o);return n}(e,t),r=i[0],o=r.name+"_$"+i.slice(1).map((function(e){return e.name})).join("_")+"$",n=_t[o];if(void 0!==n)return n;for(var a=["retType"],s=[r],c="",l=0;l<e-1;++l)c+=(0!==l?", ":"")+"arg"+l,a.push("argType"+l),s.push(i[1+l]);var d,u,h="return function "+Oe("methodCaller_"+o)+"(handle, name, destructors, args) {\n",p=0;for(l=0;l<e-1;++l)h+=" var arg"+l+" = argType"+l+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=i[l+1].argPackAdvance;for(h+=" var rv = handle[name]("+c+");\n",l=0;l<e-1;++l)i[l+1].deleteObject&&(h+=" argType"+l+".deleteObject(arg"+l+");\n");return r.isVoid||(h+=" return retType.toWireType(destructors, rv);\n"),h+="};\n",a.push(h),d=Je(Function,a).apply(null,s),u=ft.length,ft.push(d),n=u,_t[o]=n,n},a:()=>{V("")},e:function(){return Date.now()},v:()=>v.length,A:(e,t,i)=>v.copyWithin(e,t,t+i),u:e=>{v.length,V("OOM")},y:(e,t)=>{var i=0;return vt().forEach((function(r,o){var n=t+i;I[e+4*o>>2]=n,((e,t)=>{for(var i=0;i<e.length;++i)g[0|t++]=e.charCodeAt(i);g[0|t]=0})(r,n),i+=r.length+1})),0},z:(e,t)=>{var i=vt();I[e>>2]=i.length;var r=0;return i.forEach((function(e){r+=e.length+1})),I[t>>2]=r,0},i:function(e){try{var t=ae.getStreamFromFD(e);return oe.close(t),0}catch(i){if(void 0===oe||"ErrnoError"!==i.name)throw i;return i.errno}},x:function(e,t){try{var i=ae.getStreamFromFD(e),r=i.tty?2:oe.isDir(i.mode)?3:oe.isLink(i.mode)?7:4;return g[0|t]=r,E[t+2>>1]=0,C=[0,(k=0,+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[t+8>>2]=C[0],T[t+12>>2]=C[1],C=[0,(k=0,+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[t+16>>2]=C[0],T[t+20>>2]=C[1],0}catch(o){if(void 0===oe||"ErrnoError"!==o.name)throw o;return o.errno}},B:function(e,t,i,r){try{var o=((e,t,i,r)=>{for(var o=0,n=0;n<i;n++){var a=I[t>>2],s=I[t+4>>2];t+=8;var c=oe.read(e,g,a,s,r);if(c<0)return-1;if(o+=c,c<s)break;void 0!==r&&(r+=c)}return o})(ae.getStreamFromFD(e),t,i);return I[r>>2]=o,0}catch(n){if(void 0===oe||"ErrnoError"!==n.name)throw n;return n.errno}},s:function(e,t,i,r,o){var n,a,s=(a=i)+2097152>>>0<4194305-!!(n=t)?(n>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var c=ae.getStreamFromFD(e);return oe.llseek(c,s,r),C=[c.position>>>0,(k=c.position,+Math.abs(k)>=1?k>0?+Math.floor(k/4294967296)>>>0:~~+Math.ceil((k-+(~~k>>>0))/4294967296)>>>0:0)],T[o>>2]=C[0],T[o+4>>2]=C[1],c.getdents&&0===s&&0===r&&(c.getdents=null),0}catch(l){if(void 0===oe||"ErrnoError"!==l.name)throw l;return l.errno}},h:function(e,t,i,r){try{var o=((e,t,i,r)=>{for(var o=0,n=0;n<i;n++){var a=I[t>>2],s=I[t+4>>2];t+=8;var c=oe.write(e,g,a,s,r);if(c<0)return-1;o+=c,void 0!==r&&(r+=c)}return o})(ae.getStreamFromFD(e),t,i);return I[r>>2]=o,0}catch(n){if(void 0===oe||"ErrnoError"!==n.name)throw n;return n.errno}}},It=(function(){var e,t,i,n,a={a:Tt};function s(e,t){var i,r,n=e.exports;return i=(m=n).E.buffer,o.HEAP8=g=new Int8Array(i),o.HEAP16=E=new Int16Array(i),o.HEAP32=T=new Int32Array(i),o.HEAPU8=v=new Uint8Array(i),o.HEAPU16=y=new Uint16Array(i),o.HEAPU32=I=new Uint32Array(i),o.HEAPF32=A=new Float32Array(i),o.HEAPF64=b=new Float64Array(i),S=m.H,r=m.F,O.unshift(r),U(),n}if(x(),o.instantiateWasm)try{return o.instantiateWasm(a,s)}catch(c){_("Module.instantiateWasm callback failed with error: "+c),r(c)}(e=p,t=w,i=a,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||F(t)||"function"!=typeof fetch?H(t,i,n):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,i).then(n,(function(e){return _("wasm streaming compile failed: "+e),_("falling back to ArrayBuffer instantiation"),H(t,i,n)}))))).catch(r)}(),e=>(It=m.G)(e)),At=e=>(At=m.I)(e),bt=()=>(bt=m.J)(),St=e=>(St=m.K)(e),wt=(o.__embind_initialize_bindings=()=>(o.__embind_initialize_bindings=m.L)(),e=>(wt=m.M)(e));function Rt(){function e(){yt||(yt=!0,o.calledRun=!0,D||(o.noFSInit||oe.init.initialized||oe.init(),oe.ignorePermissions=!1,W(O),i(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),function(){if(o.postRun)for("function"==typeof o.postRun&&(o.postRun=[o.postRun]);o.postRun.length;)e=o.postRun.shift(),M.unshift(e);var e;W(M)}()))}L>0||(function(){if(o.preRun)for("function"==typeof o.preRun&&(o.preRun=[o.preRun]);o.preRun.length;)e=o.preRun.shift(),N.unshift(e);var e;W(N)}(),L>0||(o.setStatus?(o.setStatus("Running..."),setTimeout((function(){setTimeout((function(){o.setStatus("")}),1),e()}),1)):e()))}if(o.dynCall_jiji=(e,t,i,r,n)=>(o.dynCall_jiji=m.N)(e,t,i,r,n),o._ff_h264_cabac_tables=67061,P=function e(){yt||Rt(),yt||(P=e)},o.preInit)for("function"==typeof o.preInit&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Rt(),t.ready}})(),UH=xH,VH=class extends PH{constructor(e){super(UH,null!=e&&e.wasmPath?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}};(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0})();var FH=(e=>(e.ROOM_DESTROY="1",e.JOIN_START="21",e.JOIN_SCHEDULE_SUCCESS="22",e.JOIN_SIGNAL_CONNECTION_START="23",e.JOIN_SIGNAL_CONNECTION_END="24",e.JOIN_SEND_CMD="25",e.JOIN_RECEIVED_CMD_RES="26",e.JOIN_SUCCESS="27",e.JOIN_FAILED="28",e.LEAVE_START="51",e.LEAVE_SEND_CMD="52",e.LEAVE_SUCCESS="53",e.PUBLISH_START="61",e.SEND_FIRST_VIDEO_FRAME="62",e.PUBLISH_FAILED="63",e.SUBSCRIBE_START="81",e.SUBSCRIBE_SUCCESS="82",e.SUBSCRIBE_FAILED="84",e.UNSUBSCRIBE_SUCCESS="83",e.LOCAL_TRACK_CAPTURE_START="101",e.LOCAL_TRACK_CAPTURE_SUCCESS="102",e.LOCAL_TRACK_CAPTURE_FAILED="103",e.LOCAL_TRACK_PUBLISHED="104",e.LOCAL_TRACK_UNPUBLISHED="105",e.LOCAL_TRACK_REPLACED="106",e.SWITCH_DEVICE_SUCCESS="107",e.TRACK_MUTED="108",e.TRACK_UNMUTED="109",e.REMOTE_TRACK_SUBSCRIBED="110",e.REMOTE_TRACK_UNSUBSCRIBED="111",e.LOCAL_TRACK_RECAPTURE="112",e.LOCAL_AUDIO_STARTED="113",e.LOCAL_AUDIO_STOPPED="114",e.REMOTE_AUDIO_STARTED="115",e.REMOTE_AUDIO_STOPPED="116",e.PLAY_TRACK_START="151",e.PLAYER_STATE_CHANGED="152",e.VIDEO_LOADED_DATA="153",e.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",e.AUDIO_CONTEXT_LONG_SUSPENDED="155",e.REMOTE_VIDEO_PLAY_START="156",e.REMOTE_VIDEO_PLAY_FINISH="157",e.SIGNAL_CONNECTION_STATE_CHANGED="201",e.PEER_CONNECTION_STATE_CHANGED="202",e.SINGLE_CONNECTION_STAT="203",e.SPC_RECONNECTED="204",e.HEARTBEAT_REPORT="251",e.RECEIVED_PUBLISHED_USER_LIST="252",e.REMOTE_PUBLISH_STATE_CHANGED="253",e.AUDIO_LEVEL_INTERVAL="260",e.NETWORK_QUALITY="261",e.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",e.QUALITY_LIMITATION_CHANGED="263",e.LOG="264",e.AUDIO_PROCESSOR_DEBUG="265",e.SSO_SWITCH="266",e.SWITCH_ROOM_START="401",e.SWITCH_ROOM_SUCCESS="407",e.SWITCH_ROOM_FAILED="408",e))(FH||{}),BH="undefined"!=typeof importScripts,HH="undefined"!=typeof registerProcessor,WH="jssdk_log",jH=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(jH||{}),GH=Symbol(32),zH=Symbol(16),qH=Symbol(8),KH=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return function(e,t,i,r){return new(i||(i=Promise))((function(o,n){function a(e){try{c(r.next(e))}catch(t){n(t)}}function s(e){try{c(r.throw(e))}catch(t){n(t)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,i)=>{var r;this.reject=i,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(e,!0)||null===(r=this.pull)||void 0===r||r.call(this,e)}))}))}readU32(){return this.read(GH)}readU16(){return this.read(zH)}readU8(){return this.read(qH)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null,t=this.buffer.subarray(this.consumed),i=0,r=e=>t.length<(i=e);if("number"==typeof this.need){if(r(this.need))return;e=t.subarray(0,i)}else if(this.need===GH){if(r(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===zH){if(r(2))return;e=t[0]<<8|t[1]}else if(this.need===qH){if(r(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(r(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,i)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(r(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,i)),e=this.need}return this.consumed+=i,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){let t=this.buffer.length,i=t+e;if(i<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,i);else{let e=new Uint8Array(i);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,i)}return this.buffer=new Uint8Array(e),this.buffer}};KH.U32=GH,KH.U16=zH,KH.U8=qH;function YH(e){let t=new KH;for(;e>=128;)t.malloc(1)[0]=255&e|128,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function XH(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=new KH,r=t<<3;switch(typeof e){case"boolean":let o=i.malloc(2);o[0]=r,o[1]=e?1:0;break;case"number":i.malloc(1)[0]=r,i.write(YH(e));break;case"string":i.malloc(1)[0]=2|r;let n=(new TextEncoder).encode(e);i.write(YH(n.length));let a=i.malloc(n.length);for(let e=0;e<n.length;e++)a[e]=n[e];break;case"object":let s=new KH;if(Array.isArray(e))for(let t=0;t<e.length;t++){let i=XH(e[t],t+1);i&&s.write(i)}else{let t=1;for(let i in e){let r=XH(e[i],t++);r&&s.write(r)}}0===t?s.buffer&&i.write(s.buffer):(i.malloc(1)[0]=2|r,s.buffer&&(i.write(YH(s.buffer.length)),i.write(s.buffer)))}return i.buffer||new Uint8Array(0)}var JH=class{constructor(){TH(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function QH(e,t,i){e[i]=t>>>24&255,e[i+1]=t>>>16&255,e[i+2]=t>>>8&255,e[i+3]=255&t}function $H(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function ZH(e,t){return e[t]}function eW(e,t,i){return(new TextDecoder).decode(function(e,t,i){return e.slice(t,t+i)}(e,t,i))}var tW=0,iW=2654435769;function rW(e,t){let i=new JH,r=function(e,t,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,uin:"",uinLen:0,reqHead:{seqNumber:i,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:r,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}(t,e,tW);tW=tW+1&2147483647,i.writeInt32(0),i.writeInt32(r.version),i.writeByte(r.encryption);let o=(new TextEncoder).encode(r.d2);i.writeInt32(o.length+4),o&&i.writeBytes(o),i.writeByte(r.uinType);let n=(new TextEncoder).encode(r.uin);i.writeInt32(n.length+4),n.length&&i.writeBytes(n);let a=new JH;a.writeInt32(0),a.writeInt32(r.reqHead.seqNumber),a.writeInt32(r.reqHead.appId),a.writeByte(r.reqHead.appId>>>24&255),a.writeByte(r.reqHead.appId>>>16&255),a.writeByte(r.reqHead.appId>>>8&255),a.writeByte(255&r.reqHead.appId);for(let v=4;v<16;v++)a.writeByte(0);let s=(new TextEncoder).encode(r.reqHead.a2);a.writeInt32(s.length+4),s.length&&a.writeBytes(s);let c=(new TextEncoder).encode(r.reqHead.serviceCmd);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);let l=(new TextEncoder).encode(r.reqHead.cookie);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);let d=(new TextEncoder).encode(r.reqHead.imei);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);let u=(new TextEncoder).encode(r.reqHead.ksid);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);let h=(new TextEncoder).encode(r.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);let p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,Sj(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);let m=new Uint8Array(a.data),f=null;1===r.encryption?f=(new TextEncoder).encode(r.uin):2===r.encryption&&(f=new Uint8Array(16)),f&&(m=function(e,t){let i=e.length,r=(i+1+2+7)%8;r&&(r=8-r);let o=new Uint8Array(i+1+2+7+r),n=0,a=new Uint8Array(8),s=new Uint8Array(8),c=new Uint8Array(8),l=0;a[0]=248&Math.floor(256*Math.random())|r,l=1;for(let u=0;u<r;u++)a[l]=255&Math.floor(256*Math.random()),l+=1;for(let u=0;u<2;)if(l<8&&(a[l]=255&Math.floor(256*Math.random()),l+=1,u+=1),8===l){oW(a,t,s,c,o,n),n+=8,l=0;for(let e=0;e<8;e++)c[e]=o[n-8+e]}let d=0;for(;d<i;)if(l<8&&(a[l]=e[d],l+=1,d+=1),8===l){oW(a,t,s,c,o,n),n+=8,l=0;for(let e=0;e<8;e++)c[e]=o[n-8+e]}for(let u=0;u<7;)if(l<8&&(a[l]=0,l+=1,u+=1),8===l){oW(a,t,s,c,o,n),n+=8,l=0;for(let e=0;e<8;e++)c[e]=o[n-8+e]}return o}(m,f)),i.writeBytes(m);let _=new Uint8Array(i.data),g=_.length;return _[0]=g>>>24&255,_[1]=g>>>16&255,_[2]=g>>>8&255,_[3]=255&g,_}function oW(e,t,i,r,o,n){for(let a=0;a<8;a++)e[a]^=r[a];!function(e,t,i,r){let o=$H(e,0),n=$H(e,4),a=[];for(let c=0;c<4;c++)a[c]=$H(t,4*c);let s=0;for(let c=0;c<16;c++)s+=iW,s>>>=0,o+=(n<<4)+a[0]^n+s^(n>>>5)+a[1],o>>>=0,n+=(o<<4)+a[2]^o+s^(o>>>5)+a[3],n>>>=0;QH(i,o,r),QH(i,n,r+4)}(e,t,o,n);for(let a=0;a<8;a++)o[n+a]^=i[a];for(let a=0;a<8;a++)i[a]=e[a]}var nW=function(){return Date.now()+0},aW=function(){let e=new Date;return e.setTime(nW()),e.toLocaleString()};function sW(e){let t=function(e){try{let t={},i=0;t.totalLength=$H(e,i),i+=4,t.version=$H(e,i),i+=4,t.encryption=ZH(e,i),i+=1,t.uinType=ZH(e,i),i+=1,t.uinLength=$H(e,i),i+=4,t.uin=t.uinLength>4?eW(e,i,t.uinLength-4):"",i+=t.uinLength-4;let r=e.slice(i);if(2===t.encryption){e=function(e,t){let i=0,r=new Uint8Array(8).fill(0),o=cW(new Uint8Array(e.slice(0,8)),t),n=7&o[0],a=e.length-1-n-2-7,s=new Uint8Array(a),c=0,l=r,d=e.slice(0,8);i=8;let u=1;u+=n;for(let p=1;p<=2;)if(u<8)u++,p++;else if(8===u){let r=lW(e,i,l,d,o,t);l=r.ivPreCrypt,d=r.ivCurCrypt,o=r.debiBuf,i=r.bufPos,u=0}let h=a;for(;h>0;)if(u<8)s[c++]=o[u]^l[u],u++,h--;else if(8===u){let r=lW(e,i,l,d,o,t);l=r.ivPreCrypt,d=r.ivCurCrypt,o=r.debiBuf,i=r.bufPos,u=0}for(let p=1;p<=7;)if(u<8)o[u],l[u],u++,p++;else if(8===u){if(i>=e.length)break;let r=lW(e,i,l,d,o,t);if(!r.success)break;l=r.ivPreCrypt,d=r.ivCurCrypt,o=r.debiBuf,i=r.bufPos,u=0}return s}(r,new Uint8Array(16).fill(0)),t.decrypted=!0,i=0}else e=r,i=0;return t.rspHeadLength=$H(e,i),i+=4,t.seqNo=$H(e,i),i+=4,t.retCode=$H(e,i),i+=4,t.retStrLength=$H(e,i),i+=4,t.retStr=t.retStrLength?eW(e,i,t.retStrLength-4):"",i+=t.retStrLength-4,t.serviceCmdLength=$H(e,i),i+=4,t.serviceCmd=t.serviceCmdLength?eW(e,i,t.serviceCmdLength-4):"",i+=t.serviceCmdLength-4,t.cookieLength=$H(e,i),i+=4,t.cookie=t.cookieLength?eW(e,i,t.cookieLength-4):"",i+=t.cookieLength-4,t.flag=$H(e,i),i+=4,t.busiBuffLength=$H(e,i),i+=4,t.busiBuff=t.busiBuffLength?eW(e,i,t.busiBuffLength-4):"",i+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function cW(e,t){let i=e[0]<<24|e[1]<<16|e[2]<<8|e[3],r=e[4]<<24|e[5]<<16|e[6]<<8|e[7];i>>>=0,r>>>=0;let o=16*iW>>>0;for(let n=0;n<16;n++)r-=(i<<4)+t[2]^i+o^(i>>>5)+t[3],r>>>=0,i-=(r<<4)+t[0]^r+o^(r>>>5)+t[1],i>>>=0,o-=iW,o>>>=0;return new Uint8Array([i>>>24&255,i>>>16&255,i>>>8&255,255&i,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}function lW(e,t,i,r,o,n){if(t+8>e.length)return{success:!1};let a=new Uint8Array(r),s=e.slice(t,t+8),c=new Uint8Array(8);for(let l=0;l<8;l++)c[l]=o[l]^s[l];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:cW(c,n),bufPos:t+8}}var dW="undefined"!=typeof TextDecoder?new TextDecoder:void 0;var uW=Object.prototype.hasOwnProperty,hW=e=>"function"==typeof e,pW=e=>void 0===e;function mW(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let i=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Function.prototype.toString.call(i)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(uW.call(e,t))return!1;return!0}return!1}var fW=function(e){let{retryFunction:t,settings:i,onError:r,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:d=5,timeout:u=1e3}=i,h=0,p=-1,m=0,f=(e,i)=>cR(this,null,(function*(){let l=s||this;try{let i=yield t.apply(l,c);h>0&&a&&a.call(this,h),h=0,e(i)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,i(_)},a=()=>{2!==m&&h<(hW(d)?d():d)?(h++,m=1,hW(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,i)}),hW(u)?u(h):u)):(t(),hW(n)&&n.call(this,_))};hW(r)?r.call(this,{error:_,retry:a,reject:i,retryFuncArgs:c,retriedCount:h}):a()}}));return new Promise(f)}},_W=class e{constructor(e){TH(this,"_parentPath"),TH(this,"userId"),TH(this,"remoteUserId"),TH(this,"id"),TH(this,"sdkAppId"),TH(this,"type"),TH(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!(e=>"boolean"==typeof e)(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}createChild(t){let i=new e({id:t.id,userId:pW(t.userId)?this.userId:t.userId,sdkAppId:pW(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:pW(t.type)?this.type:t.type,isLocal:pW(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:pW(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return i.bindParent(this),i}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let i=this.isLocal?this.userId:this.remoteUserId,r=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(r).concat(i?"|".concat(i):"","]")),Ij.log(e,t,pW(this.userId)||mW(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}},gW="undefined"==typeof navigator?"":navigator.userAgent,vW=e=>new RegExp(e,"i").test(gW),EW=e=>{if(vW(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),i=gW.match(t);if(i&&i[1])return i[1]}return""},yW=e=>{if(vW(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),i=gW.match(t);if(i&&i[1])return parseFloat(i[1])}return NaN},TW=/AppleWebKit\/([\d.]+)/i.exec(gW);TW&&parseFloat(TW[1]);var IW=vW("iPad"),AW="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&vW("Macintosh"),bW=vW("iPhone")&&!IW,SW=vW("iPod"),wW=bW||IW||SW||AW,RW=vW("Android");!function(){if(RW){let e=gW.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);if(t&&i)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}}();RW&&vW("webkit");var kW=vW("Firefox"),CW=EW("Firefox");yW("Firefox");var DW=vW("Edge"),NW=EW("Edge"),OW=vW("Edg"),MW=EW("Edg");yW("Edg");var LW=vW("SogouMobileBrowser"),PW=EW("SogouMobileBrowser"),xW=vW("MetaSr\\s"),UW=EW("MetaSr\\s"),VW=vW("TBS"),FW=EW("TBS"),BW=vW("XWEB"),HW=EW("XWEB");vW("MSIE\\s8\\.0");var WW=vW("MSIE\\/\\d+");!function(){if(WW){let e=/MSIE\s(\d+)\.\d/.exec(gW),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(gW)&&/rv:11.0/.test(gW)&&(t=11),t}}();var jW=vW("(micromessenger|webbrowser)"),GW=EW("MicroMessenger"),zW=!VW&&vW("MQQBrowser")&&vW("COVC"),qW=!VW&&vW("MQQBrowser")&&!vW("COVC"),KW=qW||zW?EW("MQQBrowser"):"",YW=!VW&&vW(" QQBrowser"),XW=EW(" QQBrowser"),JW=!VW&&vW("QQBrowserLite"),QW=EW("QQBrowserLite"),$W=!VW&&vW("MQBHD"),ZW=EW("MQBHD");vW("Windows"),!wW&&vW("MAC OS X"),!RW&&vW("Linux"),vW("CrOS"),vW("MicroMessenger"),vW("UCBrowser"),vW("Electron");var ej=vW("MiuiBrowser"),tj=EW("MiuiBrowser"),ij=vW("HuaweiBrowser");vW("Huawei")||vW("HUAWEI"),vW("Honor")||vW("HONOR");var rj=EW("HuaweiBrowser"),oj=vW("SamsungBrowser"),nj=EW("SamsungBrowser"),aj=vW("HeyTapBrowser"),sj=EW("HeyTapBrowser"),cj=vW("VivoBrowser"),lj=EW("VivoBrowser");vW("OpenHarmony"),EW("OpenHarmony");var dj=vW("CriOS"),uj=vW("Chrome"),hj=!DW&&!xW&&!LW&&!VW&&!BW&&!OW&&!YW&&!ej&&!ij&&!oj&&!aj&&!cj&&uj,pj=vW("HeadlessChrome");yW("Chrome");var mj=EW("Chrome");yW("Electron");var fj=!uj&&!qW&&!zW&&!JW&&!$W&&vW("Safari"),_j=EW("Version");/Android.*(wv|.0.0.0)/.test(gW);var gj=(()=>{if(AW)return _j;if(wW){let e=gW.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();Number(gj.split(".")[0]),(()=>{let e=Number(gj.split(".")[0])})(),function(){let e=new Map([[kW,["Firefox",CW]],[OW,["Edg",MW]],[hj,["Chrome",mj]],[dj,["ChiOS",EW("CriOS")]],[fj&&!dj,["Safari",_j]],[VW,["TBS",FW]],[BW,["XWEB",HW]],[jW&&bW,["WeChat",GW]],[YW,["QQ(Win)",XW]],[qW,["QQ(Mobile)",KW]],[zW,["QQ(Mobile X5)",KW]],[JW,["QQ(Mac)",QW]],[$W,["QQ(iPad)",ZW]],[ej,["MI",tj]],[ij,["HW",rj]],[oj,["Samsung",nj]],[aj,["OPPO",sj]],[cj,["VIVO",lj]],[DW,["EDGE",NW]],[LW,["SogouMobile",PW]],[xW,["Sogou",UW]]]),t="unknown",i="unknown";e.has(!0)&&([t,i]=e.get(!0))}();var vj=new(EH(IH(),1).default),Ej=FH,yj=new class{constructor(){TH(this,"enable",!1),TH(this,"ssoFailCount",0),vj.on("22",(e=>{let{schedule:t}=e;var i;null!=(i=null==t?void 0:t.config)&&i.sso&&vj.emit("266",{enable:!0})})),vj.on("266",(e=>{let{enable:t}=e;this.enable=t}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&vj.emit("266",{enable:!1})}},Tj=class e{constructor(){TH(this,"_isEnableUploadLog",!0),TH(this,"_localJoinedUser",new Map),TH(this,"_queue",[]),TH(this,"_timeoutId",-1),TH(this,"_logLevel",1),TH(this,"_logLevelToUpload",2),BH||HH||(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){vj.on(Ej.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var i;null!=(i=null==t?void 0:t.config)&&i.logLevelToUpload&&jH[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),vj.on(Ej.JOIN_START,(e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),vj.on(Ej.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let i=this._queue[t];if(i.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:r,sdkAppId:o}=t;e.map.has(r)?e.map.get(r).logs.push(i):e.map.set(r,{userId:r,sdkAppId:o,logs:[i]})}));else if(Sj(i.userId)&&wj(i.sdkAppId)){let{userId:t,sdkAppId:r}=i;e.map.has(t)?e.map.get(t).logs.push(i):e.map.set(t,{userId:t,sdkAppId:r,logs:[i]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return cR(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:i,sdkAppId:r,logs:o}=t[e],n={timestamp:aW(),sdkAppId:String(r),userId:i,version:"5.0.0",log:o.map((e=>e.log)).join("\n")},a=JSON.stringify(n),s=yj.enable?Rj(n,2002,r):a;yield this.uploadLogWithRetry(s,r,s instanceof Uint8Array,a),o.forEach((e=>e.uploaded=!0))}}catch(pM){}let i=t.filter((e=>!e.uploaded));i.length>0&&(this._queue=i.concat(this._queue))}))}uploadLogWithRetry(e,t,i,r){return fW({retryFunction:()=>function(e){let{url:t,body:i,method:r="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:r,body:i,priority:n}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:sW(new Uint8Array(e))||(dW?dW.decode(e):e)}))))))).then(e,a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(fM){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(r,t,!0),s.send(i)}))}({url:Aj(t,WH),body:e,timeout:5e3,priority:"low"}).then((e=>{i&&"ok"!==e.data&&(yj.handleUploadFailed(),this.uploadLogWithRetry(r,t,!1,r))})),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(nW()),"[".concat(function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)}(t),"] <").concat(jH[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){bj(jH[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(Sj(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(kR){return""}}addLogToQueue(e,t){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n={log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:r,sdkAppId:o,forAllJoinedClients:i};vj.emit(Ej.LOG,{log:n}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(n)}log(t,i){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;if(i.unshift(this.getPrefix(t)),this.addLogToQueue(t,i,r,o,n),t<this._logLevel)return;let s=(null==(a=jH[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...i):console[s](...i)}debug(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];this.log(4,t)}createLogger(e){if(e.parent instanceof _W){let t=e,{parent:i}=t,r=((e,t)=>{var i={};for(var r in e)mH.call(e,r)&&t.indexOf(r)<0&&(i[r]=e[r]);if(null!=e&&hH)for(var r of hH(e))t.indexOf(r)<0&&fH.call(e,r)&&(i[r]=e[r]);return i})(t,["parent"]),o=new _W(r);return o.bindParent(i),o}return new _W(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;jH[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};TH(Tj,"PRINT_LOG_TAG",!(wW||RW||pj));var Ij=new Tj,Aj=function(e,t){let i;return i=(e=>Number(e)<14e8)(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com","".concat(i,"/v5/AVQualityReportSvc/C2S?random=").concat(Math.floor(Math.random()*Qw(2,31)),"&sdkappid=").concat(e,"&cmdtype=").concat(t)},bj=e=>void 0===e,Sj=e=>"string"==typeof e,wj=e=>"number"==typeof e;function Rj(e,t,i,r){try{let o=function(e,t,i,r){let o={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:i};return bj(r)||(o=vH(gH({},o),{gzip:+r})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}(e,t,i,r);return rW(XH(o),i)}catch(pM){return JSON.stringify(e)}}var kj=class e{constructor(e){this.core=e,TH(this,"contextMap",new Map),TH(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return null!=e&&e.track?"".concat(e.track.userId).concat(e.track.streamType):"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){var i;switch(e){case"wasm":let e=(null==(i=this.core.assetsPath)?void 0:i.replace(/\/+$/,""))||".";return new VH(vH(gH({},t),{wasmPath:"".concat(e,"/videodec.wasm")}));case"webCodecs":return new MH;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:e=>{let{frame:t,track:i}=e;var r;return(null==(r=this.decodeProcessorMap.get(i))?void 0:r({frame:t,track:i}))||t},type:3})}decode(e){let{pipe:t,take:i,subscribe:r}=this.core.rx;return o=>{let{frame:n,track:a}=o;if(a!==e.track||"empty"===n.type)return n;if(this.contextMap.has(a))return this.contextMap.get(a).decode(n);let s=this.core.room.videoManager.createDecodeContext(vH(gH({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,i(1),r((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:a})}))),this.contextMap.set(a,s),s.decode(n)}}stop(e){if(null!=e&&e.track){let t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;let i=(performance&&performance.now?Math.floor(performance.now()):Date.now())-e.startPerformanceTime,{renderFreezeTotal:r,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e),n="report health data: ".concat(e.track.userId," ").concat(e.track.streamType," ").concat(e.type,"+").concat(e.renderer," goodType:").concat(e.goodType," ").concat(e.failedReason?"failedReason: ".concat(e.failedReason):"");i&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(r/i*100),split:1,max:100}),n+=" RENDER_FREEZE_RATE: ".concat(Math.floor(r/i*100),"%")),i&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/i*100),split:1,max:100}),n+=" DATA_FREEZE_RATE: ".concat(Math.floor(o/i*100),"%")),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),n+=" VIDEO_CONSUME_RENDER_RATE: ".concat(Math.floor(e.decodedFrameCount/e.inputFrameCount*100),"%")),this.core.log.info(n)}addKVReportBeforeExitRoom(e){let{room:t}=e;t===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){let t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(vH(gH({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){let i=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),r=this.core.room.badCaseDetector.getRenderFreezeDuration("".concat(e.userId,"_").concat(e.streamType)),o=0;return i&&i.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:r,dataFreezeTotal:o}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};TH(kj,"Name","TRTCVideoDecoder");var Cj=kj,Dj=oR(lR());function Nj(e){let{timesInSecond:t,maxSizeInSecond:i,getSize:r}=e;return MU(((e,o)=>{let n=new WeakMap;return $O.on(eM.ROOM_DESTROY,(e=>{let{room:t}=e;return n.delete(t)})),function(){let a=n.get(this);for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},n.set(this,a)),0===a.timestamp?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),r&&(a.totalSizeInSecond+=r(...c)),0!==a.timestamp&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=t||a.totalSizeInSecond>i))throw new vR({code:_R.INVALID_OPERATION,message:vL({key:mL.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=t,isSize:a.totalSizeInSecond>i,name:o,timesInSecond:t,maxSizeInSecond:i}})});a.callCountInSecond++,e.call(this,...c)}}))}var Oj,Mj=!0,Lj={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},Pj={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},xj=((Oj=xj||{})[Oj.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",Oj[Oj.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",Oj[Oj.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",Oj[Oj.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",Oj[Oj.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",Oj[Oj.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",Oj[Oj.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",Oj[Oj.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",Oj[Oj.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",Oj[Oj.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",Oj[Oj.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",Oj[Oj.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",Oj[Oj.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",Oj[Oj.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",Oj[Oj.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",Oj[Oj.INVALID_ROOM_ID_REQUIRED=5015]="INVALID_ROOM_ID_REQUIRED",Oj[Oj.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",Oj[Oj.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",Oj[Oj.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",Oj[Oj.INVALID_ROOM_ID_TYPE_MISMATCH=5019]="INVALID_ROOM_ID_TYPE_MISMATCH",Oj[Oj.INVALID_ROOM_ID_DUPLICATE=5020]="INVALID_ROOM_ID_DUPLICATE",Oj[Oj.INVALID_OPERATION=5100]="INVALID_OPERATION",Oj[Oj.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",Oj[Oj.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",Oj[Oj.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",Oj[Oj.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",Oj[Oj.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",Oj[Oj.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",Oj[Oj.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",Oj[Oj.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",Oj[Oj.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",Oj[Oj.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",Oj[Oj.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",Oj[Oj.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",Oj[Oj.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",Oj[Oj.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",Oj[Oj.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",Oj[Oj.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",Oj[Oj.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",Oj[Oj.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",Oj[Oj.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",Oj[Oj.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",Oj[Oj.DEVICE_ERROR=5300]="DEVICE_ERROR",Oj[Oj.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",Oj[Oj.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",Oj[Oj.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",Oj[Oj.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",Oj[Oj.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",Oj[Oj.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",Oj[Oj.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",Oj[Oj.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",Oj[Oj.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",Oj[Oj.NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX=5310]="NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX",Oj[Oj.SERVER_ERROR=5400]="SERVER_ERROR",Oj[Oj.NEED_TO_BUY=5401]="NEED_TO_BUY",Oj[Oj.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",Oj[Oj.OPERATION_FAILED=5500]="OPERATION_FAILED",Oj[Oj.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",Oj[Oj.REJOIN_FAILED=5502]="REJOIN_FAILED",Oj[Oj.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",Oj[Oj.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",Oj[Oj.VIDEO_ENCODE_FAILED=5505]="VIDEO_ENCODE_FAILED",Oj[Oj.AUDIO_ENCODE_FAILED=5506]="AUDIO_ENCODE_FAILED",Oj[Oj.VIDEO_DECODE_FAILED=5507]="VIDEO_DECODE_FAILED",Oj[Oj.AUDIO_DECODE_FAILED=5508]="AUDIO_DECODE_FAILED",Oj[Oj.OPERATION_ABORT=5998]="OPERATION_ABORT",Oj[Oj.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",Oj);var Uj=eR(Zw({},fL),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' is a required param when calling ").concat(r,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:i,fnName:r,value:o}=e,n="".concat(t||i.name),a="";return a=Array.isArray(i.type)?i.type.join("|"):i.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(r,"(), received type: ").concat(qC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' cannot be '").concat(o,"' when calling ").concat(r,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:i,fnName:r,value:o}=e,n="".concat(t||i.name),a="".concat(i.instanceOf.name||i.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(r,"(), received type: ").concat(qC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:i,fnName:r,value:o}=e;return"'".concat(t||i.name,"' must be one of ").concat(i.values.join("|")," when calling ").concat(r,"(), received: ").concat(o,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:i,fnName:r}=e;return"'".concat(t||i.name,"' cannot be less than 0 when calling ").concat(r,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:i,value:r}=e;return"the min value of ".concat(t||i.name," is ").concat(i.min,", received: ").concat(r,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:i,value:r}=e;return"the max value of ".concat(t||i.name," is ").concat(i.max,", received: ").concat(r,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:i}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(i,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:i,type:r}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(i,"(), received: ").concat(r,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIRED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_ROOM_ID_TYPE_MISMATCH(e){let{key:t}=e;return"The type of target roomId must match the current roomId. Current room is using '".concat(t,"', but received '").concat("strRoomId"===t?"roomId":"strRoomId","'.")},INVALID_ROOM_ID_DUPLICATE(e){let{key:t}=e;return"the target '".concat(t,"' must not be the same as the current '").concat(t,"'.")},INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:i}=e;return"cannot ".concat(t," because remote user(userId: ").concat(i.userId,") does not publishing ").concat(i.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone or screen share is not turned on.")},INVALID_BUFFER_EMPTY:e=>{let{key:t}=e;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:e=>{let{fnName:t}=e;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got device exception").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"NotFoundError, no ".concat(i," detected, please check your device and the configuration on '").concat(t,"'").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"NotAllowedError, you have disabled ".concat(i," access, please allow the current application to use the ").concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"NotReadableError, the ".concat(i," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(i).concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(i,", and it is recommended to turn on the ").concat(i," after the user interacts with the page").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:i=Vj(t),error:r}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(r?" error: ".concat(r.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:i}=e;return"'".concat(t,"' failed, reason: ").concat(null==i?void 0:i.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:i}=e;return"video context error ".concat(t," ").concat((null==i?void 0:i.name)||""," ").concat((null==i?void 0:i.message)||"")},SERVER_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' got server error: ").concat(null==i?void 0:i.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:i}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(i)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:i}=e;return"'".concat(t,"' throw unknown exception").concat(i?", error: ".concat(i.toString(),"."):".")}});function Vj(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var Fj=class e extends Error{constructor(e){let{code:t,extraCode:i,message:r="",messageParams:o,fnName:n="",originError:a,data:s}=e;var c;let l;l=r||function(e){let t,{code:i,params:r,enableDocLink:o=!1}=e,a="",s=xj[i];try{t=Uj[s]}catch(n){t=Uj.UNKNOWN_ERROR}return KC(t)?a=t(r):XC(t)&&(a=t),r.fnName&&!a.includes(r.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(r.fnName,"()")),o&&(a+=" doc:"),a}({code:t===Pj.SERVER_ERROR?t:i||t,params:Zw({fnName:n,error:a},o)}),super(l),aR(this,"name","RtcError"),aR(this,"code"),aR(this,"extraCode"),aR(this,"functionName"),aR(this,"message"),aR(this,"data"),aR(this,"handler"),aR(this,"originError"),this.name=xj[t],this.code=t,this.extraCode=i,this.functionName=n,this.originError=a,this.message=l,this.data=s,5302===this.extraCode&&null!=(c=this.originError)&&c.message.includes("system")&&(this.handler=()=>{let e=document.createElement("a");qN?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):KN&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(t,i,r){let o=t;if(t instanceof vR){let{stack:n}=t,a={code:Pj.UNKNOWN_ERROR,fnName:i,originError:t};switch(t.getCode()){case _R.INVALID_PARAMETER:a.code=Pj.INVALID_PARAMETER,a.message=t.message;break;case _R.INVALID_OPERATION:a.code=Pj.INVALID_OPERATION;break;case _R.NOT_SUPPORTED:case _R.NOT_SUPPORTED_H264:a.code=Pj.ENV_NOT_SUPPORTED,t.getCode()===_R.NOT_SUPPORTED_H264&&(a.extraCode=t.message.includes(fL.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case _R.JOIN_ROOM_FAILED:a.messageParams={fnParams:r};case _R.SERVER_TIMEOUT:case _R.SWITCH_ROLE_FAILED:case _R.SWITCH_ROOM_FAILED:a.code=Pj.SERVER_ERROR,a.extraCode=t.getExtraCode();break;case _R.API_CALL_ABORTED:a.code=Pj.OPERATION_ABORT;break;case _R.DEVICE_NOT_FOUND:case _R.DEVICE_AUTO_RECOVER_FAILED:case _R.INITIALIZE_FAILED:a.code=5300,t.name&&(a.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(t.name));break;case _R.VIDEO_ENCODE_FAILED:a.extraCode=5505;case _R.AUDIO_ENCODE_FAILED:a.extraCode=5506,a.code=Pj.OPERATION_FAILED;break;case _R.UNKNOWN:break;default:a.code=Pj.OPERATION_FAILED}o=new e(a),n&&(o.stack+=n.substr(n.indexOf("\n")))}else{if(t instanceof e)return t;o=new e({code:Pj.UNKNOWN_ERROR,fnName:i,originError:t})}return o}};var Bj=Fj;function Hj(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function Wj(e){return e===Lj.QOS_PREFERENCE_CLEAR?"detail":e===Lj.QOS_PREFERENCE_SMOOTH?"motion":""}function jj(e,t){let i=t?ik:tk;return QD(e)?Zw(Zw({},i),e):ek[e]?ek[e]:i}var Gj={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{type:["string","object","boolean"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},zj={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},qj={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,i){if(XC(e)&&!document.getElementById(e))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5009,fnName:i,messageParams:{key:t}})}},Kj={name:"userId",required:!0,type:"string"},Yj={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{type:["string","object"],properties:{bitrate:{type:"number"},channelCount:{type:"number"}}},echoCancellation:{values:[!0,!1,"remote-only","all"]},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function Xj(e,t){if(!e)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5101,fnName:t})}function Jj(e,t,i){if(!e)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:i}})}function Qj(e,t,i){if(!(/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5013,fnName:t,messageParams:{key:i}})}function $j(e,t,i){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5012,fnName:t,messageParams:{key:i}})}function Zj(e){var t;if(null==(t=null==e?void 0:e.option)||!t.small)return;if(!iP())return rM.warn("small stream is not supported"),void delete e.option.small;let i=jj(e.option.profile),r=jj(e.option.small,!0);return((e,t)=>e.width*e.height>=t.width*t.height&&e.frameRate>=t.frameRate&&e.bitrate>=t.bitrate)(i,r)?void 0:(rM.warn("small stream profile must be less than big stream profile. Big: ".concat(JSON.stringify(i),", Small: ").concat(JSON.stringify(r))),void delete e.option.small)}var eG={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,i){if(this._room.isJoined)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5104,fnName:i});if(e.roomId){if(XC(e.roomId))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5016,fnName:i,messageParams:{key:t}});Qj(e.roomId,i,t)}else{if(!e.strRoomId)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5015,fnName:i});$j(e.strRoomId,i,t)}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:qj,mute:{type:["boolean","string"]},publish:{type:"boolean"},capture:{required:!1,type:"boolean"},option:Gj},validate(e){var t,i;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&UL())throw new Bj({code:Pj.ENV_NOT_SUPPORTED,extraCode:5201});null!=(i=null==e?void 0:e.option)&&i.small&&Zj(e)}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:eR(Zw({},qj),{required:!1}),publish:{type:"boolean"},capture:{required:!1,type:"boolean"},mute:{type:["boolean","string"]},option:Gj},validate(e){var t;null!=(t=null==e?void 0:e.option)&&t.small&&Zj(e)}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:Yj},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&UL())throw new Bj({code:Pj.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:Yj}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:qj,publish:{type:"boolean"},option:zj},validate(e,t,i,r,o){var n;if(null==(n=null==e?void 0:e.option)||!n.videoTrack){if(UL())throw new Bj({code:Pj.ENV_NOT_SUPPORTED,extraCode:5201});if(!GL())throw new Bj({code:Pj.ENV_NOT_SUPPORTED,fnName:i,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:qj,publish:{type:"boolean"},option:zj}},muteRemoteAudio:[Kj,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[Kj,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:qj,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){Xj(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(Jj(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:eR(Zw({},qj),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,i){Xj(this._room.isJoined,i);let r=this._room.remotePublishedUserMap.get(e.userId);if(Jj(!!r,i,e),r&&("main"===e.streamType&&!r.muteState.videoAvailable||"sub"===e.streamType&&!r.muteState.hasAuxiliary))throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5103,fnName:i,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,i){if("*"!==e.userId&&YC(e.streamType))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5014,fnName:i})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,i){Xj(this._room.isJoining||this._room.isJoined,i)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,i,r){if(!EP)throw new Bj({code:Pj.ENV_NOT_SUPPORTED,fnName:i,extraCode:5207});if(!this._room.enableSEI)throw new Bj({code:Pj.INVALID_OPERATION,fnName:i,extraCode:5108});if(e.byteLength>1e3)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5018,fnName:i});if(0===e.byteLength)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:i});Xj(this._room.isJoined,i)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(e,t,i){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:i})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(e,t,i,r){if(e.byteLength>1e3)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5018,fnName:i});if(0===e.byteLength)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5017,fnName:i,messageParams:{key:t}})}}},validate(e,t,i){if(Xj(this._room.isJoined,i),"live"===this._room.scene&&"audience"===this._room.role)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5107,fnName:i,messageParams:{key:t}})}},switchRoom:{name:"switchRoomConfig",type:"object",required:!0,validate(e,t,i){if(Xj(this._room.isJoined,i),this._room.useStringRoomId&&e.strRoomId===this._room.roomId||!this._room.useStringRoomId&&e.roomId===Number(this._room.roomId))throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5020,fnName:i,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId&&this._room.useStringRoomId||!e.roomId&&e.strRoomId&&!this._room.useStringRoomId)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5019,fnName:i,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId)Qj(e.roomId,i,t);else{if(!e.strRoomId)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5015,fnName:i});$j(e.strRoomId,i,t)}},properties:{roomId:{type:"number"},strRoomId:{type:"string"},privateMapKey:{type:"string"},userSig:{type:"string",required:!0},autoSubscribeCount:{type:"number",min:0,max:50}}}},tG={TRTC:eG},iG=class extends Error{};function rG(e,t){let i=gD(e);for(let r=0;r<t.length;r++)_D(i[r],t[r]);return i}function oG(e){this._resolve=Promise.resolve(e)}function nG(e){this._reject=Promise.reject(e)}var aG=class e{constructor(t,i){this.instance=t,this.group=i,aR(this,"started",!1),aR(this,"ops",[]),aR(this,"startSame",(()=>!0)),aR(this,"mergeUpdate",rG);let r=e.instances.get(t);r?r.set(i,this):e.instances.set(t,new Map([[i,this]]))}static get(t,i){if(!i)return;let r=e.instances.get(t);return r&&r.get(i)||new e(t,i)}static gets(t,i){let r=e.instances.get(t),o=[];return r&&r.forEach(((e,t)=>{i.test(t)&&o.push(e)})),o}action(e,t,i){let r=t=>{var i;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(i=this.currentOp)||i.action(),t},o=t=>{var i,r;throw this.ops.shift(),0===e&&2===(null==(i=this.currentOp)?void 0:i.type)&&this.ops.shift().reject(new iG("start failed")),null==(r=this.currentOp)||r.action(),t},n={type:e,action:()=>t(...n.args).then(r,o),args:i,resolve:oG,reject:nG};try{switch(this.state){case 1:if(0===e)throw new iG("already started");break;case 4:if(2===e)throw new iG("not started");break;default:return this.cacheOp(n)}}catch(hM){return Promise.reject(hM)}return this.ops.push(n),n.promise=t(...n.args).then(r,o)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new iG("already start");break;case 3:switch(e.type){case 2:throw new iG("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new iG("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new iG("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new iG("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new iG("start not allowed after update");case 0:throw new iG("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new iG("keep start")),new iG("already start")}}e.promise=new Promise(((t,i)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(i):e.reject=i}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};aR(aG,"instances",new WeakMap);var sG=aG,cG=new WeakMap,lG=(e,t)=>{if(t instanceof iG){let{stack:i}=t;t=new Bj({code:Pj.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),i&&(t.stack+=i.substr(i.indexOf("\n")))}throw t};function dG(e,t){return MU(((i,r)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let s=sG.get(this,"string"==typeof e?e:e.call(this,...n));return s?(t&&(s.startSame=t.bind(this)),s.action(0,i.bind(this),n).catch(lG.bind(null,r))):i.apply(this,n)}))}function uG(e,t){let{merge:i,debounce:r}=t||{};return MU(((t,o)=>function(){for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];let c=sG.get(this,"string"==typeof e?e:e.call(this,...a));if(!c)return t.apply(this,a);if(i&&(c.mergeUpdate=i.bind(this)),r&&r.isNeedToDebounce.apply(this,a)){let{delay:e,getKey:i}=r;return new Promise(((r,n)=>{var s,l;let d=null==(s=cG.get(this))?void 0:s.get(i(...a));if(d){let{timeoutId:e,resolve:t}=d;clearTimeout(e),t()}let u=setTimeout((()=>{if(3===c.state||4===c.state)return r();c.action(2,t.bind(this),a).catch(lG.bind(null,o)).then(r,n)}),e);cG.has(this)?null==(l=cG.get(this))||l.set(i(...a),{timeoutId:u,resolve:r}):cG.set(this,new Map([[i(...a),{timeoutId:u,resolve:r}]]))}))}return c.action(2,t.bind(this),a).catch(lG.bind(null,o))}))}function hG(e){return MU(((t,i)=>function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];let a="function"==typeof e?e.call(this,...o):e;if(a instanceof RegExp)return Promise.all(sG.gets(this,a).map((e=>e.action(3,(()=>Promise.resolve()),o)))).then((()=>t.call(this,...o)));let s=sG.get(this,a);return s?s.action(3,t.bind(this),o).catch(lG.bind(null,i)):t.apply(this,o)}))}function pG(){return function(e,t,i){return e.prototype[t]=function(){let e=this._log||console,i='"'.concat(t,'" is a static method. Use TRTC.').concat(t,"() instead. See: ").concat(FR,"/en/TRTC.html#.").concat(t);e.warn(i)},i}}var mG={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame",PERMISSION_STATE_CHANGE:"permission-state-change",VIDEO_SIZE_CHANGED:"video-size-changed"},fG=new Set([mG.AUDIO_VOLUME,mG.AUDIO_FRAME,mG.NETWORK_QUALITY,mG.STATISTICS,mG.SEI_MESSAGE,mG.CUSTOM_MESSAGE,mG.LAYER_DATA]),_G={};rR(_G,{ScheduleRequestType:()=>SG,getAbilityConfig:()=>RG,getScheduleDomain:()=>kG,isNeedToSchedule:()=>yG,scheduleProxy:()=>AG,sendScheduleRequest:()=>IG,setIsNeedToSchedule:()=>TG,setScheduleProxy:()=>bG});var gG=null,vG=0,EG=1728e5,yG=!0;function TG(e){QC(e)&&e!==yG&&(yG=e,rM.info("setIsNeedToSchedule ".concat(e)),e||(vG=Date.now()+EG))}function IG(e){return cR(this,arguments,(function(e){let{userId:t,sdkAppId:i,useStringRoomId:r,roomId:o,userSig:n,version:a,frameWorkType:s,role:c,latencyLevel:l}=e;return function*(){var e;if(!yG&&gG&&vG>Date.now())return{isCached:!0,result:gG};let d={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(i)),u.append("isStrGroupId",String(r)),u.append("groupId",String(o)),u.append("sdkVersion",a),u.append("userSig",String(n));let h=(null==(e=yield BO())?void 0:e.model)||jO();h&&u.append("model",h);let p=YO();p&&u.append("osString",p),c&&u.append("role",String(c)),l&&u.append("latencyLevel",String(l)),s&&u.append("frameWorkType",String(s));let m=cD(),f=yield function(e,t,i){return new Promise(((r,o)=>{let n=null;sD([DG((e=>t.count[0]=e+1),(e=>{let{error:r,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[0]=r.message,n||(a>=1&&(s[0]=wG(i,"config",ok.MAIN,!0)),o())}))(wG(i,"config",ok.MAIN),e,{get timeout(){return 1e3*GC(2+t.count[0])}}),DG((e=>t.count[1]=e+1),(e=>{let{error:r,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[1]=r.message,n||(a>=2&&(s[0]=wG(i,"config",ok.BACKUP,!0)),o())}))(wG(i,"config",ok.BACKUP),e,{get timeout(){return 1e3*GC(2+t.count[1])}})]).then((e=>{n=e,r(n)})).catch(o)}))}(u,d,i);f.config&&(f.config.loggerDomain&&LR(f.config.loggerDomain),QC(f.config.scheduleCache)&&TG(!f.config.scheduleCache)),d.delta=cD()-m;let _=function(e,t,i){let r={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),n=wG(e,"config",ok.MAIN),a=wG(e,"config",ok.BACKUP);for(let e of o)if(e.startTime>=i&&(e.name===n||e.name===a)&&e.transferSize>0){let i=e.name===n?ok.MAIN:ok.BACKUP,o=Math.round(e.duration),a=Math.round(e.domainLookupStart-e.startTime),s=e.redirectStart>0?Math.round(e.redirectEnd-e.redirectStart):0,c=e.fetchStart>0?Math.round(e.domainLookupStart-e.fetchStart):0,l=Math.round(e.domainLookupEnd-e.domainLookupStart),d=Math.round(e.requestStart-e.secureConnectionStart),u=Math.round(e.secureConnectionStart-e.connectStart),h=Math.round(e.responseStart-e.requestStart),p=Math.round(e.responseEnd-e.responseStart),m=[l,d,u,h,p];ox.uploadEvent({log:"stat-schedule-net:".concat(o,"(").concat(a,"(").concat(s,"->").concat(c,")->").concat(m.join("->"),") ").concat(i),userId:t}),r=eR(Zw({},r),{totalCost:o,local:a,dns:l,tcp:u,tls:d,request:h,response:p});break}}catch(n){rM.error("getScheduleDetailCost error",n)}return r}(Number(i),t,m);return gG=f,{isCached:!1,result:f,detailCost:_}}catch(cM){let t=ZC(cM)?cM[0]:cM,i=JC(t.code)?t.code:0,r="schedule failed".concat(t.message?": ".concat(t.message):""),o=new vR({code:_R.SCHEDULE_FAILED,extraCode:i,message:vL({key:mL.JOIN_ROOM_FAILED,data:{error:r,code:i}})});throw rM.error(r,i),o}}()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(Kk).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),$O.on("28",(()=>TG(!0))),$O.on("63",(()=>TG(!0))),$O.on("84",(()=>TG(!0))),$O.on("201",(e=>{"RECONNECTING"===e.state&&TG(!0)})),$O.on("202",(e=>{"RECONNECTING"===e.state&&TG(!0)}));var AG={main:"",backup:""};function bG(e){ZC(e)?(AG.main=e[0],AG.backup=e[1]):AG.main=e}var SG=(e=>(e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e))(SG||{});function wG(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ok.MAIN,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(AG[i]||kG(e,i,r),"/api/v1/").concat(t)}function RG(e,t,i){let r=wG(e,t),o=wG(e,t,ok.BACKUP),n=new URLSearchParams(i).toString(),a=fetch("".concat(r,"?").concat(n)).then((e=>e.json())),s=fetch("".concat(o,"?").concat(n)).then((e=>e.json()));return sD([a,s])}function kG(e){let t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ok.MAIN,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=RC(e)?r?i===ok.MAIN?Kk.MAIN_OVERSEA_BACKUP:Kk.BACKUP_OVERSEA:i===ok.MAIN?Kk.MAIN_OVERSEA:Kk.BACKUP_OVERSEA:i===ok.MAIN?Kk.MAIN:Kk.BACKUP,t}function CG(e,t,i){return new Promise(((r,o)=>{zD({url:e,body:t,timeout:i.timeout,priority:"high"}).then((e=>{0===e.data.code?r(e.data.data):o({code:e.data.code,message:e.data.msg})})).catch(o)}))}var DG=(e,t)=>$D({retryFunction:CG,settings:{retries:3,timeout:0},onError:t,onRetrying:e});var NG=class{constructor(){aR(this,"_log"),this._log=rM.createLogger({id:"fd"})}download(e,t){return cR(this,null,(function*(){let{type:i="blob"}=t||{};e=DD(e);try{let t,r=cD();if(t=KC(fetch)?yield this.downloadWithFetch(e,i):yield this.downloadWithXHR(e,i),!t||!t.data)throw new Error("data is empty");let o=cD()-r;return this._log.info("downloaded: ".concat(e,", return type: ").concat(i,", cost: ").concat(o,"ms")),CL.addSuccessEvent({key:522700,cost:cD()-r}),t.data}catch(pM){throw this._log.error("failed to download: ".concat(e,", error: ").concat(pM)),CL.addFailedEvent({key:522700,error:pM}),pM}}))}downloadWithFetch(e,t){return cR(this,null,(function*(){this._log.info("download with fetch: ".concat(e,", return type: ").concat(t));try{let i,r=yield fetch(e);if(!r.ok){let e=new Error("network response was not ok: ".concat(r.status));throw e.status=r.status,e}return i="arraybuffer"===t?yield r.arrayBuffer():yield r.blob(),{data:i}}catch(Ok){throw Ok}}))}downloadWithXHR(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise(((i,r)=>{let o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=t,o.onload=()=>{if(200===o.status||0===o.status&&o.response)i({data:o.response});else{let e=new Error("XHR failed, status: ".concat(o.status));e.status=o.status,r(e)}},o.onerror=r,o.send(null)}))}loadWasm(e,t){return cR(this,null,(function*(){this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t)));let i=cD(),r=null,o=null;if(KC(WebAssembly.instantiateStreaming)&&!(e=>e.startsWith("data:application/octet-stream;base64,"))(e)&&!(e=>e.startsWith("file://"))(e)&&KC(fetch))try{let i=fetch(e);r=(yield WebAssembly.instantiateStreaming(i,t)).instance}catch(CR){o=CR}if(!r)try{let i=yield this.download(e,{type:"arraybuffer"});r=(yield WebAssembly.instantiate(i,t)).instance}catch(CR){o=CR}if(r){let t=cD()-i;return this._log.info("loadedWasm ".concat(e,", cost: ").concat(t,"ms")),CL.addSuccessEvent({key:522701,cost:t}),r}throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),CL.addFailedEvent({key:522701,error:o}),o}))}loadScript(e){this._log.info("loadScript ".concat(e));let t=cD();return new Promise(((i,r)=>{let o=document.createElement("script");o.type="text/javascript",o.onload=()=>{this._log.info("loadedScript ".concat(e,", cost: ").concat(cD()-t,"ms")),CL.addSuccessEvent({key:522702,cost:cD()-t,split:1e3}),i(o)},o.onerror=t=>{this._log.error("failed to loadScript ".concat(e,", error: ").concat((null==t?void 0:t.message)||JSON.stringify(t))),CL.addFailedEvent({key:522702}),r(t)},o.crossOrigin="anonymous",o.src=e,document.head.append?document.head.append(o):document.getElementsByTagName("head")[0].appendChild(o)}))}};nR([ax({settings:{timeout:0,retries:3},onError(e,t,i){var r;404===(null==e?void 0:e.status)||null!=(r=null==e?void 0:e.message)&&r.includes("404")?(this._log.warn("download 404, stop retry"),i(e)):t()},onRetrying(e){this._log.warn("download retrying: ".concat(e))}})],NG.prototype,"download",1),nR([ax({settings:{timeout:3e3,retries:3},onRetrying(e){this._log.warn("loadScript retrying: ".concat(e))}})],NG.prototype,"loadScript",1);var OG=new NG;function MG(e){var t=this;let{TRTC:i,room:r,errorModule:o,assetsPath:n}=e;return{TRTC:i,LocalMixVideoTrack:HB,LocalVideoTrack:mB,LocalScreenTrack:GB,room:r,assetsPath:n,fileDownloader:OG,innerEmitter:$O,INNER_EVENT:eM,constants:bR,environment:eN,utils:fB,eventLogger:ox,log:this.room.getLogger(),loggerManager:rM,errorModule:o,kvStatManager:CL,rtcDectection:aM,trtc:this,rx:WU,enums:sM,schedule:_G,getDevices:hU,initVisionTaskRegistry:function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/mediapipe/vision.js";return cR(t,null,(function*(){window.VisionTaskRegistry||(yield OG.loadScript("".concat(e,"/").concat(i).replace(/([^:]\/)\/+/g,"$1"))),yield(yield window.VisionTaskRegistry.getInstance(e)).preloadModels([window.VisionTaskType.ImageSegmenter])}))},audioContext:Yx(),deviceDetector:dU,AudioPlayer:TU,showAutoPlayDialog:Nx,Timer:$P,clearStarted:(e,t)=>{let i=e.getAlias(),r=sG.instances.get(this);if(r)if(t){let e=r.get(i+t);if(!e)return;e.started=!1}else r.forEach(((e,t)=>{t.startsWith(i)&&(e.started=!1)}))},startGetPCM:KB,createAudioNode:tU,getNetworkTimeOffset:ER,validateSourceNode:()=>{var e;if(_N&&(null==(e=this.room.audioManager._localAudioPipline)||!e.source.node))throw new Bj({code:Pj.DEVICE_ERROR,extraCode:5310,message:"The audio processing plugin cannot be used due to the microphone's sampling rate is not 48KHz in Firefox. Please switch to another browser such as Chrome."})}}}var LG=new WeakMap;function PG(e,t){return MU(((i,r)=>function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];let a=LG.get(this);a||(a=new Map,LG.set(this,a));let s=t(...o),c=a.get(s);if(!c||c<=0){i.apply(this,o);let t=setTimeout((()=>{var e;null==(e=LG.get(this))||e.delete(s)}),e);a.set(s,t)}else{clearTimeout(c);let t=window.setTimeout((()=>{var e;i.apply(this,o),null==(e=LG.get(this))||e.delete(s)}),e);a.set(s,t)}}))}var xG="5.14.2-wasm.2";function UG(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MU(((e,i)=>function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];try{FG.call(this,t,o,i,this._name)}catch(pM){return Promise.reject(pM)}return e.apply(this,o)}))}function VG(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MU(((e,i)=>function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];try{FG.call(this,t,o,i,this._name)}catch(pM){throw pM}return e.apply(this,o)}))}function FG(e,t,i,r){if(ZC(e))for(let o=0;o<e.length;o++)BG.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:i,className:r});else BG.call(this,{rule:e,value:t[0],key:e.name,fnName:i,className:r})}function BG(e){let{rule:t,value:i,key:r,fnName:o,className:n}=e;function a(e){return{code:Pj.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:r,rule:t,value:i}}}if(YC(i)){if(t.required)throw new Bj(a(5001));if(YC(t.defaultValue))return void(KC(t.validate)&&t.validate.call(this,i,r,o,n,this));i=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let r=0;r<t.type.length;r++)null===t.type[r]&&null===i&&(e=!0),KC(t.type[r])&&i instanceof t.type[r]&&(e=!0),XC(t.type[r])&&qC(i)===t.type[r].toLowerCase()&&(e=!0);if(!e)throw new Bj({code:Pj.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:r,rule:{type:t.type.map((e=>rD(e)?oD(e):XC(e)?e:qC(e)))},value:i}})}else if(!YC(t.type)&&qC(i)!==t.type)throw new Bj(a(5002));if(!1===t.allowEmpty){let e=JC(i)&&(0===i||Number.isNaN(i)),t=XC(i)&&""===i.trim();if(e||t)throw new Bj(a(5003))}if(t.notLessThanZero&&JC(i)&&i<0)throw new Bj(a(5006));if(!YC(t.min)&&JC(i)&&i<t.min)throw new Bj(a(5007));if(!YC(t.max)&&JC(i)&&i>t.max)throw new Bj(a(5008));if(XC(t.instanceOf)){if(!i||i._name!==t.instanceOf)throw new Bj(a(5004))}else if(KC(t.instanceOf)&&!(i instanceof t.instanceOf))throw new Bj(a(5004));if(Array.isArray(t.values)&&!t.values.includes(i))throw new Bj(a(5005));let{properties:s}=t;jC(s)&&$C(i)&&Object.keys(s).forEach((e=>{BG.call(this,{rule:s[e],value:i&&i[e],key:"".concat(e),fnName:o,className:n})}));let{arrayItem:c}=t;jC(c)&&ZC(i)&&i.forEach(((e,t)=>{BG.call(this,{rule:c,value:e,key:"".concat(r,"[").concat(t,"]"),fnName:o,className:n})})),KC(t.validate)&&t.validate.call(this,i,r,o,n,this)}function HG(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=()=>"",replaceArg:i,getKVReportKey:r,ignoreLog:o,ignoreErrorLog:n}=e;return MU(((e,a)=>function(){for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];var d,u,h;function p(e,t,r){if(r&&r.includes(e))return"hided";if(i){let e=i(...c);if(c[e.argIndex]===t)return e.value}if(t===c||e in c)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(qC(t)):t instanceof MediaStreamTrack?ND(t):(JSON.stringify(t),t)}catch(EL){return"type:".concat(qC(t))}}let m=this._log||rM;if(null!=o&&o(...c))return e.apply(this,c);c.length>0?m.info("".concat(a,"() ").concat(JSON.stringify(c,((e,t)=>p(e,t,["userSig","privateMapKey"]))))):m.info("".concat(a,"()"));let f=r?r(...c):IL[a],_=(null==n?void 0:n(...c))||!1;try{let i=e.apply(this,c),r=cD();if(iD(i)){let e="".concat(a.includes("Plugin")?"".concat((null==(u=(d=c[0]).getName)?void 0:u.call(d))||""," "):" ");return i.then((i=>(m.info("".concat(a,"() success ").concat(e).concat(t.call(this,...c))),CL.addSuccessEvent({key:f,cost:cD()-r}),i))).catch((i=>{var r;let o=(i=Bj.convertFrom.call(this,i,a,1===c.length?c[0]:c)).extraCode||i.code,n=null!=(r=i.message)&&r.includes(o)?"":" code:".concat(o);throw _||m.error("".concat(a,"() failed ").concat(e).concat(t.call(this,...c)," ").concat(i).concat(n," params: ").concat(JSON.stringify(c,p))),CL.addFailedEvent({key:f,error:i}),i}))}return CL.addSuccessEvent({key:f}),i}catch(gM){let t=(gM=Bj.convertFrom.call(this,gM,a)).extraCode||gM.code,i=null!=(h=gM.message)&&h.includes(t)?"":" code:".concat(t);throw _||m.error("".concat(a,"() failed ").concat(gM).concat(i," params: ").concat(JSON.stringify(c,p))),CL.addFailedEvent({key:f,error:gM}),gM}}))}var WG,jG=e=>MU(((t,i)=>function(r,o){return cR(this,null,(function*(){let n=this._plugins.get(r);if(!n)throw this._log.error("plugin ".concat(String(r)," is not found")),new Bj({code:Pj.OPERATION_ABORT,message:"plugin ".concat(String(r)," is not found"),fnName:i});if(KC(n.constructor.isSupported)&&!n.constructor.isSupported())throw this._log.error("plugin ".concat(String(r)," is not supported")),new Bj({code:Pj.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(r)," is not supported"),extraCode:5210,fnName:i});return FG.call(this,n.getValidateRule(e),[o],i,"TRTC"),t.call(this,n,o)}))})),GG=0,zG=class e{constructor(e){this.core=e,aR(this,"log"),aR(this,"customAudioReferenceMap",new Map),aR(this,"audioRefId",0),aR(this,"audioContext",Yx()),aR(this,"localAudioWorkletNode"),aR(this,"screenAudioWorkletNode"),aR(this,"mixNode"),aR(this,"silentNode"),GG+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(GG)}),this.log.info("created id=".concat(this.getAlias()).concat(GG)),this.installEvent()}static getStartValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,i,r,o){if(!e.room.audioManager.hasAudioTrack&&!e.room.audioManager.hasScreenAudioTrack)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5106,fnName:r})}}}preload(e){return WG||(WG=this.doPreload(e)),WG}doPreload(e){return cR(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),i=URL.createObjectURL(t);try{yield Lx(this.audioContext,i)}catch(pM){this.log.error("preload audioProcessor failed. ".concat(pM))}finally{URL.revokeObjectURL(i)}}))}getName(){return e.Name}getAlias(){return"ap"}getGroup(){return"ap"}getValidateRule(t){switch(t){case"start":return e.getStartValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return cR(this,null,(function*(){var t,i,r,o;let{room:n}=this.core,{sdkAppId:a,userId:s,userSig:c,assetsPath:l=this.core.assetsPath,audioReference:d,processLevel:u,enableDump:h,isLocalAudioNeedAudioProcess:p=!0,isScreenAudioNeedAudioProcess:m=!1}=e;if(this.core.room.audioManager.isLocalAudioNeedAudioProcess=p,this.core.room.audioManager.isScreenAudioNeedAudioProcess=m,!l)throw new Bj({code:Pj.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(l,"/audioProcessor-wasm.js")),p&&!this.localAudioWorkletNode){let{sign:e,status:t,timestamp:i}=yield this.getAuthData(a,s,c);this.localAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.localAudioWorkletNode,"localAudio",a,s,i,e,t,n)}if(m&&!this.screenAudioWorkletNode){let{sign:e,status:t,timestamp:i}=yield this.getAuthData(a,s,c);this.screenAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.screenAudioWorkletNode,"screenAudio",a,s,i,e,t,n)}this.mixNode||(this.mixNode=this.audioContext.createGain(),this.mixNode.gain.value=1),this.silentNode||(this.silentNode=this.audioContext.createConstantSource(),this.silentNode.offset.setValueAtTime(0,this.audioContext.currentTime),this.silentNode.start()),null==(t=this.localAudioWorkletNode)||t.port.postMessage({type:"enable"}),null==(i=this.screenAudioWorkletNode)||i.port.postMessage({type:"enable"}),n.audioManager.addAudioProcessor(this.mixNode,this.silentNode,this.localAudioWorkletNode,this.screenAudioWorkletNode),YC(d)||d.forEach((e=>{this.customAudioReferenceMap.set(e,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:e,refId:"o-".concat(this.audioRefId++)})})),YC(u)||null==(r=this.localAudioWorkletNode)||r.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:u}}),YC(h)||null==(o=this.localAudioWorkletNode)||o.port.postMessage({type:"dump",data:{enable:h}})}))}update(e){return cR(this,null,(function*(){var t,i,r;let{audioReference:o,enableDump:n,processLevel:a}=e;YC(o)||(this.customAudioReferenceMap.forEach(((e,t)=>{this.customAudioReferenceMap.delete(t),this.core.room.audioManager.updateAudioReference({type:"remove",refId:e})})),o.forEach((e=>{this.customAudioReferenceMap.set(e,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:e,refId:"o-".concat(this.audioRefId++)})}))),YC(a)||null==(t=this.localAudioWorkletNode)||t.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:a}}),YC(n)||(null==(i=this.localAudioWorkletNode)||i.port.postMessage({type:"dump",data:{enable:n}}),null==(r=this.screenAudioWorkletNode)||r.port.postMessage({type:"dump",data:{enable:n}}))}))}stop(){return cR(this,null,(function*(){var e,t;let{room:i}=this.core;null==(e=this.localAudioWorkletNode)||e.port.postMessage({type:"disable"}),null==(t=this.screenAudioWorkletNode)||t.port.postMessage({type:"disable"}),yield i.audioManager.removeAudioProcessor(this.localAudioWorkletNode,this.screenAudioWorkletNode)}))}destroy(){this.localAudioWorkletNode&&(this.localAudioWorkletNode.port.onmessage=null),this.screenAudioWorkletNode&&(this.screenAudioWorkletNode.port.onmessage=null),this.uninstallEvent()}getAuthData(e,t,i){return cR(this,null,(function*(){let r=String(Date.now()).slice(0,-3),{auth:o,sign:n,status:a,message:s}=yield function(e){return cR(this,arguments,(function(e){let{sdkAppId:t,userId:i,userSig:r,timestamp:o}=e;return function*(){let e="".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ok.MAIN;return"https://".concat(AG[t]||kG(e,t),"/api/v1/audioAiAuth")}(t),"?sdkAppId=").concat(t,"&userId=").concat(i,"&userSig=").concat(r,"&timestamp=").concat(o),n=yield fetch(e),{data:{errCode:a,errMsg:s,sign:c,status:l}}=yield n.json();if("1"===l)return{auth:!0,sign:c,status:l,message:s};let d=RC(t)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",u="Init RTCAudioProcessor failed.",h="";switch(a){case 1:h="Please check your params.";break;case 2:h="You need to buy packages. Refer to: ".concat(d);break;case 3:h="Server is invalid. Please contact our engineer. ";break;case 4:h="Your packages is not active. Refer to: ".concat(d);break;case 5:h="Your packages is expired. Refer to: ".concat(d);break;case 6:h="Your version is not supported."}return{auth:!1,status:l,message:s?"".concat(u," Reason: ").concat(s,". ").concat(h):"".concat(u,", ").concat(h)}}()}))}({sdkAppId:e,userSig:i,userId:t,timestamp:r});if(!o)throw this.log.info("audioProcessor: ".concat(t," auth result: ").concat(o,". Message: ").concat(s)),new Bj({code:Pj.INVALID_PARAMETER,message:s});return{sign:n,status:a,timestamp:r}}))}initWorkletNode(e,t,i,r,o,n,a,s){e.port.postMessage({type:"init",data:{sdkAppId:String(i),userId:r,timestamp:o,sign:n,status:a}}),e.port.onmessage=e=>{var i;let{data:r}=e;switch(r.type){case"cost":let e=(null==r?void 0:r.value)>10?"info":"debug";return void this.log[e]("".concat("localAudio"===t?"":"[".concat(t,"] "),"avg cost: ").concat(r.value," max: ").concat(null==r?void 0:r.max,"(").concat(IR(new Date(null==r?void 0:r.maxCostTimestamp)),") hist: ").concat(null==(i=null==r?void 0:r.hist)?void 0:i.join(" ")));case"log":return void this.log[r.logLevel]("".concat("localAudio"===t?"":"[".concat(t,"] ")).concat(r.value));case"dump":return void $O.emit("265",{room:s,data:r.value,type:"localAudio"===t?"dump":"dump-screen-audio"})}}}handleLocalAudioStarted(e){return cR(this,null,(function*(){var t;if(this.hitTest(e.room)&&!0===(null==(t=this.core.room.scheduleResult.config)?void 0:t.audioProcessor))try{yield this.core.trtc.startPlugin("AudioProcessor",{sdkAppId:this.core.room.sdkAppId,userId:this.core.room.userId,userSig:this.core.room.userSig}),this.log.warn("audio processor auto start success")}catch(Ok){this.log.warn("audio processor auto start failed, error: ".concat(Ok))}}))}handleLocalAudioStopped(e){return cR(this,null,(function*(){var t;!this.hitTest(e.room)||!0!==(null==(t=this.core.room.scheduleResult.config)?void 0:t.audioProcessor)||(yield this.core.trtc.stopPlugin("AudioProcessor"))}))}installEvent(){this.core.innerEmitter.on("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.on("114",this.handleLocalAudioStopped,this)}uninstallEvent(){this.core.innerEmitter.off("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.off("114",this.handleLocalAudioStopped,this)}hitTest(e){return e===this.core.room}};aR(zG,"updateValidateRule",{type:"object"}),aR(zG,"stopValidateRule",{type:"object"}),aR(zG,"Name","AudioProcessor");var qG=zG;var KG=0,YG=class{constructor(e,t){aR(this,"audioObjectURL"),aR(this,"player"),aR(this,"publisher"),aR(this,"mixInput"),this.mixInput=new $x(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}updateSettings(e){this.player&&(YC(e.volume)||(this.volume=e.volume),YC(e.loop)||(this.loop=e.loop),YC(e.playbackRate)||(this.playbackRate=e.playbackRate))}updateListener(e){if(this.player){if(e.onDurationChange){let{onDurationChange:t}=e;this.player.ondurationchange=e=>{t(e.target.duration)}}if(e.onTimeUpdate){let t=e.onTimeUpdate,{player:i}=this;i.ontimeupdate=()=>{t(i.currentTime,i.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}reload(e){return cR(this,null,(function*(){if(e.url){let t=yield OG.download(e.url,{retries:3,type:"blob"});this.audioObjectURL&&URL.revokeObjectURL(this.audioObjectURL),this.audioObjectURL=URL.createObjectURL(t),this.player&&this.publisher?(this.player.src=this.audioObjectURL,this.publisher.src=this.audioObjectURL):(this.player=new Audio(this.audioObjectURL),this.player.crossOrigin="anonymous",this.publisher=new Audio(this.audioObjectURL),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher),this.updateListener(e),this.updateSettings(e))}else this.mixInput.replaceSource(e.track)}))}reset(){this.seek(0),this.mixInput.connect()}seek(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}play(){var e,t;return Promise.all([null==(e=this.player)?void 0:e.play(),null==(t=this.publisher)?void 0:t.play()])}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}set playbackRate(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}};function XG(e,t){if(t&&"function"!=typeof t)throw new Bj({code:Pj.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var JG=class e{constructor(e){this.core=e,aR(this,"log"),aR(this,"mixedMusicMap",new Map),aR(this,"cacheMusicMap",new Map),KG+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(KG)}),this.log.info("created id=".concat(this.getAlias()).concat(KG))}getName(){return e.Name}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return cR(this,null,(function*(){let{room:t}=this.core;this.core.validateSourceNode(),this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:i,url:r}=e;if(this.mixedMusicMap.has(i))return;let o=this.cacheMusicMap.get(i);o?e.url?o.reset():(o.mixInput.replaceSource(e.track),o.mixInput.connect()):(o=new YG(e,t.audioManager),this.cacheMusicMap.set(i,o)),o.updateListener(e),o.updateSettings(e);try{yield o.play()}catch(CR){yield this.handleAutoPlayFailed(o,e,CR)}this.mixedMusicMap.set(i,o),o.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"add",audioReference:o.mixInput.source.node,refId:"ax-".concat(i)}),this.log.info("start mix audio track ".concat(i," success.")),CL.addEnum({key:502700,value:3}),this.kvUpload(e)}))}handleAutoPlayFailed(e,t,i){return cR(this,null,(function*(){if("NotSupportedError"===i.name)this.log.error("play failed, try to reload source. error: ".concat(i)),yield e.reload(t),yield e.play();else{if("NotAllowedError"!==i.name)throw i;if(this.core.room.enableAutoPlayDialog){let t=()=>{var i;null==(i=e.play())||i.finally((()=>{$O.off("154",t,this)}))};$O.on("154",t,this),Nx()}else this.core.trtc.emit(mG.AUTOPLAY_FAILED,{userId:"",mediaType:"audio",resume:()=>cR(this,null,(function*(){return e.play()}))})}}))}update(e){return cR(this,null,(function*(){let{id:t,operation:i,seekFrom:r,playbackRate:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let n=this.mixedMusicMap.get(t);n?(n.updateSettings(e),n.updateListener(e),YC(i)||n.setOperation(i),YC(r)||n.seek(r),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return cR(this,arguments,(function(e){var t=this;let{id:i}=e;return function*(){if(t.mixedMusicMap.has(i)){t.log.info("remove music source, music id: ".concat(i));let e=t.mixedMusicMap.get(i);null!=e&&e.mixInput.source.node&&t.core.room.audioManager.updateAudioReference({type:"remove",audioReference:e.mixInput.source.node,refId:"ax-".concat(i)}),null==e||e.stop(),t.mixedMusicMap.delete(i)}"*"===i&&t.destroyAllMusic()}()}))}kvUpload(e){let{track:t,loop:i,volume:r,playbackRate:o,operation:n,seekFrom:a,onTimeUpdate:s,onDurationChange:c,onEnded:l}=e;t&&CL.addCount({key:502009}),i&&CL.addCount({key:502001}),r&&CL.addCount({key:502002}),o&&CL.addCount({key:502003}),n&&CL.addCount({key:502004}),a&&CL.addCount({key:502005}),"function"!=typeof s&&CL.addCount({key:502007}),"function"!=typeof l&&CL.addCount({key:502008}),"function"!=typeof c&&CL.addCount({key:502006})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>{null!=e&&e.mixInput.track&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:e.mixInput.track,refId:t}),this.stop({id:t})}))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};aR(JG,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,i){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],r=["mp3","ogg","wav","flac"],o=t.split(".").pop(),n=r.indexOf(o)>=0,a=t.startsWith("blob"),s=t.startsWith("data");if(!(n||a||s))throw new Bj({code:Pj.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:i})}if(!e.url&&!e.track)throw new Bj({code:Pj.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:i});XG("onTimeUpdate",e.onTimeUpdate),XG("onEnded",e.onEnded),XG("onDurationChange",e.onDurationChange)}}),aR(JG,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(e,t,i){XG("onTimeUpdate",e.onTimeUpdate),XG("onEnded",e.onEnded),XG("onDurationChange",e.onDurationChange)}}),aR(JG,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),aR(JG,"Name","AudioMixer");var QG,$G=JG,ZG=0,ez=class e{constructor(e){this.core=e,aR(this,"log"),aR(this,"audioContext",Yx()),aR(this,"workletNode"),aR(this,"config",{enableFarFieldReduce:!1,farFieldReduceThreshold:.5}),ZG+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(ZG)}),this.log.info("created id=".concat(this.getAlias()).concat(ZG))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0},mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}},validate(t,i,r,o){if(!e.room.audioManager.hasAudioTrack)throw new Bj({code:Pj.INVALID_OPERATION,extraCode:5106,fnName:r})}}}preload(e){return QG||(QG=this.doPreload(e)),QG}doPreload(e){return cR(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),i=URL.createObjectURL(t);try{yield Lx(this.audioContext,i)}catch(pM){throw this.log.error("load worklet failed",pM),pM}finally{URL.revokeObjectURL(i)}}))}getName(){return e.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser"}getValidateRule(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return cR(this,null,(function*(){let{room:t,schedule:i}=this.core,{assetsPath:r=this.core.assetsPath}=e;if(!r)throw new Bj({code:Pj.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(r,"/denoiser-wasm").concat(bP()?"":"-nosimd",".js")),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:r,sign:o,status:n,message:a}=yield function(e,t){return cR(this,arguments,(function(e,t){let{sdkAppId:i,userId:r,userSig:n,timestamp:a}=t;return function*(){try{let{data:{errCode:t,errMsg:o,sign:s,status:c}}=yield e.getAbilityConfig(i,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:i,userId:r,userSig:n,timestamp:a});if("1"===c)return{auth:!0,sign:s,status:c,message:o};let l=RC(i)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",d="Init RTCAIDenoiser failed.",u="";switch(t){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: ".concat(l);break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: ".concat(l);break;case 5:u="Your packages is expired. Refer to: ".concat(l);break;case 6:u="Your version is not supported."}return{auth:!1,status:c,message:o?"".concat(d," Reason: ").concat(o,". ").concat(u):"".concat(d,", ").concat(u)}}catch(o){return{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(o)}}}()}))}(i,eR(Zw({},e),{timestamp:t}));if(!r)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(r,". Message: ").concat(a)),new Bj({code:Pj.INVALID_PARAMETER,message:a});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:o,status:n}}),this.workletNode.port.onmessage=e=>{var t;let{data:i}=e;if("cost"===i.type){let e=(null==i?void 0:i.max)>20?"warn":(null==i?void 0:i.max)>10?"info":"debug";this.log[e]("avg cost: ".concat(i.value," max: ").concat(null==i?void 0:i.max,"(").concat(IR(new Date(null==i?void 0:i.maxCostTimestamp)),") hist: ").concat(null==(t=null==i?void 0:i.hist)?void 0:t.join(" ")))}else"log"===i.type&&this.log[i.logLevel]("".concat(i.value))}}this.updateConfig(e),this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(e){return cR(this,null,(function*(){this.updateConfig(e)}))}stop(){return cR(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}updateConfig(e){if(!this.workletNode)return;let t=!1;YC(e.mode)||(0===e.mode?this.config.enableFarFieldReduce=!1:1===e.mode&&(this.config.enableFarFieldReduce=!0),t=!0),YC(e.farFieldReduceThreshold)||(this.config.farFieldReduceThreshold=e.farFieldReduceThreshold,t=!0),t&&this.workletNode.port.postMessage({type:"setConfig",data:this.config})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};aR(ez,"updateValidateRule",{type:"object",properties:{mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}}}),aR(ez,"stopValidateRule",{type:"object"}),aR(ez,"Name","AIDenoiser");var tz=ez;var iz=oR(lR(),1),rz=class extends iz.EventEmitter{constructor(){super(),aR(this,"observer"),aR(this,"state","nominal"),this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return cR(this,null,(function*(){if(!this.observer)try{"PressureObserver"in window&&!hN&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(kR){ox.uploadEvent({log:"stat-pressure-detector-start-failed",error:kR})}}))}onPressureChange(e){let t=this.stateNum,i=e[e.length-1];this.state=i.state,(this.stateNum>3||t>3)&&rM.info("".concat(i.source,": ").concat(i.state)),this.emit("state-changed",{type:i.source,state:this.state})}destroy(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(Ok){ox.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:Ok})}}},oz=new rz;function nz(e){let[t,i]=e,r=i.byteLength,o=parseInt(String(r/255),10),n=r%255,a=[];a.push(0,0,0,1,6,t);for(let c=0;c<o;c++)a.push(255);a.push(n);let s=new DataView(i);return a.push(...new Uint8Array(s.buffer)),a.push(128),new uB(new DataView(new Uint8Array(a).buffer),!0)}function az(e){let{frame:t,seiMessageList:i}=e;if(!i||0===i.length||0===t.data.byteLength)return t;let r=9-function(e){let t=0,i=0,r=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(r.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&i++,t=0;break;default:t=0}return i}(t.data);if(r<=0)return t;let o=i.splice(0,r).reverse().map(nz),n=o.reduce(((e,t)=>e+t.dataView.byteLength),0),a=new ArrayBuffer(n+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),l=0;for(let d=0;d<o.length;d++)for(let e=0;e<o[d].dataView.byteLength;e++)s.setInt8(l++,o[d].dataView.getInt8(e));for(let d=0;d<t.data.byteLength;d++)s.setInt8(l++,c.getInt8(d));return t.data=a,t}function sz(e){let{frame:t,onSEI:i}=e;try{let e=new DataView(t.data);if(function(e){return"empty"===e.type||0===e.data.byteLength}(t)||!function(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}(e))return t;let r=[],o=0,n=-1,a=-1;for(let i=0;i<t.data.byteLength;i++){let s=e.getUint8(i);if(0===s)o++;else if(1===s){if(2===o||3===o){let s=i-o;if(-1===n?n=s:-1===a&&(a=s,r.push(new uB(new DataView(e.buffer.slice(n,a)))),n=s,a=-1),6!==e.getUint8(i+1)){t.data=e.buffer.slice(s);break}}o=0}else o=0}null==i||i(r.reverse())}catch(kR){}return t}var cz=0,lz=class e{constructor(e){this.core=e,aR(this,"log"),aR(this,"_seiMessageList",[]),aR(this,"_smallSeiMessageList",[]),aR(this,"_subStreamSeiMessageList",[]),cz++,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(cz)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(cz)),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode(e){let{frame:t,mediaType:i}=e;try{return az({frame:t,seiMessageList:8===i?this._smallSeiMessageList:2===i?this._subStreamSeiMessageList:this._seiMessageList})}catch(Ok){this.log.warn(Ok)}return t}decode(e){let{frame:t,track:i}=e;return sz({frame:t,onSEI:e=>{e.forEach((e=>{this.core.trtc.emit(mG.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:i.userId,streamType:2===i.mediaType?"sub":"main"})}))}})}destroy(){this.log.debug("destroy"),this.stop(),delete this.core}getValidateRule(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:gP?this.encode:az,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:gP?this.decode:sz,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update(e){let{buffer:t,options:i}=e;var r;let o=[i.seiPayloadType,t],n=!!i.small;i.toSubStream?this._subStreamSeiMessageList.push(o):(this._seiMessageList.push(o),n&&this._smallSeiMessageList.push(o)),null==(r=this.core.room.scriptTransformWorker)||r.postMessage({type:"sei",data:o,isMain:!i.toSubStream,small:n})}getName(){return e.Name}getAlias(){return"sei"}getGroup(){return"sei"}};aR(lz,"autoStart",!0),aR(lz,"Name","SEI");var dz=lz;function uz(e){let{frame:t,onDump:i}=e;return null==i||i(),t}function hz(e){let{frame:t,onDump:i}=e;return null==i||i(),t}function pz(e){let{frame:t,onDump:i}=e;return null==i||i(),t}function mz(e){let{frame:t,onDump:i}=e;return null==i||i(),t}var fz="Log",_z="Network",gz="Dump",vz="Dumping",Ez="End",yz="Upload Log",Tz="Export Log",Iz="Hide",Az="goBottom",bz="backTop",Sz="Clear Log",wz="Uplink",Rz="Downlink",kz="No Data",Cz="Basic",Dz="Duration",Nz="Video",Oz="Audio",Mz="Screen",Lz={"play() error: NotAllowedError:":{tips:e=>e.includes("main <video>")||e.includes("main <audio>")?"Remote stream auto play is restricted and playback fails":"Local stream playback failure, generally only occurs in Android WeChat devices, no need to handle",color:"red",class:"red"},"updateStream() try to recover local stream":{tips:"Device acquisition exception, automatic recovery is in progress"},"updateStream() recover local stream successfully":{tips:"Device acquisition exception, automatic recovery is successful"},"updateStream() failed to recover local stream":{tips:"Device acquisition exception, automatic recovery failed"},"main stream - video track is muted":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is muted":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is muted":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unable to provide media output":{tips:"Indicates that the received video data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - audio track is unable to provide media output":{tips:"Indicates that the received audio data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"auxiliary stream - video track is unable to provide media output":{tips:"Indicates that the received screen sharing data is not enough for playback. This is usually caused by network reasons. When enough data is received for playback, the state will change to unmuted."},"main stream - video track is unmuted":{tips:"Received enough playback video data"},"main stream - audio track is unmuted":{tips:"Received enough playback audio data"},"auxiliary stream - video track is unmuted":{tips:"Received enough playback screen sharing data"},"main stream - audio player track is ended":{tips:"Remote audio track stopped"},"main stream - video player track is ended":{tips:"Remote video track stopped"},"auxiliary stream - video player track is ended":{tips:"Received enough playback screen sharing data"},"stream - video track is muted":{tips:"Camera capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"stream - video track is unable to provide media output":{tips:"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked, and the customer needs to re-acquire. SDK v4.11.4+ will automatically resume acquisition without customer intervention",color:"orange"},"video track is unable to provide media output":{tips:e=>e.includes("↓")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"The camera acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"video player track is ended":{tips:"The camera acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"stream - audio track is muted":{tips:"Microphone capture is paused, usually due to the device being occupied by other applications or the browser media permission being revoked. The client needs to re-capture.",color:"orange"},"audio track is unable to provide media output":{tips:e=>e.includes("↓")?"The remote track is temporarily unable to decode data, which may be caused by network fluctuations":"Microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio track is unable to provide media output":{tips:"The microphone acquisition is paused, usually because the device is occupied by other applications or the browser media permissions are revoked. The SDK will automatically resume the acquisition.",color:"orange"},"stream - audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"audio player track is ended":{tips:"The microphone acquisition stops, usually because the device is unplugged. In this case, the SDK will automatically resume acquisition, and the access side does not need to handle it. It may also be caused by the device being occupied by other applications or the browser media permissions being reclaimed. It is recommended to remind the user to re-acquire on the page."},"is adding audio track to current published local stream":{tips:"add audio track",color:"orange"},"is removing audio track from current published local stream":{tips:"remove audio track",color:"orange"},"is removing video track from current published local stream":{tips:"remove video track",color:"orange"},"is adding video track to current published local stream":{tips:"add video track",color:"orange"},"is replacing audio track to current published local main stream":{tips:"replace audio track",color:"orange"},"is replacing video track to current published local main stream":{tips:"replace video track",color:"orange"},"downlink network quality change":{tips:"Downstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"uplink network quality change":{tips:"Upstream network quality change: 1: excellent, 2: good, 3: average, 4: poor, 5: extremely poor"},"localStream mute video":{tips:"mute upstream video stream",color:"orange"},"localStream unmute video":{tips:"unmute upstream video stream",color:"orange"},"localStream mute audio":{tips:"mute upstream audio stream",color:"orange"},"localStream unmute audio":{tips:"unmute upstream audio stream",color:"orange"},"black detected":{tips:"Detect black screen, which means fps = 0. It is usually caused by network, and the network will be recovered after a while. If the network is normal but has not been restored, it is an abnormal situation."},'main stream start to play with options: {"muted":true}':{tips:"Play the remote stream in silent mode. Generally, the remote stream does not need to be played in silent mode. You need to confirm whether the parameters passed in the client stream.play API call are correct.",color:"orange"},"main stream - audio player is starting playing":{tips:"Remote stream audio playback success",color:"#0dd90d",class:"success"},"main stream - video player is starting playing":{tips:"Remote stream video playback success",color:"#0dd90d",class:"success"},"video player is playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"audio player is playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"stream - video player is starting playing":{tips:"Local video playback success",color:"#0dd90d",class:"success"},"stream - audio player is starting playing":{tips:"Local audio playback success",color:"#0dd90d",class:"success"},"switch camera success":{tips:"Switch camera success",color:"#0dd90d",class:"success"},"switch microphone success":{tips:"Switch microphone success",color:"#0dd90d",class:"success"},gotStream:{tips:"Local stream capture success"},"local stream is published successfully":{tips:"Publish success",color:"#0dd90d",class:"success"},"encoderImplementation change to OpenH264":{tips:"Use software encoding"},"encoderImplementation change to ExternalEncoder":{tips:"Use hardware encoding"},"getUserMedia with constraints":{tips:"Start media (camera/microphone) capture"},"getDisplayMedia with constraints":{tips:"Start screen sharing capture"},"client-banned":{tips:"Kicked out of the room",color:"red",class:"red",textColor:"#fff"},user_timeout:{tips:"The backend is too long without receiving SDK heartbeat, which is usually caused by the JS thread being blocked for a long time. If the reproduction probability is high, the application browser Performance tool analyzes where the JS thread is blocked.",color:"red",class:"red",textColor:"#fff"},"schedule failed":{tips:"Signaling request failed, does not affect the normal room entry process, SDK will connect to the default signaling domain."},"updateStream() video flag is true, but no camera detected, set video to false":{tips:"When trying to resume camera acquisition, the camera acquisition is not resumed because it is detected that there is no camera.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to bandwidth":{tips:"bandwidth estimation is not enough to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"qualityLimitationReason change to cpu":{tips:"cpu load is too high to limit the quality of the encoding, which may cause the code rate, frame rate, and resolution to be lowered.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: hidden":{tips:"User page switched to backend, in mobile devices, this will cause the device to pause the capture, and it will be restored when the user switches backend to the frontend.",color:"orange",class:"orange",textColor:"#fff"},"visibility change: visible":{tips:"User page switched to frontend",color:"orange",class:"orange",textColor:"#fff"},"main stream - audio player is paused":{tips:"The remote stream audio playback is paused, which usually has two possibilities:\n 1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.\n 2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.",color:"orange",class:"orange",textColor:"#fff"},"main stream - video player is paused":{tips:"The remote stream video playback is paused, which usually has two possibilities:\n 1. The business side passes in the div tag container for playing audio and video to be removed by the business side from the DOM.\n 2. If the user is in Chrome 70 and below, when the div container is moved, the playback will be paused.",color:"orange",class:"orange",textColor:"#fff"},'"displaySurface":"window"':{tips:"Screen sharing captures the application window",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"monitor"':{tips:"Screen sharing captures the entire screen",color:"blue",class:"blue",textColor:"#fff"},'"displaySurface":"browser"':{tips:"Screen sharing captures a certain tab page",color:"blue",class:"blue",textColor:"#fff"},updateMediaSettings:{tips:"The resolution and frame rate below are the actual resolution and frame rate captured",color:"blue",class:"blue",textColor:"#fff"},"main stream start to play with":{tips:"Call remoteStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"stream start to play with":{tips:"Call localStream.play interface",color:"blue",class:"blue",textColor:"#fff"},"main setAudioVolume to 0":{tips:"Business side calls remoteStream.setAudioVolume(0) interface to set the playback volume to 0, which will cause the playback to be silent",color:"orange",class:"orange",textColor:"#fff"},"screen sharing was stopped because the video track is ended":{tips:"Screen sharing capture stopped, possible reasons: user clicks the stop button, the window/page shared by the user is closed, etc.",color:"orange",class:"orange",textColor:"#fff"},"Join() => joining room":{tips:"Call client.join interface",color:"blue",class:"blue",textColor:"#fff"},"publish() => publishing local stream":{tips:"Call client.publish interface",color:"blue",class:"blue",textColor:"#fff"},"subscribe() => subscribe to":{tips:"Call client.subscribe interface",color:"blue",class:"blue",textColor:"#fff"},"switchRole() => switch role":{tips:"Call client.switchRole interface",color:"blue",class:"blue",textColor:"#fff"}};["enterRoom","exitRoom","switchRole","destroy","startLocalAudio","updateLocalAudio","stopLocalAudio","startLocalVideo","updateLocalVideo","stopLocalVideo","startScreenShare","updateScreenShare","stopScreenShare","startRemoteVideo","updateRemoteVideo","stopRemoteVideo","muteRemoteAudio","setRemoteAudioVolume"].forEach((e=>{Lz["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}}));var Pz=Object.keys(Lz),xz=oR(mR()),Uz="trtc_debug_dialog",Vz="".concat(Uz,"_activated"),Fz="".concat(Uz,"_switch"),Bz="".concat(Uz,"_mask"),Hz="".concat(Uz,"_panel"),Wz="".concat(Uz,"_tabber"),jz="".concat(Uz,"_tab"),Gz="".concat(Uz,"_topbar"),zz="".concat(Uz,"_toptab"),qz="".concat(Uz,"_content"),Kz="".concat(Uz,"_has_topbar"),Yz="".concat(qz,"_log"),Xz="".concat(qz,"_network"),Jz="".concat(Uz,"_dump"),Qz="".concat(Xz,"_title"),$z="".concat(Xz,"_basic"),Zz="".concat(Xz,"_local"),eq="".concat(Xz,"_remote"),tq="".concat(Jz,"_title"),iq="".concat(Jz,"_local"),rq="".concat(Jz,"_remote"),oq="".concat(rq,"_hook"),nq="".concat(Uz,"_banner"),aq="".concat(nq,"_item"),sq="".concat(Uz,"_toolbar"),cq="".concat(Uz,"_tool"),lq="".concat(Uz,"_item"),dq="".concat(lq,"_debug"),uq="".concat(lq,"_info"),hq="".concat(lq,"_warn"),pq="".concat(lq,"_error"),mq="".concat(Uz,"_back_top"),fq="".concat(Uz,"_go_bottom"),_q="".concat(Jz,"_local_audio"),gq="".concat(Jz,"_local_video_main"),vq="".concat(Jz,"_local_video_aux"),Eq="".concat(Uz,"_tooltip"),yq="".concat($z,"_network_info"),Tq="".concat($z,"_room_info"),Iq="".concat(Yz,"_controller"),Aq="success",bq="warning",Sq="failed",wq=0,Rq=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this.addStyle(),this.addDialog()}addDialog(){var e;let t=document.createElement("template");t.innerHTML='<div id="'.concat(Uz,'" class="').concat(Uz,'"><div class="').concat(Fz,'">Debug#').concat(++wq,'</div><div class="').concat(Bz,'"></div><div class="').concat(Hz,'"><div class="').concat(Wz,'"><a class="').concat(jz," ").concat(Vz,'" data-tab="log">').concat(fz,'</a><a class="').concat(jz,'" data-tab="network">').concat(_z,'</a><a class="').concat(jz,'" data-tab="dump">').concat(gz,'</a></div><div class="').concat(Iq,'"><div data-type="back_top">').concat(bz,'</div><div data-type="go_bottom">').concat(Az,'</div><div data-type="clear_log">').concat(Sz,'</div></div><div class="').concat(Gz,'"><a class="').concat(zz," ").concat(Vz,'" data-type="all">All</a><a class="').concat(zz,'" data-type="debug">Debug</a><a class="').concat(zz,'" data-type="info">Info</a><a class="').concat(zz,'" data-type="warn">Warn</a><a class="').concat(zz,'" data-type="error">Error</a></div><div class="').concat(qz," ").concat(Kz,'"><div class="').concat(Yz,'"></div><div class="').concat(Xz,'"><div class="').concat(Qz,'">').concat(Cz,'</div><div class="').concat($z,'"><div class="').concat(Tq,'"></div><div class="').concat(yq,'">').concat(kz,'</div></div><div class="').concat(Qz,'">').concat(wz,'</div><div class="').concat(Zz,'">').concat(kz,'</div><div class="').concat(Qz,'">').concat(Rz,'</div><div class="').concat(eq,'">').concat(kz,'</div></div><div class="').concat(Jz,'"><div class="').concat(tq,'">').concat(wz,'</div><div class="').concat(iq,'"><div id="').concat(_q,'"><span>').concat(Oz," - ").concat(Dz,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(gz,'</button><button class="end-dump" disabled>').concat(Ez,'</button></div><div id="').concat(gq,'"><span>').concat(Nz," - ").concat(Dz,'(s):</span><input type="number" min=0 value=10></input><button class="dump">').concat(gz,'</button><button class="end-dump" disabled>').concat(Ez,'</button></div><div id="').concat(vq,'"><span>').concat(Mz," - ").concat(Dz,'(s):</span><input type="number" min=0 value=10></input><button class="dump">').concat(gz,'</button><button class="end-dump" disabled>').concat(Ez,'</button></div></div><div class="').concat(tq,'">').concat(Rz,'</div><div class="').concat(rq,'"><div class="').concat(oq,"\">userId:<input id=\"dump-remote-video-hook-userid\" value='*' />duration:<input id=\"dump-remote-video-hook-duration\" min='1' value='10' type='number' />mediaType:<select id=\"dump-remote-video-hook-mediaType\" value='main' ><option value='main' checked>Video</option><option value='sub'>Screen</option></select><button id=\"dump-remote-video-hook-button\">dump if video is available</button></div></div></div></div><div class=\"").concat(nq,'"></div><div class="').concat(sq,'"><a id="trtc_upload" class="').concat(cq,'">').concat(yz,'</a><a id="trtc_export" class="').concat(cq,'">').concat(Tz,'</a><a id="trtc_hide" class="').concat(cq,'">').concat(Iz,"</a></div></div></div>"),null==(e=this.shadowRoot)||e.appendChild(t.content.firstChild)}addStyle(){var e;let t=document.createElement("style");t.textContent="#".concat(Uz,"{font-size:14px;--DD-BG-0:#ededed;--DD-BG-1:#f7f7f7;--DD-BG-2:#fff;--DD-BORDER:rgba(0,0,0,0.1);--DD-ERROR:red;--DD-WARN:#fa9d3b;--DD-INFO:#000;--DD-DEBUG:#10aeff;--DD-WARN-BG:#fff3cc;--DD-ERROR-BG:#ffe6e6;}#").concat(Uz," a,.").concat(Fz,"{cursor:pointer;}.").concat(Uz,"{color:black;}.").concat(Fz,"{display:block;position:fixed;right:50px;bottom:").concat(150+50*wq,"px;border-radius:5px;background-color:#07c160;color:#fff;padding:5px 10px;z-index:10000;}.").concat(Bz,"{display:none;position:fixed;left:0;top:0;right:0;bottom:0;z-index:10001;background-color:rgb(0,0,0,0.6);}.").concat(Hz,"{background-color:#ededed;display:none;position:fixed;min-height:85%;left:60%;right:0;bottom:0;z-index:10002;border:1px solid var(--DD-BG-0);}@media (max-width:768px) {.").concat(Hz,"{left:0;}}.").concat(Wz,"{display:flex;height:2em;border-bottom:1px solid var(--DD-BORDER);}.").concat(jz,"{padding:0 20px;border-right:1px solid rgba(0,0,0,0.1);line-height:2em;color:black;}.").concat(jz,".").concat(Vz,"{background-color:var(--DD-BG-2);}.").concat(jz,".disabled{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(Gz,"{height:2em;display:flex;flex-direction:row;}.").concat(zz,"{width:20%;text-align:center;line-height:2em;border-right:1px solid var(--DD-BORDER);border-bottom:1px solid var(--DD-BORDER);color:black;}.").concat(zz,".").concat(Vz,"{border-bottom:1px solid #1485ee;background-color:var(--DD-BG-2);}.").concat(qz,"{background-color:#fff;position:absolute;left:0;right:0;top:2em;bottom:8em;overflow-y:scroll;overflow-x:hidden;}.").concat(qz,".").concat(Kz,"{top:4em;bottom:10em}.").concat(Xz,"{display:none;}.").concat(Jz,"{display:none;}.").concat(Qz,",.").concat(tq,"{line-height:2em;text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat($z,",.").concat(Zz,",.").concat(eq,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(iq,",.").concat(rq,"{display:flex;flex-direction:column;padding:0.5em 0;justify-content:center;align-items:center;}.").concat(iq," div input{margin:0 10px;height:1.5em;width:4em;}.").concat(iq," div {padding:10px 0;border-radius:5px;}.").concat(iq," div button,.").concat(rq," div button {cursor:pointer;height:1.8em;border-radius:5px;margin-right:5px;}.").concat(iq," div button[disabled],.").concat(rq," div button[disabled]{cursor:not-allowed;}.").concat(rq," select {height:1.8em;margin:0 10px;}.").concat(rq," div input{margin:0 10px;height:1.5em;width:4em;}.").concat(oq," {line-height:3em;padding:0.5em;}.").concat(Qz,"{text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat($z,",.").concat(Zz,",.").concat(eq,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(lq,"{border-bottom:1px solid var(--DD-BG-0);padding:5px 10px;overflow-wrap: break-word;}.").concat(pq,"{color:var(--DD-ERROR);background-color:var(--DD-ERROR-BG);}.").concat(hq,"{color:var(--DD-WARN);background-color:var(--DD-WARN-BG);}div .").concat(uq,"{color:var(--DD-INFO);}.").concat(dq,"{color:var(--DD-DEBUG);}.").concat(nq,"{position:absolute;left:0;right:0;bottom:2em;height:6em;border-bottom:1px solid var(--DD-BORDER);display:flex;flex-direction:column;overflow-y:scroll;background-color:var(--DD-BG-1);}.").concat(aq,"{border-bottom:1px solid var(--DD-BORDER);padding:5px 10px;overflow-wrap: break-word;}.").concat(sq,"{position:absolute;line-height:2em;display:flex;flex-direction:row;left:0;right:0;bottom:0;}.").concat(cq,"{flex:1;color:black;text-align:center;background-color:#ededed;border-right:1px solid var(--DD-BORDER);}#").concat(Uz," .").concat(mq,",#").concat(Uz," .").concat(fq,"{position:absolute;height:2em;width:6em;right:2em;border-radius:5px;background-color:rgba(30,136,229,0.8);z-index:10003;cursor:pointer;padding:0 5px;line-height:2em;color:white;text-align:center;}.").concat(fq,"{bottom:9em;}.").concat(mq,"{bottom:11.5em;}#").concat(Uz," .").concat(cq,".disable{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(Eq," {position:relative;display:inline-block;}.").concat(Eq," .tooltiptext{visibility:hidden;width:180px;background-color:black;color:#fff;text-align:center;padding:5px 0;border-radius:6px;position:absolute;}.").concat(Eq," .tooltip-top {bottom:125%;left:50%;margin-left:-90px;}.").concat(Eq,":hover .tooltiptext{visibility:visible;}.").concat(Iq,"{position:absolute;left:0;right:0;bottom:8em;height:2em;display:flex;align-items:center;}.").concat(Iq," div{flex:1;cursor:pointer;border-right:1px solid var(--DD-BORDER);text-align: center;}"),null==(e=this.shadowRoot)||e.appendChild(t)}};customElements.define("trtc-basic-debug-dialog",Rq);var kq=class{constructor(e,t,i,r,o,n){aR(this,"_dialogNode",null),aR(this,"_switchNode",null),aR(this,"_maskNode",null),aR(this,"_panelNode",null),aR(this,"_logContentNode",null),aR(this,"_networkContentNode",null),aR(this,"_dumpContentNode",null),aR(this,"_tabNodes",[]),aR(this,"_toptabNodes",[]),aR(this,"_hasMove",!1),aR(this,"_showDialog",!1),aR(this,"_isMobile",!1),aR(this,"_showLogType","all"),aR(this,"prevBytesSent",0),aR(this,"prevBytesReceived",0),aR(this,"_core"),aR(this,"_log"),aR(this,"_logList",[]),aR(this,"isUploading",!1),aR(this,"publishMap",new Map),aR(this,"dumpLocalVideoMap"),aR(this,"dumpRemoteVideoMap"),aR(this,"dumpLocalAudioMap"),aR(this,"dumpRemoteAudioMap"),aR(this,"eventMap",new Map),aR(this,"switchPos",{x:0,y:0,startX:0,startY:0,endX:0,endY:0,isTouchEnd:!1}),aR(this,"handleLeaveSuccess",(e=>{let{room:t}=e;var i,r;if(!this.hitTest(t))return;let o=null==(r=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:r.querySelector(".".concat(rq));for(let n of this.publishMap.values())null==o||o.removeChild(n);this.publishMap.clear()})),aR(this,"handleJoinSuccess",(e=>{let{room:t}=e;var i,r;if(!this.hitTest(t))return;(null==(r=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:r.querySelector(".".concat(Tq))).innerHTML="sdkAppId: ".concat(t.sdkAppId,"<br/>roomId: ").concat(t.roomId,"<br/>userId: ").concat(t.userId,"<br/>")})),aR(this,"handleRemoteVideoAvailable",(e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"publish")})),aR(this,"handleRemoteVideoUnavailable",(e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"unpublish")})),aR(this,"handleRemoteAudioAvailable",(e=>{this.renderDumpTab(e.userId,"remote","audio","publish")})),aR(this,"handleRemoteAudioUnavailable",(e=>{this.renderDumpTab(e.userId,"remote","audio","unpublish")})),aR(this,"renderDumpTab",((e,t,i,r)=>{var o,n,a;let s={main:"video",auxiliary:"screen",audio:"audio"},c=(e,t)=>{var i,r,o;let n=document.createElement("div");n.innerText="".concat(e," - ").concat(s[t]," - ").concat(Dz,"(s):");let a=document.createElement("input");a.type="number",a.min="0",a.value="10",a.id="dump_remote_".concat(t,"_").concat(e);let c=document.createElement("button");c.innerText=Ez,c.disabled=!0;let l,d=document.createElement("button");if(d.innerText=gz,d.onclick=()=>{let i,r,o=Number(a.value);if("audio"===t)({download:i,onDumpEnd:r}="true"===new URLSearchParams(location.search).get("dump_audio_before_codec")?this.dumpAudioFromPipeline("remote",o,e):this.dumpAudio("remote",o,e));else{if(!this.isSupportDumpVideo())return;({download:i,onDumpEnd:r}=this.dumpVideo(t,"remote",o,e))}i&&(this.inactiveButton(d,vz),o>0?setTimeout((()=>{null==i||i(),this.activeButton(d,gz)}),1e3*o):(this.activeButton(c),c.onclick=()=>{c.onclick=null,null==i||i(),null==r||r(),this.activeButton(d,gz),this.inactiveButton(c)}))},"audio"!==t){l=document.createElement("button"),l.innerText="preview",l.style.whiteSpace="pre";let i=document.createElement("video");document.body.appendChild(i),i.id="".concat(Uz,"_preview_remote_").concat(t,"_").concat(e),i.style.cssText="\n width: 320px;\n height: 240px;\n display: none;\n position: absolute;\n top: 50%;\n left: 50%;\n border: 3px solid #cccccc;\n transform: translate(-50%, -50%);\n z-index: 10004;\n ",l.onclick=()=>cR(this,null,(function*(){var r;if(i.style.display="none"===i.style.display?"":"none",l&&(l.innerText="none"===i.style.display?"preview":" hide "),!i.srcObject){let o=this._core.room.remotePublishedUserMap.get(e);if(o){let e=null==(r=o["main"===t?"remoteVideoTrack":"remoteAuxiliaryTrack"])?void 0:r.mediaTrack;e?(i.srcObject=new MediaStream([e]),yield i.play()):this.addInfoToBanner(Sq,"failed to preview, remote video track is not available")}}}))}n.appendChild(a),n.appendChild(d),n.appendChild(c),l&&n.appendChild(l),n.style.cssText="padding:10px;";let u=document.createElement("div");return u.style.cssText="width:100%;display:flex;justify-content:center;border-top: 1px solid var(--DD-BORDER);",u.appendChild(n),null==(o=null==(r=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:r.querySelector(".".concat(rq)))||o.appendChild(u),u};if("remote"===t)if("publish"===r){let r=c(e,i);this.publishMap.set("".concat(e,"-").concat(t,"-").concat(i),r)}else{let r=this.publishMap.get("".concat(e,"-").concat(t,"-").concat(i));if(!r)return;null==(a=null==(n=null==(o=this._dialogNode)?void 0:o.shadowRoot)?void 0:n.querySelector(".".concat(rq)))||a.removeChild(r);let s=document.querySelector("#".concat(Uz,"_preview_remote_").concat(i,"_").concat(e));s&&document.body.removeChild(s),this.publishMap.delete("".concat(e,"-").concat(t,"-").concat(i))}})),aR(this,"handleStatistics",(e=>{var t,i,r,o,n,a;let s=(e.bytesSent-this.prevBytesSent)/2,c=(e.bytesReceived-this.prevBytesReceived)/2;this.prevBytesSent=e.bytesSent,this.prevBytesReceived=e.bytesReceived,(null==(i=null==(t=this._dialogNode)?void 0:t.shadowRoot)?void 0:i.querySelector(".".concat(yq))).innerHTML="rtt: ".concat(e.rtt," ms upLoss: ").concat(e.upLoss,"% downLoss: ").concat(e.downLoss,"% <br>\n ↑ ").concat(s/1e3," KB/s (").concat(8*s/1e3," Kb/s) <br>\n ↓ ").concat(c/1e3," KB/s (").concat(8*c/1e3," Kb/s) <br>\n ");let l=null==(o=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:o.querySelector(".".concat(Zz)),d="";e.localStatistics.audio.bitrate&&(d="<li>local audio: ".concat(e.localStatistics.audio.bitrate," Kb/s audioLevel: ").concat(e.localStatistics.audio.audioLevel.toFixed(5),"</li>")),e.localStatistics.video.length>0&&(d+="".concat(e.localStatistics.video.map((e=>"<li>local ".concat(e.videoType," video: ").concat(e.bitrate," Kb/s ").concat(e.width,"*").concat(e.height," ").concat(e.frameRate,"fps</li>"))).join(""))),l.innerHTML=""===d?"".concat(kz):d;let u=null==(a=null==(n=this._dialogNode)?void 0:n.shadowRoot)?void 0:a.querySelector(".".concat(eq)),h="";e.remoteStatistics.length>0&&e.remoteStatistics.forEach((e=>{let t="remote ".concat(e.userId,":");e.audio.bitrate>0&&(t+="<li>audio: ".concat(e.audio.bitrate," Kb/s audioLevel: ").concat(e.audio.audioLevel.toFixed(5),"</li>")),e.video.length>0&&e.video.forEach((e=>{t+="<li>".concat(e.videoType," video: ").concat(e.bitrate," Kb/s ").concat(e.width,"*").concat(e.height," ").concat(e.frameRate,"fps</li>")})),h+=t})),u.innerHTML=""===h?"".concat(kz):h})),aR(this,"pad",(e=>e<10?"0".concat(e):"".concat(e))),this._core=e,this._log=t,this.dumpLocalVideoMap=i,this.dumpRemoteVideoMap=r,this.dumpLocalAudioMap=o,this.dumpRemoteAudioMap=n,this.initCustomElements(),this.synchronizeLog(),this.installEvents(),window["__trtc_instance_".concat(wq,"__")]=this._core.trtc}initCustomElements(){this._isMobile=(()=>{let e=window.navigator&&window.navigator.userAgent||"",t=/iPad/i.test(e)||/iPhone/i.test(e),i=/Android/i.test(e);return t||i})();let e=document.createElement("trtc-basic-debug-dialog");document.body.appendChild(e);let t=e.shadowRoot;if(this._dialogNode=e,!t)return;this._switchNode=t.querySelector(".".concat(Fz)),this._addEventListener(this._switchNode,"click",this.onSwitchClick.bind(this));let i=getComputedStyle(this._switchNode);this.switchPos.x=parseInt(i.right,10)||50,this.switchPos.y=parseInt(i.bottom,10)||100+50*wq,this._isMobile?(this._switchNode.ontouchstart=this.onTouchStart.bind(this),this._switchNode.ontouchend=this.onTouchEnd.bind(this),this._switchNode.ontouchmove=this.onTouchMove.bind(this)):this._switchNode.onmousedown=this.onMouseDown.bind(this),this._maskNode=t.querySelector(".".concat(Bz)),this._addEventListener(this._maskNode,"click",this.onMaskClick.bind(this)),this._panelNode=t.querySelector(".".concat(Hz)),t.querySelector(".".concat(Iq)).childNodes.forEach((e=>{switch(e.getAttribute("data-type")){case"go_bottom":this._addEventListener(e,"click",this.onGoBottomClick.bind(this));break;case"back_top":this._addEventListener(e,"click",this.onBackTopClick.bind(this));break;case"clear_log":this._addEventListener(e,"click",this.onClearLogClick.bind(this))}})),this._logContentNode=t.querySelector(".".concat(Yz)),this._networkContentNode=t.querySelector(".".concat(Xz)),this._dumpContentNode=t.querySelector(".".concat(Jz)),this._tabNodes=Array.from(t.querySelector(".".concat(Wz)).children),this._tabNodes.forEach((e=>{this._addEventListener(e,"click",this.onTabClick.bind(this))})),this._toptabNodes=Array.from(t.querySelector(".".concat(Gz)).children),this._toptabNodes.forEach((e=>{this._addEventListener(e,"click",this.onToptabClick.bind(this))}));let r=t.querySelector("#trtc_upload");this._addEventListener(r,"click",this.onUploadClick.bind(this));let o=t.querySelector("#trtc_export");this._addEventListener(o,"click",this.onExportClick.bind(this));let n=t.querySelector("#trtc_hide");this._addEventListener(n,"click",this.onHideClick.bind(this));let a=t.querySelector("#".concat(gq," .dump")),s=t.querySelector("#".concat(gq," .end-dump")),c=Number(t.querySelector("#".concat(gq," input")).value);this._addEventListener(a,"click",this.getDumpButtonClickHandler.bind(this,a,s,c,"main","local"));let l=t.querySelector("#".concat(vq," .dump")),d=t.querySelector("#".concat(vq," .end-dump")),u=Number(t.querySelector("#".concat(vq," input")).value);this._addEventListener(l,"click",this.getDumpButtonClickHandler.bind(this,l,d,u,"auxiliary","local"));let h=t.querySelector("#".concat(_q," button"));this._addEventListener(h,"click",(()=>{let e=Number(t.querySelector("#".concat(_q," input")).value),{download:i,onDumpEnd:r}="true"===new URLSearchParams(location.search).get("dump_audio_from_pipeline")?this.dumpAudioFromPipeline("local",e):this.dumpAudio("local",e);if(i)if(this.inactiveButton(h,vz),e>0)setTimeout((()=>{i(),this.activeButton(h,gz)}),1e3*e);else{let e=t.querySelector("#".concat(_q," .end-dump"));this.activeButton(e),e.onclick=()=>{e.onclick=null,i(),null==r||r(),this.activeButton(h,gz),this.inactiveButton(e)}}else this.addInfoToBanner(Sq,"Failed to dump, please check if the current user has started the audio")}));let p=t.querySelector("#dump-remote-video-hook-userid"),m=t.querySelector("#dump-remote-video-hook-duration"),f=t.querySelector("#dump-remote-video-hook-mediaType"),_=t.querySelector("#dump-remote-video-hook-button");_.onclick=()=>{let e=Number(m.value);if(e<1)return void this.addInfoToBanner(Sq,"duration at least 1s");let t=p.value;if(!t)return void this.addInfoToBanner(Sq,"please input user id");"*"===t&&this.inactiveButton(_);let i,r,o=f.value,n="remote_".concat(t,"_").concat("sub"===o?"auxiliary":o),a=n=>{if((n.userId===t||"*"===t)&&n.streamType===o){if(this.addInfoToBanner(Aq,"[".concat(n.userId,"_").concat(o,"] starting to dump video, duration: ").concat(e,"s")),({download:i,onDumpEnd:r}=this.dumpVideo("sub"===n.streamType?"auxiliary":n.streamType,"remote",e,n.userId)),!i)return;setTimeout((()=>{null==i||i(),null==r||r(),"*"!==t&&this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,a)}),1e3*e)}};this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,a),this.addInfoToBanner(Aq,"[".concat(n,"] waiting to dump video from ").concat("*"===t?"all remote users":"user ".concat(t),", duration: ").concat(e,"s"))}}synchronizeLog(){this._core.loggerManager.getQueue().forEach((e=>{this.updateLog(e)}))}isSupportDumpVideo(){return!(!this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED&&!this._core.rtcDectection.IS_SCRIPT_TRANSFORM_SUPPORTED)||(this.addInfoToBanner(Sq,"Current browser does not support dumping video"),!1)}_addEventListener(e,t,i,r){e&&(e.addEventListener(t,i,r),this.eventMap.set(e,{type:t,listener:i}))}_removeEventListener(){this.eventMap.forEach(((e,t)=>{let{type:i,listener:r}=e;t&&t.removeEventListener(i,r)})),this.eventMap.clear(),this._switchNode&&(this._switchNode.onmousedown=null,this._switchNode.ontouchmove=null,this._switchNode.ontouchstart=null,this._switchNode.ontouchend=null)}closeDialog(){this.uninstallEvents(),this._removeEventListener(),this._dialogNode&&(document.body.removeChild(this._dialogNode),this._dialogNode=null)}updateLog(e){var t;this._logList.push(e);let i=document.createElement("div");switch(i.classList.add(lq),e.level){case 4:i.classList.add(pq);break;case 2:i.classList.add(uq);break;case 3:i.classList.add(hq);break;case 1:i.classList.add(dq)}i.textContent=e.log,"all"!==this._showLogType&&!i.classList.contains("".concat(lq,"_").concat(this._showLogType))&&(i.style.display="none"),null==(t=this._logContentNode)||t.appendChild(i),this.addHelper(i)}getDumpButtonClickHandler(e,t,i,r,o){if(!this.isSupportDumpVideo())return;let{download:n,onDumpEnd:a}=this.dumpVideo(r,o,i);if(n)return this.addInfoToBanner(Aq,"[".concat(o,"_").concat(r,"] starting to dump...")),this.inactiveButton(e,vz),void(i>0?setTimeout((()=>{n(),this.activeButton(e,gz)}),1e3*i):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==a||a(),n(),this.activeButton(e,gz),this.inactiveButton(t)}));this.addInfoToBanner(Aq,"[".concat(o,"_").concat(r,"] waiting to dump..."));let s=n=>{let{track:a}=n;if(a.room===this._core.room&&a.streamType===r){this.addInfoToBanner(Aq,"[".concat(o,"_").concat(r,"] starting to dump")),"local"===o&&this._core.innerEmitter.off("104",s);let{download:n,onDumpEnd:a}=this.dumpVideo(r,o,i);if(!n)return;i>0?setTimeout((()=>{n(),this.activeButton(e,gz)}),1e3*i):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==a||a(),n(),this.activeButton(e,gz),this.inactiveButton(t)})}};s.bind(this),"local"===o&&this._core.innerEmitter.on("104",s),this.inactiveButton(e,vz)}onSwitchClick(){this._hasMove?this._hasMove=!1:this._showDialog?this.hideDialog():(this._isMobile&&(this._maskNode.style.display="block"),this._panelNode.style.display="block",this._switchNode.style.display="none",this._showDialog=!0,this.logContentGoBottom())}onTabClick(e){var t,i,r,o,n,a,s;let c=e.target;null==(t=this._tabNodes)||t.forEach((e=>{e.classList.remove(Vz)})),c.classList.add(Vz);let l=c.getAttribute("data-tab");"log"===l?(null==(o=null==(r=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:r.querySelector(".".concat(qz)))||o.classList.add(Kz),this._logContentNode.style.display="block",this._networkContentNode.style.display="none",this._dumpContentNode.style.display="none",this.logContentGoBottom()):(null==(s=null==(a=null==(n=this._dialogNode)?void 0:n.shadowRoot)?void 0:a.querySelector(".".concat(qz)))||s.classList.remove(Kz),"network"===l?(this._networkContentNode.style.display="block",this._logContentNode.style.display="none",this._dumpContentNode.style.display="none"):"dump"===l&&(this._dumpContentNode.style.display="block",this._networkContentNode.style.display="none",this._logContentNode.style.display="none"))}onToptabClick(e){var t,i;let r=e.target;null==(t=this._toptabNodes)||t.forEach((e=>{e.classList.remove(Vz)})),r.classList.add(Vz),this._showLogType=r.getAttribute("data-type");let o=null==(i=this._logContentNode)?void 0:i.querySelectorAll(".".concat(lq)),n="".concat(lq,"_").concat(this._showLogType);o.forEach((e=>{e.classList.contains(n)||"all"===this._showLogType?e.style.display="block":e.style.display="none"})),this.logContentGoBottom()}onExportClick(){let e=this._logList.reduce(((e,t)=>"".concat(e+t.log,"\n")),""),t=new Blob([e],{type:"text/plain"}),i=document.createElement("a"),r=URL.createObjectURL(t);i.href=r;let o="trtc_".concat(void 0===this._core.room.sdkAppId?"EmptySdkAppId":this._core.room.sdkAppId,"_").concat(void 0===this._core.room.userId?"EmptyUserId":this._core.room.userId,"_").concat(this.formatStartDumpTime(+new Date),".log");i.download=o,i.style.display="none",document.body.appendChild(i),i.click(),URL.revokeObjectURL(r),document.body.removeChild(i),this.addInfoToBanner(Aq,"Export success: The log file name is ".concat(o)),this._core.kvStatManager.addSuccessEvent({key:592703})}addInfoToBanner(e,t){var i,r;let o=null==(r=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:r.querySelector(".".concat(nq)),n=document.createElement("div");n.classList.add(aq);let a=e===Aq?"🟩":e===bq?"🟧":"🟥";n.innerText="".concat(a," [").concat(this.getCurrentTime(),"] ").concat(t),o.appendChild(n),o.scrollTop=o.scrollHeight}onUploadClick(){return cR(this,null,(function*(){var e,t;if(this.isUploading)return;this.isUploading=!0;let i=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector("#trtc_upload");i.innerText="Uploading...",null==i||i.classList.add(".disable");let r=this._logList.reduce(((e,t)=>"".concat(e+t.log,"\n")),""),o=new Blob([r],{type:"text/plain"}),n=new FormData;n.append("file",o,"trtc.log"),n.append("sdkAppId","".concat(this._core.room.sdkAppId||"EmptySdkAppId")),n.append("userId","".concat(this._core.room.userId||"EmptyUserId")),fetch("https://service.trtc.qcloud.com/api/uploadLogFile",{method:"POST",body:n}).then((e=>e.json())).then((e=>{this.addInfoToBanner(e.type,e.message_en||"Upload Failed: Please use local export"),this.isUploading=!1,this._log.info(e.message_en),this._core.kvStatManager.addSuccessEvent({key:592704})})).catch((()=>{this.addInfoToBanner(Sq,"Upload Failed: Please use local export"),this._log.info("Upload Failed: Please use local export"),this._core.kvStatManager.addFailedEvent({key:592704})})).finally((()=>{i.innerText=yz,null==i||i.classList.remove(".disable"),this.isUploading=!1}))}))}onHideClick(){this.hideDialog()}onMaskClick(){this.hideDialog()}hideDialog(){this._isMobile&&(this._maskNode.style.display="none"),this._panelNode.style.display="none",this._switchNode.style.display="block",this._showDialog=!1}onBackTopClick(){var e,t,i;null==(i=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(qz)))||i.scrollTo(0,0)}onGoBottomClick(){this.logContentGoBottom()}onClearLogClick(){this._logList=[],this._logContentNode&&(this._logContentNode.innerHTML="")}logContentGoBottom(){var e,t;let i=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(qz));null==i||i.scrollTo(0,null==i?void 0:i.scrollHeight)}onMouseDown(e){e.preventDefault(),this.switchPos.startX=e.pageX,this.switchPos.startY=e.pageY,document.onmousemove=this.onMouseMove.bind(this),document.onmouseup=this.onMouseUp.bind(this)}onMouseMove(e){e.cancelable&&e.preventDefault(),this._hasMove=!0;let t=this.switchPos.x-(e.pageX-this.switchPos.startX),i=this.switchPos.y-(e.pageY-this.switchPos.startY);[t,i]=this.getSafeAreaXY(t,i),this._switchNode.style.right="".concat(t,"px"),this._switchNode.style.bottom="".concat(i,"px"),this.switchPos.endX=t,this.switchPos.endY=i}onMouseUp(){this.switchPos.startX=0,this.switchPos.startY=0,this.switchPos.x=this.switchPos.endX,this.switchPos.y=this.switchPos.endY,document.onmousemove=null,document.onmouseup=null}onTouchStart(e){this.switchPos.startX=e.touches[0].pageX,this.switchPos.startY=e.touches[0].pageY,this.switchPos.isTouchEnd=!1}onTouchEnd(){this.switchPos.isTouchEnd&&(this.switchPos.startX=0,this.switchPos.startY=0,this.switchPos.isTouchEnd=!1,this.switchPos.x=this.switchPos.endX,this.switchPos.y=this.switchPos.endY)}onTouchMove(e){if(e.touches.length<=0)return;let t=e.touches[0].pageX-this.switchPos.startX,i=e.touches[0].pageY-this.switchPos.startY,r=Math.floor(this.switchPos.x-t),o=Math.floor(this.switchPos.y-i);[r,o]=this.getSafeAreaXY(r,o),this._switchNode.style.right="".concat(r,"px"),this._switchNode.style.bottom="".concat(o,"px"),this.switchPos.endX=r,this.switchPos.endY=o,this.switchPos.isTouchEnd=!0,e.cancelable&&e.preventDefault()}getSafeAreaXY(e,t){let i=Math.max(document.documentElement.offsetWidth,window.innerWidth),r=Math.max(document.documentElement.offsetHeight,window.innerHeight);return e+this._switchNode.offsetWidth>i&&(e=i-this._switchNode.offsetWidth),t+this._switchNode.offsetHeight>r&&(t=r-this._switchNode.offsetHeight),e<0&&(e=0),t<20&&(t=20),[e,t]}hitTest(e){return e===this._core.room}installEvents(){this._core.innerEmitter.on("264",this.handleLog,this),this._core.innerEmitter.on("53",this.handleLeaveSuccess,this),this._core.innerEmitter.on("27",this.handleJoinSuccess,this),this._core.trtc.on(this._core.TRTC.EVENT.STATISTICS,this.handleStatistics,this),this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_AUDIO_AVAILABLE,this.handleRemoteAudioAvailable),this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE,this.handleRemoteAudioUnavailable),this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,this.handleRemoteVideoAvailable),this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE,this.handleRemoteVideoUnavailable),this._core.room.on("dump",this.handleDumpFromScriptTransform,this)}uninstallEvents(){this._core.innerEmitter.off("264",this.handleLog,this),this._core.innerEmitter.off("53",this.handleLeaveSuccess,this),this._core.innerEmitter.off("27",this.handleJoinSuccess,this),this._core.trtc.off(this._core.TRTC.EVENT.STATISTICS,this.handleStatistics,this),this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_AUDIO_AVAILABLE,this.handleRemoteAudioAvailable),this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_AUDIO_UNAVAILABLE,this.handleRemoteAudioUnavailable),this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,this.handleRemoteVideoAvailable),this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE,this.handleRemoteVideoUnavailable),this._core.room.off("dump",this.handleDumpFromScriptTransform,this)}handleDumpFromScriptTransform(e){if(!e.isAudio)if(e.userId){let t=this.dumpRemoteVideoMap["".concat(e.userId,"-").concat(e.streamType)];t&&(t.data.push(e.data),t.duration>0&&Date.now()-t.startTimestamp>1e3*t.duration&&t.onDumpEnd())}else{let t="main"===e.streamType?"main":"sub",i=this.dumpLocalVideoMap[t];i&&(i.data.push(e.data),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}}inactiveButton(e,t){e.disabled=!0,t&&(e.innerText=t)}activeButton(e,t){e.disabled=!1,t&&(e.innerText=t)}handleLog(e){this.updateLog(e.log)}addHelper(e){let t=/((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})(\.((2(5[0-5]|[0-4]\d))|[0-1]?\d{1,2})){3}/g,i=Pz,r=e.innerText;r=r.split("\n").map((e=>{if((e=e.replace(/</g,"&lt;").replace(/>/g,"&gt;")).includes("failed"))return e.includes("on autoplay-failed")?e:"<span class='red' style=\"background:red; color:#fff;\">".concat(e,"</span>");if(e.includes("clientIp:")){let i=e.match(t);return null==i||i.forEach((t=>{e=e.replace(t,'<a href="javascript:void(0);" target=""><span class=\'ip\' style="background:#e1dfdf">'.concat(t,"</span></a>"))})),e}return e.includes("URL of current page")&&(e=e.replace(/URL of current page: (.+)/,'URL of current page: <a href="$1">$1</a>')),e})).join("\n"),i.forEach((t=>{if(e.innerText.includes(t)){let i="";i="function"==typeof Lz[t].tips?Lz[t].tips(e.innerText):Lz[t].tips,r=r.replace(new RegExp("".concat((e=>e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(">","&gt;").replace(">","&lt;"))(t)),"gi"),'<span class="'.concat(Eq,'" style="background:').concat(Lz[t].color||"#e1dfdf","; color: ").concat(Lz[t].textColor||"#000",'">').concat(t,'\n <span class="tooltiptext tooltip-top">').concat(i,"</span>\n </span>"))}})),e.innerHTML=r}getCurrentTime(){let e=new Date,t=this.pad(e.getHours()),i=this.pad(e.getMinutes()),r=this.pad(e.getSeconds());return"".concat(t,":").concat(i,":").concat(r)}dumpAudioFromPipeline(e,t,i){this.addInfoToBanner(bq,"dump audio from pipeline");let r=Date.now(),o=this.formatStartDumpTime(r),n=[],a="".concat(e,"_").concat(i);if("local"===e)this._core.trtc._localAudioTrack;else if(i){let e=this._core.room.remotePublishedUserMap.get(i);e&&e.remoteAudioTrack}let s;if("local"===e){if(!this.hasLocalTrack("main","audio"))return{};s=()=>{delete this.dumpLocalAudioMap.main},this.dumpLocalAudioMap.main={startTimestamp:r,data:n,duration:t,onDumpEnd:s}}if("remote"===e&&i){if(s=()=>{delete this.dumpRemoteAudioMap["".concat(i)]},this.dumpRemoteAudioMap["".concat(i)])return this.addInfoToBanner(bq,"[".concat(a,"] dump already exists.")),{};this.dumpRemoteAudioMap["".concat(i)]={startTimestamp:r,data:n,duration:t,onDumpEnd:s}}return{download:()=>{var t,r;if(0===n.length)return void this.addInfoToBanner(Sq,"[".concat(a,"] dump failed. Reason: data is empty"));let s,c=("local"===e?null==(t=this._core.room.singlePC)?void 0:t.audioCodec:null==(r=this._core.room.userManager)?void 0:r.getPublishedUser(i).audioCodec)||"opus",l=c;"opus"===c?(this.addInfoToBanner(bq,"[".concat(a,"] package opus to ogg")),s=this.convertOpusToOgg(n),l="ogg"):s=new Blob(n);let d=URL.createObjectURL(s),u=document.createElement("a"),h="local"===e?"local_".concat(o,".").concat(l):"remote-".concat(i,"_").concat(o,".").concat(l);u.href=d,u.download=h,u.style.display="none",document.body.appendChild(u),u.click(),URL.revokeObjectURL(d),u.remove(),this.addInfoToBanner(Aq,"[".concat(a,"] dump success. File name is: ").concat(h))},onDumpEnd:s}}dumpVideo(e,t,i,r){let o,n=Date.now(),a=this.formatStartDumpTime(n),s=[],c="".concat(t,"_").concat(r,"_").concat(e);if("local"===t)o="main"===e?this._core.trtc._localVideoTrack:this._core.trtc._localScreenTrack;else if(r){let t=this._core.room.remotePublishedUserMap.get(r);t&&(o="main"===e?t.remoteVideoTrack:t.remoteAuxiliaryTrack)}let l;if("local"===t){if(!this.hasLocalTrack(e,"video"))return{};l=()=>{delete this.dumpLocalVideoMap["auxiliary"===e?"sub":"main"]},this.dumpLocalVideoMap["auxiliary"===e?"sub":"main"]={startTimestamp:n,data:s,duration:i,onDumpEnd:l}}if("remote"===t&&r){if(l=()=>{delete this.dumpRemoteVideoMap["".concat(r,"-").concat(e)]},this.dumpRemoteVideoMap["".concat(r,"-").concat(e)])return this.addInfoToBanner(bq,"[".concat(c,"] dump already exists.")),{};this.dumpRemoteVideoMap["".concat(r,"-").concat(e)]={startTimestamp:n,data:s,duration:i,onDumpEnd:l}}return{download:()=>{var i,n;if(0===s.length)return void this.addInfoToBanner(Sq,"[".concat(c,"] dump failed. Reason: data is empty"));let l,d;"main"===e?l="video":"auxiliary"===e&&(l="screen"),"vp8"===this.getVideoCodec(r||"")?(this.addInfoToBanner(bq,"[".concat(c,"] package vp8 into ivf format")),d=this.convertVP8ToIVF(s,o)):d=new Blob(s);let u=URL.createObjectURL(d),h=document.createElement("a"),p="local"===t?"local_".concat(l,"_").concat(a,".").concat((null==(i=this._core.room.singlePC)?void 0:i.videoCodec)||"h264"):"remote-".concat(r,"_").concat(l,"_").concat(a,".").concat((null==(n=this._core.room.userManager)?void 0:n.getPublishedUser(r).videoCodec)||"h264");h.href=u,h.download=p,h.style.display="none",document.body.appendChild(h),h.click(),URL.revokeObjectURL(u),h.remove(),this.addInfoToBanner(Aq,"[".concat(c,"] dump success. File name is: ").concat(p))},onDumpEnd:l}}convertVP8ToIVF(e,t){var i,r,o;function n(e,t,i){for(let r=0;r<i.length;r++)e.setUint8(t+r,i.charCodeAt(r))}let a=e.reduce(((e,t)=>e+12+t.byteLength),32),s=new ArrayBuffer(a),c=new DataView(s),l=new Uint8Array(s),d=0;n(c,d,"DKIF"),d+=4,c.setUint16(d,0,!0),d+=2,c.setUint16(d,32,!0),d+=2,n(c,d,"VP80"),d+=4,c.setUint16(d,(null==(i=null==t?void 0:t._inputTrack)?void 0:i.getSettings().width)||0,!0),d+=2,c.setUint16(d,(null==(r=null==t?void 0:t._inputTrack)?void 0:r.getSettings().height)||0,!0),d+=2;let u=(t instanceof ZB?null==t?void 0:t.decodeFPS:null==(o=null==t?void 0:t.mediaTrack)?void 0:o.getSettings().frameRate)||15;return c.setUint32(d,u,!0),d+=4,c.setUint32(d,1,!0),d+=4,c.setUint32(d,e.length,!0),d+=4,c.setUint32(d,0,!0),d+=4,e.forEach(((e,t)=>{let i=e.byteLength,r=Math.floor(1e6*t/u);c.setUint32(d,i,!0),d+=4,c.setFloat64(d,r,!0),d+=8,l.set(new Uint8Array(e),d),d+=i})),new Blob([s],{type:"application/octet-stream"})}getVideoCodec(e){var t,i;return""===e?null==(t=this._core.room.singlePC)?void 0:t.videoCodec:null==(i=this._core.room.remotePublishedUserMap.get(e))?void 0:i.videoCodec}hasLocalTrack(e,t){for(let i of this._core.room.localTracks)if(i.streamType===e&&i.kind===t)return!0;return!1}dumpAudio(e,t,i){var r,o,n;let a,s,c=null,l=[],d=[],u=[],h=[],p=[],m=[],f=[],_=new AbortController,g=Date.now(),v=this.formatStartDumpTime(g),E=this._core.room.audioManager._localAudioPipline,y=this._core.room.audioManager._localScreenAudioPipeline,T=e=>{let{room:t,data:i,type:r}=e;if(this.hitTest(t)){if("dump"===r){if(h[0]=h[0]?h[0].concat(i.captureInput):i.captureInput,h[1]=h[1]?h[1].concat(i.playInput):i.playInput,a){let e=i.startTime-a,t=i.endTime-i.startTime;if(e>30||t>30){let r=function(e){if("number"!=typeof e||e<0)return"0毫秒";let t=[],i=Math.floor(e/6e4),r=e%6e4;i>0&&t.push("".concat(i,"分"));let o=Math.floor(r/1e3);return r%=1e3,(o>0||t.length)&&t.push("".concat(o,"秒")),(r>0||!t.length)&&t.push("".concat(r,"毫秒")),t.join("")},o=i.startTime-s,n=a-s;f.push("".concat(i.startTime,"\t").concat(r(o),"~").concat(r(n),"\t").concat(e,"\t").concat(t))}a=i.startTime}else a=i.startTime,s=i.startTime;m.push(i.startTime)}"dump-screen-audio"===r&&(p[0]=p[0]?p[0].concat(i.captureInput):i.captureInput,p[1]=p[1]?p[1].concat(i.playInput):i.playInput)}};if("local"===e){let{sampleRate:e}=this._core.room.audioManager.audioContext;if(!this._core.room.audioManager.hasAudioTrack&&!this._core.room.audioManager.hasScreenAudioTrack)return{};if(null!=E&&E.source.node&&(l.push(E.source.node),d.push("local_audio_raw_capture-".concat(e,"-").concat(E.source.node.channelCount))),(null!=(r=null==E?void 0:E.aec)&&r.node||null!=y&&y.aec.node)&&(this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!0}),this._core.innerEmitter.on("265",T),null!=(o=null==E?void 0:E.aec)&&o.node&&(l.push(E.aec.node),d.push("local_audio_audioProcessor_processed-".concat(e,"-").concat(E.aec.node.channelCount))),null!=y&&y.aec.node&&(l.push(y.aec.node),d.push("screen_audio_audioProcessor_processed-".concat(e,"-").concat(y.aec.node.channelCount)))),null!=E&&E.denoiser.node&&(l.push(E.denoiser.node),d.push("local_audio_denoiser_processed-".concat(e,"-").concat(E.denoiser.node.channelCount))),this._core.room.audioManager.mixWeight>1&&null!=E&&E.stream){let t=this._core.room.audioManager.audioContext.createMediaStreamSource(E.stream);t.channelCount=1,l.push(t),d.push("local_audio_destination-".concat(e,"-").concat(t.channelCount))}}else if("remote"===e&&void 0!==i){let e=null==(n=this._core.room.remotePublishedUserMap.get(i))?void 0:n.remoteAudioTrack;if(null==e||!e.mediaTrack)return{};let t=this._core.createAudioNode(e.mediaTrack);l.push(t),d.push("remote_".concat(i))}let I=()=>cR(this,null,(function*(){var t,i,r,o,n;let a=new xz.default;for(let e=0;e<d.length;e++)a.file("".concat(d[e],".pcm"),new Blob(u[e]));if(null!=(t=null==h?void 0:h[0])&&t.length&&a.file("audioProcessor_input_capture.pcm",new Blob(h[0])),null!=(i=null==h?void 0:h[1])&&i.length&&a.file("audioProcessor_input_playback.pcm",new Blob(h[1])),null!=(r=null==p?void 0:p[0])&&r.length&&a.file("audioProcessor_screen_audio_input_capture.pcm",new Blob(p[0])),null!=(o=null==p?void 0:p[1])&&o.length&&a.file("audioProcessor_screen_audio_input_playback.pcm",new Blob(p[1])),null!=m&&m.length){let e=m.reduce(((e,t)=>"".concat(e,"\n").concat(t)));a.file("audioProcessor_handle_timestamp.txt",new Blob([e]))}if(null!=f&&f.length){let e=f.reduce(((e,t)=>"".concat(e,"\n").concat(t)));a.file("audioProcessor_big_gap_data.txt",new Blob([e]))}let s=yield a.generateAsync({type:"blob"}),l=URL.createObjectURL(s),g=document.createElement("a");g.href=l,g.download="".concat(e,"-audio-").concat(v,".zip"),g.style.display="none",document.body.appendChild(g),g.click(),URL.revokeObjectURL(l),g.remove(),this.addInfoToBanner(Aq,"Dump success, file name is: ".concat(e,"-").concat(v,".zip")),this._core.innerEmitter.off("265",T),(null!=(n=null==E?void 0:E.aec)&&n.node||null!=y&&y.aec.node)&&this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!1}),c&&clearTimeout(c),_.abort("download")}));return t>0&&(c=Number(setTimeout((()=>{_.abort("timeout")}),1e3*t))),l.length>0&&this._core.startGetPCM(l).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>{u[t]=u[t]?u[t].concat(e[0]):[e[0]]}))}}),_).catch((()=>I)))),{download:I,onDumpEnd:()=>{_.abort("timeout")}}}formatStartDumpTime(e){let t=new Date(e),i=t.getFullYear(),r=this.pad(t.getMonth()+1),o=this.pad(t.getDate()),n=this.pad(t.getHours()),a=this.pad(t.getMinutes()),s=this.pad(t.getSeconds()),c=-t.getTimezoneOffset(),l=Math.floor(Math.abs(c)/60),d=Math.abs(c)%60,u=c>=0?"+":"-";return"".concat(i,"-").concat(r,"-").concat(o,"T").concat(n,"-").concat(a,"-").concat(s).concat(u).concat(this.pad(l),"-").concat(this.pad(d))}convertOpusToOgg(e){let t=Math.floor(4294967295*Math.random()),i=0,r=0,o=[],n=this.createOpusHead(48e3,2);o.push(this.createOggPage(2,0,t,i++,[n]));let a=this.createOpusTags();o.push(this.createOggPage(0,0,t,i++,[a]));let s=[],c=0;return e.forEach(((n,a)=>{let l=this.getOpusPacketDuration(n);s.push(n),c+=n.byteLength,r+=l;let d=a===e.length-1;if(c>6e4||s.length>=50||d){let e=d?4:0;o.push(this.createOggPage(e,r,t,i++,s)),s=[],c=0}})),new Blob(o,{type:"audio/ogg"})}createOpusHead(e,t){let i=new ArrayBuffer(19),r=new DataView(i);return this.writeString(r,0,"OpusHead"),r.setUint8(8,1),r.setUint8(9,t),r.setUint16(10,0,!0),r.setUint32(12,e,!0),r.setUint16(16,0,!0),r.setUint8(18,0),i}createOpusTags(){let e="TRTC Debugger",t=new ArrayBuffer(29),i=new DataView(t);return this.writeString(i,0,"OpusTags"),i.setUint32(8,13,!0),this.writeString(i,12,e),i.setUint32(25,0,!0),t}createOggPage(e,t,i,r,o){let n=0;o.forEach((e=>{let t=e.byteLength;for(;t>=255;)n++,t-=255;n++}));let a=27+n,s=o.reduce(((e,t)=>e+t.byteLength),0),c=new ArrayBuffer(a+s),l=new DataView(c),d=new Uint8Array(c);this.writeString(l,0,"OggS"),l.setUint8(4,0),l.setUint8(5,e),l.setUint32(6,4294967295&t,!0),l.setUint32(10,Math.floor(t/4294967295),!0),l.setUint32(14,i,!0),l.setUint32(18,r,!0),l.setUint32(22,0,!0),l.setUint8(26,n);let u=27;o.forEach((e=>{let t=e.byteLength;for(;t>=255;)d[u++]=255,t-=255;d[u++]=t}));let h=a;o.forEach((e=>{d.set(new Uint8Array(e),h),h+=e.byteLength}));let p=this.crc32(d);return l.setUint32(22,p,!0),d}writeString(e,t,i){for(let r=0;r<i.length;r++)e.setUint8(t+r,i.charCodeAt(r))}getOpusPacketDuration(e){if(0===e.byteLength)return 0;let t=new Uint8Array(e),i=t[0],r=i>>3&31,o=3&i,n=1;if(1===o||2===o)n=2;else if(3===o){if(e.byteLength<2)return 0;n=63&t[1]}return([480,480,480,480,960,960,960,960,1920,1920,1920,1920,2880,2880,480,480,120,120,120,120,240,240,240,240,480,480,480,480,960,960,960,960][r]||960)*n}crc32(e){let t=new Uint32Array(256);for(let r=0;r<256;r++){let e=r<<24;for(let t=0;t<8;t++)2147483648&e?e=e<<1^79764919:e<<=1;t[r]=e>>>0}let i=0;for(let r=0;r<e.length;r++){i=(i<<8^t[255&(i>>>24^e[r])])>>>0}return i}};nR([PG(300,(()=>"export"))],kq.prototype,"onExportClick",1),nR([PG(300,(()=>"upload"))],kq.prototype,"onUploadClick",1);var Cq,Dq=kq,Nq=0,Oq=class e{constructor(e){this.core=e,aR(this,"_core"),aR(this,"log"),aR(this,"dumpLocalVideoMap",{}),aR(this,"dumpRemoteVideoMap",{}),aR(this,"dumpLocalAudioMap",{}),aR(this,"dumpRemoteAudioMap",{}),aR(this,"dialog"),this._core=e,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(++Nq)}),this.log.info("created")}getName(){return e.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}start(){return cR(this,null,(function*(){var e;!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_ENABLE_DEBUG_PLUGIN"))||(yield this.openDebugDiaLog(),this.addVideoProcessor(),this.addAudioProcessor())}))}update(e){return cR(this,arguments,(function(e){var t=this;let{visible:i}=e;return function*(){i?(yield t.openDebugDiaLog(),t.addVideoProcessor()):(t.closeDebugDiaLog(),t.removeVideoProcessor())}()}))}stop(){this.closeDebugDiaLog(),this.removeVideoProcessor(),this.removeAudioProcessor()}destroy(){this.stop()}openDebugDiaLog(){return cR(this,null,(function*(){var e;if(!this.dialog)try{if(Cq)yield Cq;else{let t=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(wR,"/assets/debug-dialog.js");Cq=this._core.fileDownloader.loadScript(t),yield Cq}this.dialog=new Dq(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap,this.dumpLocalAudioMap,this.dumpRemoteAudioMap),this._core.kvStatManager.addSuccessEvent({key:592705})}catch(kR){this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(kR))}}))}closeDebugDiaLog(){this.dialog&&(this.dialog.closeDialog(),this.dialog=null)}addVideoProcessor(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):uz,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):hz,type:1})}removeVideoProcessor(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}addAudioProcessor(){this._core.room.audioManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeAudio.bind(this):pz,type:2}),this._core.room.audioManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeAudio.bind(this):mz,type:2})}removeAudioProcessor(){this._core.room.audioManager.removeEncodeProcessor({type:2}),this._core.room.audioManager.removeDecodeProcessor({type:2})}encodeVideo(e){let{frame:t,mediaType:i}=e;return uz({frame:t,onDump:()=>{if(!i)return;let e=2===i?"sub":"main",r=this.dumpLocalVideoMap[e];r&&(r.data.push(t.data.slice(0)),r.duration>0&&Date.now()-r.startTimestamp>1e3*r.duration&&r.onDumpEnd())}})}decodeVideo(e){let{frame:t,track:i}=e;return hz({frame:t,onDump:()=>{if(!i)return;let e=this.dumpRemoteVideoMap["".concat(i.userId,"-").concat(i.streamType)];e&&(e.data.push(t.data.slice(0)),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}})}encodeAudio(e){let{frame:t}=e;return pz({frame:t,onDump:()=>{let e=this.dumpLocalAudioMap.main;e&&(e.data.push(t.data.slice(0)),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}})}decodeAudio(e){let{frame:t,track:i}=e;return mz({frame:t,onDump:()=>{if(!i)return;let e=this.dumpRemoteAudioMap[i.userId];e&&(e.data.push(t.data.slice(0)),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}})}};aR(Oq,"Name","Debug"),aR(Oq,"autoStart",!0);var Mq=Oq,Lq=e=>{switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},Pq=class{constructor(e,t,i){aR(this,"trackDoneOB"),aR(this,"startOB"),aR(this,"stopOB"),aR(this,"inputFrameCount",0),aR(this,"decodedFrameCount",0),aR(this,"type","auto"),aR(this,"config"),aR(this,"decoder"),aR(this,"_decodeSink");let{kvStatManager:r,trtc:o}=e;this.config=i.config,this.trackDoneOB=MV(t,qP.INIT),this.stopOB=yV(),this.startOB=yV(),"auto"===i.type?this.type="webCodecs":this.type=i.type;let n=yV();ZU(this.startOB,fV(0),OF((e=>{let i=this.pipe(t);return n.next("STARTING"),t.log.info("decoder type: ".concat(this.type)),ZU(i,tF(this.stopOB),iB((()=>{}),(i=>{t.log.error(i),r.addFailedEvent({key:Lq(this.type),error:i}),e>4?this.startOB.error(i):this.startOB.next(e+1)}))),ZU(i,eF(1),QF(zV))})),tF(this.stopOB),iB((()=>{t.player.setOutput(),n.next("STARTED")}),(e=>{n.next("FAILED")}),(()=>{r.addSuccessEvent({key:Lq(this.type)}),r.addSuccessEvent({key:504702})})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}close(e){this.stopOB.next(e)}pipe(e){return sV()((t=>cR(this,null,(function*(){this._decodeSink=t,t.defer((()=>{var e;null==(e=this.decoder)||e.close()}));let{type:i}=this;try{if("webCodecs"===i)this.decoder=new AudioDecoder({error:i=>{e.log.error(i),t.error(4)},output:i=>{this.decodedFrameCount++,t.next(i),e.player.write(i)}});this.decoder.configure(this.config)}catch(pM){e.log.error(pM),t.error("webCodecs"===i?2:6)}}))))}decodeFrame(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}},xq={type:"object"},Uq=class e{constructor(e){this.core=e,aR(this,"log"),aR(this,"contextMap",new Map),aR(this,"decodeProcessorMap",new WeakMap),this.log=e.log.createChild({id:"".concat(this.getAlias())})}getAlias(){return e.Name}getGroup(e){return e.track.userId+e.track.streamType}getName(){return e.Name}getValidateRule(e){return xq}start(e){let{track:t}=e;this.decodeProcessorMap.set(t,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:e=>{let{frame:t,track:i}=e;return this.decodeProcessorMap.has(i)?this.decodeProcessorMap.get(i)({frame:t,track:i}):t},type:3})}decode(e){return t=>{let{frame:i,track:r}=t;if(r!==e.track)return i;if(this.contextMap.has(r))return this.contextMap.get(r).decodeFrame(i);let o=new Pq(this.core,r,e);return ZU(o.trackDoneOB,eF(1),iB((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:r})}))),this.contextMap.set(r,o),o.decodeFrame(i)}}stop(e){let{track:t}=e,i=this.contextMap.get(t);i&&(i.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}update(e){let t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new Pq(this.core,e.track,e))}}};aR(Uq,"Name","TRTCAudioDecoder");var Vq=Uq,Fq=class{constructor(){aR(this,"log"),this.log=rM.createLogger({id:"exp"})}call(e,t){return cR(this,null,(function*(){return KC(this[e])?this[e](t):Promise.reject(new vR({code:_R.INVALID_PARAMETER,message:vL({key:mL.API_NOT_EXIST,data:{name:e}})}))}))}enableAudioFrameEvent(e){return cR(this,null,(function*(){let{trtcInstance:t,enable:i,userId:r,sampleRate:o=48e3,channelCount:n=1,port:a}=e,{audioManager:s}=t.room,{getPCMAbortCtrlMap:c,audioFrameEventConfigMap:l}=s;if(l.set(r,{enable:i,sampleRate:o,channelCount:n,port:a}),i)if("*"===r)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isAvailable){if(c.get(e.userId))return;let i=s.getPCM((e=>{t.emit(mG.AUDIO_FRAME,e)}),e.userId);c.set(e.userId,i)}}));else{if(c.get(r))return;let e=s.getPCM((e=>{t.emit(mG.AUDIO_FRAME,e)}),r);c.set(r,e)}else if("*"===r)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isSubscribed){let{userId:t}=e,i=c.get(t);null==i||i.abort("disable"),c.delete(t)}}));else{let e=c.get(r);null==e||e.abort("disable"),c.delete(r)}}))}resumeRemotePlayer(e){return cR(this,null,(function*(){if("*"===e.userId){let t=[];return e.trtcInstance.room.remotePublishedUserMap.forEach((i=>{let{remoteAudioTrack:r,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=i;e.streamType?"main"===e.streamType?(r.isAvailable&&t.push(r.player.resume()),o.isAvailable&&t.push(o.player.resume())):n.isAvailable&&t.push(n.player.resume()):(r.isAvailable&&t.push(r.player.resume()),o.isAvailable&&t.push(o.player.resume()),n.isAvailable&&t.push(n.player.resume()))})),Promise.all(t)}let t=e.trtcInstance.room.remotePublishedUserMap.get(e.userId);if(t)return"main"===e.streamType?Promise.all([t.remoteAudioTrack.player.resume(),t.remoteVideoTrack.player.resume()]):t.remoteAuxiliaryTrack.player.resume()}))}pauseRemotePlayer(e){if("*"===e.userId)e.trtcInstance.room.remotePublishedUserMap.forEach((t=>{let{remoteAudioTrack:i,remoteVideoTrack:r,remoteAuxiliaryTrack:o}=t;e.streamType?"main"===e.streamType?(i.isAvailable&&i.player.pause(),r.isAvailable&&r.player.pause()):o.isAvailable&&o.player.pause():(i.isAvailable&&i.player.pause(),r.isAvailable&&r.player.pause(),o.isAvailable&&o.player.pause())}));else{let t=e.trtcInstance.room.remotePublishedUserMap.get(e.userId);t&&("main"===e.streamType?(t.remoteAudioTrack.player.pause(),t.remoteVideoTrack.player.pause()):t.remoteAuxiliaryTrack.player.pause())}}};nR([function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return MU(((e,i)=>function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];return oH.call(this,t,o,i,this._name),e.apply(this,o)}))}({name:"options",type:"object",required:!0,properties:{enable:{required:!0,type:"boolean"},userId:{required:!0,type:"string"},sampleRate:{type:"number",values:[8e3,16e3,32e3,44100,48e3]},channelCount:{type:"number",values:[1,2]},port:{type:"messageport"}}})],Fq.prototype,"enableAudioFrameEvent",1);var Bq=new Fq,Hq=oR(lR(),1),Wq=class extends Hq.EventEmitter{constructor(){super(),aR(this,"states",{}),aR(this,"permissionChangeHandler"),aR(this,"log"),this.log=rM.createLogger({id:"pm"}),this.permissionChangeHandler=()=>{var e,t;this.emit("permission-state-change",{camera:null==(e=this.states.camera)?void 0:e.state,microphone:null==(t=this.states.microphone)?void 0:t.state})}}request(e){return cR(this,null,(function*(){if(this.log.info("request ".concat(e.join(", "))),0===e.length)return Promise.resolve();(yield navigator.mediaDevices.getUserMedia({video:e.includes("camera"),audio:e.includes("microphone")})).getTracks().forEach((e=>e.stop()))}))}get(e){return cR(this,null,(function*(){try{return this.states[e]||(this.states[e]=yield navigator.permissions.query({name:e}),this.states[e].addEventListener("change",this.permissionChangeHandler)),this.log.info("get ".concat(e," permission state: ").concat(this.states[e].state)),this.states[e].state}catch(Ok){return this.log.error("get ".concat(e," permission failed, error: ").concat(Ok instanceof Error?Ok.message:Ok)),null}}))}destroy(){Object.values(this.states).forEach((e=>{null==e||e.removeEventListener("change",this.permissionChangeHandler)})),this.states={}}},jq=new Wq,Gq=0,zq=new Set,qq=null;RR(xG),nM.checkStorage();var Kq=class e extends Dj.EventEmitter{constructor(t,i){super(),aR(this,"_room"),aR(this,"_eventListened",new Set),aR(this,"_localVideoTrack",null),aR(this,"_localAudioTrack",null),aR(this,"_localScreenTrack",null),aR(this,"_localScreenAudioTrack",null),aR(this,"_localVideoConfig",null),aR(this,"_localScreenConfig",null),aR(this,"_localAudioConfig",null),aR(this,"_remoteVideoConfigMap",new Map),aR(this,"_remoteAudioConfigMap",new Map),aR(this,"_remoteAudioVolumeMap",new Map),aR(this,"_remoteAudioMuteMap",new Map),aR(this,"_mediaTrackMap",new WeakMap),aR(this,"_log",rM.createLogger({id:"t".concat(++Gq)})),aR(this,"_plugins",new Map),aR(this,"_networkQuality",null),aR(this,"_speakerId"),aR(this,"enterRoomParams"),aR(this,"_enableAutoSwitchWhenRecapturing",!0),this._room=new t(Zw({logger:this._log,frameWorkType:e.frameWorkType},i)),this._room.videoDecodeFallbackType=i.videoDecodeFallback,QC(i.enableAutoSwitchWhenRecapturing)&&(this._enableAutoSwitchWhenRecapturing=i.enableAutoSwitchWhenRecapturing),this._log.info("create() ".concat(JSON.stringify(i,((e,t)=>"plugins"===e?t.map((e=>e.Name)):t)))),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}}),i.plugins&&i.plugins.forEach((e=>{this._use(e,i.assetsPath)})),this._use($G,i.assetsPath),this._use(qG,i.assetsPath),this._use(tz,i.assetsPath),this._use(Vq,i.assetsPath),this._use(Mq),i.enableSEI&&EP&&this._use(dz),this._room.on("audio-volume",(e=>{var t,r;!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*(null!=(t=this._localAudioTrack.getInternalAudioLevelAfter3A())?t:this._localAudioTrack.getAudioLevel())),floatVolume:null!=(r=this._localAudioTrack.getInternalAudioLevelAfter3A())?r:this._localAudioTrack.getInternalAudioLevel()}),1===i.volumeType&&e.forEach((e=>{var t;let i=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;i&&(e.volume=i.dbVolume)})),i.enableDbVolume&&e.forEach((e=>{var t;let i=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;i&&(e.volume=i.dbVolume)})),this.emit(mG.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{this._log.error(new Bj({code:Pj.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:i}=e;e.emit=function(){for(var r=arguments.length,o=new Array(r),n=0;n<r;n++)o[n]=arguments[n];try{return i.apply(e,o)}catch(pM){let i=vL({key:mL.CATCH_HANDLER_ERROR,data:{name:t,event:o[0]},addDocLink:!1});return rM.warn("".concat(i,"\n\n").concat(pM.stack)),!1}}})(this,"trtc")}static create(e){}static _create(t,i){!function(){var e;if(Mj){Mj=!1,5!==rM.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(FR,"/en/index.html")),console.info("* Changelog: ".concat(FR,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),rM.info("TRTC Web SDK Version:",wR),MO||rM.debug("Build Time:","2025-12-04 16:34:28");let t="UA: ".concat(navigator.userAgent," \nCPU core: ").concat(navigator.hardwareConcurrency,", GPU: ").concat(HO()),i=navigator.deviceMemory;i&&(t+=", minRAM: ".concat(i,"GB")),rM.info(t),rM.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),BO().then((e=>{e&&rM.info(FO)}))}}();let r=new e(t,i||{});return zq.add(r),r.__v_skip=!0,r}get room(){return this._room}_listenEvents(){ix(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(mG.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(mG.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{TG(!0),this._exitRoom().finally((()=>{this.emit(mG.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().finally((()=>{this.emit(mG.ERROR,Bj.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(mG.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e;let t=eR(Zw({},e),{uplinkRTT:Math.min(e.uplinkRTT,nC),downlinkRTT:Math.min(e.downlinkRTT,nC)});this.emit(mG.NETWORK_QUALITY,t)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{ix(t,t).add("player-state-changed",(i=>{let r=eR(Zw({},i),{userId:e.userId});t.kind===ok.VIDEO&&(r.streamType=Hj(t.streamType)),this.emit(t.kind===ok.AUDIO?mG.AUDIO_PLAY_STATE_CHANGED:mG.VIDEO_PLAY_STATE_CHANGED,r)})).add("error",(e=>{e.getCode()===_R.PLAY_NOT_ALLOWED&&this.emit(mG.AUTOPLAY_FAILED,{userId:t.userId,mediaType:t.strMediaType,resume:()=>t.player.resume()})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{rx(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:i}=e,{userId:r}=i,o=t.audioAvailable,n=t.videoAvailable,{audioAvailable:a,videoAvailable:s}=i;a||this._remoteAudioConfigMap.delete(r),s||this._removeRemoteVideoConfig(r,"main"),i.hasAuxiliary||this._removeRemoteVideoConfig(r,"sub"),n!==s&&(s?this._onVideoAvailable({userId:r,streamType:"main"}):this._onVideoUnavailable({userId:r,streamType:"main"}),this.emit(s?mG.REMOTE_VIDEO_AVAILABLE:mG.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"main"})),o!==a&&(a?this._onAudioAvailable({userId:r}):this._onAudioUnavailable({userId:r,muteState:i}),this.emit(a?mG.REMOTE_AUDIO_AVAILABLE:mG.REMOTE_AUDIO_UNAVAILABLE,{userId:r})),t.hasAuxiliary!==i.hasAuxiliary&&(i.hasAuxiliary?this._onVideoAvailable({userId:r,streamType:"sub"}):this._onVideoUnavailable({userId:r,streamType:"sub"}),this.emit(i.hasAuxiliary?mG.REMOTE_VIDEO_AVAILABLE:mG.REMOTE_VIDEO_UNAVAILABLE,{userId:r,streamType:"sub"}))})).add("sei-message",(e=>{this.emit(mG.SEI_MESSAGE,eR(Zw({},e),{streamType:Hj(e.streamType)}))})).add("firewall-restriction",(()=>{this.emit(mG.ERROR,new Bj({code:Pj.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(e=>{var t,i,r,o,n,a,s;let c={2:"big",3:"small",7:"sub"},l={rtt:Math.min(e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(i=this._networkQuality)?void 0:i.uplinkRTT)||(null==(r=this._networkQuality)?void 0:r.downlinkRTT)||0,nC),upLoss:(null==(o=this._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(n=this._networkQuality)?void 0:n.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_level)||0)/ZM},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/ZM,point2pointDelay:(e.msg_audio_status.uint32_audio_p2p_delay||0)+(e.msg_audio_status.uint32_audio_cache_ms||0),jitterBufferDelay:e.msg_audio_status.uint32_audio_cache_ms||0},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type],point2pointDelay:(e.uint32_video_p2p_delay||0)+(e.uint32_video_cache_ms||0),jitterBufferDelay:e.uint32_video_cache_ms||0,codec:e.uint32_video_codec})))})))};this.emit(mG.STATISTICS,l)})).add("custom-message",(e=>{this.emit(mG.CUSTOM_MESSAGE,e)})).add("layerData",(e=>this.emit(mG.LAYER_DATA,e))).add("first-video-frame",(e=>{this.emit(mG.FIRST_VIDEO_FRAME,eR(Zw({},e),{streamType:Hj(e.streamType)}))})).add("audio-frame",(e=>{this.emit(mG.AUDIO_FRAME,e)})),ix(this,dU).add("audioInputAdded",(e=>{this.emit(mG.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(mG.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(mG.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(mG.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>cR(this,null,(function*(){if(this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),qq&&qq.deviceId===$k){let e=(yield _U()).find((e=>e.deviceId===$k));e&&qq.groupId!==e.groupId&&(qq=e,this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>cR(this,null,(function*(){this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield _U())[0];if(!t||!qq||qq.groupId===t.groupId)return;let i=qq.deviceId===e.deviceId,r=qq.deviceId===$k&&qq.deviceId===t.deviceId;(i||r)&&(qq=t,this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))})))),ix(this,jq).add("permission-state-change",(e=>{this.emit(mG.PERMISSION_STATE_CHANGE,e)})),this.room.enableSEI&&this.on(mG.SEI_MESSAGE,(e=>{var t;let i=null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteVideoTrack;i&&i.updateAlphaRenderInfo(e)}))}getNetworkTime(){return yR()}use(e){let t,i;return"plugin"in e?(t=e.plugin,i=e.assetsPath):t=e,"Chorus"===t.Name&&(this.room.enableChorus=!0),this._use(t,i)}_use(t,i){let r=this._plugins.get(t.Name);if(r)return this._log.warn("duplicate install plugin",t.Name),r;let o=new t(MG.call(this,{TRTC:e,room:this._room,assetsPath:i,errorModule:{RtcError:Bj,ErrorCode:Pj,CoreErrorCode:_R,ErrorCodeDictionary:xj}}));return this._plugins.set(t.Name,o),o.__v_skip=!0,t.autoStart&&this.startPlugin(t.Name),o}enterRoom(t){return cR(this,null,(function*(){var i,r;this.enterRoomParams=t;let{scene:o="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:a=!0,autoReceiveVideo:s=!1}=t;t.proxy&&(this._room.setProxyServer(t.proxy),!XC(t.proxy)&&t.proxy.turnServer&&(null==(r=(i=this._room).setTurnServer)||r.call(i,t.proxy.turnServer,t.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=a,this._room.autoReceiveVideo=s,QC(t.preferHW)&&(this._room.preferHW=t.preferHW),t.playoutDelay&&(this._room.playoutDelay=t.playoutDelay),t.jitterBufferDelay&&(this._room.jitterBufferDelay=t.jitterBufferDelay);let c={sdkAppId:t.sdkAppId,userId:t.userId,userSig:t.userSig,privateMapKey:t.privateMapKey||null,latencyLevel:t.latencyLevel,role:"audience"===t.role?21:20,roomId:t.roomId||0,strRoomId:t.strRoomId||"",businessInfo:t.businessInfo||null,streamId:null,userDefineRecordId:t.userDefineRecordId||null,frameWorkType:t.frameWorkType,component:t.component,language:t.language,priority:t.priority,useVp8:t.useVp8,useH265:t.useH265,keepAlive:t.keepAlive};t.strRoomId&&!t.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,yield this._room.join(c,o,e.frameWorkType),this._checkTrackToPublish(),oz.start()}))}exitRoom(){return cR(this,null,(function*(){return yield this._exitRoom()}))}switchRoom(e){return cR(this,null,(function*(){if(this.room.isSwitchRoomSupported())try{this._clearRemoteTracks(),yield this._room.switchRoom(e)}catch(Ok){if(!(Ok instanceof gR)||Ok.code!==_R.API_CALL_TIMEOUT&&Ok.code!==_R.SWITCH_ROOM_FAILED)throw Ok;this._log.warn("switchRoom ".concat(Ok.code===_R.API_CALL_TIMEOUT?"timeout":"failed",", fallback to exitRoom() and enterRoom()")),yield this._rejoinRoom(e)}else yield this._rejoinRoom(e)}))}_rejoinRoom(e){return cR(this,null,(function*(){yield this.exitRoom();let t=Zw(Zw({},this.enterRoomParams),e);yield this.enterRoom(t)}))}_clearRemoteTracks(){new Set([...this._remoteAudioConfigMap.keys(),...this._remoteAudioMuteMap.keys()]).forEach((e=>{this._stopRemoteAudio({userId:e}).catch((()=>{}))})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",i=e.split("_".concat(t))[0];i&&this._stopRemoteVideo({userId:i,streamType:t}).catch((()=>{}))})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),function(e){let t=LG.get(e);t&&(t.forEach((e=>clearTimeout(e))),LG.delete(e))}(this),this._room.remotePublishedUserMap.forEach((e=>{rx(e.remoteAudioTrack),rx(e.remoteVideoTrack),rx(e.remoteAuxiliaryTrack)}))}switchRole(e,t){return cR(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){this._plugins.forEach((e=>{var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),rx(this),this.removeAllListeners(),this._room.destroy(),zq.delete(this),0===zq.size&&oz.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),$O.off("102",this._onLocalTrackCaptured,this)}startLocalAudio(){return cR(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:i=!0,mute:r,option:o}=t,n=new dB(e._room.audioManager),a={},s={muted:!0};o&&(YC(o.microphoneId)?YC(o.audioTrack)||(a.customSource=o.audioTrack):a.deviceId=o.microphoneId,o&&JC(o.captureVolume)&&n.setCaptureVolume(o.captureVolume),YC(o.profile)||(XC(o.profile)?ZR[o.profile]&&n.setProfile(ZR[o.profile]):n.setProfile(o.profile)),JC(o.earMonitorVolume)&&(s.muted=!(o.earMonitorVolume>0),s.volume=o.earMonitorVolume),YC(o.echoCancellation)||(n.profile.echoCancellation=o.echoCancellation),YC(o.noiseSuppression)||(n.profile.noiseSuppression=o.noiseSuppression),YC(o.autoGainControl)||(n.profile.autoGainControl=o.autoGainControl),QC(e._enableAutoSwitchWhenRecapturing)&&(n.enableAutoSwitchWhenRecapturing=e._enableAutoSwitchWhenRecapturing)),n.on("5",(t=>{e.emit(mG.ERROR,new Bj({code:Pj.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),n.on("2",(t=>{e.emit(mG.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),n.on("4",(t=>{let i;t.error&&(i=Bj.convertFrom(t.error)),e.emit(mG.PUBLISH_STATE_CHANGED,eR(Zw({},t),{error:i}))})),n.on("6",(()=>{})),e._listenOutputTrackChanged(n),e._speakerId&&n.setAudioOutput(e._speakerId),yield n.capture(a),YC(r)||n.setMute(r),ix(n,n).add("player-state-changed",(t=>{e.emit(mG.AUDIO_PLAY_STATE_CHANGED,eR(Zw({},t),{userId:""}))})),i&&e._room.isJoined&&e._room.publish(n).catch((()=>{})),e._localAudioTrack=n,e._localAudioConfig=eR(Zw({},t),{publish:i}),yield e._updateAudioPlayOption({playOption:s,track:n}),$O.emit("113",{userId:"",room:e.room})}()}))}updateLocalAudio(e){return cR(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:i,option:r}=e,o={};r&&(r.microphoneId?yield this._localAudioTrack.switchDevice(r.microphoneId):YC(r.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(r.audioTrack)),YC(r.captureVolume)||this._localAudioTrack.setCaptureVolume(r.captureVolume),YC(r.earMonitorVolume)||(o.muted=!(r.earMonitorVolume>0),o.volume=r.earMonitorVolume),yield this._localAudioTrack.update3A(r)),this._room.isJoined&&!YC(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),YC(i)||this._localAudioTrack.setMute(i),yield this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),_D(this._localAudioConfig,e)}))}stopLocalAudio(){return cR(this,null,(function*(){this._localAudioTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),$O.emit("114",{userId:"",room:this.room}),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),rx(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return cR(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null,capture:!0};return function*(){var i;if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:r,publish:o=!0,capture:n=!0,mute:a,option:s}=t,c=new mB(e._room.videoManager),l={},d={};s&&(QC(s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s.cameraId?l.deviceId=s.cameraId:YC(s.useFrontCamera)?YC(s.videoTrack)||(l.customSource=s.videoTrack):l.facingMode=s.useFrontCamera?ok.FACING_MODE_USER:ok.FACING_MODE_ENVIRONMENT,YC(s.retryWhenExactFailed)||(l.retryWhenExactFailed=s.retryWhenExactFailed),s.qosPreference&&(l.contentHint=Wj(s.qosPreference)),YC(s.profile)||(XC(s.profile)?ek[s.profile]&&c.setProfile(ek[s.profile]):c.setProfile(s.profile)),YC(s.fillMode)||(d.objectFit=s.fillMode),YC(s.mirror)||(d.mirror=s.mirror),YC(s.small)||(YC(s.smallMode)||(e._room.smallMode=s.smallMode),QC(s.small)&&!1===s.small?c.stopSmall():c.updateSmallConfig(jj(s.small,!0))),YC(s.rotation)||c.setRotation(s.rotation),QC(e._enableAutoSwitchWhenRecapturing)&&(c.enableAutoSwitchWhenRecapturing=e._enableAutoSwitchWhenRecapturing)),c.once("first-video-frame",(t=>{e.emit(mG.FIRST_VIDEO_FRAME,eR(Zw({},t),{streamType:Hj(t.streamType)}))})),c.on("5",(t=>{e.emit(mG.ERROR,new Bj({code:Pj.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(t=>{e.emit(mG.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(t=>{let i;t.error&&(i=Bj.convertFrom(t.error)),e.emit(mG.PUBLISH_STATE_CHANGED,eR(Zw({},t),{error:i}))})),c.on("6",(()=>{})),e._listenOutputTrackChanged(c),n?yield c.capture(l):null==(i=c.manager)||i.changeInput(c),YC(a)||(yield c.setMute(a)),ix(c,c).add("player-state-changed",(t=>{e.emit(mG.VIDEO_PLAY_STATE_CHANGED,eR(Zw({},t),{userId:"",streamType:"main"}))})).add("video-size-changed",(t=>{e.emit(mG.VIDEO_SIZE_CHANGED,eR(Zw({},t),{streamType:Hj(t.streamType)}))})),o&&e._room.isJoined&&e._room.publish(c).catch((()=>{})),e._localVideoTrack=c,e._localVideoConfig=eR(Zw({},t),{view:r,publish:o,capture:n}),yield e._updateVideoPlayOption({view:r,playOption:d,track:c})}()}))}updateLocalVideo(e){return cR(this,null,(function*(){var t,i,r;if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:o,publish:n,mute:a,capture:s,option:c}=e,l={};if(this._localVideoConfig.capture)!1!==s?null!=c&&c.cameraId?yield this._localVideoTrack.switchDevice(null==c?void 0:c.cameraId):YC(null==c?void 0:c.useFrontCamera)?YC(null==c?void 0:c.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(null==c?void 0:c.videoTrack)):yield this._localVideoTrack.switchDevice(null!=c&&c.useFrontCamera?ok.FACING_MODE_USER:ok.FACING_MODE_ENVIRONMENT):this._localVideoTrack.stopCapture();else if(s){let e={};e.deviceId=(null==c?void 0:c.cameraId)||(null==(t=this._localVideoConfig.option)?void 0:t.cameraId),e.facingMode=null!=c&&c.useFrontCamera||null!=(i=this._localVideoConfig.option)&&i.useFrontCamera?ok.FACING_MODE_USER:ok.FACING_MODE_ENVIRONMENT,e.customSource=(null==c?void 0:c.videoTrack)||(null==(r=this._localVideoConfig.option)?void 0:r.videoTrack),yield this._localVideoTrack.capture(e)}c&&(YC(c.profile)||(XC(c.profile)?ek[c.profile]&&this._localVideoTrack.setProfile(ek[c.profile]):this._localVideoTrack.setProfile(c.profile),(!c.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(c.cameraId))&&YC(c.useFrontCamera)&&(yield this._localVideoTrack.applyProfile())),YC(c.fillMode)||(l.objectFit=c.fillMode),YC(c.mirror)||(l.mirror=c.mirror),YC(c.rotation)||this._localVideoTrack.setRotation(c.rotation),c.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(Wj(c.qosPreference)),YC(c.small)||(QC(c.small)&&!c.small?this._localVideoTrack.stopSmall():this._localVideoTrack.updateSmallConfig(jj(c.small,!0)))),this._room.isJoined&&YC(n)&&this._localVideoConfig.publish&&s&&!this._localVideoConfig.capture&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._room.isJoined&&((null!=n?n:this._localVideoConfig.publish)?this._room.publish(this._localVideoTrack).catch((()=>{})):this._room.unpublish(this._localVideoTrack).catch((()=>{}))),YC(a)||(yield this._localVideoTrack.setMute(a)),yield this._updateVideoPlayOption({view:o,playOption:l,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),_D(this._localVideoConfig,e)}))}stopLocalVideo(){return cR(this,null,(function*(){this._localVideoTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),rx(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return cR(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){var i,r;if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:o=null,publish:n=!0,muteSystemAudio:a,option:s}=t,c=new GB(e._room.videoManager);c.on("4",(t=>{let i;t.error&&(i=Bj.convertFrom(t.error)),e.emit(mG.PUBLISH_STATE_CHANGED,eR(Zw({},t),{error:i}))})),c.once("first-video-frame",(t=>{e.emit(mG.FIRST_VIDEO_FRAME,eR(Zw({},t),{streamType:Hj(t.streamType)}))})),e._listenOutputTrackChanged(c),"main"===t.streamType&&(c.mediaType=4);let l=null,d={},u={};s&&(YC(s.profile)||(XC(s.profile)?rk[s.profile]&&c.setProfile(rk[s.profile]):c.setProfile(s.profile)),s.systemAudio&&(d.systemAudio=!0,d.echoCancellation=s.echoCancellation,d.noiseSuppression=s.noiseSuppression,d.autoGainControl=s.autoGainControl),YC(s.fillMode)||(u.objectFit=s.fillMode),s.videoTrack&&(d.videoTrack=s.videoTrack),s.audioTrack&&(d.audioTrack=s.audioTrack),s.captureElement&&(d.captureElement=s.captureElement),s.preferDisplaySurface&&(d.preferDisplaySurface=s.preferDisplaySurface),s.qosPreference&&(d.contentHint=Wj(s.qosPreference)));let h=yield c.capture(d);if(c.mediaTrack.addEventListener(ok.ENDED,(()=>{e._stopScreenShare(),e.emit(mG.SCREEN_SHARE_STOPPED)})),h.getAudioTracks()[0]){l=new qB(e._room.audioManager);let o=h.getAudioTracks()[0];null!=(i=t.option)&&i.systemAudio&&!(null!=(r=t.option)&&r.audioTrack)&&(l.sourceTrack=o),yield l.setInputMediaStreamTrack(o),QC(a)&&l.mediaTrack&&(l.mediaTrack.enabled=!a),e._speakerId&&l.setAudioOutput(e._speakerId)}if(ix(c,c).add("player-state-changed",(t=>{e.emit(mG.VIDEO_PLAY_STATE_CHANGED,eR(Zw({},t),{userId:"",streamType:"sub"}))})),n&&e._room.isJoined){let t=[c];l&&(t.push(l),e._checkScreenAudioEchoCancellation(c,l)),t.forEach((t=>e._room.publish(t).catch((()=>{}))))}e._localScreenTrack=c,e._localScreenAudioTrack=l,e._localScreenConfig=eR(Zw({},t),{view:o,publish:n}),yield e._updateVideoPlayOption({view:o,playOption:u,track:c})}()}))}updateScreenShare(e){return cR(this,null,(function*(){var t;if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:i,publish:r,muteSystemAudio:o,option:n}=e,a={};if(n&&(YC(n.fillMode)||(a.objectFit=n.fillMode),n.qosPreference)){let e=Wj(n.qosPreference);this._localScreenTrack.setContentHint(e)}if(this._room.isJoined&&!YC(r)){if(r&&!this._localScreenConfig.publish){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),e.forEach((e=>this._room.publish(e).catch((()=>{}))))}if(this._localScreenConfig.publish&&!r){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),e.forEach((e=>this._room.unpublish(e).catch((()=>{}))))}}null!=(t=this._localScreenAudioTrack)&&t.mediaTrack&&QC(o)&&(this._localScreenAudioTrack.mediaTrack.enabled=!o),yield this._updateVideoPlayOption({view:i,playOption:a,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),_D(this._localScreenConfig,e)}))}stopScreenShare(){return cR(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return cR(this,null,(function*(){let{view:t,userId:i,streamType:r,option:o}=e,n="".concat(i,"_").concat(r);if(this._remoteVideoConfigMap.has(n))return void this._log.warn("remote video has already started. userId:".concat(i,", streamType:").concat(r));let a=this._room.remotePublishedUserMap.get(i);if(!a)return;let s={},c="main"===r?a.remoteVideoTrack:a.remoteAuxiliaryTrack;c.on("decode-failed",(e=>{this.emit(mG.ERROR,new Bj({code:Pj.OPERATION_FAILED,extraCode:5507,message:"video decode failed"}))})),c.on("video-size-changed",(e=>{this.emit(mG.VIDEO_SIZE_CHANGED,eR(Zw({},e),{streamType:Hj(e.streamType)}))})),this._listenOutputTrackChanged(c),o&&(YC(o.fillMode)||(s.objectFit=o.fillMode),YC(o.mirror)||(s.mirror=o.mirror),YC(o.poster)||(s.poster=o.poster),s.canvasRender=o.canvasRender,"main"===r&&!YC(o.small)&&(!a.remoteVideoTrack.isSubscribing&&!a.remoteVideoTrack.isSubscribed&&a.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,c.user)),YC(o.draggable)||c.setDraggable(o.draggable)),yield this._room.subscribe(c),yield this._enableVideoDecodeFallback(c,r),yield this._updateVideoPlayOption({view:t,playOption:s,track:c}),this._emitTrackEvent(c),this._remoteVideoConfigMap.set(n,{config:e}),o&&!YC(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:c,view:t,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot})}))}updateRemoteVideo(e){return cR(this,null,(function*(){var t,i;let{view:r,userId:o,streamType:n,option:a}=e,s="".concat(o,"_").concat(n),c=this._remoteVideoConfigMap.get(s);if(!c||!this._room.remotePublishedUserMap.has(o))return;let l={};a&&(YC(a.fillMode)||(l.objectFit=a.fillMode),YC(a.mirror)||(l.mirror=a.mirror));let d=null,u=this._room.remotePublishedUserMap.get(o);if("main"===n&&null!=u&&u.muteState.hasVideo&&(d=u.remoteVideoTrack),"sub"===n&&null!=u&&u.muteState.hasAuxiliary&&(d=u.remoteAuxiliaryTrack),!d)return;let{config:h}=c;"main"===n&&a&&!YC(a.small)&&this._room.changeType(a.small,d.user),a&&!YC(a.draggable)&&d.setDraggable(a.draggable),yield this._updateVideoPlayOption({view:r,playOption:l,track:d,prevConfig:h}),_D(h,e);let p=YC(null==a?void 0:a.receiveWhenViewVisible)?null==(t=h.option)?void 0:t.receiveWhenViewVisible:a.receiveWhenViewVisible,m=YC(r)?h.view:r,f=YC(null==a?void 0:a.viewRoot)?null==(i=h.option)?void 0:i.viewRoot:a.viewRoot;this._observeView({remoteTrack:d,view:m,receiveWhenViewVisible:p,viewRoot:f})}))}stopRemoteVideo(e){return cR(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return cR(this,null,(function*(){let i=[],r=this._room.remotePublishedUserMap.get(e.userId);if(r){let{muteState:t,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=r;"main"===e.streamType&&(o.stop(),t.hasVideo&&i.push(o)),"sub"===e.streamType&&(n.stop(),t.hasAuxiliary&&i.push(n))}for(let e of i)t&&(yield this._room.unsubscribe(e),this._mediaTrackMap.delete(e.outMediaTrack));this._removeRemoteVideoConfig(e.userId,e.streamType)}))}_removeRemoteVideoConfig(e,t){let i="".concat(e,"_").concat(t),r=this._remoteVideoConfigMap.get(i);r&&r.observer&&r.observer.disconnect(),this._remoteVideoConfigMap.delete(i)}muteRemoteAudio(e,t){return cR(this,null,(function*(){this._remoteAudioMuteMap.set(e,t);try{if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&!this._remoteAudioConfigMap.has(t.userId)&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):this._remoteAudioConfigMap.has(e)||(yield this._startRemoteAudio({userId:e}))}catch(pM){throw pM.code!==Pj.OPERATION_ABORT&&this._remoteAudioMuteMap.delete(e),pM}}))}setRemoteAudioVolume(e,t){if("*"===e){this._remoteAudioVolumeMap.set("*",t),this._remoteAudioVolumeMap.forEach(((e,i)=>this._remoteAudioVolumeMap.set(i,t)));let e=[...this._room.remotePublishedUserMap.values()];for(let i of e)this._remoteAudioVolumeMap.set(i.userId,t),i.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}else if(e){let i=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),i&&i.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:i.remoteAudioTrack})}}startPlugin(e,t){return cR(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return cR(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return cR(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,i){if(this.listeners(e).includes(t))return this;if(this._log.debug("on",e),super.on(e,t,i),this._eventListened.add(e),this.listeners(mG.AUDIO_FRAME).length>0){let{audioFrameEventConfigMap:e}=this.room.audioManager;e.get("")||e.set("",{enable:!0}),this._localAudioTrack&&this.room.audioManager.handleLocalTrackStarted({userId:"",room:this.room})}return this}emit(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];try{fG.has(e)||this._log.debug("emit ".concat(e," ").concat(JSON.stringify(i)))}catch(pM){}return super.emit(e,...i)}off(t,i,r){if(this._log.debug("off",t),"*"===t?(this._eventListened.clear(),this.removeAllListeners()):super.off(t,i,r),(t===e.EVENT.AUDIO_FRAME||"*"===t)&&0===this.listeners(e.EVENT.AUDIO_FRAME).length){let{getPCMAbortCtrlMap:e}=this.room.audioManager;e.forEach((e=>{null==e||e.abort("off")})),e.clear()}return this}getAudioTrack(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},i=null,r="main",o=!1;if(XC(t)?e=t:(e=t.userId,o=!0===t.processed,t.streamType&&(r=t.streamType)),e){let t=this._room.remotePublishedUserMap.get(e);t&&(i=t.remoteAudioTrack)}else i="sub"===r?this._localScreenAudioTrack:this._localAudioTrack;return i?o&&i.outMediaTrack&&i.outMediaTrack!==i.mediaTrack?i.outMediaTrack.clone():i.mediaTrack:null}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:i="main",processed:r=!1}=e,o=null;if(""===t)"main"===i&&this._localVideoTrack&&(o=this._localVideoTrack),"sub"===i&&this._localScreenTrack&&(o=this._localScreenTrack);else{let e=this._room.remotePublishedUserMap.get(t);e&&(o="main"===i?e.remoteVideoTrack:e.remoteAuxiliaryTrack)}return o?r&&o.outMediaTrack&&o.outMediaTrack!==o.mediaTrack?o.outMediaTrack.clone():o.mediaTrack:null}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:i="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===i&&null!=e&&e.muteState.hasVideo)return e.remoteVideoTrack.getVideoFrame();if("sub"===i&&null!=e&&e.muteState.hasAuxiliary)return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===i&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===i&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}_setCurrentSpeaker(e){var t,i;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(i=this._localScreenAudioTrack)||i.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}setCurrentSpeaker(e){return cR(this,null,(function*(){(yield _U()).forEach((t=>{t.deviceId===e&&(this._setCurrentSpeaker(e),this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),qq=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: '.concat(FR,"/en/TRTC.html#.setCurrentSpeaker"))}))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return cR(this,null,(function*(){var t;let{userId:i}=e;if(this._remoteAudioConfigMap.has(i))return void this._log.warn("remote audio has already started. userId:".concat(i));let r=this._room.remotePublishedUserMap.get(i);if(!r)return;let o={},n=r.remoteAudioTrack;n.on("decode-failed",(e=>{this.emit(mG.ERROR,new Bj({code:Pj.OPERATION_FAILED,extraCode:5508,message:"audio decode failed"}))})),this._listenOutputTrackChanged(n),this._speakerId&&n.setAudioOutput(this._speakerId);try{let r=null!=(t=this._remoteAudioVolumeMap.get(i))?t:this._remoteAudioVolumeMap.get("*"),a=JC(r)?r:100;o.volume=a,this._remoteAudioConfigMap.set(i,e),yield this._room.subscribe(n),ZU(MV(n,"decode-failed"),tF(MV(n,qP.INIT)),iB((()=>{this.startPlugin(Vq.Name,{track:n,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),yield this._updateAudioPlayOption({playOption:o,track:n}),$O.emit("115",{userId:i,room:this.room}),n.outMediaTrack&&this.room.audioManager.updateAudioReference({type:"add",audioReference:n.outMediaTrack,refId:"ra-".concat(i)})}catch(fM){throw this._remoteAudioConfigMap.delete(i),fM}this._emitTrackEvent(n)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return cR(this,null,(function*(){let i=this._room.remotePublishedUserMap.get(e.userId);i&&(i.remoteAudioTrack.stop(),i.muteState.hasAudio&&t&&(yield this._room.unsubscribe(i.remoteAudioTrack)),this._mediaTrackMap.delete(i.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId)),$O.emit("116",{userId:e.userId,room:this.room}),this.room.audioManager.updateAudioReference({type:"remove",refId:"ra-".concat(e.userId)})}))}_enableVideoDecodeFallback(e,t){let i,r=this._room.videoDecodeFallbackType;r&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),ZU(MV(e,"decode-failed"),tF(MV(e,qP.INIT)),rB((()=>{"h265"!==this._room.downlinkVideoCodec&&this.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:r})})),LF(MV(e,"decode-downgrade-state-changed")),iB((r=>{i=r.state,this.emit(mG.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,eR(Zw({},r),{streamType:t,userId:e.userId}))}),(t=>{e.log.error("fallback",t)}),(()=>{"STARTED"===i&&e.log.info("fallback complete")}))))}_updateVideoPlayOption(e){return cR(this,arguments,(function(e){let{view:t,playOption:i,track:r,prevConfig:o}=e;return function*(){if(r.setMirror(i.mirror),YC(t)&&o&&o.view&&!hD(i)){let e=vD(o.view);e.length>0&&(yield r.play(e,i))}if(!YC(t)){let e=vD(t);e.length>0?yield r.play(e,i):r.stop()}}()}))}_updateAudioPlayOption(e){return cR(this,arguments,(function(e){var t=this;let{playOption:i={},track:r,prevConfig:o}=e;return function*(){if(!r.isPlayCalled)try{yield r.play(null,i)}catch(CR){}if(YC(i.muted)||r.setPlayerMute(i.muted),YC(i.volume)||r.setAudioVolume(i.volume/100),r instanceof dB&&r.mediaTrack){let e=!1===i.muted&&!YC(i.volume)&&i.volume>0?"add":"remove";t.room.audioManager.updateAudioReference({type:e,audioReference:r.mediaTrack,refId:"em"})}else if(r instanceof QB){let e=i.muted?0:i.volume;if(YC(e))return;t.room.audioManager.updateAudioReference({type:"updateVolume",refId:"ra-".concat(r.userId),volume:i.volume})}}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e,!1)))}_emitTrackEvent(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===i||(this._mediaTrackMap.set(e.outMediaTrack,i),this.emit(mG.TRACK,{userId:i,streamType:Hj(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}_checkTrackToPublish(){var e,t,i;let r=[];if(null!=(e=this._localAudioConfig)&&e.publish&&this._localAudioTrack&&r.push(this._localAudioTrack),null!=(t=this._localVideoConfig)&&t.publish&&this._localVideoTrack&&r.push(this._localVideoTrack),null!=(i=this._localScreenConfig)&&i.publish&&(this._localScreenTrack&&r.push(this._localScreenTrack),this._localScreenAudioTrack&&r.push(this._localScreenAudioTrack),this._checkScreenAudioEchoCancellation(this._localScreenTrack,this._localScreenAudioTrack)),0!==r.length)return Promise.all(r.map((e=>this._room.publish(e).catch((()=>{})))))}_observeView(e){let{remoteTrack:t,view:i,receiveWhenViewVisible:r=!1,viewRoot:o}=e;if(YC(i))return;let n=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(Hj(t.streamType)));if(!n)return;let a=n.observer||void 0;if(null===i||ZC(i)&&0===i.length||!r)return null==a||a.disconnect(),void(t.isSubscribed||this._room.subscribe(t).catch((()=>{})));let s=n.visibleViewMap||new Map,c=-1;(!a||a.root!==o)&&(null==a||a.disconnect(),s.clear(),a=new IntersectionObserver((e=>{e.forEach((e=>{s.set(e.target,e.isIntersecting),t.log.info("view ".concat(e.target.id," is").concat(e.isIntersecting?"":" not"," visible"))})),clearTimeout(c),c=window.setTimeout((()=>{[...s.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:o}));let l=new Set(vD(i));s.forEach(((e,t)=>{l.has(t)||(a.unobserve(t),s.delete(t))})),l.forEach((e=>{s.set(e,!0),a.observe(e)})),a.takeRecords().forEach((e=>{s.set(e.target,e.isIntersecting)})),n.visibleViewMap=s,n.observer=a}_exitRoom(){return cR(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),this._clearRemoteTracks()}))}_stopScreenShare(){return cR(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),yield Promise.all(e.map((e=>this._room.unpublish(e).catch((()=>{})))))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(!1===(null==(e=this._localScreenAudioTrack.trackSettings)?void 0:e.echoCancellation)&&this.stopPlugin("AudioProcessor"),this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),rx(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_checkScreenAudioEchoCancellation(e,t){return cR(this,null,(function*(){var i,r;if(!e||!t)return;let o=null==(i=e.trackSettings)?void 0:i.displaySurface;if(!1===(null==(r=t.trackSettings)?void 0:r.echoCancellation)&&("monitor"===o||"browser"===o&&e.isShareCurrentTab)){this._log.warn("echoCancellation of screen audio track is disable. Try starting audioProcessor plugin");try{yield this.startPlugin("AudioProcessor",{sdkAppId:Number(this.room.sdkAppId),userId:this._room.userId,userSig:this.room.userSig,isScreenAudioNeedAudioProcess:!0,isLocalAudioNeedAudioProcess:!1})}catch(hM){this._log.warn("start audioProcessor plugin failed: ",hM)}}}))}_onLocalTrackCaptured(e){let{track:t}=e;"audio"===t.kind&&(!qq||uU(qq))&&(this._initActiveSpeaker(),$O.off("102",this._onLocalTrackCaptured,this))}_initActiveSpeaker(){return cR(this,null,(function*(){if(qq&&!uU(qq))this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:qq});else{let e=yield _U();e[0]&&!uU(e[0])?(qq=e[0],this.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]})):$O.on("102",this._onLocalTrackCaptured,this)}}))}_onAudioAvailable(e){let{userId:t}=e,i=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===i||this._room.autoReceiveAudio&&!i)&&this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:i}=e;if(!this._room.autoReceiveVideo)return;let r=this._room.remotePublishedUserMap.get(t);if(r){let e="main"===i?r.remoteVideoTrack:r.remoteAuxiliaryTrack,t=[e];this._room.autoReceiveAudio&&r.remoteAudioTrack.isAvailable&&t.push(r.remoteAudioTrack),this._room.subscribe(...t).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:i}=e;i.hasAudio&&i.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:i}=e;this._stopRemoteVideo({userId:t,streamType:i},!1).catch((()=>{}))}sendSEIMessage(e,t){var i;let r=this._plugins.get("SEI");r&&(r.update({buffer:e,options:eR(Zw({seiPayloadType:243},t),{small:!(null==(i=this._localVideoTrack)||!i.small)})}),CL.addCount({key:5e5,useUV:!0}))}sendCustomMessage(e){var t,i;null==(i=(t=this._room).sendCustomMessage)||i.call(t,e),CL.addCount({key:500001,useUV:!0})}callExperimentalAPI(e,t){return cR(this,null,(function*(){return this._log.info("callExperimentalAPI(".concat(e,", ").concat(JSON.stringify(t),")")),Bq.call(e,Zw({trtcInstance:this},t))}))}static setLogLevel(e,t){rM.setLogLevel(e),YC(t)||(t?rM.enableUploadLog():rM.disableUploadLog())}static isSupported(){return WL(e.frameWorkType)}static getPermissions(e){return cR(this,arguments,(function(e){let{request:t=!0,types:i=["camera","microphone"]}=e;return function*(){t&&(yield jq.request(i).catch((e=>{var t;return rM.error("getPermissions request failed, error: ".concat(null!=(t=null==e?void 0:e.message)?t:e))})));let[e,r]=yield Promise.all([jq.get("camera"),jq.get("microphone")]);return{camera:e,microphone:r}}()}))}static getCameraList(){return mU(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getMicrophoneList(){return pU(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getSpeakerList(){return _U(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static setCurrentSpeaker(t){return cR(this,null,(function*(){if(!hN||t!==Lj.SPEAKER&&t!==Lj.HEADSET)(yield _U()).forEach((e=>{e.deviceId===t&&(zq.forEach((i=>{i._setCurrentSpeaker(t),i.emit(mG.DEVICE_CHANGED,{type:"speaker",action:"active",device:e})})),qq=e)}));else{let i=yield e.getMicrophoneList(),r="";if(i.forEach((e=>{e.label===t&&(r=e.deviceId)})),!r)return;zq.forEach((e=>cR(this,null,(function*(){e._localAudioTrack&&(yield e.updateLocalAudio({option:{microphoneId:r}}))}))))}}))}static _addKVStat(e){let{type:t,key:i,value:r,base:o,useUV:n,version:a,max:s}=e;switch(a&&(kL.version=a),t){case"count":kL.addCount({key:i,useUV:n});break;case"enum":kL.addEnum({key:i,value:r,useUV:n});break;case"number":kL.addNumber({key:i,value:r,split:o,max:s})}}};aR(Kq,"VERSION",xG),aR(Kq,"_loggerManager",rM),aR(Kq,"EVENT",mG),aR(Kq,"ERROR_CODE",Pj),aR(Kq,"TYPE",Lj),aR(Kq,"frameWorkType",30),nR([HG({replaceArg:e=>({argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}})})],Kq.prototype,"use",1),nR([UG(tG.TRTC.enterRoom),dG("room",((e,t)=>{let[i]=e,[r]=t;return(i.roomId||i.strRoomId)===(r.roomId||r.strRoomId)&&i.userId===r.userId&&i.sdkAppId===r.sdkAppId})),MU((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),HG()],Kq.prototype,"enterRoom",1),nR([HG()],Kq.prototype,"exitRoom",1),nR([UG(tG.TRTC.switchRoom),HG(),FU()],Kq.prototype,"switchRoom",1),nR([UG(tG.TRTC.switchRole),uG("room",{merge:(e,t)=>t}),HG()],Kq.prototype,"switchRole",1),nR([HG()],Kq.prototype,"destroy",1),nR([UG(tG.TRTC.startLocalAudio),dG("audio",((e,t)=>{let[i]=e,[r]=t;var o,n;return(null==(o=null==i?void 0:i.option)?void 0:o.microphoneId)===(null==(n=null==r?void 0:r.option)?void 0:n.microphoneId)})),HG()],Kq.prototype,"startLocalAudio",1),nR([UG(tG.TRTC.updateLocalAudio),uG("audio",{debounce:{delay:200,getKey:()=>"".concat(Gq,"-localAudio"),isNeedToDebounce:e=>{var t;return!YC(null==(t=e.option)?void 0:t.captureVolume)}}}),HG()],Kq.prototype,"updateLocalAudio",1),nR([hG("audio"),HG()],Kq.prototype,"stopLocalAudio",1),nR([UG(tG.TRTC.startLocalVideo),dG("video",((e,t)=>{let[i]=e,[r]=t;var o,n;return(null==(o=null==i?void 0:i.option)?void 0:o.cameraId)===(null==(n=null==r?void 0:r.option)?void 0:n.cameraId)})),HG()],Kq.prototype,"startLocalVideo",1),nR([UG(tG.TRTC.updateLocalVideo),uG("video"),HG()],Kq.prototype,"updateLocalVideo",1),nR([hG("video"),HG()],Kq.prototype,"stopLocalVideo",1),nR([UG(tG.TRTC.startScreenShare),dG("screen",(()=>!0)),HG()],Kq.prototype,"startScreenShare",1),nR([UG(tG.TRTC.updateScreenShare),uG("screen"),HG()],Kq.prototype,"updateScreenShare",1),nR([HG()],Kq.prototype,"stopScreenShare",1),nR([UG(tG.TRTC.startRemoteVideo),dG((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),HG({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Kq.prototype,"startRemoteVideo",1),nR([UG(tG.TRTC.updateRemoteVideo),uG((e=>"v".concat(e.userId).concat(e.streamType))),HG({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Kq.prototype,"updateRemoteVideo",1),nR([UG(tG.TRTC.stopRemoteVideo),MU((e=>function(t){return cR(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),HG({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Kq.prototype,"stopRemoteVideo",1),nR([hG((e=>"v".concat(e.userId).concat(e.streamType)))],Kq.prototype,"_stopRemoteVideo",1),nR([UG(...tG.TRTC.muteRemoteAudio),HG({getRemoteId:e=>e})],Kq.prototype,"muteRemoteAudio",1),nR([VG(...tG.TRTC.setRemoteAudioVolume),PG(200,(e=>e)),HG({getRemoteId:e=>e})],Kq.prototype,"setRemoteAudioVolume",1),nR([jG("start"),OU((e=>{var t;return null==(t=e.afterStart)?void 0:t.call(e)})),dG(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),HG({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>AL[e.getName()],ignoreLog:e=>"Debug"===e.getName(),ignoreErrorLog:e=>"AudioProcessor"===e.getName()})],Kq.prototype,"startPlugin",1),nR([jG("update"),uG(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t)),{merge:(e,t)=>(_D(e[1],t[1]),e)}),HG({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>bL[e.getName()]})],Kq.prototype,"updatePlugin",1),nR([jG("stop"),hG(((e,t)=>{if(e.disableRandomCall)return null;let i=e.getGroup(t),r=e.getAlias();return"*"===i?new RegExp("".concat(r,".*")):r+i})),HG({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>SL[e.getName()]})],Kq.prototype,"stopPlugin",1),nR([VG(...tG.TRTC.enableAudioVolumeEvaluation)],Kq.prototype,"enableAudioVolumeEvaluation",1),nR([HG()],Kq.prototype,"getVideoSnapshot",1),nR([HG()],Kq.prototype,"_setCurrentSpeaker",1),nR([dG((e=>"a".concat(e.userId)),(()=>!0))],Kq.prototype,"_startRemoteAudio",1),nR([MU((e=>function(t){return cR(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(eR(Zw({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),hG((e=>"a".concat(e.userId)))],Kq.prototype,"_stopRemoteAudio",1),nR([hG("room")],Kq.prototype,"_exitRoom",1),nR([hG("screen")],Kq.prototype,"_stopScreenShare",1),nR([UG(...tG.TRTC.sendSEIMessage),Nj({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].byteLength}})],Kq.prototype,"sendSEIMessage",1),nR([UG(tG.TRTC.sendCustomMessage),Nj({timesInSecond:30,maxSizeInSecond:8e3,getSize:e=>e.data.byteLength})],Kq.prototype,"sendCustomMessage",1),nR([pG()],Kq,"create",1),nR([UG(tG.TRTC.create)],Kq,"_create",1),nR([pG()],Kq,"setLogLevel",1),nR([pG()],Kq,"isSupported",1),nR([pG()],Kq,"getPermissions",1),nR([pG()],Kq,"getCameraList",1),nR([pG()],Kq,"getMicrophoneList",1),nR([pG()],Kq,"getSpeakerList",1);var Yq=Kq,Xq=class{constructor(e,t){aR(this,"_flag"),aR(this,"terminalType"),aR(this,"userId"),aR(this,"tinyId"),aR(this,"role"),aR(this,"remoteAudioTrack"),aR(this,"remoteVideoTrack"),aR(this,"remoteAuxiliaryTrack"),this.userId=t.userId||"",this.tinyId=t.tinyId||"",this.role=t.role||"audience",this.terminalType=t.terminalType,this.remoteAudioTrack=new QB(e,this),this.remoteVideoTrack=new ZB(e,this),this.remoteAuxiliaryTrack=new eH(e,this),this.flag=t.flag||0}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return pD(this.flag,this.userId)}get flag(){return this._flag}set flag(e){if(e===this._flag)return;let t,i=this.muteState;this._flag=e;let r=this.muteState;for(t in r)i[t]!=r[t]&&console.log(this.userId,t,i[t],"->",r[t]);this.remoteAudioTrack.onFlagChanged(),this.remoteVideoTrack.onFlagChanged(),this.remoteAuxiliaryTrack.onFlagChanged()}},Jq=class{constructor(){aR(this,"_set",new Set),$O.on(eM.LEAVE_SUCCESS,this.delete,this),$O.on(eM.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess,this)}add(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,i||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(r)}delete(e){let{room:t,roomId:i}=e;if("rtc"===t.scene)return;let r=this.getKey(t.userId,t.roomId||i,t.sdkAppId,t.useStringRoomId);this._set.delete(r)}getKey(e,t,i,r){return"".concat(i,"_").concat(t,"_").concat(e,"_").concat(r)}isJoined(e){let{userId:t,roomId:i,sdkAppId:r,room:o}=e;return"rtc"!==o.scene&&this._set.has(this.getKey(t,i,r,o.useStringRoomId))}handleSwitchRoomSuccess(e){let{room:t,currentRoomId:i,targetRoomId:r}=e;"rtc"!==t.scene&&(this._set.delete(this.getKey(t.userId,i,t.sdkAppId,t.useStringRoomId)),this._set.add(this.getKey(t.userId,r,t.sdkAppId,t.useStringRoomId)))}};function Qq(){return cR(this,null,(function*(){let e,t;try{let t=yield pU();e=t&&t.length}catch(p){}try{let e=yield mU();t=e&&e.length}catch(p){}let i={microphone:e,camera:t},{isH264EncodeSupported:r,isVp8EncodeSupported:o,isH264DecodeSupported:n,isVp8DecodeSupported:a,isH265EncodeSupported:s,isH265DecodeSupported:c}=this.checkSystemResult.detail,l=aM.basis(),d={webRTC:l.isWebRTCSupported,getUserMedia:l.isGetUserMediaSupported,webSocket:l.isWebSocketsSupported,screenShare:l.isScreenShareSupported,webAudio:l.isWebAudioSupported,h264Encode:r,h264Decode:n,vp8Encode:o,vp8Decode:a,h265Encode:s,h265Decode:c},u={browser:l.browser,os:l.os,trtc:d,devices:i},h={isWebCodecSupported:l.isWebCodecSupported,isMediaSessionSupported:l.isMediaSessionSupported,isWebTransportSupported:l.isWebTransportSupported};ox.uploadEvent({log:"trtcstats-".concat(JSON.stringify(u)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(u))),ox.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(h)),userId:this.userId}),MP()}))}var $q=class{constructor(e){aR(this,"_frameWorkType"),aR(this,"_component"),aR(this,"_language"),aR(this,"connectionType"),aR(this,"_room"),aR(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,reportToken:void 0}),aR(this,"_keyPrefix"),aR(this,"_log"),aR(this,"_intervalId"),aR(this,"_firstPublishedUserList"),aR(this,"_networkQuality"),aR(this,"_basicInfo"),aR(this,"_pathJoinRoom"),aR(this,"_pathLeaveRoom"),aR(this,"_pathMainVideoMap"),aR(this,"_pathMainAudioMap"),aR(this,"_pathAuxiliaryMap"),aR(this,"_remoteStreamStatMap"),aR(this,"_localStreamStat"),aR(this,"_eventMap",new Map),aR(this,"_captureCostSum",0),aR(this,"_captureCostCount",0),aR(this,"isDestroyed",!1),this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=rM.createLogger({parent:this._room.getLogger(),id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&KC(this[e])&&(this[e]=function(e){let{fn:t,context:i}=e;return function(){try{for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];let n=t.apply(i,r);return iD(n)?n.catch((e=>rM.error("".concat(t.name,"() error observed ").concat(e)))):n}catch(Ok){rM.error("".concat(t.name,"() error observed ").concat(Ok))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents()}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:wR,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0,uint32_audio_capture_thread_health_zero_cnt:0,uint32_after3a_silence_duration:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,BO().then((()=>{this._basicInfo.string_os_version=YO(),this._basicInfo.string_device_name=WO()||this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),$O.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(eM.JOIN_START,this.handleJoinStart).addEvent(eM.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(eM.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(eM.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(eM.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(eM.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(eM.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(eM.JOIN_FAILED,this.handleJoinFailed).addEvent(eM.LEAVE_START,this.handleLeaveStart).addEvent(eM.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(eM.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(eM.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(eM.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(eM.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(eM.PUBLISH_START,this.handlePublishStart).addEvent(eM.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(eM.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(eM.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(eM.PLAY_TRACK_START,this.handlePlayStart).addEvent(eM.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(eM.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,type:r}=e;!t.isRemote||!this.hitTest(t.room)||"PLAYING"===i&&(r===ok.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(eM.SWITCH_ROOM_START,this.handleSwitchRoomStart).addEvent(eM.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess).addEvent(eM.SWITCH_ROOM_FAILED,this.handleSwitchRoomFailed).addEvent(eM.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(eM.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(eM.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(eM.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let o=i.hasAudio||i.hasVideo||i.hasSmall,n=i.hasAuxiliary,a=r.hasAudio||r.hasVideo||r.hasSmall,s=r.hasAuxiliary;!o&&a&&this.handleRemoteStreamAdded(r.userId,"main"),!n&&s&&this.handleRemoteStreamAdded(r.userId,"auxiliary")})).addEvent(eM.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:i}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=i.ice,this._pathJoinRoom.int32_dtls_cost=i.dtls,this._pathJoinRoom.int32_peer_connection_cost=i.peerConnection)}))}uninstallEvents(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach(((e,t)=>$O.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),$P.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(YC(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),YC(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),YC(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:i}=e;if(this.hitTest(t)&&i){let{totalCost:e,local:t,dns:r,tcp:o,tls:n,request:a,response:s}=i;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=r,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=n,this._pathJoinRoom.int32_schedule_request=a,this._pathJoinRoom.int32_schedule_response=s}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:i}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),i&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=i instanceof vR?Number(i.getExtraCode()||i.getCode()):_R.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:i}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=i.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){var t;if(this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time){if(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time){this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time;let e=null==(t=this._room.audioManager.localAudioTrack)?void 0:t.after3aSilenceStartTime;e&&(this._localStreamStat.statsToReport.uint32_after3a_silence_duration=cD()-e)}else this._log.warn("pathJoinRoom endTime is 0");this.report()}}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleSwitchRoomStart(e){if(this.hitTest(e.room)){let e=Date.now();this.report().then((()=>{this._pathJoinRoom.uint64_start_time=e,this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=e}))}}handleSwitchRoomSuccess(e){let{room:t}=e;if(this.hitTest(t)&&0===this._pathJoinRoom.uint64_end_time){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,this._pathJoinRoom.int32_end_ret}}handleSwitchRoomFailed(e){let{room:t,error:i}=e;if(this.hitTest(t)){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,i&&(this._pathJoinRoom.int32_end_ret=i instanceof vR?Number(i.getExtraCode()||i.getCode()):_R.UNKNOWN)}}handleRemoteStreamAdded(e,t){var i;let r="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(r)){let o={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:eR(Zw({},eK),{msg_user_info:new tK({userId:e,tinyId:null==(i=this._room.remotePublishedUserMap.get(e))?void 0:i.tinyId,role:20})})};o.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(r,o)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:i,streamType:r,subscribeState:o}=e;if(!this.hitTest(t))return;let{userId:n,tinyId:a,role:s}=i,c=new tK({userId:n,tinyId:a,role:"anchor"===s?20:21}),l=Date.now(),d="".concat(n,"_").concat(r),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=l),"main"===r?(i.muteState.hasVideo&&(o.video||o.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:n,sendSubscribeCMDTime:l}),i.muteState.hasAudio&&o.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:n,sendSubscribeCMDTime:l})):i.muteState.hasAuxiliary&&o.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:i,streamType:r}=e;if(this.hitTest(t)){let e="".concat(i.userId,"_").concat(r),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._remoteStreamStatMap.get(i);0===(null==r?void 0:r.playStreamTime)&&(r.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let i="".concat(t.userId,"_").concat(t.streamType),r=this._pathMainVideoMap.get(i);r&&0===r.statsToReport.uint64_combine_first_frame_time&&(r.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=Date.now(),r=this._pathMainVideoMap.get(t),o=this._remoteStreamStatMap.get(t);if(o){let{statsToReport:t}=o;if(t.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){let e=i-this._pathJoinRoom.uint64_start_time;t.uint32_video_render_first=e,CL.addNumber({key:516820,value:e})}}0===(null==r?void 0:r.statsToReport.uint64_render_first_frame_time)&&(r.statsToReport.uint64_render_first_frame_time=i)}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),i=this._pathMainAudioMap.get(t);i&&0===i.statsToReport.uint64_play_first_frame_time&&(i.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:i,userId:r,videoDelay:o,audioDelay:n}=e,a=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(a)a.totalRTT+=t,a.totalLoss+=i,o&&(a.totalVideoDelay=(a.totalVideoDelay||0)+o,a.videoDelayCount=(a.videoDelayCount||0)+1),n&&(a.totalAudioDelay=(a.totalAudioDelay||0)+n,a.audioDelayCount=(a.audioDelayCount||0)+1),a.count++;else{let e,a,s,c;o&&(a=o,s=1),n&&(e=n,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(r,{totalRTT:t,totalLoss:i,count:1,totalAudioDelay:e,totalVideoDelay:a,audioDelayCount:c,videoDelayCount:s})}})))}handleHeartbeatStats(e){var t;if(this.hitTest(e.room)){let{msg_device_info:i,msg_up_stream_info:r,msg_down_stream_info:o}=e.report;if(r.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:t,uint32_video_width:i,uint32_video_height:o}=r.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=t,this._localStreamStat.totalVideoWidth+=i,this._localStreamStat.totalVideoHeight+=o,this._localStreamStat.videoCount++}if(r.msg_audio_status){let{uint32_audio_level:e}=r.msg_audio_status;Math.floor(e/ZM*100)>0&&(this._localStreamStat.totalAudioLevel+=e/ZM,this._localStreamStat.audioLevelCount++)}o.forEach((e=>{let{msg_user_info:t,msg_audio_status:i,msg_video_status:r}=e,o=t.str_identifier,n=this._room.remotePublishedUserMap.get(o);if(r.forEach((e=>{let t=2===e.uint32_video_stream_type,i=7===e.uint32_video_stream_type,r="".concat(o,"_").concat(t?"main":"auxiliary"),a=this._remoteStreamStatMap.get(r);if(a&&(t&&null!=n&&n.remoteVideoTrack.isSubscribed||i&&null!=n&&n.remoteAuxiliaryTrack)){a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height);let i=t?n.remoteVideoTrack:n.remoteAuxiliaryTrack;i.stat.jitterBufferDelay&&(a.videoJitterBufferDelay=i.stat.jitterBufferDelay),i.stat.framesReceived&&(a.statsToReport.uint32_video_consume_render_rate=Math.floor(i.stat.framesDecoded/i.stat.framesReceived*Qw(10,6)))}})),!hD(i)){let e="".concat(o,"_main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&null!=n&&n.remoteAudioTrack.isSubscribed&&(t.totalAudioBitrate+=i.uint32_audio_codec_bitrate,t.audioCount++,n.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=n.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(i.uint32_audio_level/ZM*100)>0&&(t.totalAudioLevel+=i.uint32_audio_level/ZM,t.audioLevelCount++),i.uint32_audio_block_time&&(t.statsToReport.uint32_audio_block_time+=i.uint32_audio_block_time))}})),i.uint32_audio_capture_cost&&(this._captureCostSum+=i.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0)),0===i.uint32_audio_capture_cost&&!1===(null==(t=this._room.audioManager.localAudioTrack)?void 0:t.muted)&&(this._localStreamStat.statsToReport.uint32_audio_capture_thread_health_zero_cnt+=1)}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:i}=e,r={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[i.name]||(i instanceof vR?i.getExtraCode()||i.getCode():_R.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=r,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=r,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&ck))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&uk))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&dk))>=0}hitTest(e){return e===this._room}prepareReport(){if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:i}=e,r=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(r){let{totalLoss:t,count:i,audioDelayCount:o,videoDelayCount:n,totalAudioDelay:a,totalVideoDelay:s}=r;e.statsToReport.uint32_avg_down_loss=Math.floor(t/i),o&&a&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(a/o),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),n&&s&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/n))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:o}=this._room;o&&(e.statsToReport.uint32_audio_play_time=o.getDuration(t,ok.AUDIO),e.statsToReport.uint32_video_play_time=o.getDuration(t,ok.VIDEO)),e.statsToReport.uint32_video_render_first&&(e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,Zq));let{badCaseDetector:n}=this._room,{dataFreeze:a,count:s}=n.getDataFreezeDuration(t),{renderFreeze:c}=n.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=s,e.statsToReport.uint32_video_block_time=Math.min(a,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_audio_block_time=Math.min(e.statsToReport.uint32_audio_block_time,e.statsToReport.uint32_audio_play_time),n.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>Zq&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+Zq):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>Zq&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+Zq):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>Zq&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+Zq)}getReportData(){this._basicInfo.uint32_networkType=PC();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new tK({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:fD(this._signalInfo.relayIp),uint32_client_ip:fD(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Qw(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:fD(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend,str_user_sig:this._room.userSig,bytes_report_token:this._signalInfo.reportToken};return RD(e),e}report(){return cR(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),this.initData()}catch(uM){this._log.warn(uM)}finally{this.isDestroyed&&(this._room=null)}}))}upload(e){return cR(this,null,(function*(){if(0===e.msg_path_enter_room.uint64_start_time)return;let t=Number(this._room.sdkAppId),i=tM.enable?UD(e,2001,t):yield qD(e),r=i instanceof ArrayBuffer,o="".concat(kC(t,qR.KEY_POINT),"&gzip=").concat(+r),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,i));let a=[this.uploadKVStat(CL),this.uploadKVStat(kL)];n||a.push(zD({url:o,body:i,priority:"low"})),yield Promise.all(a)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return cR(this,null,(function*(){let t=e.getReportData(this._room.userSig,this._signalInfo.reportToken);if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=eR(Zw({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let i=tM.enable?UD(t,2003,this._room.sdkAppId):yield qD(t),r=i instanceof ArrayBuffer,o="".concat(kC(+this._room.sdkAppId,qR.KV_STAT),"&gzip=").concat(+r),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,i)),n||zD({url:o,body:i})}))}};nR([ax({settings:{timeout:500,retries:3}})],$q.prototype,"upload",1);var Zq=5e3,eK={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},tK=class{constructor(e){aR(this,"str_identifier"),aR(this,"str_tinyid"),aR(this,"uint32_role"),this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},iK=$q,rK=class{constructor(){aR(this,"_startTime"),aR(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=cD())}stop(){0===this._endTime&&(this._endTime=cD())}getDuration(){return 0===this._endTime?cD()-this._startTime:this._endTime-this._startTime}get startTime(){return this._startTime}get endTime(){return this._endTime}},oK=class{constructor(e){aR(this,"_room",null),aR(this,"_durationMap"),aR(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(eM.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(eM.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(eM.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;var o;let{userId:n}=r;if(!this.hitTest(t))return;i.hasAudio&&!r.hasAudio&&this.stopDurationItem("".concat(n,"_main"),ok.AUDIO),i.hasVideo&&!r.hasVideo&&this.stopDurationItem("".concat(n,"_main"),ok.VIDEO),i.hasAuxiliary&&!r.hasAuxiliary&&this.stopDurationItem("".concat(n,"_auxiliary"),ok.VIDEO);let a=null==(o=this._room)?void 0:o.remotePublishedUserMap.get(n);a&&(!i.hasAudio&&r.hasAudio&&a.remoteAudioTrack.isSubscribed&&this.addDuractionItem(n,ok.AUDIO,"main"),!i.hasVideo&&r.hasVideo&&a.remoteVideoTrack.isSubscribed&&this.addDuractionItem(n,ok.VIDEO,"main"),!i.hasAuxiliary&&r.hasAuxiliary&&a.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(n,ok.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>$O.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>$O.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{track:t}=e;if(!this.hitTest(t.room))return;let{userId:i,streamType:r,kind:o}=t;t.isSubscribed?this.addDuractionItem(i,o,r):this.stopDurationItem("".concat(i,"_").concat(r),o)}handleUnsubscribed(e){let{track:t}=e;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,i){let r="".concat(e,"_").concat(i),o=new rK,n=this._durationMap.get(r);n?this.isRecording(n[t])||n[t].push(o):this._durationMap.set(r,{userId:e,type:i,audio:t===ok.AUDIO?[o]:[],video:t===ok.AUDIO?[]:[o]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let i=this._durationMap.get(e)[t].find((e=>0===e.endTime));i&&i.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},nK=class{constructor(){aR(this,"renderFreezeMap",new Map),aR(this,"dataFreezeMap",new Map)}get(e,t){let i=this.renderFreezeMap.get(e),r=this.dataFreezeMap.get(e);return t?"data"===t?r:i:(TO||_N)&&i&&r&&i.duration>r.duration?i:r}set(e,t,i){"data"===i?this.dataFreezeMap.set(e,t):this.renderFreezeMap.set(e,t)}clear(){this.renderFreezeMap.clear(),this.dataFreezeMap.clear()}},aK=class{constructor(e){aR(this,"_room"),aR(this,"_renderFreezeMap",new Map),aR(this,"_isVideoPlayingEventFiredMap",new Map),aR(this,"_dataFreezeMap",new Map),aR(this,"_monitorFreezeData",new nK),aR(this,"_eventMap",new Map),aR(this,"_videoEncodeFailedCount",0),aR(this,"_audioEncodeFailedCount",0),aR(this,"_encodeFailedThreshold",3),aR(this,"eventListenerMap",new Map),this._room=e.room,this.installEvents()}getRenderFreezeMap(){return this._renderFreezeMap}getDataFreezeMap(){return this._dataFreezeMap}installEvents(){this._eventMap.set(eM.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(eM.PLAY_TRACK_START,this.onPlayTrackStart).set(eM.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:i,remotePublishedUser:r}=e;if(!this.hitTest(t))return;let{userId:o}=r,n="".concat(o,"_").concat(i);this.stopDataFreeze({key:n,userId:o,type:i})})).set(eM.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:i,muteState:r}=e;if(!this.hitTest(t))return;let{userId:o}=r;if(i.hasVideo&&!r.hasVideo){let e="main",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}if(i.hasAuxiliary&&!r.hasAuxiliary){let e="auxiliary",t="".concat(r.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}})).set(eM.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:i,reason:r,type:o}=e;if(t.isRemote&&t.room&&this.hitTest(t.room)&&o===ok.VIDEO){if("PLAYING"===i){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}r===ok.MUTE?this.onVideoTrackMuted(t):r===ok.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(eM.HEARTBEAT_REPORT,this.onHearBeatReport).set(eM.REMOTE_VIDEO_PLAY_START,this.onRemoteVideoPlayStart).set(eM.REMOTE_VIDEO_PLAY_FINISH,this.onRemoteVideoPlayEnd),this._eventMap.forEach(((e,t)=>$O.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>$O.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i),o=this._dataFreezeMap.get(r),n=new rK;o?o.durationItemList.push(n):this._dataFreezeMap.set(r,{userId:t,type:i,durationItemList:[n],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:i}=e,r="".concat(t,"_").concat(i);this.stopDataFreeze({key:r,userId:t,type:i})}onHearBeatReport(e){let{room:t,report:i}=e;if(this.hitTest(t)){if(i.msg_up_stream_info.msg_video_status){let e=i.msg_up_stream_info.msg_video_status,t=Array.from(this._room.localTracks).find((e=>"video"===e.kind&&!e.isScreen)),r=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||r<=0||null!=t&&t.isUseCustomSource)return;e.forEach((e=>{2===e.uint32_video_stream_type&&(0!==e.uint32_video_capture_fps&&0===e.uint32_video_codec_bitrate&&0===e.uint32_video_enc_fps&&null!=t&&t.isPublished?(this._videoEncodeFailedCount+=1,this._videoEncodeFailedCount===this._encodeFailedThreshold&&ox.uploadEvent({userId:this._room.userId,log:"stat-".concat(Lk.VIDEO_ENCODE_FAILED_DURING_CALL)})):this._videoEncodeFailedCount=0)}))}if(i.msg_up_stream_info.msg_audio_status){let e=i.msg_up_stream_info.msg_audio_status,t=Array.from(this._room.localTracks).find((e=>"audio"===e.kind)),r=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||r<=0)return;0===e.uint32_audio_codec_bitrate&&null!=t&&t.isPublished?(this._audioEncodeFailedCount+=1,this._audioEncodeFailedCount===this._encodeFailedThreshold&&ox.uploadEvent({userId:this._room.userId,log:"stat-".concat(Lk.AUDIO_ENCODE_FAILED_DURING_CALL)})):this._audioEncodeFailedCount=0}}}stopDataFreeze(e){let{key:t,userId:i,type:r}=e,o=this._dataFreezeMap.get(t);if(!o||!o.isFreezing())return;let n=o.durationItemList[o.durationItemList.length-1];n.stop();let a=n.getDuration();if(a>Wk){let e=this._monitorFreezeData.get(t,"data");this._monitorFreezeData.set(t,{userId:i,type:r,duration:e?e.duration+a:a},"data")}else o.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let i=t.getDuration();return e+Math.min(i,5e3)}),0)}onPlayTrackStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room)||t.kind!==ok.VIDEO||!t.isRemotePublished)return;let i="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(i)||this._isVideoPlayingEventFiredMap.set(i,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},i=this._dataFreezeMap.get(e);if(i){if(i.isFreezing()){let e=i.durationItemList[i.durationItemList.length-1];e.stop(),e.getDuration()<Wk&&i.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(i.durationItemList),t.count=i.durationItemList.length}return t}getRenderFreezeDuration(e){let t={renderFreeze:0,count:0},i=this._renderFreezeMap.get(e);return i&&(t.renderFreeze=i.totalDuration,t.count=i.count),t}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}onRemoteVideoPlayStart(e){let{track:t,player:i}=e;var r;if(!CP())return;let o=0,n=()=>{document.hidden||(o=0)};document.addEventListener("visibilitychange",n);let a=(e,r)=>{var n;if(o){let e=t.decodeFPS,i=e>0&&e<=5?600+1e3/e:600,n=r.presentationTime-o;if(n>i){n=Math.min(n,5e3);let e="".concat(t.userId,"_").concat(t.streamType),i=this._monitorFreezeData.get(e,"render");i?i.duration+=n:this._monitorFreezeData.set(e,{userId:t.userId,type:t.streamType,duration:n},"render");let r=this._renderFreezeMap.get(e);r?(r.totalDuration+=n,r.count+=1):this._renderFreezeMap.set(e,{userId:t.userId,type:t.streamType,totalDuration:n,count:1})}}o=r.presentationTime,null==(n=i.element)||n.requestVideoFrameCallback(a)};null==(r=i.element)||r.requestVideoFrameCallback(a),this.eventListenerMap.set("".concat(t.userId,"_").concat(t.streamType),{onVisibilityChange:n})}onRemoteVideoPlayEnd(e){let{track:t,player:i}=e,r="".concat(t.userId,"_").concat(t.streamType),o=this.eventListenerMap.get(r);o&&document.removeEventListener("visibilitychange",o.onVisibilityChange)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},sK=oR(lR(),1),cK=class{constructor(e,t,i,r,o){let n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:4/3;this.vbMode=e,this.faceDetectorHash=i,this.visionTaskRegistry=r,this.logger=o,aR(this,"animationState"),aR(this,"originalAspect"),aR(this,"totalOffsetX",0),aR(this,"totalOffsetY",0),aR(this,"defaultScaleRatio",.1),aR(this,"isRecovering",!1),aR(this,"boundaryY",280),aR(this,"lastActionTime",0),aR(this,"restTime",400),this.animationState={current:null,target:null,animating:!1,debounceTimer:null,startTime:0,duration:3e3,debounceTime:150,movementThreshold:30,debounceThreshold:15},this.addEvent(this.vbMode,!!this.faceDetectorHash),this.originalAspect=n||4/3,this.visionTaskRegistry.setVideo(this.faceDetectorHash,t)}addEvent(e,t,i){let r=[{key:570704,error:null!=i?i:t?void 0:11},{key:570705,error:null!=i?i:t?void 0:22}][e-1];r&&(t?CL.addSuccessEvent({key:r.key}):CL.addFailedEvent({key:r.key,error:r.error}))}actionCentering(e){let t=Date.now();if(this.animation(),!this.faceDetectorHash||t-this.lastActionTime<this.restTime||this.animationState.animating)return;let{videoWidth:i,videoHeight:r}=e;this.animationState.debounceThreshold=i/30,this.animationState.movementThreshold=i/20,this.boundaryY=.6*r;try{let e=this.visionTaskRegistry.getResult(this.faceDetectorHash);if(e.detections.length<=0)return void(1===this.vbMode&&this.recoverOriginal(i,r));let t=e.detections[0].boundingBox,o=t.originX,n=t.originY,a=t.width,s=t.height;1===this.vbMode?this.dualStageCropping(i,r,o,n,a,s):2===this.vbMode&&this.movingPortrait(i,r,o,n,a,s)}catch(_M){this.logger.error(_M)}this.lastActionTime=t}calculateBoundary(e,t,i,r){let o,n;return e>t/2?(o=t-i-r,n=i-o):(o=i,n=0),{min:o,offset:n}}calculateTargetPosition(e,t,i,r,o,n){let a,s,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.4,l=e+i/2,d=t+r/2,{min:u,offset:h}=this.calculateBoundary(l,o,e,i),{min:p,offset:m}=this.calculateBoundary(d,n,t,r);return a=2*u+i,s=2*p+r,a/s>this.originalAspect?(a=s*this.originalAspect,h=l-a/2):(s=a/this.originalAspect,m=d-s/2),i/o>c&&(h=0,m=0,a=o,s=n),h=Math.max(0,Math.min(h,o-a)),m=Math.max(0,Math.min(m,n-s)),{sx:h,sy:m,cropWidth:a,cropHeight:s,timestamp:Date.now()}}processFacePositionCrop(e,t,i){if(!this.animationState.current||!this.animationState.target){let e={sx:0,sy:0,cropWidth:t,cropHeight:i,timestamp:Date.now()};return this.animationState.current=e,void(this.animationState.target=e)}let r=this.positionDistance(this.animationState.target,e),o=this.positionDistance(this.animationState.current,e),n=this.animationState.current.cropWidth/t;r>this.animationState.debounceThreshold*n&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&o>this.animationState.movementThreshold*n&&(this.animationState.target=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}processFacePositionPortrait(e){if(!this.animationState.current||!this.animationState.target)return this.animationState.current=Zw({},e),void(this.animationState.target=Zw({},e));let t=this.positionDistance(this.animationState.current,e),i=this.positionDistance(this.animationState.target,e);t>this.animationState.debounceThreshold&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&i>this.animationState.movementThreshold&&(this.animationState.current=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}animation(){if(!this.animationState.animating)return;let e=Date.now()-this.animationState.startTime,t=Math.min(e/this.animationState.duration,1),i=e=>e<.5?2*e*e:(4-2*e)*e-1;if(this.animationState.current&&this.animationState.target){let e=(this.animationState.target.sx-this.animationState.current.sx)*i(t);this.animationState.current.sx+=e,this.totalOffsetX+=e;let r=(this.animationState.target.sy-this.animationState.current.sy)*i(t);if(this.animationState.current.sy+=r,this.totalOffsetY+=r,this.animationState.current.cropWidth+=(this.animationState.target.cropWidth-this.animationState.current.cropWidth)*i(t),this.animationState.current.cropHeight+=(this.animationState.target.cropHeight-this.animationState.current.cropHeight)*i(t),this.animationState.current.scaleRatio&&this.animationState.target.scaleRatio&&(this.animationState.current.scaleRatio+=(this.animationState.target.scaleRatio-this.animationState.current.scaleRatio)*i(t)),JC(this.animationState.current.scaleOffsetX)&&JC(this.animationState.target.scaleOffsetX)&&JC(this.animationState.current.scaleOffsetY)&&JC(this.animationState.target.scaleOffsetY)){let e=(this.animationState.target.scaleOffsetX-this.animationState.current.scaleOffsetX)*i(t);this.animationState.current.scaleOffsetX+=e;let r=(this.animationState.target.scaleOffsetY-this.animationState.current.scaleOffsetY)*i(t);this.animationState.current.scaleOffsetY+=r}}t>=1&&(this.animationState.animating=!1,this.animationState.current=this.animationState.target,this.isRecovering=!1)}positionDistance(e,t){return Math.sqrt(Qw(e.sx-t.sx,2)+Qw(e.sy-t.sy,2))}recoverOriginal(e,t){this.animationState.target={sx:0,sy:0,cropWidth:e,cropHeight:t,timestamp:Date.now()},this.animationState.animating=!0,this.animationState.startTime=Date.now(),this.isRecovering=!0}dualStageCropping(e,t,i,r,o,n){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.3;if(this.isRecovering)return;let s=this.calculateTargetPosition(i,r,o,n,e,t);this.processFacePositionCrop(s,e,t),o*n/s.cropWidth/s.cropHeight>a&&this.recoverOriginal(e,t)}movingPortrait(e,t,i,r,o,n){var a,s,c,l,d,u,h,p,m,f,_,g;let v={sx:i+o/2+this.totalOffsetX,sy:r+n/2+this.totalOffsetY,cropWidth:e,cropHeight:t,scaleRatio:null!=(s=null==(a=this.animationState.current)?void 0:a.scaleRatio)?s:1,scaleOffsetX:null!=(l=null==(c=this.animationState.current)?void 0:c.scaleOffsetX)?l:0,scaleOffsetY:null!=(u=null==(d=this.animationState.current)?void 0:d.scaleOffsetY)?u:0,timestamp:Date.now()};this.animationState.target={sx:e/2,sy:r+n/2,cropWidth:e,cropHeight:t,scaleRatio:null!=(p=null==(h=this.animationState.target)?void 0:h.scaleRatio)?p:1,scaleOffsetX:null!=(f=null==(m=this.animationState.target)?void 0:m.scaleOffsetX)?f:0,scaleOffsetY:null!=(g=null==(_=this.animationState.target)?void 0:_.scaleOffsetY)?g:0,timestamp:Date.now()},this.animationState.animating||(this.animationState.target.scaleRatio=Math.sqrt(o*n/e/t/this.defaultScaleRatio),this.animationState.target.scaleOffsetX=-this.animationState.target.scaleRatio/2+.5,this.animationState.target.scaleOffsetY=1-this.animationState.target.scaleRatio,(this.animationState.target.sy-this.animationState.target.scaleOffsetY*this.animationState.target.cropHeight)/this.animationState.target.scaleRatio<this.boundaryY&&(this.animationState.target.scaleOffsetY=(this.animationState.target.sy-this.boundaryY*this.animationState.target.scaleRatio)/this.animationState.target.cropHeight)),this.processFacePositionPortrait(v)}set aspectRatio(e){this.originalAspect=e}get current(){return this.animationState.current}get offset(){return{offsetX:this.totalOffsetX,offsetY:this.totalOffsetY}}get targetCrop(){return this.animationState.target}},lK=class extends CB{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,width:t.width,height:t.height,logger:e.log}),aR(this,"_bgTexture"),aR(this,"_waterMarkTexture"),aR(this,"_lastMaskTexture"),aR(this,"_lastMaskFbo"),aR(this,"_textureValid",!1),aR(this,"_selfieTextureValid",!1),aR(this,"_selfieSegmentationHash"),aR(this,"wasm"),aR(this,"predictReady"),aR(this,"_color"),aR(this,"_prePrograme"),aR(this,"_segmentationMask"),aR(this,"_weixin",!1),aR(this,"_centerFace"),aR(this,"_textureMatrixLocation"),aR(this,"_offsetMatrixLocation"),aR(this,"_colorLocation"),aR(this,"_enableFaceCentering",!1),aR(this,"_enableEffectOptimization",!1),aR(this,"_mat4"),aR(this,"_postProcessing"),aR(this,"_onAbort"),aR(this,"_visionTaskRegistry"),aR(this,"resolvePreditReady"),this.init(t).catch((t=>{e.log.error(t),e.destroy(new vR({code:_R.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(t.message||t)})),this.resolvePreditReady()}))}init(e){return cR(this,null,(function*(){var t,i,r;this.predictReady=new Promise((e=>{this.resolvePreditReady=e}));let o=e.Wasm,n=this.context.ctx;if(e.color&&(this._color=e.color),e.mat4&&(this._mat4=e.mat4),e.postProcessing&&(this._postProcessing=e.postProcessing),this._enableFaceCentering=null!=(t=e.enableFaceCentering)&&t,this._enableEffectOptimization=null!=(i=e.enableEffectOptimization)&&i,this.wasm=new o.AllIn1(n),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.rotation=e.rotation||0,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"color"===e.bg?3:0,this._onAbort=e.onAbort,e.bg||this.resolvePreditReady(),e.waterMark){let{x:t,y:i,width:r,height:o}=e.waterMark;this.wasm.setWaterMark(t,i,r,o)}if(e.beautyParams){let{beauty:t,brightness:i,ruddy:r}=e.beautyParams;this.wasm.setBeauty(t,i,r,null==e?void 0:e.width,null==e?void 0:e.height)}this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image));let a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);if(this._textureMatrixLocation=n.getUniformLocation(this.program,"u_textureMatrix"),n.uniformMatrix4fv(this._textureMatrixLocation,!1,a),this._offsetMatrixLocation=n.getUniformLocation(this.program,"u_offsetMatrix"),n.uniformMatrix4fv(this._offsetMatrixLocation,!1,a),this._colorLocation=n.getUniformLocation(this.program,"u_color"),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){let e=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),t=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(t,e),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}!this._enableEffectOptimization||2!==this.wasm.vbMode&&3!==this.wasm.vbMode?this._postProcessing=void 0:VO()?(this._postProcessing=void 0,this.log.warn("Virtual background post-processing isn't allowed on mobile.")):null==(r=this._postProcessing)||r.init(n,this.positionBuffer,this.texCoordBuffer,4/3),yield this.initVisionTasks(e)}))}initVisionTasks(e){return cR(this,null,(function*(){if(e.bg){if(this._visionTaskRegistry=yield window.VisionTaskRegistry.getInstance(),!window.VisionTaskRegistry||!this._visionTaskRegistry||!this._visionTaskRegistry.visionWasm)throw new Error("Virtual background assets not found. Please redeploy the assets of the npm package.");if(this._selfieSegmentationHash=yield this._visionTaskRegistry.register(window.VisionTaskType.ImageSegmenter,{canvas:this.context._canvas}),this._visionTaskRegistry.setVideo(this._selfieSegmentationHash,this.image),this._enableFaceCentering)try{this._visionTaskRegistry.models.has(window.VisionTaskType.FaceDetector)||(yield this._visionTaskRegistry.preloadModels([window.VisionTaskType.FaceDetector]));let e=yield this._visionTaskRegistry.register(window.VisionTaskType.FaceDetector);if(!e)return;this._centerFace=new cK(this.wasm.vbMode,this.image,e,this._visionTaskRegistry,this.context.log)}catch(Ok){this.log.error("Face detector model not found. Please redeploy the assets of the npm package.")}}}))}onPredict(e){let t=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture)));let i=this.getMaskTexture(e);if(!i)return;let r=i;this._postProcessing&&(this._postProcessing.ratio=this.image.videoWidth/this.image.videoHeight,r=this._postProcessing.postProcessing(i)),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),this.useTexture(),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,r||null),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),3===this.wasm.vbMode&&t.uniform3fv(this._colorLocation,this._color),this.useBufferFrame(),this._segmentationMask=e,this.totalFrames++,this.centerFace(),MD(this.wasm.rotation)&&this.resize(this.image.height,this.image.width),t.viewport(0,0,t.canvas.width,t.canvas.height),t.drawArrays(t.TRIANGLE_STRIP,0,4),e.close()}getMaskTexture(e){return e.confidenceMasks?e.confidenceMasks[0].getAsWebGLTexture():void 0}onFirstFrame(){this.waitingFirstFrame=!1;let e=this.context.ctx;this.useTexture(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}render(e){let t=this.context.ctx,{image:i}=this;this.tryVideoFrameCallback();let{videoWidth:r,videoHeight:o}=i;if(MD(this.wasm.rotation)&&!this._visionTaskRegistry&&([r,o]=[o,r]),0===r||0===o||!this.available)return!1;i.width=r,i.height=o;let n=!1;if(this.totalFrames)this.useTexture(),n=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),n=this._textureValid,this._textureValid=!0}if(this.width===r&&this.height===o&&n?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,i):(this.resize(r,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,i)),this._weixin){if(t.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask){let e=this.getMaskTexture(this._segmentationMask);t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,e||null),t.bindFramebuffer(t.FRAMEBUFFER,this._lastMaskFbo||null)}t.drawArrays(t.TRIANGLE_STRIP,0,4),this.useTexture(),this._segmentationMask?t.copyTexSubImage2D(t.TEXTURE_2D,0,0,0,0,0,r,o):t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,r,o,0)}try{if(this._selfieSegmentationHash&&this._visionTaskRegistry){let e=this._visionTaskRegistry.getResult(this._selfieSegmentationHash);1===this.totalFrames&&this.context._canvas&&this.resolvePreditReady(),this.onPredict(e)}}catch(fM){this._onAbort&&this._onAbort(fM)}return this.totalFrames||(t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.drawArrays(t.TRIANGLE_STRIP,0,4)),this._visionTaskRegistry&&this._visionTaskRegistry.resetHashResults(),!1}centerFace(){if(!this._centerFace||!this._enableFaceCentering)return;let e=this.context.ctx;this._centerFace.aspectRatio=e.canvas.width/e.canvas.height,this._centerFace.actionCentering(this.image);let{current:t,offset:i}=this._centerFace;if(t&&(1===this.wasm.vbMode&&this.drawImage(t.sx,t.sy,t.cropWidth,t.cropHeight),i&&2===this.wasm.vbMode)){if(!this._mat4)return;let r=this._mat4.create(),{scaleRatio:o=1,scaleOffsetX:n=0,scaleOffsetY:a=0}=t;this._mat4.fromTranslation(r,[-i.offsetX/e.canvas.width+n,a,0]),this._mat4.scale(r,r,[o,o,1]),e.uniformMatrix4fv(this._offsetMatrixLocation,!1,r)}}drawImage(e,t,i,r){let o=this.context.ctx;if(!this._mat4)return;let{width:n,height:a}=o.canvas,s=this._mat4.create();this._mat4.fromTranslation(s,[e/n,1-(t+r)/a,0]),this._mat4.scale(s,s,[i/n,r/a,1]),o.uniformMatrix4fv(this._textureMatrixLocation,!1,s)}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),this._postProcessing&&this._postProcessing.close(),null==(e=this.wasm)||e.close()}},dK=class extends EB{constructor(e){super(e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}),aR(this,"yTextureRef"),aR(this,"uTextureRef"),aR(this,"vTextureRef"),aR(this,"Y"),aR(this,"U"),aR(this,"V"),this.useProgram();let t=this.context.ctx;t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),this.setTexBuffer([0,1,1,1,0,0,1,0]),this.yTextureRef=this._initTexture("ySampler",0),this.uTextureRef=this._initTexture("uSampler",1),this.vTextureRef=this._initTexture("vSampler",2),this._canvas=e._canvas}_initTexture(e,t){let i=this.context.ctx,r=i.createTexture();return i.bindTexture(i.TEXTURE_2D,r),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),i.uniform1i(i.getUniformLocation(this.program,e),t),r}render(e){let t=this.context.ctx,i=this.width,r=this.height;return this.useProgram(),t.viewport(0,0,i,r),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,i,r,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,i/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,i/2,r/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}resize(e,t){super.resize(e,t);let i=this.context.ctx;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,this.yTextureRef),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e,t,0,i.LUMINANCE,i.UNSIGNED_BYTE,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,this.uTextureRef),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,null),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,this.vTextureRef),i.texImage2D(i.TEXTURE_2D,0,i.LUMINANCE,e/2,t/2,0,i.LUMINANCE,i.UNSIGNED_BYTE,null)}},uK=(e,t)=>{switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")};var hK=0,pK=class{constructor(e){aR(this,"id",hK++),aR(this,"trackDoneOB"),aR(this,"startOB"),aR(this,"stopOB"),aR(this,"decoder"),aR(this,"videoContext"),aR(this,"gop",0),aR(this,"gop_helper",0),aR(this,"waitFirstKeyFrame",!0),aR(this,"startTimestamp",0),aR(this,"startTime",0),aR(this,"startPerformanceTime",0),aR(this,"inputFrameCount",0),aR(this,"decodedFrameCount",0),aR(this,"decodeFrameCount",0),aR(this,"downgradeLevel",0),aR(this,"lastDowngradeTime",0),aR(this,"lastFrameDiff",0),aR(this,"lastDecodeFrameTimestamp",0),aR(this,"config"),aR(this,"gop_before_configure",[]),aR(this,"videoElement"),aR(this,"type","wasm"),aR(this,"goodType"),aR(this,"renderer","2d"),aR(this,"wasmOption"),aR(this,"createDecoder"),aR(this,"_decodeSink"),aR(this,"isReported",!1),aR(this,"track"),aR(this,"stateChangeOB"),aR(this,"failedReason");let{track:t,createDecoder:i}=e;if(this.stateChangeOB=yV(),this.track=t,this.createDecoder=i,this.wasmOption={yuvMode:"webgl"===e.renderer,wasmPath:e.wasmPath,workerMode:e.workerMode,canvas:e.canvas},this.config=e.config,this.videoElement=e.videoElement,this.renderer=e.renderer,this.trackDoneOB=MV(t.availableState,qP.OFF),this.stopOB=yV(),"auto"===e.type){switch(e.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=e.type;this.changeRenderer(this.renderer),ZU(this.stateChangeOB,AF(((e,i)=>(e!==i&&t.onDecodeDowngradeStateChanged({type:this.type,renderer:this.renderer,reason:this.failedReason,prevState:e,state:i}),i)),"INITIALIZED"),tF(this.stopOB),iB()),this.start()}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");let t=ZU(this.pipe(this.track),tF(this.stopOB),sV());ZU(t,iB((()=>{this.track.stat.framesDecoded++}),(t=>{if(this.track.log.error("".concat(this.id," play failed: ").concat(t," retryCount: ").concat(e)),CL.addFailedEvent({key:uK(this.type,this.renderer),error:t}),e>4)this.failedReason=t,this.stateChangeOB.next("FAILED"),CL.addFailedEvent({key:514704});else{if(this.goodType)return void this.start(e);switch(this.type){case"webCodecs":this.type="wasm",this.changeRenderer("webgl");break;case"wasm":if("webgl"===this.renderer)this.changeRenderer("videoFrame")}this.start(e+1)}}),(()=>{this.track.log.warn("".concat(this.id," decoderOB completed")),CL.addSuccessEvent({key:uK(this.type,this.renderer)}),CL.addSuccessEvent({key:514704})}))),ZU(t,eF(1),iB((()=>{this.track.player.handlePlaying("canvas"),this.goodType=this.type,this.stateChangeOB.next("STARTED")})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.start()}close(e){this.stopOB.next(e)}changeRenderer(e){this.renderer=e,"videoFrame"===this.renderer&&!VL()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}decode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var i,r;if(this.failedReason)return;this.inputFrameCount++;let o=new Uint8Array(e.data);if(!function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]}(o)||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;let n=!1;switch(31&o[4]){case 5:case 7:n=!0}if("configured"!==(null==(i=this.decoder)?void 0:i.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),n&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!t&&(this.gop_before_configure.forEach((e=>this.decode(e,!0))),this.gop_before_configure=[]);let{timestamp:a}=e;if(n?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!n)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=a,this.startTime=Date.now(),this.startPerformanceTime=cD()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(a," ").concat(null==(r=e.getMetadata)?void 0:r.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=a,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}checkDowngradeByFrameDiff(){let e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}checkDowngradeByTimestampDiff(e){let t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}pipe(e){return t=>cR(this,null,(function*(){this._decodeSink=t;let i,r=e.mediaTrack;t.defer((()=>{var t;r&&(e.player.setCanvas(),e.setInputMediaStreamTrack(r)),null==i||i.close(),null==(t=this.videoContext)||t.destroy(),delete this._decodeSink}));let{renderer:o,type:n}=this;e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer));try{switch(n){case"wasm":i=this.createDecoder(n,this.wasmOption);break;case"webCodecs":i=this.createDecoder(n);break;default:throw new Error("not supported yet")}let r=0;if(i.on("videoFrame",(i=>{this.decodedFrameCount++,r++,(r<=10||r%500==0)&&e.log.debug("frame ".concat(r," ").concat(this.decodedFrameCount,"/").concat(this.decodeFrameCount," decoded ").concat(i.timestamp)),Date.now()-this.lastDowngradeTime>5e3&&("webCodecs"===this.type?this.checkDowngradeByFrameDiff():"wasm"===this.type&&this.checkDowngradeByTimestampDiff(i.timestamp)),t.next(i)})),i.on("error",(i=>{e.log.error(i),t.error("webCodecs"===n?4:8)})),yield i.initialize(this.videoElement),!this._decodeSink)return;if(i.configure(this.config),"wasm"===n&&"webgl"===o){this.videoContext=new LB({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(LB.UNAVAILABLE,(i=>{e.log.error(i),t.error(7)}));let r=new dK(this.videoContext);i.on("videoCodecInfo",(e=>r.resize(e.width,e.height))),i.on("videoFrame",(e=>{({y:r.Y,u:r.U,v:r.V}=e),1===this.downgradeLevel?this.decodedFrameCount%2==0&&r.render(this.decodedFrameCount):r.render(this.decodedFrameCount)})),e.source=r,e.player.setCanvas(this.videoContext._canvas,2)}else if("videoFrame"===o){e.player.setCanvas();let t=new MediaStreamTrackGenerator({kind:"video"}),r=t.writable.getWriter();e.setInputMediaStreamTrack(t),i.on("videoFrame",(e=>r.write(e)))}else{this.videoContext=new PB({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1});let r=this.videoContext.createVideoImageSource();i.on("videoFrame",(i=>{try{r.image=i,r.update()}catch(o){delete this.goodType,e.log.error(o),t.error(11)}}));let o=new AB(this.videoContext,{name:"remotePlayer",logger:e.log});r.connect(o),e.source=r,e.player.setCanvas(this.videoContext._canvas,2)}this.decoder=i}catch(hM){e.log.error(hM),t.error("webCodecs"===n?2:6)}}))}},mK=Promise.resolve(),fK=class extends sK.EventEmitter{constructor(e){super(),this.room=e,aR(this,"videoContext"),aR(this,"_glVideoContext"),aR(this,"_2dVideoContext"),aR(this,"destination"),aR(this,"smallVideoContext"),aR(this,"smallDestination"),aR(this,"smallTrackSource"),aR(this,"smallImageSource"),aR(this,"_isMirror",!1),aR(this,"_rotation",0),aR(this,"cameraTrack"),aR(this,"cameraNode"),aR(this,"transformNode"),aR(this,"mixNode"),aR(this,"screenTrack"),aR(this,"screenNode"),aR(this,"selfModel",!1),aR(this,"blurRadius",3),aR(this,"arTrack"),aR(this,"_enableFaceCentering",!1),aR(this,"_enableEffectOptimization",!1),aR(this,"onAbort"),aR(this,"_color"),aR(this,"Wasm"),aR(this,"waterMarkNode"),aR(this,"_waterMarkOption"),aR(this,"watermarkImageList",[]),aR(this,"_beautyParams"),aR(this,"isUsingArTrack",!1),aR(this,"mixTrack"),aR(this,"_isMixScreen",!1),aR(this,"_virtualBackground"),aR(this,"_virtualBackgroundAbortCallback"),aR(this,"virtualBackgroundInstance"),aR(this,"_bgAssetPath"),aR(this,"log"),aR(this,"_mat4"),aR(this,"_postProcessing"),aR(this,"_checkId",0),aR(this,"_use2d",!1),aR(this,"_autoSwitchRenderMode",!0),aR(this,"encodePipeline",[]),aR(this,"decodePipeline",[]),aR(this,"updated",mK),aR(this,"_updateFlag",!1),this.log=rM.createLogger({parent:null==e?void 0:e.getLogger(),id:"vm",userId:null==e?void 0:e.userId,sdkAppId:null==e?void 0:e.sdkAppId}),this.smallVideoContext=new PB({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get smallMode(){var e;return(null==(e=this.room)?void 0:e.smallMode)||"canvas"}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get _isRotate(){return 0!==this._rotation}get _isTransform(){return this._isMirror||this._isRotate}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get cameraResolution(){var e;let{width:t,height:i}=(null==(e=this.cameraTrack)?void 0:e.settings)||{};return MD(this._rotation)?{width:i,height:t}:{width:t,height:i}}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new PB({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new LB({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}initializeGlVideoContext(){try{this._glVideoContext.create(yO<=22),this._glVideoContext.on(LB.UNAVAILABLE,(e=>{var t;this.emit("error",e),this.log.warn("video context unavailable",e),null==(t=this._virtualBackgroundAbortCallback)||t.call(this,e),this.update().catch((e=>{this.log.error(e)}))}))}catch(kR){this.emit("error",kR)}}initVirtualBackground(e,t,i){this.onAbort=e,this._mat4=t,this._postProcessing=i}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=$P.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),$P.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(IO||this._isMixScreen||this._isTransform||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?CL.addFailedEvent({key:t,error:e}):CL.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new LB({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}setSmallVideo(e,t){if("api"!==this.smallMode)if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new wB(this.smallVideoContext,e,this.log),this.smallVideoContext.on(LB.UNAVAILABLE,(e=>{this.log.warn("small video context lost",e)}))}if(this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t)this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.resize(t.width,t.height),this.smallImageSource.connect(this.smallDestination));else if(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource)this.smallTrackSource.replaceTrack(this.initialTrack);else{this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource");let{width:e,height:t}=this.cameraTrack.settings;this.smallTrackSource.resize(e,t),this.smallTrackSource.connect(this.smallDestination)}}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}_setMainOutput(e){var t;try{let i=this.cameraTrack,{small:r,player:o}=i;IO&&o.setCanvas(e);let n=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),n=this.arTrack),this.log.info("set main output ".concat(n?n.label:"no output track")),this.setSmallVideo(r,e),i.setOutputMediaStreamTrack(n)}catch(pM){this.log.error("set main output failed",pM)}}update(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return cR(this,null,(function*(){var t;if(!this.cameraTrack||!this.initialTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:i,profile:r}=this.cameraTrack;if(this._use2d||!this._virtualBackground&&!this._beautyParams)this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(EB.RENDER,(e=>{var t;null==(t=this.cameraTrack)||t.emit("render",e)}))),16===kO?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof CB?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof CB?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(i.width,i.height);else if(e&&this.cameraNode&&this.destination)this.cameraNode.replaceTrack(this.initialTrack);else{this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():(this.destination=new SB(this.videoContext,{name:"mainDestination",logger:this.log}),this.destination.on(EB.RENDER,(e=>{var t;null==(t=this.cameraTrack)||t.emit("render",e)})));let{width:e,height:t}=this.cameraResolution,i=yield this.getWatermarkImage(e,t);this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.cameraNode=new lK(this.videoContext,{input:this.initialTrack,width:e,height:t,mirror:this._isMirror,rotation:this._rotation,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,Wasm:this.Wasm,enableFaceCentering:this._enableFaceCentering,enableEffectOptimization:this._enableEffectOptimization,onAbort:this.onAbort,mat4:this._mat4,postProcessing:this._postProcessing,color:this._color}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute(),yield this.cameraNode.predictReady}if(this.videoContext.frameRate=r.frameRate,this._use2d){let e=this.cameraNode;if(e.disconnect(),this._isTransform&&(this.transformNode?(this.transformNode.mirror=this._isMirror,this.transformNode.rotation=this._rotation):this.transformNode=new BB(this.videoContext,this.log,this._isMirror,this._rotation),e=e.connect(this.transformNode),e.disconnect(),this.log.info("start mirror ".concat(this._isMirror," rotate ").concat(this.rotation))),this.mixNode&&this.mixNode.close(),delete this.mixNode,this._isMixScreen||this._hasWaterMark){if(this.mixNode=new VB(this.videoContext,this.log),e.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption)this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y;else if(this.waterMarkNode){let{width:e,height:t}=this.cameraResolution;this.waterMarkNode.image=yield this.getWatermarkImage(e,t),e&&t&&this.waterMarkNode.resize(e,t)}null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&(this.screenNode||(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource"),this.screenNode.resize(this.screenTrack.settings.width,this.screenTrack.settings.height)),this.screenNode.shouldUpdate=!1,this.screenNode.connect(this.mixNode,{zIndex:0})),e=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))}e.connect(this.destination)}return this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext.canvas)}))}clearLastFrame(){var e;this.destination&&(null==(e=this.destination.ctx2d)||e.clearRect(0,0,this.destination.width,this.destination.height))}changeInput(e){var t,i,r,o,n;if(e instanceof GB)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof mB)return this.log.info("change video input",null==(i=e.mediaTrack)?void 0:i.label),this.setCameraTrack(e);if(e instanceof ZB){this.log.info("change remote input",null==(r=e.mediaTrack)?void 0:r.label);let t=e.mediaTrack;return e.setOutputMediaStreamTrack(t)}if(e instanceof HB)return this.log.info("change mix input",null==(o=e.outMediaTrack)?void 0:o.label),this.setMixTrack(e);this.log.warn("change unknown input",null==(n=e.mediaTrack)?void 0:n.label)}removeInput(e){var t;e instanceof GB?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof mB?this._isMixScreen?(delete this.cameraNode,this.cameraTrack._inputTrack=null,this.update()):(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof ZB?e.source&&e.source.context.destroy():e instanceof HB&&(delete this.mixTrack,this.update())}setMixTrack(e){this.mixTrack=e}setCameraTrack(e){return this.cameraTrack=e,this.update(!0)}setScreenTrack(e){return cR(this,null,(function*(){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):yield this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}))}getWatermarkImage(e,t){return cR(this,null,(function*(){let i=document.createElement("canvas");t&&e&&(i.height=t,i.width=e);let r=i.getContext("2d");if(!r)throw new vR({code:_R.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((i=>{let{image:o,x:n,y:a,width:s,height:c,fillVideo:l}=i,d=l&&e||s,u=l&&t||c,h=l?0:n,p=l?0:a;r.drawImage(o,h,p,d,u)})),SD(i.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex&&t.fillVideo===e.fillVideo))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setBeautyParams(e){return cR(this,null,(function*(){this._beautyParams=e,this.update()}))}stopBeauty(){return cR(this,null,(function*(){this._beautyParams=void 0,this.update()}))}setWatermark(e){return cR(this,null,(function*(){let t;try{t=yield SD((null==e?void 0:e.imageElement)||e.imageUrl)}catch(cM){throw new vR({code:_R.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:i=0,y:r=0,width:o=t.width,height:n=t.height,type:a="watermark",zIndex:s=2,fillVideo:c=!1}=e;this.watermarkImageList.some((e=>e.type===a))?(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==a)),this.pushWaterMarkImageList({x:i,y:r,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl,fillVideo:c}),t=yield this.getWatermarkImage(this.cameraResolution.width,this.cameraResolution.height),this._waterMarkOption={x:0,y:0,width:t.width,height:t.height,image:t},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(t.width,t.height),this.waterMarkNode.image=t):this.update()):(this.pushWaterMarkImageList({x:i,y:r,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl,fillVideo:c}),yield this.freshWatermark()),this.log.info("set watermark",JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t)))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return cR(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t))),yield this.freshWatermark()}))}freshWatermark(){return cR(this,null,(function*(){var e;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let{width:t,height:i}=this.cameraResolution,r=yield this.getWatermarkImage(t,i);this._waterMarkOption={x:0,y:0,width:r.width,height:r.height,image:r},this.update()}))}setVirtualBackground(e){return cR(this,null,(function*(){var t,i,r;if(e){if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield SD(e.imageUrl):(this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type),this._enableFaceCentering=null!=(t=e.enableFaceCentering)?t:this._enableFaceCentering,this._enableEffectOptimization=null!=(i=e.enableEffectOptimization)?i:this._enableEffectOptimization,this._color=null!=(r=e.color)?r:[0,1,0]}else delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;if(this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),yield this.update(),this._virtualBackground&&!this._glVideoContext.available)throw new vR({code:_R.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)})}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get mirror(){return this._isMirror}set rotation(e){var t;this._rotation!==e&&(this._rotation=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get rotation(){return this._rotation}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return cR(this,null,(function*(){var e;null!=(e=this.cameraTrack)&&e.mediaTrack&&(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}createDecodeContext(e){return new pK(e)}clear(){var e,t;null==(e=this.videoContext)||e.disconnect(),null==(t=this.destination)||t.removeAllListeners(),delete this.destination,delete this.cameraNode,delete this.transformNode,delete this.screenNode,delete this.waterMarkNode}addEncodeProcessor(e){let{processor:t,type:i}=e;var r;this.encodePipeline.includes(t)||(this.encodePipeline[i]=t,null==(r=this.room)||r.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:i}=e;var r;this.decodePipeline.includes(t)||(this.decodePipeline[i]=t,null==(r=this.room)||r.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}};nR([function(e){return MU(((t,i)=>function(){for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return cR(this,null,(function*(){try{return yield t.apply(this,r)}catch(pM){e.call(this,pM)}}))}))}((function(e){this.log.error("update failed",e)})),MU((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return cR(this,null,(function*(){this._updateFlag||(this._updateFlag=!0,yield mK,this.updated=new Promise(((t,r)=>{e.apply(this,i).then(t,r),setTimeout(r,5e3,new vR({code:_R.API_CALL_TIMEOUT,message:"update timeout"}))})),this._updateFlag=!1,yield this.updated)}))}))],fK.prototype,"update",1);var _K=0,gK=class extends qP{constructor(e){super("room"),aR(this,"seq",++_K),aR(this,"sdkAppId"),aR(this,"userId"),aR(this,"userSig"),aR(this,"privateMapKey"),aR(this,"latencyLevel"),aR(this,"tinyId"),aR(this,"scene"),aR(this,"roomId"),aR(this,"useStringRoomId"),aR(this,"role","anchor"),aR(this,"joinParams",null),aR(this,"localPublishFlag",0),aR(this,"localTracks",new Set),aR(this,"enableAutoPlayDialog",!0),aR(this,"autoReceiveAudio",!0),aR(this,"autoReceiveVideo",!0),aR(this,"proxy_ws"),aR(this,"proxy_wt"),aR(this,"proxy_unified"),aR(this,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0,isH265EncodeSupported:!0,isH265DecodeSupported:!0}}),aR(this,"keyPointManager"),aR(this,"audioManager"),aR(this,"videoManager"),aR(this,"callDurationCalculator"),aR(this,"badCaseDetector"),aR(this,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),aR(this,"videoDecodeFallbackType"),aR(this,"smallMode","canvas"),aR(this,"enableChorus",!1),aR(this,"_isUsingCachedSchedule",!1),aR(this,"_log"),aR(this,"_joinedTimestamp",0),aR(this,"_sdkType"),aR(this,"heartbeatReport"),aR(this,"heartbeatCount",0),aR(this,"quality"),aR(this,"enableSEI"),aR(this,"isDestroyed",!1),this._log=rM.createLogger({parent:e.logger,id:"r".concat(this.seq)}),this.useStringRoomId=!!e.useStringRoomId,QC(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),QC(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),QC(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new iK({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new oK({room:this}),this.badCaseDetector=new aK({room:this}),this.audioManager=new YB(this),this.videoManager=new fK(this)}get videoCodec(){return"h264"}get scriptTransformWorker(){}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}get localMainAudioTrack(){for(let e of this.localTracks)if(1&e.mediaType)return e;return null}get localMainVideoTrack(){for(let e of this.localTracks)if(4&e.mediaType)return e;return null}get localAuxVideoTrack(){for(let e of this.localTracks)if(2&e.mediaType)return e;return null}get publishState(){let e={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};return this.localTracks.forEach((t=>{if(t.isPublished||t.isPublishing)switch(t.mediaType){case 1:e.audio=!0;break;case 4:e.bigVideo=!0,e.smallVideo=t.hasSmall;break;case 2:e.auxVideo=!0}})),e}get muteState(){var e,t,i;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(i=this.localAuxVideoTrack)||!i.muted)}}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return cR(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return cR(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return cR(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(XC(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(jC(e)){let{websocketProxy:t,webtransportProxy:i,loggerProxy:r,scheduleProxy:o,unifiedProxy:n}=e;this.proxy_ws=t,this.proxy_wt=i,this.proxy_unified=n,n?(bG([n,n]),LR("https://".concat(n))):(r&&LR(r),o&&bG(o))}$O.once(eM.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:AG.main,sched_back_domain:AG.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return cR(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return cR(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let i of this.quality.downlinkInfo)t.downlinksRTT[i.userId]=i.rtt;return t}))}getRemoteVideoStats(){return cR(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let i={};return e.remotePublishedUserMap.forEach((e=>{let r="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;i[e.userId]=r.stat})),i}()}))}checkDestroy(){if(this.isDestroyed)throw new vR({code:_R.INVALID_OPERATION,message:vL({key:mL.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(fL.INVALID_DESTROY),new vR({code:_R.INVALID_OPERATION,message:vL({key:mL.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,$O.emit(eM.ROOM_DESTROY,{room:this})}schedule(e,t){return cR(this,null,(function*(){var i,r,o,n;let a=cD();try{let{isCached:s,result:c,detailCost:l}=yield IG({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:wR,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});this._isUsingCachedSchedule=s,this._log.info("schedule cache:".concat(+s," ").concat(TD(c,{keysToExclude:["username","credential"]}))),s&&$O.once(eM.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=Zw(Zw({},this.scheduleResult),c),JC(null==(i=c.config)?void 0:i.retryCount)&&Dk(c.config.retryCount),XC(null==(r=c.config)?void 0:r.loggerDomain)&&LR(c.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=c.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,this.smallMode=(null==(n=c.config)?void 0:n.smallMode)||this.smallMode,$O.emit(eM.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),CL.addSuccessEvent({key:521700,cost:cD()-a})}catch(lM){throw CL.addFailedEvent({key:521700,error:lM}),lM}}))}sendAbilityStatus(e){}enableInsertableStreams(){return Promise.resolve()}switchRoom(e){return Promise.reject()}isSwitchRoomSupported(){return!1}};var vK={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},EK="__INLINE__WORKER__",yK="__INLINE__WASM__",{debug:TK}=console;vK.debug||(console.debug=()=>{});var IK,AK=!EK.startsWith("__"),bK=!yK.startsWith("__");function SK(){let e=DD("".concat(vK.assetsPath?"".concat(vK.assetsPath,"/"):"","worker.js"));return AK?URL.createObjectURL(new Blob([atob(EK)],{type:"application/javascript"})):e.startsWith("http")?fetch(e).then((e=>e.blob().then((e=>URL.createObjectURL(e))))):e}function wK(){return cR(this,null,(function*(){let e=vK.assetsPath?"".concat(vK.assetsPath,"/"):"";return IK||(IK=bK?(new TextEncoder).encode(atob(yK)).buffer:yield fetch(DD("".concat(e,"av_processing.wasm"))).then((e=>e.arrayBuffer())),IK)}))}var RK=new class{constructor(){aR(this,"playPort"),aR(this,"playPortSent",!1),aR(this,"worklet"),aR(this,"workletPromise")}init(){return this.workletPromise||(this.workletPromise=this._init()),this.workletPromise}_init(){return cR(this,null,(function*(){let e=Yx(),t=SK();try{yield e.audioWorklet.addModule("string"==typeof t?t:yield t),rM.info("global audio player worklet addModule success",t)}catch(Ok){throw rM.error("global audio player worklet addModule failed:",Ok),Ok}return this.worklet=new AudioWorkletNode(e,"global-audio-player",{processorOptions:{wasm:yield wK(),flag:vK},numberOfInputs:2}),rM.info("global audio player worklet created",e.state),this.worklet.connect(e.destination),this.playPort=this.worklet.port,this.playPort}))}playAudio(e){return cR(this,null,(function*(){var t;yield this.init();let i=new MessageChannel;null==(t=this.playPort)||t.postMessage(null,[i.port1]),e(i.port2)}))}},kK="undefined"!=typeof self&&(!("top"in self)||self===top)&&"showOpenFilePicker"in self&&"showOpenFilePicker";kK?Promise.resolve().then((function(){return OK})):Promise.resolve().then((function(){return VK})),kK?Promise.resolve().then((function(){return xK})):Promise.resolve().then((function(){return FK}));var CK=kK?Promise.resolve().then((function(){return UK})):Promise.resolve().then((function(){return BK}));function DK(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(this,null,(function*(){return(yield CK).default(...t)}))}var NK=e=>cR(void 0,null,(function*(){let t=yield e.getFile();return t.handle=e,t})),OK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){Array.isArray(e)||(e=[e]);let t=[];e.forEach(((e,i)=>{t[i]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map((r=>{t[i].accept[r]=e.extensions||[]})):t[i].accept["*/*"]=e.extensions||[]}));let i=yield window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=yield Promise.all(i.map(NK));return e[0].multiple?r:r[0]}()}))}};function MK(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return MK=function(e){this.s=e,this.n=e.next},MK.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var i=this.s.return;return void 0===i?Promise.resolve({value:e,done:!0}):t(i.apply(this.s,arguments))},throw:function(e){var i=this.s.return;return void 0===i?Promise.reject(e):t(i.apply(this.s,arguments))}},new MK(e)}var LK,PK=function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),o=2;o<i;o++)r[o-2]=arguments[o];return cR(void 0,[e,t,...r],(function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.name,r=arguments.length>3?arguments[3]:void 0;return function*(){let o=[],n=[];var a,s=!1,c=!1;try{for(var l,d=function(e){var t,i,r,o=2;for("undefined"!=typeof Symbol&&(i=Symbol.asyncIterator,r=Symbol.iterator);o--;){if(i&&null!=(t=e[i]))return t.call(e);if(r&&null!=(t=e[r]))return new MK(t.call(e));i="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(l=yield d.next()).done;s=!1){let a=l.value,s="".concat(i,"/").concat(a.name);"file"===a.kind?n.push(a.getFile().then((t=>(t.directoryHandle=e,t.handle=a,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>s}))))):"directory"!==a.kind||!t||r&&r(a)||o.push(PK(a,t,s,r))}}catch(u){c=!0,a=u}finally{try{s&&null!=d.return&&(yield d.return())}finally{if(c)throw a}}return[...(yield Promise.all(o)).flat(),...yield Promise.all(n)]}()}))},xK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){e.recursive=e.recursive||!1,e.mode=e.mode||"read";let t=yield window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return PK(t,e.recursive,void 0,e.skipDirectory)}()}))}},UK={__proto__:null,default:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return cR(void 0,[e,...i],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[{}],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return function*(){Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";let n=[],a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach(((e,t)=>{n[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&a&&e.mimeTypes.push(a),e.mimeTypes.map((i=>{n[t].accept[i]=e.extensions||[]}))):a?n[t].accept[a]=e.extensions||[]:n[t].accept["*/*"]=e.extensions||[]})),i)try{yield i.getFile()}catch(l){if(i=null,r)throw l}let s=i||(yield window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:n,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1}));!i&&o&&o(s);let c=yield s.createWritable();return"stream"in e?(yield e.stream().pipeTo(c),s):"body"in e?(yield e.body.pipeTo(c),s):(yield c.write(yield e),yield c.close(),s)}()}))}},VK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),new Promise(((t,i)=>{let r=document.createElement("input");r.type="file";let o=[...e.map((e=>e.mimeTypes||[])),...e.map((e=>e.extensions||[]))].join();r.multiple=e[0].multiple||!1,r.accept=o||"",r.style.display="none",document.body.append(r);let n=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(n,(()=>a(i)),r),s=()=>{window.removeEventListener("focus",s),r.remove()};r.addEventListener("click",(()=>{window.addEventListener("focus",s)})),r.addEventListener("change",(()=>{window.removeEventListener("focus",s),r.remove(),n(r.multiple?Array.from(r.files):r.files[0])})),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()}))}()}))}},FK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise(((t,i)=>{let r=document.createElement("input");r.type="file",r.webkitdirectory=!0;let o=e=>{"function"==typeof n&&n(),t(e)},n=e[0].legacySetup&&e[0].legacySetup(o,(()=>n(i)),r);r.addEventListener("change",(()=>{let t=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter((t=>t.webkitRelativePath.split("/").every((t=>!e[0].skipDirectory({name:t,kind:"directory"})))))):t=t.filter((e=>2===e.webkitRelativePath.split("/").length)),o(t)})),"showPicker"in HTMLInputElement.prototype?r.showPicker():r.click()}))}()}))}},BK={__proto__:null,default:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return cR(void 0,[e,...i],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){Array.isArray(t)&&(t=t[0]);let i=document.createElement("a"),r=e;"body"in e&&(r=yield function(e,t){return cR(this,null,(function*(){let i=e.getReader(),r=new ReadableStream({start:e=>function t(){return cR(this,null,(function*(){return i.read().then((i=>{let{done:r,value:o}=i;if(!r)return e.enqueue(o),t();e.close()}))}))}()}),o=new Response(r),n=yield o.blob();return i.releaseLock(),new Blob([n],{type:t})}))}(e.body,e.headers.get("content-type"))),i.download=t.fileName||"Untitled",i.href=URL.createObjectURL(yield r);let o=()=>{"function"==typeof n&&n()},n=t.legacySetup&&t.legacySetup(o,(()=>n()),i);return i.addEventListener("click",(()=>{setTimeout((()=>URL.revokeObjectURL(i.href)),3e4),o()})),i.click(),null}()}))}},HK=class{constructor(e){this.name=e,aR(this,"ready"),aR(this,"worker"),aR(this,"ports"),aR(this,"ids",1),aR(this,"transactions",new Map),aR(this,"log"),aR(this,"addTransaction",(e=>(this.transactions.set(++this.ids,e),this.ids)))}postMessage(e,t){var i;null==(i=this.worker)||i.postMessage(e,t)}create(e){return cR(this,null,(function*(){if(this.ready)return this.ready;e||(e=this.name),console.time("createWorker_".concat(e));let t=SK(),i=new Worker("string"==typeof t?t:yield t,{name:e});return this.worker=i,this.ready=new Promise(((t,r)=>cR(this,null,(function*(){i.onmessage=i=>{let{data:{id:o,type:n,payload:a}}=i;var s;if(o)null==(s=this.transactions.get(o))||s(a),this.transactions.delete(o);else switch(n){case"error":console.timeEnd("createWorker_".concat(e)),console.warn("worker error:",a),r(a);break;case"ready":console.timeEnd("createWorker_".concat(e)),t(this);break;case"updateAFSM":if(a.value){let e="string"==typeof a.old?a.old:"".concat(a.old.action,"ing"),t="string"==typeof a.value?a.value:"".concat(a.value.action,"ing");console.log(yD(),a.group,a.name,e,"👉",t)}break;case"log":console.log(a);break;case"glog":window.dispatchEvent(new CustomEvent(n,{detail:a}))}},i.postMessage({wasm:yield wK(),flag:vK},this.ports)}))))}))}destroy(){var e;console.log("destroy worker",this.name),delete this.ready,null==(e=this.worker)||e.terminate()}},WK=class{constructor(e,t,i){this.worker=e,aR(this,"channel",new MessageChannel),aR(this,"ready"),this.ready=new Promise(((e,i)=>{this.worker.postMessage({id:this.worker.addTransaction(e),payload:t},[this.channel.port2])})).then((e=>(0===e.err&&(this.worker.sessionCount++,this.channel.port1.onmessage=i),e)))}postMessage(){this.channel.port1.postMessage(...arguments)}destroy(){0==--this.worker.sessionCount&&this.worker.destroy()}},jK=new class e extends HK{constructor(){super("main"),aR(this,"switchValue",new Map),aR(this,"extendChannel"),aR(this,"sessionCount",0)}setSwitchValue(e,t){var i;this.switchValue.set(e,t),null==(i=this.extendChannel)||i.port1.postMessage([e,t])}create(){return cR(this,null,(function*(){return this.ready?this.ready:(this.extendChannel=new MessageChannel,this.ports=[this.extendChannel.port2],yield sR(e.prototype,this,"create").call(this),this.switchValue.forEach(((e,t)=>{this.extendChannel.port1.postMessage([t,e])})),this)}))}};function GK(e){return cR(this,null,(function*(){yield jK.create(),$O.emit(eM.JOIN_SEND_CMD,{room:this});let t=new WK(jK,e,(e=>{let i=e.data;if("string"==typeof i)this.onWorkerEvent(i);else if(null==i)this.onWorkerEvent("client-banned",0),t.destroy();else{let{cmd:e,payload:t}=i;this.onWorkerEvent(e,t)}})),{err:i,data:r}=yield t.ready;if("number"==typeof i){if($O.emit(eM.JOIN_RECEIVED_CMD_RES,{room:this,code:i}),0===i)return Object.assign(this,r,{session:t});throw new vR({code:_R.JOIN_ROOM_FAILED,extraCode:Number(i),message:vL({key:mL.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:i,errorMsg:""}})})}throw i}))}function zK(e){return cR(this,null,(function*(){jK.setSwitchValue("useAINS",e)}))}function qK(e){return cR(this,null,(function*(){jK.setSwitchValue("useV2",e)}))}function KK(e){let t=new MediaStreamTrackGenerator({kind:"audio"});e.setInputMediaStreamTrack(t),e.player.setVolume(0),this.postMessage({cmd:"pullAudio",payload:{tinyId:e.tinyId,writable:t.writable}},[t.writable])}function YK(e){return cR(this,null,(function*(){var t;this._log.info("pull video",e);let i=Date.now(),r=0,o=new MessageChannel;this.postMessage({cmd:"pullVideo",payload:{mediaType:e.mediaType,tinyId:e.tinyId}},[o.port1]),(t=e.stat).framesReceived||(t.framesReceived=0),ZU(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=Object.defineProperties(yV(),{postMessage:{value:e.postMessage.bind(e)},port:{get:()=>e,set(t){e.onmessage=jU,e.onmessageerror=jU,e=t,r()}}});function r(){e.onmessage=r=>{r.data?r.ports.length||t?i.next(r):i.next(r.data):(i.complete(),e.close())},e.onmessageerror=t=>{i.error(t),e.close()}}return r(),i}(o.port2),tF(MV(e,qP.INIT)),iB((t=>{let{data:o,packetsReceived:n}=t;e.stat.packetsReceived=n,e.stat.framesReceived++,r++;let a,s=31&o[4];if(r<=10){let e=Array.from(o.slice(0,10)).map((e=>e.toString(16).padStart(2,"0"))).join(" ");this._log.info("Frame ".concat(r," - Size: ").concat(o.length," bytes, Type: ").concat(s,", Timestamp: ").concat(Date.now()-i,"ms First 10 bytes: ").concat(e))}switch(s){case 5:case 7:a="key";break;default:a="delta"}e.isAvailable?e.decodeFrame({data:o.buffer,type:a,timestamp:1e3*(Date.now()-i)}):console.warn("track is not available")}),(()=>{}),(()=>{o.port2.postMessage(null),o.port2.close()})))}))}Object.defineProperties(window,{useAINS:{set:zK},useWt:{set:function(e){return cR(this,null,(function*(){jK.setSwitchValue("useWt",e)}))}},enableDebug:{set(e){console.debug=e?TK:()=>{},jK.setSwitchValue("enableDebug",e)}},useV2:{set:qK},dump:{value(){if(LK||(console.warn("dump audio will be activated at next time join room"),LK=[]),!LK.length)return void console.warn("no audio data to dump,try it later");let e=[];return LK.forEach((t=>{e.push(new Uint16Array([t.length])),e.push(t)})),DK(new Blob(e),{fileName:"audio dump hex",extensions:[".hex"]})}},dumpAudio:{value(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"audio",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,i=[],r=new Promise((r=>{let o=new MessageChannel;jK.extendChannel.port1.postMessage(["dump",e],[o.port1]),o.port2.onmessage=n=>{let{data:a}=n;console.log(a),i.push(a),i.length>t&&(o.port2.onmessage=null,jK.extendChannel.port1.postMessage(["dump",e]),o.port2.close(),r(new Blob(i)))}}));return DK(r,{fileName:e,extensions:[".pcm"]})}},hardDec:{set(e){switch(e){case!0:vK.useHardDecoder="prefer-hardware";break;case!1:vK.useHardDecoder="prefer-software";break;default:vK.useHardDecoder="no-preference"}}}});var XK=[];function JK(e){var t;let i=yV();if("joined"!==this.state)throw new Error("Room is not joined");if("publish"===e.state)return;for(let l=0;l<=XK.length;l++)if(!XK[l]){XK[l]=this,this.index=l;break}let r=e.profile;this._log.info("start push audio",this.index,r);let o=new MessageChannel,n=e.enableEncryptFrame?new MessageChannel:null;null==(t=this.session)||t.postMessage({cmd:"pushAudio",payload:Zw({index:this.index},r)},n?[o.port2,n.port2]:[o.port2]),o.port1.onmessage=t=>{null==t.data||("number"==typeof t.data?i.next(t.data):n&&n.port1.postMessage(eR(Zw({},t.data),{data:new Uint8Array(e.encodeFrame({data:t.data.data.buffer,timestamp:t.data.timestamp}).data)})))};let a,s=new MediaStream,c=e=>{let t=s.getAudioTracks()[0];t&&(a.disconnect(),s.removeTrack(t)),s.addTrack(e),this._log.info("push audio track:",e.readyState,e.getSettings().deviceId),a=Yx().createMediaStreamSource(s),a.connect(RK.worklet,0,this.index)};ZU(MV(e,"output-media-track-changed"),tF(MV(e,"ready")),iB(c,console.error,(()=>{this._log.info("stop push audio",r),e.volume=0,a.disconnect(),XK[this.index]=null,n&&n.port1.postMessage(null),o.port1.postMessage(null)}))),ZU(i,rB((t=>e.volume=t)),LF(TB(1e3)),iB((()=>{e.volume=0}))),c(e.outMediaTrack)}var QK=class{constructor(e,t,i,r){this.localTrack=e,this.type=t,this.config=i,this.port=r,aR(this,"track"),aR(this,"label"),aR(this,"insertKeyFrame",!0),aR(this,"session"),aR(this,"tsMap",new Map),e._log.info("create Video Encoder",i)}trans(e,t,i){return cR(this,null,(function*(){let r=yield this.recreate(i,{recreateCount:0,frameEncoded:0,selectConfigIndex:0});t.signal.addEventListener("abort",(()=>{r.encoder.close()}));let o=0;return e.pipeThrough(new TransformStream({transform:(e,t)=>{"configured"===r.encoder.state&&(this.tsMap.set(o,Date.now()),this.encode(e),o++,t.enqueue(e))}}),t)}))}encode(e){var t,i;null==(i=null==(t=this.session)?void 0:t.encoder)||i.encode(e,{keyFrame:this.insertKeyFrame}),this.insertKeyFrame=!1}start(e,t,i){return cR(this,null,(function*(){let r=yield this.recreate(i,{recreateCount:0,frameEncoded:0,selectConfigIndex:0});this.session=r;let o=0;e.pipeTo(new WritableStream({write:e=>{"configured"===r.encoder.state&&(o<10&&this.localTrack.log.info("capture ".concat(this.label," track frame:"),o,Date.now(),e.timestamp,e.displayWidth,e.displayHeight),(e.displayWidth!==this.config.width||e.displayHeight!==this.config.height)&&(this.localTrack.log.info("resize video track frame:",e.displayWidth,e.displayHeight,this.config.width,this.config.height),this.configure({width:e.displayWidth,height:e.displayHeight},r)),this.tsMap.set(o,Date.now()),this.encode(e),o<10&&this.localTrack.log.info("encode ".concat(this.label," track frame:"),o),o++,e.close())}}),t).catch((e=>{this.localTrack.log.warn(e),r.encoder.close()}))}))}recreate(e,t){return cR(this,null,(function*(){let i=0,r=new VideoEncoder({output:r=>{let o=this.tsMap.get(i);if(this.tsMap.delete(r.timestamp),i<10&&(0===i&&0===t.recreateCount&&$O.emit(eM.SEND_FIRST_VIDEO_FRAME,{room:e}),this.localTrack.log.info("encoded ".concat(this.label," track frame:"),i,Date.now(),r.timestamp)),i++,t.frameEncoded=i,!1===this.track.enabled)return;let n=null;if(this.localTrack.enableEncodeFrame){n=new Uint8Array(r.byteLength),r.copyTo(n);let e=this.localTrack.encodeFrame({data:n.buffer},3===this.type);n=new Uint8Array(e.data)}n?(this.localTrack.stat.bytesSent+=n.length,this.port.postMessage({chunk:{type:r.type,timestamp:r.timestamp,data:n,duration:r.duration},timestamp:o},[n.buffer])):(this.localTrack.stat.bytesSent+=r.byteLength,this.port.postMessage({chunk:r,timestamp:o}))},error:i=>{this.localTrack.log.warn(i,this.config),t.recreateCount++,setTimeout((()=>this.recreate(e,t)),100)}});return t.encoder=r,yield this.configure(null,t),t}))}configure(e,t){return cR(this,null,(function*(){var i;e&&Object.assign(this.config,e),null==(i=t.encoder)||i.configure(this.config)}))}close(){this.port.postMessage(null),this.port.close()}};function $K(e,t){return cR(this,null,(function*(){let i=2===e.mediaType,r=i?"screen":"video",o={codec:"avc1.420028",latencyMode:"realtime",avc:{format:"annexb"},hardwareAcceleration:vK.useHardEncoder,width:t.profile.width,height:t.profile.height,framerate:t.profile.frameRate,bitrate:1e3*t.profile.bitrate},n=new MessageChannel;this.postMessage({cmd:"pushVideo",payload:t},[n.port1]);let a=new QK(e,t.type,o,n.port2);return n.port2.onmessage=e=>{if(260===e.data)a.insertKeyFrame=!0;else if(!i){let{bitrate:t}=e.data;HC({configureBr:[e.data.bitrate,t]}),a.session&&a.configure({bitrate:t},a.session)}},this._log.info("start push",r,t),a}))}function ZK(e){return cR(this,null,(function*(){var t;let i=2===e.mediaType,r=i?"screen":"video",o={type:i?7:2,profile:e.profile,trackType:i?"screen":"camera",crypto:!(null==(t=e.manager)||!t.encodePipeline[0])};!i&&e.outMediaTrack instanceof CanvasCaptureMediaStreamTrack&&(o.trackType="canvas");let{trackType:n}=o,{width:a,height:s}=e.outMediaTrack.getSettings();o.profile.width=a,o.profile.height=s;let c=yield $K.call(this,e,o);this._log.info("VideoEncoder created",o);let l,d=t=>cR(this,null,(function*(){if(null==l||l.abort("track changed"),!t)return;l=new AbortController;let{width:i,height:o,displaySurface:a}=t.getSettings();i&&(c.config.width=i),o&&(c.config.height=o);let s,d=tN.match(/Chrome\/(\d+)/);"114"===(null==d?void 0:d[1])&&"browser"===a&&delete c.config.hardwareAcceleration,this._log.info("push",r,"track:",t.readyState,t.getSettings()),s="undefined"==typeof MediaStreamTrackProcessor||t instanceof CanvasCaptureMediaStreamTrack?new ReadableStream({start(t){e.on("render",(i=>{if(0!==e.player.mode||document.hidden)try{t.enqueue(new VideoFrame(i,{timestamp:1e3*performance.now()}))}catch(r){console.warn(r)}}))},pull(t){return cR(this,null,(function*(){if(0===e.player.mode&&CP()&&e.player.element)return new Promise((i=>{e.player.element.requestVideoFrameCallback(((r,o)=>{try{let i=new VideoFrame(e.player.element);t.enqueue(i)}catch(n){console.warn(n)}i()}))}))}))}}):new MediaStreamTrackProcessor({track:t}).readable;let u="small"in e&&e.small;return u?(this.smallEncoder||(this.smallEncoder=yield $K.call(this,e,{profile:u,type:3,trackType:n})),this.smallEncoder.track=t,this.smallEncoder.label="small",s=yield this.smallEncoder.trans(s,l,this)):this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder),c.track=t,c.label=r,c.start(s,l,this)}));return ZU(MV(e,"output-media-track-changed"),tF(MV(e,"ready")),iB(d,console.error,(()=>{var e;this._log.info("stop push",r,o),l.abort("unpublish"),c.close(),null==(e=this.smallEncoder)||e.close()}))),d(e.outMediaTrack)}))}var eY=class e extends qP{constructor(t){var i,r;super(null!=(r=null==(i=t.roomid)?void 0:i.toString())?r:t.name,"volumeEvaluation"),this.room=t,aR(this,"enableInBackground",!1),aR(this,"interval",400),t.on("joined",(()=>{this.emit(e.INTERVALCHANGED,this.interval)})),ZU(MV(this,e.INTERVALCHANGED),OF((e=>"joined"===this.room.state?this.room.fromWorker("getAudioEnergy",e):ZU((e=>t=>{let i=0,r=performance.now();ZU(yB,wF((t=>(t-r)/e|0)),$V((e=>e!=i&&(i=e,!0))))(t)})(e),wF((()=>[]))))),iB((e=>{e.forEach((e=>{this.room.remotePublishedUserMap.has(e.userId)&&(this.room.remotePublishedUserMap.get(e.userId).remoteAudioTrack.volume=e.volume)})),(!document.hidden||this.enableInBackground)&&this.state==qP.ON&&this.room.emit("audio-volume",e)})))}start(t,i){this.interval=t,this.enableInBackground=i,this.emit(e.INTERVALCHANGED,this.interval)}stop(){}};aR(eY,"INTERVALCHANGED","intervalChanged"),nR([jP([qP.INIT,qP.OFF],qP.ON)],eY.prototype,"start",1),nR([jP([],qP.OFF)],eY.prototype,"stop",1);var tY=eY,iY=class extends gK{constructor(e){super(e),aR(this,"index",0),aR(this,"session"),aR(this,"tinyid"),aR(this,"roomid"),aR(this,"openid"),aR(this,"socketid"),aR(this,"relayip"),aR(this,"clientip"),aR(this,"remotePublishedUserMap",new Map),aR(this,"bussinessInfo"),aR(this,"token"),aR(this,"audioVolumeEvalution",new tY(this)),aR(this,"enableAIVoice",zK),aR(this,"AbilityOption",{AVLimit:{EncVideoCodec:"H265",EncVideoWidth:0,EncVideoHeight:0,EncVideoBr:"0",EncVideoFps:0,EncAudioCodec:"opus",EncAudioFS:0,EncAudioCh:0,EncAudioBr:"0"},GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:navigator.platform,uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:XO(),uint32_device_type:0,str_os_verion:JO(),uint32_link_type:1,str_client_version:wR,uint32_net_type:QR[AR.getNetworkType()],ua:navigator.userAgent,version:""}}),aR(this,"joinAbortController",new AbortController),aR(this,"smallAbortCtrl"),aR(this,"smallEncoder"),e.tinyId&&(this.tinyId=e.tinyId,qK(!0)),this._log||(this._log=e.logger),this.bussinessInfo=e.bussinessInfo,e.encodedDataProcessingListener&&this.setEncodedDataProcessingListener(e.encodedDataProcessingListener)}replaceTrack(e){return cR(this,null,(function*(){}))}getLogger(){return this._log}postMessage(e,t){this.session&&(e?"string"==typeof e?this.session.postMessage({cmd:e,payload:t}):this.session.postMessage(e,t):this.session.postMessage(null))}sendMessage(e,t){return new Promise(((i,r)=>{"joined"!=this.state&&r("join room first");let o=new MessageChannel;this.postMessage({cmd:e,payload:t},[o.port1]),o.port2.onmessageerror=r,o.port2.onmessage=e=>{o.port2.close(),i(e.data)}}))}fromWorker(e,t){if("joined"!=this.state)throw"join room first";return i=>{var r;let o=new MessageChannel;o.port2.onmessage=e=>{e.data?i.next(e.data):i.complete()},o.port2.onmessageerror=e=>i.error(e),i.defer((()=>{o.port2.postMessage(null),o.port2.close()})),null==(r=this.session)||r.postMessage({cmd:e,payload:t},[o.port1])}}switchRole(e){return cR(this,null,(function*(){if(e!==this.role)return this._log.info("switchRole() => switch role to: ".concat(e)),"audience"==e&&this.unpublish(...this.localTracks),this.sendMessage("switchRole","audience"==e?21:20).then((t=>{this.role=e}))}))}join(e,t,i){return cR(this,null,(function*(){var r,o,n;let a=AR.getEnv(),s=OL(),c={isH264EncodeSupported:this.checkSystemResult.detail.isH264EncodeSupported,isVp8EncodeSupported:this.checkSystemResult.detail.isVp8EncodeSupported,frameWorkType:i,params:e,proxy_wt:null==(r=this.proxy_wt)?void 0:r.replace("https://",""),proxy_ws:null==(o=this.proxy_ws)?void 0:o.replace("wss://",""),proxy_cloud:null!=(n=this.scheduleResult.iceServers)&&n.length?this.scheduleResult.iceServers[0].urls:[],proxy_unified:this.proxy_unified,domains:this.scheduleResult.domains,env:a,osName:zO(),browserInfo:OL(),tinyId:this.tinyId,joinReq:{useStrRoomid:!!this.useStringRoomId,roomid:String(e.roomId||e.strRoomId),sdkAppID:String(e.sdkAppId),userSig:e.userSig,privMapEncrypt:e.privateMapKey||"",privMap:"",pstnBizType:0,role:"user",jsSdkVersion:wR,browserVersion:s.browserName+s.browserVersion,closeLocalMedia:!0,trtcscene:"live"===t?2:1,trtcrole:e.role,bussinessInfo:e.businessInfo||this.bussinessInfo||"",isAuxUser:0,autoSubscribe:this.autoReceiveAudio&&this.autoReceiveVideo,AbilityOption:this.AbilityOption}};yield GK.call(this,c),console.log(this),RK.playAudio((e=>this.postMessage({cmd:"setAudioWorkletPort"},[e]))),this.checkDestroy()}))}leave(){return cR(this,null,(function*(){this.remotePublishedUserMap.forEach((e=>{e.remoteAudioTrack.close(),e.remoteAuxiliaryTrack.close(),e.remoteVideoTrack.close()})),this.postMessage(null),this.remotePublishedUserMap.clear(),this.localTracks.forEach(((e,t)=>t.unpublish())),this.localTracks.clear()}))}getSignalInfo(){return{tinyId:this.tinyid,clientIp:this.clientip,signalIp:"",relayIp:this.relayip,relayInnerIp:"",relayPort:0}}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e<=0?this.audioVolumeEvalution.stop():this.audioVolumeEvalution.start(e,t)}getLocalAudioStats(){return this.sendMessage("getLocalAudioStats")}getLocalVideoStats(){return this.sendMessage("getLocalVideoStats")}afterJoin(){return cR(this,null,(function*(){ZU((e=>cR(this,null,(function*(){let t=new MessageChannel;t.port2.onmessage=i=>{i.data?e.next({data:i.data,port:t.port2}):e.complete()},t.port2.onmessageerror=t=>e.error(t),e.defer((()=>{t.port2.postMessage(null),t.port2.close()})),this.postMessage({cmd:"decodeAudio",payload:!!this.audioManager.decodePipeline[0]},[t.port1])}))),tF(MV(this,"left")),iB((e=>{let{data:t,port:i}=e,r=this.audioManager.decodePipeline[0]({frame:{data:t.data.buffer}});i.postMessage(eR(Zw({},t),{data:new Uint8Array(r.data)}),[r.data])})))}))}onWorkerEvent(e,t){switch("network-quality"!==e&&console.info(this.userId,"onWorkerEvent",e,JSON.stringify(t)),e){case eM.RECEIVED_PUBLISHED_USER_LIST:return void $O.emit(e,Zw({room:this},t));case"1":if(t.userId===this.userId)return;return void this.emit("peer-join",t);case"2":return void this.emit("peer-leave",t);case"3":let i=new Xq(this,t);return this.remotePublishedUserMap.set(t.userId,i),void this.emit("remote-published",i);case"5":{let e=t,i=this.remotePublishedUserMap.get(e);i&&(i.remoteVideoTrack.close(),i.remoteAuxiliaryTrack.close(),i.remoteAudioTrack.close(),this.remotePublishedUserMap.delete(e),this.emit("remote-unpublished",i))}return;case"banned":switch(t){case 8:return void this.emit("banned",{reason:"kick",message:""});case 2:case 6:case 4:return void this.emit("banned",{reason:"banned",message:""});case 7:case 5:return void this.emit("banned",{reason:"room_disband",message:""})}break;case"6":{let{prevMuteState:e,muteState:i,flag:r}=t,o=this.remotePublishedUserMap.get(i.userId);if(!o)return void this.emit("remote-publish-state-changed",t);o.flag=r}return $O.emit(eM.REMOTE_PUBLISH_STATE_CHANGED,Zw({room:this},t)),void this.emit("remote-publish-state-changed",t);case"7":return void(this.localPublishFlag!==t.flag&&(this.localPublishFlag=t.flag,this.emit("local-publish-flag-changed",t.flag)));case"network-quality":this.quality=Zw({},t);let{uplinkLoss:r,uplinkRTT:o,uplinkInfo:n,downlinkInfo:a,msg_down_stream_info:s}=t,c={str_sdk_version:wR,uint64_datetime:Date.now(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyid},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:QR[DC()]},msg_event_msg:rH(this.userId),str_acc_ip:this.relayip,str_client_ip:this.clientip,msg_up_stream_info:n,msg_down_stream_info:s};$O.emit(eM.HEARTBEAT_REPORT,{room:this,report:c}),this.emit("heartbeat-report",c),$O.emit(eM.NETWORK_QUALITY,{room:this,uplink:{rtt:o,loss:r},downlinks:a}),delete t.downlinkInfo;break;case"signal-connection-state-changed":return void $O.emit(eM.SIGNAL_CONNECTION_STATE_CHANGED,Zw({room:this},t))}this.emit(e,t)}sendStartPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("publishCdn",e)}sendStopPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("stopPublishCdn",e)}sendStartMixTranscode(e){return this.sendMessage("startMcuMix",e)}sendStopMixTranscode(e){return this.sendMessage("stopMcuMix",e)}publish(e){return cR(this,null,(function*(){if(1===(yield this.sendMessage("publish",e.mediaType).then((e=>0!==e.err?Promise.reject(e.err):e)),ix(e,e).add("mute",(()=>{this.postMessage("mute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,remove:!0})})).add("unmute",(()=>{this.postMessage("unmute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,add:!0})})),e.mediaType))yield RK.init(),JK.call(this,e);else yield ZK.call(this,e);e.muted&&this.postMessage("mute",{mediaType:e.mediaType,srctinyid:this.tinyid,userId:this.openid,remove:!0})}))}unpublish(e){return cR(this,null,(function*(){rx(e)}))}subscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),{userId:i,tinyId:r,streamType:o}=t[0],n=this.remotePublishedUserMap.get(i),a=Zw({},n.subscribeState),s=Object.assign(new tL,a);s.mediaType|=e,$O.emit(eM.SUBSCRIBE_START,{room:this,streamType:o,remotePublishedUser:n,subscribeState:s});let c=yield this.sendMessage("subscribe",{mediaType:s.mediaType,userId:i,srctinyid:r,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8,2].filter((e=>s.mediaType&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}});console.dir("subscribe",c),yield Promise.all(t.filter((e=>!e.isSubscribed)).map((e=>1===e.mediaType?KK.call(this,e):YK.call(this,e)))),$O.emit(eM.SUBSCRIBE_SUCCESS,{room:this,streamType:o,remotePublishedUser:n})}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return cR(this,null,(function*(){let e=0;for(let i of t)e|=i.mediaType;if(t.length){let{userId:i,streamType:r,tinyId:o}=t[0];yield this.sendMessage("unSubscribe",{mediaType:e,srctinyid:o,userId:i});for(let e of t)e.unsubscribe();$O.emit(eM.UNSUBSCRIBE_SUCCESS,{room:this,streamType:r,remotePublishedUser:this.remotePublishedUserMap.get(i)})}}))}enableSmall(e){return cR(this,null,(function*(){var t;if(e){if(this.videoManager.smallTrack){let e=this.videoManager.cameraTrack;this.smallEncoder=yield $K.call(this,e,{profile:e.small,type:3,trackType:"camera"});let t=new MediaStreamTrackProcessor({track:this.videoManager.smallTrack}).readable;this.smallEncoder.track=this.videoManager.smallTrack,this.smallEncoder.label="small",this.smallAbortCtrl=new AbortController,this.smallEncoder.start(t,this.smallAbortCtrl,this),this._log.info("push small")}}else null==(t=this.smallAbortCtrl)||t.abort("stop"),this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder)}))}changeType(e,t){let i=this.remotePublishedUserMap.get(t.userId);if(!i)return;let r=e?8:4;if(i.remoteVideoTrack.mediaType===r)return;let o={srctinyid:i.tinyId,mediaType:r,userId:t.userId,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8].filter((e=>r&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}};i.remoteVideoTrack.mediaType=o.mediaType,this.postMessage("changetype",o)}destroy(){this.isDestroyed||(super.destroy(),this.isDestroyed=!0,this.joinAbortController.abort("destroy"))}};nR([OU(iY.prototype.afterJoin),jP(["left",qP.INIT],"joined"),MU((e=>{let t=new Jq;return function(i,r,o){return cR(this,null,(function*(){let n=String(i.roomId||i.strRoomId);if(this.userId=i.userId,this.sdkAppId=i.sdkAppId,this.userSig=i.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=r,i.privateMapKey=i.privateMapKey||"",this.isJoined)throw new vR({code:_R.INVALID_OPERATION,message:vL({key:mL.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:n,sdkAppId:this.sdkAppId,room:this}))throw new vR({code:_R.INVALID_OPERATION,message:vL({key:mL.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:n}),this.role=21===i.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(n," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),$O.emit(eM.JOIN_START,{room:this,roomId:n,params:i});let a=AR.getEnv();a||(a=KR.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(ak.OLD_CLOUD_LADDER)?a=KR.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(ak.WEBRTC)&&(a=KR.WEBRTC))),ox.setConfig({env:a,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:n}),aM.checkSystemRequirementsInternal(o).then((e=>{this.checkSystemResult=e,Qq.call(this)}));try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!AR.getEnv()&&(yield this.schedule(i,o));let t=yield e.call(this,i,r,o);return this.roomId=n,this._joinedTimestamp=AR.performanceNow(),$O.emit(eM.JOIN_SUCCESS,{room:this}),30===o&&!i.component&&ox.uploadEvent({log:"stat-conv-".concat(Number(MO),"-").concat(location.hostname),userId:this.userId}),t}catch(hM){throw t.delete({room:this,roomId:n}),$O.emit(eM.JOIN_FAILED,{room:this,error:hM}),hM}}))}}))],iY.prototype,"join",1),nR([jP("joined","left",{ignoreError:!0}),MU((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return cR(this,null,(function*(){$O.emit(eM.LEAVE_START,{room:this}),yield e.call(this,...i),$O.emit(eM.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))}))],iY.prototype,"leave",1),nR([BU((e=>e.mediaType)),MU((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return cR(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||(i=i.filter((e=>e.outMediaTrack&&"ready"===e.state)),!i.length))return;$O.emit("61",{room:this});let t=e.apply(this,i);return Promise.all(i.map((e=>e.publish(this,t))))}))}))],iY.prototype,"publish",1),nR([BU((e=>e.mediaType)),MU((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let o=e.apply(this,i);return i.forEach((e=>e.unpublish())),o}))],iY.prototype,"unpublish",1),nR([BU((function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return t[0].userId})),MU((e=>function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];let o=e.apply(this,i);return i.forEach((e=>!e.isSubscribed&&e.subscribe(o))),o}))],iY.prototype,"subscribe",1);var rY=iY;
2
- /*! Bundled license information:
3
-
4
- jszip/dist/jszip.min.js:
5
- (*!
6
-
7
- JSZip v3.10.1 - A JavaScript class for generating and reading zip files
8
- <http://stuartk.com/jszip>
9
-
10
- (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
11
- Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
12
-
13
- JSZip uses the library pako released under the MIT license :
14
- https://github.com/nodeca/pako/blob/main/LICENSE
15
- *)
16
- */
17
- return Yq.frameWorkType=37,Yq.create=function(e){let t=Yq._create.call(this,rY,e);return t._use(Cj,null==e?void 0:e.assetsPath),null!=e&&e.assetsPath&&(vK.assetsPath=null==e?void 0:e.assetsPath),console.log("trtc wasm sdk:",wR,"created",vK),t},Object.assign(Yq.prototype,{_setCurrentSpeaker(e){let t=Yx();return null!=t&&t.setSinkId?t.setSinkId(e):Promise.reject("not support")},_enableVideoDecodeFallback(e,t){return cR(this,null,(function*(){return this.startPlugin(Cj.Name,{type:"webCodecs",renderer:"videoFrame",track:e,config:{codec:"avc1.640028",hardwareAcceleration:"prefer-software",optimizeForLatency:!0},fallback:"wasm"}),new Promise(((t,i)=>{ZU(MV(e,"decode-downgrade-state-changed"),$V((e=>"STARTED"===e.state)),eF(1),oB(1e4),tF(MV(e,qP.INIT)),iB(t,i))}))}))}}),kP(37),Yq}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e){return e&&e.Math===Math&&e},r=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof e&&e)||t("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i={},o=function(e){try{return!!e()}catch(t){return!0}},n=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,l=Function.prototype.call,c=s?l.bind(l):function(){return l.apply(l,arguments)},d={},u={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,p=h&&!u.call({1:2},1);d.f=p?function(e){var t=h(this,e);return!!t&&t.enumerable}:u;var m,f,_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},g=a,E=Function.prototype,v=E.call,y=g&&E.bind.bind(v,v),T=g?y:function(e){return function(){return v.apply(e,arguments)}},I=T,A=I({}.toString),S=I("".slice),R=function(e){return S(A(e),8,-1)},b=o,w=R,C=Object,D=T("".split),N=b((function(){return!C("z").propertyIsEnumerable(0)}))?function(e){return"String"===w(e)?D(e,""):C(e)}:C,k=function(e){return null==e},O=k,M=TypeError,L=function(e){if(O(e))throw new M("Can't call method on "+e);return e},P=N,x=L,U=function(e){return P(x(e))},V="object"==typeof document&&document.all,F=void 0===V&&void 0!==V?function(e){return"function"==typeof e||e===V}:function(e){return"function"==typeof e},B=F,H=function(e){return"object"==typeof e?null!==e:B(e)},W=r,G=F,j=function(e,t){return arguments.length<2?(r=W[e],G(r)?r:void 0):W[e]&&W[e][t];var r},z=T({}.isPrototypeOf),K=r.navigator,q=K&&K.userAgent,Y=q?String(q):"",J=r,X=Y,Q=J.process,$=J.Deno,Z=Q&&Q.versions||$&&$.version,ee=Z&&Z.v8;ee&&(f=(m=ee.split("."))[0]>0&&m[0]<4?1:+(m[0]+m[1])),!f&&X&&(!(m=X.match(/Edge\/(\d+)/))||m[1]>=74)&&(m=X.match(/Chrome\/(\d+)/))&&(f=+m[1]);var te=f,re=te,ie=o,oe=r.String,ne=!!Object.getOwnPropertySymbols&&!ie((function(){var e=Symbol("symbol detection");return!oe(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41})),ae=ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=j,le=F,ce=z,de=Object,ue=ae?function(e){return"symbol"==typeof e}:function(e){var t=se("Symbol");return le(t)&&ce(t.prototype,de(e))},he=String,pe=function(e){try{return he(e)}catch(t){return"Object"}},me=F,fe=pe,_e=TypeError,ge=function(e){if(me(e))return e;throw new _e(fe(e)+" is not a function")},Ee=ge,ve=k,ye=function(e,t){var r=e[t];return ve(r)?void 0:Ee(r)},Te=c,Ie=F,Ae=H,Se=TypeError,Re={exports:{}},be=r,we=Object.defineProperty,Ce=function(e,t){try{we(be,e,{value:t,configurable:!0,writable:!0})}catch(r){be[e]=t}return t},De=r,Ne=Ce,ke="__core-js_shared__",Oe=Re.exports=De[ke]||Ne(ke,{});(Oe.versions||(Oe.versions=[])).push({version:"3.40.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Me=Re.exports,Le=Me,Pe=function(e,t){return Le[e]||(Le[e]=t||{})},xe=L,Ue=Object,Ve=function(e){return Ue(xe(e))},Fe=Ve,Be=T({}.hasOwnProperty),He=Object.hasOwn||function(e,t){return Be(Fe(e),t)},We=T,Ge=0,je=Math.random(),ze=We(1..toString),Ke=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ze(++Ge+je,36)},qe=Pe,Ye=He,Je=Ke,Xe=ne,Qe=ae,$e=r.Symbol,Ze=qe("wks"),et=Qe?$e.for||$e:$e&&$e.withoutSetter||Je,tt=function(e){return Ye(Ze,e)||(Ze[e]=Xe&&Ye($e,e)?$e[e]:et("Symbol."+e)),Ze[e]},rt=c,it=H,ot=ue,nt=ye,at=function(e,t){var r,i;if("string"===t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;if(Ie(r=e.valueOf)&&!Ae(i=Te(r,e)))return i;if("string"!==t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;throw new Se("Can't convert object to primitive value")},st=TypeError,lt=tt("toPrimitive"),ct=function(e,t){if(!it(e)||ot(e))return e;var r,i=nt(e,lt);if(i){if(void 0===t&&(t="default"),r=rt(i,e,t),!it(r)||ot(r))return r;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),at(e,t)},dt=ct,ut=ue,ht=function(e){var t=dt(e,"string");return ut(t)?t:t+""},pt=H,mt=r.document,ft=pt(mt)&&pt(mt.createElement),_t=function(e){return ft?mt.createElement(e):{}},gt=_t,Et=!n&&!o((function(){return 7!==Object.defineProperty(gt("div"),"a",{get:function(){return 7}}).a})),vt=n,yt=c,Tt=d,It=_,At=U,St=ht,Rt=He,bt=Et,wt=Object.getOwnPropertyDescriptor;i.f=vt?wt:function(e,t){if(e=At(e),t=St(t),bt)try{return wt(e,t)}catch(r){}if(Rt(e,t))return It(!yt(Tt.f,e,t),e[t])};var Ct={},Dt=n&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Nt=H,kt=String,Ot=TypeError,Mt=function(e){if(Nt(e))return e;throw new Ot(kt(e)+" is not an object")},Lt=n,Pt=Et,xt=Dt,Ut=Mt,Vt=ht,Ft=TypeError,Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Wt="enumerable",Gt="configurable",jt="writable";Ct.f=Lt?xt?function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),"function"==typeof e&&"prototype"===t&&"value"in r&&jt in r&&!r[jt]){var i=Ht(e,t);i&&i[jt]&&(e[t]=r.value,r={configurable:Gt in r?r[Gt]:i[Gt],enumerable:Wt in r?r[Wt]:i[Wt],writable:!1})}return Bt(e,t,r)}:Bt:function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),Pt)try{return Bt(e,t,r)}catch(i){}if("get"in r||"set"in r)throw new Ft("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var zt=Ct,Kt=_,qt=n?function(e,t,r){return zt.f(e,t,Kt(1,r))}:function(e,t,r){return e[t]=r,e},Yt={exports:{}},Jt=n,Xt=He,Qt=Function.prototype,$t=Jt&&Object.getOwnPropertyDescriptor,Zt=Xt(Qt,"name"),er={EXISTS:Zt,PROPER:Zt&&"something"===function(){}.name,CONFIGURABLE:Zt&&(!Jt||Jt&&$t(Qt,"name").configurable)},tr=F,rr=Me,ir=T(Function.toString);tr(rr.inspectSource)||(rr.inspectSource=function(e){return ir(e)});var or,nr,ar,sr=rr.inspectSource,lr=F,cr=r.WeakMap,dr=lr(cr)&&/native code/.test(String(cr)),ur=Ke,hr=Pe("keys"),pr=function(e){return hr[e]||(hr[e]=ur(e))},mr={},fr=dr,_r=r,gr=H,Er=qt,vr=He,yr=Me,Tr=pr,Ir=mr,Ar="Object already initialized",Sr=_r.TypeError,Rr=_r.WeakMap;if(fr||yr.state){var br=yr.state||(yr.state=new Rr);br.get=br.get,br.has=br.has,br.set=br.set,or=function(e,t){if(br.has(e))throw new Sr(Ar);return t.facade=e,br.set(e,t),t},nr=function(e){return br.get(e)||{}},ar=function(e){return br.has(e)}}else{var wr=Tr("state");Ir[wr]=!0,or=function(e,t){if(vr(e,wr))throw new Sr(Ar);return t.facade=e,Er(e,wr,t),t},nr=function(e){return vr(e,wr)?e[wr]:{}},ar=function(e){return vr(e,wr)}}var Cr={set:or,get:nr,has:ar,enforce:function(e){return ar(e)?nr(e):or(e,{})},getterFor:function(e){return function(t){var r;if(!gr(t)||(r=nr(t)).type!==e)throw new Sr("Incompatible receiver, "+e+" required");return r}}},Dr=T,Nr=o,kr=F,Or=He,Mr=n,Lr=er.CONFIGURABLE,Pr=sr,xr=Cr.enforce,Ur=Cr.get,Vr=String,Fr=Object.defineProperty,Br=Dr("".slice),Hr=Dr("".replace),Wr=Dr([].join),Gr=Mr&&!Nr((function(){return 8!==Fr((function(){}),"length",{value:8}).length})),jr=String(String).split("String"),zr=Yt.exports=function(e,t,r){"Symbol("===Br(Vr(t),0,7)&&(t="["+Hr(Vr(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Or(e,"name")||Lr&&e.name!==t)&&(Mr?Fr(e,"name",{value:t,configurable:!0}):e.name=t),Gr&&r&&Or(r,"arity")&&e.length!==r.arity&&Fr(e,"length",{value:r.arity});try{r&&Or(r,"constructor")&&r.constructor?Mr&&Fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var i=xr(e);return Or(i,"source")||(i.source=Wr(jr,"string"==typeof t?t:"")),e};Function.prototype.toString=zr((function(){return kr(this)&&Ur(this).source||Pr(this)}),"toString");var Kr=Yt.exports,qr=F,Yr=Ct,Jr=Kr,Xr=Ce,Qr=function(e,t,r,i){i||(i={});var o=i.enumerable,n=void 0!==i.name?i.name:t;if(qr(r)&&Jr(r,n,i),i.global)o?e[t]=r:Xr(t,r);else{try{i.unsafe?e[t]&&(o=!0):delete e[t]}catch(a){}o?e[t]=r:Yr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},$r={},Zr=Math.ceil,ei=Math.floor,ti=Math.trunc||function(e){var t=+e;return(t>0?ei:Zr)(t)},ri=ti,ii=function(e){var t=+e;return t!=t||0===t?0:ri(t)},oi=ii,ni=Math.max,ai=Math.min,si=function(e,t){var r=oi(e);return r<0?ni(r+t,0):ai(r,t)},li=ii,ci=Math.min,di=function(e){var t=li(e);return t>0?ci(t,9007199254740991):0},ui=di,hi=function(e){return ui(e.length)},pi=U,mi=si,fi=hi,_i=function(e){return function(t,r,i){var o=pi(t),n=fi(o);if(0===n)return!e&&-1;var a,s=mi(i,n);if(e&&r!=r){for(;n>s;)if((a=o[s++])!=a)return!0}else for(;n>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},gi={includes:_i(!0),indexOf:_i(!1)},Ei=He,vi=U,yi=gi.indexOf,Ti=mr,Ii=T([].push),Ai=function(e,t){var r,i=vi(e),o=0,n=[];for(r in i)!Ei(Ti,r)&&Ei(i,r)&&Ii(n,r);for(;t.length>o;)Ei(i,r=t[o++])&&(~yi(n,r)||Ii(n,r));return n},Si=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ri=Ai,bi=Si.concat("length","prototype");$r.f=Object.getOwnPropertyNames||function(e){return Ri(e,bi)};var wi={};wi.f=Object.getOwnPropertySymbols;var Ci=j,Di=$r,Ni=wi,ki=Mt,Oi=T([].concat),Mi=Ci("Reflect","ownKeys")||function(e){var t=Di.f(ki(e)),r=Ni.f;return r?Oi(t,r(e)):t},Li=He,Pi=Mi,xi=i,Ui=Ct,Vi=function(e,t,r){for(var i=Pi(t),o=Ui.f,n=xi.f,a=0;a<i.length;a++){var s=i[a];Li(e,s)||r&&Li(r,s)||o(e,s,n(t,s))}},Fi=o,Bi=F,Hi=/#|\.prototype\./,Wi=function(e,t){var r=ji[Gi(e)];return r===Ki||r!==zi&&(Bi(t)?Fi(t):!!t)},Gi=Wi.normalize=function(e){return String(e).replace(Hi,".").toLowerCase()},ji=Wi.data={},zi=Wi.NATIVE="N",Ki=Wi.POLYFILL="P",qi=Wi,Yi=r,Ji=i.f,Xi=qt,Qi=Qr,$i=Ce,Zi=Vi,eo=qi,to=function(e,t){var r,i,o,n,a,s=e.target,l=e.global,c=e.stat;if(r=l?Yi:c?Yi[s]||$i(s,{}):Yi[s]&&Yi[s].prototype)for(i in t){if(n=t[i],o=e.dontCallGetSet?(a=Ji(r,i))&&a.value:r[i],!eo(l?i:s+(c?".":"#")+i,e.forced)&&void 0!==o){if(typeof n==typeof o)continue;Zi(n,o)}(e.sham||o&&o.sham)&&Xi(n,"sham",!0),Qi(r,i,n,e)}},ro={};ro[tt("toStringTag")]="z";var io="[object z]"===String(ro),oo=F,no=R,ao=tt("toStringTag"),so=Object,lo="Arguments"===no(function(){return arguments}()),co=io?no:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=so(e),ao))?r:lo?no(t):"Object"===(i=no(t))&&oo(t.callee)?"Arguments":i},uo=co,ho=String,po=function(e){if("Symbol"===uo(e))throw new TypeError("Cannot convert a Symbol value to a string");return ho(e)},mo=Kr,fo=Ct,_o=function(e,t,r){return r.get&&mo(r.get,t,{getter:!0}),r.set&&mo(r.set,t,{setter:!0}),fo.f(e,t,r)},go=to,Eo=n,vo=T,yo=He,To=F,Io=z,Ao=po,So=_o,Ro=Vi,bo=r.Symbol,wo=bo&&bo.prototype;if(Eo&&To(bo)&&(!("description"in wo)||void 0!==bo().description)){var Co={},Do=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Ao(arguments[0]),t=Io(wo,this)?new bo(e):void 0===e?bo():bo(e);return""===e&&(Co[t]=!0),t};Ro(Do,bo),Do.prototype=wo,wo.constructor=Do;var No="Symbol(description detection)"===String(bo("description detection")),ko=vo(wo.valueOf),Oo=vo(wo.toString),Mo=/^Symbol\((.*)\)[^)]+$/,Lo=vo("".replace),Po=vo("".slice);So(wo,"description",{configurable:!0,get:function(){var e=ko(this);if(yo(Co,e))return"";var t=Oo(e),r=No?Po(t,7,-1):Lo(t,Mo,"$1");return""===r?void 0:r}}),go({global:!0,constructor:!0,forced:!0},{Symbol:Do})}var xo=r,Uo={},Vo=tt;Uo.f=Vo;var Fo=xo,Bo=He,Ho=Uo,Wo=Ct.f,Go=function(e){var t=Fo.Symbol||(Fo.Symbol={});Bo(t,e)||Wo(t,e,{value:Ho.f(e)})};Go("asyncIterator");var jo=R,zo=Array.isArray||function(e){return"Array"===jo(e)},Ko=TypeError,qo=R,Yo=T,Jo=function(e){if("Function"===qo(e))return Yo(e)},Xo=ge,Qo=a,$o=Jo(Jo.bind),Zo=function(e,t){return Xo(e),void 0===t?e:Qo?$o(e,t):function(){return e.apply(t,arguments)}},en=zo,tn=hi,rn=function(e){if(e>9007199254740991)throw Ko("Maximum allowed index exceeded");return e},on=Zo,nn=function(e,t,r,i,o,n,a,s){for(var l,c,d=o,u=0,h=!!a&&on(a,s);u<i;)u in r&&(l=h?h(r[u],u,t):r[u],n>0&&en(l)?(c=tn(l),d=nn(e,t,l,c,d,n-1)-1):(rn(d+1),e[d]=l),d++),u++;return d},an=nn,sn=T,ln=o,cn=F,dn=co,un=sr,hn=function(){},pn=j("Reflect","construct"),mn=/^\s*(?:class|function)\b/,fn=sn(mn.exec),_n=!mn.test(hn),gn=function(e){if(!cn(e))return!1;try{return pn(hn,[],e),!0}catch(t){return!1}},En=function(e){if(!cn(e))return!1;switch(dn(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _n||!!fn(mn,un(e))}catch(t){return!0}};En.sham=!0;var vn=!pn||ln((function(){var e;return gn(gn.call)||!gn(Object)||!gn((function(){e=!0}))||e}))?En:gn,yn=zo,Tn=vn,In=H,An=tt("species"),Sn=Array,Rn=function(e){var t;return yn(e)&&(t=e.constructor,(Tn(t)&&(t===Sn||yn(t.prototype))||In(t)&&null===(t=t[An]))&&(t=void 0)),void 0===t?Sn:t},bn=function(e,t){return new(Rn(e))(0===t?0:t)},wn=an,Cn=Ve,Dn=hi,Nn=ii,kn=bn;to({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Cn(this),r=Dn(t),i=kn(t,0);return i.length=wn(i,t,t,r,0,void 0===e?1:Nn(e)),i}});var On={},Mn=Ai,Ln=Si,Pn=Object.keys||function(e){return Mn(e,Ln)},xn=n,Un=Dt,Vn=Ct,Fn=Mt,Bn=U,Hn=Pn;On.f=xn&&!Un?Object.defineProperties:function(e,t){Fn(e);for(var r,i=Bn(t),o=Hn(t),n=o.length,a=0;n>a;)Vn.f(e,r=o[a++],i[r]);return e};var Wn,Gn=j("document","documentElement"),jn=Mt,zn=On,Kn=Si,qn=mr,Yn=Gn,Jn=_t,Xn="prototype",Qn="script",$n=pr("IE_PROTO"),Zn=function(){},ea=function(e){return"<"+Qn+">"+e+"</"+Qn+">"},ta=function(e){e.write(ea("")),e.close();var t=e.parentWindow.Object;return e=null,t},ra=function(){try{Wn=new ActiveXObject("htmlfile")}catch(t){}ra="undefined"!=typeof document?document.domain&&Wn?ta(Wn):function(){var e,t=Jn("iframe"),r="java"+Qn+":";return t.style.display="none",Yn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(ea("document.F=Object")),e.close(),e.F}():ta(Wn);for(var e=Kn.length;e--;)delete ra[Xn][Kn[e]];return ra()};qn[$n]=!0;var ia=Object.create||function(e,t){var r;return null!==e?(Zn[Xn]=jn(e),r=new Zn,Zn[Xn]=null,r[$n]=e):r=ra(),void 0===t?r:zn.f(r,t)},oa=tt,na=ia,aa=Ct.f,sa=oa("unscopables"),la=Array.prototype;void 0===la[sa]&&aa(la,sa,{configurable:!0,value:na(null)});var ca=function(e){la[sa][e]=!0},da=gi.includes,ua=ca;to({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return da(this,e,arguments.length>1?arguments[1]:void 0)}}),ua("includes");var ha,pa,ma,fa={},_a=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),ga=He,Ea=F,va=Ve,ya=_a,Ta=pr("IE_PROTO"),Ia=Object,Aa=Ia.prototype,Sa=ya?Ia.getPrototypeOf:function(e){var t=va(e);if(ga(t,Ta))return t[Ta];var r=t.constructor;return Ea(r)&&t instanceof r?r.prototype:t instanceof Ia?Aa:null},Ra=o,ba=F,wa=H,Ca=Sa,Da=Qr,Na=tt("iterator"),ka=!1;[].keys&&("next"in(ma=[].keys())?(pa=Ca(Ca(ma)))!==Object.prototype&&(ha=pa):ka=!0);var Oa=!wa(ha)||Ra((function(){var e={};return ha[Na].call(e)!==e}));Oa&&(ha={}),ba(ha[Na])||Da(ha,Na,(function(){return this}));var Ma={IteratorPrototype:ha,BUGGY_SAFARI_ITERATORS:ka},La=Ct.f,Pa=He,xa=tt("toStringTag"),Ua=function(e,t,r){e&&!r&&(e=e.prototype),e&&!Pa(e,xa)&&La(e,xa,{configurable:!0,value:t})},Va=Ma.IteratorPrototype,Fa=ia,Ba=_,Ha=Ua,Wa=fa,Ga=function(){return this},ja=function(e,t,r,i){var o=t+" Iterator";return e.prototype=Fa(Va,{next:Ba(+!i,r)}),Ha(e,o,!1),Wa[o]=Ga,e},za=T,Ka=ge,qa=H,Ya=function(e){return qa(e)||null===e},Ja=String,Xa=TypeError,Qa=function(e,t,r){try{return za(Ka(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},$a=H,Za=L,es=function(e){if(Ya(e))return e;throw new Xa("Can't set "+Ja(e)+" as a prototype")},ts=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=Qa(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return Za(r),es(i),$a(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0),rs=to,is=c,os=F,ns=ja,as=Sa,ss=ts,ls=Ua,cs=qt,ds=Qr,us=fa,hs=er.PROPER,ps=er.CONFIGURABLE,ms=Ma.IteratorPrototype,fs=Ma.BUGGY_SAFARI_ITERATORS,_s=tt("iterator"),gs="keys",Es="values",vs="entries",ys=function(){return this},Ts=function(e,t,r,i,o,n,a){ns(r,t,i);var s,l,c,d=function(e){if(e===o&&f)return f;if(!fs&&e&&e in p)return p[e];switch(e){case gs:case Es:case vs:return function(){return new r(this,e)}}return function(){return new r(this)}},u=t+" Iterator",h=!1,p=e.prototype,m=p[_s]||p["@@iterator"]||o&&p[o],f=!fs&&m||d(o),_="Array"===t&&p.entries||m;if(_&&(s=as(_.call(new e)))!==Object.prototype&&s.next&&(as(s)!==ms&&(ss?ss(s,ms):os(s[_s])||ds(s,_s,ys)),ls(s,u,!0)),hs&&o===Es&&m&&m.name!==Es&&(ps?cs(p,"name",Es):(h=!0,f=function(){return is(m,this)})),o)if(l={values:d(Es),keys:n?f:d(gs),entries:d(vs)},a)for(c in l)(fs||h||!(c in p))&&ds(p,c,l[c]);else rs({target:t,proto:!0,forced:fs||h},l);return p[_s]!==f&&ds(p,_s,f,{name:o}),us[t]=f,l},Is=function(e,t){return{value:e,done:t}},As=U,Ss=ca,Rs=fa,bs=Cr,ws=Ct.f,Cs=Ts,Ds=Is,Ns=n,ks="Array Iterator",Os=bs.set,Ms=bs.getterFor(ks),Ls=Cs(Array,"Array",(function(e,t){Os(this,{type:ks,target:As(e),index:0,kind:t})}),(function(){var e=Ms(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Ds(void 0,!0);switch(e.kind){case"keys":return Ds(r,!1);case"values":return Ds(t[r],!1)}return Ds([r,t[r]],!1)}),"values"),Ps=Rs.Arguments=Rs.Array;if(Ss("keys"),Ss("values"),Ss("entries"),Ns&&"values"!==Ps.name)try{ws(Ps,"name",{value:"values"})}catch(UK){}var xs=ge,Us=Ve,Vs=N,Fs=hi,Bs=TypeError,Hs="Reduce of empty array with no initial value",Ws=function(e){return function(t,r,i,o){var n=Us(t),a=Vs(n),s=Fs(n);if(xs(r),0===s&&i<2)throw new Bs(Hs);var l=e?s-1:0,c=e?-1:1;if(i<2)for(;;){if(l in a){o=a[l],l+=c;break}if(l+=c,e?l<0:s<=l)throw new Bs(Hs)}for(;e?l>=0:s>l;l+=c)l in a&&(o=r(o,a[l],l,n));return o}},Gs={left:Ws(!1),right:Ws(!0)},js=o,zs=function(e,t){var r=[][e];return!!r&&js((function(){r.call(null,t||function(){return 1},1)}))},Ks=r,qs=Y,Ys=R,Js=function(e){return qs.slice(0,e.length)===e},Xs=Js("Bun/")?"BUN":Js("Cloudflare-Workers")?"CLOUDFLARE":Js("Deno/")?"DENO":Js("Node.js/")?"NODE":Ks.Bun&&"string"==typeof Bun.version?"BUN":Ks.Deno&&"object"==typeof Deno.version?"DENO":"process"===Ys(Ks.process)?"NODE":Ks.window&&Ks.document?"BROWSER":"REST",Qs="NODE"===Xs,$s=Gs.left;to({target:"Array",proto:!0,forced:!Qs&&te>79&&te<83||!zs("reduce")},{reduce:function(e){var t=arguments.length;return $s(this,e,t,t>1?arguments[1]:void 0)}});var Zs=Gs.right;to({target:"Array",proto:!0,forced:!Qs&&te>79&&te<83||!zs("reduceRight")},{reduceRight:function(e){return Zs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var el=to,tl=zo,rl=T([].reverse),il=[1,2];el({target:"Array",proto:!0,forced:String(il)===String(il.reverse())},{reverse:function(){return tl(this)&&(this.length=this.length),rl(this)}});var ol=pe,nl=TypeError,al=T([].slice),sl=al,ll=Math.floor,cl=function(e,t){var r=e.length;if(r<8)for(var i,o,n=1;n<r;){for(o=n,i=e[n];o&&t(e[o-1],i)>0;)e[o]=e[--o];o!==n++&&(e[o]=i)}else for(var a=ll(r/2),s=cl(sl(e,0,a),t),l=cl(sl(e,a),t),c=s.length,d=l.length,u=0,h=0;u<c||h<d;)e[u+h]=u<c&&h<d?t(s[u],l[h])<=0?s[u++]:l[h++]:u<c?s[u++]:l[h++];return e},dl=cl,ul=Y.match(/firefox\/(\d+)/i),hl=!!ul&&+ul[1],pl=/MSIE|Trident/.test(Y),ml=Y.match(/AppleWebKit\/(\d+)\./),fl=!!ml&&+ml[1],_l=to,gl=T,El=ge,vl=Ve,yl=hi,Tl=function(e,t){if(!delete e[t])throw new nl("Cannot delete property "+ol(t)+" of "+ol(e))},Il=po,Al=o,Sl=dl,Rl=zs,bl=hl,wl=pl,Cl=te,Dl=fl,Nl=[],kl=gl(Nl.sort),Ol=gl(Nl.push),Ml=Al((function(){Nl.sort(void 0)})),Ll=Al((function(){Nl.sort(null)})),Pl=Rl("sort"),xl=!Al((function(){if(Cl)return Cl<70;if(!(bl&&bl>3)){if(wl)return!0;if(Dl)return Dl<603;var e,t,r,i,o="";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(i=0;i<47;i++)Nl.push({k:t+i,v:r})}for(Nl.sort((function(e,t){return t.v-e.v})),i=0;i<Nl.length;i++)t=Nl[i].k.charAt(0),o.charAt(o.length-1)!==t&&(o+=t);return"DGBEFHACIJK"!==o}}));_l({target:"Array",proto:!0,forced:Ml||!Ll||!Pl||!xl},{sort:function(e){void 0!==e&&El(e);var t=vl(this);if(xl)return void 0===e?kl(t):kl(t,e);var r,i,o=[],n=yl(t);for(i=0;i<n;i++)i in t&&Ol(o,t[i]);for(Sl(o,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Il(t)>Il(r)?1:-1}}(e)),r=yl(o),i=0;i<r;)t[i]=o[i++];for(;i<n;)Tl(t,i++);return t}}),ca("flat");var Ul="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Vl=Qr,Fl=function(e,t,r){for(var i in t)Vl(e,i,t[i],r);return e},Bl=z,Hl=TypeError,Wl=function(e,t){if(Bl(t,e))return e;throw new Hl("Incorrect invocation")},Gl=ii,jl=di,zl=RangeError,Kl=function(e){if(void 0===e)return 0;var t=Gl(e),r=jl(t);if(t!==r)throw new zl("Wrong length or index");return r},ql=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},Yl=4503599627370496,Jl=ql,Xl=function(e){return e+Yl-Yl},Ql=Math.abs,$l=function(e,t,r,i){var o=+e,n=Ql(o),a=Jl(o);if(n<i)return a*Xl(n/i/t)*i*t;var s=(1+t/2220446049250313e-31)*n,l=s-(s-n);return l>r||l!=l?Infinity*a:a*l},Zl=Math.fround||function(e){return $l(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},ec=Array,tc=Math.abs,rc=Math.pow,ic=Math.floor,oc=Math.log,nc=Math.LN2,ac={pack:function(e,t,r){var i,o,n,a=ec(r),s=8*r-t-1,l=(1<<s)-1,c=l>>1,d=23===t?rc(2,-24)-rc(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=tc(e))!=e||Infinity===e?(o=e!=e?1:0,i=l):(i=ic(oc(e)/nc),e*(n=rc(2,-i))<1&&(i--,n*=2),(e+=i+c>=1?d/n:d*rc(2,1-c))*n>=2&&(i++,n/=2),i+c>=l?(o=0,i=l):i+c>=1?(o=(e*n-1)*rc(2,t),i+=c):(o=e*rc(2,c-1)*rc(2,t),i=0));t>=8;)a[h++]=255&o,o/=256,t-=8;for(i=i<<t|o,s+=t;s>0;)a[h++]=255&i,i/=256,s-=8;return a[h-1]|=128*u,a},unpack:function(e,t){var r,i=e.length,o=8*i-t-1,n=(1<<o)-1,a=n>>1,s=o-7,l=i-1,c=e[l--],d=127&c;for(c>>=7;s>0;)d=256*d+e[l--],s-=8;for(r=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)r=256*r+e[l--],s-=8;if(0===d)d=1-a;else{if(d===n)return r?NaN:c?-Infinity:Infinity;r+=rc(2,t),d-=a}return(c?-1:1)*r*rc(2,d-t)}},sc=Ve,lc=si,cc=hi,dc=function(e){for(var t=sc(this),r=cc(t),i=arguments.length,o=lc(i>1?arguments[1]:void 0,r),n=i>2?arguments[2]:void 0,a=void 0===n?r:lc(n,r);a>o;)t[o++]=e;return t},uc=F,hc=H,pc=ts,mc=function(e,t,r){var i,o;return pc&&uc(i=t.constructor)&&i!==r&&hc(o=i.prototype)&&o!==r.prototype&&pc(e,o),e},fc=r,_c=T,gc=n,Ec=Ul,vc=qt,yc=_o,Tc=Fl,Ic=o,Ac=Wl,Sc=ii,Rc=di,bc=Kl,wc=Zl,Cc=ac,Dc=Sa,Nc=ts,kc=dc,Oc=al,Mc=mc,Lc=Vi,Pc=Ua,xc=Cr,Uc=er.PROPER,Vc=er.CONFIGURABLE,Fc="ArrayBuffer",Bc="DataView",Hc="prototype",Wc="Wrong index",Gc=xc.getterFor(Fc),jc=xc.getterFor(Bc),zc=xc.set,Kc=fc[Fc],qc=Kc,Yc=qc&&qc[Hc],Jc=fc[Bc],Xc=Jc&&Jc[Hc],Qc=Object.prototype,$c=fc.Array,Zc=fc.RangeError,ed=_c(kc),td=_c([].reverse),rd=Cc.pack,id=Cc.unpack,od=function(e){return[255&e]},nd=function(e){return[255&e,e>>8&255]},ad=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},sd=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},ld=function(e){return rd(wc(e),23,4)},cd=function(e){return rd(e,52,8)},dd=function(e,t,r){yc(e[Hc],t,{configurable:!0,get:function(){return r(this)[t]}})},ud=function(e,t,r,i){var o=jc(e),n=bc(r),a=!!i;if(n+t>o.byteLength)throw new Zc(Wc);var s=o.bytes,l=n+o.byteOffset,c=Oc(s,l,l+t);return a?c:td(c)},hd=function(e,t,r,i,o,n){var a=jc(e),s=bc(r),l=i(+o),c=!!n;if(s+t>a.byteLength)throw new Zc(Wc);for(var d=a.bytes,u=s+a.byteOffset,h=0;h<t;h++)d[u+h]=l[c?h:t-h-1]};if(Ec){var pd=Uc&&Kc.name!==Fc;Ic((function(){Kc(1)}))&&Ic((function(){new Kc(-1)}))&&!Ic((function(){return new Kc,new Kc(1.5),new Kc(NaN),1!==Kc.length||pd&&!Vc}))?pd&&Vc&&vc(Kc,"name",Fc):((qc=function(e){return Ac(this,Yc),Mc(new Kc(bc(e)),this,qc)})[Hc]=Yc,Yc.constructor=qc,Lc(qc,Kc)),Nc&&Dc(Xc)!==Qc&&Nc(Xc,Qc);var md=new Jc(new qc(2)),fd=_c(Xc.setInt8);md.setInt8(0,2147483648),md.setInt8(1,2147483649),!md.getInt8(0)&&md.getInt8(1)||Tc(Xc,{setInt8:function(e,t){fd(this,e,t<<24>>24)},setUint8:function(e,t){fd(this,e,t<<24>>24)}},{unsafe:!0})}else Yc=(qc=function(e){Ac(this,Yc);var t=bc(e);zc(this,{type:Fc,bytes:ed($c(t),0),byteLength:t}),gc||(this.byteLength=t,this.detached=!1)})[Hc],Xc=(Jc=function(e,t,r){Ac(this,Xc),Ac(e,Yc);var i=Gc(e),o=i.byteLength,n=Sc(t);if(n<0||n>o)throw new Zc("Wrong offset");if(n+(r=void 0===r?o-n:Rc(r))>o)throw new Zc("Wrong length");zc(this,{type:Bc,buffer:e,byteLength:r,byteOffset:n,bytes:i.bytes}),gc||(this.buffer=e,this.byteLength=r,this.byteOffset=n)})[Hc],gc&&(dd(qc,"byteLength",Gc),dd(Jc,"buffer",jc),dd(Jc,"byteLength",jc),dd(Jc,"byteOffset",jc)),Tc(Xc,{getInt8:function(e){return ud(this,1,e)[0]<<24>>24},getUint8:function(e){return ud(this,1,e)[0]},getInt16:function(e){var t=ud(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ud(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return sd(ud(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return sd(ud(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return id(ud(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return id(ud(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){hd(this,1,e,od,t)},setUint8:function(e,t){hd(this,1,e,od,t)},setInt16:function(e,t){hd(this,2,e,nd,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){hd(this,2,e,nd,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){hd(this,4,e,ad,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){hd(this,4,e,ad,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){hd(this,4,e,ld,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){hd(this,8,e,cd,t,arguments.length>2&&arguments[2])}});Pc(qc,Fc),Pc(Jc,Bc);var _d={ArrayBuffer:qc,DataView:Jc},gd=j,Ed=_o,vd=n,yd=tt("species"),Td=function(e){var t=gd(e);vd&&t&&!t[yd]&&Ed(t,yd,{configurable:!0,get:function(){return this}})},Id=Td,Ad="ArrayBuffer",Sd=_d[Ad];to({global:!0,constructor:!0,forced:r[Ad]!==Sd},{ArrayBuffer:Sd}),Id(Ad);var Rd=to,bd=Jo,wd=o,Cd=Mt,Dd=si,Nd=di,kd=_d.ArrayBuffer,Od=_d.DataView,Md=Od.prototype,Ld=bd(kd.prototype.slice),Pd=bd(Md.getUint8),xd=bd(Md.setUint8);Rd({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wd((function(){return!new kd(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Ld&&void 0===t)return Ld(Cd(this),e);for(var r=Cd(this).byteLength,i=Dd(e,r),o=Dd(void 0===t?r:t,r),n=new kd(Nd(o-i)),a=new Od(this),s=new Od(n),l=0;i<o;)xd(s,l++,Pd(a,i++));return n}});var Ud,Vd,Fd,Bd,Hd=vn,Wd=pe,Gd=TypeError,jd=function(e){if(Hd(e))return e;throw new Gd(Wd(e)+" is not a constructor")},zd=Mt,Kd=jd,qd=k,Yd=tt("species"),Jd=function(e,t){var r,i=zd(e).constructor;return void 0===i||qd(r=zd(i)[Yd])?t:Kd(r)},Xd=a,Qd=Function.prototype,$d=Qd.apply,Zd=Qd.call,eu="object"==typeof Reflect&&Reflect.apply||(Xd?Zd.bind($d):function(){return Zd.apply($d,arguments)}),tu=TypeError,ru=function(e,t){if(e<t)throw new tu("Not enough arguments");return e},iu=/(?:ipad|iphone|ipod).*applewebkit/i.test(Y),ou=r,nu=eu,au=Zo,su=F,lu=He,cu=o,du=Gn,uu=al,hu=_t,pu=ru,mu=iu,fu=Qs,_u=ou.setImmediate,gu=ou.clearImmediate,Eu=ou.process,vu=ou.Dispatch,yu=ou.Function,Tu=ou.MessageChannel,Iu=ou.String,Au=0,Su={},Ru="onreadystatechange";cu((function(){Ud=ou.location}));var bu=function(e){if(lu(Su,e)){var t=Su[e];delete Su[e],t()}},wu=function(e){return function(){bu(e)}},Cu=function(e){bu(e.data)},Du=function(e){ou.postMessage(Iu(e),Ud.protocol+"//"+Ud.host)};_u&&gu||(_u=function(e){pu(arguments.length,1);var t=su(e)?e:yu(e),r=uu(arguments,1);return Su[++Au]=function(){nu(t,void 0,r)},Vd(Au),Au},gu=function(e){delete Su[e]},fu?Vd=function(e){Eu.nextTick(wu(e))}:vu&&vu.now?Vd=function(e){vu.now(wu(e))}:Tu&&!mu?(Bd=(Fd=new Tu).port2,Fd.port1.onmessage=Cu,Vd=au(Bd.postMessage,Bd)):ou.addEventListener&&su(ou.postMessage)&&!ou.importScripts&&Ud&&"file:"!==Ud.protocol&&!cu(Du)?(Vd=Du,ou.addEventListener("message",Cu,!1)):Vd=Ru in hu("script")?function(e){du.appendChild(hu("script"))[Ru]=function(){du.removeChild(this),bu(e)}}:function(e){setTimeout(wu(e),0)});var Nu={set:_u,clear:gu},ku=r,Ou=n,Mu=Object.getOwnPropertyDescriptor,Lu=function(e){if(!Ou)return ku[e];var t=Mu(ku,e);return t&&t.value},Pu=function(){this.head=null,this.tail=null};Pu.prototype={add:function(e){var t={item:e,next:null},r=this.tail;r?r.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var xu,Uu,Vu,Fu,Bu,Hu=Pu,Wu=/ipad|iphone|ipod/i.test(Y)&&"undefined"!=typeof Pebble,Gu=/web0s(?!.*chrome)/i.test(Y),ju=r,zu=Lu,Ku=Zo,qu=Nu.set,Yu=Hu,Ju=iu,Xu=Wu,Qu=Gu,$u=Qs,Zu=ju.MutationObserver||ju.WebKitMutationObserver,eh=ju.document,th=ju.process,rh=ju.Promise,ih=zu("queueMicrotask");if(!ih){var oh=new Yu,nh=function(){var e,t;for($u&&(e=th.domain)&&e.exit();t=oh.get();)try{t()}catch(UK){throw oh.head&&xu(),UK}e&&e.enter()};Ju||$u||Qu||!Zu||!eh?!Xu&&rh&&rh.resolve?((Fu=rh.resolve(void 0)).constructor=rh,Bu=Ku(Fu.then,Fu),xu=function(){Bu(nh)}):$u?xu=function(){th.nextTick(nh)}:(qu=Ku(qu,ju),xu=function(){qu(nh)}):(Uu=!0,Vu=eh.createTextNode(""),new Zu(nh).observe(Vu,{characterData:!0}),xu=function(){Vu.data=Uu=!Uu}),ih=function(e){oh.head||xu(),oh.add(e)}}var ah=ih,sh=function(e){try{return{error:!1,value:e()}}catch(UK){return{error:!0,value:UK}}},lh=r.Promise,ch=r,dh=lh,uh=F,hh=qi,ph=sr,mh=tt,fh=Xs,_h=te;dh&&dh.prototype;var gh=mh("species"),Eh=!1,vh=uh(ch.PromiseRejectionEvent),yh=hh("Promise",(function(){var e=ph(dh),t=e!==String(dh);if(!t&&66===_h)return!0;if(!_h||_h<51||!/native code/.test(e)){var r=new dh((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[gh]=i,!(Eh=r.then((function(){}))instanceof i))return!0}return!(t||"BROWSER"!==fh&&"DENO"!==fh||vh)})),Th={CONSTRUCTOR:yh,REJECTION_EVENT:vh,SUBCLASSING:Eh},Ih={},Ah=ge,Sh=TypeError,Rh=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw new Sh("Bad Promise constructor");t=e,r=i})),this.resolve=Ah(t),this.reject=Ah(r)};Ih.f=function(e){return new Rh(e)};var bh,wh,Ch,Dh=to,Nh=Qs,kh=r,Oh=c,Mh=Qr,Lh=ts,Ph=Ua,xh=Td,Uh=ge,Vh=F,Fh=H,Bh=Wl,Hh=Jd,Wh=Nu.set,Gh=ah,jh=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(UK){}},zh=sh,Kh=Hu,qh=Cr,Yh=lh,Jh=Ih,Xh="Promise",Qh=Th.CONSTRUCTOR,$h=Th.REJECTION_EVENT,Zh=Th.SUBCLASSING,ep=qh.getterFor(Xh),tp=qh.set,rp=Yh&&Yh.prototype,ip=Yh,op=rp,np=kh.TypeError,ap=kh.document,sp=kh.process,lp=Jh.f,cp=lp,dp=!!(ap&&ap.createEvent&&kh.dispatchEvent),up="unhandledrejection",hp=function(e){var t;return!(!Fh(e)||!Vh(t=e.then))&&t},pp=function(e,t){var r,i,o,n=t.value,a=1===t.state,s=a?e.ok:e.fail,l=e.resolve,c=e.reject,d=e.domain;try{s?(a||(2===t.rejection&&Ep(t),t.rejection=1),!0===s?r=n:(d&&d.enter(),r=s(n),d&&(d.exit(),o=!0)),r===e.promise?c(new np("Promise-chain cycle")):(i=hp(r))?Oh(i,r,l,c):l(r)):c(n)}catch(UK){d&&!o&&d.exit(),c(UK)}},mp=function(e,t){e.notified||(e.notified=!0,Gh((function(){for(var r,i=e.reactions;r=i.get();)pp(r,e);e.notified=!1,t&&!e.rejection&&_p(e)})))},fp=function(e,t,r){var i,o;dp?((i=ap.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),kh.dispatchEvent(i)):i={promise:t,reason:r},!$h&&(o=kh["on"+e])?o(i):e===up&&jh("Unhandled promise rejection",r)},_p=function(e){Oh(Wh,kh,(function(){var t,r=e.facade,i=e.value;if(gp(e)&&(t=zh((function(){Nh?sp.emit("unhandledRejection",i,r):fp(up,r,i)})),e.rejection=Nh||gp(e)?2:1,t.error))throw t.value}))},gp=function(e){return 1!==e.rejection&&!e.parent},Ep=function(e){Oh(Wh,kh,(function(){var t=e.facade;Nh?sp.emit("rejectionHandled",t):fp("rejectionhandled",t,e.value)}))},vp=function(e,t,r){return function(i){e(t,i,r)}},yp=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,mp(e,!0))},Tp=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new np("Promise can't be resolved itself");var i=hp(t);i?Gh((function(){var r={done:!1};try{Oh(i,t,vp(Tp,r,e),vp(yp,r,e))}catch(UK){yp(r,UK,e)}})):(e.value=t,e.state=1,mp(e,!1))}catch(UK){yp({done:!1},UK,e)}}};if(Qh&&(op=(ip=function(e){Bh(this,op),Uh(e),Oh(bh,this);var t=ep(this);try{e(vp(Tp,t),vp(yp,t))}catch(UK){yp(t,UK)}}).prototype,(bh=function(e){tp(this,{type:Xh,done:!1,notified:!1,parent:!1,reactions:new Kh,rejection:!1,state:0,value:null})}).prototype=Mh(op,"then",(function(e,t){var r=ep(this),i=lp(Hh(this,ip));return r.parent=!0,i.ok=!Vh(e)||e,i.fail=Vh(t)&&t,i.domain=Nh?sp.domain:void 0,0===r.state?r.reactions.add(i):Gh((function(){pp(i,r)})),i.promise})),wh=function(){var e=new bh,t=ep(e);this.promise=e,this.resolve=vp(Tp,t),this.reject=vp(yp,t)},Jh.f=lp=function(e){return e===ip||undefined===e?new wh(e):cp(e)},Vh(Yh)&&rp!==Object.prototype)){Ch=rp.then,Zh||Mh(rp,"then",(function(e,t){var r=this;return new ip((function(e,t){Oh(Ch,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete rp.constructor}catch(UK){}Lh&&Lh(rp,op)}Dh({global:!0,constructor:!0,wrap:!0,forced:Qh},{Promise:ip}),Ph(ip,Xh,!1),xh(Xh);var Ip=fa,Ap=tt("iterator"),Sp=Array.prototype,Rp=function(e){return void 0!==e&&(Ip.Array===e||Sp[Ap]===e)},bp=co,wp=ye,Cp=k,Dp=fa,Np=tt("iterator"),kp=function(e){if(!Cp(e))return wp(e,Np)||wp(e,"@@iterator")||Dp[bp(e)]},Op=c,Mp=ge,Lp=Mt,Pp=pe,xp=kp,Up=TypeError,Vp=function(e,t){var r=arguments.length<2?xp(e):t;if(Mp(r))return Lp(Op(r,e));throw new Up(Pp(e)+" is not iterable")},Fp=c,Bp=Mt,Hp=ye,Wp=function(e,t,r){var i,o;Bp(e);try{if(!(i=Hp(e,"return"))){if("throw"===t)throw r;return r}i=Fp(i,e)}catch(UK){o=!0,i=UK}if("throw"===t)throw r;if(o)throw i;return Bp(i),r},Gp=Zo,jp=c,zp=Mt,Kp=pe,qp=Rp,Yp=hi,Jp=z,Xp=Vp,Qp=kp,$p=Wp,Zp=TypeError,em=function(e,t){this.stopped=e,this.result=t},tm=em.prototype,rm=function(e,t,r){var i,o,n,a,s,l,c,d=r&&r.that,u=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),m=!(!r||!r.INTERRUPTED),f=Gp(t,d),_=function(e){return i&&$p(i,"normal",e),new em(!0,e)},g=function(e){return u?(zp(e),m?f(e[0],e[1],_):f(e[0],e[1])):m?f(e,_):f(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(o=Qp(e)))throw new Zp(Kp(e)+" is not iterable");if(qp(o)){for(n=0,a=Yp(e);a>n;n++)if((s=g(e[n]))&&Jp(tm,s))return s;return new em(!1)}i=Xp(e,o)}for(l=h?e.next:i.next;!(c=jp(l,i)).done;){try{s=g(c.value)}catch(UK){$p(i,"throw",UK)}if("object"==typeof s&&s&&Jp(tm,s))return s}return new em(!1)},im=tt("iterator"),om=!1;try{var nm=0,am={next:function(){return{done:!!nm++}},return:function(){om=!0}};am[im]=function(){return this},Array.from(am,(function(){throw 2}))}catch(UK){}var sm=function(e,t){try{if(!t&&!om)return!1}catch(UK){return!1}var r=!1;try{var i={};i[im]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(UK){}return r},lm=lh,cm=Th.CONSTRUCTOR||!sm((function(e){lm.all(e).then(void 0,(function(){}))})),dm=c,um=ge,hm=Ih,pm=sh,mm=rm;to({target:"Promise",stat:!0,forced:cm},{all:function(e){var t=this,r=hm.f(t),i=r.resolve,o=r.reject,n=pm((function(){var r=um(t.resolve),n=[],a=0,s=1;mm(e,(function(e){var l=a++,c=!1;s++,dm(r,t,e).then((function(e){c||(c=!0,n[l]=e,--s||i(n))}),o)})),--s||i(n)}));return n.error&&o(n.value),r.promise}});var fm=to,_m=Th.CONSTRUCTOR,gm=lh,Em=j,vm=F,ym=Qr,Tm=gm&&gm.prototype;if(fm({target:"Promise",proto:!0,forced:_m,real:!0},{catch:function(e){return this.then(void 0,e)}}),vm(gm)){var Im=Em("Promise").prototype.catch;Tm.catch!==Im&&ym(Tm,"catch",Im,{unsafe:!0})}var Am=c,Sm=ge,Rm=Ih,bm=sh,wm=rm;to({target:"Promise",stat:!0,forced:cm},{race:function(e){var t=this,r=Rm.f(t),i=r.reject,o=bm((function(){var o=Sm(t.resolve);wm(e,(function(e){Am(o,t,e).then(r.resolve,i)}))}));return o.error&&i(o.value),r.promise}});var Cm=Ih;to({target:"Promise",stat:!0,forced:Th.CONSTRUCTOR},{reject:function(e){var t=Cm.f(this);return(0,t.reject)(e),t.promise}});var Dm=Mt,Nm=H,km=Ih,Om=function(e,t){if(Dm(e),Nm(t)&&t.constructor===e)return t;var r=km.f(e);return(0,r.resolve)(t),r.promise},Mm=to,Lm=Th.CONSTRUCTOR,Pm=Om;j("Promise"),Mm({target:"Promise",stat:!0,forced:Lm},{resolve:function(e){return Pm(this,e)}});var xm=to,Um=lh,Vm=o,Fm=j,Bm=F,Hm=Jd,Wm=Om,Gm=Qr,jm=Um&&Um.prototype;if(xm({target:"Promise",proto:!0,real:!0,forced:!!Um&&Vm((function(){jm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hm(this,Fm("Promise")),r=Bm(e);return this.then(r?function(r){return Wm(t,e()).then((function(){return r}))}:e,r?function(r){return Wm(t,e()).then((function(){throw r}))}:e)}}),Bm(Um)){var zm=Fm("Promise").prototype.finally;jm.finally!==zm&&Gm(jm,"finally",zm,{unsafe:!0})}var Km=H,qm=R,Ym=tt("match"),Jm=function(e){var t;return Km(e)&&(void 0!==(t=e[Ym])?!!t:"RegExp"===qm(e))},Xm=Mt,Qm=function(){var e=Xm(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},$m=c,Zm=He,ef=z,tf=Qm,rf=RegExp.prototype,of=function(e){var t=e.flags;return void 0!==t||"flags"in rf||Zm(e,"flags")||!ef(rf,e)?t:$m(tf,e)},nf=o,af=r.RegExp,sf=nf((function(){var e=af("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),lf=sf||nf((function(){return!af("a","y").sticky})),cf=sf||nf((function(){var e=af("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),df={BROKEN_CARET:cf,MISSED_STICKY:lf,UNSUPPORTED_Y:sf},uf=Ct.f,hf=o,pf=r.RegExp,mf=hf((function(){var e=pf(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),ff=o,_f=r.RegExp,gf=ff((function(){var e=_f("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),Ef=n,vf=r,yf=T,Tf=qi,If=mc,Af=qt,Sf=ia,Rf=$r.f,bf=z,wf=Jm,Cf=po,Df=of,Nf=df,kf=function(e,t,r){r in e||uf(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},Of=Qr,Mf=o,Lf=He,Pf=Cr.enforce,xf=Td,Uf=mf,Vf=gf,Ff=tt("match"),Bf=vf.RegExp,Hf=Bf.prototype,Wf=vf.SyntaxError,Gf=yf(Hf.exec),jf=yf("".charAt),zf=yf("".replace),Kf=yf("".indexOf),qf=yf("".slice),Yf=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Jf=/a/g,Xf=/a/g,Qf=new Bf(Jf)!==Jf,$f=Nf.MISSED_STICKY,Zf=Nf.UNSUPPORTED_Y,e_=Ef&&(!Qf||$f||Uf||Vf||Mf((function(){return Xf[Ff]=!1,Bf(Jf)!==Jf||Bf(Xf)===Xf||"/a/i"!==String(Bf(Jf,"i"))})));if(Tf("RegExp",e_)){for(var t_=function(e,t){var r,i,o,n,a,s,l=bf(Hf,this),c=wf(e),d=void 0===t,u=[],h=e;if(!l&&c&&d&&e.constructor===t_)return e;if((c||bf(Hf,e))&&(e=e.source,d&&(t=Df(h))),e=void 0===e?"":Cf(e),t=void 0===t?"":Cf(t),h=e,Uf&&"dotAll"in Jf&&(i=!!t&&Kf(t,"s")>-1)&&(t=zf(t,/s/g,"")),r=t,$f&&"sticky"in Jf&&(o=!!t&&Kf(t,"y")>-1)&&Zf&&(t=zf(t,/y/g,"")),Vf&&(n=function(e){for(var t,r=e.length,i=0,o="",n=[],a=Sf(null),s=!1,l=!1,c=0,d="";i<=r;i++){if("\\"===(t=jf(e,i)))t+=jf(e,++i);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(o+=t,"?:"===qf(e,i+1,i+3))continue;Gf(Yf,qf(e,i+1))&&(i+=2,l=!0),c++;continue;case">"===t&&l:if(""===d||Lf(a,d))throw new Wf("Invalid capture group name");a[d]=!0,n[n.length]=[d,c],l=!1,d="";continue}l?d+=t:o+=t}return[o,n]}(e),e=n[0],u=n[1]),a=If(Bf(e,t),l?this:Hf,t_),(i||o||u.length)&&(s=Pf(a),i&&(s.dotAll=!0,s.raw=t_(function(e){for(var t,r=e.length,i=0,o="",n=!1;i<=r;i++)"\\"!==(t=jf(e,i))?n||"."!==t?("["===t?n=!0:"]"===t&&(n=!1),o+=t):o+="[\\s\\S]":o+=t+jf(e,++i);return o}(e),r)),o&&(s.sticky=!0),u.length&&(s.groups=u)),e!==h)try{Af(a,"source",""===h?"(?:)":h)}catch(UK){}return a},r_=Rf(Bf),i_=0;r_.length>i_;)kf(t_,Bf,r_[i_++]);Hf.constructor=t_,t_.prototype=Hf,Of(vf,"RegExp",t_,{constructor:!0})}xf("RegExp");var o_=c,n_=T,a_=po,s_=Qm,l_=df,c_=ia,d_=Cr.get,u_=mf,h_=gf,p_=Pe("native-string-replace",String.prototype.replace),m_=RegExp.prototype.exec,f_=m_,__=n_("".charAt),g_=n_("".indexOf),E_=n_("".replace),v_=n_("".slice),y_=function(){var e=/a/,t=/b*/g;return o_(m_,e,"a"),o_(m_,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),T_=l_.BROKEN_CARET,I_=void 0!==/()??/.exec("")[1];(y_||I_||T_||u_||h_)&&(f_=function(e){var t,r,i,o,n,a,s,l=this,c=d_(l),d=a_(e),u=c.raw;if(u)return u.lastIndex=l.lastIndex,t=o_(f_,u,d),l.lastIndex=u.lastIndex,t;var h=c.groups,p=T_&&l.sticky,m=o_(s_,l),f=l.source,_=0,g=d;if(p&&(m=E_(m,"y",""),-1===g_(m,"g")&&(m+="g"),g=v_(d,l.lastIndex),l.lastIndex>0&&(!l.multiline||l.multiline&&"\n"!==__(d,l.lastIndex-1))&&(f="(?: "+f+")",g=" "+g,_++),r=new RegExp("^(?:"+f+")",m)),I_&&(r=new RegExp("^"+f+"$(?!\\s)",m)),y_&&(i=l.lastIndex),o=o_(m_,p?r:l,g),p?o?(o.input=v_(o.input,_),o[0]=v_(o[0],_),o.index=l.lastIndex,l.lastIndex+=o[0].length):l.lastIndex=0:y_&&o&&(l.lastIndex=l.global?o.index+o[0].length:i),I_&&o&&o.length>1&&o_(p_,o[0],r,(function(){for(n=1;n<arguments.length-2;n++)void 0===arguments[n]&&(o[n]=void 0)})),o&&h)for(o.groups=a=c_(null),n=0;n<h.length;n++)a[(s=h[n])[0]]=o[s[1]];return o});var A_=f_;to({target:"RegExp",proto:!0,forced:/./.exec!==A_},{exec:A_});var S_=n,R_=_o,b_=Qm,w_=o,C_=r.RegExp,D_=C_.prototype,N_=S_&&w_((function(){var e=!0;try{C_(".","d")}catch(UK){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",o=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(n.hasIndices="d"),n)o(a,n[a]);return Object.getOwnPropertyDescriptor(D_,"flags").get.call(t)!==i||r!==i}));N_&&R_(D_,"flags",{configurable:!0,get:b_});var k_=ii,O_=po,M_=L,L_=RangeError,P_=T,x_=di,U_=po,V_=function(e){var t=O_(M_(this)),r="",i=k_(e);if(i<0||Infinity===i)throw new L_("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r},F_=L,B_=P_(V_),H_=P_("".slice),W_=Math.ceil,G_=function(e){return function(t,r,i){var o,n,a=U_(F_(t)),s=x_(r),l=a.length,c=void 0===i?" ":U_(i);return s<=l||""===c?a:((n=B_(c,W_((o=s-l)/c.length))).length>o&&(n=H_(n,0,o)),e?a+n:n+a)}},j_={start:G_(!1),end:G_(!0)},z_=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Y),K_=j_.start;to({target:"String",proto:!0,forced:z_},{padStart:function(e){return K_(this,e,arguments.length>1?arguments[1]:void 0)}});var q_=c,Y_=Qr,J_=A_,X_=o,Q_=tt,$_=qt,Z_=Q_("species"),eg=RegExp.prototype,tg=T,rg=ii,ig=po,og=L,ng=tg("".charAt),ag=tg("".charCodeAt),sg=tg("".slice),lg=function(e){return function(t,r){var i,o,n=ig(og(t)),a=rg(r),s=n.length;return a<0||a>=s?e?"":void 0:(i=ag(n,a))<55296||i>56319||a+1===s||(o=ag(n,a+1))<56320||o>57343?e?ng(n,a):i:e?sg(n,a,a+2):o-56320+(i-55296<<10)+65536}},cg={codeAt:lg(!1),charAt:lg(!0)},dg=cg.charAt,ug=T,hg=Ve,pg=Math.floor,mg=ug("".charAt),fg=ug("".replace),_g=ug("".slice),gg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,Eg=/\$([$&'`]|\d{1,2})/g,vg=function(e,t,r,i,o,n){var a=r+e.length,s=i.length,l=Eg;return void 0!==o&&(o=hg(o),l=gg),fg(n,l,(function(n,l){var c;switch(mg(l,0)){case"$":return"$";case"&":return e;case"`":return _g(t,0,r);case"'":return _g(t,a);case"<":c=o[_g(l,1,-1)];break;default:var d=+l;if(0===d)return n;if(d>s){var u=pg(d/10);return 0===u?n:u<=s?void 0===i[u-1]?mg(l,1):i[u-1]+mg(l,1):n}c=i[d-1]}return void 0===c?"":c}))},yg=c,Tg=Mt,Ig=F,Ag=R,Sg=A_,Rg=TypeError,bg=eu,wg=c,Cg=T,Dg=function(e,t,r,i){var o=Q_(e),n=!X_((function(){var t={};return t[o]=function(){return 7},7!==""[e](t)})),a=n&&!X_((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Z_]=function(){return r},r.flags="",r[o]=/./[o]),r.exec=function(){return t=!0,null},r[o](""),!t}));if(!n||!a||r){var s=/./[o],l=t(o,""[e],(function(e,t,r,i,o){var a=t.exec;return a===J_||a===eg.exec?n&&!o?{done:!0,value:q_(s,t,r,i)}:{done:!0,value:q_(e,r,t,i)}:{done:!1}}));Y_(String.prototype,e,l[0]),Y_(eg,o,l[1])}i&&$_(eg[o],"sham",!0)},Ng=o,kg=Mt,Og=F,Mg=k,Lg=ii,Pg=di,xg=po,Ug=L,Vg=function(e,t,r){return t+(r?dg(e,t).length:1)},Fg=ye,Bg=vg,Hg=function(e,t){var r=e.exec;if(Ig(r)){var i=yg(r,e,t);return null!==i&&Tg(i),i}if("RegExp"===Ag(e))return yg(Sg,e,t);throw new Rg("RegExp#exec called on incompatible receiver")},Wg=tt("replace"),Gg=Math.max,jg=Math.min,zg=Cg([].concat),Kg=Cg([].push),qg=Cg("".indexOf),Yg=Cg("".slice),Jg="$0"==="a".replace(/./,"$0"),Xg=!!/./[Wg]&&""===/./[Wg]("a","$0"),Qg=!Ng((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}));Dg("replace",(function(e,t,r){var i=Xg?"$":"$0";return[function(e,r){var i=Ug(this),o=Mg(e)?void 0:Fg(e,Wg);return o?wg(o,e,i,r):wg(t,xg(i),e,r)},function(e,o){var n=kg(this),a=xg(e);if("string"==typeof o&&-1===qg(o,i)&&-1===qg(o,"$<")){var s=r(t,n,a,o);if(s.done)return s.value}var l=Og(o);l||(o=xg(o));var c,d=n.global;d&&(c=n.unicode,n.lastIndex=0);for(var u,h=[];null!==(u=Hg(n,a))&&(Kg(h,u),d);){""===xg(u[0])&&(n.lastIndex=Vg(a,Pg(n.lastIndex),c))}for(var p,m="",f=0,_=0;_<h.length;_++){for(var g,E=xg((u=h[_])[0]),v=Gg(jg(Lg(u.index),a.length),0),y=[],T=1;T<u.length;T++)Kg(y,void 0===(p=u[T])?p:String(p));var I=u.groups;if(l){var A=zg([E],y,v,a);void 0!==I&&Kg(A,I),g=xg(bg(o,void 0,A))}else g=Bg(E,a,v,y,I,o);v>=f&&(m+=Yg(a,f,v)+g,f=v+E.length)}return m+Yg(a,f)}]}),!Qg||!Jg||Xg);var $g="\t\n\v\f\r                 \u2028\u2029\ufeff",Zg=L,eE=po,tE=$g,rE=T("".replace),iE=RegExp("^["+tE+"]+"),oE=RegExp("(^|[^"+tE+"])["+tE+"]+$"),nE=function(e){return function(t){var r=eE(Zg(t));return 1&e&&(r=rE(r,iE,"")),2&e&&(r=rE(r,oE,"$1")),r}},aE={start:nE(1),end:nE(2),trim:nE(3)},sE=er.PROPER,lE=o,cE=$g,dE=aE.trim;to({target:"String",proto:!0,forced:function(e){return lE((function(){return!!cE[e]()||"​…᠎"!=="​…᠎"[e]()||sE&&cE[e].name!==e}))}("trim")},{trim:function(){return dE(this)}});var uE,hE,pE,mE={exports:{}},fE=Ul,_E=n,gE=r,EE=F,vE=H,yE=He,TE=co,IE=pe,AE=qt,SE=Qr,RE=_o,bE=z,wE=Sa,CE=ts,DE=tt,NE=Ke,kE=Cr.enforce,OE=Cr.get,ME=gE.Int8Array,LE=ME&&ME.prototype,PE=gE.Uint8ClampedArray,xE=PE&&PE.prototype,UE=ME&&wE(ME),VE=LE&&wE(LE),FE=Object.prototype,BE=gE.TypeError,HE=DE("toStringTag"),WE=NE("TYPED_ARRAY_TAG"),GE="TypedArrayConstructor",jE=fE&&!!CE&&"Opera"!==TE(gE.opera),zE=!1,KE={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},qE={BigInt64Array:8,BigUint64Array:8},YE=function(e){var t=wE(e);if(vE(t)){var r=OE(t);return r&&yE(r,GE)?r[GE]:YE(t)}},JE=function(e){if(!vE(e))return!1;var t=TE(e);return yE(KE,t)||yE(qE,t)};for(uE in KE)(pE=(hE=gE[uE])&&hE.prototype)?kE(pE)[GE]=hE:jE=!1;for(uE in qE)(pE=(hE=gE[uE])&&hE.prototype)&&(kE(pE)[GE]=hE);if((!jE||!EE(UE)||UE===Function.prototype)&&(UE=function(){throw new BE("Incorrect invocation")},jE))for(uE in KE)gE[uE]&&CE(gE[uE],UE);if((!jE||!VE||VE===FE)&&(VE=UE.prototype,jE))for(uE in KE)gE[uE]&&CE(gE[uE].prototype,VE);if(jE&&wE(xE)!==VE&&CE(xE,VE),_E&&!yE(VE,HE))for(uE in zE=!0,RE(VE,HE,{configurable:!0,get:function(){return vE(this)?this[WE]:void 0}}),KE)gE[uE]&&AE(gE[uE],WE,uE);var XE={NATIVE_ARRAY_BUFFER_VIEWS:jE,TYPED_ARRAY_TAG:zE&&WE,aTypedArray:function(e){if(JE(e))return e;throw new BE("Target is not a typed array")},aTypedArrayConstructor:function(e){if(EE(e)&&(!CE||bE(UE,e)))return e;throw new BE(IE(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(_E){if(r)for(var o in KE){var n=gE[o];if(n&&yE(n.prototype,e))try{delete n.prototype[e]}catch(UK){try{n.prototype[e]=t}catch(a){}}}VE[e]&&!r||SE(VE,e,r?t:jE&&LE[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,o;if(_E){if(CE){if(r)for(i in KE)if((o=gE[i])&&yE(o,e))try{delete o[e]}catch(UK){}if(UE[e]&&!r)return;try{return SE(UE,e,r?t:jE&&UE[e]||t)}catch(UK){}}for(i in KE)!(o=gE[i])||o[e]&&!r||SE(o,e,t)}},getTypedArrayConstructor:YE,isView:function(e){if(!vE(e))return!1;var t=TE(e);return"DataView"===t||yE(KE,t)||yE(qE,t)},isTypedArray:JE,TypedArray:UE,TypedArrayPrototype:VE},QE=r,$E=o,ZE=sm,ev=XE.NATIVE_ARRAY_BUFFER_VIEWS,tv=QE.ArrayBuffer,rv=QE.Int8Array,iv=!ev||!$E((function(){rv(1)}))||!$E((function(){new rv(-1)}))||!ZE((function(e){new rv,new rv(null),new rv(1.5),new rv(e)}),!0)||$E((function(){return 1!==new rv(new tv(2),1,void 0).length})),ov=H,nv=Math.floor,av=Number.isInteger||function(e){return!ov(e)&&isFinite(e)&&nv(e)===e},sv=ii,lv=RangeError,cv=function(e){var t=sv(e);if(t<0)throw new lv("The argument can't be less than 0");return t},dv=RangeError,uv=function(e,t){var r=cv(e);if(r%t)throw new dv("Wrong offset");return r},hv=Math.round,pv=co,mv=ct,fv=TypeError,_v=function(e){var t=mv(e,"number");if("number"==typeof t)throw new fv("Can't convert number to bigint");return BigInt(t)},gv=Zo,Ev=c,vv=jd,yv=Ve,Tv=hi,Iv=Vp,Av=kp,Sv=Rp,Rv=function(e){var t=pv(e);return"BigInt64Array"===t||"BigUint64Array"===t},bv=XE.aTypedArrayConstructor,wv=_v,Cv=Zo,Dv=N,Nv=Ve,kv=hi,Ov=bn,Mv=T([].push),Lv=function(e){var t=1===e,r=2===e,i=3===e,o=4===e,n=6===e,a=7===e,s=5===e||n;return function(l,c,d,u){for(var h,p,m=Nv(l),f=Dv(m),_=kv(f),g=Cv(c,d),E=0,v=u||Ov,y=t?v(l,_):r||a?v(l,0):void 0;_>E;E++)if((s||E in f)&&(p=g(h=f[E],E,m),e))if(t)y[E]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:Mv(y,h)}else switch(e){case 4:return!1;case 7:Mv(y,h)}return n?-1:i||o?o:y}},Pv={forEach:Lv(0),map:Lv(1),filter:Lv(2),some:Lv(3),every:Lv(4),find:Lv(5),findIndex:Lv(6),filterReject:Lv(7)},xv=hi,Uv=to,Vv=r,Fv=c,Bv=n,Hv=iv,Wv=XE,Gv=_d,jv=Wl,zv=_,Kv=qt,qv=av,Yv=di,Jv=Kl,Xv=uv,Qv=function(e){var t=hv(e);return t<0?0:t>255?255:255&t},$v=ht,Zv=He,ey=co,ty=H,ry=ue,iy=ia,oy=z,ny=ts,ay=$r.f,sy=function(e){var t,r,i,o,n,a,s,l,c=vv(this),d=yv(e),u=arguments.length,h=u>1?arguments[1]:void 0,p=void 0!==h,m=Av(d);if(m&&!Sv(m))for(l=(s=Iv(d,m)).next,d=[];!(a=Ev(l,s)).done;)d.push(a.value);for(p&&u>2&&(h=gv(h,arguments[2])),r=Tv(d),i=new(bv(c))(r),o=Rv(i),t=0;r>t;t++)n=p?h(d[t],t):d[t],i[t]=o?wv(n):+n;return i},ly=Pv.forEach,cy=Td,dy=_o,uy=Ct,hy=i,py=function(e,t,r){for(var i=0,o=arguments.length>2?r:xv(t),n=new e(o);o>i;)n[i]=t[i++];return n},my=mc,fy=Cr.get,_y=Cr.set,gy=Cr.enforce,Ey=uy.f,vy=hy.f,yy=Vv.RangeError,Ty=Gv.ArrayBuffer,Iy=Ty.prototype,Ay=Gv.DataView,Sy=Wv.NATIVE_ARRAY_BUFFER_VIEWS,Ry=Wv.TYPED_ARRAY_TAG,by=Wv.TypedArray,wy=Wv.TypedArrayPrototype,Cy=Wv.isTypedArray,Dy="BYTES_PER_ELEMENT",Ny="Wrong length",ky=function(e,t){dy(e,t,{configurable:!0,get:function(){return fy(this)[t]}})},Oy=function(e){var t;return oy(Iy,e)||"ArrayBuffer"===(t=ey(e))||"SharedArrayBuffer"===t},My=function(e,t){return Cy(e)&&!ry(t)&&t in e&&qv(+t)&&t>=0},Ly=function(e,t){return t=$v(t),My(e,t)?zv(2,e[t]):vy(e,t)},Py=function(e,t,r){return t=$v(t),!(My(e,t)&&ty(r)&&Zv(r,"value"))||Zv(r,"get")||Zv(r,"set")||r.configurable||Zv(r,"writable")&&!r.writable||Zv(r,"enumerable")&&!r.enumerable?Ey(e,t,r):(e[t]=r.value,e)};Bv?(Sy||(hy.f=Ly,uy.f=Py,ky(wy,"buffer"),ky(wy,"byteOffset"),ky(wy,"byteLength"),ky(wy,"length")),Uv({target:"Object",stat:!0,forced:!Sy},{getOwnPropertyDescriptor:Ly,defineProperty:Py}),mE.exports=function(e,t,r){var i=e.match(/\d+/)[0]/8,o=e+(r?"Clamped":"")+"Array",n="get"+e,a="set"+e,s=Vv[o],l=s,c=l&&l.prototype,d={},u=function(e,t){Ey(e,t,{get:function(){return function(e,t){var r=fy(e);return r.view[n](t*i+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,o){var n=fy(e);n.view[a](t*i+n.byteOffset,r?Qv(o):o,!0)}(this,t,e)},enumerable:!0})};Sy?Hv&&(l=t((function(e,t,r,o){return jv(e,c),my(ty(t)?Oy(t)?void 0!==o?new s(t,Xv(r,i),o):void 0!==r?new s(t,Xv(r,i)):new s(t):Cy(t)?py(l,t):Fv(sy,l,t):new s(Jv(t)),e,l)})),ny&&ny(l,by),ly(ay(s),(function(e){e in l||Kv(l,e,s[e])})),l.prototype=c):(l=t((function(e,t,r,o){jv(e,c);var n,a,s,d=0,h=0;if(ty(t)){if(!Oy(t))return Cy(t)?py(l,t):Fv(sy,l,t);n=t,h=Xv(r,i);var p=t.byteLength;if(void 0===o){if(p%i)throw new yy(Ny);if((a=p-h)<0)throw new yy(Ny)}else if((a=Yv(o)*i)+h>p)throw new yy(Ny);s=a/i}else s=Jv(t),n=new Ty(a=s*i);for(_y(e,{buffer:n,byteOffset:h,byteLength:a,length:s,view:new Ay(n)});d<s;)u(e,d++)})),ny&&ny(l,by),c=l.prototype=iy(wy)),c.constructor!==l&&Kv(c,"constructor",l),gy(c).TypedArrayConstructor=l,Ry&&Kv(c,Ry,o);var h=l!==s;d[o]=l,Uv({global:!0,constructor:!0,forced:h,sham:!Sy},d),Dy in l||Kv(l,Dy,i),Dy in c||Kv(c,Dy,i),cy(o)}):mE.exports=function(){};var xy=mE.exports;xy("Float32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Float64",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Int8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Int16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Int32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}}),!0),xy("Uint16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),xy("Uint32",(function(e){return function(t,r,i){return e(this,t,r,i)}}));var Uy=dc,Vy=_v,Fy=co,By=c,Hy=o,Wy=XE.aTypedArray,Gy=XE.exportTypedArrayMethod,jy=T("".slice);Gy("fill",(function(e){var t=arguments.length;Wy(this);var r="Big"===jy(Fy(this),0,3)?Vy(e):+e;return By(Uy,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),Hy((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var zy=r,Ky=c,qy=XE,Yy=hi,Jy=uv,Xy=Ve,Qy=o,$y=zy.RangeError,Zy=zy.Int8Array,eT=Zy&&Zy.prototype,tT=eT&&eT.set,rT=qy.aTypedArray,iT=qy.exportTypedArrayMethod,oT=!Qy((function(){var e=new Uint8ClampedArray(2);return Ky(tT,e,{length:1,0:3},1),3!==e[1]})),nT=oT&&qy.NATIVE_ARRAY_BUFFER_VIEWS&&Qy((function(){var e=new Zy(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));iT("set",(function(e){rT(this);var t=Jy(arguments.length>1?arguments[1]:void 0,1),r=Xy(e);if(oT)return Ky(tT,this,r,t);var i=this.length,o=Yy(r),n=0;if(o+t>i)throw new $y("Wrong length");for(;n<o;)this[t+n]=r[n++]}),!oT||nT);var aT=Jo,sT=o,lT=ge,cT=dl,dT=hl,uT=pl,hT=te,pT=fl,mT=XE.aTypedArray,fT=XE.exportTypedArrayMethod,_T=r.Uint16Array,gT=_T&&aT(_T.prototype.sort),ET=!(!gT||sT((function(){gT(new _T(2),null)}))&&sT((function(){gT(new _T(2),{})}))),vT=!!gT&&!sT((function(){if(hT)return hT<74;if(dT)return dT<67;if(uT)return!0;if(pT)return pT<602;var e,t,r=new _T(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(gT(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==i[e])return!0}));fT("sort",(function(e){return void 0!==e&&lT(e),vT?gT(this,e):cT(mT(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))}),!vT||ET);var yT=to,TT=c,IT=T,AT=L,ST=F,RT=k,bT=Jm,wT=po,CT=ye,DT=of,NT=vg,kT=tt("replace"),OT=TypeError,MT=IT("".indexOf);IT("".replace);var LT=IT("".slice),PT=Math.max;yT({target:"String",proto:!0},{replaceAll:function(e,t){var r,i,o,n,a,s,l,c,d,u=AT(this),h=0,p="";if(!RT(e)){if(bT(e)&&(r=wT(AT(DT(e))),!~MT(r,"g")))throw new OT("`.replaceAll` does not allow non-global regexes");if(i=CT(e,kT))return TT(i,e,u,t)}for(o=wT(u),n=wT(e),(a=ST(t))||(t=wT(t)),s=n.length,l=PT(1,s),c=MT(o,n);-1!==c;)d=a?wT(t(n,c,o)):NT(n,o,c,[],void 0,t),p+=LT(o,h,c)+d,h=c+s,c=c+l>o.length?-1:MT(o,n,c+l);return h<o.length&&(p+=LT(o,h)),p}});var xT={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},UT=_t("span").classList,VT=UT&&UT.constructor&&UT.constructor.prototype,FT=VT===Object.prototype?void 0:VT,BT=Pv.forEach,HT=zs("forEach")?[].forEach:function(e){return BT(this,e,arguments.length>1?arguments[1]:void 0)},WT=r,GT=xT,jT=FT,zT=HT,KT=qt,qT=function(e){if(e&&e.forEach!==zT)try{KT(e,"forEach",zT)}catch(UK){e.forEach=zT}};for(var YT in GT)GT[YT]&&qT(WT[YT]&&WT[YT].prototype);qT(jT);var JT=r,XT=xT,QT=FT,$T=Ls,ZT=qt,eI=Ua,tI=tt("iterator"),rI=$T.values,iI=function(e,t){if(e){if(e[tI]!==rI)try{ZT(e,tI,rI)}catch(UK){e[tI]=rI}if(eI(e,t,!0),XT[t])for(var r in $T)if(e[r]!==$T[r])try{ZT(e,r,$T[r])}catch(UK){e[r]=$T[r]}}};for(var oI in XT)iI(JT[oI]&&JT[oI].prototype,oI);iI(QT,"DOMTokenList");var nI=Nu.clear;to({global:!0,bind:!0,enumerable:!0,forced:r.clearImmediate!==nI},{clearImmediate:nI});var aI=r,sI=eu,lI=F,cI=Xs,dI=Y,uI=al,hI=ru,pI=aI.Function,mI=/MSIE .\./.test(dI)||"BUN"===cI&&function(){var e=aI.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),fI=to,_I=r,gI=Nu.set,EI=function(e,t){var r=t?2:1;return mI?function(i,o){var n=hI(arguments.length,1)>r,a=lI(i)?i:pI(i),s=n?uI(arguments,r):[],l=n?function(){sI(a,this,s)}:a;return t?e(l,o):e(l)}:e},vI=_I.setImmediate?EI(gI,!1):gI;fI({global:!0,bind:!0,enumerable:!0,forced:_I.setImmediate!==vI},{setImmediate:vI});var yI=cg.charAt,TI=po,II=Cr,AI=Ts,SI=Is,RI="String Iterator",bI=II.set,wI=II.getterFor(RI);AI(String,"String",(function(e){bI(this,{type:RI,string:TI(e),index:0})}),(function(){var e,t=wI(this),r=t.string,i=t.index;return i>=r.length?SI(void 0,!0):(e=yI(r,i),t.index+=e.length,SI(e,!1))}));var CI=o,DI=n,NI=tt("iterator"),kI=!CI((function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),i="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),i+=r+e})),r.delete("a",2),r.delete("b",void 0),!t.size&&!DI||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[NI]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==i||"x"!==new URL("https://x",void 0).host})),OI=n,MI=T,LI=c,PI=o,xI=Pn,UI=wi,VI=d,FI=Ve,BI=N,HI=Object.assign,WI=Object.defineProperty,GI=MI([].concat),jI=!HI||PI((function(){if(OI&&1!==HI({b:1},HI(WI({},"a",{enumerable:!0,get:function(){WI(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),i="abcdefghijklmnopqrst";return e[r]=7,i.split("").forEach((function(e){t[e]=e})),7!==HI({},e)[r]||xI(HI({},t)).join("")!==i}))?function(e,t){for(var r=FI(e),i=arguments.length,o=1,n=UI.f,a=VI.f;i>o;)for(var s,l=BI(arguments[o++]),c=n?GI(xI(l),n(l)):xI(l),d=c.length,u=0;d>u;)s=c[u++],OI&&!LI(a,l,s)||(r[s]=l[s]);return r}:HI,zI=Mt,KI=Wp,qI=n,YI=Ct,JI=_,XI=Zo,QI=c,$I=Ve,ZI=function(e,t,r,i){try{return i?t(zI(r)[0],r[1]):t(r)}catch(UK){KI(e,"throw",UK)}},eA=Rp,tA=vn,rA=hi,iA=function(e,t,r){qI?YI.f(e,t,JI(0,r)):e[t]=r},oA=Vp,nA=kp,aA=Array,sA=T,lA=2147483647,cA=/[^\0-\u007E]/,dA=/[.\u3002\uFF0E\uFF61]/g,uA="Overflow: input needs wider integers to process",hA=RangeError,pA=sA(dA.exec),mA=Math.floor,fA=String.fromCharCode,_A=sA("".charCodeAt),gA=sA([].join),EA=sA([].push),vA=sA("".replace),yA=sA("".split),TA=sA("".toLowerCase),IA=function(e){return e+22+75*(e<26)},AA=function(e,t,r){var i=0;for(e=r?mA(e/700):e>>1,e+=mA(e/t);e>455;)e=mA(e/35),i+=36;return mA(i+36*e/(e+38))},SA=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var o=_A(e,r++);if(o>=55296&&o<=56319&&r<i){var n=_A(e,r++);56320==(64512&n)?EA(t,((1023&o)<<10)+(1023&n)+65536):(EA(t,o),r--)}else EA(t,o)}return t}(e);var r,i,o=e.length,n=128,a=0,s=72;for(r=0;r<e.length;r++)(i=e[r])<128&&EA(t,fA(i));var l=t.length,c=l;for(l&&EA(t,"-");c<o;){var d=lA;for(r=0;r<e.length;r++)(i=e[r])>=n&&i<d&&(d=i);var u=c+1;if(d-n>mA((lA-a)/u))throw new hA(uA);for(a+=(d-n)*u,n=d,r=0;r<e.length;r++){if((i=e[r])<n&&++a>lA)throw new hA(uA);if(i===n){for(var h=a,p=36;;){var m=p<=s?1:p>=s+26?26:p-s;if(h<m)break;var f=h-m,_=36-m;EA(t,fA(IA(m+f%_))),h=mA(f/_),p+=36}EA(t,fA(IA(h))),s=AA(a,u,c===l),a=0,c++}}a++,n++}return gA(t,"")},RA=to,bA=T,wA=si,CA=RangeError,DA=String.fromCharCode,NA=String.fromCodePoint,kA=bA([].join);RA({target:"String",stat:!0,arity:1,forced:!!NA&&1!==NA.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,o=0;i>o;){if(t=+arguments[o++],wA(t,1114111)!==t)throw new CA(t+" is not a valid code point");r[o]=t<65536?DA(t):DA(55296+((t-=65536)>>10),t%1024+56320)}return kA(r,"")}});var OA=to,MA=r,LA=Lu,PA=j,xA=c,UA=T,VA=n,FA=kI,BA=Qr,HA=_o,WA=Fl,GA=Ua,jA=ja,zA=Cr,KA=Wl,qA=F,YA=He,JA=Zo,XA=co,QA=Mt,$A=H,ZA=po,eS=ia,tS=_,rS=Vp,iS=kp,oS=Is,nS=ru,aS=dl,sS=tt("iterator"),lS="URLSearchParams",cS=lS+"Iterator",dS=zA.set,uS=zA.getterFor(lS),hS=zA.getterFor(cS),pS=LA("fetch"),mS=LA("Request"),fS=LA("Headers"),_S=mS&&mS.prototype,gS=fS&&fS.prototype,ES=MA.TypeError,vS=MA.encodeURIComponent,yS=String.fromCharCode,TS=PA("String","fromCodePoint"),IS=parseInt,AS=UA("".charAt),SS=UA([].join),RS=UA([].push),bS=UA("".replace),wS=UA([].shift),CS=UA([].splice),DS=UA("".split),NS=UA("".slice),kS=UA(/./.exec),OS=/\+/g,MS=/^[0-9a-f]+$/i,LS=function(e,t){var r=NS(e,t,t+2);return kS(MS,r)?IS(r,16):NaN},PS=function(e){for(var t=0,r=128;r>0&&e&r;r>>=1)t++;return t},xS=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},US=function(e){for(var t=(e=bS(e,OS," ")).length,r="",i=0;i<t;){var o=AS(e,i);if("%"===o){if("%"===AS(e,i+1)||i+3>t){r+="%",i++;continue}var n=LS(e,i+1);if(n!=n){r+=o,i++;continue}i+=2;var a=PS(n);if(0===a)o=yS(n);else{if(1===a||a>4){r+="�",i++;continue}for(var s=[n],l=1;l<a&&!(++i+3>t||"%"!==AS(e,i));){var c=LS(e,i+1);if(c!=c){i+=3;break}if(c>191||c<128)break;RS(s,c),i+=2,l++}if(s.length!==a){r+="�";continue}var d=xS(s);null===d?r+="�":o=TS(d)}}r+=o,i++}return r},VS=/[!'()~]|%20/g,FS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},BS=function(e){return FS[e]},HS=function(e){return bS(vS(e),VS,BS)},WS=jA((function(e,t){dS(this,{type:cS,target:uS(e).entries,index:0,kind:t})}),lS,(function(){var e=hS(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,oS(void 0,!0);var i=t[r];switch(e.kind){case"keys":return oS(i.key,!1);case"values":return oS(i.value,!1)}return oS([i.key,i.value],!1)}),!0),GS=function(e){this.entries=[],this.url=null,void 0!==e&&($A(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===AS(e,0)?NS(e,1):e:ZA(e)))};GS.prototype={type:lS,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,o,n,a,s,l=this.entries,c=iS(e);if(c)for(r=(t=rS(e,c)).next;!(i=xA(r,t)).done;){if(n=(o=rS(QA(i.value))).next,(a=xA(n,o)).done||(s=xA(n,o)).done||!xA(n,o).done)throw new ES("Expected sequence with length 2");RS(l,{key:ZA(a.value),value:ZA(s.value)})}else for(var d in e)YA(e,d)&&RS(l,{key:d,value:ZA(e[d])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,o=DS(e,"&"),n=0;n<o.length;)(t=o[n++]).length&&(r=DS(t,"="),RS(i,{key:US(wS(r)),value:US(SS(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],RS(r,HS(e.key)+"="+HS(e.value));return SS(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var jS=function(){KA(this,zS);var e=dS(this,new GS(arguments.length>0?arguments[0]:void 0));VA||(this.size=e.entries.length)},zS=jS.prototype;if(WA(zS,{append:function(e,t){var r=uS(this);nS(arguments.length,2),RS(r.entries,{key:ZA(e),value:ZA(t)}),VA||this.length++,r.updateURL()},delete:function(e){for(var t=uS(this),r=nS(arguments.length,1),i=t.entries,o=ZA(e),n=r<2?void 0:arguments[1],a=void 0===n?n:ZA(n),s=0;s<i.length;){var l=i[s];if(l.key!==o||void 0!==a&&l.value!==a)s++;else if(CS(i,s,1),void 0!==a)break}VA||(this.size=i.length),t.updateURL()},get:function(e){var t=uS(this).entries;nS(arguments.length,1);for(var r=ZA(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){var t=uS(this).entries;nS(arguments.length,1);for(var r=ZA(e),i=[],o=0;o<t.length;o++)t[o].key===r&&RS(i,t[o].value);return i},has:function(e){for(var t=uS(this).entries,r=nS(arguments.length,1),i=ZA(e),o=r<2?void 0:arguments[1],n=void 0===o?o:ZA(o),a=0;a<t.length;){var s=t[a++];if(s.key===i&&(void 0===n||s.value===n))return!0}return!1},set:function(e,t){var r=uS(this);nS(arguments.length,1);for(var i,o=r.entries,n=!1,a=ZA(e),s=ZA(t),l=0;l<o.length;l++)(i=o[l]).key===a&&(n?CS(o,l--,1):(n=!0,i.value=s));n||RS(o,{key:a,value:s}),VA||(this.size=o.length),r.updateURL()},sort:function(){var e=uS(this);aS(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=uS(this).entries,i=JA(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)i((t=r[o++]).value,t.key,this)},keys:function(){return new WS(this,"keys")},values:function(){return new WS(this,"values")},entries:function(){return new WS(this,"entries")}},{enumerable:!0}),BA(zS,sS,zS.entries,{name:"entries"}),BA(zS,"toString",(function(){return uS(this).serialize()}),{enumerable:!0}),VA&&HA(zS,"size",{get:function(){return uS(this).entries.length},configurable:!0,enumerable:!0}),GA(jS,lS),OA({global:!0,constructor:!0,forced:!FA},{URLSearchParams:jS}),!FA&&qA(fS)){var KS=UA(gS.has),qS=UA(gS.set),YS=function(e){if($A(e)){var t,r=e.body;if(XA(r)===lS)return t=e.headers?new fS(e.headers):new fS,KS(t,"content-type")||qS(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),eS(e,{body:tS(0,ZA(r)),headers:tS(0,t)})}return e};if(qA(pS)&&OA({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return pS(e,arguments.length>1?YS(arguments[1]):{})}}),qA(mS)){var JS=function(e){return KA(this,_S),new mS(e,arguments.length>1?YS(arguments[1]):{})};_S.constructor=JS,JS.prototype=_S,OA({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:JS})}}var XS,QS=to,$S=n,ZS=kI,eR=r,tR=Zo,rR=T,iR=Qr,oR=_o,nR=Wl,aR=He,sR=jI,lR=function(e){var t=$I(e),r=tA(this),i=arguments.length,o=i>1?arguments[1]:void 0,n=void 0!==o;n&&(o=XI(o,i>2?arguments[2]:void 0));var a,s,l,c,d,u,h=nA(t),p=0;if(!h||this===aA&&eA(h))for(a=rA(t),s=r?new this(a):aA(a);a>p;p++)u=n?o(t[p],p):t[p],iA(s,p,u);else for(s=r?new this:[],d=(c=oA(t,h)).next;!(l=QI(d,c)).done;p++)u=n?ZI(c,o,[l.value,p],!0):l.value,iA(s,p,u);return s.length=p,s},cR=al,dR=cg.codeAt,uR=function(e){var t,r,i=[],o=yA(vA(TA(e),dA,"."),".");for(t=0;t<o.length;t++)r=o[t],EA(i,pA(cA,r)?"xn--"+SA(r):r);return gA(i,".")},hR=po,pR=Ua,mR=ru,fR={URLSearchParams:jS,getState:uS},_R=Cr,gR=_R.set,ER=_R.getterFor("URL"),vR=fR.URLSearchParams,yR=fR.getState,TR=eR.URL,IR=eR.TypeError,AR=eR.parseInt,SR=Math.floor,RR=Math.pow,bR=rR("".charAt),wR=rR(/./.exec),CR=rR([].join),DR=rR(1..toString),NR=rR([].pop),kR=rR([].push),OR=rR("".replace),MR=rR([].shift),LR=rR("".split),PR=rR("".slice),xR=rR("".toLowerCase),UR=rR([].unshift),VR="Invalid scheme",FR="Invalid host",BR="Invalid port",HR=/[a-z]/i,WR=/[\d+-.a-z]/i,GR=/\d/,jR=/^0x/i,zR=/^[0-7]+$/,KR=/^\d+$/,qR=/^[\da-f]+$/i,YR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,JR=/[\0\t\n\r #/:<>?@[\\\]^|]/,XR=/^[\u0000-\u0020]+/,QR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,$R=/[\t\n\r]/g,ZR=function(e){var t,r,i,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)UR(t,e%256),e=SR(e/256);return CR(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,o=0,n=0;n<8;n++)0!==e[n]?(o>r&&(t=i,r=o),i=null,o=0):(null===i&&(i=n),++o);return o>r?i:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),i===r?(t+=r?":":"::",o=!0):(t+=DR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},eb={},tb=sR({},eb,{" ":1,'"':1,"<":1,">":1,"`":1}),rb=sR({},tb,{"#":1,"?":1,"{":1,"}":1}),ib=sR({},rb,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),ob=function(e,t){var r=dR(e,0);return r>32&&r<127&&!aR(t,e)?e:encodeURIComponent(e)},nb={ftp:21,file:null,http:80,https:443,ws:80,wss:443},ab=function(e,t){var r;return 2===e.length&&wR(HR,bR(e,0))&&(":"===(r=bR(e,1))||!t&&"|"===r)},sb=function(e){var t;return e.length>1&&ab(PR(e,0,2))&&(2===e.length||"/"===(t=bR(e,2))||"\\"===t||"?"===t||"#"===t)},lb=function(e){return"."===e||"%2e"===xR(e)},cb={},db={},ub={},hb={},pb={},mb={},fb={},_b={},gb={},Eb={},vb={},yb={},Tb={},Ib={},Ab={},Sb={},Rb={},bb={},wb={},Cb={},Db={},Nb=function(e,t,r){var i,o,n,a=hR(e);if(t){if(o=this.parse(a))throw new IR(o);this.searchParams=null}else{if(void 0!==r&&(i=new Nb(r,!0)),o=this.parse(a,null,i))throw new IR(o);(n=yR(new vR)).bindURL(this),this.searchParams=n}};Nb.prototype={type:"URL",parse:function(e,t,r){var i,o,n,a,s,l=this,c=t||cb,d=0,u="",h=!1,p=!1,m=!1;for(e=hR(e),t||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,e=OR(e,XR,""),e=OR(e,QR,"$1")),e=OR(e,$R,""),i=lR(e);d<=i.length;){switch(o=i[d],c){case cb:if(!o||!wR(HR,o)){if(t)return VR;c=ub;continue}u+=xR(o),c=db;break;case db:if(o&&(wR(WR,o)||"+"===o||"-"===o||"."===o))u+=xR(o);else{if(":"!==o){if(t)return VR;u="",c=ub,d=0;continue}if(t&&(l.isSpecial()!==aR(nb,u)||"file"===u&&(l.includesCredentials()||null!==l.port)||"file"===l.scheme&&!l.host))return;if(l.scheme=u,t)return void(l.isSpecial()&&nb[l.scheme]===l.port&&(l.port=null));u="","file"===l.scheme?c=Ib:l.isSpecial()&&r&&r.scheme===l.scheme?c=hb:l.isSpecial()?c=_b:"/"===i[d+1]?(c=pb,d++):(l.cannotBeABaseURL=!0,kR(l.path,""),c=wb)}break;case ub:if(!r||r.cannotBeABaseURL&&"#"!==o)return VR;if(r.cannotBeABaseURL&&"#"===o){l.scheme=r.scheme,l.path=cR(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,c=Db;break}c="file"===r.scheme?Ib:mb;continue;case hb:if("/"!==o||"/"!==i[d+1]){c=mb;continue}c=gb,d++;break;case pb:if("/"===o){c=Eb;break}c=bb;continue;case mb:if(l.scheme=r.scheme,o===XS)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=cR(r.path),l.query=r.query;else if("/"===o||"\\"===o&&l.isSpecial())c=fb;else if("?"===o)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=cR(r.path),l.query="",c=Cb;else{if("#"!==o){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=cR(r.path),l.path.length--,c=bb;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=cR(r.path),l.query=r.query,l.fragment="",c=Db}break;case fb:if(!l.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,c=bb;continue}c=Eb}else c=gb;break;case _b:if(c=gb,"/"!==o||"/"!==bR(u,d+1))continue;d++;break;case gb:if("/"!==o&&"\\"!==o){c=Eb;continue}break;case Eb:if("@"===o){h&&(u="%40"+u),h=!0,n=lR(u);for(var f=0;f<n.length;f++){var _=n[f];if(":"!==_||m){var g=ob(_,ib);m?l.password+=g:l.username+=g}else m=!0}u=""}else if(o===XS||"/"===o||"?"===o||"#"===o||"\\"===o&&l.isSpecial()){if(h&&""===u)return"Invalid authority";d-=lR(u).length+1,u="",c=vb}else u+=o;break;case vb:case yb:if(t&&"file"===l.scheme){c=Sb;continue}if(":"!==o||p){if(o===XS||"/"===o||"?"===o||"#"===o||"\\"===o&&l.isSpecial()){if(l.isSpecial()&&""===u)return FR;if(t&&""===u&&(l.includesCredentials()||null!==l.port))return;if(a=l.parseHost(u))return a;if(u="",c=Rb,t)return;continue}"["===o?p=!0:"]"===o&&(p=!1),u+=o}else{if(""===u)return FR;if(a=l.parseHost(u))return a;if(u="",c=Tb,t===yb)return}break;case Tb:if(!wR(GR,o)){if(o===XS||"/"===o||"?"===o||"#"===o||"\\"===o&&l.isSpecial()||t){if(""!==u){var E=AR(u,10);if(E>65535)return BR;l.port=l.isSpecial()&&E===nb[l.scheme]?null:E,u=""}if(t)return;c=Rb;continue}return BR}u+=o;break;case Ib:if(l.scheme="file","/"===o||"\\"===o)c=Ab;else{if(!r||"file"!==r.scheme){c=bb;continue}switch(o){case XS:l.host=r.host,l.path=cR(r.path),l.query=r.query;break;case"?":l.host=r.host,l.path=cR(r.path),l.query="",c=Cb;break;case"#":l.host=r.host,l.path=cR(r.path),l.query=r.query,l.fragment="",c=Db;break;default:sb(CR(cR(i,d),""))||(l.host=r.host,l.path=cR(r.path),l.shortenPath()),c=bb;continue}}break;case Ab:if("/"===o||"\\"===o){c=Sb;break}r&&"file"===r.scheme&&!sb(CR(cR(i,d),""))&&(ab(r.path[0],!0)?kR(l.path,r.path[0]):l.host=r.host),c=bb;continue;case Sb:if(o===XS||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&ab(u))c=bb;else if(""===u){if(l.host="",t)return;c=Rb}else{if(a=l.parseHost(u))return a;if("localhost"===l.host&&(l.host=""),t)return;u="",c=Rb}continue}u+=o;break;case Rb:if(l.isSpecial()){if(c=bb,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==XS&&(c=bb,"/"!==o))continue}else l.fragment="",c=Db;else l.query="",c=Cb;break;case bb:if(o===XS||"/"===o||"\\"===o&&l.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(s=xR(s=u))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(l.shortenPath(),"/"===o||"\\"===o&&l.isSpecial()||kR(l.path,"")):lb(u)?"/"===o||"\\"===o&&l.isSpecial()||kR(l.path,""):("file"===l.scheme&&!l.path.length&&ab(u)&&(l.host&&(l.host=""),u=bR(u,0)+":"),kR(l.path,u)),u="","file"===l.scheme&&(o===XS||"?"===o||"#"===o))for(;l.path.length>1&&""===l.path[0];)MR(l.path);"?"===o?(l.query="",c=Cb):"#"===o&&(l.fragment="",c=Db)}else u+=ob(o,rb);break;case wb:"?"===o?(l.query="",c=Cb):"#"===o?(l.fragment="",c=Db):o!==XS&&(l.path[0]+=ob(o,eb));break;case Cb:t||"#"!==o?o!==XS&&("'"===o&&l.isSpecial()?l.query+="%27":l.query+="#"===o?"%23":ob(o,eb)):(l.fragment="",c=Db);break;case Db:o!==XS&&(l.fragment+=ob(o,tb))}d++}},parseHost:function(e){var t,r,i;if("["===bR(e,0)){if("]"!==bR(e,e.length-1))return FR;if(t=function(e){var t,r,i,o,n,a,s,l=[0,0,0,0,0,0,0,0],c=0,d=null,u=0,h=function(){return bR(e,u)};if(":"===h()){if(":"!==bR(e,1))return;u+=2,d=++c}for(;h();){if(8===c)return;if(":"!==h()){for(t=r=0;r<4&&wR(qR,h());)t=16*t+AR(h(),16),u++,r++;if("."===h()){if(0===r)return;if(u-=r,c>6)return;for(i=0;h();){if(o=null,i>0){if(!("."===h()&&i<4))return;u++}if(!wR(GR,h()))return;for(;wR(GR,h());){if(n=AR(h(),10),null===o)o=n;else{if(0===o)return;o=10*o+n}if(o>255)return;u++}l[c]=256*l[c]+o,2!=++i&&4!==i||c++}if(4!==i)return;break}if(":"===h()){if(u++,!h())return}else if(h())return;l[c++]=t}else{if(null!==d)return;u++,d=++c}}if(null!==d)for(a=c-d,c=7;0!==c&&a>0;)s=l[c],l[c--]=l[d+a-1],l[d+--a]=s;else if(8!==c)return;return l}(PR(e,1,-1)),!t)return FR;this.host=t}else if(this.isSpecial()){if(e=uR(e),wR(YR,e))return FR;if(t=function(e){var t,r,i,o,n,a,s,l=LR(e,".");if(l.length&&""===l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],i=0;i<t;i++){if(""===(o=l[i]))return e;if(n=10,o.length>1&&"0"===bR(o,0)&&(n=wR(jR,o)?16:8,o=PR(o,8===n?1:2)),""===o)a=0;else{if(!wR(10===n?KR:8===n?zR:qR,o))return e;a=AR(o,n)}kR(r,a)}for(i=0;i<t;i++)if(a=r[i],i===t-1){if(a>=RR(256,5-t))return null}else if(a>255)return null;for(s=NR(r),i=0;i<r.length;i++)s+=r[i]*RR(256,3-i);return s}(e),null===t)return FR;this.host=t}else{if(wR(JR,e))return FR;for(t="",r=lR(e),i=0;i<r.length;i++)t+=ob(r[i],eb);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return aR(nb,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&ab(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,o=e.host,n=e.port,a=e.path,s=e.query,l=e.fragment,c=t+":";return null!==o?(c+="//",e.includesCredentials()&&(c+=r+(i?":"+i:"")+"@"),c+=ZR(o),null!==n&&(c+=":"+n)):"file"===t&&(c+="//"),c+=e.cannotBeABaseURL?a[0]:a.length?"/"+CR(a,"/"):"",null!==s&&(c+="?"+s),null!==l&&(c+="#"+l),c},setHref:function(e){var t=this.parse(e);if(t)throw new IR(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new kb(e.path[0]).origin}catch(UK){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+ZR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(hR(e)+":",cb)},getUsername:function(){return this.username},setUsername:function(e){var t=lR(hR(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=ob(t[r],ib)}},getPassword:function(){return this.password},setPassword:function(e){var t=lR(hR(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=ob(t[r],ib)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?ZR(e):ZR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,vb)},getHostname:function(){var e=this.host;return null===e?"":ZR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,yb)},getPort:function(){var e=this.port;return null===e?"":hR(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=hR(e))?this.port=null:this.parse(e,Tb))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+CR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,Rb))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=hR(e))?this.query=null:("?"===bR(e,0)&&(e=PR(e,1)),this.query="",this.parse(e,Cb)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=hR(e))?("#"===bR(e,0)&&(e=PR(e,1)),this.fragment="",this.parse(e,Db)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var kb=function(e){var t=nR(this,Ob),r=mR(arguments.length,1)>1?arguments[1]:void 0,i=gR(t,new Nb(e,!1,r));$S||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},Ob=kb.prototype,Mb=function(e,t){return{get:function(){return ER(this)[e]()},set:t&&function(e){return ER(this)[t](e)},configurable:!0,enumerable:!0}};if($S&&(oR(Ob,"href",Mb("serialize","setHref")),oR(Ob,"origin",Mb("getOrigin")),oR(Ob,"protocol",Mb("getProtocol","setProtocol")),oR(Ob,"username",Mb("getUsername","setUsername")),oR(Ob,"password",Mb("getPassword","setPassword")),oR(Ob,"host",Mb("getHost","setHost")),oR(Ob,"hostname",Mb("getHostname","setHostname")),oR(Ob,"port",Mb("getPort","setPort")),oR(Ob,"pathname",Mb("getPathname","setPathname")),oR(Ob,"search",Mb("getSearch","setSearch")),oR(Ob,"searchParams",Mb("getSearchParams")),oR(Ob,"hash",Mb("getHash","setHash"))),iR(Ob,"toJSON",(function(){return ER(this).serialize()}),{enumerable:!0}),iR(Ob,"toString",(function(){return ER(this).serialize()}),{enumerable:!0}),TR){var Lb=TR.createObjectURL,Pb=TR.revokeObjectURL;Lb&&iR(kb,"createObjectURL",tR(Lb,TR)),Pb&&iR(kb,"revokeObjectURL",tR(Pb,TR))}pR(kb,"URL"),QS({global:!0,constructor:!0,forced:!ZS,sham:!$S},{URL:kb});var xb=c;to({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return xb(URL.prototype.toString,this)}});var Ub,Vb=Object.create,Fb=Object.defineProperty,Bb=Object.defineProperties,Hb=Object.getOwnPropertyDescriptor,Wb=Object.getOwnPropertyDescriptors,Gb=Object.getOwnPropertyNames,jb=Object.getOwnPropertySymbols,zb=Object.getPrototypeOf,Kb=Object.prototype.hasOwnProperty,qb=Object.prototype.propertyIsEnumerable,Yb=Reflect.get,Jb=Math.pow,Xb=(e,t,r)=>t in e?Fb(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qb=(e,t)=>{for(var r in t||(t={}))Kb.call(t,r)&&Xb(e,r,t[r]);if(jb)for(var r of jb(t))qb.call(t,r)&&Xb(e,r,t[r]);return e},$b=(e,t)=>Bb(e,Wb(t)),Zb=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ew=(e,t)=>{for(var r in t)Fb(e,r,{get:t[r],enumerable:!0})},tw=(e,t,r)=>(r=null!=e?Vb(zb(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of Gb(t))!Kb.call(e,o)&&o!==r&&Fb(e,o,{get:()=>t[o],enumerable:!(i=Hb(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:Fb(r,"default",{value:e,enumerable:!0}),e)),rw=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?Hb(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&Fb(t,r,n),n},iw=(e,t,r)=>Xb(e,"symbol"!=typeof t?t+"":t,r),ow=(e,t,r)=>Yb(zb(e),r,t),nw=(e,t,r)=>new Promise(((i,o)=>{var n=e=>{try{s(r.next(e))}catch(nM){o(nM)}},a=e=>{try{s(r.throw(e))}catch(nM){o(nM)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(n,a);s((r=r.apply(e,t)).next())})),aw=Zb(((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function l(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),l.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},l.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},l.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var l,c,d=this._events[s],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,o),!0;case 5:return d.fn.call(d.context,t,r,o,n),!0;case 6:return d.fn.call(d.context,t,r,o,n,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,p=d.length;for(c=0;c<p;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,r);break;case 4:d[c].fn.call(d[c].context,t,r,o);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},l.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},l.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},l.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn===t&&(!o||a.once)&&(!r||a.context===r)&&s(this,n);else{for(var l=0,c=[],d=a.length;l<d;l++)(a[l].fn!==t||o&&!a[l].once||r&&a[l].context!==r)&&c.push(a[l]);c.length?this._events[n]=1===c.length?c[0]:c:s(this,n)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,void 0!==t&&(t.exports=l)})),sw=Zb(((e,t)=>{var r=t.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return null!=e.address?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return null!=e.subtype?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return null!=e.sessionConfig?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var t="candidate:%s %d %s %d %s %d typ %s";return t+=null!=e.raddr?" raddr %s rport %d":"%v%v",t+=null!=e.tcptype?" tcptype %s":"%v",null!=e.generation&&(t+=" generation %d"),t+=null!=e["network-id"]?" network-id %d":"%v",t+=null!=e["network-cost"]?" network-cost %d":"%v"}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var t="ssrc:%d";return null!=e.attribute&&(t+=" %s",null!=e.value&&(t+=":%s")),t}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return null!=e.maxMessageSize?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(null!=e.clksrcExt?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var t="mediaclk:";return t+=null!=e.id?"id=%s %s":"%v%s",t+=null!=e.mediaClockValue?"=%s":"",t+=null!=e.rateNumerator?" rate=%s":"",t+=null!=e.rateDenominator?"/%s":""}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};Object.keys(r).forEach((function(e){r[e].forEach((function(e){e.reg||(e.reg=/(.*)/),e.format||(e.format="%s")}))}))})),lw=Zb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,i){var o=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:o&&!r[e.name]&&(r[e.name]={});var n=e.push?{}:o?r[e.name]:r;(function(e,r,i,o){if(o&&!i)r[o]=t(e[1]);else for(var n=0;n<i.length;n+=1)null!=e[n+1]&&(r[i[n]]=t(e[n+1]))})(i.match(e.reg),n,e.names,e.name),e.push&&r[e.push].push(n)},i=sw(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},n=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(o).forEach((function(e){var t=e[0],o=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),a=n[n.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var l=i[t][s];if(l.reg.test(o))return r(l,a,o)}})),t.media=n,t};var n=function(e,r){var i=r.split(/=(.+)/,2);return 2===i.length?e[i[0]]=t(i[1]):1===i.length&&r.length>1&&(e[i[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(n,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],i=e.split(" ").map(t),o=0;o<i.length;o+=3)r.push({component:i[o],ip:i[o+1],port:i[o+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(n,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,i=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),i=!0),{scid:r,paused:i}}))}))}})),cw=Zb(((e,t)=>{var r=sw(),i=/%[sdv%]/g,o=function(e){var t=1,r=arguments,o=r.length;return e.replace(i,(function(e){if(t>=o)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""}}))},n=function(e,t,r){var i=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var a=t.names[n];t.name?i.push(r[t.name][a]):i.push(r[t.names[n]])}else i.push(r[t.name]);return o.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var i=t.outerOrder||a,o=t.innerOrder||s,l=[];return i.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?l.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){l.push(n(t,r,e))}))}))})),e.media.forEach((function(e){l.push(n("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?l.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){l.push(n(t,r,e))}))}))}))})),l.join("\r\n")+"\r\n"}})),dw=Zb((e=>{var t=lw(),r=cw(),i=sw();e.grammar=i,e.write=r,e.parse=t.parse,e.parseParams=t.parseParams,e.parseFmtpConfig=t.parseFmtpConfig,e.parsePayloads=t.parsePayloads,e.parseRemoteCandidates=t.parseRemoteCandidates,e.parseImageAttributes=t.parseImageAttributes,e.parseSimulcastStreamList=t.parseSimulcastStreamList})),uw=((Ub=uw||{})[Ub.INVALID_PARAMETER=4096]="INVALID_PARAMETER",Ub[Ub.INVALID_OPERATION=4097]="INVALID_OPERATION",Ub[Ub.NOT_SUPPORTED=4098]="NOT_SUPPORTED",Ub[Ub.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",Ub[Ub.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",Ub[Ub.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",Ub[Ub.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",Ub[Ub.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",Ub[Ub.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",Ub[Ub.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",Ub[Ub.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",Ub[Ub.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",Ub[Ub.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",Ub[Ub.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",Ub[Ub.CLIENT_BANNED=16448]="CLIENT_BANNED",Ub[Ub.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",Ub[Ub.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",Ub[Ub.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",Ub[Ub.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",Ub[Ub.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",Ub[Ub.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",Ub[Ub.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",Ub[Ub.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",Ub[Ub.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",Ub[Ub.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",Ub[Ub.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",Ub[Ub.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",Ub[Ub.API_CALL_ABORTED=16461]="API_CALL_ABORTED",Ub[Ub.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",Ub[Ub.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",Ub[Ub.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",Ub[Ub.VIDEO_ENCODE_FAILED=16465]="VIDEO_ENCODE_FAILED",Ub[Ub.AUDIO_ENCODE_FAILED=16466]="AUDIO_ENCODE_FAILED",Ub[Ub.UNKNOWN=65535]="UNKNOWN",Ub),hw=uw,pw=class extends Error{constructor(e){let{name:t="RtcError",message:r,code:i=hw.UNKNOWN,extraCode:o=0,constraint:n}=e,a="<".concat(function(e){for(let t in hw)if(hw[t]===e)return t;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(r).concat(n?" constraint: ".concat(n):"").concat(null!=r&&r.includes(a)?"":" ".concat(a));super(s),iw(this,"code"),iw(this,"extraCode"),iw(this,"message"),iw(this,"originMessage"),iw(this,"name"),iw(this,"constraint"),this.code=i,this.extraCode=o,this.name=t,this.message=s,this.constraint=n,this.originMessage=r}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},mw=pw,fw=function(){return 0},_w=function(){return Date.now()+0},gw=function(){let e=new Date;return e.setTime(_w()),e.toLocaleString()},Ew=function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},vw={};ew(vw,{REPORT_TYPE:()=>ON,buildSSOPackage:()=>MN,bytes2ms:()=>MD,calculateScaleResolutionDownNumber:()=>CN,concatArrayBuffers:()=>LN,convertObjectNumberToInt:()=>AN,copyProperties:()=>OD,deepClone:()=>pN,deepCloneBasic:()=>kN,deepMerge:()=>hN,delay:()=>SN,fibonacci:()=>BD,formatedTime:()=>_N,getConstructorName:()=>eN,getContainerFromElement:()=>fN,getEnv:()=>ID,getFirst16Bits:()=>xN,getInternalVersion:()=>aN,getLast16Bits:()=>PN,getLoggerUrl:()=>SD,getMediaStreamTrackInfo:()=>wN,getMuteStateFromFlag:()=>cN,getNetworkType:()=>bD,getNumNetworkType:()=>kD,getReconnectionTimeout:()=>HD,getStringByteLength:()=>vN,getTurnServer:()=>dN,getUint32Version:()=>IN,getValueType:()=>WD,getViewListFromView:()=>mN,glog:()=>UD,ipv4ToUint32:()=>uN,isArray:()=>JD,isAudioWorkletSupported:()=>tN,isBoolean:()=>qD,isConstructor:()=>ZD,isEmpty:()=>lN,isFunction:()=>GD,isLangChinese:()=>VD,isMediaStreamTrack:()=>XD,isNumber:()=>KD,isObject:()=>YD,isOverseaSdkAppId:()=>AD,isPlainObject:()=>FD,isPortrait:()=>yN,isPromise:()=>$D,isRemoteTrack:()=>QD,isRotate90Or270:()=>DN,isSetSinkIdSupported:()=>rN,isString:()=>zD,isUndefined:()=>jD,loadImage:()=>TN,loadVideo:()=>NN,ms2bytes:()=>PD,ms2samples:()=>xD,normalizeUrl:()=>bN,performanceNow:()=>oN,promiseAny:()=>iN,samples2ms:()=>LD,setNetworkTypeFromWebRTC:()=>ND,stringify:()=>gN,stringifyIncludeValue:()=>EN,throttlePromise:()=>RN});var yw={};ew(yw,{AUDIO_MUTE_BIT:()=>lC,AUDIO_STAT_BIT:()=>sC,AUX_STAT_BIT:()=>aC,AUX_STREAM_MSID:()=>pC,BACKEND_ENV:()=>rC,BASE_DOC_URL:()=>Pw,BASE_HOST:()=>kw,CAPABILITIES_KEYS:()=>eD,CLASS_NAME:()=>zC,CLOUD_CONSOLE_URL:()=>Lw,CROSS_ROOM_BIT:()=>uC,DATA_FREEZE_TIMING:()=>VC,DOC_BILLING_CN:()=>Uw,DOC_BILLING_OVERSEA:()=>Vw,DOC_URL:()=>xw,DTLS_STATE_UNKNOWN:()=>AC,ENV_NAME:()=>Gw,EXCHANGE_SDP_TIMEOUT:()=>MC,IS_WORKER:()=>bw,IS_WORKLET:()=>ww,KIBANA_EVENT:()=>NC,LOCAL_STREAM_PUBLISH_STATE:()=>UC,LOGGER_CMD_TYPE:()=>Ww,LOGGER_DOMAIN:()=>Fw,LOGGER_DOMAIN_OVERSEA:()=>Bw,LOG_LEVEL:()=>jw,LOG_LEVEL_NAME:()=>XC,MAIN_STREAM_MSID:()=>hC,MAX_RTT:()=>tD,MICROPHONE_COMMUNICATIONS:()=>JC,MICROPHONE_DEFAULT:()=>qC,MUTE_ALL_BIT:()=>dC,NAME:()=>eC,NETWORK_TYPE:()=>qw,NOT_SUPPORTED_H264:()=>xC,PAUSED_RETRY_COUNT:()=>KC,PEERCONNECTION_CONNECTING_TIMEOUT:()=>WC,PEER_CONNECTION_STATE:()=>SC,PEER_LEAVE_REASON:()=>QC,RECOVER_CAPTURE_INTERVAL:()=>ZC,REMOTE_STREAM_TYPE_AUX:()=>fC,REMOTE_STREAM_TYPE_MAIN:()=>mC,RENDER_FREEZE_TIMING:()=>FC,SCHEDULE_DOMAIN:()=>GC,SCHEDULE_TIMEOUT:()=>jC,SDP_SEMANTICS_PLAN_B:()=>PC,SDP_SEMANTICS_UNIFIED_PLAN:()=>LC,SECOND_HOST:()=>Ow,SIGNAL_PING_PONG_INTERVAL:()=>Kw,SIGNAL_PING_TIMEOUT:()=>zw,SIGNAL_RECONNECTION_COUNT:()=>DC,SMALL_STAT_BIT:()=>nC,SPEAKER_DEFAULT:()=>YC,STORAGE_EXPIRES_TIME:()=>Yw,STREAM_TYPE_BIG:()=>BC,STREAM_TYPE_SMALL:()=>HC,SUBSCRIBE_SMALL_RETRY_COUNT:()=>$C,SYNC_USER_LIST_INTERVAL:()=>kC,Scene:()=>iC,THIRD_HOST:()=>Mw,TRANSPORT_DIRECTION:()=>tC,TRTC_ERROR_ASSISTANCE:()=>Hw,TRTC_QUALITY_BAD:()=>yC,TRTC_QUALITY_DISCONNECTED:()=>IC,TRTC_QUALITY_EXCELLENT:()=>gC,TRTC_QUALITY_GOOD:()=>EC,TRTC_QUALITY_POOR:()=>vC,TRTC_QUALITY_UNKNOWN:()=>_C,TRTC_QUALITY_VERY_BAD:()=>TC,UPDATE_OFFER_TIMEOUT:()=>OC,VIDEO_MUTE_BIT:()=>cC,VIDEO_STAT_BIT:()=>oC,audioProfileMap:()=>Jw,defaultBigVideoProfile:()=>Qw,defaultSmallVideoProfile:()=>$w,getRetryCount:()=>wC,getScriptDir:()=>Cw,innerVersion:()=>Tw,loggerProxy:()=>Dw,screenProfileMap:()=>Zw,setLoggerProxy:()=>Nw,setRetryCount:()=>bC,setVersion:()=>Aw,version:()=>Iw,videoProfileMap:()=>Xw});var Tw="4.15.00.1600",Iw="5.0.0";function Aw(e){Iw=e;let[t,r,i]=e.split(".").map((e=>parseInt(e,10)));Tw="".concat(t,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var Sw,Rw,bw="undefined"!=typeof importScripts,ww="undefined"!=typeof registerProcessor,Cw=()=>{let e=bw?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},Dw="",Nw=e=>Dw=e,kw="web.sdk.qcloud.com",Ow="web.sdk.tencent.cn",Mw="web.sdk.cloud.tencent.cn",Lw="https://console.cloud.tencent.com/trtc",Pw="https://".concat(kw,"/trtc/webrtc/doc"),xw="".concat(Pw,"/zh-cn/"),Uw="https://cloud.tencent.com/document/product/647/85386",Vw="https://trtc.io/document/56025",Fw="https://yun.tim.qq.com",Bw="https://apisgp.my-imcloud.com",Hw="trtc_error_assistance",Ww={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},Gw={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},jw=((Rw=jw||{})[Rw.TRACE=0]="TRACE",Rw[Rw.DEBUG=1]="DEBUG",Rw[Rw.INFO=2]="INFO",Rw[Rw.WARN=3]="WARN",Rw[Rw.ERROR=4]="ERROR",Rw[Rw.NONE=5]="NONE",Rw),zw=18e3,Kw=2e3,qw={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5,"5g":6},Yw=6048e5,Jw={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},Xw={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Qw=Xw["480p_2"],$w=Xw["120p_2"],Zw={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},eC={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture",RESIZE:"resize",TIME_UPDATE:"timeupdate"},tC={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},rC={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},iC=((Sw=iC||{}).LIVE="live",Sw.RTC="rtc",Sw),oC=1,nC=2,aC=4,sC=8,lC=64,cC=16,dC=112,uC=128,hC="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",pC="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",mC=eC.MAIN,fC=eC.AUXILIARY,_C=0,gC=1,EC=2,vC=3,yC=4,TC=5,IC=6,AC="unknown",SC={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},RC=1/0;function bC(e){RC=e}function wC(){return RC}var CC,DC=30,NC={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry",VIDEO_ENCODE_FAILED_DURING_CALL:"video-encode-failed-during-call",AUDIO_ENCODE_FAILED_DURING_CALL:"audio-encode-failed-during-call"},kC=1e4,OC=1e4,MC=1e4,LC="unified-plan",PC="plan-b",xC=1028,UC=((CC=UC||{})[CC.UNPUBLISH=-1]="UNPUBLISH",CC[CC.PUBLISHING=0]="PUBLISHING",CC[CC.PUBLISHED=1]="PUBLISHED",CC),VC=500,FC=1e3,BC=eC.BIG,HC=eC.SMALL,WC=1e4,GC={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},jC=2e3,zC={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},KC=5,qC="default",YC=qC,JC="communications",XC=Object.keys(jw),QC=["normal leave","timeout leave","kick","role change"],$C=10,ZC=2e3,eD=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],tD=1e4,rD=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{l(i.next(e))}catch(t){n(t)}}function s(e){try{l(i.throw(e))}catch(t){n(t)}}function l(e){e.done?o(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(a,s)}l((i=i.apply(e,t||[])).next())}))},iD=Symbol(32),oD=Symbol(16),nD=Symbol(8),aD=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return rD(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,r)=>{var i;this.reject=r,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(e,!0)||null===(i=this.pull)||void 0===i||i.call(this,e)}))}))}readU32(){return this.read(iD)}readU16(){return this.read(oD)}readU8(){return this.read(nD)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null,t=this.buffer.subarray(this.consumed),r=0,i=e=>t.length<(r=e);if("number"==typeof this.need){if(i(this.need))return;e=t.subarray(0,r)}else if(this.need===iD){if(i(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===oD){if(i(2))return;e=t[0]<<8|t[1]}else if(this.need===nD){if(i(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(i(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,r)),e=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){let t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{let e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}};aD.U32=iD,aD.U16=oD,aD.U8=nD;var sD=128;function lD(e){let t=new aD;for(;e>=128;)t.malloc(1)[0]=255&e|sD,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function cD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new aD,i=t<<3;switch(typeof e){case"boolean":let o=r.malloc(2);o[0]=i,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=i,r.write(lD(e));break;case"string":r.malloc(1)[0]=2|i;let n=(new TextEncoder).encode(e);r.write(lD(n.length));let a=r.malloc(n.length);for(let e=0;e<n.length;e++)a[e]=n[e];break;case"object":let s=new aD;if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=cD(e[t],t+1);r&&s.write(r)}else{let t=1;for(let r in e){let i=cD(e[r],t++);i&&s.write(i)}}0===t?s.buffer&&r.write(s.buffer):(r.malloc(1)[0]=2|i,s.buffer&&(r.write(lD(s.buffer.length)),r.write(s.buffer)))}return r.buffer||new Uint8Array(0)}var dD=class{constructor(){iw(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function uD(e,t,r){e[r]=t>>>24&255,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function hD(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function pD(e,t){return e[t]}function mD(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var fD=0,_D=2654435769,gD=16,ED=2,vD=7;function yD(e,t){let r=new dD,i=function(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,uin:"",uinLen:0,reqHead:{seqNumber:r,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:i,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}(t,e,fD);fD=fD+1&2147483647,r.writeInt32(0),r.writeInt32(i.version),r.writeByte(i.encryption);let o=(new TextEncoder).encode(i.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(i.uinType);let n=(new TextEncoder).encode(i.uin);r.writeInt32(n.length+4),n.length&&r.writeBytes(n);let a=new dD;a.writeInt32(0),a.writeInt32(i.reqHead.seqNumber),a.writeInt32(i.reqHead.appId),a.writeByte(i.reqHead.appId>>>24&255),a.writeByte(i.reqHead.appId>>>16&255),a.writeByte(i.reqHead.appId>>>8&255),a.writeByte(255&i.reqHead.appId);for(let E=4;E<16;E++)a.writeByte(0);let s=(new TextEncoder).encode(i.reqHead.a2);a.writeInt32(s.length+4),s.length&&a.writeBytes(s);let l=(new TextEncoder).encode(i.reqHead.serviceCmd);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);let c=(new TextEncoder).encode(i.reqHead.cookie);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);let d=(new TextEncoder).encode(i.reqHead.imei);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);let u=(new TextEncoder).encode(i.reqHead.ksid);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);let h=(new TextEncoder).encode(i.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);let p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,zD(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);let m=new Uint8Array(a.data),f=null;1===i.encryption?f=(new TextEncoder).encode(i.uin):2===i.encryption&&(f=new Uint8Array(16)),f&&(m=function(e,t){let r=e.length,i=(r+1+ED+vD)%8;i&&(i=8-i);let o=r+1+ED+vD+i,n=new Uint8Array(o),a=0,s=new Uint8Array(8),l=new Uint8Array(8),c=new Uint8Array(8),d=0;s[0]=248&Math.floor(256*Math.random())|i,d=1;for(let h=0;h<i;h++)s[d]=255&Math.floor(256*Math.random()),d+=1;for(let h=0;h<ED;)if(d<8&&(s[d]=255&Math.floor(256*Math.random()),d+=1,h+=1),8===d){TD(s,t,l,c,n,a),a+=8,d=0;for(let e=0;e<8;e++)c[e]=n[a-8+e]}let u=0;for(;u<r;)if(d<8&&(s[d]=e[u],d+=1,u+=1),8===d){TD(s,t,l,c,n,a),a+=8,d=0;for(let e=0;e<8;e++)c[e]=n[a-8+e]}for(let h=0;h<vD;)if(d<8&&(s[d]=0,d+=1,h+=1),8===d){TD(s,t,l,c,n,a),a+=8,d=0;for(let e=0;e<8;e++)c[e]=n[a-8+e]}return n}(m,f)),r.writeBytes(m);let _=new Uint8Array(r.data),g=_.length;return _[0]=g>>>24&255,_[1]=g>>>16&255,_[2]=g>>>8&255,_[3]=255&g,_}function TD(e,t,r,i,o,n){for(let a=0;a<8;a++)e[a]^=i[a];!function(e,t,r,i){let o=hD(e,0),n=hD(e,4),a=[];for(let l=0;l<4;l++)a[l]=hD(t,4*l);let s=0;for(let l=0;l<gD;l++)s+=_D,s>>>=0,o+=(n<<4)+a[0]^n+s^(n>>>5)+a[1],o>>>=0,n+=(o<<4)+a[2]^o+s^(o>>>5)+a[3],n>>>=0;uD(r,o,i),uD(r,n,i+4)}(e,t,o,n);for(let a=0;a<8;a++)o[n+a]^=r[a];for(let a=0;a<8;a++)r[a]=e[a]}var ID=function(){return new URLSearchParams(location.search).get("trtc_env")||""},AD=e=>Number(e)<14e8,SD=function(e,t){let r;r=Dw||(AD(e)?Bw:Fw);let i=Math.floor(Math.random()*Jb(2,31));return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},RD="unknown";function bD(){!function(){var e;CD||(CD=!0,null==(e=navigator.connection)||e.addEventListener("typechange",wD))}();let{userAgent:e,connection:t}=navigator,r=(e.match(/NetType\/\S+/)||[])[0]||"";r=r.toLowerCase().replace("nettype/",""),"3gnet"===r&&(r="3g");let i=t&&t.type&&t.type.toLowerCase(),o=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===o&&(o="2g"),i?DD(i,o):RD}function wD(){ZO.warn("netType changed",bD())}var CD=!1;function DD(e,t){if(qw[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function ND(e){RD=DD(e)}function kD(){return qw[bD()]}function OD(e,t){for(let r of Reflect.ownKeys(t))if("constructor"!==r&&"prototype"!==r&&"name"!==r){let i=Object.getOwnPropertyDescriptor(t,r)||"";Object.defineProperty(e,r,i)}return e}function MD(e){return LD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function LD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function PD(e){return 4*xD(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function xD(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var UD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},VD=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},FD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)};function BD(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:BD(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function HD(e){return e>8?3e4:1e3*BD(e)}function WD(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var GD=e=>"function"==typeof e,jD=e=>void 0===e,zD=e=>"string"==typeof e,KD=e=>"number"==typeof e,qD=e=>"boolean"==typeof e,YD=e=>"object"===WD(e),JD=e=>"array"===WD(e),XD=e=>WD(e)==="MediaStreamTrack".toLowerCase(),QD=e=>e.isRemote,$D=e=>"promise"===WD(e),ZD=e=>GD(e)&&e.prototype.constructor===e,eN=e=>ZD(e)?e.prototype.constructor.name:"",tN="undefined"!=typeof AudioWorkletNode,rN="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function iN(e){return new Promise(((t,r)=>{let i=[];e.forEach((o=>{o.then(t).catch((t=>{i.push(t),i.length===e.length&&r(i)}))}))}))}function oN(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var nN=e=>+e<10?"0".concat(e):e,aN=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let r=t.split("."),i=nN(r[1])+nN(r[2]);return r[1]-15>0&&(r[1]="15"),r[2]-15>0&&(r[2]="15"),"".concat(r.join("."),".").concat(i)},sN=Object.prototype.hasOwnProperty;function lN(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(FD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(sN.call(e,t))return!1;return!0}return!1}function cN(e,t){return{userId:t,hasAudio:!!(e&sC),hasVideo:!!(e&oC),hasAuxiliary:!!(e&aC),hasSmall:!!(e&nC),audioMuted:!!(e&lC),videoMuted:!!(e&cC),audioAvailable:!(!(e&sC)||e&lC),videoAvailable:!(!(e&oC)||e&cC)}}function dN(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!jD(e.username)&&!jD(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",jD(e.credentialType)||(t.credentialType=e.credentialType)),t}function uN(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!zD(e))return 0;let r=e.split(".");return t?(Number(r[0])<<24|Number(r[1])<<16|Number(r[2])<<8|Number(r[3]))>>>0:(Number(r[3])<<24|Number(r[2])<<16|Number(r[1])<<8|Number(r[0]))>>>0}var hN=function(e,t,r,i){if(!YD(e)||!YD(t))return 0;let o,n=0,a=Object.keys(t);for(let s=0,l=a.length;s<l;s++)if(o=a[s],!(jD(t[o])||r&&r.includes(o)))if(YD(e[o])&&YD(t[o]))n+=hN(e[o],t[o],r,i);else{if(i&&i.includes(t[o]))continue;e[o]!==t[o]&&(e[o]=pN(t[o]),n+=1)}return n};function pN(e){if(JD(e)){let t=[];return e.forEach(((e,r)=>{t[r]=pN(e)})),t}if(YD(e)){let t={};return Object.keys(e).forEach((r=>{t[r]=pN(e[r])})),t}return e}var mN=e=>{let t=[];if(JD(e))t=[...e];else if(zD(e)){let r=document.getElementById(e);r&&t.push(r)}else e&&t.push(e);return t},fN=e=>zD(e)?document.getElementById(e):e,_N=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),n=t(e.getHours()),a=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(r,"/").concat(i,"/").concat(o," ").concat(n,":").concat(a,":").concat(s)})(new Date);function gN(e,t){let{keysToInclude:r,keysToExclude:i}=t;try{if(JD(e))return"[".concat(e.map((e=>gN(e,{keysToInclude:r,keysToExclude:i}))).join(","),"]");if(!FD(e)||!JD(r)&&!JD(i))return JSON.stringify(e);let t={},o=new Set(r),n=new Set(i);return Object.keys(e).forEach((a=>{(0===n.size&&o.has(a)||0===o.size&&!n.has(a))&&(t[a]=FD(e[a])||JD(e[a])?JSON.parse(gN(e[a],{keysToExclude:i,keysToInclude:r})):e[a])})),JSON.stringify(t)}catch(CC){return"{}"}}function EN(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=[];return Object.keys(e).forEach((i=>{t===e[i]&&r.push(i)})),gN(e,{keysToInclude:r})}function vN(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var yN=()=>{var e,t,r,i;return null!=(e=window.screen)&&e.orientation?!(null==(i=null==(r=null==(t=window.screen)?void 0:t.orientation)?void 0:r.type)||!i.includes("portrait")):0===window.orientation||180===window.orientation},TN=e=>nw(void 0,null,(function*(){return new Promise(((t,r)=>{let i;if(zD(e))i=new Image,i.crossOrigin="anonymous",i.src=e;else if(i=e,i.complete)return void t(i);i.onload=()=>t(i),i.onerror=()=>{r(new mw({code:hw.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}))})),IN=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},AN=e=>(Object.keys(e).forEach((t=>{KD(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(FD(e[t])||JD(e[t]))&&AN(e[t])})),e);function SN(e,t){return new Promise((r=>{let i=setTimeout(r,e);t&&t(i)}))}function RN(e,t){let r=null;return function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return r||(r=e.apply(t||this,o),r.finally((()=>r=null)),r)}}function bN(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function wN(e){var t;try{let{width:r,height:i,frameRate:o,sampleRate:n,sampleSize:a,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),l=e.kind===eC.AUDIO?"".concat(n,"x").concat(a,"@").concat(s):"".concat(r,"x").concat(i,"@").concat(o),c=e.stats?" stats: ".concat(JSON.stringify(e.stats).replaceAll('"',"")):"";return"".concat(e.id," ").concat(e.readyState," muted:").concat(e.muted," ").concat(e.kind," ").concat(e.label," ").concat(l).concat(c)}catch(Sw){return""}}function CN(e,t){return e.width*e.height==t.width*t.height?1:yN()&&t.width>t.height&&e.height>t.width?Math.max(e.width/t.height,e.height/t.width,1):Math.max(e.width/t.width,e.height/t.height,1)}function DN(e){return 90===e||270===e}function NN(e){return nw(this,null,(function*(){return new Promise(((t,r)=>{let i=document.createElement("video");i.crossOrigin="anonymous",i.src=e,i.muted=!0,i.loop=!0,i.playsInline=!0,i.play().then((()=>t(i))),i.onerror=()=>{r(i.error)}}))}))}function kN(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new WeakMap;if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let r=[];return t.set(e,r),e.forEach(((e,i)=>{r[i]=kN(e,t)})),r}if("[object Object]"===Object.prototype.toString.call(e)){let r={};return t.set(e,r),Reflect.ownKeys(e).forEach((i=>{r[i]=kN(e[i],t)})),r}return e}var ON=(e=>(e[e.END_REPORT=2001]="END_REPORT",e[e.LOG=2002]="LOG",e[e.KEY_METRIC_REPORT=2003]="KEY_METRIC_REPORT",e))(ON||{});function MN(e,t,r,i){try{let o=function(e,t,r,i){let o={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:r};return jD(i)||(o=$b(Qb({},o),{gzip:+i})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}(e,t,r,i);return yD(cD(o),r)}catch(cM){return JSON.stringify(e)}}function LN(e,t){let r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e),0),r.set(new Uint8Array(t),e.byteLength),r.buffer}function PN(e){return(65535&e)>>>0}function xN(e){return(4294901760&e)>>>0}function UN(e){let t=function(e){try{let t={},r=0;t.totalLength=hD(e,r),r+=4,t.version=hD(e,r),r+=4,t.encryption=pD(e,r),r+=1,t.uinType=pD(e,r),r+=1,t.uinLength=hD(e,r),r+=4,t.uin=t.uinLength>4?mD(e,r,t.uinLength-4):"",r+=t.uinLength-4;let i=e.slice(r);if(2===t.encryption){e=function(e,t){let r=0,i=new Uint8Array(8).fill(0),o=new Uint8Array(e.slice(0,8)),n=VN(o,t),a=7&n[0],s=e.length-1-a-ED-vD,l=new Uint8Array(s),c=0,d=i,u=e.slice(0,8);r=8;let h=1;h+=a;for(let m=1;m<=ED;)if(h<8)h++,m++;else if(8===h){let i=FN(e,r,d,u,n,t);d=i.ivPreCrypt,u=i.ivCurCrypt,n=i.debiBuf,r=i.bufPos,h=0}let p=s;for(;p>0;)if(h<8)l[c++]=n[h]^d[h],h++,p--;else if(8===h){let i=FN(e,r,d,u,n,t);d=i.ivPreCrypt,u=i.ivCurCrypt,n=i.debiBuf,r=i.bufPos,h=0}for(let m=1;m<=vD;)if(h<8)n[h],d[h],h++,m++;else if(8===h){if(r>=e.length)break;let i=FN(e,r,d,u,n,t);if(!i.success)break;d=i.ivPreCrypt,u=i.ivCurCrypt,n=i.debiBuf,r=i.bufPos,h=0}return l}(i,new Uint8Array(16).fill(0)),t.decrypted=!0,r=0}else e=i,r=0;return t.rspHeadLength=hD(e,r),r+=4,t.seqNo=hD(e,r),r+=4,t.retCode=hD(e,r),r+=4,t.retStrLength=hD(e,r),r+=4,t.retStr=t.retStrLength?mD(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=hD(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?mD(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=hD(e,r),r+=4,t.cookie=t.cookieLength?mD(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=hD(e,r),r+=4,t.busiBuffLength=hD(e,r),r+=4,t.busiBuff=t.busiBuffLength?mD(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function VN(e,t){let r=e[0]<<24|e[1]<<16|e[2]<<8|e[3],i=e[4]<<24|e[5]<<16|e[6]<<8|e[7];r>>>=0,i>>>=0;let o=_D*gD>>>0;for(let n=0;n<gD;n++)i-=(r<<4)+t[2]^r+o^(r>>>5)+t[3],i>>>=0,r-=(i<<4)+t[0]^i+o^(i>>>5)+t[1],r>>>=0,o-=_D,o>>>=0;return new Uint8Array([r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i])}function FN(e,t,r,i,o,n){if(t+8>e.length)return{success:!1};let a=new Uint8Array(i),s=e.slice(t,t+8),l=new Uint8Array(8);for(let c=0;c<8;c++)l[c]=o[c]^s[c];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:VN(l,n),bufPos:t+8}}var BN="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function HN(e){let{url:t,body:r,method:i="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:n}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:UN(new Uint8Array(e))||(BN?BN.decode(e):e)}))))))).then(e,a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(uM){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,t,!0),s.send(r)}))}function WN(e){return nw(this,null,(function*(){let t=oN(),r=JSON.stringify(e);try{if(!CompressionStream||r.length<=2800)return r;let e=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),i=yield(yield(yield new Response(e)).blob()).arrayBuffer();return ZO.debug("compressJSON ".concat(r.length," -> ").concat(i.byteLength," ").concat(oN()-t,"ms")),i}catch(CC){return r}}))}var GN=Object.prototype.hasOwnProperty,jN=e=>"function"==typeof e,zN=e=>void 0===e,KN=e=>e.isRemote,qN=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)};var YN=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,l=new Array(e),c=0;c<e;c++)l[c]=arguments[c];let{retries:d=5,timeout:u=1e3}=r,h=0,p=-1,m=0,f=(e,r)=>nw(this,null,(function*(){let c=s||this;try{let r=yield t.apply(c,l);h>0&&a&&a.call(this,h),h=0,e(r)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,r(_)},a=()=>{2!==m&&h<(jN(d)?d():d)?(h++,m=1,jN(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,r)}),jN(u)?u(h):u)):(t(),jN(n)&&n.call(this,_))};jN(i)?i.call(this,{error:_,retry:a,reject:r,retryFuncArgs:l,retriedCount:h}):a()}}));return new Promise(f)}},JN=class e{constructor(e){iw(this,"_parentPath"),iw(this,"userId"),iw(this,"remoteUserId"),iw(this,"id"),iw(this,"sdkAppId"),iw(this,"type"),iw(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!(e=>"boolean"==typeof e)(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}createChild(t){let r=new e({id:t.id,userId:zN(t.userId)?this.userId:t.userId,sdkAppId:zN(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:zN(t.type)?this.type:t.type,isLocal:zN(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:zN(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let r=this.isLocal?this.userId:this.remoteUserId,i=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(i).concat(r?"|".concat(r):"","]")),ZO.log(e,t,zN(this.userId)||function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(qN(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(GN.call(e,t))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}},XN={};ew(XN,{ANDROID_VERSION:()=>ck,CHROME_MAJOR_VERSION:()=>mO,CHROME_VERSION:()=>fO,EDGE_VERSION:()=>_k,EDG_MAJOR_VERSION:()=>vk,EDG_VERSION:()=>Ek,ELECTRON_MAJOR_VERSION:()=>_O,FIREFOX_MAJOR_VERSION:()=>mk,FIREFOX_VERSION:()=>pk,HUAWEI_VERSION:()=>eO,IE_VERSION:()=>Nk,IOS_MAIN_VERSION:()=>SO,IOS_VERSION:()=>TO,IPADQQB_VERSION:()=>Hk,IS_ANDROID:()=>lk,IS_ANDROID_WEBVIEW:()=>yO,IS_ANY_SAFARI:()=>EO,IS_CHROME:()=>hO,IS_CHROME_OS:()=>zk,IS_CHROMIUM_BASE:()=>uO,IS_DESKTOP_IOS_CHROME:()=>CO,IS_EDG:()=>gk,IS_EDGE:()=>fk,IS_ELECTRON:()=>Yk,IS_FIREFOX:()=>hk,IS_HEADLESS_CHROME:()=>pO,IS_HONOR:()=>Zk,IS_HUAWEI:()=>$k,IS_HUAWEIBROWSER:()=>Qk,IS_IE:()=>Dk,IS_IE8:()=>Ck,IS_IOS:()=>sk,IS_IOS_13_OR_14:()=>wO,IS_IOS_15_1:()=>bO,IS_IOS_CHROME:()=>dO,IS_IPAD:()=>ik,IS_IPADQQB:()=>Bk,IS_IPAD_PRO:()=>ok,IS_IPHONE:()=>nk,IS_IPOD:()=>ak,IS_LINUX:()=>jk,IS_LOCAL:()=>DO,IS_MAC:()=>Gk,IS_MACQQB:()=>Vk,IS_MIBROWSER:()=>Jk,IS_MQQB:()=>Lk,IS_NATIVE_ANDROID:()=>uk,IS_OLD_ANDROID:()=>dk,IS_OPENHARMONY:()=>sO,IS_OPPOBROWSER:()=>iO,IS_SAFARI:()=>gO,IS_SAFARI_15_1:()=>RO,IS_SAMSUNGBROWSER:()=>tO,IS_SOGOU:()=>Ik,IS_SOGOUM:()=>yk,IS_TBS:()=>Sk,IS_UCBROWSER:()=>qk,IS_VIVOBROWSER:()=>nO,IS_WECHAT:()=>kk,IS_WIN:()=>Wk,IS_WQQB:()=>xk,IS_WX:()=>Kk,IS_X5MQQB:()=>Mk,IS_XWEB:()=>bk,MACQQB_VERSION:()=>Fk,MI_VERSION:()=>Xk,MQQB_VERSION:()=>Pk,OPENHARMONY_VERSION:()=>lO,OPPO_VERSION:()=>oO,SAFARI_VERSION:()=>vO,SAMSUNG_VERSION:()=>rO,SOGOUM_VERSION:()=>Tk,SOGOU_VERSION:()=>Ak,TBS_VERSION:()=>Rk,UA_DATA_STRING:()=>PO,USER_AGENT:()=>QN,VIVO_VERSION:()=>aO,WECHAT_VERSION:()=>Ok,WQQB_VERSION:()=>Uk,XWEB_VERSION:()=>wk,browserInfo:()=>kO,getBrowserCoreNumber:()=>GO,getBrowserInfo:()=>OO,getChromeMajorVersion:()=>cO,getDeviceModel:()=>VO,getDeviceModelFromUA:()=>FO,getGPUInfo:()=>UO,getOSName:()=>HO,getOSNumber:()=>WO,getOSString:()=>jO,getOSType:()=>KO,getTerminalType:()=>zO,getUserAgentData:()=>xO,isLocalStorageEnabled:()=>NO,isMobile:()=>LO,isVersionLargerThan:()=>AO,isVersionSmallerThan:()=>IO});var QN="undefined"==typeof navigator?"":navigator.userAgent,$N=e=>new RegExp(e,"i").test(QN),ZN=e=>{if($N(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=QN.match(t);if(r&&r[1])return r[1]}return""},ek=e=>{if($N(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=QN.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},tk=/AppleWebKit\/([\d.]+)/i.exec(QN),rk=tk?parseFloat(tk[1]):NaN,ik=$N("iPad"),ok="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&$N("Macintosh"),nk=$N("iPhone")&&!ik,ak=$N("iPod"),sk=nk||ik||ak||ok,lk=$N("Android"),ck=function(){if(lk){let e=QN.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}return NaN}(),dk=lk&&$N("webkit")&&ck<2.3,uk=lk&&ck<5&&rk<537,hk=$N("Firefox"),pk=ZN("Firefox"),mk=ek("Firefox"),fk=$N("Edge"),_k=ZN("Edge"),gk=$N("Edg"),Ek=ZN("Edg"),vk=ek("Edg"),yk=$N("SogouMobileBrowser"),Tk=ZN("SogouMobileBrowser"),Ik=$N("MetaSr\\s"),Ak=ZN("MetaSr\\s"),Sk=$N("TBS"),Rk=ZN("TBS"),bk=$N("XWEB"),wk=ZN("XWEB"),Ck=$N("MSIE\\s8\\.0"),Dk=$N("MSIE\\/\\d+"),Nk=function(){if(Dk){let e=/MSIE\s(\d+)\.\d/.exec(QN),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(QN)&&/rv:11.0/.test(QN)&&(t=11),t}return NaN}(),kk=$N("(micromessenger|webbrowser)"),Ok=ZN("MicroMessenger"),Mk=!Sk&&$N("MQQBrowser")&&$N("COVC"),Lk=!Sk&&$N("MQQBrowser")&&!$N("COVC"),Pk=Lk||Mk?ZN("MQQBrowser"):"",xk=!Sk&&$N(" QQBrowser"),Uk=ZN(" QQBrowser"),Vk=!Sk&&$N("QQBrowserLite"),Fk=ZN("QQBrowserLite"),Bk=!Sk&&$N("MQBHD"),Hk=ZN("MQBHD"),Wk=$N("Windows"),Gk=!sk&&$N("MAC OS X"),jk=!lk&&$N("Linux"),zk=$N("CrOS"),Kk=$N("MicroMessenger"),qk=$N("UCBrowser"),Yk=$N("Electron"),Jk=$N("MiuiBrowser"),Xk=ZN("MiuiBrowser"),Qk=$N("HuaweiBrowser"),$k=$N("Huawei")||$N("HUAWEI"),Zk=$N("Honor")||$N("HONOR"),eO=ZN("HuaweiBrowser"),tO=$N("SamsungBrowser"),rO=ZN("SamsungBrowser"),iO=$N("HeyTapBrowser"),oO=ZN("HeyTapBrowser"),nO=$N("VivoBrowser"),aO=ZN("VivoBrowser"),sO=$N("OpenHarmony"),lO=ZN("OpenHarmony"),cO=()=>ek("Chrome"),dO=$N("CriOS"),uO=$N("Chrome"),hO=!fk&&!Ik&&!yk&&!Sk&&!bk&&!gk&&!xk&&!Jk&&!Qk&&!tO&&!iO&&!nO&&uO,pO=$N("HeadlessChrome"),mO=cO(),fO=ZN("Chrome"),_O=ek("Electron"),gO=!uO&&!Lk&&!Mk&&!Vk&&!Bk&&$N("Safari"),EO=gO||sk,vO=ZN("Version"),yO=/Android.*(wv|.0.0.0)/.test(QN),TO=(()=>{if(ok)return vO;if(sk){let e=QN.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function IO(e,t){let r=e.split(".").map((e=>Number(e))),i=t.split(".").map((e=>Number(e)));for(let o=0;o<Math.max(r.length,i.length);o++){let e=r[o]||0,t=i[o]||0;if(e<t)return!0;if(e>t)return!1}return!1}function AO(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.split(".").map((e=>Number(e))),o=t.split(".").map((e=>Number(e)));for(let n=0;n<Math.max(i.length,o.length);n++){let e=i[n]||0,t=o[n]||0;if(e>t)return!0;if(e<t)return!1}return r}var SO=Number(TO.split(".")[0]),RO="15.1"===vO,bO="15.1"===TO,wO=(()=>{let e=Number(TO.split(".")[0]);return 14===e||13===e})(),CO=dO&&"11.1.1"===vO,DO="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),NO=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(sM){e=!1}return e}})(),kO=OO();function OO(){let e=new Map([[hk,["Firefox",pk]],[gk,["Edg",Ek]],[hO,["Chrome",fO]],[dO,["ChiOS",ZN("CriOS")]],[gO&&!dO,["Safari",vO]],[Sk,["TBS",Rk]],[bk,["XWEB",wk]],[kk&&nk,["WeChat",Ok]],[xk,["QQ(Win)",Uk]],[Lk,["QQ(Mobile)",Pk]],[Mk,["QQ(Mobile X5)",Pk]],[Vk,["QQ(Mac)",Fk]],[Bk,["QQ(iPad)",Hk]],[Jk,["MI",Xk]],[Qk,["HW",eO]],[tO,["Samsung",rO]],[iO,["OPPO",oO]],[nO,["VIVO",aO]],[fk,["EDGE",_k]],[yk,["SogouMobile",Tk]],[Ik,["Sogou",Ak]]]),t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}var MO=null;function LO(){return MO&&"boolean"==typeof MO.mobile?MO.mobile:lk||sk||nk||ik||sO}var PO="";function xO(){return nw(this,null,(function*(){if(MO)return MO;if(!navigator.userAgentData||"function"!=typeof navigator.userAgentData.getHighEntropyValues)return null;try{return(MO=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]))&&!PO&&(PO="UAData: ".concat(MO.platform,"/").concat(MO.platformVersion),MO.architecture&&MO.bitness&&(PO+=" ".concat(MO.architecture,"/").concat(MO.bitness)),MO.mobile&&(PO+=" mobile"),MO.model&&(PO+=" model: ".concat(MO.model.replace(/\s+/g,"/"))),MO.fullVersionList&&(PO+=" ".concat(MO.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(",")))),MO}catch(OH){return null}}))}function UO(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return"";let r=t.getExtension("WEBGL_debug_renderer_info");if(r){let e=t.getParameter(r.UNMASKED_VENDOR_WEBGL),i=t.getParameter(r.UNMASKED_RENDERER_WEBGL);return"".concat(e," ").concat(i)}return""}catch(OH){return""}}function VO(){return(null==MO?void 0:MO.model)||FO()||""}function FO(){let e=QN.match(/;\s*([^;)]+)\s+Build\//);return null!=e&&e[1]?e[1].trim():null}var BO=new Map([[lk,"Android"],[sk,"iOS"],[Wk,"Windows"],[Gk,"MacOS"],[jk,"Linux"],[zk,"ChromeOS"]]),HO=function(){return BO.get(!0)?BO.get(!0):MO?MO.platform:"unknown"};function WO(){return Wk?1:lk?2:Gk?3:sk?4:jk?5:zk?6:sO?7:0}function GO(){return kk||bk?4:uO?1:gO?2:hk?3:0}var jO=()=>{let e=HO();return null!=MO&&MO.platformVersion?e+="/".concat(MO.platformVersion):sk?e+="/".concat(TO):lk&&(e+="/".concat(ck)),e+="/".concat(kO.name,"/").concat(gO&&!dO?kO.version:kO.version.split(".")[0]),null!=MO&&MO.architecture&&(e+="/".concat(MO.architecture)),e};function zO(){return lk?4:nk?2:ik?3:Gk?12:Wk?5:jk?13:sO?22:1}function KO(){return lk?"Android":nk?"iPhone":ik?"iPad":Gk?"Mac":Wk?"Windows":jk?"Linux":"unknown"}var qO,YO=new(tw(aw(),1).default),JO=((qO=JO||{}).ROOM_DESTROY="1",qO.JOIN_START="21",qO.JOIN_SCHEDULE_SUCCESS="22",qO.JOIN_SIGNAL_CONNECTION_START="23",qO.JOIN_SIGNAL_CONNECTION_END="24",qO.JOIN_SEND_CMD="25",qO.JOIN_RECEIVED_CMD_RES="26",qO.JOIN_SUCCESS="27",qO.JOIN_FAILED="28",qO.LEAVE_START="51",qO.LEAVE_SEND_CMD="52",qO.LEAVE_SUCCESS="53",qO.PUBLISH_START="61",qO.SEND_FIRST_VIDEO_FRAME="62",qO.PUBLISH_FAILED="63",qO.SUBSCRIBE_START="81",qO.SUBSCRIBE_SUCCESS="82",qO.SUBSCRIBE_FAILED="84",qO.UNSUBSCRIBE_SUCCESS="83",qO.LOCAL_TRACK_CAPTURE_START="101",qO.LOCAL_TRACK_CAPTURE_SUCCESS="102",qO.LOCAL_TRACK_CAPTURE_FAILED="103",qO.LOCAL_TRACK_PUBLISHED="104",qO.LOCAL_TRACK_UNPUBLISHED="105",qO.LOCAL_TRACK_REPLACED="106",qO.SWITCH_DEVICE_SUCCESS="107",qO.TRACK_MUTED="108",qO.TRACK_UNMUTED="109",qO.REMOTE_TRACK_SUBSCRIBED="110",qO.REMOTE_TRACK_UNSUBSCRIBED="111",qO.LOCAL_TRACK_RECAPTURE="112",qO.LOCAL_AUDIO_STARTED="113",qO.LOCAL_AUDIO_STOPPED="114",qO.REMOTE_AUDIO_STARTED="115",qO.REMOTE_AUDIO_STOPPED="116",qO.PLAY_TRACK_START="151",qO.PLAYER_STATE_CHANGED="152",qO.VIDEO_LOADED_DATA="153",qO.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",qO.AUDIO_CONTEXT_LONG_SUSPENDED="155",qO.REMOTE_VIDEO_PLAY_START="156",qO.REMOTE_VIDEO_PLAY_FINISH="157",qO.SIGNAL_CONNECTION_STATE_CHANGED="201",qO.PEER_CONNECTION_STATE_CHANGED="202",qO.SINGLE_CONNECTION_STAT="203",qO.SPC_RECONNECTED="204",qO.HEARTBEAT_REPORT="251",qO.RECEIVED_PUBLISHED_USER_LIST="252",qO.REMOTE_PUBLISH_STATE_CHANGED="253",qO.AUDIO_LEVEL_INTERVAL="260",qO.NETWORK_QUALITY="261",qO.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",qO.QUALITY_LIMITATION_CHANGED="263",qO.LOG="264",qO.AUDIO_PROCESSOR_DEBUG="265",qO.SSO_SWITCH="266",qO.SWITCH_ROOM_START="401",qO.SWITCH_ROOM_SUCCESS="407",qO.SWITCH_ROOM_FAILED="408",qO),XO=JO,QO=new class{constructor(){iw(this,"enable",!1),iw(this,"ssoFailCount",0),YO.on("22",(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.sso&&YO.emit("266",{enable:!0})})),YO.on("266",(e=>{let{enable:t}=e;this.enable=t}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&YO.emit("266",{enable:!1})}},$O=class e{constructor(){iw(this,"_isEnableUploadLog",!0),iw(this,"_localJoinedUser",new Map),iw(this,"_queue",[]),iw(this,"_timeoutId",-1),iw(this,"_logLevel",1),iw(this,"_logLevelToUpload",2),!bw&&!ww&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){YO.on(XO.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&jw[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),YO.on(XO.JOIN_START,(e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),YO.on(XO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:i,sdkAppId:o}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:o,logs:[r]})}));else if(zD(r.userId)&&KD(r.sdkAppId)){let{userId:t,sdkAppId:i}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:i,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return nw(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:r,sdkAppId:i,logs:o}=t[e],n={timestamp:gw(),sdkAppId:String(i),userId:r,version:Iw,log:o.map((e=>e.log)).join("\n")},a=JSON.stringify(n),s=QO.enable?MN(n,2002,i):a;yield this.uploadLogWithRetry(s,i,s instanceof Uint8Array,a),o.forEach((e=>e.uploaded=!0))}}catch(cM){}let r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}))}uploadLogWithRetry(e,t,r,i){return YN({retryFunction:()=>HN({url:SD(t,Ww.LOG),body:e,timeout:5e3,priority:"low"}).then((e=>{r&&"ok"!==e.data&&(QO.handleUploadFailed(),this.uploadLogWithRetry(i,t,!1,i))})),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(_w()),"[".concat(Ew(t),"] <").concat(jw[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){jD(jw[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(zD(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(Sw){return""}}addLogToQueue(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n={log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:i,sdkAppId:o,forAllJoinedClients:r};YO.emit(XO.LOG,{log:n}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(n)}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,i,o,n),t<this._logLevel)return;let s=(null==(a=jw[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...r):console[s](...r)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}createLogger(e){if(e.parent instanceof JN){let t=e,{parent:r}=t,i=((e,t)=>{var r={};for(var i in e)Kb.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&jb)for(var i of jb(e))t.indexOf(i)<0&&qb.call(e,i)&&(r[i]=e[i]);return r})(t,["parent"]),o=new JN(i);return o.bindParent(r),o}return new JN(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;jw[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};iw($O,"PRINT_LOG_TAG",!(sk||lk||pO));var ZO=new $O,eM=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{let t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))},tM=new class{constructor(){iw(this,"_prefix","TRTC"),iw(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){NO()&&(setInterval(this.doFlush.bind(this),2e4),Object.keys(localStorage).filter((e=>{if(e.startsWith(this._prefix))try{let t=localStorage.getItem(e);if(!t)return!1;let r=JSON.parse(t);if(r&&r.expiresIn<Date.now())return!0}catch(cM){return!1}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(NO())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(sM){ZO.warn(sM)}}getItem(e){if(!NO())return null;try{let t=localStorage.getItem(this.getRealKey(e));if(!t)return null;let r=JSON.parse(t);return r&&r.expiresIn>=Date.now()?r.value:null}catch(Sw){ZO.warn(Sw)}}setItem(e,t){if(NO())try{let r={expiresIn:Date.now()+Yw,value:t};this._queue.set(this.getRealKey(e),r)}catch(CC){ZO.warn(CC)}}deleteItem(e){if(!NO())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(Sw){return ZO.warn(Sw),!1}}clear(){if(NO())try{localStorage.clear()}catch(sM){ZO.warn(sM)}}},rM={};ew(rM,{HTTPS_API:()=>jL,IS_GET_CAPABILITIES_FROM_INPUTDEVICE_SUPPORTED:()=>hP,IS_GET_CAPABILITIES_SUPPORTED:()=>uP,IS_GET_SETTINGS_SUPPORTED:()=>dP,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>cP,IS_INSERTABLE_STREAM_SUPPORTED:()=>pP,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>bP,IS_RTC_RTP_SENDER_SUPPORTED:()=>aP,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>mP,IS_SEI_SUPPORTED:()=>fP,IS_SPC_SUPPORTED:()=>oP,basis:()=>TP,capabilityCheck:()=>SP,checkSystemRequirementsInternal:()=>VL,decodeSupportStatus:()=>UL,detectVideoCodecCapabilities:()=>DP,detectVideoDecoderCapabilities:()=>kP,detectVideoEncoderCapabilities:()=>NP,encodeSupportStatus:()=>xL,getBrowserInfo:()=>CL,getDisplayResolution:()=>KL,getH264ProfileLevelIds:()=>OP,isAddTransceiverSupported:()=>iP,isBrowserSupported:()=>DL,isCanvasCaptureStreamAPISupported:()=>JL,isCanvasSmallStreamSupported:()=>XL,isGetReceiversSupported:()=>eP,isGetSendersSupported:()=>tP,isGetTransceiversSupported:()=>rP,isGetUserMediaSupported:()=>qL,isMediaDevicesSupported:()=>kL,isMediaSessionSupported:()=>EP,isMediaStreamTrackGeneratorSupported:()=>PL,isMediaStreamTrackProcessorSupported:()=>LL,isReplaceTrackSupported:()=>sP,isRequestVideoFrameCallbackSupported:()=>RP,isSIMDSupported:()=>yP,isScaleResolutionDownBySupported:()=>QL,isScreenCaptureApiAvailable:()=>BL,isSelectedCandidatePair:()=>zL,isSetParametersSupported:()=>lP,isSetSinkIdSupported:()=>HL,isSmallStreamSupported:()=>$L,isStopTransceiverSupported:()=>nP,isTRTCSupported:()=>FL,isUnifiedPlanDefault:()=>ZL,isUsedInHttpProtocol:()=>ML,isWebAudioSupported:()=>YL,isWebCodecSupported:()=>gP,isWebCodecsSupported:()=>NL,isWebRTCSupported:()=>_P,isWebTransportSupported:()=>vP});var iM={};ew(iM,{AUDIO_LEVEL_SCALE:()=>JM,AlphaStitchingType:()=>cL,AudioCodecPipelineType:()=>tL,AudioDecoderDowngradeState:()=>NM,AudioPlayerMode:()=>KM,AudioType:()=>xM,BASIC_TYPE:()=>$M,BannedReason:()=>qM,CONNECTION_CLOSED_REASON:()=>gM,CheckPermissionType:()=>sL,ClientEvent:()=>EM,CodecType:()=>rL,ConnectionEvent:()=>_M,ConnectionState:()=>DM,DECODE_FAILED_ERROR_CODE:()=>iL,DenoiserMode:()=>XM,DeviceType:()=>lL,FacingMode:()=>jM,FrameWorkType:()=>fM,LeaveReason:()=>YM,LocalTrackEvent:()=>yM,MULTI_VIDEO_DATA_TYPE:()=>BM,MediaType:()=>LM,MediaTypeLabel:()=>PM,MonitorEventId:()=>HM,MutedFlag:()=>RM,NetworkQualityValue:()=>WM,PlayerState:()=>TM,ReceiveMode:()=>GM,RemoteStreamType:()=>FM,RemoteTrackEvent:()=>SM,RoomEvent:()=>IM,SMALL_MODE:()=>aL,SceneNumber:()=>bM,StreamEvent:()=>vM,StreamType:()=>VM,SubscribeMediaType:()=>QM,TIMER_TYPE:()=>nL,TRACK_ACTION:()=>MM,TRACK_KIND:()=>OM,TrackEvent:()=>AM,UserRole:()=>CM,UserRoleNumber:()=>wM,VideoCodec:()=>ZM,VideoCodecPipelineType:()=>eL,VideoContentHint:()=>oL,VideoDecoderDowngradeState:()=>kM,VideoPlayerMode:()=>zM,VideoType:()=>UM});var oM,nM,aM,sM,lM,cM,dM,uM,hM,pM,mM,fM=(e=>(e[e.WEBRTC=30]="WEBRTC",e[e.WASM=37]="WASM",e))(fM||{}),_M=((mM=_M||{}).TRACK_ADDED="track-added",mM.TRACK_UPDATED="track-updated",mM.TRACK_SUBSCRIBED="track-subscribed",mM.STREAM_ADDED="stream-added",mM.STREAM_REMOVED="stream-removed",mM.STREAM_UPDATED="stream-updated",mM.STREAM_PUBLISHED="stream-published",mM.STREAM_SUBSCRIBED="stream-subscribed",mM.STREAM_UNSUBSCRIBED="stream-unsubscribed",mM.STATE_CHANGED="state-changed",mM.ERROR="error",mM.CONNECTION_STATE_CHANGED="connection-state-changed",mM.FIREWALL_RESTRICTION="firewall-restriction",mM.SEI_MESSAGE="sei-message",mM.CLOSED="closed",mM),gM=(e=>(e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e))(gM||{}),EM=((pM=EM||{}).STREAM_ADDED="stream-added",pM.STREAM_REMOVED="stream-removed",pM.STREAM_UPDATED="stream-updated",pM.STREAM_SUBSCRIBED="stream-subscribed",pM.CONNECTION_STATE_CHANGED="connection-state-changed",pM.PEER_JOIN="peer-join",pM.PEER_LEAVE="peer-leave",pM.MUTE_AUDIO="mute-audio",pM.MUTE_VIDEO="mute-video",pM.UNMUTE_AUDIO="unmute-audio",pM.UNMUTE_VIDEO="unmute-video",pM.CLIENT_BANNED="client-banned",pM.NETWORK_QUALITY="network-quality",pM.AUDIO_VOLUME="audio-volume",pM.SEI_MESSAGE="sei-message",pM.ERROR="error",pM),vM=((hM=vM||{}).PLAYER_STATE_CHANGED="player-state-changed",hM.SCREEN_SHARING_STOPPED="screen-sharing-stopped",hM.CONNECTION_STATE_CHANGED="connection-state-changed",hM.DEVICE_AUTO_RECOVERED="device-auto-recovered",hM.ERROR="error",hM),yM=((uM=yM||{}).DEVICE_AUTO_RECOVERED="1",uM.DEVICE_RECOVER_FAILED="5",uM.DEVICE_CHANGED="2",uM.ERROR="3",uM.PUBLISH_STATE_CHANGED="4",uM.ENCODE_FAILED="6",uM.TRACK_ENDED="7",uM.RENDER="render",uM),TM=(e=>(e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e))(TM||{}),IM=((dM=IM||{}).PEER_JOIN="peer-join",dM.PEER_LEAVE="peer-leave",dM.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",dM.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",dM.BANNED="banned",dM.NETWORK_QUALITY="network-quality",dM.AUDIO_VOLUME="audio-volume",dM.SEI_MESSAGE="sei-message",dM.ERROR="error",dM.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",dM.REMOTE_PUBLISHED="remote-published",dM.REMOTE_UNPUBLISHED="remote-unpublished",dM.FIREWALL_RESTRICTION="firewall-restriction",dM.HEARTBEAT_REPORT="heartbeat-report",dM.CUSTOM_MESSAGE="custom-message",dM.LAYER_DATA="layerData",dM.FIRST_VIDEO_FRAME="first-video-frame",dM.DUMP="dump",dM.AUDIO_FRAME="audio-frame",dM.SUBSCRIBE_SMALL_VIDEO_CHANGED="subscribe-small-video-changed",dM.LOCAL_PUBLISH_FLAG_CHANGED="local-publish-flag-changed",dM.NTP_TIME_UPDATED="ntp-time-updated",dM),AM=(e=>(e.PLAYER_STATE_CHANGED="player-state-changed",e.MUTE="mute",e.UNMUTE="unmute",e.ERROR="error",e.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",e.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",e.FIRST_VIDEO_FRAME="first-video-frame",e.VIDEO_SIZE_CHANGED="video-size-changed",e))(AM||{}),SM=((cM=SM||{}).DECODE_FAILED="decode-failed",cM.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",cM.REMOTE_PUBLISH_CHANGED="remote-publish-changed",cM.AUDIO_FRAME_WITH_NTP="audio-frame-with-ntp",cM),RM=((lM=RM||{})[lM.VIDEO=1]="VIDEO",lM[lM.SMALL=2]="SMALL",lM[lM.AUX=4]="AUX",lM[lM.AUDIO=8]="AUDIO",lM[lM.VIDEO_MUTE=16]="VIDEO_MUTE",lM[lM.AUX_MUTE=32]="AUX_MUTE",lM[lM.AUDIO_MUTE=64]="AUDIO_MUTE",lM),bM=(e=>(e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e))(bM||{}),wM=(e=>(e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e))(wM||{}),CM=(e=>(e.ANCHOR="anchor",e.AUDIENCE="audience",e))(CM||{}),DM=(e=>(e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e))(DM||{}),NM=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(NM||{}),kM=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(kM||{}),OM=(e=>(e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e))(OM||{}),MM=(e=>(e.ADD="add",e.REMOVE="remove",e))(MM||{}),LM=(e=>(e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e))(LM||{}),PM={1:"audio",2:"auxVideo",4:"video"},xM=((sM=xM||{})[sM.opus=111]="opus",sM),UM=(e=>(e[e.h264=100]="h264",e[e.vp8=101]="vp8",e))(UM||{}),VM=(e=>(e.Big="big",e.Small="small",e))(VM||{}),FM=(e=>(e.Main="main",e.Aux="auxiliary",e))(FM||{}),BM=(e=>(e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e))(BM||{}),HM=((aM=HM||{})[aM.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",aM[aM.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",aM[aM.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",aM[aM.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",aM[aM.MUTE_AUDIO=32772]="MUTE_AUDIO",aM[aM.MUTE_VIDEO=32773]="MUTE_VIDEO",aM[aM.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",aM[aM.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",aM[aM.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",aM[aM.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",aM[aM.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",aM[aM.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",aM[aM.SWITCH_CAMERA=32780]="SWITCH_CAMERA",aM[aM.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",aM[aM.REPLACE_VIDEO=32782]="REPLACE_VIDEO",aM[aM.REPLACE_AUDIO=32783]="REPLACE_AUDIO",aM[aM.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",aM[aM.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",aM[aM.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",aM[aM.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",aM[aM.JOIN=32788]="JOIN",aM[aM.LEAVE=32789]="LEAVE",aM[aM.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",aM[aM.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",aM[aM.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",aM[aM.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",aM[aM.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",aM[aM.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",aM[aM.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",aM[aM.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",aM[aM.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",aM[aM.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",aM[aM.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",aM[aM.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",aM[aM.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",aM[aM.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",aM[aM.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",aM[aM.PUBLISH_AUX=32805]="PUBLISH_AUX",aM[aM.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",aM[aM.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",aM[aM.VIDEO_ENCODER=4004]="VIDEO_ENCODER",aM[aM.VIDEO_DECODER=4005]="VIDEO_DECODER",aM),WM=(e=>(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.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e))(WM||{}),GM=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e))(GM||{}),jM=(e=>(e.user="user",e.environment="environment",e))(jM||{}),zM=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e))(zM||{}),KM=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e))(KM||{}),qM=(e=>(e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e))(qM||{}),YM=((nM=YM||{})[nM.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",nM[nM.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",nM[nM.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",nM[nM.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",nM[nM.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",nM[nM.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",nM[nM.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",nM[nM.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",nM[nM.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",nM),JM=1e8,XM=(e=>(e[e.NORMAL=0]="NORMAL",e[e.FAR_FIELD_REDUCTION=1]="FAR_FIELD_REDUCTION",e))(XM||{}),QM=class{constructor(){iw(this,"mediaType",0)}set audio(e){e?this.mediaType|=1:this.mediaType&=-2}get audio(){return!!(1&this.mediaType)}set video(e){e?this.mediaType|=4:this.mediaType&=-5}get video(){return!!(4&this.mediaType)}set auxiliary(e){e?this.mediaType|=2:this.mediaType&=-3}get auxiliary(){return!!(2&this.mediaType)}set smallVideo(e){e?this.mediaType|=8:this.mediaType&=-9}get smallVideo(){return!!(8&this.mediaType)}},$M=(e=>(e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e))($M||{}),ZM=(e=>(e.H264="h264",e.H265="h265",e.VP8="vp8",e.VP9="vp9",e.AV1="av1",e))(ZM||{}),eL=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(eL||{}),tL=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(tL||{}),rL=(e=>(e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e))(rL||{}),iL=((oM=iL||{})[oM.SUCCESS=0]="SUCCESS",oM[oM.FAILED=1]="FAILED",oM[oM.WEBCODEC_INIT=2]="WEBCODEC_INIT",oM[oM.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",oM[oM.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",oM[oM.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",oM[oM.WASM_INIT=6]="WASM_INIT",oM[oM.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",oM[oM.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",oM[oM.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",oM[oM.TEST=10]="TEST",oM[oM.RENDER_2D_ERROR=11]="RENDER_2D_ERROR",oM),oL=(e=>(e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e))(oL||{}),nL=(e=>(e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e))(nL||{}),aL=(e=>(e.CANVAS="canvas",e.API="api",e))(aL||{}),sL=(e=>(e[e.NONE=0]="NONE",e[e.MICROPHONE=1]="MICROPHONE",e[e.CAMERA=2]="CAMERA",e[e.BOTH=3]="BOTH",e))(sL||{}),lL=(e=>(e.CAMERA="camera",e.MICROPHONE="microphone",e))(lL||{}),cL=(e=>(e[e.none=0]="none",e[e.horizontal=1]="horizontal",e[e.vertical=2]="vertical",e))(cL||{}),dL={AVOID_REPEATED_CALL:"AVOID_REPEATED_CALL",INVALID_PARAMETER_REQUIRED:"INVALID_PARAMETER_REQUIRED",INVALID_PARAMETER_TYPE:"INVALID_PARAMETER_TYPE",INVALID_PARAMETER_EMPTY:"INVALID_PARAMETER_EMPTY",INVALID_PARAMETER_INSTANCE:"INVALID_PARAMETER_INSTANCE",INVALID_PARAMETER_RANGE:"INVALID_PARAMETER_RANGE",INVALID_PARAMETER_MIN:"INVALID_PARAMETER_MIN",INVALID_PARAMETER_MAX:"INVALID_PARAMETER_MAX",INVALID_PARAMETER_STREAMTYPE:"INVALID_PARAMETER_STREAMTYPE",API_CALL_TIMEOUT:"API_CALL_TIMEOUT",SIGNAL_CHANNEL_RECONNECTION_FAILED:"SIGNAL_CHANNEL_RECONNECTION_FAILED",SIGNAL_CHANNEL_SETUP_FAILED:"SIGNAL_CHANNEL_SETUP_FAILED",ERROR_MESSAGE:"ERROR_MESSAGE",EXCHANGE_SDP_TIMEOUT:"EXCHANGE_SDP_TIMEOUT",DOWNLINK_RECONNECTION_FAILED:"DOWNLINK_RECONNECTION_FAILED",EXCHANGE_SDP_FAILED:"EXCHANGE_SDP_FAILED",UPDATE_OFFER_TIMEOUT:"UPDATE_OFFER_TIMEOUT",UPLINK_RECONNECTION_FAILED:"UPLINK_RECONNECTION_FAILED",INVALID_RECORDID:"INVALID_RECORDID",INVALID_PURE_AUDIO:"INVALID_PURE_AUDIO",INVALID_STREAMID:"INVALID_STREAMID",INVALID_USER_DEFINE_RECORDID:"INVALID_USER_DEFINE_RECORDID",INVALID_USER_DEFINE_PUSH_ARGS:"INVALID_USER_DEFINE_PUSH_ARGS",INVALID_PROXY:"INVALID_PROXY",INVALID_JOIN:"INVALID_JOIN",INVALID_ROOMID_STRING:"INVALID_ROOMID_STRING",INVALID_ROOMID_INTEGER:"INVALID_ROOMID_INTEGER",INVALID_SIGNAL_CHANNEL:"INVALID_SIGNAL_CHANNEL",JOIN_ROOM_TIMEOUT:"JOIN_ROOM_TIMEOUT",JOIN_ROOM_FAILED:"JOIN_ROOM_FAILED",REJOIN_ROOM_FAILED:"REJOIN_ROOM_FAILED",INVALID_DESTROY:"INVALID_DESTROY",INVALID_PUBLISH:"INVALID_PUBLISH",INVALID_UNPUBLISH:"INVALID_UNPUBLISH",INVALID_AUDIENCE:"INVALID_AUDIENCE",INVALID_INITIALIZE:"INVALID_INITIALIZE",INVALID_DUPLICATE_PUBLISHING:"INVALID_DUPLICATE_PUBLISHING",INVALID_SUBSCRIBE_UNDEFINED:"INVALID_SUBSCRIBE_UNDEFINED",INVALID_SUBSCRIBE_LOCAL:"INVALID_SUBSCRIBE_LOCAL",INVALID_REMOTE_STREAM:"INVALID_REMOTE_STREAM",SUBSCRIBE_FAILED:"SUBSCRIBE_FAILED",INVALID_ROLE:"INVALID_ROLE",INVALID_PARAMETER_SWITCH_ROLE:"INVALID_PARAMETER_SWITCH_ROLE",INVALID_OPERATION_SWITCH_ROLE:"INVALID_OPERATION_SWITCH_ROLE",SWITCH_ROLE_TIMEOUT:"SWITCH_ROLE_TIMEOUT",SWITCH_ROLE_FAILED:"SWITCH_ROLE_FAILED",CLIENT_BANNED:"CLIENT_BANNED",INVALID_OPERATION_START_PUBLISH_CDN:"INVALID_OPERATION_START_PUBLISH_CDN",INVALID_OPERATION_STOP_PUBLISH_CDN:"INVALID_OPERATION_STOP_PUBLISH_CDN",INVALID_STREAM_ID:"INVALID_STREAM_ID",START_PUBLISH_CDN_FAILED:"START_PUBLISH_CDN_FAILED",STOP_PUBLISH_CDN_FAILED:"STOP_PUBLISH_CDN_FAILED",START_MIX_TRANSCODE:"START_MIX_TRANSCODE",STOP_MIX_TRANSCODE:"STOP_MIX_TRANSCODE",INVALID_AUDIO_VOLUME:"INVALID_AUDIO_VOLUME",ENABLE_SMALL_STREAM_PUBLISHED:"ENABLE_SMALL_STREAM_PUBLISHED",DISABLE_SMALL_STREAM_PUBLISHED:"DISABLE_SMALL_STREAM_PUBLISHED",NOT_SUPPORTED_SMALL_STREAM:"NOT_SUPPORTED_SMALL_STREAM",INVALID_SMALL_STREAM_PROFILE:"INVALID_SMALL_STREAM_PROFILE",INVALID_PARAMETER_REMOTE_STREAM:"INVALID_PARAMETER_REMOTE_STREAM",INVALID_OPERATION_CHANGE_SMALL:"INVALID_OPERATION_CHANGE_SMALL",REMOTE_NOT_PUBLISH_SMALL_STREAM:"REMOTE_NOT_PUBLISH_SMALL_STREAM",INVALID_SWITCH_DEVICE:"INVALID_SWITCH_DEVICE",INVALID_SWITCH_DEVICE_PUBLISHING:"INVALID_SWITCH_DEVICE_PUBLISHING",INVALID_REPLACE_TRACK:"INVALID_REPLACE_TRACK",INVALID_INITIALIZE_LOCAL_STREAM:"INVALID_INITIALIZE_LOCAL_STREAM",INVALID_ADD_TRACK_REPETITIVE:"INVALID_ADD_TRACK_REPETITIVE",INVALID_ADD_TRACK_REMOVING:"INVALID_ADD_TRACK_REMOVING",INVALID_ADD_TRACK_PUBLISHING:"INVALID_ADD_TRACK_PUBLISHING",INVALID_STREAM_INITIALIZED:"INVALID_STREAM_INITIALIZED",INVALID_ADD_TRACK_NUMBER:"INVALID_ADD_TRACK_NUMBER",INVALID_REMOVE_AUDIO_TRACK:"INVALID_REMOVE_AUDIO_TRACK",INVALID_REMOVE_AUDIO_ADDING:"INVALID_REMOVE_AUDIO_ADDING",INVALID_REMOVE_AUDIO_ON:"INVALID_REMOVE_AUDIO_ON",INVALID_REMOVE_TRACK_PUBLISHING:"INVALID_REMOVE_TRACK_PUBLISHING",INVALID_REMOVE_TRACK_NOT_TRACK:"INVALID_REMOVE_TRACK_NOT_TRACK",INVALID_REMOVE_TRACK_NUMBER:"INVALID_REMOVE_TRACK_NUMBER",INVALID_REPLACE_TRACK_NO_TRACK:"INVALID_REPLACE_TRACK_NO_TRACK",REPEAT_JOIN:"REPEAT_JOIN",CLIENT_DESTROYED:"CLIENT_DESTROYED",NOT_BUG_PACKAGE:"NOT_BUG_PACKAGE",START_MIX_TRANSCODE_FAILED:"START_MIX_TRANSCODE_FAILED",STOP_MIX_TRANSCODE_FAILED:"STOP_MIX_TRANSCODE_FAILED",MIX_TRANSCODE_NOT_STARTED:"MIX_TRANSCODE_NOT_STARTED",CANNOT_LESS_THAN_ZERO:"CANNOT_LESS_THAN_ZERO",MIX_PARAMS_VIDEO_FRAMERATE:"MIX_PARAMS_VIDEO_FRAMERATE",MIX_PARAMS_VIDEO_GOP:"MIX_PARAMS_VIDEO_GOP",MIX_PARAMS_AUDIO_BITRATE:"MIX_PARAMS_AUDIO_BITRATE",MIX_PARAMS_USER_Z_ORDER:"MIX_PARAMS_USER_Z_ORDER",MIX_PARAMS_NOT_SELF:"MIX_PARAMS_NOT_SELF",MIX_PARAMS_USER_STREAM:"MIX_PARAMS_USER_STREAM",INVALID_PLAY:"INVALID_PLAY",INVALID_ELEMENT_ID:"INVALID_ELEMENT_ID",INVALID_ELEMENT_ID_TYPE:"INVALID_ELEMENT_ID_TYPE",PLAY_FAILED:"PLAY_FAILED",INVALID_USERID:"INVALID_USERID",INVALID_CREATE_STREAM_SOURCE:"INVALID_CREATE_STREAM_SOURCE",INVALID_CREATE_STREAM_SCREEN:"INVALID_CREATE_STREAM_SCREEN",INVALID_CREATE_STREAM_AUDIO:"INVALID_CREATE_STREAM_AUDIO",INVALID_CREATE_STREAM_SCREEN_AUDIO:"INVALID_CREATE_STREAM_SCREEN_AUDIO",NOT_SUPPORTED_HTTP:"NOT_SUPPORTED_HTTP",NOT_SUPPORTED_WEBRTC:"NOT_SUPPORTED_WEBRTC",NOT_SUPPORTED_PROFILE:"NOT_SUPPORTED_PROFILE",NOT_SUPPORTED_MEDIA:"NOT_SUPPORTED_MEDIA",NOT_SUPPORTED_H264ENCODE:"NOT_SUPPORTED_H264ENCODE",NOT_SUPPORTED_H264DECODE:"NOT_SUPPORTED_H264DECODE",NOT_SUPPORTED_TRACK:"NOT_SUPPORTED_TRACK",NOT_SUPPORTED_SWITCH_DEVICE:"NOT_SUPPORTED_SWITCH_DEVICE",NOT_SUPPORTED_CAPTURE:"NOT_SUPPORTED_CAPTURE",NOT_SUPPORTED_AUX:"NOT_SUPPORTED_AUX",MICROPHONE_NOT_FOUND:"MICROPHONE_NOT_FOUND",CAMERA_NOT_FOUND:"CAMERA_NOT_FOUND",SIGNAL_RESPONSE_FAILED:"SIGNAL_RESPONSE_FAILED",CATCH_HANDLER_ERROR:"CATCH_HANDLER_ERROR",API_NOT_EXIST:"API_NOT_EXIST",CONNECTION_CLOSED:"CONNECTION_CLOSED",SUBSCRIBE_ALL_FALSE:"SUBSCRIBE_ALL_FALSE",SEI_NOT_SUPPORT:"SEI_NOT_SUPPORT",SEI_DISABLED:"SEI_DISABLED",SEI_BEFORE_PUBLISH:"SEI_BEFORE_PUBLISH",SEI_NOT_VIDEO:"SEI_NOT_VIDEO",CALL_FREQUENCY_LIMIT:"CALL_FREQUENCY_LIMIT",CONNECTION_ABORTED:"CONNECTION_ABORTED",API_CALL_ABORTED:"API_CALL_ABORTED",DUPLICATE_AUX:"DUPLICATE_AUX"},uL={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(WD(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(WD(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(o,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(o,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:r}=e;return"Failed to join room - ".concat(t," code: ").concat(r)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:r,streamType:i}=e;return"failed to subscribe ".concat(r," ").concat(i," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},PLAY_FAILED:e=>"".concat(e.media," play failed, browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:r}=e;return"an error was caught in ".concat(t,".on('").concat(r,"', handler), please check your code in 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"please avoid repeated join.",CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:r,timesInSecond:i,maxSizeInSecond:o}=e;return"api ".concat(r," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(o," bytes"):i," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},hL=(e,t)=>t?"".concat(Pw,"/").concat(e,"/").concat(t):"".concat(Pw,"/").concat(e,"/index.html"),pL=()=>{if(window.TRTC_ERROR_INFO&&window.TRTC_ERROR_LINK)return{TRTC_ERROR_INFO:window.TRTC_ERROR_INFO,TRTC_ERROR_LINK:window.TRTC_ERROR_LINK};let e=null==localStorage?void 0:localStorage.getItem(Hw);if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let r=window.TRTC_ERROR_INFO,i=window.TRTC_ERROR_LINK;return document.body.removeChild(t),{TRTC_ERROR_INFO:r,TRTC_ERROR_LINK:i}}return{}};function mL(e){let{key:t,data:r,link:i,addDocLink:o=!0}=e,n="",a="",s="";GD(uL[t])?n=uL[t](r):zD(uL[t])&&(n=uL[t]);let{TRTC_ERROR_INFO:l,TRTC_ERROR_LINK:c}=pL();i?s="".concat(i.className,".html#").concat(i.fnName):c&&c[t]&&(GD(c[t])?s=c[t](r):zD(c[t])&&(s=c[t]));let d=n;return VD()&&(l&&l[t]&&(GD(l[t])?a=l[t](r):zD(l[t])&&(a=l[t])),a&&(d=o?"".concat(a,"\n请查看文档: ").concat(hL("zh-cn",s),"\n\n"):"".concat(a,"\n\n"),d+=n)),o&&(d+=" \nRefer to: ".concat(hL("en",s),"\n")),d}var fL,_L=tw(dw(),1),gL=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];iw(this,"countMap",new Map),iw(this,"distributionMap",new Map),iw(this,"version"),iw(this,"log",ZO.createLogger({id:"kv"})),e&&(YO.on("102",(e=>{let{track:t,cost:r}=e;this.addSuccessEvent({key:t.kind===eC.AUDIO?501700:511700,cost:r})})),YO.on("103",(e=>{let{track:t,error:r}=e;this.addFailedEvent({key:t.kind===eC.AUDIO?501700:511700,error:r})})),YO.on("266",(e=>{let{enable:t}=e;this.log.info("".concat(t?"enable":"disable"," sso")),t?this.addSuccessEvent({key:525701}):this.addFailedEvent({key:525701})})))}getReportData(e,t){let r={msg_sdk_basic_info:{uint32_sdk_version:IN(this.version||Iw),uint32_terminal_type:15,bytes_device_name:"",bytes_os_version:"",uint32_framework:30,uint32_network_type:0},stats_count:[...this.countMap.entries()].map((e=>{let[t,r]=e;return{uint32_key:t,uint32_count:r}})),stats_distribution:[...this.distributionMap.entries()].map((e=>{let[t,r]=e;return{uint32_key:t,distribution_items:[...r.entries()].map((e=>{let[t,r]=e;return{uint32_item_key:t,uint32_item_value:r}}))}})),str_user_sig:e,bytes_report_token:t};return this.countMap.clear(),this.distributionMap.clear(),r}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:r=!1}=e;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:r,useUV:i=!0}=e;var o;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(i&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let n=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map;n.set(r,(n.get(r)||0)+1),this.distributionMap.set(t,n)}addNumber(e){let{key:t,value:r,split:i=100,useUV:o=!1,max:n=5e3}=e;var a;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(o&&this.countMap.has(t))return;r>n&&(r=n),this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(a=this.distributionMap)?void 0:a.get(t))||new Map,l=0;if(KD(i))l=Math.floor(r/i);else for(let c=i.length-1;c>0;c--)if(r>i[c]){l=c;break}s.set(l,(s.get(l)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:r,timeKey:i,split:o}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),r)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:i||t+100,value:r,split:o}):i||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:r}=e;if(!t)return;let i=hw.UNKNOWN;r&&(KD(r)?i=r:(!jD(r.extraCode)||!jD(r.code))&&(i=r.extraCode||r.code)),this.addEnum({key:t,value:0,useUV:!1}),this.addEnum({key:t,value:Math.abs(i),useUV:!1})}},EL=(e=>(e[e.enterRoom=500700]="enterRoom",e[e.exitRoom=500701]="exitRoom",e[e.switchRole=500702]="switchRole",e[e.destroy=500703]="destroy",e[e.startLocalAudio=500704]="startLocalAudio",e[e.updateLocalAudio=500705]="updateLocalAudio",e[e.stopLocalAudio=500706]="stopLocalAudio",e[e.startLocalVideo=500707]="startLocalVideo",e[e.updateLocalVideo=500708]="updateLocalVideo",e[e.stopLocalVideo=500709]="stopLocalVideo",e[e.startScreenShare=500710]="startScreenShare",e[e.updateScreenShare=500711]="updateScreenShare",e[e.stopScreenShare=500712]="stopScreenShare",e[e.startRemoteVideo=500713]="startRemoteVideo",e[e.updateRemoteVideo=500714]="updateRemoteVideo",e[e.stopRemoteVideo=500715]="stopRemoteVideo",e[e.muteRemoteAudio=500716]="muteRemoteAudio",e[e.setRemoteAudioVolume=500717]="setRemoteAudioVolume",e[e.use=500718]="use",e[e.switchRoom=500719]="switchRoom",e[e.sendSEIMessage=5e5]="sendSEIMessage",e[e.sendCustomMessage=500001]="sendCustomMessage",e))(EL||{}),vL=(e=>(e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e[e.SmallStreamAutoSwitcher=593700]="SmallStreamAutoSwitcher",e[e.VideoMixer=594700]="VideoMixer",e[e.AudioProcessor=595700]="AudioProcessor",e))(vL||{}),yL=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e[e.SmallStreamAutoSwitcher=593701]="SmallStreamAutoSwitcher",e[e.VideoMixer=594701]="VideoMixer",e[e.AudioProcessor=595701]="AudioProcessor",e))(yL||{}),TL=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e[e.SmallStreamAutoSwitcher=593702]="SmallStreamAutoSwitcher",e[e.VideoMixer=594702]="VideoMixer",e[e.AudioProcessor=595702]="AudioProcessor",e))(TL||{}),IL=((fL=IL||{})[fL.DECODER_TYPE=514700]="DECODER_TYPE",fL[fL.DECODER_HW_SW=514701]="DECODER_HW_SW",fL[fL.DECODE_RESULT=514702]="DECODE_RESULT",fL[fL.DECODE_FAILED_OS=514703]="DECODE_FAILED_OS",fL[fL.DOWNGRADE_RESULT=514704]="DOWNGRADE_RESULT",fL[fL.DOWNGRADE_WEBCODECS_VIDEO=514705]="DOWNGRADE_WEBCODECS_VIDEO",fL[fL.DOWNGRADE_WEBCODECS_2D=514706]="DOWNGRADE_WEBCODECS_2D",fL[fL.DOWNGRADE_WASM_WEGBL=514707]="DOWNGRADE_WASM_WEGBL",fL[fL.DOWNGRADE_WASM_VIDEO=514708]="DOWNGRADE_WASM_VIDEO",fL[fL.DOWNGRADE_WASM_2D=514709]="DOWNGRADE_WASM_2D",fL[fL.DECODE_H264_RESULT=514710]="DECODE_H264_RESULT",fL[fL.DECODE_H265_RESULT=514711]="DECODE_H265_RESULT",fL[fL.DECODE_VP8_RESULT=514712]="DECODE_VP8_RESULT",fL[fL.DECODE_CAPABILITIES=514713]="DECODE_CAPABILITIES",fL[fL.H264_PROFILE_LEVEL_ID_HIGH=514714]="H264_PROFILE_LEVEL_ID_HIGH",fL[fL.H264_PROFILE_LEVEL_ID_MAIN=514715]="H264_PROFILE_LEVEL_ID_MAIN",fL[fL.RENDER_FREEZE_RATE=514850]="RENDER_FREEZE_RATE",fL[fL.DATA_FREEZE_RATE=514851]="DATA_FREEZE_RATE",fL[fL.VIDEO_CONSUME_RENDER_RATE=514852]="VIDEO_CONSUME_RENDER_RATE",fL),AL=new gL(!0),SL=new gL(!1),RL=AL,bL={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}},wL=new Map([[hk,["Firefox",pk]],[gk,["Edg",Ek]],[hO,["Chrome",fO]],[gO,["Safari",vO]],[Sk,["TBS",Rk]],[bk,["XWEB",wk]],[kk&&nk,["WeChat",Ok]],[xk,["QQ(Win)",Uk]],[Lk,["QQ(Mobile)",Pk]],[Mk,["QQ(Mobile X5)",Pk]],[Vk,["QQ(Mac)",Fk]],[Bk,["QQ(iPad)",Hk]],[Jk,["MI",Xk]],[Qk,["HW",eO]],[tO,["Samsung",rO]],[iO,["OPPO",oO]],[nO,["VIVO",aO]],[fk,["EDGE",_k]],[yk,["SogouMobile",Tk]],[Ik,["Sogou",Ak]]]);function CL(){let e=wL.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var DL=function(){return!(qk||fk||gk&&vk<80||hk&&mk<56)},NL=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every((e=>e in window))},kL=function(){if(!navigator.mediaDevices)return ML()||ZO.error(uL.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},OL=!1;function ML(){return"http:"===location.protocol&&!DO&&(OL||ZO.error(mL({key:dL.NOT_SUPPORTED_HTTP})),OL=!0,!0)}var LL=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},PL=function(){return!(null==window||!window.MediaStreamTrackGenerator)},xL=function(){return nw(this,null,(function*(){var e,t,r;if(bL.detail.isH264EncodeSupported&&bL.detail.isVp8EncodeSupported)return{isH264EncodeSupported:bL.detail.isH264EncodeSupported,isVp8EncodeSupported:bL.detail.isVp8EncodeSupported,isH265EncodeSupported:bL.detail.isH265EncodeSupported};let i,o=!1,n=!1,a=!1;try{let s=new RTCPeerConnection,l=document.createElement(eC.CANVAS);l.getContext("2d");let c=l.captureStream(0);return s.addTrack(c.getVideoTracks()[0],c),i=yield s.createOffer(),o=-1!==(null==(e=i.sdp)?void 0:e.toLowerCase().indexOf("h264")),n=-1!==(null==(t=i.sdp)?void 0:t.toLowerCase().indexOf("vp8")),a=-1!==(null==(r=i.sdp)?void 0:r.toLowerCase().indexOf("h265")),s.close(),{isH264EncodeSupported:o,isVp8EncodeSupported:n,isH265EncodeSupported:a}}catch(lM){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1}}}))},UL=function(){return nw(this,null,(function*(){var e;if(bL.detail.isH264DecodeSupported&&bL.detail.isVp8DecodeSupported)return{isH264DecodeSupported:bL.detail.isH264DecodeSupported,isVp8DecodeSupported:bL.detail.isVp8DecodeSupported,isH265DecodeSupported:bL.detail.isH265DecodeSupported};let t,r=!1,i=!1;try{let o=new RTCPeerConnection;iP()?(o.addTransceiver(eC.VIDEO,{direction:"recvonly"}),t=yield o.createOffer()):t=yield o.createOffer({offerToReceiveVideo:!0}),-1!==t.sdp.toLowerCase().indexOf("h264")&&(r=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(i=!0);let n=-1!==(null==(e=t.sdp)?void 0:e.toLowerCase().indexOf("h265"));return o.close(),{isH264DecodeSupported:r,isVp8DecodeSupported:i,isH265DecodeSupported:n}}catch(cM){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}}}))};var VL=RN((e=>nw(void 0,null,(function*(){let t=Date.now(),r=_P(),i=kL(),o=NL();if(bL.detail.isWebRTCSupported=r,bL.detail.isMediaDevicesSupported=i,bL.detail.isWebCodecsSupported=o,bL.detail.isScreenShareSupported=BL(),bL.detail.isSmallStreamSupported=$L(),37===e)return Object.assign(bL.detail,yield function(){return nw(this,null,(function*(){return GL||(GL=new Promise((e=>nw(this,null,(function*(){let t={isH264EncodeSupported:!1,isH264DecodeSupported:!1,isVp8EncodeSupported:!1,isVp8DecodeSupported:!1};if(!NL())return void e(t);let r=null,i=null,o=null,n=()=>{o&&clearTimeout(o),r=null,i=null};try{r=document.createElement("canvas"),i=r.getContext("2d"),r.width=320,r.height=240;let a=0,s=()=>{!i||!r||(i.fillStyle="hsl(".concat(a%360,", 50%, 50%)"),i.fillRect(0,0,r.width,r.height),i.fillStyle="white",i.font="20px Arial",i.fillText("Frame ".concat(a),10,30),a++)};o=setTimeout((()=>{n(),e(t)}),5e3);let l=[{type:"h264",encodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"},width:320,height:240,bitrate:1e6},decodeConfig:{codec:"avc1.42E01E",avc:{format:"annexb"}}},{type:"vp8",encodeConfig:{codec:"vp8",width:320,height:240,bitrate:1e6},decodeConfig:{codec:"vp8"}}];(yield Promise.all(l.map((e=>nw(this,null,(function*(){let t,i={type:e.type,encodeSupported:!1,decodeSupported:!1};try{t=yield new Promise(((t,o)=>nw(this,null,(function*(){try{let n=new VideoEncoder({output:e=>{t(e),i.encodeSupported=!0},error:o});n.configure(e.encodeConfig),s();let a=new VideoFrame(r,{timestamp:0});n.encode(a,{keyFrame:!0}),a.close(),yield n.flush(),n.close()}catch(mM){o(mM)}}))))}catch(p){return ZO.warn("".concat(e.type," encoder error:"),p),i}try{yield new Promise(((r,o)=>nw(this,null,(function*(){try{let n=new VideoDecoder({output:e=>{i.decodeSupported=!0,r(0),e.close()},error:o});n.configure(e.decodeConfig),n.decode(t),yield n.flush(),n.close()}catch(mM){o(mM)}}))))}catch(p){ZO.warn("".concat(e.type," decoder error:"),p)}return i})))))).forEach((e=>{"h264"===e.type?(t.isH264EncodeSupported=e.encodeSupported,t.isH264DecodeSupported=e.decodeSupported):"vp8"===e.type&&(t.isVp8EncodeSupported=e.encodeSupported,t.isVp8DecodeSupported=e.decodeSupported)})),n(),e(t)}catch(a){n(),ZO.warn("detectWebCodecsSupported failed:",a),e(t)}})))),GL)}))}()),bL.detail.isBrowserSupported=o,bL.result=i&&o,bL.result||ZO.error("".concat(navigator.userAgent," ").concat(EN(bL.detail,!1))),AP(e),RL.addNumber({key:523800,value:Date.now()-t}),bL;if(bL.result&&bL.detail.isH264EncodeSupported&&bL.detail.isVp8EncodeSupported&&bL.detail.isH265EncodeSupported&&bL.detail.isH264DecodeSupported&&bL.detail.isVp8DecodeSupported&&bL.detail.isH265DecodeSupported)return bL;let n=DL(),{encode:a,decode:s}=yield function(){return nw(this,null,(function*(){let[e,t]=yield Promise.all([xL(),UL()]);return{encode:{h264:e.isH264EncodeSupported,vp8:e.isVp8EncodeSupported,h265:e.isH265EncodeSupported},decode:{h264:t.isH264DecodeSupported,vp8:t.isVp8DecodeSupported,h265:t.isH265DecodeSupported}}}))}(),{h264:l,vp8:c}=a,{h264:d}=s,{h265:u}=a,{vp8:h,h265:p}=s;if(!l||!c){let e=yield xL();ZO.warn("detect encode again h264:".concat(l," vp8:").concat(c," result: ").concat(JSON.stringify(e))),l=e.isH264EncodeSupported,c=e.isVp8EncodeSupported}if(l&&d&&lk&&uO&&!bk&&!Sk&&(!iO||115!==mO)){let{encode:e,decode:t}=yield function(){return nw(this,null,(function*(){return WL||(WL=new Promise((e=>nw(this,null,(function*(){let t={encode:!1,decode:!1},r=()=>{};try{let i=document.createElement("canvas"),o=i.getContext("2d");i.width=640,i.height=480;let n=setInterval((()=>{o.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))}),66),a=-1,s=-1;r=()=>{clearInterval(a),clearInterval(n),clearTimeout(s),c.close(),d.close(),l.getTracks().forEach((e=>e.stop()))},s=setTimeout((()=>{r(),e(t)}),2e3);let l=i.captureStream(),c=new RTCPeerConnection({}),d=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});c.addEventListener("icecandidate",(e=>d.addIceCandidate(e.candidate))),d.addEventListener("icecandidate",(e=>c.addIceCandidate(e.candidate))),c.addTrack(l.getVideoTracks()[0],l);let u=yield c.createOffer();yield c.setLocalDescription(u),yield d.setRemoteDescription(u);let h=yield d.createAnswer(),p=_L.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=_L.default.write(p),yield d.setLocalDescription(h),yield c.setRemoteDescription(h),a=setInterval((()=>nw(this,null,(function*(){t.encode&&t.decode&&(r(),e(t));let[i,o]=yield Promise.all([c.getSenders()[0].getStats(),d.getReceivers()[0].getStats()]);t.encode||i.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===eC.VIDEO&&e.bytesSent>0&&(t.encode=!0)})),t.decode||o.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===eC.VIDEO&&e.bytesReceived>0&&(t.decode=!0)}))}))),100)}catch(i){r(),ZO.warn("detectH264Supported failed",i),e({encode:!0,decode:!0})}})))).then((e=>(e.encode||(e.decode=!0),(!e.encode||!e.decode)&&ZO.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(PO)),e))),WL)}))}();l=e,d=t}return bL.result=n&&r&&i&&(l||c)&&(d||h),bL.detail.isBrowserSupported=n,bL.detail.isWebRTCSupported=r,bL.detail.isH264EncodeSupported=l,bL.detail.isVp8EncodeSupported=c,bL.detail.isH265EncodeSupported=u,bL.detail.isH264DecodeSupported=d,bL.detail.isVp8DecodeSupported=h,bL.detail.isH265DecodeSupported=p,bL.result||ZO.error("".concat(navigator.userAgent," ").concat(EN(bL.detail,!1))),AP(),RL.addNumber({key:523800,value:Date.now()-t}),bL})))),FL=function(){return bL.result},BL=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},HL="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype,WL=null;var GL=null;var jL=(e,t,r)=>{"http:"===location.protocol&&!DO&&(e[t]=()=>{throw new mw({code:hw.INVALID_OPERATION,message:uL.NOT_SUPPORTED_HTTP})})},zL=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(qD(e.selected)&&!e.selected)};function KL(){let e="";if(screen.width){let t=screen.width?screen.width*window.devicePixelRatio:"",r=screen.height?screen.height*window.devicePixelRatio:"";e+="".concat(t," * ").concat(r)}return e}function qL(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function YL(){let e={isSupported:!1},t=["AudioContext","webkitAudioContext","mozAudioContext","msAudioContext"];for(let r=0;r<t.length;r++)if(t[r]in window){e.isSupported=!0;break}return e.isSupported}function JL(){return"captureStream"in HTMLCanvasElement.prototype}function XL(){return!(kk||sk||mO&&mO<63)&&!(!DL()||!JL())}function QL(){return!(mO<74||fk||SO<11||mk<46)}function $L(){return XL()||QL()}var ZL=function(){if(jD(window.RTCRtpTransceiver)||!iP()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:LC}),e.addTransceiver(eC.AUDIO),t=!0}catch(Sw){}return null==e||e.close(),t};function eP(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function tP(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function rP(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function iP(){return!(11===SO&&!CO)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var oP=!(!iP()||uO&&mO<86);function nP(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var aP="RTCRtpSender"in window;function sP(){return aP&&"replaceTrack"in window.RTCRtpSender.prototype}function lP(){return aP&&"setParameters"in window.RTCRtpSender.prototype&&tP()}var cP="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,dP=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,uP=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,hP="undefined"!=typeof InputDeviceInfo&&"getCapabilities"in InputDeviceInfo.prototype,pP=aP&&"createEncodedStreams"in window.RTCRtpSender.prototype&&cO()>=86,mP="RTCRtpScriptTransform"in window,fP=aP&&(pP||mP),_P=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function gP(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return jD(window.AudioDecoder)||(e.AudioDecoder=!0),jD(window.AudioEncoder)||(e.AudioEncoder=!0),jD(window.VideoDecoder)||(e.VideoDecoder=!0),jD(window.VideoEncoder)||(e.VideoEncoder=!0),jD(window.ImageDecoder)||(e.ImageDecoder=!0),e}function EP(){return"mediaSession"in navigator&&!jD(navigator.mediaSession.setActionHandler)}function vP(){return!jD(window.WebTransport)}function yP(){return"undefined"!=typeof WebAssembly&&WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]))}function TP(){let e={browser:"".concat(kO.name,"/").concat(kO.version),os:HO(),displayResolution:KL(),isScreenShareSupported:BL(),isWebRTCSupported:_P(),isGetUserMediaSupported:qL(),isWebAudioSupported:YL(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:gP(),isMediaSessionSupported:EP(),isWebTransportSupported:vP()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var IP="checkResult";function AP(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;tM.setItem(IP+e,{ua:navigator.userAgent,checkResult:bL})}function SP(e){ML();let t=tM.getItem(IP+e);t&&t.ua===navigator.userAgent&&t.checkResult&&function(e,t){return!!YD(e)&&Object.keys(t).every((t=>t in e))}(t.checkResult.detail,bL.detail)&&(bL=t.checkResult),VL(e)}function RP(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var bP="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype;function wP(e){return{h264:1,h265:2,vp8:3,vp9:4,av1:5}[e]}var CP=!1;function DP(){return nw(this,null,(function*(){var e;try{if(CP||null==(e=null==navigator?void 0:navigator.mediaCapabilities)||!e.encodingInfo)return;let t=WO(),r=GO();if(0===t||0===r)return;CP=!0;let i=["H264","VP8","VP9","AV1","H265"],[o,n]=yield Promise.all([NP(i),kP(i)]);o&&Object.keys(o).forEach((e=>{let i=wP(e.toLowerCase());RL.addEnum({key:513707,value:+"".concat(i).concat(+o[e].supported).concat(+o[e].powerEfficient).concat(t).concat(r),useUV:!1})})),n&&Object.keys(n).forEach((e=>{let i=wP(e.toLowerCase());RL.addEnum({key:514713,value:+"".concat(i).concat(+n[e].supported).concat(+n[e].powerEfficient).concat(t).concat(r),useUV:!1})}));let{sender:a,receiver:s}=OP();RL.addEnum({key:513708,value:+"".concat(t).concat(r).concat(+a.high),useUV:!1}),RL.addEnum({key:513709,value:+"".concat(t).concat(r).concat(+a.main),useUV:!1}),RL.addEnum({key:514714,value:+"".concat(t).concat(r).concat(+s.high),useUV:!1}),RL.addEnum({key:514715,value:+"".concat(t).concat(r).concat(+s.main),useUV:!1})}catch(sM){ZO.info("detectVideoCodecCapabilities failed",sM)}}))}function NP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return nw(this,null,(function*(){let n={};try{for(let a of e){let e=yield navigator.mediaCapabilities.encodingInfo({type:"webrtc",video:{contentType:"video/".concat(a),width:t,height:r,bitrate:o,framerate:i}});n[a]=e}}catch(Rw){}return n}))}function kP(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1920,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1080,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:30,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return nw(this,null,(function*(){let n={};try{for(let a of e){let e=yield navigator.mediaCapabilities.decodingInfo({type:"webrtc",video:{contentType:"video/".concat(a),width:t,height:r,bitrate:o,framerate:i}});n[a]=e}}catch(Rw){}return n}))}function OP(){let e={sender:{base:!1,main:!1,high:!1},receiver:{base:!1,main:!1,high:!1}};try{if(RTCRtpSender&&"function"==typeof RTCRtpSender.getCapabilities){let t=RTCRtpSender.getCapabilities("video");t&&t.codecs&&t.codecs.filter((e=>"video/h264"===e.mimeType.toLowerCase())).forEach((t=>{if(t.sdpFmtpLine){let r=t.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(r&&r[1])switch(r[1].slice(0,2)){case"42":e.sender.base=!0;break;case"4d":e.sender.main=!0;break;case"64":e.sender.high=!0}}}))}if(RTCRtpReceiver&&"function"==typeof RTCRtpReceiver.getCapabilities){let t=RTCRtpReceiver.getCapabilities("video");t&&t.codecs&&t.codecs.filter((e=>"video/h264"===e.mimeType.toLowerCase())).forEach((t=>{if(t.sdpFmtpLine){let r=t.sdpFmtpLine.match(/profile-level-id=([0-9a-fA-F]+)/);if(r&&r[1])switch(r[1].slice(0,2)){case"42":e.receiver.base=!0;break;case"4d":e.receiver.main=!0;break;case"64":e.receiver.high=!0}}}))}}catch(sM){ZO.warn("get H264 profile levelId failed",sM)}return e}var MP=tw(aw(),1),LP=Symbol("instance"),PP=Symbol("cacheResult"),xP=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,HP.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},UP=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var VP=new Map;function FP(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=VP.get(i)||[];VP.has(i)||VP.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),l=0;l<o;l++)n[l]=arguments[l];if(r.context&&(i=WP.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[PP]:Promise.resolve(i[PP]);i.state instanceof xP&&i.state.action==r.abortAction&&i.state.abort(i);let c=null;Array.isArray(e)?0==e.length?i.state instanceof xP&&i.state.abort(i):("string"!=typeof i.state||!e.includes(i.state))&&(c=new UP(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(c=new UP(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let d=e=>{if(r.fail&&r.fail.call(this,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(c)return d(c);let u=i.state,h=new xP(u,t,a);HP.call(i,h);let p=e=>{var o;return i[PP]=e,h.aborted||(HP.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[PP])),e},m=e=>(HP.call(i,u,e),d(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(pM){return m(new UP(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(pM),pM instanceof Error?pM:new Error(String(pM))))}}}}var BP="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function HP(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(WP.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var WP=class e extends MP.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[LP];o?this.name=o.name+"-"+o.count++:i[LP]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=VP.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);VP.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};BP(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){HP.call(this,e)}};WP.STATECHANGED="stateChanged",WP.UPDATEAFSM="updateAFSM",WP.INIT="[*]",WP.ON="on",WP.OFF="off",WP.instances=new Map,WP.instances2=new WeakMap;var GP="undefined"!=typeof window,jP=GP&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},zP=GP&&window.cancelIdleCallback||function(e){clearTimeout(e)},KP=GP&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),qP=class e{static generateTaskID(){return this.currentTaskID++}static run(e,t,r){null!=r&&r.fps&&(r.delay=r.delay||Number((1e3/r.fps).toFixed(2))),r=Qb("interval"===e?{delay:2e3,count:0,backgroundTask:!0}:"ric"===e?{delay:1e4,count:0}:"raf"===e?{fps:60,delay:16.6,count:0,backgroundTask:!0}:{delay:2e3,count:0,backgroundTask:!0},r);let i=$b(Qb({taskID:this.generateTaskID(),loopCount:0,intervalID:null,timeoutID:null,rafID:null,ricID:null,taskName:e,callback:t},r),{delay:r.delay});return this.taskMap.set(i.taskID,i),this[e](i),i.taskID}static interval(t){return t.intervalID=setInterval((()=>{t.callback(),t.loopCount+=1,e.isBreakLoop(t)}),t.delay)}static intervalInWorker(t){e.sharedWorker||(e.sharedWorker=new Worker(URL.createObjectURL(new Blob(["\n const timers = new Map();\n self.onmessage = function(e) {\n const { taskId, delay, type } = e.data;\n if (type === 'start') {\n timers.set(taskId, setInterval(() => {\n self.postMessage({ type: 'tick', taskId });\n }, delay));\n } else if (type === 'stop') {\n clearInterval(timers.get(taskId));\n timers.delete(taskId);\n }\n };\n "],{type:"application/javascript"}))),e.sharedWorker.onmessage=t=>{var r;if("tick"===t.data.type){let i=e.workerTasks.get(t.data.taskId);i&&(e.isBreakLoop(i)?(null==(r=e.sharedWorker)||r.postMessage({type:"stop",taskId:i.taskID}),e.workerTasks.delete(i.taskID)):(i.callback(),i.loopCount+=1))}}),e.workerTasks.set(t.taskID,t),e.sharedWorker.postMessage({taskId:t.taskID,delay:t.delay,type:"start"})}static timeout(t){let r=()=>{if(t.callback(),t.loopCount+=1,!e.isBreakLoop(t))return t.timeoutID=setTimeout(r,t.delay)};return t.timeoutID=setTimeout(r,t.delay)}static ric(t){let r,i=oN(),o=()=>{if(r=oN()-i,r>=t.delay&&(i=oN()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=jP(o,{timeout:t.delay})};return t.ricID=jP(o,{timeout:t.delay})}static raf(t){let r,i=oN(),o=()=>document.hidden&&t.backgroundTask?(r=oN()-i,i=oN(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(o,t.delay-Math.floor(r%t.delay))):(r=oN()-i,r>=t.delay&&(i=oN()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(o));if(t.rafID=requestAnimationFrame(o),t.backgroundTask){let e=()=>{if(document.hidden){let e=oN()-i;e>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-e)}};document.addEventListener("visibilitychange",e),t.onVisibilitychange=e,document.hidden&&e()}return t.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:r,rafID:i,ricID:o,onVisibilitychange:n}=this.taskMap.get(e);return t&&clearInterval(t),r&&clearTimeout(r),i&&KP&&KP(i),o&&zP(o),n&&document.removeEventListener("visibilitychange",n),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.hasTask(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};iw(qP,"taskMap",new Map),iw(qP,"currentTaskID",1),iw(qP,"sharedWorker",null),iw(qP,"workerTasks",new Map);var YP=qP;eC.SEI_MESSAGE;var JP={LOADED_DATA:eC.LOADEDDATA,LOADED_META_DATA:eC.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error",RESIZE:eC.RESIZE,TIME_UPDATE:"time-update"},XP={};ew(XP,{create:()=>$P,remove:()=>ZP});var QP=new WeakMap;function $P(e,t){QP.has(e)||QP.set(e,[]);let r=QP.get(e),i={add:(e,o)=>("addEventListener"in t?(r.push(t.removeEventListener.bind(t,e,o)),t.addEventListener(e,o)):(r.push(t.off.bind(t,e,o)),t.on(e,o)),i)};return i}function ZP(e){let t=QP.get(e);t&&(t.forEach((e=>e())),QP.delete(e))}var ex=new class{constructor(){iw(this,"_roomIdMap",new Map),iw(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:Iw,env:Gw.QCLOUD,browserVersion:kO.name+kO.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:r,userId:i,roomId:o}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=r,this._configs.userId=i,this._roomIdMap.set(i,String(o))}logSuccessEvent(e){DO||!ZO.isAbleToUpload||this._configs.env===Gw.QCLOUD&&this.uploadEventToKibana($b(Qb({},e),{result:"success"}))}logFailedEvent(e){if(DO||!ZO.isAbleToUpload)return;let{eventType:t,code:r,error:i,userId:o}=e,n={roomId:this._roomIdMap.get(o||this._configs.userId),userId:o,eventType:t,result:"failed",code:r||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||hw.UNKNOWN};this._configs.env===Gw.QCLOUD&&this.uploadEventToKibana($b(Qb({},n),{error:i}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:r,error:i}=e,o={timestamp:gw(),sdkAppId:this._configs.sdkAppId,userId:r||this._configs.userId,version:Iw,log:t};i&&(o.errorInfo=i.message,i.stack&&(o.errorInfo+="\n".concat(i.stack)));let n=QO.enable?MN(o,2002,Number(this._configs.sdkAppId)):JSON.stringify(o);this.sendRequest(SD(this._configs.sdkAppId,Ww.LOG),n)}sendRequest(e,t){setTimeout((()=>HN({url:e,body:t,priority:"low"}).catch((()=>{}))),2e3)}},tx=new WeakMap;function rx(e){let{settings:t={retries:5,timeout:2e3},onError:r,onRetrying:i,onRetryFailed:o}=e;return function(e,n,a){let s=YN({retryFunction:a.value,settings:t,onError(t){let{error:i,retry:o,reject:a,retryFuncArgs:s}=t;var l;r?r.call(this,i,(()=>{var t;null!=(t=tx.get(e))&&t.has(n)?o():a(i)}),a,s):null!=(l=tx.get(e))&&l.has(n)?o():a(i)},onRetrying(t,r){var o;jN(i)&&i.call(this,t,r),null!=(o=tx.get(e))&&o.has(n)&&(tx.get(e).get(n).stopRetry=r)},onRetryFailed:o});return a.value=function(){let t=tx.get(e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return t?t.set(n,{args:i}):tx.set(e,new Map([[n,{args:i}]])),s.apply(this,i).finally((()=>{var t;return null==(t=tx.get(e))?void 0:t.delete(n)}))},a}}var ix=class extends WP{constructor(e,t){super(e.id,"".concat(t,"-player")),this.options=e,this.kind=t,iw(this,"id"),iw(this,"element",null),iw(this,"track"),iw(this,"url"),iw(this,"attr"),iw(this,"mode"),iw(this,"muted"),iw(this,"_log"),iw(this,"_isPausedByUserCall",!1),iw(this,"_pausedRetryCount"),iw(this,"_isElementPlayingFired",!1),iw(this,"_interval"),iw(this,"_delayDestroyTimeoutId",0),iw(this,"_playSuccessResolve"),iw(this,"_isReplayByRecreateMediaStreamCalled",!1),iw(this,"isPlayCalled",!1),iw(this,"isInAutoPlayFailedState",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=KC,this._state="STOPPED",this.bindTrackEvents(),this._log.info("create ".concat(t,"-player ").concat(this.id))}get isPlaying(){var e;return"PLAYING"===this._state&&!1===(null==(e=this.element)?void 0:e.paused)}get isPaused(){var e;return"PAUSED"===this._state||!0===(null==(e=this.element)?void 0:e.paused)}get isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return nw(this,null,(function*(){if(!this.isPlaying)try{this.isPlayCalled=!0,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),yield new Promise(((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)}))}catch(Sw){let t=mL({key:dL.PLAY_FAILED,data:{media:this.kind,error:Sw}});if(this._log.warn(Sw),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new mw({code:hw.PLAY_NOT_ALLOWED,message:t})}}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this.isPlayCalled=!1,this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!EO?this._delayDestroyTimeoutId||(null==(t=this.element)||t.remove(),this._log.info("destroy element after 3 * ".concat(e)),this._delayDestroyTimeoutId=setTimeout((()=>this.destroyElement()),3*e)):this.destroyElement(),this.handleStopped(eC.ENDED),this._interval>0&&YP.clearTask(this._interval)}destroyElement(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.src="",this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}pause(){var e;this._log.info("pause"),this._isPausedByUserCall=!0,null==(e=this.element)||e.pause()}resume(){return this._isPausedByUserCall=!1,this.doResume()}doResume(){return this._log.info("resume"),this._isPausedByUserCall||this.isPlaying?Promise.resolve():bO?this.replay():(this.element&&this.track&&uO&&mO>=128&&(this.element.srcObject=new MediaStream([this.track])),this.play().catch((()=>{})))}setMuted(e){this.element&&(this.element.muted=e),this.muted=e}replay(){return this.stop(),this.play().catch((()=>{}))}bindElementEvents(){if(this.element){let e=this.handleElementEvent.bind(this);return $P(this.element,this.element).add(eC.PLAYING,e).add(eC.ENDED,e).add(eC.PAUSE,e).add(eC.ERROR,e).add(eC.LOADEDDATA,e).add(eC.LOADEDMETADATA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==XP||XP.create(e,e).add(eC.ENDED,t).add(eC.MUTE,t).add(eC.UNMUTE,t),e.readyState===eC.ENDED&&this.handleTrackEvent({type:eC.ENDED}),e.muted&&this.handleTrackEvent({type:eC.MUTE})}}bindAutoPlayEvent(){YO.on(XO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&ZP(e)}unbindEvents(){this.element&&ZP(this.element),this.unbindTrackEvents(),YO.off(XO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){switch(e.type){case eC.PLAYING:Tx()||(this.isInAutoPlayFailedState=!1),this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(eC.PLAYING),this._interval&&(YP.clearTask(this._interval),this._interval=-1);break;case eC.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(eC.ENDED);break;case eC.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(eC.PAUSE),sk&&(this._interval=YP.run("timeout",(()=>{this.element&&"PAUSED"===this._state&&this.doResume()}),{delay:3e3}));break;case eC.ERROR:if(this.element&&this.element.error){this.handlePaused(eC.ERROR);let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),ex.uploadEvent({log:"stat-".concat(this.kind,"-").concat(NC.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),Zk||$k?this.emit(JP.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case eC.LOADEDDATA:this.kind===eC.VIDEO&&this.emit(JP.LOADED_DATA);break;case eC.LOADEDMETADATA:this.kind===eC.VIDEO&&this.emit(JP.LOADED_META_DATA)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((()=>{this._log.warn("replayByRecreateMediaStream success"),ex.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),RL.addSuccessEvent({key:this.kind===eC.AUDIO?506700:516700})})).catch((()=>{var t;this._log.error("replayByRecreateMediaStream failed"),ex.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),RL.addFailedEvent({key:this.kind===eC.AUDIO?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(JP.ERROR,e)}))}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise(((t,r)=>{SN(e).then((()=>{this.element&&(this.element.srcObject=null,this.element.srcObject=new MediaStream([this.track]),this._log.warn("recreated mediaStream"),this.element.onerror=()=>{var e,t,i;this._log.warn("element onerror ".concat(null==(t=null==(e=this.element)?void 0:e.error)?void 0:t.code," fired after recreated mediaStream")),r(null==(i=this.element)?void 0:i.error)}),SN(5e3).then((()=>{var e,i;(!this.isPlaying||null!=(e=this.element)&&e.error)&&r(null==(i=this.element)?void 0:i.error),t()}))}))})).finally((()=>{this.element&&(this.element.onerror=null)}))}handleTrackEvent(e){return nw(this,null,(function*(){switch(e.type){case eC.ENDED:this.handleStopped(eC.ENDED);break;case eC.MUTE:this.handlePaused(eC.MUTE);break;case eC.UNMUTE:this.mode>0?this.handlePlaying(this.mode.toString()):this.element&&(this.element.paused&&(this._log.warn("track unmuted and element is paused, resume"),yield this.doResume()),this.element&&!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(eC.UNMUTE))}}))}handlePlaying(e){var t;return this._log.debug("handlePlaying",e),null==(t=this._playSuccessResolve)||t.call(this,e),e}handlePaused(e){return this._log.debug("handlePaused",e),e}handleStopped(e){return this._log.debug("handleStopped",e),e}getElement(){return this.element}};iw(ix,"PlayerEvent",JP),rw([rx({settings:{retries:2,timeout:0},onError(e,t,r,i){i[0]=(i[0]||1e3)+1e3,t()}})],ix.prototype,"doReplayByRecreateMediaStream",1),rw([FP([],"PLAYING",{sync:!0,success(e){this.emit(JP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}})],ix.prototype,"handlePlaying",1),rw([FP("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(e){this.emit(JP.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}})],ix.prototype,"handlePaused",1),rw([FP([],"STOPPED",{sync:!0,success(e){this.emit(JP.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}})],ix.prototype,"handleStopped",1);var ox="trtc_autoplay",nx="".concat(ox,"_mask"),ax="".concat(ox,"_wrapper"),sx="".concat(ox,"_header"),lx="".concat(ox,"_content"),cx="".concat(ox,"_action_wrapper"),dx="".concat(ox,"_question"),ux="".concat(ox,"_collapse"),hx="".concat(ox,"_action_confirm"),px="".concat(ox,"_detail"),mx="#2473E8",fx="dialog",_x="".concat(fx,"-show"),gx="".concat(fx,"-1"),Ex="".concat(fx,"-2"),vx=!1,yx=!1,Tx=()=>yx,Ix="".concat(Pw,"/").concat(VD()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),Ax="<br><a href='".concat(Ix,"' target='_blank'>").concat(VD()?"其他方案?":"Any other solution?","</a>"),Sx="".concat(VD()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(Ax):"Autoplay Policy: Before user interacts with the web page (clicking, touching), page will not be allowed to play media with sound. This Dialog is used to help users resume playback. ".concat(Ax)),Rx=class{constructor(){if(iw(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),iw(this,"_dialogNode",null),iw(this,"_bodyPosition",""),iw(this,"_showDetail",!1),iw(this,"_isCollapseClicked",!1),iw(this,"_isQuestionClicked",!1),VD()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!vx){let e=document.createElement("style");e.innerHTML=".".concat(nx,"{position:fixed;top:0;left:0;right:0;bottom:0;width:100vw;height:100vh;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,0.5);z-index:1500;}.").concat(nx," div:not(.").concat(cx,"){display:block !important;}.").concat(ax,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(ax," a{color:").concat(mx,";}.").concat(sx,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(lx,"{margin:8px 0;}.").concat(cx,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(ux,"{margin-right:auto;cursor:pointer}.").concat(dx,"{height:100%;line-height:16px;cursor:pointer;}.").concat(hx,"{margin-left:8px;color:#fff;background:").concat(mx,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(hx,":hover{opacity:0.9;}.").concat(ux,",.").concat(hx,",.").concat(lx,",.").concat(dx,"{font-size:14px;}@media screen and (max-width:750px){.").concat(ax,"{width:80vw;}}"),document.head.appendChild(e),vx=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(nx,"\"><div class='").concat(ax,"'><div class='").concat(sx,"'>").concat(location.host,"</div><div class='").concat(lx,"'>").concat(this.content,"</div><div class='").concat(px,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(Sx,"</div><div class='").concat(cx,"'></div></div></div>").trim();let t=document.createElement("button");t.className=hx,t.innerText=VD()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let r=document.createElement("div");r.className=dx,r.innerHTML='<?xml version="1.0" encoding="UTF-8"?>\n <svg class="icon" width="18" height="18" p-id="2030" t="1639646523624" version="1.1" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg">\n <path d="m464 784.35c0 26.51 21.49 48 48 48s48-21.49 48-48-21.49-48-48-48-48 21.49-48 48z" p-id="2031"/>\n <path d="m512 960c-247.04 0-448-200.96-448-448s200.96-448 448-448 448 200.96 448 448-200.96 448-448 448zm0-831.71c-211.58 0-383.71 172.13-383.71 383.71 0 211.55 172.13 383.71 383.71 383.71 211.55 0 383.71-172.16 383.71-383.71 0-211.58-172.16-383.71-383.71-383.71z" p-id="2032"/>\n <path d="m512 673.7c-17.665 0-32.001-14.336-32.001-31.999v-54.112c0-52.353 40-92.352 75.328-127.65 25.887-25.92 52.672-52.672 52.672-74.017 0-53.343-43.072-96.735-95.999-96.735-53.823 0-95.999 41.536-95.999 94.559 0 17.665-14.336 31.999-32.001 31.999s-32.001-14.336-32.001-31.999c0-87.424 71.775-158.56 160-158.56s160 72.095 160 160.74c0 47.904-36.32 84.192-71.424 119.3-27.84 27.776-56.576 56.512-56.576 82.336v54.112c0 17.665-14.336 32.032-32.001 32.032z" p-id="2033"/>\n </svg>\n ',r.onclick=this.onQuestionClick.bind(this);let i=document.createElement("div");i.className=ux,i.innerText="".concat(VD()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let o=e.content.firstChild,n=o.querySelector(".".concat(cx));return n.appendChild(i),n.appendChild(r),n.appendChild(t),o}addDiaLog(){Tx()||(yx=!0,this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(ax)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",ZO.info("show autoplay dialog"),ex.uploadEvent({log:_x}))}deleteDialog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null,yx=!1)}onConfirm(){ZO.warn("confirm clicked, try resume stream"),YO.emit(XO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDialog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(px));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||ex.uploadEvent({log:gx}),this._isCollapseClicked=!0}onQuestionClick(){window.open(Ix,"_blank"),this._isQuestionClicked||ex.uploadEvent({log:Ex}),this._isQuestionClicked=!0}},bx=null;function wx(){bx||(bx=new Rx)}var Cx,Dx=class e extends ix{constructor(e){super(e,eC.VIDEO),iw(this,"stat",{}),iw(this,"_calculateTimeout",-1),iw(this,"viewMirror",!1),iw(this,"objectFit"),iw(this,"container"),iw(this,"canvas"),iw(this,"shouldRenderAlpha",!1),iw(this,"_preSize",{width:0,height:0}),iw(this,"posterImg"),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,jD(e.viewMirror)||(this.viewMirror=e.viewMirror),jD(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}get isPlaying(){var e;return!("PLAYING"!==this._state||this.element&&this.element.paused)&&("live"===(null==(e=this.track)?void 0:e.readyState)&&!this.track.muted)}initializeElement(){var e;let t=document.createElement(eC.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,lk&&(t.poster="noposter"),null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color: black",";");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(eC.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(eC.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent).add(eC.RESIZE,this.handleElementEvent)}handleTrackEvent(e){var t;return e.type===eC.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0),super.handleTrackEvent(e)}handleElementEvent(e){var t,r,i,o,n,a;if(2===this.mode)return;super.handleElementEvent(e);let s=e.type;if(s===eC.PAUSE&&(this.container&&!this.container.isConnected&&(this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(this.container.id)),SN(500).then((()=>{var e;null!=(e=this.container)&&e.isConnected&&(this._pausedRetryCount=KC,this._log.info("view container ".concat(this.container.id," is in dom, reset pausedRetryCount")))}))),this._pausedRetryCount>0&&!Tx()&&!this._isPausedByUserCall&&(this._log.info("[".concat(KC-this._pausedRetryCount+1,"/").concat(KC,"] ").concat(this.kind," player auto resume when paused")),this.doResume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;s===eC.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):s===eC.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}s===eC.RESIZE&&(this._preSize.height!==(null==(t=this.element)?void 0:t.videoHeight)||this._preSize.width!==(null==(r=this.element)?void 0:r.videoWidth))&&(this._log.info("video size changed to ".concat(null==(i=this.element)?void 0:i.videoWidth,"x").concat(null==(o=this.element)?void 0:o.videoHeight)),this._preSize.height=(null==(n=this.element)?void 0:n.videoHeight)||0,this._preSize.width=(null==(a=this.element)?void 0:a.videoWidth)||0,this.emit(JP.RESIZE,{newWidth:this._preSize.width,newHeight:this._preSize.height}))}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var r,i,o,n;this.canvas!==e&&(null==(r=this.canvas)||r.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?t:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(i=this.element)||i.remove(),null==(o=this.container)||o.appendChild(e)):this.element&&(null==(n=this.container)||n.appendChild(this.element)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}setPoster(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return new Promise((r=>{if(this.element)if(this._log.info("setPoster",e.slice(0,10)),this.element.poster=e,t&&(gO||hk)){if(""===e)this.removePosterImg();else if(!this.posterImg){let t=document.createElement("img");t.src=e,t.style="position:absolute;top:0;left:0;".concat(this.styleAttribute),t.onload=()=>nw(this,null,(function*(){var e;t.decode&&(yield t.decode()),this.posterImg=t,null==(e=this.container)||e.appendChild(t),r()}))}}else r()}))}removePosterImg(){this.posterImg&&(this.posterImg.remove(),URL.revokeObjectURL(this.posterImg.src),delete this.posterImg)}pause(){return nw(this,null,(function*(){return(uO&&mO>=128||hk||gO)&&(yield this.setPoster(this.getVideoFrame(),!0)),ow(e.prototype,this,"pause").call(this)}))}resume(){return this.posterImg&&this.setPoster("",!0),super.resume()}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;super.stop(e),null==(t=this.canvas)||t.remove(),this.removePosterImg()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(JP.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}calculateStat(){try{if(RP()&&this.element&&this._calculateTimeout<0){let e=0,t=null,r=(i,o)=>{this.stat.width=o.width,this.stat.height=o.height,t&&(this.stat.fps=Math.round((o.presentedFrames-t.presentedFrames)/(i-e)*1e3)),e=i,t=o,this._calculateTimeout=-1,this.element&&(this._calculateTimeout=setTimeout((()=>{var e;return null==(e=this.element)?void 0:e.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(Sw){this._log.warn("init stat failed",Sw)}}};function Nx(e,t){return nw(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),ZO.info("worklet addModule success")}catch(Sw){throw ZO.info("worklet addModule catch error. ".concat(Sw.message)),Sw}}))}"undefined"!=typeof AudioContext?Cx=AudioContext:"undefined"!=typeof webkitAudioContext?Cx=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(Cx=mozAudioContext);var kx,Ox=1500,Mx=-1,Lx=0,Px=-1,xx=!1,Ux=0,Vx=-1,Fx=-1;!function e(){try{if(kx)return;(kx=new Cx({sampleRate:48e3})).onstatechange=()=>{ZO.info("context state: ".concat(kx.state).concat("running"!==kx.state?" visibilityState: ".concat(document.visibilityState):"")),Bx()},clearTimeout(Mx)}catch(OH){ZO.error("initAudioContext failed: ".concat(OH," typeof AudioContextClass: ").concat(typeof Cx)),Mx=setTimeout(e,1e3)}}();var Bx=()=>{"suspended"===kx.state?(Lx=oN(),-1===Px&&(Px=setTimeout((()=>{"suspended"===kx.state&&(xx=!0,YO.emit("155",{isSuspended:!0}))}),Ox)),Gx(),document.addEventListener("click",Bx)):"interrupted"===kx.state?Gx():(Lx&&(RL.addNumber({key:507800,value:oN()-Lx,split:[0,500,1e3,1500,2e3,3e3,4e3,5e3,1e4,3e4],max:6e4}),Lx=0),-1!==Px&&(clearTimeout(Px),Px=-1,xx&&(xx=!1,YO.emit("155",{isSuspended:!1}))),document.removeEventListener("visibilitychange",Bx),document.removeEventListener("click",Bx))},Hx=0,Wx=-1;function Gx(){return new Promise(((e,t)=>{if("running"===kx.state)return e();Date.now()-Hx<1e3?(clearTimeout(Wx),Wx=setTimeout((()=>{Hx=Date.now(),kx.resume().then(e,t)}),1e3)):(clearTimeout(Wx),Hx=Date.now(),kx.resume().then(e,t))})).catch((e=>{ZO.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",Bx)}))}document.addEventListener("click",Bx);var jx=e=>kx,zx=class{constructor(e){this.name=e,iw(this,"node"),iw(this,"node2"),iw(this,"pre",new Set),iw(this,"next",new Set),iw(this,"context"),iw(this,"connectedNodes",new Set),iw(this,"nextInputChannelMap",new Map),iw(this,"_channelCount",1)}get channelCount(){return this._channelCount}set channelCount(e){this._channelCount=e,this.setChannelCount(this.node,e),this.setChannelCount(this.node2,e),this.next.forEach((t=>t.channelCount=e))}setChannelCount(e,t){!e||e instanceof ScriptProcessorNode||(e.channelCountMode="explicit",e.channelCount=t||this.channelCount||1)}setContext(e){this.context=e,this.node&&e.addMixWeight()}removeContext(){var e;this.node&&(null==(e=this.context)||e.reduceMixWeight()),delete this.context}replaceNode(e){var t;if(e!==this.node)try{this.node?this._disconnect():null==(t=this.context)||t.addMixWeight(),this.node=e,this.setChannelCount(this.node),this.preNodeReconnect(),this.reconnect()}catch(CC){ZO.error(CC)}}setNode(e,t){var r;if(!this.node)try{null==(r=this.context)||r.addMixWeight(),this.node=e,this.setChannelCount(this.node),t&&(this.node2=t,this.setChannelCount(this.node2)),this.preNodeReconnect(),this.reconnect(),RL.addSuccessEvent({key:502701})}catch(cM){ZO.error(cM),RL.addFailedEvent({key:502701,error:cM})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),RL.addSuccessEvent({key:502702})}catch(Sw){ZO.error(Sw),RL.addFailedEvent({key:502702,error:Sw})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>{let r=this.nextInputChannelMap.get(t);e._connect(t.node,r)||t.connectNext(e)}))}_connect(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!(!this.node||!e)&&((this.node2||this.node).connect(e,0,t),this.connectedNodes.add(e),!0)}_disconnect(){this.connectedNodes.forEach((e=>{var t;return null==(t=this.node2||this.node)?void 0:t.disconnect(e)})),this.connectedNodes.clear()}reconnect(){this._disconnect(),this.connectNext(this)}pipeTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.next.add(e),e.pre.add(this),this.nextInputChannelMap.set(e,t),e}},Kx=class extends zx{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,iw(this,"dataArray",new Uint8Array(0))}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,r=0,i="M".concat(t,",").concat(r);for(let o=0;o<e.length;o++)r=e[o]/128*100/2,i+="L".concat(t,",").concat(r),t+=1;return i}},qx=class{constructor(){iw(this,"source",new zx),iw(this,"gain",new zx),iw(this,"destination",new zx)}get volume(){var e;return(null==(e=this.gain.node)?void 0:e.gain.value)||1}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(jx().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){let t=Qx(e);t&&this.source.replaceNode(t)}get track(){var e;return null==(e=this.stream)?void 0:e.getAudioTracks()[0]}get stream(){var e;return null==(e=this.destination.node)?void 0:e.stream}},Yx=class extends qx{constructor(e){super(),this.context=e,iw(this,"aec",new zx("aec")),iw(this,"mixNode",new zx("mixNode")),iw(this,"silentNode",new zx("silentNode")),iw(this,"denoiser",new zx("denoiser")),iw(this,"voiceChanger",new zx("voiceChanger")),this.source.pipeTo(this.aec).pipeTo(this.denoiser).pipeTo(this.voiceChanger).pipeTo(this.gain).pipeTo(this.destination),this.silentNode.pipeTo(this.mixNode).pipeTo(this.aec,1)}get isProcessEnabled(){return this.aec.node||this.denoiser.node||this.voiceChanger.node||this.gain.node}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.aec.setContext(this.context),this.silentNode.setContext(this.context),this.mixNode.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.aec.removeContext(),this.silentNode.removeContext(),this.mixNode.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.aec.deleteNode(),this.silentNode.deleteNode(),this.mixNode.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},Jx=class{constructor(){iw(this,"audioContext",jx()),iw(this,"destination",this.audioContext.createMediaStreamDestination()),iw(this,"inputs",new Set),iw(this,"mixWeight",0),this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},Xx=new WeakMap;function Qx(e){try{let t=Xx.get(e);if(t)return t;let r=jx();if(e instanceof HTMLAudioElement)t=r.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=r.createMediaStreamSource(new MediaStream([e]))}return Xx.set(e,t),t}catch(sM){if(!(hk&&sM instanceof Error&&"NotSupportedError"===sM.name))throw sM;ZO.warn(sM)}}var $x=class e{constructor(e){iw(this,"_volume",0),iw(this,"_volumeDb",0),iw(this,"_log"),iw(this,"_scriptProcessorNode",null),iw(this,"_audioWorkletNode",null),iw(this,"_interval",200),iw(this,"ready",this.preload());let{log:t}=e;this._log=t,YO.on(XO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(!e.workletReady){let t='class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);';e.workletReady=Nx(e.audioContext,URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}return e.workletReady.then((()=>this.initAudioWorklet())).catch((e=>(this._log.error("volumeMeter preload error: ".concat(e)),this.initScriptProcessor())))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");let t=!1;this._audioWorkletNode.port.onmessage=r=>{e.lastMessageTime=Date.now(),this._volume=r.data.volume||0,this._volumeDb=r.data.volumeDb||0,!t&&r.data.cacheLen&&r.data.outputLen&&(this._log.warn("worklet play success"),t=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(sM){this._log.error("volumeMeter init audio worklet error: ".concat(sM)),ex.logFailedEvent({userId:this._log.userId,eventType:NC.LOAD_WORKLET,error:sM}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=jx().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let r=t.inputBuffer.getChannelData(0),i=0;for(let e=0;e<r.length;++e)i+=r[e]*r[e];this._volume=Math.sqrt(i/r.length)||0}}catch(sM){this._log.error("volumeMeter init script processor error: ".concat(sM))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,YO.off(XO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}getInternalAudioLevel(){return this._volume}getCalculatedVolume(){return parseFloat(this._volume.toFixed(2))}getVolumeDb(){return Math.floor(100*this._volumeDb)}handleAudioLevelInterval(e){var t;let{interval:r}=e;this._interval=r,null==(t=this._audioWorkletNode)||t.port.postMessage({name:"setIntervalTime",intervalTime:r})}};iw($x,"lastMessageTime",0),iw($x,"audioContext",jx()),iw($x,"workletReady");var Zx=$x,eU=class extends zx{constructor(e){super(),iw(this,"_volumeMeter"),this._volumeMeter=new Zx(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}init(){return nw(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}getVolumeDb(){return this._volumeMeter.getVolumeDb()}write(e){if(this.node){let t=e.allocationSize({planeIndex:0}),r=new Float32Array(t>>2);e.copyTo(r,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:r},[r.buffer]),e.close()}}},tU=Zx,rU=tw(aw(),1),iU=e=>t=>t.deviceId===e,oU=class{constructor(e,t){iw(this,"kind"),iw(this,"type"),iw(this,"devices",[]),this.kind=e,this.type=t}update(e,t){let r=e.filter((e=>e.kind==="".concat(this.kind).concat(this.type.toLocaleLowerCase())));1===this.devices.length&&sU(this.devices[0])||t&&(r.forEach((e=>{if(e.deviceId&&!this.devices.find(iU(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Added");ZO.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!r.find(iU(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Removed");ZO.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}}))),this.devices=r}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},nU=class extends rU.EventEmitter{constructor(){super(),iw(this,"audioInputs",new oU(eC.AUDIO,"Input")),iw(this,"videoInputs",new oU(eC.VIDEO,"Input")),iw(this,"audioOutputs",new oU(eC.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||YP.run("interval",(()=>{this.update()}),{delay:1e4}))}init(){lU().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return nw(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let r=yield lU(t);return e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e}()}))}hasBlueTooth(){var e;if(1e3*(null==(e=jx())?void 0:e.outputLatency)>150)return!0;let t=["bluetooth","air","wireless","bt","tws","buds","headset","headphone"];return this.audioOutputs.devices.some((e=>t.some((t=>e.label.toLowerCase().includes(t)))))||this.audioInputs.devices.some((e=>t.some((t=>e.label.toLowerCase().includes(t)))))}},aU=ww||bw?null:new nU;function sU(e){return e.deviceId===e.groupId&&""===e.groupId}function lU(){return nw(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(ML()||!kL())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let r={audio:!1,video:!1};if(t.forEach((e=>{sU(e)&&(e.kind===eC.AUDIO_INPUT?r.audio=!0:e.kind===eC.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),r.audio||r.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(r),r.audio&&Gx()}catch(cM){ZO.debug("capture before getDevices failed: ",cM)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let r={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&pU.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(r.getCapabilities=()=>e.getCapabilities()),r}))}()}))}function cU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return aU.update(e?1:0).then((e=>e.audioInputs.devices))}function dU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return aU.update(e?2:0).then((e=>e.videoInputs.devices))}var uU=!1;function hU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return nw(this,null,(function*(){return(sk||gO)&&(e=!1),aU.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var pU=new Set;function mU(e,t){return nw(this,null,(function*(){let r=(yield cU()).find((e=>e.deviceId===qC));return!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t}))}var fU,_U=class extends qx{constructor(e){super(),this.log=e,iw(this,"volumeMeter"),iw(this,"volumeMeterAfter3A"),iw(this,"volumeDestination"),iw(this,"analyser",new Kx),this.volumeMeter=new eU({log:this.log}),this.volumeMeterAfter3A=new eU({log:this.log}),this.volumeDestination=new zx,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},gU=class e extends ix{constructor(e){super(e,eC.AUDIO),iw(this,"_outputDeviceId"),iw(this,"_volume",1),iw(this,"_destination",jx().createMediaStreamDestination()),iw(this,"pipeline"),iw(this,"volumeMeterMode","worklet"),iw(this,"enableVolumeControlInIOS"),this.enableVolumeControlInIOS=e.enableVolumeControlInIOS,this.mode=0,e.url&&(this.url=e.url),this.pipeline=new _U(this._log)}setTrack(e){}get duration(){var e;return Math.floor(1e3*((null==(e=this.element)?void 0:e.duration)||0))}get currentTime(){var e;return Math.floor(1e3*((null==(e=this.element)?void 0:e.currentTime)||0))}set currentTime(e){this.element&&(this.element.currentTime=e/1e3)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(e){if(("15.2"===TO||"15.3"===TO||"15.4"===TO)&&this.muted)return void this._log.info("audioElement is muted.");let t=fU||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.url&&(t.crossOrigin="anonymous",t.src=this.url),this.element=t,KD(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===fU&&(fU=void 0),this.options.enableTimeupdateEvent&&(this.element.ontimeupdate=()=>this.emit(JP.TIME_UPDATE,this.currentTime)),this.bindElementEvents()}play(t){return nw(this,null,(function*(){if(this.track||this.url)return!this.pipeline.source.node&&this.track&&this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==t?void 0:t.volume),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?(this.pipeline.volumeMeter.init(),this.pipeline.volumeMeterAfter3A.init()):"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(jx().createAnalyser()),function(){nw(this,null,(function*(){try{uU||(uU=!0,ZO.info("speakers:".concat((yield hU()).map((e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label))))))}catch(e){}}))}(),ow(e.prototype,this,"play").call(this)}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}setSinkId(e){return nw(this,null,(function*(){var t,r;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(r=(t=this.element).setSinkId)?void 0:r.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){this.element&&(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}getInternalAudioLevelAfter3A(){return this.pipeline.volumeMeterAfter3A.getInternalAudioLevel()}},EU=class extends gU{setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(JP.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}},vU=class extends gU{constructor(e){super(e),iw(this,"_sourceElement"),iw(this,"_output",new zx),this.pipeline.source.pipeTo(this.pipeline.gain),this.pipeline.gain.pipeTo(this.pipeline.volumeMeter).pipeTo(this._output),this.pipeline.gain.pipeTo(this.pipeline.destination)}setOutput(){this.mode=1,this._output.setNode(jx().destination)}write(e){this.pipeline.volumeMeter.write(e)}setTrack(e){var t,r,i;(null==(r=null==(t=this.element)?void 0:t.error)?void 0:r.code)!==MediaError.MEDIA_ERR_DECODE&&this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(JP.MEDIA_TRACK_CHANGED,e),e?(this.bindTrackEvents(),this._sourceElement?this._sourceElement.srcObject=new MediaStream([e]):!this.useDestination&&this.element&&(this.element.srcObject=new MediaStream([e])),this.pipeline.source.channelCount=(null==(i=e.getSettings())?void 0:i.channelCount)||1,this.pipeline.replaceSource(e)):this.pipeline.source.deleteNode())}setVolume(e){if(this._volume=e,this.useDestination)this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e));else if(e<=1&&!sk)this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element");else{if(sk){if(!this.enableVolumeControlInIOS)return;!function(){if(!sk||-1!==Fx)return;let e=()=>{oN()-Ux<500||(kx&&"running"===kx.state&&kx.currentTime===Vx&&(ZO.warn("context is fake running, auto resume"),kx.suspend().catch((e=>{ZO.warn("context suspend failed: ".concat(e))}))),Vx=kx.currentTime,Ux=oN())};Fx=setInterval((()=>{e()}),2e3),document.addEventListener("visibilitychange",(()=>{"visible"===document.visibilityState&&e()}))}()}if(hk&&!this.pipeline.source.node)return void this._log.warn("set pipeline volume failed: no source node");this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),ZP(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play())}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&EO&&(fU=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},yU=class extends WP{constructor(e){let{userId:t,sdkAppId:r,mediaType:i,room:o,PlayerClass:n=(1===i?vU:Dx)}=e;var a;super(),iw(this,"id",eM()),iw(this,"userId",""),iw(this,"isRemote"),iw(this,"mediaType"),iw(this,"room"),iw(this,"user"),iw(this,"_log"),iw(this,"_inputTrack"),iw(this,"_outputTrack"),iw(this,"isPlayCalled"),iw(this,"container",null),iw(this,"player"),iw(this,"subVideoPlayerMap"),iw(this,"muted",!1),iw(this,"abortCtrl"),iw(this,"objectFit","cover"),iw(this,"mirror"),iw(this,"rotation"),iw(this,"isScreen",!1),iw(this,"manager"),iw(this,"trackSettings"),iw(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=i,this._log=ZO.createLogger({parent:null==o?void 0:o.getLogger(),id:"".concat(this.kind[0],"t"),userId:null==(a=o||this.room)?void 0:a.userId,remoteUserId:this instanceof oB?void 0:this.userId,sdkAppId:r,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof oB}),this.player=new n({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log,enableVolumeControlInIOS:null==o?void 0:o.enableVolumeControlInIOS}),this.player.on(JP.PLAYER_STATE_CHANGED,(e=>{if(YO.emit(XO.PLAYER_STATE_CHANGED,Qb({track:this},e)),this.emit("player-state-changed",e),"PLAYING"===e.state&&this.room){let e=!0;for(let{remoteAudioTrack:t,remoteVideoTrack:r,remoteAuxiliaryTrack:i}of[...this.room.remotePublishedUserMap.values()])if(t.isAvailable&&!t.player.isPlaying||r.isAvailable&&!r.player.isPlaying||i.isAvailable&&!i.player.isPlaying){e=!1;break}e&&Tx()&&bx&&(bx.deleteDialog(),bx=null)}})),this.kind===eC.VIDEO&&(this.player.on(JP.LOADED_DATA,(()=>{this.emitFirstVideoFrameEvent(JP.LOADED_DATA),YO.emit(XO.VIDEO_LOADED_DATA,{track:this})})),this.player.on(JP.LOADED_META_DATA,(()=>{this.emitFirstVideoFrameEvent(JP.LOADED_META_DATA)})),this.player.on(JP.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))})),this.player.on(JP.RESIZE,(e=>{this.emitFirstVideoFrameEvent(JP.RESIZE),this.emit("video-size-changed",Qb({userId:this.userId,streamType:2===this.mediaType?"auxiliary":"main"},e))}))),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this),this.onPlayerError&&this.player.on(JP.ERROR,this.onPlayerError.bind(this))}get log(){return this._log||ZO}get kind(){return 1===this.mediaType?eC.AUDIO:eC.VIDEO}get isAudio(){return this.kind===eC.AUDIO}get strMediaType(){return 4===this.mediaType?eC.VIDEO:2===this.mediaType?eC.SCREEN:eC.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}play(e,t){return nw(this,null,(function*(){let r=JD(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!jD(t.muted)&&this.setPlayerMute(t.muted),t&&!jD(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof Dx&&(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),JD(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!jD(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===eC.VIDEO)&&this.setPlayerMute(!0),t&&!jD(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof Dx&&(this.player.setObjectFit(this.objectFit),t&&!jD(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof Dx&&this.player.setContainer(r)),YO.emit(XO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(t),JD(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(hM){throw this.handleAutoPlayFailed(hM),hM}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==eC.VIDEO||jD(e)||e===this.mirror)return;this.mirror=e;let r=this.player;t&&(r=t);let i=this.manager;if(qD(this.mirror))return r.setViewMirror(this.mirror),void(!this.isRemote&&i&&(i.mirror=!1));switch(this.mirror){case"view":i&&(i.mirror=!1),r.setViewMirror(!0);break;case"publish":i&&(i.mirror=!0),r.setViewMirror(!0);break;case"both":i&&(i.mirror=!0),r.setViewMirror(!1)}}playSubContainer(e,t){return nw(this,null,(function*(){if(!this._outputTrack||this.kind===eC.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,r)=>{var i;e.find((e=>r===e))||(t.stop(),null==(i=this.subVideoPlayerMap)||i.delete(r))}));for(let[i,o]of e.entries()){let e=this.subVideoPlayerMap.get(o);e?t&&(jD(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(o,new Dx({id:this.userId||this.id,track:this.playerMediaTrack,container:o,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let r=[...this.subVideoPlayerMap.values()];for(let e of r)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.isFirstVideoFrameEmitted=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(KN(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return nw(this,null,(function*(){var e;this.isPlayCalled&&(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),YO.emit(e?XO.TRACK_MUTED:XO.TRACK_UNMUTED,{track:this})}setPlayerMute(e){this.player.setMuted(e)}get mediaTrack(){return this._inputTrack||null}get outMediaTrack(){return this._outputTrack||null}get playerMediaTrack(){return this.outMediaTrack}installTrackEvent(e){$P(e,e).add(eC.MUTE,this.onTrackMuted).add(eC.UNMUTE,this.onTrackUnmuted).add(eC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===eC.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){ZP(e)}setInputMediaStreamTrack(e){var t;let r=this._inputTrack;if(e!==r)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,r&&this.uninstallTrackEvent(r),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,r||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((e=>this.handleAutoPlayFailed(e))),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(KN(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(e){return nw(this,null,(function*(){var t;this.log.warn("handleAutoPlayFailed",e);let r=()=>{this.resume().then((()=>{document.removeEventListener("click",r,!0)}))};if(this.room&&this.room.enableAutoPlayDialog){if((bk||kk)&&(yield SN(100),null!=(t=this.player)&&t.isPlaying))return;wx()}else document.addEventListener("click",r,!0);YO.once(XO.LOCAL_TRACK_CAPTURE_SUCCESS,(e=>{let{track:t}=e;"audio"===t.kind&&Tx()&&!this.player.isPlaying&&this.isRemote&&this.isAvailable&&r()})),this.emit("error",e)}))}getVideoFrame(){return this.player instanceof Dx?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,r,i;if(this.isFirstVideoFrameEmitted)return;let o=null==(t=this.mediaTrack)?void 0:t.getSettings(),n=(null==o?void 0:o.width)||(null==(r=this.player.element)?void 0:r.videoWidth)||0,a=(null==o?void 0:o.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;e===JP.RESIZE&&!n&&!a||e===JP.LOADED_META_DATA&&!n&&!a||(e===JP.LOADED_DATA&&!n&&!a&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,DN(this.rotation)&&([n,a]=[a,n]),this.emit("first-video-frame",{width:n,height:a,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}onTrackMuted(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}onTrackUnmuted(){this._log.info("".concat(this.kind," track is able to provide media output"))}onTrackEnded(){this._log.warn("".concat(this.kind," track ended"))}};rw([FP([],WP.INIT,{sync:!0})],yU.prototype,"close",1);var TU=Object.prototype.hasOwnProperty;var IU=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(FD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(TU.call(e,t))return!1;return!0}return!1},AU=YN({retryFunction:function(e){return nw(this,null,(function*(){let t=function(e){return{audio:RU(e),video:bU(e)}}(e);ZO.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],i=[],o=["label","deviceId","groupId"];if(t.audio&&(r=yield cU(),ZO.info("microphones: ".concat(gN(r.map((e=>$b(Qb({},e),{groupId:e.groupId.substring(0,8)}))),{keysToInclude:o})))),t.video&&(i=yield dU(),ZO.info("cameras: ".concat(gN(i,{keysToInclude:o}))),!qD(t.video)&&"user"===t.video.facingMode&&!t.video.deviceId)){let e=i.filter((e=>!e.label.includes("infrared"))).find((e=>e.label.includes("facing front")));e&&(t.video.deviceId=e.deviceId,ZO.info("exclude infrared camera: ".concat(JSON.stringify(t))))}try{let r=yield navigator.mediaDevices.getUserMedia(t);return uP&&r.getTracks().forEach((t=>{var r;let i=t.getCapabilities();ZO.info("".concat(t.kind," capabilities: ").concat(gN(i,{keysToInclude:eD}))),!jD(e.echoCancellation)&&-1===(null==(r=i.echoCancellation)?void 0:r.indexOf(e.echoCancellation))&&ZO.warn("Invalid argument for 'echoCancellation'. Expected one of [".concat(JSON.stringify(i.echoCancellation),"], but received '").concat(e.echoCancellation,"'"))})),t.audio&&Gx(),r}catch(hM){let{message:o}=hM;throw"NotFoundError"===hM.name&&(e.video&&i&&0===i.length&&(o=mL({key:dL.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(o=mL({key:dL.MICROPHONE_NOT_FOUND}))),new mw({code:hw.INITIALIZE_FAILED,name:hM.name,message:o,constraint:hM.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:r,reject:i,retryFuncArgs:o,retriedCount:n}=e,a=n+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name||"AbortError"===t.name?(1===a?(o[0].video&&(o[0].maxResolution=!1,(!gO||o[0].width*o[0].height<=2073600)&&o[0].frameRate&&(o[0].frameRate=o[0].frameRate>10?10:5)),o[0].retryWhenExactFailed&&o[0].useExactDeviceId&&(o[0].useExactDeviceId=!1)):2===a?o[0].useDeviceIdOnly=!0:3===a&&!o[0].useExactDeviceId&&(o[0].useTrueAsConstraint=!0),r()):i(t),o[0].microphoneId&&SU(o[0].microphoneId,!1),o[0].cameraId&&SU(o[0].cameraId,!0)},onRetrying:e=>{ZO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{ex.logFailedEvent({eventType:NC.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{ex.logSuccessEvent({eventType:NC.GET_USER_MEDIA_RETRY}),ex.uploadEvent({log:"stat-".concat(NC.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function SU(e,t){return nw(this,null,(function*(){let r=(t?yield dU():yield cU()).find((t=>t.deviceId===e));r&&GD(r.getCapabilities)&&ZO.warn(gN(r.getCapabilities(),{keysToInclude:eD}))}))}function RU(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!IU(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(KD(e.channelCount)&&(t.channelCount=e.channelCount),(qD(e.echoCancellation)||"remote-only"===e.echoCancellation||"all"===e.echoCancellation)&&(t.echoCancellation=e.echoCancellation),qD(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),qD(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!IU(t)||t)}function bU(e){if(!e.video)return!1;if(e.useTrueAsConstraint)return!0;let{maxResolution:t=!0}=e,r={};return e.cameraId?r.deviceId=e.useExactDeviceId?{exact:e.cameraId}:e.cameraId:e.facingMode&&(r.facingMode=e.facingMode),e.useDeviceIdOnly&&!IU(r)?r:(e.width&&(r.width={ideal:e.width},t&&!hk&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},t&&!hk&&(r.height.max=e.height)),hk&&Gk&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!IU(r)||r)}var wU=AU;function CU(e){return DU(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return nw(this,null,(function*(){let r=yield t.apply(this,i);return yield e.call(this,...i),r}))}))}function DU(e){return function(t,r,i){return i.value=e(i.value,r),i}}var NU=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&ZO.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{ZO.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),kU=0,OU=class{constructor(){iw(this,"log",ZO.createLogger({id:"fq".concat(++kU)})),iw(this,"isRunning",!1),iw(this,"queue",[])}get length(){return this.queue.length}get lastQueueItem(){return 0===this.length?null:this.queue[this.length-1]}push(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;let o=Qb({},e),n=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));return o.promise=n,t?this.length<=1?this.queue.push(o):null==(i=null==(r=this.lastQueueItem)?void 0:r.promise)||i.then(o.resolve,o.reject):this.queue.push(o),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),n}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}callNext(){if(this.isRunning||0===this.length)return;this.log.debug("callNext ",this.length);let{fn:e,args:t,context:r,resolve:i,reject:o}=this.queue[0];this.isRunning=!0,e.apply(r,t).then(i,o).finally((()=>{this.isRunning=!1,this.shift(),this.callNext()}))}},MU=new WeakMap,LU=new WeakMap;function PU(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,r,i){let o=i.value;return i.value=function(){let t=MU.get(this)||new OU;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return MU.set(this,t),t.push({fn:o,args:i,context:this},e)},i}}function xU(e){return function(t,r,i){let o=i.value,n=t=>e(...t);return i.value=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];let i=LU.get(this)||new Map,a=i.get(n(t))||new OU;return i.set(n(t),a),LU.set(this,i),a.push({fn:o,args:t,context:this})},i}}function UU(e,t){return DU(((r,i)=>function(){let i=e;try{for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let e=r.apply(this,n),s=oN();return $D(e)?e.then((e=>(t?RL.addSuccessEvent({key:i,cost:oN()-s}):RL.addSuccessEvent({key:i}),e))).catch((e=>{throw RL.addFailedEvent({key:i,error:e}),e})):(RL.addSuccessEvent({key:i}),e)}catch(Rw){throw RL.addFailedEvent({key:i,error:Rw}),Rw}}))}var VU={};function FU(){}ew(VU,{Events:()=>eV,Inspect:()=>zU,LastSink:()=>KU,Sink:()=>qU,Subscribe:()=>YU,TimeoutError:()=>tV,audit:()=>lF,bindCallback:()=>UV,bindNodeCallback:()=>VV,buffer:()=>mV,bufferCount:()=>pV,bufferTime:()=>zF,call:()=>BU,catchError:()=>qF,combineLatest:()=>cV,concat:()=>aV,concatMap:()=>MF,concatMapTo:()=>LF,count:()=>jV,create:()=>XU,debounce:()=>uF,debounceTime:()=>hF,defer:()=>gV,delay:()=>KF,deliver:()=>QU,dispose:()=>WU,elementAt:()=>pF,empty:()=>HV,every:()=>EF,exhaustMap:()=>HF,exhaustMapTo:()=>WF,expand:()=>JF,filter:()=>YV,find:()=>mF,findIndex:()=>fF,first:()=>_F,fromAnimationFrame:()=>PV,fromArray:()=>SV,fromEvent:()=>DV,fromEventPattern:()=>CV,fromFetch:()=>kV,fromIterable:()=>OV,fromPromise:()=>NV,fromReadableStream:()=>LV,fromReader:()=>MV,groupBy:()=>GF,identity:()=>HU,ignoreElements:()=>JV,iif:()=>lV,inspect:()=>GU,interval:()=>RV,last:()=>gF,map:()=>IF,mapTo:()=>AF,max:()=>zV,merge:()=>oV,mergeMap:()=>UF,mergeMapTo:()=>VF,min:()=>KV,never:()=>FV,nothing:()=>FU,of:()=>AV,pairwise:()=>yF,pipe:()=>JU,race:()=>nV,range:()=>xV,reduce:()=>GV,retry:()=>tB,scan:()=>vF,setAsapScheduler:()=>TV,share:()=>iV,shareReplay:()=>sV,skip:()=>eF,skipUntil:()=>tF,skipWhile:()=>rF,startWith:()=>uV,subject:()=>_V,subscribe:()=>$F,sum:()=>qV,switchMap:()=>CF,switchMapTo:()=>NF,take:()=>XV,takeLast:()=>ZV,takeUntil:()=>QV,takeWhile:()=>$V,tap:()=>ZF,throttle:()=>aF,throwError:()=>BV,timeInterval:()=>jF,timeout:()=>eB,timer:()=>bV,toPromise:()=>XF,toReadableStream:()=>QF,withLatestFrom:()=>hV,zip:()=>dV});var BU=e=>e(),HU=e=>e;function WU(){this.dispose()}var GU=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,jU=1,zU=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new ZU(e,this,this.streamId++);return eV.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},KU=class{constructor(){this.defers=new Set,this.disposed=!1}next(e){}complete(){this.dispose()}error(e){this.dispose()}get bindDispose(){return()=>this.dispose()}dispose(){this.disposed=!0,this.complete=FU,this.error=FU,this.next=FU,this.dispose=FU,this.subscribe=FU,this.doDefer()}subscribe(e){return e instanceof zU?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(BU),this.defers.clear()}defer(e){this.defers.add(e)}removeDefer(e){this.defers.delete(e)}reset(){this.disposed=!1,delete this.complete,delete this.next,delete this.dispose,delete this.next,delete this.subscribe}resetNext(){delete this.next}resetComplete(){delete this.complete}resetError(){delete this.error}},qU=class extends KU{constructor(e){super(),this.sink=e,e.defer(this.bindDispose)}next(e){this.sink.next(e)}complete(){this.sink.complete()}error(e){this.sink.error(e)}},YU=class extends KU{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:FU,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:FU,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:FU;if(super(),this._next=t,this._error=r,this._complete=i,this.then=FU,e instanceof zU){let o={toString:()=>"subscribe",id:0,source:e};this.defer((()=>{eV.defer(o,0)})),eV.create(o),eV.pipe(o),this.sourceId=o.id,this.subscribe(e),eV.subscribe({id:o.id,end:!0}),t==FU?this._next=e=>eV.next(o,0,e):this.next=e=>{eV.next(o,0,e),t(e)},i==FU?this._complete=()=>eV.complete(o,0):this.complete=()=>{this.dispose(),eV.complete(o,0),i()},r==FU?this._error=e=>eV.complete(o,0,e):this.error=e=>{this.dispose(),eV.complete(o,0,e),r(e)}}else this.subscribe(e)}next(e){this._next(e)}complete(){this.dispose(),this._complete()}error(e){this.dispose(),this._error(e)}};function JU(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return r.reduce(((e,t)=>t(e)),e)}function XU(e,t,r){if(GU()){let i=Object.defineProperties(Object.setPrototypeOf(e,zU.prototype),{streamId:{value:0,writable:!0,configurable:!0},name:{value:t,writable:!0,configurable:!0},args:{value:r,writable:!0,configurable:!0},id:{value:0,writable:!0,configurable:!0}});eV.create(i);for(let e=0;e<r.length;e++){let t=r[e];"function"==typeof t&&t instanceof zU&&eV.addSource(i,t)}return i}return e}function QU(e,t){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return r=>{if(r instanceof zU){let o=XU((t=>{let n=new e(t,...i);n.sourceId=o.id,n.subscribe(r)}),t,arguments);return o.source=r,eV.pipe(o),o}return t=>r(new e(t,...i))}}}function $U(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var ZU=class extends qU{constructor(e,t,r){super(e),this.source=t,this.id=r,this.sourceId=e.sourceId,this.defer((()=>{eV.defer(this.source,this.id)}))}next(e){eV.next(this.source,this.id,e),this.sink.next(e)}complete(){eV.complete(this.source,this.id),this.sink.complete()}error(e){eV.complete(this.source,this.id,e),this.sink.error(e)}},eV={addSource(e,t){$U("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,r){$U("next",{id:e.id,streamId:t,data:r&&r.toString()})},subscribe(e,t){let{id:r,end:i}=e;$U("subscribe",{id:r,end:i,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,r){$U("complete",{id:e.id,streamId:t,err:r?r.toString():null})},defer(e,t){$U("defer",{id:e.id,streamId:t})},pipe(e){$U("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){$U("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=jU++),$U("create",{name:e.toString(),id:e.id})}},tV=class extends Error{constructor(e){super("timeout after ".concat(e,"ms")),this.timeout=e}},rV=class extends KU{constructor(e){super(),this.source=e,this.sinks=new Set}add(e){e.defer((()=>this.remove(e))),1===this.sinks.add(e).size&&(this.reset(),this.subscribe(this.source))}remove(e){this.sinks.delete(e),0===this.sinks.size&&this.dispose()}next(e){this.sinks.forEach((t=>t.next(e)))}complete(){this.sinks.forEach((e=>e.complete())),this.sinks.clear()}error(e){this.sinks.forEach((t=>t.error(e))),this.sinks.clear()}};function iV(){return e=>{let t=new rV(e);if(e instanceof zU){let r=XU((e=>{t.add(e)}),"share",arguments);return t.sourceId=r.id,r.source=e,eV.pipe(r),r}return XU(t.add.bind(t),"share",arguments)}}function oV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU((e=>{let r=new qU(e),i=t.length;r.complete=()=>{0==--i&&e.complete()},t.forEach(r.bindSubscribe)}),"merge",arguments)}function nV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU((e=>{let r=new Map;t.forEach((t=>{let i=new qU(e);r.set(t,i),i.complete=()=>{r.delete(t),0===r.size?e.complete():i.dispose()},i.next=e=>{r.delete(t),r.forEach((e=>e.dispose())),i.resetNext(),i.resetComplete(),i.next(e)}})),t.forEach((e=>r.get(e).subscribe(e)))}),"race",arguments)}function aV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU((e=>{let r=0,i=t.length,o=new qU(e);o.complete=()=>{r<i&&!o.disposed?(o.doDefer(),o.subscribe(t[r++])):e.complete()},o.complete()}),"concat",arguments)}function sV(e){return t=>{let r=new rV(t),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((e=>e.next(t)))},XU((e=>{e.defer((()=>r.remove(e))),i.forEach((t=>e.next(t))),r.add(e)}),"shareReplay",arguments)}}function lV(e,t,r){return XU((i=>e()?t(i):r(i)),"iif",arguments)}function cV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU((e=>{let r=t.length,i=r,o=r,n=new Array(r),a=()=>{0==--o&&e.complete()};t.forEach(((t,r)=>{let o=new qU(e);o.next=t=>{i--,o.next=t=>{n[r]=t,0===i&&e.next(n)},o.next(t)},o.complete=a,o.subscribe(t)}))}),"combineLatest",arguments)}function dV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU((e=>{let r=t.length,i=r,o=new Array(r),n=()=>{0==--i&&e.complete()};t.forEach(((t,r)=>{let i=new qU(e),a=[];o[r]=a,i.next=t=>{a.push(t),o.every((e=>e.length))&&e.next(o.map((e=>e.shift())))},i.complete=n,i.subscribe(t)}))}),"zip",arguments)}function uV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return e=>XU((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;i<o&&!r.disposed;)r.next(t[i++]);r.disposed||r.subscribe(e)}),"startWith",arguments)}var hV=QU(class extends qU{constructor(e){super(e);let t=new qU(this.sink);for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.next=e=>this.buffer=e,t.complete=FU,t.subscribe(cV(...i))}next(e){this.buffer&&this.sink.next([e,...this.buffer])}},"withLatestFrom"),pV=QU(class extends qU{constructor(e,t,r){super(e),this.bufferSize=t,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((t=>{t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((e=>this.sink.next(e))),super.complete()}},"bufferCount"),mV=QU(class extends qU{constructor(e,t){super(e),this.buffer=[];let r=new qU(e);r.next=t=>{e.next(this.buffer),this.buffer=[]},r.complete=FU,r.subscribe(t)}next(e){this.buffer.push(e)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},"buffer"),fV=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{l(i.next(e))}catch(t){n(t)}}function s(e){try{l(i.throw(e))}catch(t){n(t)}}function l(e){e.done?o(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(a,s)}l((i=i.apply(e,t||[])).next())}))};function _V(e){let t=arguments,r=iV()(XU((t=>{r.next=e=>t.next(e),r.complete=()=>t.complete(),r.error=e=>t.error(e),e&&t.subscribe(e)}),"subject",t));return r.next=FU,r.complete=FU,r.error=FU,r}function gV(e){return XU((t=>t.subscribe(e())),"defer",arguments)}var EV={promise:e=>{Promise.resolve().then(e)},setImmediate:"undefined"!=typeof setImmediate?e=>setImmediate(e):null,setTimeout:e=>setTimeout(e,0)},vV="undefined"!=typeof Promise?EV.promise:EV.setImmediate?EV.setImmediate:EV.setTimeout,yV=e=>t=>{vV((()=>e(t)))},TV=e=>{"function"==typeof e?vV=e:EV[e]&&(vV=EV[e])},IV=e=>yV((t=>{for(let r=0;!t.disposed&&r<e.length;r++)t.next(e[r]);t.complete()}));function AV(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return XU(IV(t),"of",arguments)}function SV(e){return XU(IV(e),"fromArray",arguments)}function RV(e){return XU((t=>{let r=0,i=setInterval((()=>t.next(r++)),e);return t.defer((()=>{clearInterval(i)})),"interval"}),"interval",arguments)}function bV(e,t){return XU((r=>{let i=0,o=setTimeout((()=>{if(r.removeDefer(n),r.next(i++),t){let e=setInterval((()=>r.next(i++)),t);r.defer((()=>{clearInterval(e)}))}else r.complete()}),e),n=()=>clearTimeout(o);r.defer(n)}),"timer",arguments)}function wV(e,t){return r=>{let i=e=>r.next(e);r.defer((()=>t(i))),e(i)}}function CV(e,t){return XU(wV(e,t),"fromEventPattern",arguments)}function DV(e,t){if("on"in e&&"off"in e)return XU(wV((r=>e.on(t,r)),(r=>e.off(t,r))),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return XU(wV((r=>e.addListener(t,r)),(r=>e.removeListener(t,r))),"fromEvent",arguments);if("addEventListener"in e)return XU(wV((r=>e.addEventListener(t,r)),(r=>e.removeEventListener(t,r))),"fromEvent",arguments);throw"target is not a EventDispachter"}function NV(e){return XU((t=>{e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function kV(e,t){return XU(gV((()=>NV(fetch(e,t)))),"fromFetch",arguments)}function OV(e){return XU(yV((t=>{try{for(let r of e){if(t.disposed)return;t.next(r)}t.complete()}catch(Sw){t.error(Sw)}})),"fromIterable",arguments)}function MV(e){let t=r=>fV(this,void 0,void 0,(function*(){if(r.disposed)return;let{done:i,value:o}=yield e.read();i?r.complete():(r.next(o),t(r))}));return XU((e=>{t(e)}),"fromReader",arguments)}function LV(e){return XU((t=>{let r=new AbortController,i=r.signal;t.defer((()=>r.abort("cancelled"))),e.pipeTo(new WritableStream({write(e){t.next(e)},close(){t.complete()},abort(e){t.error(e)}}),{signal:i}).then((()=>t.complete()),(e=>t.error(e)))}),"fromReadableStream",arguments)}function PV(){return XU((e=>{let t=requestAnimationFrame((function r(i){e.disposed||(e.next(i),t=requestAnimationFrame(r))}));e.defer((()=>cancelAnimationFrame(t)))}),"fromAnimationFrame",arguments)}function xV(e,t){return XU((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;for(;i<o&&!r.disposed;)r.next(i++);return r.complete(),"range"}),"range",arguments)}function UV(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return XU((r=>{let o=i.concat((e=>(r.next(e),r.complete())));e.apply(t,o)}),"bindCallback",arguments)}function VV(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return XU((r=>{let o=i.concat(((e,t)=>e?r.error(e):(r.next(t),r.complete())));e.apply(t,o)}),"bindNodeCallback",arguments)}function FV(){return XU((()=>{}),"never",arguments)}function BV(e){return XU((t=>t.error(e)),"throwError",arguments)}function HV(){return XU((e=>e.complete()),"empty",arguments)}var WV=class extends qU{constructor(e,t,r){super(e),this.f=t;let i=()=>{this.sink.next(this.acc),this.sink.complete()};void 0===r?this.next=e=>{this.acc=e,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(e){this.acc=this.f(this.acc,e)}},GV=QU(WV,"reduce"),jV=e=>QU(WV,"count")(((t,r)=>e(r)?t+1:t),0),zV=()=>QU(WV,"max")(Math.max),KV=()=>QU(WV,"min")(Math.min),qV=()=>QU(WV,"sum")(((e,t)=>e+t),0),YV=QU(class extends qU{constructor(e,t,r){super(e),this.filter=t,this.thisArg=r}next(e){this.filter.call(this.thisArg,e)&&this.sink.next(e)}},"filter"),JV=QU(class extends qU{next(e){}},"ignoreElements"),XV=QU(class extends qU{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0==--this.count&&(this.doDefer(),this.complete())}},"take"),QV=QU(class extends qU{constructor(e,t){super(e);let r=new qU(e);r.next=()=>{r.doDefer(),e.complete()},r.complete=WU,r.subscribe(t)}},"takeUntil"),$V=QU(class extends qU{constructor(e,t){super(e),this.f=t}next(e){this.f(e)?this.sink.next(e):(this.doDefer(),this.complete())}},"takeWhile"),ZV=e=>GV(((t,r)=>(t.push(r),t.length>e&&t.shift(),t)),[]),eF=QU(class extends qU{constructor(e,t){super(e),this.count=t}next(e){0==--this.count&&(this.next=super.next)}},"skip"),tF=QU(class extends qU{constructor(e,t){super(e),e.next=FU;let r=new qU(e);r.next=()=>{r.doDefer(),e.resetNext()},r.complete=WU,r.subscribe(t)}},"skipUntil"),rF=QU(class extends qU{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),iF={leading:!0,trailing:!1},oF=class extends qU{constructor(e,t,r){super(e),this.durationSelector=t,this.trailing=r}cacheValue(e){this.last=e,this.disposed&&this.throttle(e)}send(e){this.sink.next(e),this.throttle(e)}throttle(e){this.reset(),this.subscribe(this.durationSelector(e))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},nF=class extends qU{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:iF;super(e),this.durationSelector=t,this.config=r,this._throttle=new oF(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}complete(){this._throttle.throttle=FU,this._throttle.complete(),super.complete()}},aF=QU(nF,"throttle"),sF={leading:!1,trailing:!0},lF=e=>QU(nF,"audit")(e,sF),cF=class extends qU{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},dF=class extends qU{constructor(e,t){super(e),this.durationSelector=t,this._debounce=new cF(this.sink),this._debounce.dispose()}next(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}complete(){this._debounce.complete(),super.complete()}},uF=QU(dF,"debounce"),hF=e=>QU(dF,"debounceTime")((t=>bV(e))),pF=QU(class extends qU{constructor(e,t,r){super(e),this.count=t,this.defaultValue=r}next(e){0==this.count--&&(this.defaultValue=e,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("not enough elements in sequence"))}},"elementAt"),mF=e=>t=>XV(1)(rF((t=>!e(t)))(t)),fF=QU(class extends qU{constructor(e,t){super(e),this.f=t,this.i=0}next(e){this.f(e)?(this.sink.next(this.i++),this.doDefer(),this.complete()):++this.i}},"findIndex"),_F=QU(class extends qU{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.doDefer(),this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"first"),gF=QU(class extends qU{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"last"),EF=QU(class extends qU{constructor(e,t){super(e),this.predicate=t,this.index=0}next(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.doDefer(),this.complete())}complete(){void 0!==this.result?(this.sink.next(this.result),super.complete()):this.error(new Error("no elements in sequence"))}},"every"),vF=QU(class extends qU{constructor(e,t,r){super(e),this.f=t,void 0===r?this.next=e=>{this.acc=e,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(e){this.sink.next(this.acc=this.f(this.acc,e))}},"scan"),yF=QU(class extends qU{constructor(){super(...arguments),this.hasLast=!1}next(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}},"pairwise"),TF=class extends qU{constructor(e,t,r){super(e),this.mapper=t,this.thisArg=r}next(e){super.next(this.mapper.call(this.thisArg,e))}},IF=QU(TF,"map"),AF=e=>QU(TF,"mapTo")((t=>e)),SF=class extends qU{constructor(e,t,r){super(e),this.data=t,this.context=r}next(e){let t=this.context.combineResults;t?this.sink.next(t(this.data,e)):this.sink.next(e)}tryComplete(){this.context.resetComplete(),this.dispose()}},RF=class e extends qU{constructor(e,t,r){super(e),this.makeSource=t,this.combineResults=r,this.index=0}subInner(t,r){let i=this.currentSink=new r(this.sink,t,this);this.complete===e.prototype.complete&&(this.complete=this.tryComplete),i.complete=i.tryComplete,i.subscribe(this.makeSource(t,this.index++))}complete(){this.sink.complete()}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},bF=class extends SF{},wF=class extends RF{next(e){this.subInner(e,bF),this.next=e=>{this.currentSink.dispose(),this.subInner(e,bF)}}},CF=QU(wF,"switchMap");function DF(e){return(t,r)=>e((()=>t),r)}var NF=DF(QU(wF,"switchMapTo")),kF=class extends SF{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},OF=class extends RF{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(e){this.next2(e),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),kF),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}tryComplete(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}},MF=QU(OF,"concatMap"),LF=DF(QU(OF,"concatMapTo")),PF=class extends SF{tryComplete(){this.context.inners.delete(this),super.dispose(),0===this.context.inners.size&&this.context.resetComplete()}},xF=class extends RF{constructor(){super(...arguments),this.inners=new Set}next(e){this.subInner(e,PF),this.inners.add(this.currentSink)}tryComplete(){1===this.inners.size?this.inners.forEach((e=>e.resetComplete())):this.dispose()}},UF=QU(xF,"mergeMap"),VF=DF(QU(xF,"mergeMapTo")),FF=class extends SF{dispose(){this.context.resetNext(),super.dispose()}},BF=class extends RF{next(e){this.next=FU,this.subInner(e,FF)}},HF=QU(BF,"exhaustMap"),WF=DF(QU(BF,"exhaustMapTo")),GF=QU(class extends qU{constructor(e,t){super(e),this.f=t,this.groups=new Map}next(e){let t=this.f(e),r=this.groups.get(t);void 0===r&&(r=_V(),r.key=t,this.groups.set(t,r),super.next(r)),r.next(e)}complete(){this.groups.forEach((e=>e.complete())),super.complete()}error(e){this.groups.forEach((t=>t.error(e))),super.error(e)}},"groupBy"),jF=QU(class extends qU{constructor(){super(...arguments),this.start=new Date}next(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},"timeInterval"),zF=QU(class extends qU{constructor(e,t){super(e),this.miniseconds=t,this.buffer=[],this.id=setInterval((()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0}),this.miniseconds)}next(e){this.buffer.push(e)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},"bufferTime"),KF=QU(class extends qU{constructor(e,t){super(e),this.buffer=[],this.delayTime=t}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(e){this.timeoutId=setTimeout((()=>{let e=this.buffer.shift();if(e){let{time:t,data:r}=e;super.next(r),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(t))}}),e)}next(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}complete(){this.timeoutId=setTimeout((()=>super.complete()),this.delayTime)}},"delay"),qF=QU(class extends qU{constructor(e,t){super(e),this.selector=t}error(e){this.dispose(),this.selector(e)(this.sink)}},"catchError"),YF=class extends SF{tryComplete(){let e=this.context.inners.delete(this);super.dispose(),e&&this.context.checkComplete()}next(e){this.sink.next(e),this.context.expandValue(e)}},JF=QU(class extends RF{constructor(e,t){super(e,t),this.project=t,this.inners=new Set,this.sourceCompleted=!1}next(e){this.sink.next(e),this.expandValue(e)}expandValue(e){let t=new YF(this.sink,e,this);this.currentSink=t,this.complete=this.tryComplete,t.complete=t.tryComplete,this.inners.add(t),t.subscribe(this.makeSource(e,this.index++))}complete(){this.sourceCompleted=!0,this.checkComplete()}checkComplete(){this.sourceCompleted&&0===this.inners.size&&(this.resetComplete(),super.complete())}tryComplete(){this.sourceCompleted=!0,this.checkComplete()}},"expand"),XF=()=>e=>new Promise(((t,r)=>{let i;new YU(e,(e=>i=e),r,(()=>t(i)))})),QF=()=>e=>{let t;return new ReadableStream({start(r){t=new YU(e,r.enqueue.bind(r),r.error.bind(r),r.close.bind(r))},cancel(){t.dispose()}})},$F=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:FU,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:FU,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:FU;return i=>new YU(i,e,t,r)},ZF=QU(class extends qU{constructor(e,t){super(e),t instanceof Function?this.next=r=>{t(r),e.next(r)}:(t.next&&(this.next=r=>{t.next(r),e.next(r)}),t.complete&&(this.complete=()=>{t.complete(),e.complete()}),t.error&&(this.error=r=>{t.error(r),e.error(r)}))}},"tap"),eB=QU(class extends qU{constructor(e,t){super(e),this.timeout=t,this.id=setTimeout((()=>this.error(new tV(this.timeout))),this.timeout)}next(e){super.next(e),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},"timeout"),tB=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return t=>{if(t instanceof zU){let r=XU((i=>{let o=e,n=new qU(i);n.error=e=>{o-- >0?n.subscribe(t):i.error(e)},n.sourceId=r.id,n.subscribe(t)}),"retry",[e]);return r.source=t,eV.pipe(r),r}return r=>{let i=e,o=new qU(r);o.error=e=>{i-- >0?t(o):r.error(e)},t(o)}}},rB=(e=>(e[e.AUTO_SWITCH_NEW_DEVICE=0]="AUTO_SWITCH_NEW_DEVICE",e[e.WAIT_CURRENT_DEVICE=1]="WAIT_CURRENT_DEVICE",e))(rB||{}),iB=class e extends yU{constructor(e,t){super({mediaType:e,PlayerClass:t}),iw(this,"isRemote",!1),iw(this,"deviceId"),iw(this,"groupId",""),iw(this,"label",""),iw(this,"sourceTrack"),iw(this,"enableAutoSwitchWhenRecapturing",!0),iw(this,"_isRecapturing",!1),iw(this,"_lastRecaptureTime",0),iw(this,"_onMuteTimeoutId",-1),iw(this,"_encodeCheckTimeoutId",-1),iw(this,"recaptureMode",0),iw(this,"profile"),iw(this,"retryEncodeFailed")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}get isUseCustomSource(){return this.sourceTrack&&this.mediaTrack&&this.sourceTrack!==this.mediaTrack}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){e.addEventListener(eC.MUTE,this.onTrackMuted),e.addEventListener(eC.UNMUTE,this.onTrackUnmuted),e.addEventListener(eC.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===eC.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){e.removeEventListener(eC.MUTE,this.onTrackMuted),e.removeEventListener(eC.UNMUTE,this.onTrackUnmuted),e.removeEventListener(eC.ENDED,this.onTrackEnded)}setStateToReady(){}capture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return nw(this,null,(function*(){var r;let i=this.sourceTrack;try{let i,o=oN();YO.emit(XO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(i=new MediaStream,i.addTrack(e.customSource)):(t||null==(r=this.sourceTrack)||r.stop(),i=yield wU(e));let n=i.getTracks()[0];return yield this.setInputMediaStreamTrack(n),e.customSource||(this.sourceTrack=n,this.updateDeviceIdInUse(),this.listenDeviceChange()),YO.emit(XO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:oN()-o}),i}catch(Rw){throw YO.emit(XO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:Rw}),this.log.error("getUserMedia error observed ".concat(Rw)),Rw}finally{t&&(null==i||i.stop())}}))}setOutputMediaStreamTrack(e){var t;if(super.setOutputMediaStreamTrack(e),this.setStateToReady(),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}get hasFlag(){var e,t;let r=cN((null==(e=this.room)?void 0:e.localPublishFlag)||0,(null==(t=this.room)?void 0:t.userId)||"");return 4===this.mediaType&&r.hasVideo||1===this.mediaType&&r.hasAudio||2===this.mediaType&&r.hasAuxiliary}publish(e,t){return nw(this,null,(function*(){return this.room=e,this.room.localTracks.add(this),this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.bindParent(e.getLogger()),yield t,this._checkPublishFlag(e)}))}_checkPublishFlag(e){return new Promise(((t,r)=>nw(this,null,(function*(){var i,o,n,a;let s=()=>r(new mw({code:hw.API_CALL_ABORTED,message:"publish aborted"}));if(this.hasFlag||this.muted?t():((this.state===WP.INIT||"ready"===this.state)&&s(),JU(DV(e,"local-publish-flag-changed"),YV((()=>this.hasFlag)),QV(oV(DV(this,WP.INIT),DV(this,"ready"))),$F(t,r,s))),((null==(o=null==(i=this.room)?void 0:i.networkQuality)?void 0:o.uplinkNetworkQuality)||0)>3)return t();let l=e.heartbeatCount,c=(null==(a=null==(n=this.mediaTrack)?void 0:n.stats)?void 0:a.totalFrames)||0;this._encodeCheckTimeoutId=setTimeout((()=>nw(this,null,(function*(){var i,o,n,a,s,d,u;if(((null==(o=null==(i=this.room)?void 0:i.networkQuality)?void 0:o.uplinkNetworkQuality)||0)>3||e.heartbeatCount-l<3)return t();if((this.isPublished||this.isPublishing)&&this.isMediaTrackActive){if(null!=(n=this.mediaTrack)&&n.stats){let e=this.mediaTrack.stats.totalFrames||0;e-c==0&&this.log.warn("capture totalFrames is 0 during encode check, totalFrames",e)}let e=this.kind===eC.AUDIO,i=this.stat.bytesSent>0;if(RL[i?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),!e){let e={H264:513704,H265:513705,VP8:513706}[(null==(s=null==(a=this.room)?void 0:a.videoCodec)?void 0:s.toUpperCase())||"H264"];e&&RL[i?"addSuccessEvent":"addFailedEvent"]({key:e})}if(!i){if(RL.addEnum({key:e?503701:513703,value:WO()}),ex.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(VO()||jO()),userId:this.userId}),this.log.warn(e?"encode failed":"".concat(null==(u=null==(d=this.room)?void 0:d.videoCodec)?void 0:u.toUpperCase()," encode failed")),this.retryEncodeFailed&&(this.log.warn("retry encode"),yield this.retryEncodeFailed(this),this.stat.bytesSent>0||this.hasFlag||(yield SN(5e3),this.stat.bytesSent>0||this.hasFlag)))return t();this.emit("6",this),r(new mw({message:"".concat(this.strMediaType," encode failed"),code:e?hw.AUDIO_ENCODE_FAILED:hw.VIDEO_ENCODE_FAILED}))}}}))),1e4)}))))}unpublish(){this.room&&this.room.localTracks.delete(this),this.log.info("unpublish"),YO.emit(XO.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return nw(this,null,(function*(){if(this.sourceTrack&&dP){let{deviceId:e,groupId:t}=this.sourceTrack.getSettings(),{label:r}=this.sourceTrack;(yield function(e){return nw(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:r,oldGroupId:i,oldLabel:o,kind:n}=e;return function*(){return t===r&&(n!==eC.AUDIO||t!==qC||(yield mU(i,o)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=r,t&&(this.groupId=t),lU().then((r=>{let i=r.find((r=>{let i=r.deviceId===e;return t&&(i=i&&r.groupId===t),i}));i&&this.emit("2",i)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.sourceTrack||this.kind===eC.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(eC.AUDIO_INPUT);return!!pU.has(r)}(this.sourceTrack)||this.kind===eC.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(eC.VIDEO_INPUT);return!!pU.has(r)}(this.sourceTrack)||this._isRecapturing||e&&Gk&&gO)}onTrackMuted(){if(super.onTrackMuted(),NU(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<ZC)return void setTimeout((()=>this.onTrackMuted()),ZC);this._onMuteTimeoutId=setTimeout((()=>nw(this,null,(function*(){var e;if(null!=(e=this.sourceTrack)&&e.muted){if((sk||lk)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return nw(this,null,(function*(){if(ow(e.prototype,this,"onTrackEnded").call(this),this.isNeedToRecapture()&&0===this.recaptureMode){if(Date.now()-this._lastRecaptureTime<ZC)return void setTimeout((()=>this.onTrackEnded()),ZC);this.emit("7"),this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return nw(this,null,(function*(){var r;if(this._isRecapturing||!this.sourceTrack)return;this.log.warn("recapture trying");let i=this.sourceTrack;t||null==(r=this.sourceTrack)||r.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let o={useExactDeviceId:!0};if("user"===e||"environment"===e)o.facingMode=e;else{let t;("audio"===this.kind?yield cU():yield dU()).find((t=>t.deviceId===e))&&(t=e),o.deviceId=t}return this.capture(o,t).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),YO.emit(XO.LOCAL_TRACK_RECAPTURE,{track:this})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),YO.emit(XO.LOCAL_TRACK_RECAPTURE,{track:this,error:e})})).finally((()=>{t&&(null==i||i.stop())}))}))}getRecoverCaptureDeviceId(){return nw(this,null,(function*(){let e=this instanceof dB;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let r=(nB.get(t)||0)+1;if(nB.set(t,r),r>=3&&this.enableAutoSwitchWhenRecapturing){let i=e?(yield dU()).find((e=>!nB.has(e.deviceId))):(yield cU()).find((e=>!nB.has(e.deviceId)));i&&(this.log.warn("".concat(t," capture fail ").concat(r," times, change new ").concat(i.deviceId)),t=i.deviceId)}}return t}))}stopCapture(){var e;this.sourceTrack&&(this.sourceTrack.stop(),this.uninstallTrackEvent(this.sourceTrack)),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack),null==(e=this.manager)||e.removeInput(this)}close(){super.close(),this.stopCapture()}};rw([FP(WP.INIT,"ready",{ignoreError:!0,sync:!0})],iB.prototype,"setStateToReady",1),rw([PU()],iB.prototype,"capture",1),rw([FP("ready","publish",{ignoreError:!0,success(){YO.emit(XO.LOCAL_TRACK_PUBLISHED,{track:this,room:this.room}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),this.log.info("published")},fail(e){var t;null==(t=this.room)||t.localTracks.delete(this);let r="error",i=e instanceof mw?e:e.cause instanceof mw?e.cause:e,o=!1;i instanceof mw&&(i.message.includes("timeout")?r="timeout":i.code===hw.API_CALL_ABORTED&&(o=!0,r="api-call")),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:r,error:i}),this.log[o?"info":"error"]("publish failed",i)}}),UU(521714,!1)],iB.prototype,"publish",1),rw([DU((e=>function(){return nw(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId)}))})),FP([],"ready",{sync:!0})],iB.prototype,"unpublish",1);var oB=iB,nB=new Map;YO.on(XO.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&nB.delete(e.track.deviceId)}));var aB=class e extends oB{constructor(e){super(1,EU),iw(this,"mediaType",1),iw(this,"volume",0),iw(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),iw(this,"playerMuted",!0),iw(this,"pipeline"),iw(this,"earMonitorGainNode",new zx),iw(this,"_output",new zx),iw(this,"codecPipeline",[]),iw(this,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),iw(this,"mixedAudioReferenceMap",new Map),iw(this,"isAudioContextLongSuspended",!1),iw(this,"after3aSilenceStartTime",0),this.manager=e,this.pipeline=new Yx(e),this.pipeline.source.pipeTo(this.player.pipeline.volumeMeter),this.pipeline.gain.pipeTo(this.earMonitorGainNode).pipeTo(this._output),this.pipeline.gain.pipeTo(this.player.pipeline.volumeMeterAfter3A),this.handleMicrophoneAdded=this.handleMicrophoneAdded.bind(this),this.handleMicrophoneRemoved=this.handleMicrophoneRemoved.bind(this),YO.on(XO.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this)}get dbVolume(){return tU.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}getInternalAudioLevelAfter3A(){if(this.pipeline.isProcessEnabled)return this.player.getInternalAudioLevelAfter3A()}updateAfter3aSilenceStartTime(e){jD(e)||(0!==e||this.after3aSilenceStartTime?e>0&&(this.after3aSilenceStartTime=0):this.after3aSilenceStartTime=oN())}setInputMediaStreamTrack(t){return nw(this,null,(function*(){let r=this.trackSettings||{};RL.addEnum({key:501701,value:r.channelCount||0,useUV:!1}),RL.addEnum({key:501702,value:r.sampleRate||0,useUV:!1}),RL.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:o}=r;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:o}))),this.pipeline.source.channelCount=o||1,this.pipeline.replaceSource(t),yield ow(e.prototype,this,"setInputMediaStreamTrack").call(this,t),this.updatePlayingState(!!t)}))}capture(t){return nw(this,arguments,(function(t){var r=this;let{deviceId:i,customSource:o,useExactDeviceId:n=!0,retryWhenExactFailed:a}=t,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function*(){let t=yield ow(e.prototype,r,"capture").call(r,{video:!1,audio:!0,microphoneId:i,echoCancellation:r.profile.echoCancellation,autoGainControl:r.profile.autoGainControl,noiseSuppression:r.profile.noiseSuppression,sampleRate:r.profile.sampleRate,channelCount:r.profile.channelCount,useExactDeviceId:n,retryWhenExactFailed:a,customSource:o},s);return Gx(),t}()}))}switchDevice(e){return nw(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e&&!this.isUseCustomSource){if(e!==qC)return;if(yield mU(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.sourceTrack&&this.sourceTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1}),YO.emit(XO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(CC){throw this.log.error("switch microphone failed ".concat(CC)),this.deviceId&&this.recapture(this.deviceId),CC}}}))}listenDeviceChange(){aU&&!aU.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&aU.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return nw(this,null,(function*(){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(rB[this.recaptureMode],". Current microphone is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){$B(this.userId,{eventId:2003,param1:6,streamType:1});let e=yield cU();e[0]?this.recapture(e[0].deviceId):t=!0}t&&aU.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){1===this.recaptureMode&&e.deviceId!==this.deviceId||(aU.off("audioInputAdded",this.handleMicrophoneAdded,this),this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId))}update3A(e){return nw(this,arguments,(function(e){var t=this;let{echoCancellation:r,noiseSuppression:i,autoGainControl:o}=e;return function*(){let e=t.sourceTrack||t.mediaTrack;if(!e)return;let n=e.getConstraints(),a=!1;!jD(r)&&r!==t.profile.echoCancellation&&(t.profile.echoCancellation=r,n.echoCancellation=r,a=!0),!jD(i)&&i!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=i,n.noiseSuppression=i,a=!0),!jD(o)&&o!==t.profile.autoGainControl&&(t.profile.autoGainControl=o,n.autoGainControl=o,a=!0),a&&(hk||gO?yield e.applyConstraints(n).catch((e=>t._log.warn("update3A failed: ",e))):t.deviceId&&(yield t.recapture(t.deviceId,!0)))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&RL.addEnum({key:502700,value:2})}setAudioVolume(e){super.setAudioVolume(0),sk&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(jx().createGain()),this._output.setNode(jx().destination)),this.earMonitorGainNode.node.gain.value=e}enableTrackANS(e){return this.update3A({noiseSuppression:e})}enableTrackAEC(e){if(this.sourceTrack&&!gO&&!sk)return this.update3A({echoCancellation:e})}addDenoiser(e){var t;mO<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(RL.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}mixAudioReference(e,t){if(this.mixedAudioReferenceMap.has(t))return;this.log.info("mixAudioReference() => ".concat(t));let r=Qx(e);if(!r)return;let i=new zx,o=jx().createGain();o.gain.value=1;let n=new zx;i.pipeTo(n).pipeTo(this.pipeline.mixNode),i.setNode(r),n.setNode(o),this.mixedAudioReferenceMap.set(t,[i,n])}unMixAudioReference(e){let[t,r]=this.mixedAudioReferenceMap.get(e)||[];t&&(this.log.info("unMixAudioReference() => ".concat(e)),t.deleteNode(),null==r||r.deleteNode(),this.mixedAudioReferenceMap.delete(e))}setAudioReferenceVolume(e,t){let[r,i]=this.mixedAudioReferenceMap.get(e)||[];null!=i&&i.node&&(i.node.gain.value=t/100,this.log.info("setAudioReferenceVolume() => ".concat(e," ").concat(i.node.gain.value)))}addAudioProcessor(e,t,r){this.pipeline.silentNode.setNode(r),this.pipeline.mixNode.setNode(t),this.pipeline.aec.setNode(e)}removeDenoiser(e){if(this.pipeline.denoiser.node===e)return this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0)}removeAudioProcessor(e){this.pipeline.aec.node===e&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode())}close(){this.mixedAudioReferenceMap.forEach((e=>{let[t,r]=e;t.deleteNode(),r.deleteNode()})),this.mixedAudioReferenceMap.clear(),this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),aU.off("audioInputAdded",this.handleMicrophoneAdded,this),aU.off("audioInputRemoved",this.handleMicrophoneRemoved,this),YO.off(XO.AUDIO_CONTEXT_LONG_SUSPENDED,this.handleAudioContextLongSuspended,this),super.close()}recapture(t){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return nw(this,null,(function*(){try{yield ow(e.prototype,this,"recapture").call(this,t,r)}catch(cM){let i=(yield cU()).find((e=>e.deviceId!==t));if(!i)throw cM;yield ow(e.prototype,this,"recapture").call(this,i.deviceId)}}))}encodeFrame(e){return this.manager?this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e,ntp:_w()}):e),e):e}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}get enableEncryptFrame(){return this.manager&&!!this.manager.encodePipeline[0]}handleAudioContextLongSuspended(e){let{isSuspended:t}=e;if(this.pipeline.isProcessEnabled)if(t){this.isAudioContextLongSuspended=!0,this.log.warn("context has suspended for ".concat(1.5," seconds, change to source audio").concat(EO?"":", non-Safari"));let e=this.sourceTrack||this.mediaTrack;e&&this.setOutputMediaStreamTrack(e)}else this.isAudioContextLongSuspended=!1,this.log.warn("context has resumed, change to processed audio"),this.pipeline.track&&this.setOutputMediaStreamTrack(this.pipeline.track)}setOutputMediaStreamTrack(e){if(this.isAudioContextLongSuspended){let t=this.sourceTrack||this.mediaTrack;t&&(e=t)}super.setOutputMediaStreamTrack(e)}},sB=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,r=[],i=0;for(let n=e;n<=t;n++){let e=this.dataView.getInt8(n);switch(e){case 0:case 1:case 2:case 3:2===i&&(r.push(3),i=0),0==e?i++:i=0,r.push(e);break;default:i=0,r.push(e)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,r=[],i=0;for(let n=e;n<=t;n++)switch(this.dataView.getInt8(n)){case 0:i++,r.push(this.dataView.getInt8(n));break;case 3:2!==i&&r.push(this.dataView.getInt8(n)),i=0;break;default:r.push(this.dataView.getInt8(n)),i=0}let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let o=6;o<this.dataView.buffer.byteLength;o++){let r=this.dataView.getUint8(o);if(t++,255!==r){e+=r;break}e+=255}let r=new ArrayBuffer(e),i=new DataView(r);for(let o=0;o<r.byteLength;o++,t++)i.setInt8(o,this.dataView.getInt8(t));return i}},lB=class{constructor(){iw(this,"_seiMessageList",[]),iw(this,"_smallSeiMessageList",[]),iw(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,r=parseInt(String(t/255),10),i=t%255,o=[];o.push(0,0,0,1,6,this._seiPayloadType);for(let a=0;a<r;a++)o.push(255);o.push(i);let n=new DataView(e);return o.push(...new Uint8Array(n.buffer)),o.push(128),new sB(new DataView(new Uint8Array(o).buffer),!0)}sendSEI(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}isEmpty(){return!this._seiMessageList.length}getNaluCount(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}encode(e,t){let r=t?this._smallSeiMessageList:this._seiMessageList;if(r.length>0&&e.data.byteLength>0){let t=9-this.getNaluCount(e.data);if(t<=0)return 0;let i=r.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce(((e,t)=>e+t.dataView.byteLength),0),n=new ArrayBuffer(o+e.data.byteLength),a=new DataView(n),s=new DataView(e.data),l=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)a.setInt8(l++,i[e].dataView.getInt8(t));for(let r=0;r<e.data.byteLength;r++)a.setInt8(l++,s.getInt8(r));return e.data=n,i.length}return 0}},cB=class e extends oB{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,Dx),iw(this,"profile",Qb({},Qw)),iw(this,"avoidCropping",!1),iw(this,"_scaleResolutionDownBy"),iw(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0,framesCaptured:0}),iw(this,"small"),iw(this,"isNeedToSetBandwidth"),iw(this,"muteImage"),iw(this,"manager"),iw(this,"_seiCodec",new lB),this.manager=e;let t=()=>{var e;if(this.isAllowed2k4k(this.profile))this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1});else{let t=AD((null==(e=this.room)?void 0:e.sdkAppId)||0)?Vw:Uw;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(t)),this.setProfile($b(Qb({},this.profile),{width:1920,height:1080})),this.applyProfile()}};this.on("input-media-track-changed",t),this.on("publish",t),this.handleCameraAdded=this.handleCameraAdded.bind(this),this.handleCameraRemoved=this.handleCameraRemoved.bind(this)}get facingMode(){if(dP&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e;return(null==(e=this._inputTrack)?void 0:e.contentHint)||""}get isQosClearFirst(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}get hasSmall(){var e;return!(null==(e=this.manager)||!e.hasSmall)}setMute(t){return nw(this,null,(function*(){var r,i,o;if(zD(t)){if(this.muteImage===t)return;yield null==(r=this.manager)?void 0:r.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:t,fillVideo:!0}),this.muteImage=t,ow(e.prototype,this,"setMute").call(this,!1)}else this.muteImage&&(yield null==(o=this.manager)?void 0:o.deleteWatermark("mute"),this.muteImage=void 0),ow(e.prototype,this,"setMute").call(this,t)}))}capture(t){return nw(this,arguments,(function(t){var r=this;let{deviceId:i,facingMode:o,useExactDeviceId:n=!0,customSource:a,retryWhenExactFailed:s=!0}=t;return function*(){let t={audio:!1,video:!0,facingMode:o||r.facingMode,cameraId:i,width:r.profile.width,height:r.profile.height,frameRate:r.profile.frameRate,useExactDeviceId:n,retryWhenExactFailed:s,customSource:a};if("environment"===t.facingMode){let e=yield r.getDeviceIdWhenUsingBackCamera();e&&(t.cameraId=e)}return ow(e.prototype,r,"capture").call(r,t)}()}))}setProfile(e){var t;let r=this.fallbackProfile(e);if(r.bitrate&&(this.isNeedToSetBandwidth=r.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile))super.setProfile(r);else{let e=AD((null==(t=this.room)?void 0:t.sdkAppId)||0)?Vw:Uw;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(e)),super.setProfile($b(Qb({},this.profile),{width:1920,height:1080}))}}applyProfile(){return nw(this,null,(function*(){var e;if(!this.mediaTrack)return;let{width:t=0,height:r=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=t*r,o=this.settings,n=o.height!==this.profile.height||o.width!==this.profile.width||o.frameRate!==this.profile.frameRate;if(n&&(16===SO&&this.deviceId?yield this.recapture(this.deviceId):(yield null==(e=this.sourceTrack||this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}),this.manager&&this.manager.changeInput(this)),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1})),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth){this.isNeedToSetBandwidth=!1;let{width:e=0,height:t=0}=(this.sourceTrack||this.mediaTrack).getSettings(),r=e*t;return n&&r&&i&&r===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:eC.VIDEO,videoType:eC.BIG})}}))}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return dP&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:CN(this.settings,this.profile)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return nw(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e)&&!this.isUseCustomSource)return;let t={useExactDeviceId:!0,retryWhenExactFailed:!1};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.sourceTrack&&this.sourceTrack.stop(),yield this.capture(t),YO.emit(XO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(CC){throw this.log.error("switch camera failed ".concat(CC)),this.deviceId&&this.recapture(this.deviceId),CC}}))}getDeviceIdWhenUsingBackCamera(){return nw(this,null,(function*(){let e;try{if($k&&!sO&&hP){let t=(yield dU(!0)).map((e=>{var t;return $b(Qb({},e),{capabilities:null==(t=e.getCapabilities)?void 0:t.call(e)})})).filter((e=>{var t,r;return null==(r=null==(t=e.capabilities)?void 0:t.facingMode)?void 0:r.includes("environment")})),r=t[0];t.forEach((e=>{var t,i,o,n;let{capabilities:a}=e;(null!=(t=a.width)&&t.max&&null!=(i=a.height)&&i.max?a.width.max*a.height.max:0)>(null!=(o=r.capabilities.width)&&o.max&&null!=(n=r.capabilities.height)&&n.max?r.capabilities.width.max*r.capabilities.height.max:0)&&(r=e)})),null!=r&&r.capabilities&&(this._log.info("use max resolution back camera",r),e=r.deviceId)}}catch(CC){this._log.warn("get max res camera failed",CC)}return e}))}updateSmallConfig(e){var t,r;this._log.info("update small stream config: ".concat(JSON.stringify(e)));let i=!this.small;this.small=this.fallbackProfile(e,!0),null==(t=this.manager)||t.update(),i&&(null==(r=this.room)||r.enableSmall(!0)),this.log.info("update small stream config success")}fallbackProfile(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=e.width>e.height,i=Qb({},e);return e.width*e.height<=19200&&lk&&uO&&(this.log.warn("".concat(t?"small ":"","resolution is ").concat(e.width,"*").concat(e.height,", fallback to 240*180 for android chrome")),i.width=r?240:180,i.height=r?180:240,i.bitrate=Math.max(e.bitrate,150)),e.width*e.height>921600&&wO&&(i.width=r?1280:720,i.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),IO(TO,"14.3")&&AO(TO,"14.0",!0)&&this.on("7",(()=>{let e=this.profile.width>this.profile.height;this.profile.width*this.profile.height>307200?(this.profile.width=e?640:480,this.profile.height=e?480:640,this.log.warn("reduce the resolution to 480p on iOS 14.0 ~ 14.2")):this.profile.width*this.profile.height>230400&&(this.profile.width=e?640:360,this.profile.height=e?360:640,this.log.warn("reduce the resolution to 360p on iOS 14.0 ~ 14.2"))})),!t&&this.avoidCropping&&(uO||hk)&&!LO()&&e.width*e.height<=230400&&e.width/e.height==16/9&&(this._scaleResolutionDownBy=1280/e.width,e.width=1280,e.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),i}stopSmall(){var e,t;this.small&&(delete this.small,null==(e=this.manager)||e.update(),null==(t=this.room)||t.enableSmall(!1))}listenDeviceChange(){aU&&!aU.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&aU.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return nw(this,null,(function*(){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(rB[this.recaptureMode],". Current camera is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){$B(this.userId,{eventId:2003,param1:7,streamType:2});let e=yield dU();e[0]?this.recapture(e[0].deviceId):t=!0}t&&aU.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return nw(this,null,(function*(){1===this.recaptureMode&&e.deviceId!==this.deviceId||(aU.off("videoInputAdded",this.handleCameraAdded,this),this.log.warn("camera added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId))}))}encodeFrame(e,t){if(!this.manager)return e;let r=t?8:this.mediaType;return this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e,mediaType:r}):e),e)}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}play(e,t){return jD(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){aU.off("videoInputAdded",this.handleCameraAdded,this),aU.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}recapture(t){return nw(this,null,(function*(){try{yield ow(e.prototype,this,"recapture").call(this,t)}catch(CC){let i=(yield dU()).find((e=>e.deviceId!==t));if(!i)throw CC;yield ow(e.prototype,this,"recapture").call(this,i.deviceId)}}))}setContentHint(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}setRotation(e){this.manager&&(this.isScreen||jD(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}};rw([CU((function(e){this.setContentHint(e.contentHint||"motion")}))],cB.prototype,"capture",1);var dB=cB,uB={};ew(uB,{REPORT_TYPE:()=>ON,buildSSOPackage:()=>MN,bytes2ms:()=>MD,calculateScaleResolutionDownNumber:()=>CN,concatArrayBuffers:()=>LN,convertObjectNumberToInt:()=>AN,copyProperties:()=>OD,deepClone:()=>pN,deepCloneBasic:()=>kN,deepMerge:()=>hN,delay:()=>SN,fibonacci:()=>BD,formatedTime:()=>_N,getConstructorName:()=>eN,getContainerFromElement:()=>fN,getEnv:()=>ID,getFirst16Bits:()=>xN,getInternalVersion:()=>aN,getLast16Bits:()=>PN,getLoggerUrl:()=>SD,getMediaStreamTrackInfo:()=>wN,getMuteStateFromFlag:()=>cN,getNetworkType:()=>bD,getNumNetworkType:()=>kD,getReconnectionTimeout:()=>HD,getStringByteLength:()=>vN,getTurnServer:()=>dN,getUint32Version:()=>IN,getValueType:()=>WD,getViewListFromView:()=>mN,glog:()=>UD,ipv4ToUint32:()=>uN,isArray:()=>JD,isAudioWorkletSupported:()=>tN,isBoolean:()=>qD,isConstructor:()=>ZD,isEmpty:()=>lN,isFunction:()=>GD,isLangChinese:()=>VD,isMediaStreamTrack:()=>XD,isNumber:()=>KD,isObject:()=>YD,isOverseaSdkAppId:()=>AD,isPlainObject:()=>FD,isPortrait:()=>yN,isPromise:()=>$D,isRemoteTrack:()=>QD,isRotate90Or270:()=>DN,isSetSinkIdSupported:()=>rN,isString:()=>zD,isUndefined:()=>jD,loadImage:()=>TN,loadVideo:()=>NN,ms2bytes:()=>PD,ms2samples:()=>xD,normalizeUrl:()=>bN,performanceNow:()=>oN,promiseAny:()=>iN,samples2ms:()=>LD,setNetworkTypeFromWebRTC:()=>ND,stringify:()=>gN,stringifyIncludeValue:()=>EN,throttlePromise:()=>RN});var hB=[-1,-1,1,-1,-1,1,1,1],pB=[0,0,1,0,0,1,1,1],mB=class e extends WP{constructor(e,t){if(super(),this.context=e,iw(this,"name"),iw(this,"input"),iw(this,"output"),iw(this,"texture"),iw(this,"ctx2d",null),iw(this,"fbo"),iw(this,"width",0),iw(this,"height",0),iw(this,"x",0),iw(this,"y",0),iw(this,"program"),iw(this,"vertexShader"),iw(this,"fragmentShader"),iw(this,"totalFrames",0),iw(this,"dropFrames",0),iw(this,"matchInputSize",!0),iw(this,"texCoordBuffer"),iw(this,"positionBuffer"),iw(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),iw(this,"cost",0),iw(this,"_canvas",null),iw(this,"_image"),iw(this,"log"),this.context.on("disconnect",this.close,this),this.name=t.name,this.log=t.logger,this.matchInputSize=!1!==t.matchInputSize,this.width=t.width||e.width,this.height=t.height||e.height,this._image=t.image,e instanceof kB)e.ctx&&t.create2d&&("function"==typeof OffscreenCanvas&&16!==SO?this._canvas=new OffscreenCanvas(this.width,this.height):(this._canvas=document.createElement("canvas"),this._canvas.width=this.width,this._canvas.height=this.height),this.ctx2d=this._canvas.getContext("2d"),this._image=this._canvas);else try{let r=e.ctx;this.texCoordBuffer=this.createBuffer(pB),this.positionBuffer=this.createBuffer(hB),!1!==t.createTexture&&(this.texture=r.createTexture(),this.useTexture(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.pixelStorei(r.UNPACK_ALIGNMENT,1)),t.useFbo&&(this.fbo=r.createFramebuffer(),this.useBufferFrame(),this.useTexture(),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,this.texture,0)),t.useDefaultProgram?this.program=e.defaultProgam:(t.vertexShaderSource||t.fragmentShaderSource)&&(this.vertexShader=t.vertexShaderSource?e.createShader(r.VERTEX_SHADER,t.vertexShaderSource):e.defaultVShader,this.fragmentShader=t.fragmentShaderSource?e.createShader(r.FRAGMENT_SHADER,t.fragmentShaderSource):e.defaultFShader,this.program=e.createProgram(this.vertexShader,this.fragmentShader))}catch(cM){this.context.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(cM.message||cM)}))}}get image(){return this._image}set image(e){this._image=e}createFramebuffer(e){let t=this.context.ctx,r=t.createFramebuffer();return t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),r}connect(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return e.addInput(this,...r),this.output=e,e}addInput(e){this.input=e,this.matchInputSize&&e.width&&e.height&&this.resize(e.width,e.height)}requestFrame(e){let t=Date.now();return!!(this.context instanceof NB&&this.render(e)||this.context instanceof kB&&this.render2d(e))&&(this.totalFrames++,this.cost=Date.now()-t,!0)}render2d(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&this.draw2d(this.input.image,0,0,this.width,this.height)}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;null==(t=this.output)||t.update(e)}disconnect(){for(var e,t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];null==(e=this.output)||e.removeInput(this,...r),delete this.output}removeInput(e){delete this.input}close(){var e,t;if(this.context.off("disconnect",this.close,this),null==(e=this.output)||e.removeInput(this),delete this.output,null==(t=this.input)||t.disconnect(),this.context instanceof NB){let e=this.context.ctx;e.deleteBuffer(this.texCoordBuffer),e.deleteBuffer(this.positionBuffer),this.fbo&&e.deleteFramebuffer(this.fbo),this.texture&&e.deleteTexture(this.texture),this.vertexShader&&this.vertexShader!==this.context.defaultVShader&&e.deleteShader(this.vertexShader),this.fragmentShader&&this.fragmentShader!==this.context.defaultFShader&&e.deleteShader(this.fragmentShader),this.program&&this.program!==this.context.defaultProgam&&e.deleteProgram(this.program)}this._canvas&&(this._canvas.width=0,this._canvas.height=0,this.ctx2d=null),this.removeAllListeners()}useTexture(){this.useTextures(this.texture)}useInputTexture(){var e;this.useTextures(null==(e=this.input)?void 0:e.texture)}useTextures(){let e=this.context.ctx;for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach(((t,r)=>{t&&(e.activeTexture(e.TEXTURE0+r),e.bindTexture(e.TEXTURE_2D,t))}))}useProgram(){this.context.ctx.useProgram(this.program)}useBufferFrame(){let e=this.context.ctx;e.bindFramebuffer(e.FRAMEBUFFER,this.fbo||null)}createBuffer(e){let t=this.context.ctx,r=t.createBuffer();return t.bindBuffer(t.ARRAY_BUFFER,r),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW),r}setTexBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}setPosBuffer(e){let t=this.context.ctx;t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,new Float32Array(e),t.STATIC_DRAW)}changeBufferData(e,t){let r=this.context.ctx;r.bindBuffer(r.ARRAY_BUFFER,e),r.bufferData(r.ARRAY_BUFFER,new Float32Array(t),r.STATIC_DRAW)}setAttributes(){let e=this.context.ctx;for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];r.forEach(((t,r)=>{e.enableVertexAttribArray(r),e.bindBuffer(e.ARRAY_BUFFER,t),e.vertexAttribPointer(r,2,e.FLOAT,!1,0,0)}))}getVertexPoint(e,t){return[e/this.width*2-1,t/this.height*2-1]}layout2texCoords(e){return[...this.getVertexPoint(e.x,e.y),...this.getVertexPoint(e.x+e.width,e.y),...this.getVertexPoint(e.x,e.y+e.height),...this.getVertexPoint(e.x+e.width,e.y+e.height)]}resize(e,t){if(this.width!==e||this.height!==t){if(this.width=e,this.height=t,this._canvas&&(this._canvas.width=e,this._canvas.height=t),this.texture&&this.fbo){this.useTexture();let r=this.context.ctx;r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,t,0,r.RGBA,r.UNSIGNED_BYTE,null)}this.output&&this.output.matchInputSize&&this.output.resize(e,t)}}draw(e,t){this.setAttributes(e||this.positionBuffer,t||this.texCoordBuffer);let r=this.context.ctx;r.drawArrays(r.TRIANGLE_STRIP,0,4)}draw2d(t,r,i,o,n,a,s,l,c){let d=!(jD(a)||jD(s)||jD(l)||jD(c));return!(!this.ctx2d||!t)&&(t instanceof ImageData?(d?this.ctx2d.putImageData(t,r,i,a,s,l,c):this.ctx2d.putImageData(t,r,i),this.emit(e.RENDER,this.ctx2d.canvas)):(d?this.ctx2d.drawImage(t,a,s,l,c,r,i,o,n):this.ctx2d.drawImage(t,r,i,o,n),this.emit(e.RENDER,t)),"undefined"!=typeof VideoFrame&&t instanceof VideoFrame&&t.close(),!0)}drawBackGround2d(e){this.ctx2d&&(this.ctx2d.save(),this.ctx2d.fillStyle=e,this.ctx2d.fillRect(0,0,this.width,this.height),this.ctx2d.restore())}getInfo(){var e;let{totalFrames:t,x:r,y:i,width:o,height:n,name:a,cost:s}=this,l=Date.now(),c=(t-this.lastInfo.totalFrames)/((l-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:r,y:i,width:o,height:n,timestamp:l,fps:c,name:a,cost:s},Qb({parent:null==(e=this.input)?void 0:e.getInfo()},this.lastInfo)}createTexture(e){let t=this.context.ctx,r=t.createTexture();return this.useTextures(r),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),r}};iw(mB,"RENDER","render"),rw([FP(WP.INIT,"connected",{sync:!0})],mB.prototype,"connect",1),rw([FP("connected",WP.INIT,{ignoreError:!0,sync:!0})],mB.prototype,"disconnect",1),rw([FP([],"closed",{sync:!0})],mB.prototype,"close",1);var fB=mB,_B=JU(RV(250),IF((()=>performance.now())),iV()),gB=e=>t=>{let r=performance.now();JU(_B,rF((t=>t-r<e)),XV(1))(t)},EB=[0,1,1,1,0,0,1,0],vB=class extends fB{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),iw(this,"_intervalId",0),iw(this,"_sequence",0),iw(this,"checkGLError",!1),iw(this,"checkVisibilityChange"),e instanceof kB?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(EB)}start(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),YP.clearTask(this._intervalId),this._intervalId=YP.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&(YP.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof NB){let e=this.context.ctx.getError();e&&this.context.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:5,message:"".concat(this.name," req ").concat(this._sequence," render ").concat(this.totalFrames," faild ").concat(e)}))}}),{fps:this.context.frameRate})}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),this.emit(fB.RENDER,this.context._canvas),!0)}addInput(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];super.addInput(e,...r),this.start(this.context.frameRate)}update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;"closed"!==this.state&&(this._intervalId&&(YP.clearTask(this._intervalId),this._intervalId=0,1===e&&(this.log.info("".concat(this.name," use requestVideoFrameCallback")),this.checkVisibilityChange=()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")),document.removeEventListener("visibilitychange",this.checkVisibilityChange))},document.addEventListener("visibilitychange",this.checkVisibilityChange))),this.requestFrame(this._sequence++))}removeInput(e){super.removeInput(e),YP.clearTask(this._intervalId)}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}close(){super.close(),YP.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}},yB=class extends vB{constructor(e,t){super(e,t),iw(this,"_videoTrack"),iw(this,"_muteOb"),iw(this,"_closedOb",DV(this,"closed")),iw(this,"_subscription"),iw(this,"_canvasContainer"),Number(vO)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),[this._videoTrack]=e.canvas.captureStream().getVideoTracks(),this._muteOb=DV(this._videoTrack,"mute"),JU(DV(this._videoTrack,"ended"),QV(this._closedOb),$F((()=>{this.context.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})))}enableCheckMute(){this._subscription=JU(this._muteOb,QV(this._closedOb),NF(gB(5e3)),YV((()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)})),$F((()=>{this.context.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}disableCheckMute(){var e;null==(e=this._subscription)||e.dispose()}get videoTrack(){return this._videoTrack}putCanvasIntoDom(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}render(e){return this.putCanvasIntoDom(),super.render(e)}render2d(e){return this.putCanvasIntoDom(),super.render2d(e)}close(){var e,t;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},TB=class extends yB{render(e){var t;let r=!(null==(t=this.input)||!t.requestFrame(e));if(this.context._canvas2d){let e=this.context._canvas2d.getContext("2d");e.clearRect(0,0,this.context._canvas2d.width,this.context._canvas2d.height),e.drawImage(this.context._canvas,0,0,this.context._canvas2d.width,this.context._canvas2d.height),this.emit(fB.RENDER,this.context._canvas2d)}else this.emit(fB.RENDER,this.context._canvas);return r}},IB=class extends yB{constructor(e,t,r){super(e,{name:"smallDestination",logger:r}),this.resolution=t}resize(e,t){let r,i=e*t,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>o?r=i/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),super.resize(e/Math.sqrt(r),t/Math.sqrt(r))}},AB=class extends fB{constructor(e,t){super(e,Qb({name:"imageSource"},t)),iw(this,"_lastImage"),iw(this,"_totalFrames",0),iw(this,"_autoResize",!1),iw(this,"_canvasRendered"),iw(this,"videoCallbackId",0),iw(this,"waitingFirstFrame",!0),iw(this,"shouldUpdate",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===SO&&(this._canvasRendered=_V(),JU(this._canvasRendered,uV(this._image),CF((e=>e instanceof HTMLCanvasElement?DV(e,"rendered"):HV())),QV(DV(this,"closed")),$F((()=>{this.update()}))))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){if(!this.shouldUpdate)return;let e=this.image;this.videoCallbackId&&e.cancelVideoFrameCallback(this.videoCallbackId),RP()&&!document.hidden&&(this.videoCallbackId=e.requestVideoFrameCallback(((e,t)=>{this.waitingFirstFrame&&this.onFirstFrame(),document.hidden||(this._totalFrames=t.presentedFrames,this.update(1))})))}_render(e,t){var r;let{width:i,height:o}=this,{image:n}=this;if(n instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:o}=n),!i||!o)return!1;n.width=i,n.height=o}else if(n instanceof HTMLImageElement||n instanceof ImageData||n instanceof ImageBitmap){if(({width:i,height:o}=n),n!==this._lastImage)this._lastImage=n;else if(i===this.width&&o===this.height)return!0}else n instanceof HTMLCanvasElement||n instanceof OffscreenCanvas?(({width:i,height:o}=n),this._lastImage=n):"undefined"!=typeof VideoFrame&&n instanceof VideoFrame&&(({displayWidth:i,displayHeight:o}=n),null==(r=this._lastImage)||r.close(),this._lastImage=n);if(!this._autoResize)return!0;if(this.width===i&&this.height===o&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}this.resize(i,o)}return!0}get image(){return this._image}set image(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},SB=class extends AB{constructor(e,t,r){super(e,r),this._player=t,this.name="videoPlayerSource",JU(DV(this._player,JP.PLAYER_STATE_CHANGED),QV(DV(this,"closed")),YV((e=>{let{state:t}=e;return"PLAYING"===t})),$F((()=>{this.tryVideoFrameCallback()})))}get image(){return this._player.element}},RB=class extends SB{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,r){super(e,new Dx({id:r.name,track:t,muted:!0,container:null,objectFit:"contain",log:r.logger}),r),this.name="videoTrackSource",this._player.play()}replaceTrack(e){this.waitingFirstFrame=!0,this._player.setTrack(e),this._player.play()}close(){super.close(),this._player.stop()}},bB=class extends fB{constructor(e,t,r){super(e,$b(Qb({name:"textSource"},r),{create2d:!0})),iw(this,"hasChange",!0),iw(this,"content",""),this.ctx2d.textBaseline="top",this.content=t.content||"",t.font&&(this.font=t.font),t.color&&(this.color=t.color)}set font(e){this.ctx2d&&(this.ctx2d.font=e,this.hasChange=!0)}get font(){var e;return(null==(e=this.ctx2d)?void 0:e.font)||""}set color(e){this.ctx2d&&(this.ctx2d.fillStyle=e,this.hasChange=!0)}get color(){var e;return(null==(e=this.ctx2d)?void 0:e.fillStyle)||""}render2d(e){return!(!this.ctx2d||!this.hasChange)&&(this.ctx2d.clearRect(0,0,this.width,this.height),this.drawMultilineText(0,0),this.hasChange=!1,!0)}render(e){return!1}resize(e,t){if(!this.ctx2d)return;let{color:r,font:i}=this;super.resize(e,t),this.color=r,this.font=i}drawMultilineText(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1.2;if(!this.ctx2d)return;let i=this.ctx2d.measureText(this.content);t+=i.fontBoundingBoxAscent||i.actualBoundingBoxAscent||0;let o=this.font.match(/(\d+)px/),n=(o?parseInt(o[1],10):16)*r,a=this.content.split("\n");for(let s=0;s<a.length;s++)this.ctx2d.fillText(a[s],e,t+s*n)}},wB=class extends WP{constructor(e){super(),iw(this,"frameRate"),iw(this,"_canvas"),iw(this,"log"),iw(this,"hasAlpha",!1),iw(this,"name"),iw(this,"error"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}get canvas(){return this._canvas}set width(e){this._canvas&&(this._canvas.width=e)}get width(){var e;return(null==(e=this._canvas)?void 0:e.width)||0}set height(e){this._canvas&&(this._canvas.height=e)}get height(){var e;return(null==(e=this._canvas)?void 0:e.height)||0}setSize(e,t){this._canvas&&(this._canvas.width=e,this._canvas.height=t)}createVideoTrackSource(e,t){return new RB(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new yB(this,e)}createVideoImageSource(e,t){return new AB(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new SB(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}createTextSource(e,t){return new bB(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};iw(wB,"_ids",0);var CB={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},DB=class extends wB{constructor(){super(...arguments),iw(this,"defaultProgam"),iw(this,"defaultVShader"),iw(this,"defaultFShader"),iw(this,"ctx"),iw(this,"_canvas2d")}get canvas(){return this._canvas2d||this._canvas}create(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(wB._ids++)),e&&(this._canvas2d=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",CB),!this.ctx)throw new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:2,message:"webgl2 not supported"});this.defaultVShader=this.createShader(this.ctx.VERTEX_SHADER,"\n// 顶点着色器\nattribute vec4 a_position;\nattribute vec2 a_texCoord;\nvarying vec2 v_texCoord;\n\nvoid main() {\n gl_Position = a_position;\n v_texCoord = a_texCoord;\n}\n"),this.defaultFShader=this.createShader(this.ctx.FRAGMENT_SHADER,"\n// 片元着色器\nprecision mediump float;\nvarying vec2 v_texCoord;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n} "),this.defaultProgam=this.createProgram(this.defaultVShader,this.defaultFShader),this._canvas.addEventListener("webglcontextlost",(()=>{this.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}destroy(e){let t="";return e&&(t=e.message,this.error=e,RL.addFailedEvent({key:512702,error:e})),this.disconnect(),this.log.info("video context destroy".concat(t)?": ".concat(t):""),this.ctx&&(this.ctx.deleteShader(this.defaultVShader),this.ctx.deleteShader(this.defaultFShader),this.ctx.deleteProgram(this.defaultProgam),delete this.ctx),e}set width(e){var t;null==(t=this.ctx)||t.viewport(0,0,e,this.height),super.width=e,this._canvas2d&&(this._canvas2d.width=e)}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e,this._canvas2d&&(this._canvas2d.height=e)}setSize(e,t){var r;null==(r=this.ctx)||r.viewport(0,0,e,t),super.setSize(e,t),this._canvas2d&&(this._canvas2d.width=e,this._canvas2d.height=t)}createShader(e,t){let r=this.ctx,i=r.createShader(e);return r.shaderSource(i,t),r.compileShader(i),i}createProgram(e,t){let r=this.ctx,i=r.createProgram();return r.attachShader(i,e),r.attachShader(i,t),r.linkProgram(i),r.getProgramParameter(i,r.LINK_STATUS)||this.log.error(r.getProgramInfoLog(i)),i}};iw(DB,"UNAVAILABLE","unavailable"),rw([FP(WP.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),RL.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),RL.addSuccessEvent({key:512700})}})],DB.prototype,"create",1),rw([FP("created",WP.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(DB.UNAVAILABLE,e),this.removeAllListeners()}})],DB.prototype,"destroy",1);var NB=DB,kB=class extends wB{constructor(){super(...arguments),iw(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(wB._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha,willReadFrequently:e.willReadFrequently}),!this.ctx)throw new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(()=>{this.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(()=>{this.log.warn("2d context restored")}))}destroy(e){let t="";e&&(t=e.message,this.error=e,RL.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),RL.addSuccessEvent({key:512703})}};function OB(e,t,r,i,o){arguments.length>5&&void 0!==arguments[5]&&arguments[5]&&([r,i]=[i,r]);let n={sWidth:e,sHeight:t,dWidth:r,dHeight:i,sx:0,sy:0,dx:0,dy:0};if(0===e||0===t)return n;switch(o){case void 0:case"fill":break;case"contain":{let o=Math.min(r/e,i/t);n.dWidth=e*o,n.dHeight=t*o,n.dx=(r-n.dWidth)/2,n.dy=(i-n.dHeight)/2;break}case"cover":{let o=Math.max(r/e,i/t),a=r/o,s=i/o;n.sx=(e-a)/2,n.sy=(t-s)/2,n.sWidth=a,n.sHeight=s;break}}return n}rw([FP(WP.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),RL.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d"),RL.addSuccessEvent({key:512701})}})],kB.prototype,"create",1),rw([FP("created",WP.INIT,{ignoreError:!0,sync:!0})],kB.prototype,"destroy",1);var MB=class{constructor(e,t){this.node=e,this.layout=t,iw(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get fillMode(){return this.layout.fillMode}get rotation(){return this.layout.rotation}get hidden(){return!!this.layout.hidden}},LB=class extends fB{constructor(e,t){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:t}),iw(this,"inputs",[]),iw(this,"backgroundColor","black")}addInput(e,t){let r=0,i=this.inputs.length;for(;r<i;){let e=Math.floor((r+i)/2);if(this.inputs[e].layout.zIndex<t.zIndex)r=e+1;else{if(!(this.inputs[e].layout.zIndex>t.zIndex))throw new Error("input already exists at zIndex ".concat(t.zIndex));i=e}}let o=new MB(e,t);this.inputs.splice(r,0,o)}changeInputLayout(e,t){let r=this.inputs.findIndex((t=>t.node===e));if(r<0)return;let{x:i,y:o,width:n,height:a,zIndex:s,fillMode:l,rotation:c,hidden:d}=t;if(!jD(s)&&this.inputs.some((t=>t.layout.zIndex===s&&t.node!==e)))throw new Error("input already exists at zIndex ".concat(t.zIndex));let u=this.inputs[r];jD(i)||(u.layout.x=i),jD(o)||(u.layout.y=o),jD(n)||(u.layout.width=n),jD(a)||(u.layout.height=a),jD(c)||(u.layout.rotation=c),jD(d)||(u.layout.hidden=d),l&&(u.layout.fillMode=l),!jD(s)&&s!==u.layout.zIndex&&(u.layout.zIndex=s,this.inputs.sort(((e,t)=>e.layout.zIndex-t.layout.zIndex)))}hasInput(e){return this.inputs.some((t=>t.node===e))}hasNoInput(){return 0===this.inputs.length}resize(e,t){if(!this.matchInputSize)return void super.resize(e,t);let r=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(r.width,r.height),this.context instanceof NB&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return super.connect(e,...r),this.drawBackGround2d(this.backgroundColor),this.matchInputSize&&this.resize(0,0),e}removeInput(e){this.inputs=this.inputs.filter((t=>t.node!==e)),0===this.inputs.length&&this.drawBackGround2d(this.backgroundColor)}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),this.inputs.reduce(((t,r)=>r.node.requestFrame(e)||t),!1)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(this.inputs.forEach((t=>t.node.requestFrame(e))),this.ctx2d){this.drawBackGround2d(this.backgroundColor);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];if(t.hidden)continue;let r=OB(t.node.width,t.node.height,t.width,t.height,t.fillMode,DN(t.rotation));this.draw2d(t.node.image,t.x+r.dx,t.y+r.dy,r.dWidth,r.dHeight,r.sx,r.sy,r.sWidth,r.sHeight)}return!0}return!1}debugLayout(e,t,r,i){let o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];this.ctx2d&&(o&&([r,i]=[i,r]),this.ctx2d.save(),this.ctx2d.strokeStyle="red",this.ctx2d.lineWidth=2,this.ctx2d.strokeRect(e,t,r,i),this.ctx2d.restore())}getInfo(){let{totalFrames:e,x:t,y:r,width:i,height:o,name:n}=this,a=Date.now(),s=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:r,width:i,height:o,timestamp:a,fps:s,name:n},Qb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}removeAllInputs(){this.inputs.forEach((e=>{var t;if(e.node.disconnect(),e.positionBuffer&&this.context instanceof NB)try{null==(t=this.context.ctx)||t.deleteBuffer(e.positionBuffer)}catch(cM){}}))}close(){super.close(),this.removeAllInputs()}},PB=[1,0,0,0,1,1,0,1],xB=class extends fB{constructor(e,t,r,i){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:t}),iw(this,"mirror",!1),iw(this,"rotation",0),r&&(this.mirror=r),i&&(this.rotation=i),e instanceof NB)try{this.setTexBuffer(PB)}catch(Rw){e.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(Rw.message||Rw)}))}}draw2d(e,t,r,i,o){if(this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height),this.ctx2d.save(),this.mirror&&(this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0)),90===this.rotation?(this.ctx2d.translate(i,0),this.ctx2d.rotate(Math.PI/2),this.ctx2d.scale(o/i,i/o)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,o),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(o/i,i/o));let n=super.draw2d(e,t,r,i,o);return this.ctx2d.restore(),n}return!1}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}resize(e,t){DN(this.rotation)&&([e,t]=[t,e]),super.resize(e,t)}},UB=class extends oB{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,Dx),iw(this,"inputLocalVideoTracks",new Map),iw(this,"inputLocalScreenTracks",new Map),iw(this,"cameraNodeMap",new Map),iw(this,"screenNodeMap",new Map),iw(this,"textNodeMap",new Map),iw(this,"imageNodeMap",new Map),iw(this,"videoNodeMap",new Map),iw(this,"endedIds",new Set),iw(this,"videoContext"),iw(this,"mixNode"),iw(this,"destination"),iw(this,"manager"),iw(this,"stat"),iw(this,"_checkId",0),iw(this,"autoSetFps",!0),this.manager=e,this.log.id+="mix",this.create2dVideoContext(),this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(fB.RENDER,(e=>{this.emit("render",e)})),this.mixNode=new LB(this.videoContext,this.log),this.mixNode.matchInputSize=!1}listenDeviceChange(){throw new Error("Method not implemented.")}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=YP.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}create2dVideoContext(){this.videoContext?this.videoContext.destroy():this.videoContext=new kB({frameRate:15,logger:this.log,name:"mix-ctx"}),this.videoContext.create({alpha:!1})}setFps(e){this.autoSetFps=!1,this.videoContext.frameRate=e;for(let t of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])t.shouldUpdate=!1;setTimeout((()=>{var e;return null==(e=this.destination)?void 0:e.start(this.videoContext.frameRate)}),500)}setFpsAuto(){var e;if(!this.autoSetFps)return;for(let o of[...this.cameraNodeMap.values(),...this.screenNodeMap.values()])o.shouldUpdate=!1;let t=null,r=0,i=!0;for(let[o,n]of this.inputLocalVideoTracks)if(n.profile.frameRate>r){if(this.endedIds.has(o)){let e=this.cameraNodeMap.get(o);e&&e.image.cancelVideoFrameCallback(e.videoCallbackId);continue}r=n.profile.frameRate,t=o}for(let[o,n]of this.inputLocalScreenTracks)if(n.profile.frameRate>r){if(this.endedIds.has(o)){let e=this.screenNodeMap.get(o);e&&e.image.cancelVideoFrameCallback(e.videoCallbackId);continue}r=n.profile.frameRate,t=o,i=!1}if(null!==t){let e=i?this.cameraNodeMap.get(t):this.screenNodeMap.get(t);e&&(e.shouldUpdate=!0,e.tryVideoFrameCallback()),this.log.info("set mix fps: ",r)}else null==(e=this.destination)||e.start(this.videoContext.frameRate),this.log.info("fallback to timer, fps: ",this.videoContext.frameRate)}setMixBackground(e){this.mixNode&&(this.mixNode.backgroundColor=e)}resizeMixCanvas(e,t){var r;null==(r=this.mixNode)||r.resize(e,t)}startMix(){return nw(this,null,(function*(){var e;if(!this.mixNode||!this.destination)throw new Error("can't mix without necessary conditions");this.mixNode.disconnect(),this.mixNode.connect(this.destination),EO&&this.player.setCanvas(this.videoContext._canvas),this.setOutputMediaStreamTrack(this.destination.videoTrack),null==(e=this.manager)||e.changeInput(this)}))}addCameraSource(e,t,r){if(this.inputLocalVideoTracks.has(e)||this.cameraNodeMap.has(e))throw new Error("There is already a cameraSource with the same ID: ".concat(e));let i,{mediaTrack:o}=t;if(!o)throw new Error("no mediaTrack, add cameraSource failed");t.recaptureMode=1,$P(this,aU).add("videoInputRemoved",(r=>{r.deviceId===t.deviceId&&(this.endedIds.add(e),this.setFpsAuto())})),t.on("output-media-track-changed",(()=>{this.endedIds.delete(e),this.updateCameraSource(e,r,t.mediaTrack)})),i=16===SO&&o instanceof CanvasCaptureMediaStreamTrack?this.videoContext.createVideoImageSource(o.canvas,{name:"cameraCanvasSource",logger:this.log}):this.videoContext.createVideoTrackSource(o,"cameraNodeSource"),i.resize(t.settings.width,t.settings.height),i.shouldUpdate=!1,this._connectMix(i,r,"cover"),this.inputLocalVideoTracks.set(e,t),this.cameraNodeMap.set(e,i),this.setFpsAuto()}addScreenSource(e,t,r){if(this.inputLocalScreenTracks.has(e)||this.screenNodeMap.has(e))throw new Error("There is already a screenSource with the same ID: ".concat(e));let{mediaTrack:i}=t;if(!i)throw new Error("no mediaTrack, add cameraSource failed");let o=this.videoContext.createVideoTrackSource(i,"screenNodeSource");o.resize(t.settings.width,t.settings.height),o.shouldUpdate=!1,this._connectMix(o,r),this.inputLocalScreenTracks.set(e,t),this.screenNodeMap.set(e,o),this.setFpsAuto()}addTextSource(e){let{id:t,content:r="",font:i,color:o,layout:n}=e;if(this.textNodeMap.has(t))throw new Error("There is already a textSource with the same ID: ".concat(t));let a=this.videoContext.createTextSource({content:r,font:i,color:o});a.resize(n.width,n.height),this._connectMix(a,n),this.textNodeMap.set(t,a)}addImageSource(e,t,r){if(this.imageNodeMap.has(e))throw new Error("There is already a imageSource with the same ID: ".concat(e));let i=this.videoContext.createVideoImageSource(t,{autoResize:!1,logger:this.log});i.resize(t.width,t.height),this._connectMix(i,r),this.imageNodeMap.set(e,i)}addVideoSource(e,t,r){if(this.videoNodeMap.has(e))throw new Error("There is already a videoSource with the same ID: ".concat(e));let i=this.videoContext.createVideoImageSource(t,{autoResize:!1,logger:this.log});i.resize(t.videoWidth,t.videoHeight),i.shouldUpdate=!1,this._connectMix(i,r),this.videoNodeMap.set(e,i)}updateCameraSource(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3?arguments[3]:void 0,o=this.cameraNodeMap.get(e);if(o){if(r){if(16===SO&&r instanceof CanvasCaptureMediaStreamTrack)if(o instanceof RB){let t=o.output;o.close(),o=this.videoContext.createVideoImageSource(r.canvas,{name:"cameraCanvasSource",logger:this.log}),o.connect(t),this.cameraNodeMap.set(e,o)}else o.image=r.canvas;else if(o instanceof RB)o.replaceTrack(r);else{let t=o.output;o.close(),o=this.videoContext.createVideoTrackSource(r,"cameraNodeSource"),o.connect(t),this.cameraNodeMap.set(e,o)}let{width:t,height:i}=r.getSettings();t&&i&&o.resize(t,i)}i&&o.resize(i.width,i.height),(i||r)&&this.setFpsAuto(),this._changeMixLayout(o,t)}}updateScreenSource(e,t){let r=this.screenNodeMap.get(e);r&&this._changeMixLayout(r,t)}updateTextSource(e){let{id:t,content:r,font:i,color:o,layout:n}=e,a=this.textNodeMap.get(t);a&&(jD(r)||(a.content=r),jD(i)||(a.font=i),jD(o)||(a.color=o),a.resize(n.width,n.height),this._changeMixLayout(a,n))}updateImageSource(e,t,r){let i=this.imageNodeMap.get(e);i&&(r&&(i.image=r,i.resize(r.width,r.height)),this._changeMixLayout(i,t))}updateVideoSource(e,t,r){let i=this.videoNodeMap.get(e);if(i){if(r){let e=i.image;e instanceof HTMLVideoElement&&this.stopVideoElement(e),i.image=r,i.resize(r.videoWidth,r.videoHeight)}this._changeMixLayout(i,t)}}_connectMix(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"contain";if(!this.mixNode)return;let{mirror:i,rotation:o}=t;e.disconnect();let n=new xB(this.videoContext,this.log,i,o);n=e.connect(n),t.fillMode||(t.fillMode=r),n.connect(this.mixNode,t)}_changeMixLayout(e,t){if(!this.mixNode)return;let{mirror:r,rotation:i}=t,o=e.output||e;o instanceof xB&&(jD(r)||(o.mirror=r),jD(i)||(o.rotation=i),o.resize(e.width,e.height)),this.mixNode.changeInputLayout(o,t)}removeCameraSource(e){let t=this.inputLocalVideoTracks.get(e);if(!t)return;t.close(),this.inputLocalVideoTracks.delete(e);let r=this.cameraNodeMap.get(e);r&&(r.output instanceof xB&&r.output.close(),r.close(),this.cameraNodeMap.delete(e)),this.checkAfterRemove(!0)}removeScreenSource(e){let t=this.inputLocalScreenTracks.get(e);if(!t)return;t.close(),this.inputLocalScreenTracks.delete(e);let r=this.screenNodeMap.get(e);r&&(r.output instanceof xB&&r.output.close(),r.close(),this.screenNodeMap.delete(e)),this.checkAfterRemove(!0)}removeTextSource(e){let t=this.textNodeMap.get(e);t&&(t.output instanceof xB&&t.output.close(),t.close(),this.textNodeMap.delete(e)),this.checkAfterRemove()}removeImageSource(e){let t=this.imageNodeMap.get(e);t&&(t.output instanceof xB&&t.output.close(),t.close(),this.imageNodeMap.delete(e)),this.checkAfterRemove()}removeVideoSource(e){let t=this.videoNodeMap.get(e);t&&(t.output instanceof xB&&t.output.close(),t.image instanceof HTMLVideoElement&&this.stopVideoElement(t.image),t.close(),this.videoNodeMap.delete(e)),this.checkAfterRemove()}checkAfterRemove(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&this.setFpsAuto()}stopVideoElement(e){e.pause(),e.src="",e.srcObject=null,e.remove()}close(){var e;super.close(),YP.clearTask(this._checkId),null==(e=this.videoContext)||e.destroy(),delete this.mixNode,delete this.destination;for(let t of[...this.inputLocalVideoTracks.values(),...this.inputLocalScreenTracks.values()])t.close();this.inputLocalVideoTracks.clear(),this.inputLocalScreenTracks.clear(),this.cameraNodeMap.clear(),this.screenNodeMap.clear(),this.textNodeMap.clear(),this.imageNodeMap.clear(),ZP(this);for(let t of this.videoNodeMap.values())t.image instanceof HTMLVideoElement&&this.stopVideoElement(t.image);this.videoNodeMap.clear(),this.log.info("localMixVideoTrack close, stop mix")}},VB=eM();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:VB,exposeOrigin:!0,permittedOrigins:["*"]})}catch(OH){}var FB=function(e){return nw(this,null,(function*(){let t=null,r=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},r={width:gO?{max:e.width}:{ideal:e.width,max:e.width},height:gO?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=r,e.systemAudio){let{echoCancellation:r=!0,noiseSuppression:i=!1,autoGainControl:o=!1}=e;t.audio={echoCancellation:r,noiseSuppression:i,autoGainControl:o,sampleRate:48e3}}return t}(e);ZO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r)));let i=yield navigator.mediaDevices.getDisplayMedia(r);e.systemAudio&&0===i.getAudioTracks().length&&(hO&&mO<74||gO||hk)&&ZO.warn("Your browser not support capture system audio");let o=i.getVideoTracks()[0];if(o){if(e.frameRate)try{yield o.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(hM){ZO.warn("screen applyConstraints failed: ".concat(hM))}e.captureElement&&(yield function(e,t){return nw(this,null,(function*(){var r;if("CropTarget"in window&&"fromElement"in CropTarget&&GD(e.cropTo))try{if((null==(r=e.getCaptureHandle())?void 0:r.handle)!==VB)return;let i=yield CropTarget.fromElement(t);yield e.cropTo(i)}catch(i){ZO.warn("cropTo target failed ".concat(i))}}))}(o,e.captureElement))}if(e.audio){let r=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return jD(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);ZO.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t=yield navigator.mediaDevices.getUserMedia(r),i.addTrack(t.getAudioTracks()[0])}return i}))},BB=class extends dB{constructor(e){super(e,2),iw(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),iw(this,"objectFit","contain"),iw(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}get isShareCurrentTab(){var e,t;try{return VB===(null==(t=null==(e=this.mediaTrack)?void 0:e.getCaptureHandle())?void 0:t.handle)}catch(cM){return}}capture(e){return nw(this,arguments,(function(e){var t=this;let{systemAudio:r=!1,autoGainControl:i,echoCancellation:o,noiseSuppression:n,audioTrack:a,videoTrack:s,captureElement:l,preferDisplaySurface:c}=e;return function*(){try{let e;return s||a?(e=new MediaStream,s&&e.addTrack(s),a&&e.addTrack(a)):(e=yield FB({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:o,noiseSuppression:n,captureElement:l,preferDisplaySurface:c}),t.sourceTrack=e.getVideoTracks()[0]),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(e){throw t.log.error("getDisplayMedia error observed ".concat(e)),e instanceof mw?e:new mw({code:hw.INITIALIZE_FAILED,name:e.name,message:e.message})}}()}))}switchDevice(e){return nw(this,null,(function*(){throw new Error("Method not implemented.")}))}};rw([CU((function(e){this.setContentHint(e.contentHint||"detail")}))],BB.prototype,"capture",1);var HB,WB=class extends aB{constructor(e){super(e),this._log.id="s-".concat(this._log.id),this.isScreen=!0}addAudioProcessor(e,t,r){this.pipeline.silentNode.setNode(r),this.pipeline.mixNode.setNode(t),this.pipeline.aec.setNode(e),this.enableTrackAEC(!1)}removeAudioProcessor(e){this.pipeline.aec.node===e&&(this.pipeline.aec.deleteNode(),this.pipeline.silentNode.deleteNode(),this.pipeline.mixNode.deleteNode(),this.enableTrackAEC(!0))}};function GB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0;return nw(this,null,(function*(){let o=jx();HB||(HB=Nx(o,URL.createObjectURL(new Blob(['registerProcessor("dumper",class extends AudioWorkletProcessor{constructor(e){super(),this.sourceSampleRate=e.processorOptions.sourceSampleRate||48e3,this.targetSampleRate=e.processorOptions.targetSampleRate||48e3,this.port.onmessage=e=>{this.port2=e.data.port}}process(e){return(this.port2||this.port).postMessage(this.resampleAll(e,this.sourceSampleRate,this.targetSampleRate)),!0}resampleAll(r,s,a){if(s===a)return r;var o=[];for(let t=0;t<r.length;t++){o[t]=[];for(let e=0;e<r[t].length;e++)o[t][e]=this.resample(r[t][e],s,a)}return o}resample(t,e,r){if(e===r)return t;var s=Math.round(t.length*(this.targetSampleRate/this.sourceSampleRate)),a=new Float32Array(s),o=(t.length-1)/(s-1);a[0]=t[0];for(let e=1;e<s-1;e++){var l=e*o,p=Math.floor(l),h=Math.ceil(l);a[e]=t[p]+(t[h]-t[p])*(l-p)}return a[s-1]=t[t.length-1],a}});'],{type:"application/javascript"})))),yield HB;let n=o.sampleRate,a=new AudioWorkletNode(o,"dumper",{numberOfInputs:e.length,numberOfOutputs:0,processorOptions:{sourceSampleRate:n,targetSampleRate:t}});return a.channelCountMode="explicit",a.channelCount=r,i&&a.port.postMessage({port:i},[i]),e.forEach(((e,t)=>e.connect(a,0,t))),new ReadableStream({start(e){a.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(a))),a.port.close()}})}))}var jB=class extends Jx{constructor(e){super(),this.room=e,iw(this,"_localAudioTrack"),iw(this,"_localScreenAudioTrack"),iw(this,"log"),iw(this,"denoiser"),iw(this,"voiceChanger"),iw(this,"mixChangedDebounce"),iw(this,"audioProcessor"),iw(this,"encodePipeline",[]),iw(this,"decodePipeline",[]),iw(this,"getPCMAbortCtrlMap",new Map),iw(this,"audioFrameEventConfigMap",new Map),iw(this,"audioReferenceMap",new Map),iw(this,"isLocalAudioNeedAudioProcess",!1),iw(this,"isScreenAudioNeedAudioProcess",!1),this.log=ZO.createLogger({parent:null==e?void 0:e.getLogger(),id:"am",userId:null==e?void 0:e.userId,sdkAppId:null==e?void 0:e.sdkAppId}),this.installEvent()}get localAudioTrack(){return this._localAudioTrack}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}get _localScreenAudioPipeline(){var e;return null==(e=this._localScreenAudioTrack)?void 0:e.pipeline}dump(e){var t,r;if(!this._localAudioTrack)return;let i=[],o=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),o.push("mic")),null!=(r=this._localAudioPipline)&&r.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(e));let n=new AbortController,a=[],s=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),n.abort("timeout")}),1e3*e),l=()=>{for(let e=0;e<o.length;e++){let t=URL.createObjectURL(new Blob(a[e])),r=document.createElement("a");r.href=t,r.download="".concat(o[e],".pcm"),r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(t),r.remove()}clearTimeout(s),n.abort("download")},c=GB(i).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>a[t]=a[t]?a[t].concat(e[0]):[e[0]]))}}),n).catch((e=>l))));return{then:c.then.bind(c),download:l}}getPCM(e,t){var r,i,o;if("undefined"==typeof WritableStream)return void this.log.warn("getPCM failed: browser not support WritableStream");let{enable:n,sampleRate:a=48e3,channelCount:s=1,port:l}=(""===t?this.audioFrameEventConfigMap.get(""):this.audioFrameEventConfigMap.get(t)||this.audioFrameEventConfigMap.get("*"))||{};if(!n)return;this.log.info("getPCM ".concat(t||"local"));let c,d,u=Math.floor(.04*a),h=new Float32Array(u),p=new Float32Array(u),m=0,f=new AbortController,_=""===t?null==(r=this._localAudioTrack)?void 0:r.mediaTrack:null==(o=null==(i=this.room)?void 0:i.remotePublishedUserMap.get(t))?void 0:o.remoteAudioTrack.mediaTrack;if(_)return GB([jx().createMediaStreamSource(new MediaStream([_]))],a,s,l).then((r=>r.pipeTo(new WritableStream({write(r){r[0][0]&&(m+r[0][0].length>u?(h.set(r[0][0].subarray(0,u-m),m),c=r[0][0].subarray(u-m),r[0][1]&&(p.set(r[0][1].subarray(0,u-m),m),d=r[0][1].subarray(u-m)),m+=u-m):(c&&(h.set(c,m),m+=c.length,c=void 0),d&&(p.set(d,m),d=void 0),h.set(r[0][0],m),r[0][1]&&p.set(r[0][1],m),m+=r[0][0].length),m>=u&&(m=0,e({userId:t,sampleRate:a,channelCount:s,data:1===s?h:[h,p]}),h=new Float32Array(u),p=new Float32Array(u)))}}),f).catch((e=>this.log.warn("stop getPCM reason:".concat(e)))))),f;this.log.info("getPCM failed: ".concat(t||"local"," has no audio track"))}get hasScreenAudioTrack(){return!jD(this._localScreenAudioTrack)}get hasAudioTrack(){return!jD(this._localAudioTrack)}changeInput(e){var t,r;return e instanceof WB?(this._localScreenAudioTrack=e,this.isScreenAudioNeedAudioProcess&&null!=(t=this.audioProcessor)&&t.screenAudioWorkletNode&&(e.addAudioProcessor(this.audioProcessor.screenAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach(((t,r)=>{e.mixAudioReference(t,r)}))),e.pipeline.connect(),this.mixOnChange()):e instanceof aB?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),this.isLocalAudioNeedAudioProcess&&null!=(r=this.audioProcessor)&&r.localAudioWorkletNode&&(e.addAudioProcessor(this.audioProcessor.localAudioWorkletNode,this.audioProcessor.mixNode,this.audioProcessor.silentNode),this.audioReferenceMap.forEach(((t,r)=>{e.mixAudioReference(t,r)}))),e.pipeline.connect(),this.mixOnChange()):e instanceof qB?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}mixAudioReference(e,t){var r;null==(r=this._localAudioTrack)||r.mixAudioReference(e,t)}unMixAudioReference(e){var t;null==(t=this._localAudioTrack)||t.unMixAudioReference(e)}setAudioReferenceVolume(e,t){var r;null==(r=this._localAudioTrack)||r.setAudioReferenceVolume(e,t)}mixOnChange(){return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((()=>{var e,t;return delete this.mixChangedDebounce,Promise.all([null==(e=this._localAudioTrack)?void 0:e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)?void 0:t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}removeInput(e){e instanceof WB?delete this._localScreenAudioTrack:e instanceof aB&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}addAudioProcessor(e,t,r,i){var o;this.audioProcessor={localAudioWorkletNode:r,mixNode:e,silentNode:t,screenAudioWorkletNode:i},this.isLocalAudioNeedAudioProcess&&this._localAudioTrack&&r&&(this._localAudioTrack.addAudioProcessor(r,e,t),this.audioReferenceMap.forEach(((e,t)=>{var r;null==(r=this._localAudioTrack)||r.mixAudioReference(e,t)}))),this.isScreenAudioNeedAudioProcess&&this._localScreenAudioTrack&&i&&(null==(o=this._localScreenAudioTrack)||o.addAudioProcessor(i,e,t),this.audioReferenceMap.forEach(((e,t)=>{var r;null==(r=this._localScreenAudioTrack)||r.mixAudioReference(e,t)})))}removeDenoiser(e){var t;return delete this.denoiser,null==(t=this._localAudioTrack)?void 0:t.removeDenoiser(e)}addVoiceChanger(e,t){var r;this.voiceChanger=[e,t],null==(r=this._localAudioTrack)||r.pipeline.voiceChanger.setNode(e,t)}removeVoiceChanger(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}removeAudioProcessor(e,t){var r,i;delete this.audioProcessor,null==(r=this._localAudioTrack)||r.removeAudioProcessor(e),null==(i=this._localScreenAudioTrack)||i.removeAudioProcessor(t)}destroy(){this.close(),this.audioReferenceMap.clear(),this.getPCMAbortCtrlMap.forEach((e=>null==e?void 0:e.abort("destroy"))),this.getPCMAbortCtrlMap.clear(),this.audioFrameEventConfigMap.clear(),this.uninstallEvent()}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}handleLocalTrackStarted(e){let{room:t,userId:r}=e;var i;if(t!==this.room||this.getPCMAbortCtrlMap.get(r))return;let o=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),"");this.getPCMAbortCtrlMap.set(r,o),this.getPCMAbortCtrlMap.get(r)&&(null==(i=this._localAudioTrack)||i.on("input-media-track-changed",(()=>{let e=this.getPCMAbortCtrlMap.get(r);e&&(e.abort("inputMediaTrackChanged"),e=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),""),this.getPCMAbortCtrlMap.set(r,e))})))}handleLocalTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopLocalAudio"),this.getPCMAbortCtrlMap.delete(r))}handleRemoteTrackStarted(e){let{room:t,userId:r}=e;if(t===this.room&&!this.getPCMAbortCtrlMap.get(r)){let e=this.room.audioManager.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),r);this.getPCMAbortCtrlMap.set(r,e)}}handleRemoteTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopRemoteAudio"),this.getPCMAbortCtrlMap.delete(r))}installEvent(){YO.on("113",this.handleLocalTrackStarted,this),YO.on("114",this.handleLocalTrackStopped,this),YO.on("115",this.handleRemoteTrackStarted,this),YO.on("116",this.handleRemoteTrackStopped,this)}uninstallEvent(){YO.off("113",this.handleLocalTrackStarted),YO.off("114",this.handleLocalTrackStopped),YO.off("115",this.handleRemoteTrackStarted),YO.off("116",this.handleRemoteTrackStopped)}updateAudioReference(e){let{type:t,audioReference:r,refId:i,volume:o}=e;if("add"===t){if(this.audioReferenceMap.get(i)||!r||(this.audioReferenceMap.set(i,r),!this.audioProcessor))return;this.mixAudioReference(r,i)}else if("remove"===t)this.audioReferenceMap.get(i)&&(this.audioReferenceMap.delete(i),this.unMixAudioReference(i));else if("updateVolume"===t){if(!this.audioProcessor||jD(o))return;this.setAudioReferenceVolume(i,o)}}};var zB=class e extends yU{constructor(t,r,i){super({userId:r.userId,sdkAppId:t.sdkAppId,mediaType:i,room:t}),this.room=t,this.user=r,iw(this,"tinyId"),iw(this,"isRemote",!0),iw(this,"jitterBufferDelay",0),iw(this,"availableState"),iw(this,"remotePublishState"),iw(this,"_triggerCheckDecodeSubject",_V(DV(this,e.STATE_SUBSCRIBE))),iw(this,"ignoreUpdatePlayingState"),this.tinyId=r.tinyId,this.availableState=new WP("".concat(r.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new WP("".concat(r.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),JU(oV(DV(this,WP.STATECHANGED),DV(this.remotePublishState,WP.STATECHANGED)),IF((()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing))),$F((e=>{this.availableState.state!==(e?WP.ON:WP.OFF)&&(this.availableState.state=e?WP.ON:WP.OFF),(!this.isRemotePublished||!this.ignoreUpdatePlayingState)&&this.updatePlayingState(e)})));let o=JU(DV(this.player,JP.ERROR),YV((e=>e.code===MediaError.MEDIA_ERR_DECODE))),n=JU(bV(5e3),YV((()=>!(this.ignoreDecodeError||!this.isSubscribed||!this.isPlayCalled||!this.stat.bytesReceived)&&(!this.player.isPlaying&&!(this.kind===eC.AUDIO?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1))))),a=JU(nV(o,n),QV(DV(this,WP.INIT)));JU(this._triggerCheckDecodeSubject,YV((()=>!this.ignoreDecodeError)),NF(a),$F((e=>{this.reportDecodeResult(!1,e)})))}setMute(e){this.isRemotePublished&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}checkDecodeResult(){this._triggerCheckDecodeSubject.next(!0)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get ignoreDecodeError(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===WP.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){var r,i;let o=this.kind===eC.AUDIO;if(RL[e?"addSuccessEvent":"addFailedEvent"]({key:o?504700:514702}),!o){let t=(null==(r=this.room)?void 0:r.downlinkVideoCodec.toUpperCase())||"H264";RL[e?"addSuccessEvent":"addFailedEvent"]({key:IL["DECODE_".concat(t,"_RESULT")]}),e||this.log.warn("".concat(null==(i=this.room)?void 0:i.downlinkVideoCodec," decode failed"))}e||(RL.addEnum({key:o?504701:514703,value:WO()}),ex.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(VO()||jO()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===eC.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}updatePlayingState(e){if(this.player.isPlayCalled&&this.player.setTrack(this.playerMediaTrack),this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));super.updatePlayingState(e)}}close(){super.close(),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}onFlagChanged(){this.remotePublishState.state=this.isRemotePublished?WP.ON:WP.OFF,this.emit("remote-publish-changed",this.isRemotePublished)}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};iw(zB,"STATE_SUBSCRIBE","subscribe"),rw([function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return DU(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return new Promise(((o,a)=>{let s=setTimeout((()=>{let r=new mw({code:hw.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(e,"s")});(this.log||this._log||ZO).warn(r),2===t?a(r):1===t&&o()}),1e3*e);this._checkPendingPromiseSet||(this._checkPendingPromiseSet=new Set),this._checkPendingPromiseSet.add(s),r.apply(this,n).then(o,a).finally((()=>{clearTimeout(s),this._checkPendingPromiseSet&&s&&this._checkPendingPromiseSet.delete(s)}))}))}))}(5,1)],zB.prototype,"waitHasMediaTrack",1),rw([FP(WP.INIT,zB.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),YO.emit(XO.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),UU(521716,!1)],zB.prototype,"subscribe",1),rw([FP(zB.STATE_SUBSCRIBE,WP.INIT,{sync:!0,success(){this.log.info("unsubscribed"),YO.emit(XO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],zB.prototype,"unsubscribe",1);var KB=zB,qB=class extends KB{constructor(e,t){super(e,t,1),iw(this,"volume",0),iw(this,"mediaType",1),iw(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}get dbVolume(){return tU.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}onPlayerError(e){this.enableDecodeFrame&&(this._log.warn("use audio decoder"),this.room.enableInsertableStreams())}get enableDecodeFrame(){var e,t;return!!this.manager&&(this.manager.decodePipeline.some((e=>e))||(null==(t=null==(e=this.player.element)?void 0:e.error)?void 0:t.code)===MediaError.MEDIA_ERR_DECODE&&gP().AudioDecoder&&pP)}get enableDecryptFrame(){return this.manager&&!!this.manager.decodePipeline[0]}decodeFrame(e){if(!this.manager)return e;let t=e;for(let[r,i]of this.manager.decodePipeline.entries()){if(!i)continue;let o={frame:e,track:this};if(1===r&&this.isAvailable&&"audience"===this.room.role&&(o.onAudioFrameNTPTime=e=>{let{ntp:t,frame:r,hasLeavingTag:i}=e;this.emit("audio-frame-with-ntp",{ntp:t,frame:r,hasLeavingTag:i})}),t=i(o),!t)return}return t}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get isRemotePublished(){return this.user.muteState.audioAvailable}},YB=class extends fB{constructor(e,t,r,i,o){super(e,{useDefaultProgram:!0,useFbo:!0,name:"alpha",create2d:!0,logger:t}),this.setContainer=i,iw(this,"initStat",{alphaStitchingType:1}),iw(this,"end",_V()),iw(this,"minSize",320),iw(this,"maxSize",1280),iw(this,"draggable",!1),iw(this,"startDragX",0),iw(this,"startDragY",0),iw(this,"left",0),iw(this,"top",0),iw(this,"baseWidth",320),iw(this,"baseRatio"),iw(this,"container"),this.initStat=o,this.draggable=r,this.bindDragEvents()}bindDragEvents(){let e=this.context._canvas;if(e)if(this.draggable){let t=QV(this.end);JU(DV(e,"mousedown"),ZF(this.startDrag.bind(this)),CF((()=>JU(DV(window,"mousemove"),QV(DV(window,"mouseup"))))),t,$F(this.doDrag.bind(this))),JU(DV(e,"dblclick"),t,$F(this.resetPosition.bind(this))),JU(DV(e,"wheel"),t,$F(this.handleZoom.bind(this))),this.renderCanvas()}else{if(!this.container)return;this.container.style.removeProperty("left"),this.container.style.removeProperty("top"),this.end.next()}}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}startDrag(e){e.preventDefault(),0===e.button&&(this.startDragX=e.clientX-this.left,this.startDragY=e.clientY-this.top)}renderCanvas(){let{container:e}=this;e||this.setContainer(),e&&this.baseRatio&&this.draggable&&(e.style.setProperty("width","".concat(this.baseWidth,"px")),e.style.setProperty("height","".concat(this.baseWidth/this.baseRatio,"px")),e.style.setProperty("position","fixed"),e.style.setProperty("left","".concat(this.left,"px")),e.style.setProperty("top","".concat(this.top,"px")))}doDrag(e){e.preventDefault(),this.left=e.clientX-this.startDragX,this.top=e.clientY-this.startDragY,this.renderCanvas()}handleZoom(e){e.preventDefault();let t=e.deltaY,r=this.context._canvas;r&&(this.baseWidth||(this.baseWidth=r.offsetWidth),this.baseWidth=t<0?Math.min(1.1*this.baseWidth,this.maxSize):Math.max(.9*this.baseWidth,this.minSize),this.renderCanvas())}resetPosition(){this.left=0,this.top=0,this.renderCanvas()}onRatioReset(){this.renderCanvas()}draw2d(e,t,r,i,o){var n;let{ctx2d:a}=this,s=this.context._canvas;if(!a||!s)return!1;let l=super.draw2d(e,t,r,i,o),c=a.getImageData(0,0,i,o),{data:d}=c,u=!1;if(1===this.initStat.alphaStitchingType){let e=Math.floor(i/2);for(let t=0;t<o;t++)for(let r=0;r<e;r++){let o=4*(t*i+r),n=4*(t*i+(r+e)),a=d[n];d[n+3]=0;let s=a>=100;d[o+3]=s?255:0}u=super.draw2d(c,0,0,0,0,e,o),s.width=e}else if(2===this.initStat.alphaStitchingType){let e=Math.floor(o/2);for(let t=0;t<e;t++)for(let r=0;r<i;r++){let o=4*(t*i+r),n=4*((t+e)*i+r),a=d[n];d[n+3]=0;let s=a>=100;d[o+3]=s?255:0}u=super.draw2d(c,0,0,0,0,i,e),s.height=e}return null==(n=this.context.ctx)||n.clearRect(0,0,i,o),l&&u}close(){this.baseRatio=void 0,this.end.next(),this.end.complete()}};var JB=class extends KB{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),iw(this,"mediaType",4),iw(this,"source"),iw(this,"shouldRenderAlpha",!1),iw(this,"alphaNode"),iw(this,"shouldBeDraggable",!0),iw(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager,this.on("first-video-frame",(e=>{this.room.emit("first-video-frame",e)}))}isAlphaSei(e){if(this.userId!==e.userId||50!==e.seiPayloadType)return!1;let t=new Uint8Array(e.data);return t.length%3==0&&0===t[0]&&1===t[1]&&t}play(e,t){return(qD(null==t?void 0:t.canvasRender)?t.canvasRender:17===SO)&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then((()=>{this.player.calculateStat(),YO.emit("156",{track:this,player:this.player})}))}updateAlphaRenderInfo(e){let t=this.isAlphaSei(e);if(t)if(this.alphaNode){let e=t[2];if(this.alphaNode.baseRatio&&this.alphaNode.initStat.alphaStitchingType===e)return;this.alphaNode.initStat={alphaStitchingType:e};let r=this.player.getElement();if(r){let t=r.videoWidth/r.videoHeight;t&&(this.alphaNode.baseRatio=t*(1===e?.5:2),this.alphaNode.onRatioReset())}this.player.canvas&&(this.player.canvas.id=this.generateAlphaCanvasName(e))}else this.shouldRenderAlpha=!0,this.player.shouldRenderAlpha=!0,this.useCanvasPlayer(t[2])}generateAlphaCanvasName(e){let t=cL[e];return"".concat("alpha","_").concat(t,"_").concat(this.userId)}useCanvasPlayer(e){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),!this.player.element)return;let t=new kB({frameRate:15,logger:this.log,name:this.shouldRenderAlpha&&e?this.generateAlphaCanvasName(e):this.userId});t.create({alpha:this.shouldRenderAlpha,willReadFrequently:this.shouldRenderAlpha});let r=new vB(t,{name:"remotePlayer",logger:this.log});if(this.source=t.createVideoPlayerSource(this.player),this.player.setCanvas(t._canvas),this.shouldRenderAlpha&&e){let i=()=>{!this.player.container||!this.alphaNode||(this.alphaNode.container=this.player.container,this.alphaNode.renderCanvas())},o=new YB(t,this.log,this.shouldBeDraggable,i,{alphaStitchingType:e});this.source.connect(o),o.connect(r),this.alphaNode=o}else this.source.connect(r);RP()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,t),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,r=(i=t,[15,30,45,60].reduce(((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e)));var i;!KD(t)||t<=0?this.log.debug("updateCanvasPlayerFPS() ignore decoder: ".concat(t," ")):r!==e.frameRate?(this.log.info("updateCanvasPlayerFPS() decoder: ".concat(t,", closest: ").concat(r,", current: ").concat(e.frameRate)),e.frameRate=r):this.log.debug("updateCanvasPlayerFPS() ignore ClosestFPS ".concat(r," == ").concat(e.frameRate))}get decodeFPS(){var e;let{msg_video_status:t}=(null==(e=this.room.heartbeatReport)?void 0:e.msg_down_stream_info.find((e=>e.msg_user_info.str_identifier===this.userId)))||{},r=2===this.mediaType?7:this.isSmall?3:2;if(!t||0===t.length)return 0;let i=t.find((e=>e.uint32_video_stream_type===r));return(null==i?void 0:i.uint32_video_dec_fps)||0}stop(){return this.room.off("heartbeat-report",this.updateCanvasPlayerFPS,this),YO.emit("157",{track:this,player:this.player}),this.alphaNode&&this.alphaNode.close(),super.stop()}decodeFrame(e){if(!this.manager)return e;for(let t of this.manager.decodePipeline)if(t&&!(e=t({frame:e,track:this})))return;return e}get isBig(){return 4===this.mediaType}get isSmall(){return 8===this.mediaType}changeType(e){this.room.changeType(e,this.user)}get isRemotePublished(){return this.user.muteState.videoAvailable}setMirror(e){"publish"===e||"both"===e||super.setMirror(e)}setDraggable(e){this.shouldBeDraggable=e,this.alphaNode&&(this.alphaNode.draggable=e,this.alphaNode.bindDragEvents())}onDecodeDowngradeStateChanged(e){this.emit("decode-downgrade-state-changed",e)}},XB=class extends JB{constructor(e,t){super(e,t,2),iw(this,"mediaType",2),iw(this,"objectFit","contain")}get isRemotePublished(){return this.user.muteState.hasAuxiliary}},QB=new Map;function $B(e,t){let r=$b(Qb({},t),{timestamp:_w()});QB.has(e)?QB.get(e).push(r):QB.set(e,[r])}function ZB(e){if(QB.has(e)){let t=QB.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType})));return QB.delete(e),t}return[]}function eH(e,t,r,i){try{if(JD(e))for(let o=0;o<e.length;o++)tH.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else tH.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}catch(cM){throw ZO.error(cM),cM}}function tH(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;if(jD(r)){if(t.required)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_REQUIRED,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(jD(t.defaultValue))return;r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),GD(t.type[i])&&r instanceof t.type[i]&&(e=!0),zD(t.type[i])&&WD(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_TYPE,data:{key:i,rule:{type:t.type.map((e=>ZD(e)?eN(e):zD(e)?e:WD(e)))},fnName:o,value:r},link:{className:n,fnName:o}})})}else if(!jD(t.type)&&WD(r)!==t.type)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_TYPE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!1===t.allowEmpty){let e=KD(r)&&(0===r||Number.isNaN(r)),a=zD(r)&&""===r.trim();if(e||a)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_EMPTY,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}if(t.notLessThanZero&&KD(r)&&r<0)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.CANNOT_LESS_THAN_ZERO,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!jD(t.min)&&KD(r)&&r<t.min)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_MIN,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!jD(t.max)&&KD(r)&&r>t.max)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_MAX,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(zD(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}else if(GD(t.instanceOf)&&!(r instanceof t.instanceOf))throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(t.values&&!t.values.includes(r))throw new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.INVALID_PARAMETER_RANGE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});let{properties:a}=t;FD(a)&&YD(r)&&Object.keys(a).forEach((e=>{tH.call(this,{rule:a[e],value:r&&r[e],key:"".concat(i,".").concat(e),fnName:o,className:n})}));let{arrayItem:s}=t;FD(s)&&JD(r)&&r.forEach(((e,t)=>{tH.call(this,{rule:s,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),GD(t.validate)&&t.validate.call(this,r,i,o,n,this)}YO.on(XO.JOIN_SUCCESS,(e=>{let{room:t}=e;$B(t.userId,{eventId:32788})})),YO.on(XO.LEAVE_START,(e=>{let{room:t}=e;$B(t.userId,{eventId:32789})})),YO.on(XO.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),$B(t.room.userId,{eventId:e})}})),YO.on(XO.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),$B(t.room.userId,{eventId:e})}})),YO.on(XO.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===eC.AUDIO?$B(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):$B(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),YO.on(XO.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===eC.AUDIO?$B(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):$B(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),YO.on(XO.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&$B(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&$B(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&$B(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),YO.on(XO.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&$B(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&$B(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&$B(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),YO.on(XO.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&$B(t.room.userId,{eventId:t.kind===eC.VIDEO?32780:32781})})),YO.on(XO.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&$B(t.room.userId,{eventId:t.kind===eC.VIDEO?32782:32783})})),YO.on(XO.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o}=e;switch(o){case"CONNECTED":t="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":t=32794}t&&$B(r.userId,{eventId:t})})),YO.on(XO.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o,remoteUserId:n}=e,a=!!n;switch(o){case"CONNECTED":t="RECONNECTING"===i?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(t=a?32802:32799);break;case"RECONNECTING":t=a?32800:32797}t&&$B(r.userId,{eventId:t,remoteUserId:n})})),YO.on(XO.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(e=>{let{implementation:t,userId:r,remoteUserId:i,codec:o,isHWCodec:n,prevImplementation:a,streamType:s}=e,l=n?1:0;a||(l=n?3:2);let c={H264:0,H265:1,VP8:2}[o.toUpperCase()],d={eventId:4004,param1:l,param2:c,streamType:s||2};i&&(d.remoteUserId=i,d.eventId=4005),$B(r,d),RL.addEnum({key:i?514701:513701,value:l}),RL.addEnum({key:i?514700:513700,value:c})})),YO.on(XO.LOCAL_TRACK_RECAPTURE,(e=>{let{track:t,error:r}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===eC.AUDIO?(e.streamType=1,r&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,r&&(e.param1=8)),$B(t.userId,e)}})),tw(aw(),1);var rH=Object.create,iH=Object.defineProperty,oH=Object.defineProperties,nH=Object.getOwnPropertyDescriptor,aH=Object.getOwnPropertyDescriptors,sH=Object.getOwnPropertyNames,lH=Object.getOwnPropertySymbols,cH=Object.getPrototypeOf,dH=Object.prototype.hasOwnProperty,uH=Object.prototype.propertyIsEnumerable,hH=(e,t,r)=>t in e?iH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pH=(e,t)=>{for(var r in t||(t={}))dH.call(t,r)&&hH(e,r,t[r]);if(lH)for(var r of lH(t))uH.call(t,r)&&hH(e,r,t[r]);return e},mH=(e,t)=>oH(e,aH(t)),fH=(e,t,r)=>(r=null!=e?rH(cH(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of sH(t))dH.call(e,o)||o===r||iH(e,o,{get:()=>t[o],enumerable:!(i=nH(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:iH(r,"default",{value:e,enumerable:!0}),e)),_H=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?nH(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&iH(t,r,n),n},gH=(e,t,r)=>hH(e,"symbol"!=typeof t?t+"":t,r),EH=((e,t)=>function(){return t||(0,e[sH(e)[0]])((t={exports:{}}).exports,t),t.exports})({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),l=i?i+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new o:delete e._events[t]}function l(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),l.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},l.prototype.listeners=function(e){var t=i?i+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},l.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},l.prototype.emit=function(e,t,r,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var l,c,d=this._events[s],u=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),u){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,r),!0;case 4:return d.fn.call(d.context,t,r,o),!0;case 5:return d.fn.call(d.context,t,r,o,n),!0;case 6:return d.fn.call(d.context,t,r,o,n,a),!0}for(c=1,l=new Array(u-1);c<u;c++)l[c-1]=arguments[c];d.fn.apply(d.context,l)}else{var h,p=d.length;for(c=0;c<p;c++)switch(d[c].once&&this.removeListener(e,d[c].fn,void 0,!0),u){case 1:d[c].fn.call(d[c].context);break;case 2:d[c].fn.call(d[c].context,t);break;case 3:d[c].fn.call(d[c].context,t,r);break;case 4:d[c].fn.call(d[c].context,t,r,o);break;default:if(!l)for(h=1,l=new Array(u-1);h<u;h++)l[h-1]=arguments[h];d[c].fn.apply(d[c].context,l)}}return!0},l.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},l.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},l.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,n);else{for(var l=0,c=[],d=a.length;l<d;l++)(a[l].fn!==t||o&&!a[l].once||r&&a[l].context!==r)&&c.push(a[l]);c.length?this._events[n]=1===c.length?c[0]:c:s(this,n)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=i,l.EventEmitter=l,void 0!==t&&(t.exports=l)}}),vH=fH(EH(),1),yH=Symbol("instance"),TH=Symbol("cacheResult"),IH=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,wH.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},AH=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var SH=new Map;function RH(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=SH.get(i)||[];SH.has(i)||SH.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),l=0;l<o;l++)n[l]=arguments[l];if(r.context&&(i=CH.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[TH]:Promise.resolve(i[TH]);i.state instanceof IH&&i.state.action==r.abortAction&&i.state.abort(i);let c=null;Array.isArray(e)?0==e.length?i.state instanceof IH&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(c=new AH(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(c=new AH(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let d=e=>{if(r.fail&&r.fail.call(this,e),r.sync){if(r.ignoreError)return e;throw e}return r.ignoreError?Promise.resolve(e):Promise.reject(e)};if(c)return d(c);let u=i.state,h=new IH(u,t,a);wH.call(i,h);let p=e=>{var o;return i[TH]=e,h.aborted||(wH.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[TH])),e},m=e=>(wH.call(i,u,e),d(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(pM){return m(new AH(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(pM),pM instanceof Error?pM:new Error(String(pM))))}}}}var bH="undefined"!=typeof window&&window.__AFSM__?(e,t)=>{window.dispatchEvent(new CustomEvent(e,{detail:t}))}:"undefined"!=typeof importScripts?(e,t)=>{postMessage({type:e,payload:t})}:()=>{};function wH(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(CH.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var CH=class e extends vH.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[yH];o?this.name=o.name+"-"+o.count++:i[yH]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=SH.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);SH.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};bH(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){wH.call(this,e)}};CH.STATECHANGED="stateChanged",CH.UPDATEAFSM="updateAFSM",CH.INIT="[*]",CH.ON="on",CH.OFF="off",CH.instances=new Map,CH.instances2=new WeakMap;var DH=class extends CH{constructor(){super(...arguments),gH(this,"decoder"),gH(this,"config")}initialize(){return nw(this,null,(function*(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}))}configure(e){this.config=e,this.decoder.configure(mH(pH({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function NH(){var e;self.onmessage=t=>{if("init"===t.data.type){let{canvas:r,wasmScript:i,wasmBinary:o}=t.data,n=null==r?void 0:r.getContext("2d"),a=0,s=0,l={wasmBinary:o,postRun:()=>{e=new l.VideoDecoder({videoInfo(e,t){a=e,s=t,console.log("video info",e,t)},yuvData(e,t){let i=a*s,o=i>>2,c=l.HEAPU32[e>>2],d=l.HEAPU32[1+(e>>2)],u=l.HEAPU32[2+(e>>2)],h=l.HEAPU8.subarray(c,c+i),p=l.HEAPU8.subarray(d,d+o),m=l.HEAPU8.subarray(u,u+o),f=new Uint8Array(i+o+o);f.set(h),f.set(p,i),f.set(m,i+o);let _=new VideoFrame(f,{codedWidth:a,codedHeight:s,format:"I420",timestamp:t});r?(null==n||n.drawImage(_,0,0,r.width,r.height),null==n||n.commit()):self.postMessage({type:"yuvData",videoFrame:_},[_])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+i)()(l)}else if("decode"===t.data.type){let{packet:r}=t.data;null==e||e.decode(r.data,"key"==r.type,r.timestamp)}else if("setCodec"===t.data.type){let{codec:r,format:i,description:o}=t.data;null==e||e.setCodec(r,i,null!=o?o:"")}}}_H([RH([CH.INIT,"closed"],"initialized")],DH.prototype,"initialize",1),_H([RH("initialized","configured",{sync:!0})],DH.prototype,"configure",1),_H([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return(e,r,i)=>{let o=i.value,n=r;i.value=function(){if(!t.includes(this.state.toString()))throw new AH(this.state,"".concat(this.name," ").concat(n," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return o.apply(this,r)}}}("configured")],DH.prototype,"decode",1),_H([RH([],CH.INIT,{sync:!0})],DH.prototype,"reset",1),_H([RH([],"closed",{ignoreError:!0,sync:!0})],DH.prototype,"close",1);var kH=class extends CH{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.createModule=e,this.wasmBinary=t,this.workerMode=r,this.canvas=i,this.yuvMode=o,gH(this,"worker"),gH(this,"decoder"),gH(this,"config"),gH(this,"module",{}),gH(this,"width",0),gH(this,"height",0)}initialize(e){return nw(this,null,(function*(){var t;if(this.workerMode){let e=new RegExp("\\{(.+)\\}","s").exec(NH.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));let r=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),i=yield this.wasmBinary;return console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:r,wasmScript:this.createModule.toString(),wasmBinary:i},r?[r,i]:[i]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){let{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}let r=this.module;return this.wasmBinary&&(r.wasmBinary=yield this.wasmBinary),r.print=e=>console.log(e),r.printErr=e=>console.log("[JS] ERROR: ".concat(e)),r.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{r.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(r,e),this.createModule(r)}))}))}configure(e){var t,r,i;this.config=e;let o=this.config.codec.startsWith("avc")?"avc":"hevc",n=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,n,null!=(t=this.config.description)?t:""),null==(i=this.worker)||i.postMessage({type:"setCodec",codec:o,format:n,description:this.config.description})}decode(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let r={width:e,height:t};this.emit("videoCodecInfo",r)}yuvData(e,t){if(!this.module)return;let r=this.width*this.height,i=r>>2,o=this.module.HEAPU32[e>>2],n=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),l=this.module.HEAPU8.subarray(n,n+i),c=this.module.HEAPU8.subarray(a,a+i);if(this.yuvMode)return void this.emit("videoFrame",{y:s,u:l,v:c,timestamp:t});let d=new Uint8Array(r+i+i);d.set(s),d.set(l,r),d.set(c,r+i),this.emit("videoFrame",new VideoFrame(d,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};_H([RH([CH.INIT,"closed"],"initialized")],kH.prototype,"initialize",1),_H([RH("initialized","configured",{sync:!0})],kH.prototype,"configure",1),_H([RH([],CH.INIT,{sync:!0})],kH.prototype,"reset",1),_H([RH([],"closed",{sync:!0})],kH.prototype,"close",1);var OH,MH=(OH="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,i=e;i.ready=new Promise(((e,i)=>{t=e,r=i}));var o,n,a,s=Object.assign({},i),l="./this.program",c="object"==typeof window,d="function"==typeof importScripts,u=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(c||d)&&(d?u=self.location.href:"undefined"!=typeof document&&document.currentScript&&(u=document.currentScript.src),OH&&(u=OH),u=0!==u.indexOf("blob:")?u.substr(0,u.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),n=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)});var h,p,m=i.print||console.log.bind(console),f=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(l=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(h=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&U("no native wasm support detected");var _,g,E,v,y,T,I,A,S,R,b,w,C,D=!1,N=[],k=[],O=[],M=0,L=null;function P(e){M++,i.monitorRunDependencies&&i.monitorRunDependencies(M)}function x(e){if(M--,i.monitorRunDependencies&&i.monitorRunDependencies(M),0==M&&L){var t=L;L=null,t()}}function U(e){i.onAbort&&i.onAbort(e),f(e="Aborted("+e+")"),D=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function V(e){return e.startsWith("data:application/octet-stream;base64,")}function F(e){if(e==R&&h)return new Uint8Array(h);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function B(e,t,r){return(i=e,h||!c&&!d||"function"!=typeof fetch?Promise.resolve().then((()=>F(i))):fetch(i,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+i+"'";return e.arrayBuffer()})).catch((()=>F(i)))).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{f("failed to asynchronously prepare wasm: "+e),U(e)}));var i}V(R="videodec.wasm")||(b=R,R=i.locateFile?i.locateFile(b,u):u+b);var H=e=>{for(;e.length>0;)e.shift()(i)};function W(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){T[this.ptr+4>>2]=e},this.get_type=function(){return T[this.ptr+4>>2]},this.set_destructor=function(e){T[this.ptr+8>>2]=e},this.get_destructor=function(){return T[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,_[this.ptr+12|0]=e},this.get_caught=function(){return 0!=_[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,_[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=_[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){T[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return T[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Rt(this.get_type()))return T[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var G={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,i=e.length-1;i>=0;i--){var o=e[i];"."===o?e.splice(i,1):".."===o?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=G.isAbs(e),r="/"===e.substr(-1);return(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=G.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=G.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return G.normalize(e.join("/"))},join2:(e,t)=>G.normalize(e+"/"+t)},j=e=>(j=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);U("initRandomDevice")})())(e),z={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:ie.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t=G.isAbs(i)}return(t?"/":"")+(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=z.resolve(e).substr(1),t=z.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),n=Math.min(i.length,o.length),a=n,s=0;s<n;s++)if(i[s]!==o[s]){a=s;break}var l=[];for(s=a;s<i.length;s++)l.push("..");return(l=l.concat(o.slice(a))).join("/")}},K="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,q=(e,t,r)=>{for(var i=t+r,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&K)return K.decode(e.subarray(t,o));for(var n="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&e[t++])<65536)n+=String.fromCharCode(a);else{var c=a-65536;n+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else n+=String.fromCharCode((31&a)<<6|s)}else n+=String.fromCharCode(a)}return n},Y=[],J=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++r):t+=3}return t},X=(e,t,r,i)=>{if(!(i>0))return 0;for(var o=r,n=r+i-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=n)break;t[r++]=s}else if(s<=2047){if(r+1>=n)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=n)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function Q(e,t,r){var i=r>0?r:J(e)+1,o=new Array(i),n=X(e,o,0,o.length);return t&&(o.length=n),o}var $={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){$.ttys[e]={input:[],output:[],ops:t},ie.registerDevice(e,$.stream_ops)},stream_ops:{open:function(e){var t=$.ttys[e.node.rdev];if(!t)throw new ie.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.get_char)throw new ie.ErrnoError(60);for(var n=0,a=0;a<i;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(l){throw new ie.ErrnoError(29)}if(void 0===s&&0===n)throw new ie.ErrnoError(6);if(null==s)break;n++,t[r+a]=s}return n&&(e.node.timestamp=Date.now()),n},write:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.put_char)throw new ie.ErrnoError(60);try{for(var n=0;n<i;n++)e.tty.ops.put_char(e.tty,t[r+n])}catch(a){throw new ie.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),n}},default_tty_ops:{get_char:function(e){return(()=>{if(!Y.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;Y=Q(e,!0)}return Y.shift()})()},put_char:function(e,t){null===t||10===t?(m(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(m(q(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(f(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(f(q(e.output,0)),e.output=[])}}},Z=e=>{U()},ee={ops_table:null,mount:e=>ee.createNode(null,"/",16895,0),createNode(e,t,r,i){if(ie.isBlkdev(r)||ie.isFIFO(r))throw new ie.ErrnoError(63);ee.ops_table||(ee.ops_table={dir:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,lookup:ee.node_ops.lookup,mknod:ee.node_ops.mknod,rename:ee.node_ops.rename,unlink:ee.node_ops.unlink,rmdir:ee.node_ops.rmdir,readdir:ee.node_ops.readdir,symlink:ee.node_ops.symlink},stream:{llseek:ee.stream_ops.llseek}},file:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:{llseek:ee.stream_ops.llseek,read:ee.stream_ops.read,write:ee.stream_ops.write,allocate:ee.stream_ops.allocate,mmap:ee.stream_ops.mmap,msync:ee.stream_ops.msync}},link:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,readlink:ee.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:ie.chrdev_stream_ops}});var o=ie.createNode(e,t,r,i);return ie.isDir(o.mode)?(o.node_ops=ee.ops_table.dir.node,o.stream_ops=ee.ops_table.dir.stream,o.contents={}):ie.isFile(o.mode)?(o.node_ops=ee.ops_table.file.node,o.stream_ops=ee.ops_table.file.stream,o.usedBytes=0,o.contents=null):ie.isLink(o.mode)?(o.node_ops=ee.ops_table.link.node,o.stream_ops=ee.ops_table.link.stream):ie.isChrdev(o.mode)&&(o.node_ops=ee.ops_table.chrdev.node,o.stream_ops=ee.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=ie.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ie.isDir(e.mode)?t.size=4096:ie.isFile(e.mode)?t.size=e.usedBytes:ie.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ee.resizeFileStorage(e,t.size)},lookup(e,t){throw ie.genericErrors[44]},mknod:(e,t,r,i)=>ee.createNode(e,t,r,i),rename(e,t,r){if(ie.isDir(e.mode)){var i;try{i=ie.lookupNode(t,r)}catch(n){}if(i)for(var o in i.contents)throw new ie.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=ie.lookupNode(e,t);for(var i in r.contents)throw new ie.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var i=ee.createNode(e,t,41471,0);return i.link=r,i},readlink(e){if(!ie.isLink(e.mode))throw new ie.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,i,o){var n=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,i);if(a>8&&n.subarray)t.set(n.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=n[o+s];return a},write(e,t,r,i,o,n){if(!i)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(n)return a.contents=t.subarray(r,r+i),a.usedBytes=i,i;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+i),a.usedBytes=i,i;if(o+i<=a.usedBytes)return a.contents.set(t.subarray(r,r+i),o),i}if(ee.expandFileStorage(a,o+i),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+i),o);else for(var s=0;s<i;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+i),i},llseek(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&ie.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new ie.ErrnoError(28);return i},allocate(e,t,r){ee.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,i,o){if(!ie.isFile(e.node.mode))throw new ie.ErrnoError(43);var n,a,s=e.node.contents;if(2&o||s.buffer!==_.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(n=Z()))throw new ie.ErrnoError(48);_.set(s,n)}else a=!1,n=s.byteOffset;return{ptr:n,allocated:a}},msync:(e,t,r,i,o)=>(ee.stream_ops.write(e,t,0,i,r,!1),0)}},te=i.preloadPlugins||[];function re(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ie={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=z.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ie.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),i=ie.root,o="/",n=0;n<r.length;n++){var a=n===r.length-1;if(a&&t.parent)break;if(i=ie.lookupNode(i,r[n]),o=G.join2(o,r[n]),ie.isMountpoint(i)&&(!a||a&&t.follow_mount)&&(i=i.mounted.root),!a||t.follow)for(var s=0;ie.isLink(i.mode);){var l=ie.readlink(o);if(o=z.resolve(G.dirname(o),l),i=ie.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ie.ErrnoError(32)}}return{path:o,node:i}},getPath:e=>{for(var t;;){if(ie.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%ie.nameTable.length},hashAddNode:e=>{var t=ie.hashName(e.parent.id,e.name);e.name_next=ie.nameTable[t],ie.nameTable[t]=e},hashRemoveNode:e=>{var t=ie.hashName(e.parent.id,e.name);if(ie.nameTable[t]===e)ie.nameTable[t]=e.name_next;else for(var r=ie.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=ie.mayLookup(e);if(r)throw new ie.ErrnoError(r,e);for(var i=ie.hashName(e.id,t),o=ie.nameTable[i];o;o=o.name_next){var n=o.name;if(o.parent.id===e.id&&n===t)return o}return ie.lookup(e,t)},createNode:(e,t,r,i)=>{var o=new ie.FSNode(e,t,r,i);return ie.hashAddNode(o),o},destroyNode:e=>{ie.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ie.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>ie.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,t)=>{try{return ie.lookupNode(e,t),20}catch(r){}return ie.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var i;try{i=ie.lookupNode(e,t)}catch(n){return n.errno}var o=ie.nodePermissions(e,"wx");if(o)return o;if(r){if(!ie.isDir(i.mode))return 54;if(ie.isRoot(i)||ie.getPath(i)===ie.cwd())return 10}else if(ie.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?ie.isLink(e.mode)?32:ie.isDir(e.mode)&&("r"!==ie.flagsToPermissionString(t)||512&t)?31:ie.nodePermissions(e,ie.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=ie.MAX_OPEN_FDS;e++)if(!ie.streams[e])return e;throw new ie.ErrnoError(33)},getStreamChecked:e=>{var t=ie.getStream(e);if(!t)throw new ie.ErrnoError(8);return t},getStream:e=>ie.streams[e],createStream:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ie.FSStream||(ie.FSStream=function(){this.shared={}},ie.FSStream.prototype={},Object.defineProperties(ie.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new ie.FSStream,e),-1==t&&(t=ie.nextfd()),e.fd=t,ie.streams[t]=e,e},closeStream:e=>{ie.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ie.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ie.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ie.devices[e]={stream_ops:t}},getDevice:e=>ie.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ie.syncFSRequests++,ie.syncFSRequests>1&&f("warning: ".concat(ie.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ie.getMounts(ie.root.mount),i=0;function o(e){return ie.syncFSRequests--,t(e)}function n(e){if(e)return n.errored?void 0:(n.errored=!0,o(e));++i>=r.length&&o(null)}r.forEach((t=>{if(!t.type.syncfs)return n(null);t.type.syncfs(t,e,n)}))},mount:(e,t,r)=>{var i,o="/"===r,n=!r;if(o&&ie.root)throw new ie.ErrnoError(10);if(!o&&!n){var a=ie.lookupPath(r,{follow_mount:!1});if(r=a.path,i=a.node,ie.isMountpoint(i))throw new ie.ErrnoError(10);if(!ie.isDir(i.mode))throw new ie.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},l=e.mount(s);return l.mount=s,s.root=l,o?ie.root=l:i&&(i.mounted=s,i.mount&&i.mount.mounts.push(s)),l},unmount:e=>{var t=ie.lookupPath(e,{follow_mount:!1});if(!ie.isMountpoint(t.node))throw new ie.ErrnoError(28);var r=t.node,i=r.mounted,o=ie.getMounts(i);Object.keys(ie.nameTable).forEach((e=>{for(var t=ie.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ie.destroyNode(t),t=r}})),r.mounted=null;var n=r.mount.mounts.indexOf(i);r.mount.mounts.splice(n,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var i=ie.lookupPath(e,{parent:!0}).node,o=G.basename(e);if(!o||"."===o||".."===o)throw new ie.ErrnoError(28);var n=ie.mayCreate(i,o);if(n)throw new ie.ErrnoError(n);if(!i.node_ops.mknod)throw new ie.ErrnoError(63);return i.node_ops.mknod(i,o,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ie.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ie.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var r=e.split("/"),i="",o=0;o<r.length;++o)if(r[o]){i+="/"+r[o];try{ie.mkdir(i,t)}catch(n){if(20!=n.errno)throw n}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,ie.mknod(e,t,r)),symlink:(e,t)=>{if(!z.resolve(e))throw new ie.ErrnoError(44);var r=ie.lookupPath(t,{parent:!0}).node;if(!r)throw new ie.ErrnoError(44);var i=G.basename(t),o=ie.mayCreate(r,i);if(o)throw new ie.ErrnoError(o);if(!r.node_ops.symlink)throw new ie.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename:(e,t)=>{var r,i,o=G.dirname(e),n=G.dirname(t),a=G.basename(e),s=G.basename(t);if(r=ie.lookupPath(e,{parent:!0}).node,i=ie.lookupPath(t,{parent:!0}).node,!r||!i)throw new ie.ErrnoError(44);if(r.mount!==i.mount)throw new ie.ErrnoError(75);var l,c=ie.lookupNode(r,a),d=z.relative(e,n);if("."!==d.charAt(0))throw new ie.ErrnoError(28);if("."!==(d=z.relative(t,o)).charAt(0))throw new ie.ErrnoError(55);try{l=ie.lookupNode(i,s)}catch(p){}if(c!==l){var u=ie.isDir(c.mode),h=ie.mayDelete(r,a,u);if(h)throw new ie.ErrnoError(h);if(h=l?ie.mayDelete(i,s,u):ie.mayCreate(i,s))throw new ie.ErrnoError(h);if(!r.node_ops.rename)throw new ie.ErrnoError(63);if(ie.isMountpoint(c)||l&&ie.isMountpoint(l))throw new ie.ErrnoError(10);if(i!==r&&(h=ie.nodePermissions(r,"w")))throw new ie.ErrnoError(h);ie.hashRemoveNode(c);try{r.node_ops.rename(c,i,s)}catch(p){throw p}finally{ie.hashAddNode(c)}}},rmdir:e=>{var t=ie.lookupPath(e,{parent:!0}).node,r=G.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!0);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.rmdir)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.rmdir(t,r),ie.destroyNode(i)},readdir:e=>{var t=ie.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ie.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ie.lookupPath(e,{parent:!0}).node;if(!t)throw new ie.ErrnoError(44);var r=G.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!1);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.unlink)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.unlink(t,r),ie.destroyNode(i)},readlink:e=>{var t=ie.lookupPath(e).node;if(!t)throw new ie.ErrnoError(44);if(!t.node_ops.readlink)throw new ie.ErrnoError(28);return z.resolve(ie.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var r=ie.lookupPath(e,{follow:!t}).node;if(!r)throw new ie.ErrnoError(44);if(!r.node_ops.getattr)throw new ie.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>ie.stat(e,!0),chmod:(e,t,r)=>{var i;if(!(i="string"==typeof e?ie.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ie.chmod(e,t,!0)},fchmod:(e,t)=>{var r=ie.getStreamChecked(e);ie.chmod(r.node,t)},chown:(e,t,r,i)=>{var o;if(!(o="string"==typeof e?ie.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,r)=>{ie.chown(e,t,r,!0)},fchown:(e,t,r)=>{var i=ie.getStreamChecked(e);ie.chown(i.node,t,r)},truncate:(e,t)=>{if(t<0)throw new ie.ErrnoError(28);var r;if(!(r="string"==typeof e?ie.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);if(ie.isDir(r.mode))throw new ie.ErrnoError(31);if(!ie.isFile(r.mode))throw new ie.ErrnoError(28);var i=ie.nodePermissions(r,"w");if(i)throw new ie.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var r=ie.getStreamChecked(e);if(!(2097155&r.flags))throw new ie.ErrnoError(28);ie.truncate(r.node,t)},utime:(e,t,r)=>{var i=ie.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new ie.ErrnoError(44);var o;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error("Unknown file open mode: ".concat(e));return t}(t):t)?4095&r|32768:0,"object"==typeof e)o=e;else{e=G.normalize(e);try{o=ie.lookupPath(e,{follow:!(131072&t)}).node}catch(l){}}var n=!1;if(64&t)if(o){if(128&t)throw new ie.ErrnoError(20)}else o=ie.mknod(e,r,0),n=!0;if(!o)throw new ie.ErrnoError(44);if(ie.isChrdev(o.mode)&&(t&=-513),65536&t&&!ie.isDir(o.mode))throw new ie.ErrnoError(54);if(!n){var a=ie.mayOpen(o,t);if(a)throw new ie.ErrnoError(a)}512&t&&!n&&ie.truncate(o,0),t&=-131713;var s=ie.createStream({node:o,path:ie.getPath(o),flags:t,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!i.logReadFiles||1&t||(ie.readFiles||(ie.readFiles={}),e in ie.readFiles||(ie.readFiles[e]=1)),s},close:e=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{ie.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ie.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ie.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,i,o)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(1==(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.read)throw new ie.ErrnoError(28);var n=void 0!==o;if(n){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,r,i,o);return n||(e.position+=a),a},write:(e,t,r,i,o,n)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.write)throw new ie.ErrnoError(28);e.seekable&&1024&e.flags&&ie.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,r,i,o,n);return a||(e.position+=s),s},allocate:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(t<0||r<=0)throw new ie.ErrnoError(28);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(!ie.isFile(e.node.mode)&&!ie.isDir(e.node.mode))throw new ie.ErrnoError(43);if(!e.stream_ops.allocate)throw new ie.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,i,o)=>{if(2&i&&!(2&o)&&2!=(2097155&e.flags))throw new ie.ErrnoError(2);if(1==(2097155&e.flags))throw new ie.ErrnoError(2);if(!e.stream_ops.mmap)throw new ie.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,o)},msync:(e,t,r,i,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(!e.stream_ops.ioctl)throw new ie.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'.concat(t.encoding,'"'));var r,i=ie.open(e,t.flags),o=ie.stat(e).size,n=new Uint8Array(o);return ie.read(i,n,0,o,0),"utf8"===t.encoding?r=q(n,0):"binary"===t.encoding&&(r=n),ie.close(i),r},writeFile:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var i=ie.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(J(t)+1),n=X(t,o,0,o.length);ie.write(i,o,0,n,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ie.write(i,t,0,t.byteLength,void 0,r.canOwn)}ie.close(i)},cwd:()=>ie.currentPath,chdir:e=>{var t=ie.lookupPath(e,{follow:!0});if(null===t.node)throw new ie.ErrnoError(44);if(!ie.isDir(t.node.mode))throw new ie.ErrnoError(54);var r=ie.nodePermissions(t.node,"x");if(r)throw new ie.ErrnoError(r);ie.currentPath=t.path},createDefaultDirectories:()=>{ie.mkdir("/tmp"),ie.mkdir("/home"),ie.mkdir("/home/web_user")},createDefaultDevices:()=>{ie.mkdir("/dev"),ie.registerDevice(ie.makedev(1,3),{read:()=>0,write:(e,t,r,i,o)=>i}),ie.mkdev("/dev/null",ie.makedev(1,3)),$.register(ie.makedev(5,0),$.default_tty_ops),$.register(ie.makedev(6,0),$.default_tty1_ops),ie.mkdev("/dev/tty",ie.makedev(5,0)),ie.mkdev("/dev/tty1",ie.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=j(e).byteLength),e[--t]);ie.createDevice("/dev","random",r),ie.createDevice("/dev","urandom",r),ie.mkdir("/dev/shm"),ie.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ie.mkdir("/proc");var e=ie.mkdir("/proc/self");ie.mkdir("/proc/self/fd"),ie.mount({mount:()=>{var t=ie.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var r=+t,i=ie.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{i.stdin?ie.createDevice("/dev","stdin",i.stdin):ie.symlink("/dev/tty","/dev/stdin"),i.stdout?ie.createDevice("/dev","stdout",null,i.stdout):ie.symlink("/dev/tty","/dev/stdout"),i.stderr?ie.createDevice("/dev","stderr",null,i.stderr):ie.symlink("/dev/tty1","/dev/stderr"),ie.open("/dev/stdin",0),ie.open("/dev/stdout",1),ie.open("/dev/stderr",1)},ensureErrnoError:()=>{ie.ErrnoError||(ie.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ie.ErrnoError.prototype=new Error,ie.ErrnoError.prototype.constructor=ie.ErrnoError,[44].forEach((e=>{ie.genericErrors[e]=new ie.ErrnoError(e),ie.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ie.ensureErrnoError(),ie.nameTable=new Array(4096),ie.mount(ee,{},"/"),ie.createDefaultDirectories(),ie.createDefaultDevices(),ie.createSpecialDirectories(),ie.filesystems={MEMFS:ee}},init:(e,t,r)=>{ie.init.initialized=!0,ie.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,ie.createStandardStreams()},quit:()=>{ie.init.initialized=!1;for(var e=0;e<ie.streams.length;e++){var t=ie.streams[e];t&&ie.close(t)}},findObject:(e,t)=>{var r=ie.analyzePath(e,t);return r.exists?r.object:null},analyzePath:(e,t)=>{try{e=(i=ie.lookupPath(e,{follow:!t})).path}catch(o){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=ie.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=G.basename(e),i=ie.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(o){r.error=o.errno}return r},createPath:(e,t,r,i)=>{e="string"==typeof e?e:ie.getPath(e);for(var o=t.split("/").reverse();o.length;){var n=o.pop();if(n){var a=G.join2(e,n);try{ie.mkdir(a)}catch(s){}e=a}}return a},createFile:(e,t,r,i,o)=>{var n=G.join2("string"==typeof e?e:ie.getPath(e),t),a=re(i,o);return ie.create(n,a)},createDataFile:(e,t,r,i,o,n)=>{var a=t;e&&(e="string"==typeof e?e:ie.getPath(e),a=t?G.join2(e,t):e);var s=re(i,o),l=ie.create(a,s);if(r){if("string"==typeof r){for(var c=new Array(r.length),d=0,u=r.length;d<u;++d)c[d]=r.charCodeAt(d);r=c}ie.chmod(l,146|s);var h=ie.open(l,577);ie.write(h,r,0,r.length,0,n),ie.close(h),ie.chmod(l,s)}return l},createDevice:(e,t,r,i)=>{var o=G.join2("string"==typeof e?e:ie.getPath(e),t),n=re(!!r,!!i);ie.createDevice.major||(ie.createDevice.major=64);var a=ie.makedev(ie.createDevice.major++,0);return ie.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{i&&i.buffer&&i.buffer.length&&i(10)},read:(e,t,i,o,n)=>{for(var a=0,s=0;s<o;s++){var l;try{l=r()}catch(c){throw new ie.ErrnoError(29)}if(void 0===l&&0===a)throw new ie.ErrnoError(6);if(null==l)break;a++,t[i+s]=l}return a&&(e.node.timestamp=Date.now()),a},write:(e,t,r,o,n)=>{for(var a=0;a<o;a++)try{i(t[r+a])}catch(s){throw new ie.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),ie.mkdev(o,n,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!o)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Q(o(e.url),!0),e.usedBytes=e.contents.length}catch(t){throw new ie.ErrnoError(29)}},createLazyFile:(e,t,r,i,o)=>{function n(){this.lengthKnown=!1,this.chunks=[]}if(n.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},n.prototype.setDataGetter=function(e){this.getter=e},n.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,n=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,a=1048576;o||(a=i);var s=this;s.setDataGetter((e=>{var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,i-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),i!==a&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):Q(o.responseText||"",!0)})(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!n&&i||(a=i=1,i=this.getter(0).length,a=i,m("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!d)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new n;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:r};var l=ie.createFile(e,t,s,i,o);s.contents?l.contents=s.contents:s.url&&(l.contents=null,l.url=s.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var c={};function u(e,t,r,i,o){var n=e.node.contents;if(o>=n.length)return 0;var a=Math.min(n.length-o,i);if(n.slice)for(var s=0;s<a;s++)t[r+s]=n[o+s];else for(s=0;s<a;s++)t[r+s]=n.get(o+s);return a}return Object.keys(l.stream_ops).forEach((e=>{var t=l.stream_ops[e];c[e]=function(){return ie.forceLoadFile(l),t.apply(null,arguments)}})),c.read=(e,t,r,i,o)=>(ie.forceLoadFile(l),u(e,t,r,i,o)),c.mmap=(e,t,r,i,o)=>{ie.forceLoadFile(l);var n=Z();if(!n)throw new ie.ErrnoError(48);return u(e,_,n,t,r),{ptr:n,allocated:!0}},l.stream_ops=c,l}},oe=(e,t)=>e?q(g,e,t):"",ne={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(G.isAbs(t))return t;var i;if(i=-100===e?ie.cwd():ne.getStreamFromFD(e).path,0==t.length){if(!r)throw new ie.ErrnoError(44);return i}return G.join2(i,t)},doStat:function(e,t,r){try{var i=e(t)}catch(s){if(s&&s.node&&G.normalize(t)!==G.normalize(ie.getPath(s.node)))return-54;throw s}y[r>>2]=i.dev,y[r+4>>2]=i.mode,T[r+8>>2]=i.nlink,y[r+12>>2]=i.uid,y[r+16>>2]=i.gid,y[r+20>>2]=i.rdev,C=[i.size>>>0,(w=i.size,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+24>>2]=C[0],y[r+28>>2]=C[1],y[r+32>>2]=4096,y[r+36>>2]=i.blocks;var o=i.atime.getTime(),n=i.mtime.getTime(),a=i.ctime.getTime();return C=[Math.floor(o/1e3)>>>0,(w=Math.floor(o/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+40>>2]=C[0],y[r+44>>2]=C[1],T[r+48>>2]=o%1e3*1e3,C=[Math.floor(n/1e3)>>>0,(w=Math.floor(n/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+56>>2]=C[0],y[r+60>>2]=C[1],T[r+64>>2]=n%1e3*1e3,C=[Math.floor(a/1e3)>>>0,(w=Math.floor(a/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+72>>2]=C[0],y[r+76>>2]=C[1],T[r+80>>2]=a%1e3*1e3,C=[i.ino>>>0,(w=i.ino,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+88>>2]=C[0],y[r+92>>2]=C[1],0},doMsync:function(e,t,r,i,o){if(!ie.isFile(t.node.mode))throw new ie.ErrnoError(43);if(2&i)return 0;var n=g.slice(e,e+r);ie.msync(t,n,o,r,i)},varargs:void 0,get:()=>(ne.varargs+=4,y[ne.varargs-4>>2]),getStr:e=>oe(e),getStreamFromFD:function(e){return ie.getStreamChecked(e)}};function ae(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: ".concat(e))}}var se=void 0;function le(e){for(var t="",r=e;g[r];)t+=se[g[r++]];return t}var ce={},de={},ue={},he=void 0;function pe(e){throw new he(e)}var me=void 0;function fe(e){throw new me(e)}function _e(e,t,r){function i(t){var i=r(t);i.length!==e.length&&fe("Mismatched type converter count");for(var o=0;o<e.length;++o)ge(e[o],i[o])}e.forEach((function(e){ue[e]=t}));var o=new Array(t.length),n=[],a=0;t.forEach(((e,t)=>{de.hasOwnProperty(e)?o[t]=de[e]:(n.push(e),ce.hasOwnProperty(e)||(ce[e]=[]),ce[e].push((()=>{o[t]=de[e],++a===n.length&&i(o)})))})),0===n.length&&i(o)}function ge(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i=t.name;if(e||pe('type "'.concat(i,'" must have a positive integer typeid pointer')),de.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;pe("Cannot register type '".concat(i,"' twice"))}if(de[e]=t,delete ue[e],ce.hasOwnProperty(e)){var o=ce[e];delete ce[e],o.forEach((e=>e()))}}(e,t,r)}function Ee(e){pe(e.$$.ptrType.registeredClass.name+" instance already deleted")}var ve=!1;function ye(e){}function Te(e){var t;e.count.value-=1,0===e.count.value&&((t=e).smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr))}function Ie(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var i=Ie(e,t,r.baseClass);return null===i?null:r.downcast(i)}var Ae={},Se=[];function Re(){for(;Se.length;){var e=Se.pop();e.$$.deleteScheduled=!1,e.delete()}}var be=void 0,we={};function Ce(e,t){return t.ptrType&&t.ptr||fe("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&fe("Both smartPtrType and smartPtr must be specified"),t.count={value:1},De(Object.create(e,{$$:{value:t}}))}var De=function(e){return"undefined"==typeof FinalizationRegistry?(De=e=>e,e):(ve=new FinalizationRegistry((e=>{Te(e.$$)})),ye=e=>ve.unregister(e),(De=e=>{var t=e.$$;if(t.smartPtr){var r={$$:t};ve.register(e,r,e)}return e})(e))};function Ne(){}function ke(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function Oe(e,t){return e=ke(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Me(e,t,r){if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||pe("Function '".concat(r,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}}function Le(e,t,r,i,o,n,a,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=o,this.getActualType=n,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function Pe(e,t,r){for(;t!==r;)t.upcast||pe("Expected null or instance of ".concat(r.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function xe(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Ue(e,t){var r;if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var i=t.$$.ptrType.registeredClass;if(r=Pe(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&pe("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,et.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:pe("Unsupporting sharing policy")}return r}function Ve(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Fe(e){return this.fromWireType(y[e>>2])}function Be(e,t,r,i,o,n,a,s,l,c,d){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=l,this.rawShare=c,this.rawDestructor=d,o||void 0!==t.baseClass?this.toWireType=Ue:i?(this.toWireType=xe,this.destructorFunction=null):(this.toWireType=Ve,this.destructorFunction=null)}var He=[],We=e=>{var t=He[e];return t||(e>=He.length&&(He.length=e+1),He[e]=t=S.get(e)),t};function Ge(e,t){var r,o,n,a=(e=le(e)).includes("j")?(r=e,o=t,n=[],function(){return n.length=0,Object.assign(n,arguments),((e,t,r)=>{return e.includes("j")?(o=t,n=r,a=i["dynCall_"+e],n&&n.length?a.apply(null,[o].concat(n)):a.call(null,o)):We(t).apply(null,r);var o,n,a})(r,o,n)}):We(t);return"function"!=typeof a&&pe("unknown function pointer with signature ".concat(e,": ").concat(t)),a}var je=void 0;function ze(e){var t=St(e),r=le(t);return It(t),r}function Ke(e,t){var r=[],i={};throw t.forEach((function e(t){i[t]||de[t]||(ue[t]?ue[t].forEach(e):(r.push(t),i[t]=!0))})),new je("".concat(e,": ")+r.map(ze).join([", "]))}function qe(e,t){for(var r=[],i=0;i<e;i++)r.push(T[t+4*i>>2]);return r}function Ye(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Je(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var r=Oe(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,o=e.apply(i,t);return o instanceof Object?o:i}function Xe(e,t,r,i,o,n){var a=t.length;a<2&&pe("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==t[1]&&null!==r,l=!1,c=1;c<t.length;++c)if(null!==t[c]&&void 0===t[c].destructorFunction){l=!0;break}var d="void"!==t[0].name,u="",h="";for(c=0;c<a-2;++c)u+=(0!==c?", ":"")+"arg"+c,h+=(0!==c?", ":"")+"arg"+c+"Wired";var p="\n return function ".concat(ke(e),"(").concat(u,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");l&&(p+="var destructors = [];\n");var m=l?"destructors":"null",f=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[pe,i,o,Ye,t[0],t[1]];for(s&&(p+="var thisWired = classParam.toWireType("+m+", this);\n"),c=0;c<a-2;++c)p+="var arg"+c+"Wired = argType"+c+".toWireType("+m+", arg"+c+"); // "+t[c+2].name+"\n",f.push("argType"+c),_.push(t[c+2]);if(s&&(h="thisWired"+(h.length>0?", ":"")+h),p+=(d||n?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",l)p+="runDestructors(destructors);\n";else for(c=s?1:2;c<t.length;++c){var g=1===c?"thisWired":"arg"+(c-2)+"Wired";null!==t[c].destructorFunction&&(p+=g+"_dtor("+g+"); // "+t[c].name+"\n",f.push(g+"_dtor"),_.push(t[c].destructorFunction))}return d&&(p+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),p+="}\n",f.push(p),Je(Function,f).apply(null,_)}function Qe(){this.allocated=[void 0],this.freelist=[]}var $e=new Qe;function Ze(e){e>=$e.reserved&&0==--$e.get(e).refcount&&$e.free(e)}var et={toValue:e=>(e||pe("Cannot use deleted val. handle = "+e),$e.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return $e.allocate({refcount:1,value:e})}}};function tt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function rt(e,t){switch(t){case 2:return function(e){return this.fromWireType(I[e>>2])};case 3:return function(e){return this.fromWireType(A[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function it(e,t,r){switch(t){case 0:return r?function(e){return _[e]}:function(e){return g[e]};case 1:return r?function(e){return E[e>>1]}:function(e){return v[e>>1]};case 2:return r?function(e){return y[e>>2]}:function(e){return T[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var ot,nt,at="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,st=(e,t)=>{for(var r=e,i=r>>1,o=i+t/2;!(i>=o)&&v[i];)++i;if((r=i<<1)-e>32&&at)return at.decode(g.subarray(e,r));for(var n="",a=0;!(a>=t/2);++a){var s=E[e+2*a>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},lt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,o=(r-=2)<2*e.length?r/2:e.length,n=0;n<o;++n){var a=e.charCodeAt(n);E[t>>1]=a,t+=2}return E[t>>1]=0,t-i},ct=e=>2*e.length,dt=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var o=y[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var n=o-65536;i+=String.fromCharCode(55296|n>>10,56320|1023&n)}else i+=String.fromCharCode(o)}return i},ut=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,o=i+r-4,n=0;n<e.length;++n){var a=e.charCodeAt(n);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++n)),y[t>>2]=a,(t+=4)+4>o)break}return y[t>>2]=0,t-i},ht=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t},pt={},mt=[],ft=[],_t={},gt=()=>{if(!gt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:l||"./this.program"};for(var t in _t)void 0===_t[t]?delete e[t]:e[t]=_t[t];var r=[];for(var t in e)r.push("".concat(t,"=").concat(e[t]));gt.strings=r}return gt.strings},Et=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ie.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i};Object.defineProperties(Et.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ie.isDir(this.mode)}},isDevice:{get:function(){return ie.isChrdev(this.mode)}}}),ie.FSNode=Et,ie.createPreloadedFile=function(e,t,r,i,o,a,s,l,c,d){var u=t?z.resolve(G.join2(e,t)):e;function h(r){function n(r){d&&d(),l||ie.createDataFile(e,t,r,i,o,c),a&&a(),x()}(function(e,t,r,i){"undefined"!=typeof Browser&&Browser.init();var o=!1;return te.forEach((function(n){o||n.canHandle(t)&&(n.handle(e,t,r,i),o=!0)})),o})(r,u,n,(()=>{s&&s(),x()}))||n(r)}P(),"string"==typeof r?((e,t,r,i)=>{var o=i?"":"al ".concat(e);n(e,(r=>{var i;i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),r||U(i),t(new Uint8Array(r)),o&&x()}),(t=>{if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&P()})(r,(e=>h(e)),s):h(r)},ie.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);se=e}(),he=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},me=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Ne.prototype.isAliasOf=function(e){if(!(this instanceof Ne&&e instanceof Ne))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,i=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)o=i.upcast(o),i=i.baseClass;return t===i&&r===o},Ne.prototype.clone=function(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=De(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},Ne.prototype.delete=function(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),ye(this),Te(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},Ne.prototype.isDeleted=function(){return!this.$$.ptr},Ne.prototype.deleteLater=function(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),Se.push(this),1===Se.length&&be&&be(Re),this.$$.deleteScheduled=!0,this},i.getInheritedInstanceCount=function(){return Object.keys(we).length},i.getLiveInheritedInstances=function(){var e=[];for(var t in we)we.hasOwnProperty(t)&&e.push(we[t]);return e},i.flushPendingDeletes=Re,i.setDelayFunction=function(e){be=e,Se.length&&be&&be(Re)},Be.prototype.getPointee=function(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},Be.prototype.destructor=function(e){this.rawDestructor&&this.rawDestructor(e)},Be.prototype.argPackAdvance=8,Be.prototype.readValueFromPointer=Fe,Be.prototype.deleteObject=function(e){null!==e&&e.delete()},Be.prototype.fromWireType=function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=function(e,t){return t=function(e,t){for(void 0===t&&pe("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),we[t]}(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function o(){return this.isSmartPointer?Ce(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):Ce(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var n,a=this.registeredClass.getActualType(t),s=Ae[a];if(!s)return o.call(this);n=this.isConst?s.constPointerType:s.pointerType;var l=Ie(t,this.registeredClass,n.registeredClass);return null===l?o.call(this):this.isSmartPointer?Ce(n.registeredClass.instancePrototype,{ptrType:n,ptr:l,smartPtrType:this,smartPtr:e}):Ce(n.registeredClass.instancePrototype,{ptrType:n,ptr:l})},je=i.UnboundTypeError=(ot=Error,(nt=Oe("UnboundTypeError",(function(e){this.name="UnboundTypeError",this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(ot.prototype),nt.prototype.constructor=nt,nt.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},nt),Object.assign(Qe.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),$e.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),$e.reserved=$e.allocated.length,i.count_emval_handles=function(){for(var e=0,t=$e.reserved;t<$e.allocated.length;++t)void 0!==$e.allocated[t]&&++e;return e};var vt,yt={p:function(e,t,r){throw new W(e).init(t,r),e},C:function(e,t,r){ne.varargs=r;try{var i=ne.getStreamFromFD(e);switch(t){case 0:return(o=ne.get())<0?-28:ie.createStream(i,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return i.flags;case 4:var o=ne.get();return i.flags|=o,0;case 5:return o=ne.get(),E[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return y[At()>>2]=28,-1}}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},w:function(e,t,r,i){ne.varargs=i;try{t=ne.getStr(t),t=ne.calculateAt(e,t);var o=i?ne.get():0;return ie.open(t,r,o).fd}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},t:function(e,t,r,i,o){},n:function(e,t,r,i,o){var n=ae(r);ge(e,{name:t=le(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:o},argPackAdvance:8,readValueFromPointer:function(e){var i;if(1===r)i=_;else if(2===r)i=E;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);i=y}return this.fromWireType(i[e>>n])},destructorFunction:null})},r:function(e,t,r,o,n,a,s,l,c,d,u,h,p){u=le(u),a=Ge(n,a),l&&(l=Ge(s,l)),d&&(d=Ge(c,d)),p=Ge(h,p);var m,f,_,g=ke(u);m=g,f=function(){Ke("Cannot construct ".concat(u," due to unbound types"),[o])},i.hasOwnProperty(m)?(pe("Cannot register public name '".concat(m,"' twice")),Me(i,m,m),i.hasOwnProperty(_)&&pe("Cannot register multiple overloads of a function with the same number of arguments (".concat(_,")!")),i[m].overloadTable[_]=f):i[m]=f,_e([e,t,r],o?[o]:[],(function(t){var r,n;t=t[0],n=o?(r=t.registeredClass).instancePrototype:Ne.prototype;var s=Oe(g,(function(){if(Object.getPrototypeOf(this)!==c)throw new he("Use 'new' to construct "+u);if(void 0===h.constructor_body)throw new he(u+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new he("Tried to invoke ctor of ".concat(u," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(h.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),c=Object.create(n,{constructor:{value:s}});s.prototype=c;var h=new Le(u,s,c,p,r,a,l,d);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m,f,_,E=new Be(u,h,!0,!1,!1),v=new Be(u+"*",h,!1,!1,!1),y=new Be(u+" const*",h,!1,!0,!1);return Ae[e]={pointerType:v,constPointerType:y},m=g,f=s,i.hasOwnProperty(m)||fe("Replacing nonexistant public symbol"),i[m].overloadTable,i[m]=f,i[m].argCount=_,[E,v,y]}))},q:function(e,t,r,i,o,n){var a=qe(t,r);o=Ge(i,o),_e([],[e],(function(e){var r="constructor ".concat((e=e[0]).name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new he("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=()=>{Ke("Cannot construct ".concat(e.name," due to unbound types"),a)},_e([],a,(function(i){return i.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Xe(r,i,null,o,n),[]})),[]}))},d:function(e,t,r,i,o,n,a,s,l){var c=qe(r,i);t=le(t),n=Ge(o,n),_e([],[e],(function(e){var i="".concat((e=e[0]).name,".").concat(t);function o(){Ke("Cannot call ".concat(i," due to unbound types"),c)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var d=e.registeredClass.instancePrototype,u=d[t];return void 0===u||void 0===u.overloadTable&&u.className!==e.name&&u.argCount===r-2?(o.argCount=r-2,o.className=e.name,d[t]=o):(Me(d,t,i),d[t].overloadTable[r-2]=o),_e([],c,(function(o){var s=Xe(i,o,e,n,a,l);return void 0===d[t].overloadTable?(s.argCount=r-2,d[t]=s):d[t].overloadTable[r-2]=s,[]})),[]}))},D:function(e,t){ge(e,{name:t=le(t),fromWireType:function(e){var t=et.toValue(e);return Ze(e),t},toWireType:function(e,t){return et.toHandle(t)},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:null})},k:function(e,t,r){var i=ae(r);ge(e,{name:t=le(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:rt(t,i),destructorFunction:null})},c:function(e,t,r,i,o){t=le(t);var n=ae(r),a=e=>e;if(0===i){var s=32-8*r;a=e=>e<<s>>>s}var l=t.includes("unsigned");ge(e,{name:t,fromWireType:a,toWireType:l?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:it(t,n,0!==i),destructorFunction:null})},b:function(e,t,r){var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=T,r=t[e>>=2],o=t[e+1];return new i(t.buffer,o,r)}ge(e,{name:r=le(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=le(t));ge(e,{name:t,fromWireType:function(e){var t,i=T[e>>2],o=e+4;if(r)for(var n=o,a=0;a<=i;++a){var s=o+a;if(a==i||0==g[s]){var l=oe(n,s-n);void 0===t?t=l:(t+="\0",t+=l),n=s+1}}else{var c=new Array(i);for(a=0;a<i;++a)c[a]=String.fromCharCode(g[o+a]);t=c.join("")}return It(e),t},toWireType:function(e,t){var i;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||pe("Cannot pass non-string to std::string"),i=r&&o?J(t):t.length;var n=Tt(4+i+1),a=n+4;if(T[n>>2]=i,r&&o)X(t,g,a,i+1);else if(o)for(var s=0;s<i;++s){var l=t.charCodeAt(s);l>255&&(It(a),pe("String has UTF-16 code units that do not fit in 8 bits")),g[a+s]=l}else for(s=0;s<i;++s)g[a+s]=t[s];return null!==e&&e.push(It,n),n},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},f:function(e,t,r){var i,o,n,a,s;r=le(r),2===t?(i=st,o=lt,a=ct,n=()=>v,s=1):4===t&&(i=dt,o=ut,a=ht,n=()=>T,s=2),ge(e,{name:r,fromWireType:function(e){for(var r,o=T[e>>2],a=n(),l=e+4,c=0;c<=o;++c){var d=e+4+c*t;if(c==o||0==a[d>>s]){var u=i(l,d-l);void 0===r?r=u:(r+="\0",r+=u),l=d+t}}return It(e),r},toWireType:function(e,i){"string"!=typeof i&&pe("Cannot pass non-string to C++ string type ".concat(r));var n=a(i),l=Tt(4+n+t);return T[l>>2]=n>>s,o(i,l+4,n+t),null!==e&&e.push(It,l),l},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},o:function(e,t){ge(e,{isVoid:!0,name:t=le(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,i){var o,n;(e=mt[e])(t=et.toValue(t),r=void 0===(n=pt[o=r])?le(o):n,null,i)},m:Ze,l:function(e,t){var r=function(e,t){for(var r,i,o,n=new Array(e),a=0;a<e;++a)n[a]=(r=T[t+4*a>>2],i="parameter "+a,void 0===(o=de[r])&&pe(i+" has unknown type "+ze(r)),o);return n}(e,t),i=r[0],o=i.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",n=ft[o];if(void 0!==n)return n;for(var a=["retType"],s=[i],l="",c=0;c<e-1;++c)l+=(0!==c?", ":"")+"arg"+c,a.push("argType"+c),s.push(r[1+c]);var d,u,h="return function "+ke("methodCaller_"+o)+"(handle, name, destructors, args) {\n",p=0;for(c=0;c<e-1;++c)h+=" var arg"+c+" = argType"+c+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=r[c+1].argPackAdvance;for(h+=" var rv = handle[name]("+l+");\n",c=0;c<e-1;++c)r[c+1].deleteObject&&(h+=" argType"+c+".deleteObject(arg"+c+");\n");return i.isVoid||(h+=" return retType.toWireType(destructors, rv);\n"),h+="};\n",a.push(h),d=Je(Function,a).apply(null,s),u=mt.length,mt.push(d),n=u,ft[o]=n,n},a:()=>{U("")},e:function(){return Date.now()},v:()=>g.length,A:(e,t,r)=>g.copyWithin(e,t,t+r),u:e=>{g.length,U("OOM")},y:(e,t)=>{var r=0;return gt().forEach((function(i,o){var n=t+r;T[e+4*o>>2]=n,((e,t)=>{for(var r=0;r<e.length;++r)_[0|t++]=e.charCodeAt(r);_[0|t]=0})(i,n),r+=i.length+1})),0},z:(e,t)=>{var r=gt();T[e>>2]=r.length;var i=0;return r.forEach((function(e){i+=e.length+1})),T[t>>2]=i,0},i:function(e){try{var t=ne.getStreamFromFD(e);return ie.close(t),0}catch(r){if(void 0===ie||"ErrnoError"!==r.name)throw r;return r.errno}},x:function(e,t){try{var r=ne.getStreamFromFD(e),i=r.tty?2:ie.isDir(r.mode)?3:ie.isLink(r.mode)?7:4;return _[0|t]=i,E[t+2>>1]=0,C=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+8>>2]=C[0],y[t+12>>2]=C[1],C=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+16>>2]=C[0],y[t+20>>2]=C[1],0}catch(o){if(void 0===ie||"ErrnoError"!==o.name)throw o;return o.errno}},B:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var l=ie.read(e,_,a,s,i);if(l<0)return-1;if(o+=l,l<s)break;void 0!==i&&(i+=l)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}},s:function(e,t,r,i,o){var n,a,s=(a=r)+2097152>>>0<4194305-!!(n=t)?(n>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var l=ne.getStreamFromFD(e);return ie.llseek(l,s,i),C=[l.position>>>0,(w=l.position,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[o>>2]=C[0],y[o+4>>2]=C[1],l.getdents&&0===s&&0===i&&(l.getdents=null),0}catch(c){if(void 0===ie||"ErrnoError"!==c.name)throw c;return c.errno}},h:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var l=ie.write(e,_,a,s,i);if(l<0)return-1;o+=l,void 0!==i&&(i+=l)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}}},Tt=(function(){var e,t,o,n,a={a:yt};function s(e,t){var r,o,n=e.exports;return r=(p=n).E.buffer,i.HEAP8=_=new Int8Array(r),i.HEAP16=E=new Int16Array(r),i.HEAP32=y=new Int32Array(r),i.HEAPU8=g=new Uint8Array(r),i.HEAPU16=v=new Uint16Array(r),i.HEAPU32=T=new Uint32Array(r),i.HEAPF32=I=new Float32Array(r),i.HEAPF64=A=new Float64Array(r),S=p.H,o=p.F,k.unshift(o),x(),n}if(P(),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(l){f("Module.instantiateWasm callback failed with error: "+l),r(l)}(e=h,t=R,o=a,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||V(t)||"function"!=typeof fetch?B(t,o,n):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,o).then(n,(function(e){return f("wasm streaming compile failed: "+e),f("falling back to ArrayBuffer instantiation"),B(t,o,n)}))))).catch(r)}(),e=>(Tt=p.G)(e)),It=e=>(It=p.I)(e),At=()=>(At=p.J)(),St=e=>(St=p.K)(e),Rt=(i.__embind_initialize_bindings=()=>(i.__embind_initialize_bindings=p.L)(),e=>(Rt=p.M)(e));function bt(){function e(){vt||(vt=!0,i.calledRun=!0,D||(i.noFSInit||ie.init.initialized||ie.init(),ie.ignorePermissions=!1,H(k),t(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),O.unshift(e);var e;H(O)}()))}M>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)e=i.preRun.shift(),N.unshift(e);var e;H(N)}(),M>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),e()}),1)):e()))}if(i.dynCall_jiji=(e,t,r,o,n)=>(i.dynCall_jiji=p.N)(e,t,r,o,n),i._ff_h264_cabac_tables=67061,L=function e(){vt||bt(),vt||(L=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return bt(),e.ready}),LH=MH,PH=class extends kH{constructor(e){super(LH,null!=e&&e.wasmPath?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}};(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0})();var xH=(e=>(e.ROOM_DESTROY="1",e.JOIN_START="21",e.JOIN_SCHEDULE_SUCCESS="22",e.JOIN_SIGNAL_CONNECTION_START="23",e.JOIN_SIGNAL_CONNECTION_END="24",e.JOIN_SEND_CMD="25",e.JOIN_RECEIVED_CMD_RES="26",e.JOIN_SUCCESS="27",e.JOIN_FAILED="28",e.LEAVE_START="51",e.LEAVE_SEND_CMD="52",e.LEAVE_SUCCESS="53",e.PUBLISH_START="61",e.SEND_FIRST_VIDEO_FRAME="62",e.PUBLISH_FAILED="63",e.SUBSCRIBE_START="81",e.SUBSCRIBE_SUCCESS="82",e.SUBSCRIBE_FAILED="84",e.UNSUBSCRIBE_SUCCESS="83",e.LOCAL_TRACK_CAPTURE_START="101",e.LOCAL_TRACK_CAPTURE_SUCCESS="102",e.LOCAL_TRACK_CAPTURE_FAILED="103",e.LOCAL_TRACK_PUBLISHED="104",e.LOCAL_TRACK_UNPUBLISHED="105",e.LOCAL_TRACK_REPLACED="106",e.SWITCH_DEVICE_SUCCESS="107",e.TRACK_MUTED="108",e.TRACK_UNMUTED="109",e.REMOTE_TRACK_SUBSCRIBED="110",e.REMOTE_TRACK_UNSUBSCRIBED="111",e.LOCAL_TRACK_RECAPTURE="112",e.LOCAL_AUDIO_STARTED="113",e.LOCAL_AUDIO_STOPPED="114",e.REMOTE_AUDIO_STARTED="115",e.REMOTE_AUDIO_STOPPED="116",e.PLAY_TRACK_START="151",e.PLAYER_STATE_CHANGED="152",e.VIDEO_LOADED_DATA="153",e.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",e.AUDIO_CONTEXT_LONG_SUSPENDED="155",e.REMOTE_VIDEO_PLAY_START="156",e.REMOTE_VIDEO_PLAY_FINISH="157",e.SIGNAL_CONNECTION_STATE_CHANGED="201",e.PEER_CONNECTION_STATE_CHANGED="202",e.SINGLE_CONNECTION_STAT="203",e.SPC_RECONNECTED="204",e.HEARTBEAT_REPORT="251",e.RECEIVED_PUBLISHED_USER_LIST="252",e.REMOTE_PUBLISH_STATE_CHANGED="253",e.AUDIO_LEVEL_INTERVAL="260",e.NETWORK_QUALITY="261",e.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",e.QUALITY_LIMITATION_CHANGED="263",e.LOG="264",e.AUDIO_PROCESSOR_DEBUG="265",e.SSO_SWITCH="266",e.SWITCH_ROOM_START="401",e.SWITCH_ROOM_SUCCESS="407",e.SWITCH_ROOM_FAILED="408",e))(xH||{}),UH="undefined"!=typeof importScripts,VH="undefined"!=typeof registerProcessor,FH="jssdk_log",BH=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(BH||{}),HH=Symbol(32),WH=Symbol(16),GH=Symbol(8),jH=class{constructor(e){this.g=e,this.consumed=0,e&&(this.need=e.next().value)}setG(e){this.g=e,this.demand(e.next().value,!0)}consume(){this.buffer&&this.consumed&&(this.buffer.copyWithin(0,this.consumed),this.buffer=this.buffer.subarray(0,this.buffer.length-this.consumed),this.consumed=0)}demand(e,t){return t&&this.consume(),this.need=e,this.flush()}read(e){return function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{l(i.next(e))}catch(t){n(t)}}function s(e){try{l(i.throw(e))}catch(t){n(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))}(this,void 0,void 0,(function*(){return this.lastReadPromise&&(yield this.lastReadPromise),this.lastReadPromise=new Promise(((t,r)=>{var i;this.reject=r,this.resolve=e=>{delete this.lastReadPromise,delete this.resolve,delete this.need,t(e)},this.demand(e,!0)||null===(i=this.pull)||void 0===i||i.call(this,e)}))}))}readU32(){return this.read(HH)}readU16(){return this.read(WH)}readU8(){return this.read(GH)}close(){var e;this.g&&this.g.return(),this.buffer&&this.buffer.subarray(0,0),null===(e=this.reject)||void 0===e||e.call(this,new Error("EOF")),delete this.lastReadPromise}flush(){if(!this.buffer||!this.need)return;let e=null,t=this.buffer.subarray(this.consumed),r=0,i=e=>t.length<(r=e);if("number"==typeof this.need){if(i(this.need))return;e=t.subarray(0,r)}else if(this.need===HH){if(i(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===WH){if(i(2))return;e=t[0]<<8|t[1]}else if(this.need===GH){if(i(1))return;e=t[0]}else if("buffer"in this.need){if("byteOffset"in this.need){if(i(this.need.byteLength-this.need.byteOffset))return;new Uint8Array(this.need.buffer,this.need.byteOffset).set(t.subarray(0,r)),e=this.need}else if(this.g)return void this.g.throw(new Error("Unsupported type"))}else{if(i(this.need.byteLength))return;new Uint8Array(this.need).set(t.subarray(0,r)),e=this.need}return this.consumed+=r,this.g?this.demand(this.g.next(e).value,!0):this.resolve&&this.resolve(e),e}write(e){if(e instanceof Uint8Array?this.malloc(e.length).set(e):"buffer"in e?this.malloc(e.byteLength).set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):this.malloc(e.byteLength).set(new Uint8Array(e)),!this.g&&!this.resolve)return new Promise((e=>this.pull=e));this.flush()}writeU32(e){this.malloc(4).set([e>>24&255,e>>16&255,e>>8&255,255&e]),this.flush()}writeU16(e){this.malloc(2).set([e>>8&255,255&e]),this.flush()}writeU8(e){this.malloc(1)[0]=e,this.flush()}malloc(e){if(this.buffer){let t=this.buffer.length,r=t+e;if(r<=this.buffer.buffer.byteLength-this.buffer.byteOffset)this.buffer=new Uint8Array(this.buffer.buffer,this.buffer.byteOffset,r);else{let e=new Uint8Array(r);e.set(this.buffer),this.buffer=e}return this.buffer.subarray(t,r)}return this.buffer=new Uint8Array(e),this.buffer}};jH.U32=HH,jH.U16=WH,jH.U8=GH;function zH(e){let t=new jH;for(;e>=128;)t.malloc(1)[0]=255&e|128,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function KH(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new jH,i=t<<3;switch(typeof e){case"boolean":let o=r.malloc(2);o[0]=i,o[1]=e?1:0;break;case"number":r.malloc(1)[0]=i,r.write(zH(e));break;case"string":r.malloc(1)[0]=2|i;let n=(new TextEncoder).encode(e);r.write(zH(n.length));let a=r.malloc(n.length);for(let e=0;e<n.length;e++)a[e]=n[e];break;case"object":let s=new jH;if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=KH(e[t],t+1);r&&s.write(r)}else{let t=1;for(let r in e){let i=KH(e[r],t++);i&&s.write(i)}}0===t?s.buffer&&r.write(s.buffer):(r.malloc(1)[0]=2|i,s.buffer&&(r.write(zH(s.buffer.length)),r.write(s.buffer)))}return r.buffer||new Uint8Array(0)}var qH=class{constructor(){gH(this,"buffer"),this.buffer=[]}get data(){return this.buffer}get length(){return this.buffer.length}writeInt32(e){this.buffer.push(e>>>24&255),this.buffer.push(e>>>16&255),this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeInt16(e){this.buffer.push(e>>>8&255),this.buffer.push(255&e)}writeByte(e){this.buffer.push(255&e)}writeBytes(e){for(let t=0;t<e.length;t++)this.buffer.push(e[t])}};function YH(e,t,r){e[r]=t>>>24&255,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=255&t}function JH(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function XH(e,t){return e[t]}function QH(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var $H=0,ZH=2654435769;function eW(e,t){let r=new qH,i=function(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"AVQualityReportSvc.C2S";return{version:arguments.length>4&&void 0!==arguments[4]?arguments[4]:2e3,encryption:arguments.length>5&&void 0!==arguments[5]?arguments[5]:2,d2:"",d2Len:0,uinType:arguments.length>6&&void 0!==arguments[6]?arguments[6]:30,uin:"",uinLen:0,reqHead:{seqNumber:r,appId:e,appidAtThird:new Uint8Array(0),a2:"",a2Len:0,serviceCmd:i,serviceCmdLen:0,cookie:"",cookieLen:0,imei:"",imeiLen:0,ksid:"",ksidLen:0,clientVersionInfo:"",clientVersionInfoLen:0},busiBuff:t}}(t,e,$H);$H=$H+1&2147483647,r.writeInt32(0),r.writeInt32(i.version),r.writeByte(i.encryption);let o=(new TextEncoder).encode(i.d2);r.writeInt32(o.length+4),o&&r.writeBytes(o),r.writeByte(i.uinType);let n=(new TextEncoder).encode(i.uin);r.writeInt32(n.length+4),n.length&&r.writeBytes(n);let a=new qH;a.writeInt32(0),a.writeInt32(i.reqHead.seqNumber),a.writeInt32(i.reqHead.appId),a.writeByte(i.reqHead.appId>>>24&255),a.writeByte(i.reqHead.appId>>>16&255),a.writeByte(i.reqHead.appId>>>8&255),a.writeByte(255&i.reqHead.appId);for(let E=4;E<16;E++)a.writeByte(0);let s=(new TextEncoder).encode(i.reqHead.a2);a.writeInt32(s.length+4),s.length&&a.writeBytes(s);let l=(new TextEncoder).encode(i.reqHead.serviceCmd);a.writeInt32(l.length+4),l.length&&a.writeBytes(l);let c=(new TextEncoder).encode(i.reqHead.cookie);a.writeInt32(c.length+4),c.length&&a.writeBytes(c);let d=(new TextEncoder).encode(i.reqHead.imei);a.writeInt32(d.length+4),d.length&&a.writeBytes(d);let u=(new TextEncoder).encode(i.reqHead.ksid);a.writeInt32(u.length+4),u.length&&a.writeBytes(u);let h=(new TextEncoder).encode(i.reqHead.clientVersionInfo);a.writeInt16(h.length+2),h.length&&a.writeBytes(h);let p=a.length;a.data[0]=p>>>24&255,a.data[1]=p>>>16&255,a.data[2]=p>>>8&255,a.data[3]=255&p,IG(e)&&(e=(new TextEncoder).encode(e)),a.writeInt32(e.length+4),e.length&&a.writeBytes(e);let m=new Uint8Array(a.data),f=null;1===i.encryption?f=(new TextEncoder).encode(i.uin):2===i.encryption&&(f=new Uint8Array(16)),f&&(m=function(e,t){let r=e.length,i=(r+1+2+7)%8;i&&(i=8-i);let o=new Uint8Array(r+1+2+7+i),n=0,a=new Uint8Array(8),s=new Uint8Array(8),l=new Uint8Array(8),c=0;a[0]=248&Math.floor(256*Math.random())|i,c=1;for(let u=0;u<i;u++)a[c]=255&Math.floor(256*Math.random()),c+=1;for(let u=0;u<2;)if(c<8&&(a[c]=255&Math.floor(256*Math.random()),c+=1,u+=1),8===c){tW(a,t,s,l,o,n),n+=8,c=0;for(let e=0;e<8;e++)l[e]=o[n-8+e]}let d=0;for(;d<r;)if(c<8&&(a[c]=e[d],c+=1,d+=1),8===c){tW(a,t,s,l,o,n),n+=8,c=0;for(let e=0;e<8;e++)l[e]=o[n-8+e]}for(let u=0;u<7;)if(c<8&&(a[c]=0,c+=1,u+=1),8===c){tW(a,t,s,l,o,n),n+=8,c=0;for(let e=0;e<8;e++)l[e]=o[n-8+e]}return o}(m,f)),r.writeBytes(m);let _=new Uint8Array(r.data),g=_.length;return _[0]=g>>>24&255,_[1]=g>>>16&255,_[2]=g>>>8&255,_[3]=255&g,_}function tW(e,t,r,i,o,n){for(let a=0;a<8;a++)e[a]^=i[a];!function(e,t,r,i){let o=JH(e,0),n=JH(e,4),a=[];for(let l=0;l<4;l++)a[l]=JH(t,4*l);let s=0;for(let l=0;l<16;l++)s+=ZH,s>>>=0,o+=(n<<4)+a[0]^n+s^(n>>>5)+a[1],o>>>=0,n+=(o<<4)+a[2]^o+s^(o>>>5)+a[3],n>>>=0;YH(r,o,i),YH(r,n,i+4)}(e,t,o,n);for(let a=0;a<8;a++)o[n+a]^=r[a];for(let a=0;a<8;a++)r[a]=e[a]}var rW=function(){return Date.now()+0},iW=function(){let e=new Date;return e.setTime(rW()),e.toLocaleString()};function oW(e){let t=function(e){try{let t={},r=0;t.totalLength=JH(e,r),r+=4,t.version=JH(e,r),r+=4,t.encryption=XH(e,r),r+=1,t.uinType=XH(e,r),r+=1,t.uinLength=JH(e,r),r+=4,t.uin=t.uinLength>4?QH(e,r,t.uinLength-4):"",r+=t.uinLength-4;let i=e.slice(r);if(2===t.encryption){e=function(e,t){let r=0,i=new Uint8Array(8).fill(0),o=nW(new Uint8Array(e.slice(0,8)),t),n=7&o[0],a=e.length-1-n-2-7,s=new Uint8Array(a),l=0,c=i,d=e.slice(0,8);r=8;let u=1;u+=n;for(let p=1;p<=2;)if(u<8)u++,p++;else if(8===u){let i=aW(e,r,c,d,o,t);c=i.ivPreCrypt,d=i.ivCurCrypt,o=i.debiBuf,r=i.bufPos,u=0}let h=a;for(;h>0;)if(u<8)s[l++]=o[u]^c[u],u++,h--;else if(8===u){let i=aW(e,r,c,d,o,t);c=i.ivPreCrypt,d=i.ivCurCrypt,o=i.debiBuf,r=i.bufPos,u=0}for(let p=1;p<=7;)if(u<8)o[u],c[u],u++,p++;else if(8===u){if(r>=e.length)break;let i=aW(e,r,c,d,o,t);if(!i.success)break;c=i.ivPreCrypt,d=i.ivCurCrypt,o=i.debiBuf,r=i.bufPos,u=0}return s}(i,new Uint8Array(16).fill(0)),t.decrypted=!0,r=0}else e=i,r=0;return t.rspHeadLength=JH(e,r),r+=4,t.seqNo=JH(e,r),r+=4,t.retCode=JH(e,r),r+=4,t.retStrLength=JH(e,r),r+=4,t.retStr=t.retStrLength?QH(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=JH(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?QH(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=JH(e,r),r+=4,t.cookie=t.cookieLength?QH(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=JH(e,r),r+=4,t.busiBuffLength=JH(e,r),r+=4,t.busiBuff=t.busiBuffLength?QH(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function nW(e,t){let r=e[0]<<24|e[1]<<16|e[2]<<8|e[3],i=e[4]<<24|e[5]<<16|e[6]<<8|e[7];r>>>=0,i>>>=0;let o=16*ZH>>>0;for(let n=0;n<16;n++)i-=(r<<4)+t[2]^r+o^(r>>>5)+t[3],i>>>=0,r-=(i<<4)+t[0]^i+o^(i>>>5)+t[1],r>>>=0,o-=ZH,o>>>=0;return new Uint8Array([r>>>24&255,r>>>16&255,r>>>8&255,255&r,i>>>24&255,i>>>16&255,i>>>8&255,255&i])}function aW(e,t,r,i,o,n){if(t+8>e.length)return{success:!1};let a=new Uint8Array(i),s=e.slice(t,t+8),l=new Uint8Array(8);for(let c=0;c<8;c++)l[c]=o[c]^s[c];return{success:!0,ivPreCrypt:a,ivCurCrypt:s,debiBuf:nW(l,n),bufPos:t+8}}var sW="undefined"!=typeof TextDecoder?new TextDecoder:void 0;var lW=Object.prototype.hasOwnProperty,cW=e=>"function"==typeof e,dW=e=>void 0===e;function uW(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)}(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(lW.call(e,t))return!1;return!0}return!1}var hW=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,l=new Array(e),c=0;c<e;c++)l[c]=arguments[c];let{retries:d=5,timeout:u=1e3}=r,h=0,p=-1,m=0,f=(e,r)=>nw(this,null,(function*(){let c=s||this;try{let r=yield t.apply(c,l);h>0&&a&&a.call(this,h),h=0,e(r)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,r(_)},a=()=>{2!==m&&h<(cW(d)?d():d)?(h++,m=1,cW(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,r)}),cW(u)?u(h):u)):(t(),cW(n)&&n.call(this,_))};cW(i)?i.call(this,{error:_,retry:a,reject:r,retryFuncArgs:l,retriedCount:h}):a()}}));return new Promise(f)}},pW=class e{constructor(e){gH(this,"_parentPath"),gH(this,"userId"),gH(this,"remoteUserId"),gH(this,"id"),gH(this,"sdkAppId"),gH(this,"type"),gH(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal=!(e=>"boolean"==typeof e)(e.isLocal)||e.isLocal,this.type=this.isLocal?"":e.type}getFullId(){return this._parentPath&&this.id?"".concat(this._parentPath,"-").concat(this.id):this._parentPath?this._parentPath:this.id}createChild(t){let r=new e({id:t.id,userId:dW(t.userId)?this.userId:t.userId,sdkAppId:dW(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:dW(t.type)?this.type:t.type,isLocal:dW(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:dW(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this.debug("bind logger parent: ".concat(e.id)),this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let r=this.isLocal?this.userId:this.remoteUserId,i=this.getFullId();t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(i).concat(r?"|".concat(r):"","]")),vG.log(e,t,dW(this.userId)||uW(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}},mW="undefined"==typeof navigator?"":navigator.userAgent,fW=e=>new RegExp(e,"i").test(mW),_W=e=>{if(fW(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=mW.match(t);if(r&&r[1])return r[1]}return""},gW=e=>{if(fW(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=mW.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},EW=/AppleWebKit\/([\d.]+)/i.exec(mW);EW&&parseFloat(EW[1]);var vW=fW("iPad"),yW="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&fW("Macintosh"),TW=fW("iPhone")&&!vW,IW=fW("iPod"),AW=TW||vW||IW||yW,SW=fW("Android");!function(){if(SW){let e=mW.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(e){let t=e[1]&&parseFloat(e[1]),r=e[2]&&parseFloat(e[2]);if(t&&r)return parseFloat("".concat(e[1],".").concat(e[2]));if(t)return t}}}();SW&&fW("webkit");var RW=fW("Firefox"),bW=_W("Firefox");gW("Firefox");var wW=fW("Edge"),CW=_W("Edge"),DW=fW("Edg"),NW=_W("Edg");gW("Edg");var kW=fW("SogouMobileBrowser"),OW=_W("SogouMobileBrowser"),MW=fW("MetaSr\\s"),LW=_W("MetaSr\\s"),PW=fW("TBS"),xW=_W("TBS"),UW=fW("XWEB"),VW=_W("XWEB");fW("MSIE\\s8\\.0");var FW=fW("MSIE\\/\\d+");!function(){if(FW){let e=/MSIE\s(\d+)\.\d/.exec(mW),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(mW)&&/rv:11.0/.test(mW)&&(t=11),t}}();var BW=fW("(micromessenger|webbrowser)"),HW=_W("MicroMessenger"),WW=!PW&&fW("MQQBrowser")&&fW("COVC"),GW=!PW&&fW("MQQBrowser")&&!fW("COVC"),jW=GW||WW?_W("MQQBrowser"):"",zW=!PW&&fW(" QQBrowser"),KW=_W(" QQBrowser"),qW=!PW&&fW("QQBrowserLite"),YW=_W("QQBrowserLite"),JW=!PW&&fW("MQBHD"),XW=_W("MQBHD");fW("Windows"),!AW&&fW("MAC OS X"),!SW&&fW("Linux"),fW("CrOS"),fW("MicroMessenger"),fW("UCBrowser"),fW("Electron");var QW=fW("MiuiBrowser"),$W=_W("MiuiBrowser"),ZW=fW("HuaweiBrowser");fW("Huawei")||fW("HUAWEI"),fW("Honor")||fW("HONOR");var eG=_W("HuaweiBrowser"),tG=fW("SamsungBrowser"),rG=_W("SamsungBrowser"),iG=fW("HeyTapBrowser"),oG=_W("HeyTapBrowser"),nG=fW("VivoBrowser"),aG=_W("VivoBrowser");fW("OpenHarmony"),_W("OpenHarmony");var sG=fW("CriOS"),lG=fW("Chrome"),cG=!wW&&!MW&&!kW&&!PW&&!UW&&!DW&&!zW&&!QW&&!ZW&&!tG&&!iG&&!nG&&lG,dG=fW("HeadlessChrome");gW("Chrome");var uG=_W("Chrome");gW("Electron");var hG=!lG&&!GW&&!WW&&!qW&&!JW&&fW("Safari"),pG=_W("Version");/Android.*(wv|.0.0.0)/.test(mW);var mG=(()=>{if(yW)return pG;if(AW){let e=mW.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();Number(mG.split(".")[0]),(()=>{let e=Number(mG.split(".")[0])})(),function(){let e=new Map([[RW,["Firefox",bW]],[DW,["Edg",NW]],[cG,["Chrome",uG]],[sG,["ChiOS",_W("CriOS")]],[hG&&!sG,["Safari",pG]],[PW,["TBS",xW]],[UW,["XWEB",VW]],[BW&&TW,["WeChat",HW]],[zW,["QQ(Win)",KW]],[GW,["QQ(Mobile)",jW]],[WW,["QQ(Mobile X5)",jW]],[qW,["QQ(Mac)",YW]],[JW,["QQ(iPad)",XW]],[QW,["MI",$W]],[ZW,["HW",eG]],[tG,["Samsung",rG]],[iG,["OPPO",oG]],[nG,["VIVO",aG]],[wW,["EDGE",CW]],[kW,["SogouMobile",OW]],[MW,["Sogou",LW]]]),t="unknown",r="unknown";e.has(!0)&&([t,r]=e.get(!0))}();var fG=new(fH(EH(),1).default),_G=xH,gG=new class{constructor(){gH(this,"enable",!1),gH(this,"ssoFailCount",0),fG.on("22",(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.sso&&fG.emit("266",{enable:!0})})),fG.on("266",(e=>{let{enable:t}=e;this.enable=t}))}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&fG.emit("266",{enable:!1})}},EG=class e{constructor(){gH(this,"_isEnableUploadLog",!0),gH(this,"_localJoinedUser",new Map),gH(this,"_queue",[]),gH(this,"_timeoutId",-1),gH(this,"_logLevel",1),gH(this,"_logLevelToUpload",2),UH||VH||(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){fG.on(_G.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&BH[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),fG.on(_G.JOIN_START,(e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),fG.on(_G.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:i,sdkAppId:o}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:o,logs:[r]})}));else if(IG(r.userId)&&AG(r.sdkAppId)){let{userId:t,sdkAppId:i}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:i,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return nw(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:r,sdkAppId:i,logs:o}=t[e],n={timestamp:iW(),sdkAppId:String(i),userId:r,version:"5.0.0",log:o.map((e=>e.log)).join("\n")},a=JSON.stringify(n),s=gG.enable?SG(n,2002,i):a;yield this.uploadLogWithRetry(s,i,s instanceof Uint8Array,a),o.forEach((e=>e.uploaded=!0))}}catch(cM){}let r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}))}uploadLogWithRetry(e,t,r,i){return hW({retryFunction:()=>function(e){let{url:t,body:r,method:i="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:n}).then((e=>e.clone().json().then((e=>({data:e})),(()=>e.arrayBuffer().then((e=>({data:oW(new Uint8Array(e))||(sW?sW.decode(e):e)}))))))).then(e,a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(uM){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,t,!0),s.send(r)}))}({url:yG(t,FH),body:e,timeout:5e3,priority:"low"}).then((e=>{r&&"ok"!==e.data&&(gG.handleUploadFailed(),this.uploadLogWithRetry(i,t,!1,i))})),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(rW()),"[".concat(function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)}(t),"] <").concat(BH[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){TG(BH[e])||(this._logLevel!==e&&this.info("setLogLevel",e),this._logLevel=e)}enableUploadLog(){this._isEnableUploadLog=!0}disableUploadLog(){this.warn("disableUploadLog"),this._isEnableUploadLog=!1}logChunkToString(e){if(IG(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(Sw){return""}}addLogToQueue(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,n={log:t.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:e,userId:i,sdkAppId:o,forAllJoinedClients:r};fG.emit(_G.LOG,{log:n}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(n)}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,i,o,n),t<this._logLevel)return;let s=(null==(a=BH[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[s]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...r):console[s](...r)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}createLogger(e){if(e.parent instanceof pW){let t=e,{parent:r}=t,i=((e,t)=>{var r={};for(var i in e)dH.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&lH)for(var i of lH(e))t.indexOf(i)<0&&uH.call(e,i)&&(r[i]=e[i]);return r})(t,["parent"]),o=new pW(i);return o.bindParent(r),o}return new pW(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;BH[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};gH(EG,"PRINT_LOG_TAG",!(AW||SW||dG));var vG=new EG,yG=function(e,t){let r;return r=(e=>Number(e)<14e8)(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com","".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(Math.floor(Math.random()*Jb(2,31)),"&sdkappid=").concat(e,"&cmdtype=").concat(t)},TG=e=>void 0===e,IG=e=>"string"==typeof e,AG=e=>"number"==typeof e;function SG(e,t,r,i){try{let o=function(e,t,r,i){let o={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:r};return TG(i)||(o=mH(pH({},o),{gzip:+i})),{uint32_sdkappid:0,uint64_from_uin:0,uint32_timestamp:0,uint32_seq:0,msg_common_info:{msg_device_info:{enum_device_type:0,str_device_brand:"",str_device_model:"",str_device_board:"",str_device_cpu_abi:""},msg_system_info:{enum_os_type:0,str_os_version:"",msg_network_info:0},msg_network_info:{enum_network_type:0}},msg_report_content:{uint32_type:t,bytes_report_data:JSON.stringify(o)}}}(e,t,r,i);return eW(KH(o),r)}catch(cM){return JSON.stringify(e)}}var RG=class e{constructor(e){this.core=e,gH(this,"contextMap",new Map),gH(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return null!=e&&e.track?"".concat(e.track.userId).concat(e.track.streamType):"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){var r;switch(e){case"wasm":let e=(null==(r=this.core.assetsPath)?void 0:r.replace(/\/+$/,""))||".";return new PH(mH(pH({},t),{wasmPath:"".concat(e,"/videodec.wasm")}));case"webCodecs":return new DH;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;var i;return(null==(i=this.decodeProcessorMap.get(r))?void 0:i({frame:t,track:r}))||t},type:3})}decode(e){let{pipe:t,take:r,subscribe:i}=this.core.rx;return o=>{let{frame:n,track:a}=o;if(a!==e.track||"empty"===n.type)return n;if(this.contextMap.has(a))return this.contextMap.get(a).decode(n);let s=this.core.room.videoManager.createDecodeContext(mH(pH({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,r(1),i((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:a})}))),this.contextMap.set(a,s),s.decode(n)}}stop(e){if(null!=e&&e.track){let t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;let r=(performance&&performance.now?Math.floor(performance.now()):Date.now())-e.startPerformanceTime,{renderFreezeTotal:i,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e),n="report health data: ".concat(e.track.userId," ").concat(e.track.streamType," ").concat(e.type,"+").concat(e.renderer," goodType:").concat(e.goodType," ").concat(e.failedReason?"failedReason: ".concat(e.failedReason):"");r&&(this.core.kvStatManager.addNumber({key:514850,value:Math.floor(i/r*100),split:1,max:100}),n+=" RENDER_FREEZE_RATE: ".concat(Math.floor(i/r*100),"%")),r&&(this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/r*100),split:1,max:100}),n+=" DATA_FREEZE_RATE: ".concat(Math.floor(o/r*100),"%")),e.inputFrameCount&&(this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100}),n+=" VIDEO_CONSUME_RENDER_RATE: ".concat(Math.floor(e.decodedFrameCount/e.inputFrameCount*100),"%")),this.core.log.info(n)}addKVReportBeforeExitRoom(e){let{room:t}=e;t===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){let t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(mH(pH({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){let r=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),i=this.core.room.badCaseDetector.getRenderFreezeDuration("".concat(e.userId,"_").concat(e.streamType)),o=0;return r&&r.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(o+=e.getDuration())})),{renderFreezeTotal:i,dataFreezeTotal:o}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};gH(RG,"Name","TRTCVideoDecoder");var bG=RG,wG=tw(aw());function CG(e){let{timesInSecond:t,maxSizeInSecond:r,getSize:i}=e;return DU(((e,o)=>{let n=new WeakMap;return YO.on(XO.ROOM_DESTROY,(e=>{let{room:t}=e;return n.delete(t)})),function(){let a=n.get(this);for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},n.set(this,a)),0===a.timestamp?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),i&&(a.totalSizeInSecond+=i(...l)),0!==a.timestamp&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=t||a.totalSizeInSecond>r))throw new mw({code:hw.INVALID_OPERATION,message:mL({key:dL.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=t,isSize:a.totalSizeInSecond>r,name:o,timesInSecond:t,maxSizeInSecond:r}})});a.callCountInSecond++,e.call(this,...l)}}))}var DG,NG=!0,kG={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},OG={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},MG=((DG=MG||{})[DG.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",DG[DG.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",DG[DG.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",DG[DG.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",DG[DG.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",DG[DG.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",DG[DG.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",DG[DG.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",DG[DG.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",DG[DG.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",DG[DG.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",DG[DG.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",DG[DG.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",DG[DG.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",DG[DG.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",DG[DG.INVALID_ROOM_ID_REQUIRED=5015]="INVALID_ROOM_ID_REQUIRED",DG[DG.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",DG[DG.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",DG[DG.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",DG[DG.INVALID_ROOM_ID_TYPE_MISMATCH=5019]="INVALID_ROOM_ID_TYPE_MISMATCH",DG[DG.INVALID_ROOM_ID_DUPLICATE=5020]="INVALID_ROOM_ID_DUPLICATE",DG[DG.INVALID_OPERATION=5100]="INVALID_OPERATION",DG[DG.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",DG[DG.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",DG[DG.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",DG[DG.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",DG[DG.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",DG[DG.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",DG[DG.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",DG[DG.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",DG[DG.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",DG[DG.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",DG[DG.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",DG[DG.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",DG[DG.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",DG[DG.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",DG[DG.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",DG[DG.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",DG[DG.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",DG[DG.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",DG[DG.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",DG[DG.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",DG[DG.DEVICE_ERROR=5300]="DEVICE_ERROR",DG[DG.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",DG[DG.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",DG[DG.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",DG[DG.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",DG[DG.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",DG[DG.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",DG[DG.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",DG[DG.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",DG[DG.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",DG[DG.NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX=5310]="NOT_SUPPORTED_MISMATCH_SAMPLE_RATE_IN_FIREFOX",DG[DG.SERVER_ERROR=5400]="SERVER_ERROR",DG[DG.NEED_TO_BUY=5401]="NEED_TO_BUY",DG[DG.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",DG[DG.OPERATION_FAILED=5500]="OPERATION_FAILED",DG[DG.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",DG[DG.REJOIN_FAILED=5502]="REJOIN_FAILED",DG[DG.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",DG[DG.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",DG[DG.VIDEO_ENCODE_FAILED=5505]="VIDEO_ENCODE_FAILED",DG[DG.AUDIO_ENCODE_FAILED=5506]="AUDIO_ENCODE_FAILED",DG[DG.VIDEO_DECODE_FAILED=5507]="VIDEO_DECODE_FAILED",DG[DG.AUDIO_DECODE_FAILED=5508]="AUDIO_DECODE_FAILED",DG[DG.OPERATION_ABORT=5998]="OPERATION_ABORT",DG[DG.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",DG);var LG=$b(Qb({},uL),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(WD(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(WD(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,value:i}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(i,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,value:i}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(i,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIRED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_ROOM_ID_TYPE_MISMATCH(e){let{key:t}=e;return"The type of target roomId must match the current roomId. Current room is using '".concat(t,"', but received '").concat("strRoomId"===t?"roomId":"strRoomId","'.")},INVALID_ROOM_ID_DUPLICATE(e){let{key:t}=e;return"the target '".concat(t,"' must not be the same as the current '").concat(t,"'.")},INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing ").concat(r.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone or screen share is not turned on.")},INVALID_BUFFER_EMPTY:e=>{let{key:t}=e;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:e=>{let{fnName:t}=e;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got device exception").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:r=PG(t),error:i}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(i?" error: ".concat(i.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:r}=e;return"'".concat(t,"' failed, reason: ").concat(null==r?void 0:r.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:r}=e;return"video context error ".concat(t," ").concat((null==r?void 0:r.name)||""," ").concat((null==r?void 0:r.message)||"")},SERVER_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got server error: ").concat(null==r?void 0:r.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:r}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(r)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' throw unknown exception").concat(r?", error: ".concat(r.toString(),"."):".")}});function PG(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var xG=class e extends Error{constructor(e){let{code:t,extraCode:r,message:i="",messageParams:o,fnName:n="",originError:a,data:s}=e;var l;let c;c=i||function(e){let t,{code:r,params:i,enableDocLink:o=!1}=e,a="",s=MG[r];try{t=LG[s]}catch(n){t=LG.UNKNOWN_ERROR}return GD(t)?a=t(i):zD(t)&&(a=t),i.fnName&&!a.includes(i.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(i.fnName,"()")),o&&(a+=" doc:"),a}({code:t===OG.SERVER_ERROR?t:r||t,params:Qb({fnName:n,error:a},o)}),super(c),iw(this,"name","RtcError"),iw(this,"code"),iw(this,"extraCode"),iw(this,"functionName"),iw(this,"message"),iw(this,"data"),iw(this,"handler"),iw(this,"originError"),this.name=MG[t],this.code=t,this.extraCode=r,this.functionName=n,this.originError=a,this.message=c,this.data=s,5302===this.extraCode&&null!=(l=this.originError)&&l.message.includes("system")&&(this.handler=()=>{let e=document.createElement("a");Wk?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):Gk&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(t,r,i){let o=t;if(t instanceof mw){let{stack:n}=t,a={code:OG.UNKNOWN_ERROR,fnName:r,originError:t};switch(t.getCode()){case hw.INVALID_PARAMETER:a.code=OG.INVALID_PARAMETER,a.message=t.message;break;case hw.INVALID_OPERATION:a.code=OG.INVALID_OPERATION;break;case hw.NOT_SUPPORTED:case hw.NOT_SUPPORTED_H264:a.code=OG.ENV_NOT_SUPPORTED,t.getCode()===hw.NOT_SUPPORTED_H264&&(a.extraCode=t.message.includes(uL.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case hw.JOIN_ROOM_FAILED:a.messageParams={fnParams:i};case hw.SERVER_TIMEOUT:case hw.SWITCH_ROLE_FAILED:case hw.SWITCH_ROOM_FAILED:a.code=OG.SERVER_ERROR,a.extraCode=t.getExtraCode();break;case hw.API_CALL_ABORTED:a.code=OG.OPERATION_ABORT;break;case hw.DEVICE_NOT_FOUND:case hw.DEVICE_AUTO_RECOVER_FAILED:case hw.INITIALIZE_FAILED:a.code=5300,t.name&&(a.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(t.name));break;case hw.VIDEO_ENCODE_FAILED:a.extraCode=5505;case hw.AUDIO_ENCODE_FAILED:a.extraCode=5506,a.code=OG.OPERATION_FAILED;break;case hw.UNKNOWN:break;default:a.code=OG.OPERATION_FAILED}o=new e(a),n&&(o.stack+=n.substr(n.indexOf("\n")))}else{if(t instanceof e)return t;o=new e({code:OG.UNKNOWN_ERROR,fnName:r,originError:t})}return o}};var UG=xG;function VG(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function FG(e){return e===kG.QOS_PREFERENCE_CLEAR?"detail":e===kG.QOS_PREFERENCE_SMOOTH?"motion":""}function BG(e,t){let r=t?$w:Qw;return qN(e)?Qb(Qb({},r),e):Xw[e]?Xw[e]:r}var HG={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{type:["string","object","boolean"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},WG={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},GG={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,r){if(zD(e)&&!document.getElementById(e))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5009,fnName:r,messageParams:{key:t}})}},jG={name:"userId",required:!0,type:"string"},zG={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{type:["string","object"],properties:{bitrate:{type:"number"},channelCount:{type:"number"}}},echoCancellation:{values:[!0,!1,"remote-only","all"]},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function KG(e,t){if(!e)throw new UG({code:OG.INVALID_OPERATION,extraCode:5101,fnName:t})}function qG(e,t,r){if(!e)throw new UG({code:OG.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:r}})}function YG(e,t,r){if(!(/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5013,fnName:t,messageParams:{key:r}})}function JG(e,t,r){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5012,fnName:t,messageParams:{key:r}})}function XG(e){var t;if(null==(t=null==e?void 0:e.option)||!t.small)return;if(!$L())return ZO.warn("small stream is not supported"),void delete e.option.small;let r=BG(e.option.profile),i=BG(e.option.small,!0);return((e,t)=>e.width*e.height>=t.width*t.height&&e.frameRate>=t.frameRate&&e.bitrate>=t.bitrate)(r,i)?void 0:(ZO.warn("small stream profile must be less than big stream profile. Big: ".concat(JSON.stringify(r),", Small: ").concat(JSON.stringify(i))),void delete e.option.small)}var QG={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,r){if(this._room.isJoined)throw new UG({code:OG.INVALID_OPERATION,extraCode:5104,fnName:r});if(e.roomId){if(zD(e.roomId))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5016,fnName:r,messageParams:{key:t}});YG(e.roomId,r,t)}else{if(!e.strRoomId)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5015,fnName:r});JG(e.strRoomId,r,t)}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:GG,mute:{type:["boolean","string"]},publish:{type:"boolean"},capture:{required:!1,type:"boolean"},option:HG},validate(e){var t,r;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&ML())throw new UG({code:OG.ENV_NOT_SUPPORTED,extraCode:5201});null!=(r=null==e?void 0:e.option)&&r.small&&XG(e)}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:$b(Qb({},GG),{required:!1}),publish:{type:"boolean"},capture:{required:!1,type:"boolean"},mute:{type:["boolean","string"]},option:HG},validate(e){var t;null!=(t=null==e?void 0:e.option)&&t.small&&XG(e)}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:zG},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&ML())throw new UG({code:OG.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:zG}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:GG,publish:{type:"boolean"},option:WG},validate(e,t,r,i,o){var n;if(null==(n=null==e?void 0:e.option)||!n.videoTrack){if(ML())throw new UG({code:OG.ENV_NOT_SUPPORTED,extraCode:5201});if(!BL())throw new UG({code:OG.ENV_NOT_SUPPORTED,fnName:r,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:GG,publish:{type:"boolean"},option:WG}},muteRemoteAudio:[jG,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[jG,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:GG,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){KG(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(qG(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new UG({code:OG.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:$b(Qb({},GG),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){KG(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(qG(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new UG({code:OG.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,r){if("*"!==e.userId&&jD(e.streamType))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5014,fnName:r})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,r){KG(this._room.isJoining||this._room.isJoined,r)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,r,i){if(!fP)throw new UG({code:OG.ENV_NOT_SUPPORTED,fnName:r,extraCode:5207});if(!this._room.enableSEI)throw new UG({code:OG.INVALID_OPERATION,fnName:r,extraCode:5108});if(e.byteLength>1e3)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:r});KG(this._room.isJoined,r)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(e,t,r){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new UG({code:OG.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:r})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(e,t,r,i){if(e.byteLength>1e3)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5017,fnName:r,messageParams:{key:t}})}}},validate(e,t,r){if(KG(this._room.isJoined,r),"live"===this._room.scene&&"audience"===this._room.role)throw new UG({code:OG.INVALID_OPERATION,extraCode:5107,fnName:r,messageParams:{key:t}})}},switchRoom:{name:"switchRoomConfig",type:"object",required:!0,validate(e,t,r){if(KG(this._room.isJoined,r),this._room.useStringRoomId&&e.strRoomId===this._room.roomId||!this._room.useStringRoomId&&e.roomId===Number(this._room.roomId))throw new UG({code:OG.INVALID_PARAMETER,extraCode:5020,fnName:r,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId&&this._room.useStringRoomId||!e.roomId&&e.strRoomId&&!this._room.useStringRoomId)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5019,fnName:r,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId)YG(e.roomId,r,t);else{if(!e.strRoomId)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5015,fnName:r});JG(e.strRoomId,r,t)}},properties:{roomId:{type:"number"},strRoomId:{type:"string"},privateMapKey:{type:"string"},userSig:{type:"string",required:!0},autoSubscribeCount:{type:"number",min:0,max:50}}}},$G={TRTC:QG},ZG=class extends Error{};function ej(e,t){let r=pN(e);for(let i=0;i<t.length;i++)hN(r[i],t[i]);return r}function tj(e){this._resolve=Promise.resolve(e)}function rj(e){this._reject=Promise.reject(e)}var ij=class e{constructor(t,r){this.instance=t,this.group=r,iw(this,"started",!1),iw(this,"ops",[]),iw(this,"startSame",(()=>!0)),iw(this,"mergeUpdate",ej);let i=e.instances.get(t);i?i.set(r,this):e.instances.set(t,new Map([[r,this]]))}static get(t,r){if(!r)return;let i=e.instances.get(t);return i&&i.get(r)||new e(t,r)}static gets(t,r){let i=e.instances.get(t),o=[];return i&&i.forEach(((e,t)=>{r.test(t)&&o.push(e)})),o}action(e,t,r){let i=t=>{var r;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(r=this.currentOp)||r.action(),t},o=t=>{var r,i;throw this.ops.shift(),0===e&&2===(null==(r=this.currentOp)?void 0:r.type)&&this.ops.shift().reject(new ZG("start failed")),null==(i=this.currentOp)||i.action(),t},n={type:e,action:()=>t(...n.args).then(i,o),args:r,resolve:tj,reject:rj};try{switch(this.state){case 1:if(0===e)throw new ZG("already started");break;case 4:if(2===e)throw new ZG("not started");break;default:return this.cacheOp(n)}}catch(lM){return Promise.reject(lM)}return this.ops.push(n),n.promise=t(...n.args).then(i,o)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new ZG("already start");break;case 3:switch(e.type){case 2:throw new ZG("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new ZG("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new ZG("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new ZG("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new ZG("start not allowed after update");case 0:throw new ZG("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new ZG("keep start")),new ZG("already start")}}e.promise=new Promise(((t,r)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(r):e.reject=r}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};iw(ij,"instances",new WeakMap);var oj=ij,nj=new WeakMap,aj=(e,t)=>{if(t instanceof ZG){let{stack:r}=t;t=new UG({code:OG.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),r&&(t.stack+=r.substr(r.indexOf("\n")))}throw t};function sj(e,t){return DU(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let s=oj.get(this,"string"==typeof e?e:e.call(this,...n));return s?(t&&(s.startSame=t.bind(this)),s.action(0,r.bind(this),n).catch(aj.bind(null,i))):r.apply(this,n)}))}function lj(e,t){let{merge:r,debounce:i}=t||{};return DU(((t,o)=>function(){for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];let l=oj.get(this,"string"==typeof e?e:e.call(this,...a));if(!l)return t.apply(this,a);if(r&&(l.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,a)){let{delay:e,getKey:r}=i;return new Promise(((i,n)=>{var s,c;let d=null==(s=nj.get(this))?void 0:s.get(r(...a));if(d){let{timeoutId:e,resolve:t}=d;clearTimeout(e),t()}let u=setTimeout((()=>{if(3===l.state||4===l.state)return i();l.action(2,t.bind(this),a).catch(aj.bind(null,o)).then(i,n)}),e);nj.has(this)?null==(c=nj.get(this))||c.set(r(...a),{timeoutId:u,resolve:i}):nj.set(this,new Map([[r(...a),{timeoutId:u,resolve:i}]]))}))}return l.action(2,t.bind(this),a).catch(aj.bind(null,o))}))}function cj(e){return DU(((t,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a="function"==typeof e?e.call(this,...o):e;if(a instanceof RegExp)return Promise.all(oj.gets(this,a).map((e=>e.action(3,(()=>Promise.resolve()),o)))).then((()=>t.call(this,...o)));let s=oj.get(this,a);return s?s.action(3,t.bind(this),o).catch(aj.bind(null,r)):t.apply(this,o)}))}function dj(){return function(e,t,r){return e.prototype[t]=function(){let e=this._log||console,r='"'.concat(t,'" is a static method. Use TRTC.').concat(t,"() instead. See: ").concat(Pw,"/en/TRTC.html#.").concat(t);e.warn(r)},r}}var uj={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame",PERMISSION_STATE_CHANGE:"permission-state-change",VIDEO_SIZE_CHANGED:"video-size-changed"},hj=new Set([uj.AUDIO_VOLUME,uj.AUDIO_FRAME,uj.NETWORK_QUALITY,uj.STATISTICS,uj.SEI_MESSAGE,uj.CUSTOM_MESSAGE,uj.LAYER_DATA]),pj={};ew(pj,{ScheduleRequestType:()=>Ij,getAbilityConfig:()=>Sj,getScheduleDomain:()=>Rj,isNeedToSchedule:()=>gj,scheduleProxy:()=>yj,sendScheduleRequest:()=>vj,setIsNeedToSchedule:()=>Ej,setScheduleProxy:()=>Tj});var mj=null,fj=0,_j=1728e5,gj=!0;function Ej(e){qD(e)&&e!==gj&&(gj=e,ZO.info("setIsNeedToSchedule ".concat(e)),e||(fj=Date.now()+_j))}function vj(e){return nw(this,arguments,(function(e){let{userId:t,sdkAppId:r,useStringRoomId:i,roomId:o,userSig:n,version:a,frameWorkType:s,role:l,latencyLevel:c}=e;return function*(){var e;if(!gj&&mj&&fj>Date.now())return{isCached:!0,result:mj};let d={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(r)),u.append("isStrGroupId",String(i)),u.append("groupId",String(o)),u.append("sdkVersion",a),u.append("userSig",String(n));let h=(null==(e=yield xO())?void 0:e.model)||FO();h&&u.append("model",h);let p=jO();p&&u.append("osString",p),l&&u.append("role",String(l)),c&&u.append("latencyLevel",String(c)),s&&u.append("frameWorkType",String(s));let m=oN(),f=yield function(e,t,r){return new Promise(((i,o)=>{let n=null;iN([wj((e=>t.count[0]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[0]=i.message,n||(a>=1&&(s[0]=Aj(r,"config",eC.MAIN,!0)),o())}))(Aj(r,"config",eC.MAIN),e,{get timeout(){return 1e3*BD(2+t.count[0])}}),wj((e=>t.count[1]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[1]=i.message,n||(a>=2&&(s[0]=Aj(r,"config",eC.BACKUP,!0)),o())}))(Aj(r,"config",eC.BACKUP),e,{get timeout(){return 1e3*BD(2+t.count[1])}})]).then((e=>{n=e,i(n)})).catch(o)}))}(u,d,r);f.config&&(f.config.loggerDomain&&Nw(f.config.loggerDomain),qD(f.config.scheduleCache)&&Ej(!f.config.scheduleCache)),d.delta=oN()-m;let _=function(e,t,r){let i={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),n=Aj(e,"config",eC.MAIN),a=Aj(e,"config",eC.BACKUP);for(let e of o)if(e.startTime>=r&&(e.name===n||e.name===a)&&e.transferSize>0){let r=e.name===n?eC.MAIN:eC.BACKUP,o=Math.round(e.duration),a=Math.round(e.domainLookupStart-e.startTime),s=e.redirectStart>0?Math.round(e.redirectEnd-e.redirectStart):0,l=e.fetchStart>0?Math.round(e.domainLookupStart-e.fetchStart):0,c=Math.round(e.domainLookupEnd-e.domainLookupStart),d=Math.round(e.requestStart-e.secureConnectionStart),u=Math.round(e.secureConnectionStart-e.connectStart),h=Math.round(e.responseStart-e.requestStart),p=Math.round(e.responseEnd-e.responseStart),m=[c,d,u,h,p];ex.uploadEvent({log:"stat-schedule-net:".concat(o,"(").concat(a,"(").concat(s,"->").concat(l,")->").concat(m.join("->"),") ").concat(r),userId:t}),i=$b(Qb({},i),{totalCost:o,local:a,dns:c,tcp:u,tls:d,request:h,response:p});break}}catch(n){ZO.error("getScheduleDetailCost error",n)}return i}(Number(r),t,m);return mj=f,{isCached:!1,result:f,detailCost:_}}catch(oM){let t=JD(oM)?oM[0]:oM,r=KD(t.code)?t.code:0,i="schedule failed".concat(t.message?": ".concat(t.message):""),o=new mw({code:hw.SCHEDULE_FAILED,extraCode:r,message:mL({key:dL.JOIN_ROOM_FAILED,data:{error:i,code:r}})});throw ZO.error(i,r),o}}()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(GC).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),YO.on("28",(()=>Ej(!0))),YO.on("63",(()=>Ej(!0))),YO.on("84",(()=>Ej(!0))),YO.on("201",(e=>{"RECONNECTING"===e.state&&Ej(!0)})),YO.on("202",(e=>{"RECONNECTING"===e.state&&Ej(!0)}));var yj={main:"",backup:""};function Tj(e){JD(e)?(yj.main=e[0],yj.backup=e[1]):yj.main=e}var Ij=(e=>(e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e))(Ij||{});function Aj(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eC.MAIN,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(yj[r]||Rj(e,r,i),"/api/v1/").concat(t)}function Sj(e,t,r){let i=Aj(e,t),o=Aj(e,t,eC.BACKUP),n=new URLSearchParams(r).toString(),a=fetch("".concat(i,"?").concat(n)).then((e=>e.json())),s=fetch("".concat(o,"?").concat(n)).then((e=>e.json()));return iN([a,s])}function Rj(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eC.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=AD(e)?i?r===eC.MAIN?GC.MAIN_OVERSEA_BACKUP:GC.BACKUP_OVERSEA:r===eC.MAIN?GC.MAIN_OVERSEA:GC.BACKUP_OVERSEA:r===eC.MAIN?GC.MAIN:GC.BACKUP,t}function bj(e,t,r){return new Promise(((i,o)=>{HN({url:e,body:t,timeout:r.timeout,priority:"high"}).then((e=>{0===e.data.code?i(e.data.data):o({code:e.data.code,message:e.data.msg})})).catch(o)}))}var wj=(e,t)=>YN({retryFunction:bj,settings:{retries:3,timeout:0},onError:t,onRetrying:e});var Cj=class{constructor(){iw(this,"_log"),this._log=ZO.createLogger({id:"fd"})}download(e,t){return nw(this,null,(function*(){let{type:r="blob"}=t||{};e=bN(e);try{let t,i=oN();if(t=GD(fetch)?yield this.downloadWithFetch(e,r):yield this.downloadWithXHR(e,r),!t||!t.data)throw new Error("data is empty");let o=oN()-i;return this._log.info("downloaded: ".concat(e,", return type: ").concat(r,", cost: ").concat(o,"ms")),RL.addSuccessEvent({key:522700,cost:oN()-i}),t.data}catch(cM){throw this._log.error("failed to download: ".concat(e,", error: ").concat(cM)),RL.addFailedEvent({key:522700,error:cM}),cM}}))}downloadWithFetch(e,t){return nw(this,null,(function*(){this._log.info("download with fetch: ".concat(e,", return type: ").concat(t));try{let r,i=yield fetch(e);if(!i.ok){let e=new Error("network response was not ok: ".concat(i.status));throw e.status=i.status,e}return r="arraybuffer"===t?yield i.arrayBuffer():yield i.blob(),{data:r}}catch(CC){throw CC}}))}downloadWithXHR(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise(((r,i)=>{let o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=t,o.onload=()=>{if(200===o.status||0===o.status&&o.response)r({data:o.response});else{let e=new Error("XHR failed, status: ".concat(o.status));e.status=o.status,i(e)}},o.onerror=i,o.send(null)}))}loadWasm(e,t){return nw(this,null,(function*(){this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t)));let r=oN(),i=null,o=null;if(GD(WebAssembly.instantiateStreaming)&&!(e=>e.startsWith("data:application/octet-stream;base64,"))(e)&&!(e=>e.startsWith("file://"))(e)&&GD(fetch))try{let r=fetch(e);i=(yield WebAssembly.instantiateStreaming(r,t)).instance}catch(Rw){o=Rw}if(!i)try{let r=yield this.download(e,{type:"arraybuffer"});i=(yield WebAssembly.instantiate(r,t)).instance}catch(Rw){o=Rw}if(i){let t=oN()-r;return this._log.info("loadedWasm ".concat(e,", cost: ").concat(t,"ms")),RL.addSuccessEvent({key:522701,cost:t}),i}throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),RL.addFailedEvent({key:522701,error:o}),o}))}loadScript(e){this._log.info("loadScript ".concat(e));let t=oN();return new Promise(((r,i)=>{let o=document.createElement("script");o.type="text/javascript",o.onload=()=>{this._log.info("loadedScript ".concat(e,", cost: ").concat(oN()-t,"ms")),RL.addSuccessEvent({key:522702,cost:oN()-t,split:1e3}),r(o)},o.onerror=t=>{this._log.error("failed to loadScript ".concat(e,", error: ").concat((null==t?void 0:t.message)||JSON.stringify(t))),RL.addFailedEvent({key:522702}),i(t)},o.crossOrigin="anonymous",o.src=e,document.head.append?document.head.append(o):document.getElementsByTagName("head")[0].appendChild(o)}))}};rw([rx({settings:{timeout:0,retries:3},onError(e,t,r){var i;404===(null==e?void 0:e.status)||null!=(i=null==e?void 0:e.message)&&i.includes("404")?(this._log.warn("download 404, stop retry"),r(e)):t()},onRetrying(e){this._log.warn("download retrying: ".concat(e))}})],Cj.prototype,"download",1),rw([rx({settings:{timeout:3e3,retries:3},onRetrying(e){this._log.warn("loadScript retrying: ".concat(e))}})],Cj.prototype,"loadScript",1);var Dj=new Cj;function Nj(e){var t=this;let{TRTC:r,room:i,errorModule:o,assetsPath:n}=e;return{TRTC:r,LocalMixVideoTrack:UB,LocalVideoTrack:dB,LocalScreenTrack:BB,room:i,assetsPath:n,fileDownloader:Dj,innerEmitter:YO,INNER_EVENT:XO,constants:yw,environment:XN,utils:uB,eventLogger:ex,log:this.room.getLogger(),loggerManager:ZO,errorModule:o,kvStatManager:RL,rtcDectection:rM,trtc:this,rx:VU,enums:iM,schedule:pj,getDevices:lU,initVisionTaskRegistry:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/mediapipe/vision.js";return nw(t,null,(function*(){window.VisionTaskRegistry||(yield Dj.loadScript("".concat(e,"/").concat(r).replace(/([^:]\/)\/+/g,"$1"))),yield(yield window.VisionTaskRegistry.getInstance(e)).preloadModels([window.VisionTaskType.ImageSegmenter])}))},audioContext:jx(),deviceDetector:aU,AudioPlayer:gU,showAutoPlayDialog:wx,Timer:YP,clearStarted:(e,t)=>{let r=e.getAlias(),i=oj.instances.get(this);if(i)if(t){let e=i.get(r+t);if(!e)return;e.started=!1}else i.forEach(((e,t)=>{t.startsWith(r)&&(e.started=!1)}))},startGetPCM:GB,createAudioNode:Qx,getNetworkTimeOffset:fw,validateSourceNode:()=>{var e;if(hk&&(null==(e=this.room.audioManager._localAudioPipline)||!e.source.node))throw new UG({code:OG.DEVICE_ERROR,extraCode:5310,message:"The audio processing plugin cannot be used due to the microphone's sampling rate is not 48KHz in Firefox. Please switch to another browser such as Chrome."})}}}var kj=new WeakMap;var Oj="5.14.2-wasm.3";function Mj(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return DU(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{Pj.call(this,t,o,r,this._name)}catch(cM){return Promise.reject(cM)}return e.apply(this,o)}))}function Lj(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return DU(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{Pj.call(this,t,o,r,this._name)}catch(cM){throw cM}return e.apply(this,o)}))}function Pj(e,t,r,i){if(JD(e))for(let o=0;o<e.length;o++)xj.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else xj.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}function xj(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;function a(e){return{code:OG.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:i,rule:t,value:r}}}if(jD(r)){if(t.required)throw new UG(a(5001));if(jD(t.defaultValue))return void(GD(t.validate)&&t.validate.call(this,r,i,o,n,this));r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),GD(t.type[i])&&r instanceof t.type[i]&&(e=!0),zD(t.type[i])&&WD(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new UG({code:OG.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:i,rule:{type:t.type.map((e=>ZD(e)?eN(e):zD(e)?e:WD(e)))},value:r}})}else if(!jD(t.type)&&WD(r)!==t.type)throw new UG(a(5002));if(!1===t.allowEmpty){let e=KD(r)&&(0===r||Number.isNaN(r)),t=zD(r)&&""===r.trim();if(e||t)throw new UG(a(5003))}if(t.notLessThanZero&&KD(r)&&r<0)throw new UG(a(5006));if(!jD(t.min)&&KD(r)&&r<t.min)throw new UG(a(5007));if(!jD(t.max)&&KD(r)&&r>t.max)throw new UG(a(5008));if(zD(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new UG(a(5004))}else if(GD(t.instanceOf)&&!(r instanceof t.instanceOf))throw new UG(a(5004));if(Array.isArray(t.values)&&!t.values.includes(r))throw new UG(a(5005));let{properties:s}=t;FD(s)&&YD(r)&&Object.keys(s).forEach((e=>{xj.call(this,{rule:s[e],value:r&&r[e],key:"".concat(e),fnName:o,className:n})}));let{arrayItem:l}=t;FD(l)&&JD(r)&&r.forEach(((e,t)=>{xj.call(this,{rule:l,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),GD(t.validate)&&t.validate.call(this,r,i,o,n,this)}function Uj(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=()=>"",replaceArg:r,getKVReportKey:i,ignoreLog:o,ignoreErrorLog:n}=e;return DU(((e,a)=>function(){for(var s=arguments.length,l=new Array(s),c=0;c<s;c++)l[c]=arguments[c];var d,u,h;function p(e,t,i){if(i&&i.includes(e))return"hided";if(r){let e=r(...l);if(l[e.argIndex]===t)return e.value}if(t===l||e in l)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(WD(t)):t instanceof MediaStreamTrack?wN(t):(JSON.stringify(t),t)}catch(fL){return"type:".concat(WD(t))}}let m=this._log||ZO;if(null!=o&&o(...l))return e.apply(this,l);l.length>0?m.info("".concat(a,"() ").concat(JSON.stringify(l,((e,t)=>p(e,t,["userSig","privateMapKey"]))))):m.info("".concat(a,"()"));let f=i?i(...l):EL[a],_=(null==n?void 0:n(...l))||!1;try{let r=e.apply(this,l),i=oN();if($D(r)){let e="".concat(a.includes("Plugin")?"".concat((null==(u=(d=l[0]).getName)?void 0:u.call(d))||""," "):" ");return r.then((r=>(m.info("".concat(a,"() success ").concat(e).concat(t.call(this,...l))),RL.addSuccessEvent({key:f,cost:oN()-i}),r))).catch((r=>{var i;let o=(r=UG.convertFrom.call(this,r,a,1===l.length?l[0]:l)).extraCode||r.code,n=null!=(i=r.message)&&i.includes(o)?"":" code:".concat(o);throw _||m.error("".concat(a,"() failed ").concat(e).concat(t.call(this,...l)," ").concat(r).concat(n," params: ").concat(JSON.stringify(l,p))),RL.addFailedEvent({key:f,error:r}),r}))}return RL.addSuccessEvent({key:f}),r}catch(pM){let t=(pM=UG.convertFrom.call(this,pM,a)).extraCode||pM.code,r=null!=(h=pM.message)&&h.includes(t)?"":" code:".concat(t);throw _||m.error("".concat(a,"() failed ").concat(pM).concat(r," params: ").concat(JSON.stringify(l,p))),RL.addFailedEvent({key:f,error:pM}),pM}}))}var Vj,Fj=e=>DU(((t,r)=>function(i,o){return nw(this,null,(function*(){let n=this._plugins.get(i);if(!n)throw this._log.error("plugin ".concat(String(i)," is not found")),new UG({code:OG.OPERATION_ABORT,message:"plugin ".concat(String(i)," is not found"),fnName:r});if(GD(n.constructor.isSupported)&&!n.constructor.isSupported())throw this._log.error("plugin ".concat(String(i)," is not supported")),new UG({code:OG.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(i)," is not supported"),extraCode:5210,fnName:r});return Pj.call(this,n.getValidateRule(e),[o],r,"TRTC"),t.call(this,n,o)}))})),Bj=0,Hj=class e{constructor(e){this.core=e,iw(this,"log"),iw(this,"customAudioReferenceMap",new Map),iw(this,"audioRefId",0),iw(this,"audioContext",jx()),iw(this,"localAudioWorkletNode"),iw(this,"screenAudioWorkletNode"),iw(this,"mixNode"),iw(this,"silentNode"),Bj+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(Bj)}),this.log.info("created id=".concat(this.getAlias()).concat(Bj)),this.installEvent()}static getStartValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,r,i,o){if(!e.room.audioManager.hasAudioTrack&&!e.room.audioManager.hasScreenAudioTrack)throw new UG({code:OG.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(e){return Vj||(Vj=this.doPreload(e)),Vj}doPreload(e){return nw(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),r=URL.createObjectURL(t);try{yield Nx(this.audioContext,r)}catch(cM){this.log.error("preload audioProcessor failed. ".concat(cM))}finally{URL.revokeObjectURL(r)}}))}getName(){return e.Name}getAlias(){return"ap"}getGroup(){return"ap"}getValidateRule(t){switch(t){case"start":return e.getStartValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return nw(this,null,(function*(){var t,r,i,o;let{room:n}=this.core,{sdkAppId:a,userId:s,userSig:l,assetsPath:c=this.core.assetsPath,audioReference:d,processLevel:u,enableDump:h,isLocalAudioNeedAudioProcess:p=!0,isScreenAudioNeedAudioProcess:m=!1}=e;if(this.core.room.audioManager.isLocalAudioNeedAudioProcess=p,this.core.room.audioManager.isScreenAudioNeedAudioProcess=m,!c)throw new UG({code:OG.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(c,"/audioProcessor-wasm.js")),p&&!this.localAudioWorkletNode){let{sign:e,status:t,timestamp:r}=yield this.getAuthData(a,s,l);this.localAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.localAudioWorkletNode,"localAudio",a,s,r,e,t,n)}if(m&&!this.screenAudioWorkletNode){let{sign:e,status:t,timestamp:r}=yield this.getAuthData(a,s,l);this.screenAudioWorkletNode=new AudioWorkletNode(this.audioContext,"trtc-audio-processor",{numberOfInputs:2,numberOfOutputs:1}),this.initWorkletNode(this.screenAudioWorkletNode,"screenAudio",a,s,r,e,t,n)}this.mixNode||(this.mixNode=this.audioContext.createGain(),this.mixNode.gain.value=1),this.silentNode||(this.silentNode=this.audioContext.createConstantSource(),this.silentNode.offset.setValueAtTime(0,this.audioContext.currentTime),this.silentNode.start()),null==(t=this.localAudioWorkletNode)||t.port.postMessage({type:"enable"}),null==(r=this.screenAudioWorkletNode)||r.port.postMessage({type:"enable"}),n.audioManager.addAudioProcessor(this.mixNode,this.silentNode,this.localAudioWorkletNode,this.screenAudioWorkletNode),jD(d)||d.forEach((e=>{this.customAudioReferenceMap.set(e,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:e,refId:"o-".concat(this.audioRefId++)})})),jD(u)||null==(i=this.localAudioWorkletNode)||i.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:u}}),jD(h)||null==(o=this.localAudioWorkletNode)||o.port.postMessage({type:"dump",data:{enable:h}})}))}update(e){return nw(this,null,(function*(){var t,r,i;let{audioReference:o,enableDump:n,processLevel:a}=e;jD(o)||(this.customAudioReferenceMap.forEach(((e,t)=>{this.customAudioReferenceMap.delete(t),this.core.room.audioManager.updateAudioReference({type:"remove",refId:e})})),o.forEach((e=>{this.customAudioReferenceMap.set(e,"o-".concat(this.audioRefId++)),this.core.room.audioManager.updateAudioReference({type:"add",audioReference:e,refId:"o-".concat(this.audioRefId++)})}))),jD(a)||null==(t=this.localAudioWorkletNode)||t.port.postMessage({type:"setConfig",data:{aecEnable:1,aecNlpLevel:a}}),jD(n)||(null==(r=this.localAudioWorkletNode)||r.port.postMessage({type:"dump",data:{enable:n}}),null==(i=this.screenAudioWorkletNode)||i.port.postMessage({type:"dump",data:{enable:n}}))}))}stop(){return nw(this,null,(function*(){var e,t;let{room:r}=this.core;null==(e=this.localAudioWorkletNode)||e.port.postMessage({type:"disable"}),null==(t=this.screenAudioWorkletNode)||t.port.postMessage({type:"disable"}),yield r.audioManager.removeAudioProcessor(this.localAudioWorkletNode,this.screenAudioWorkletNode)}))}destroy(){this.localAudioWorkletNode&&(this.localAudioWorkletNode.port.onmessage=null),this.screenAudioWorkletNode&&(this.screenAudioWorkletNode.port.onmessage=null),this.uninstallEvent()}getAuthData(e,t,r){return nw(this,null,(function*(){let i=String(Date.now()).slice(0,-3),{auth:o,sign:n,status:a,message:s}=yield function(e){return nw(this,arguments,(function(e){let{sdkAppId:t,userId:r,userSig:i,timestamp:o}=e;return function*(){let e="".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:eC.MAIN;return"https://".concat(yj[t]||Rj(e,t),"/api/v1/audioAiAuth")}(t),"?sdkAppId=").concat(t,"&userId=").concat(r,"&userSig=").concat(i,"&timestamp=").concat(o),n=yield fetch(e),{data:{errCode:a,errMsg:s,sign:l,status:c}}=yield n.json();if("1"===c)return{auth:!0,sign:l,status:c,message:s};let d=AD(t)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",u="Init RTCAudioProcessor failed.",h="";switch(a){case 1:h="Please check your params.";break;case 2:h="You need to buy packages. Refer to: ".concat(d);break;case 3:h="Server is invalid. Please contact our engineer. ";break;case 4:h="Your packages is not active. Refer to: ".concat(d);break;case 5:h="Your packages is expired. Refer to: ".concat(d);break;case 6:h="Your version is not supported."}return{auth:!1,status:c,message:s?"".concat(u," Reason: ").concat(s,". ").concat(h):"".concat(u,", ").concat(h)}}()}))}({sdkAppId:e,userSig:r,userId:t,timestamp:i});if(!o)throw this.log.info("audioProcessor: ".concat(t," auth result: ").concat(o,". Message: ").concat(s)),new UG({code:OG.INVALID_PARAMETER,message:s});return{sign:n,status:a,timestamp:i}}))}initWorkletNode(e,t,r,i,o,n,a,s){e.port.postMessage({type:"init",data:{sdkAppId:String(r),userId:i,timestamp:o,sign:n,status:a}}),e.port.onmessage=e=>{var r;let{data:i}=e;switch(i.type){case"cost":let e=(null==i?void 0:i.value)>10?"info":"debug";return void this.log[e]("".concat("localAudio"===t?"":"[".concat(t,"] "),"avg cost: ").concat(i.value," max: ").concat(null==i?void 0:i.max,"(").concat(Ew(new Date(null==i?void 0:i.maxCostTimestamp)),") hist: ").concat(null==(r=null==i?void 0:i.hist)?void 0:r.join(" ")));case"log":return void this.log[i.logLevel]("".concat("localAudio"===t?"":"[".concat(t,"] ")).concat(i.value));case"dump":return void YO.emit("265",{room:s,data:i.value,type:"localAudio"===t?"dump":"dump-screen-audio"})}}}handleLocalAudioStarted(e){return nw(this,null,(function*(){var t;if(this.hitTest(e.room)&&!0===(null==(t=this.core.room.scheduleResult.config)?void 0:t.audioProcessor))try{yield this.core.trtc.startPlugin("AudioProcessor",{sdkAppId:this.core.room.sdkAppId,userId:this.core.room.userId,userSig:this.core.room.userSig}),this.log.warn("audio processor auto start success")}catch(CC){this.log.warn("audio processor auto start failed, error: ".concat(CC))}}))}handleLocalAudioStopped(e){return nw(this,null,(function*(){var t;!this.hitTest(e.room)||!0!==(null==(t=this.core.room.scheduleResult.config)?void 0:t.audioProcessor)||(yield this.core.trtc.stopPlugin("AudioProcessor"))}))}installEvent(){this.core.innerEmitter.on("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.on("114",this.handleLocalAudioStopped,this)}uninstallEvent(){this.core.innerEmitter.off("104",this.handleLocalAudioStarted,this),this.core.innerEmitter.off("114",this.handleLocalAudioStopped,this)}hitTest(e){return e===this.core.room}};iw(Hj,"updateValidateRule",{type:"object"}),iw(Hj,"stopValidateRule",{type:"object"}),iw(Hj,"Name","AudioProcessor");var Wj=Hj;var Gj=0,jj=class{constructor(e,t){iw(this,"audioObjectURL"),iw(this,"player"),iw(this,"publisher"),iw(this,"mixInput"),this.mixInput=new Yx(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}updateSettings(e){this.player&&(jD(e.volume)||(this.volume=e.volume),jD(e.loop)||(this.loop=e.loop),jD(e.playbackRate)||(this.playbackRate=e.playbackRate))}updateListener(e){if(this.player){if(e.onDurationChange){let{onDurationChange:t}=e;this.player.ondurationchange=e=>{t(e.target.duration)}}if(e.onTimeUpdate){let t=e.onTimeUpdate,{player:r}=this;r.ontimeupdate=()=>{t(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}reload(e){return nw(this,null,(function*(){if(e.url){let t=yield Dj.download(e.url,{retries:3,type:"blob"});this.audioObjectURL&&URL.revokeObjectURL(this.audioObjectURL),this.audioObjectURL=URL.createObjectURL(t),this.player&&this.publisher?(this.player.src=this.audioObjectURL,this.publisher.src=this.audioObjectURL):(this.player=new Audio(this.audioObjectURL),this.player.crossOrigin="anonymous",this.publisher=new Audio(this.audioObjectURL),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher),this.updateListener(e),this.updateSettings(e))}else this.mixInput.replaceSource(e.track)}))}reset(){this.seek(0),this.mixInput.connect()}seek(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}play(){var e,t;return Promise.all([null==(e=this.player)?void 0:e.play(),null==(t=this.publisher)?void 0:t.play()])}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}set playbackRate(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}};function zj(e,t){if(t&&"function"!=typeof t)throw new UG({code:OG.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var Kj=class e{constructor(e){this.core=e,iw(this,"log"),iw(this,"mixedMusicMap",new Map),iw(this,"cacheMusicMap",new Map),Gj+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(Gj)}),this.log.info("created id=".concat(this.getAlias()).concat(Gj))}getName(){return e.Name}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return nw(this,null,(function*(){let{room:t}=this.core;this.core.validateSourceNode(),this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:r,url:i}=e;if(this.mixedMusicMap.has(r))return;let o=this.cacheMusicMap.get(r);o?e.url?o.reset():(o.mixInput.replaceSource(e.track),o.mixInput.connect()):(o=new jj(e,t.audioManager),this.cacheMusicMap.set(r,o)),o.updateListener(e),o.updateSettings(e);try{yield o.play()}catch(Rw){yield this.handleAutoPlayFailed(o,e,Rw)}this.mixedMusicMap.set(r,o),o.mixInput.source.node&&this.core.room.audioManager.updateAudioReference({type:"add",audioReference:o.mixInput.source.node,refId:"ax-".concat(r)}),this.log.info("start mix audio track ".concat(r," success.")),RL.addEnum({key:502700,value:3}),this.kvUpload(e)}))}handleAutoPlayFailed(e,t,r){return nw(this,null,(function*(){if("NotSupportedError"===r.name)this.log.error("play failed, try to reload source. error: ".concat(r)),yield e.reload(t),yield e.play();else{if("NotAllowedError"!==r.name)throw r;if(this.core.room.enableAutoPlayDialog){let t=()=>{var r;null==(r=e.play())||r.finally((()=>{YO.off("154",t,this)}))};YO.on("154",t,this),wx()}else this.core.trtc.emit(uj.AUTOPLAY_FAILED,{userId:"",mediaType:"audio",resume:()=>nw(this,null,(function*(){return e.play()}))})}}))}update(e){return nw(this,null,(function*(){let{id:t,operation:r,seekFrom:i,playbackRate:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let n=this.mixedMusicMap.get(t);n?(n.updateSettings(e),n.updateListener(e),jD(r)||n.setOperation(r),jD(i)||n.seek(i),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return nw(this,arguments,(function(e){var t=this;let{id:r}=e;return function*(){if(t.mixedMusicMap.has(r)){t.log.info("remove music source, music id: ".concat(r));let e=t.mixedMusicMap.get(r);null!=e&&e.mixInput.source.node&&t.core.room.audioManager.updateAudioReference({type:"remove",audioReference:e.mixInput.source.node,refId:"ax-".concat(r)}),null==e||e.stop(),t.mixedMusicMap.delete(r)}"*"===r&&t.destroyAllMusic()}()}))}kvUpload(e){let{track:t,loop:r,volume:i,playbackRate:o,operation:n,seekFrom:a,onTimeUpdate:s,onDurationChange:l,onEnded:c}=e;t&&RL.addCount({key:502009}),r&&RL.addCount({key:502001}),i&&RL.addCount({key:502002}),o&&RL.addCount({key:502003}),n&&RL.addCount({key:502004}),a&&RL.addCount({key:502005}),"function"!=typeof s&&RL.addCount({key:502007}),"function"!=typeof c&&RL.addCount({key:502008}),"function"!=typeof l&&RL.addCount({key:502006})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>{null!=e&&e.mixInput.track&&this.core.room.audioManager.updateAudioReference({type:"remove",audioReference:e.mixInput.track,refId:t}),this.stop({id:t})}))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};iw(Kj,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,r){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],i=["mp3","ogg","wav","flac"],o=t.split(".").pop(),n=i.indexOf(o)>=0,a=t.startsWith("blob"),s=t.startsWith("data");if(!(n||a||s))throw new UG({code:OG.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:r})}if(!e.url&&!e.track)throw new UG({code:OG.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});zj("onTimeUpdate",e.onTimeUpdate),zj("onEnded",e.onEnded),zj("onDurationChange",e.onDurationChange)}}),iw(Kj,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(e,t,r){zj("onTimeUpdate",e.onTimeUpdate),zj("onEnded",e.onEnded),zj("onDurationChange",e.onDurationChange)}}),iw(Kj,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),iw(Kj,"Name","AudioMixer");var qj,Yj=Kj,Jj=0,Xj=class e{constructor(e){this.core=e,iw(this,"log"),iw(this,"audioContext",jx()),iw(this,"workletNode"),iw(this,"config",{enableFarFieldReduce:!1,farFieldReduceThreshold:.5}),Jj+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(Jj)}),this.log.info("created id=".concat(this.getAlias()).concat(Jj))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0},mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}},validate(t,r,i,o){if(!e.room.audioManager.hasAudioTrack)throw new UG({code:OG.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(e){return qj||(qj=this.doPreload(e)),qj}doPreload(e){return nw(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),r=URL.createObjectURL(t);try{yield Nx(this.audioContext,r)}catch(cM){throw this.log.error("load worklet failed",cM),cM}finally{URL.revokeObjectURL(r)}}))}getName(){return e.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser"}getValidateRule(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return nw(this,null,(function*(){let{room:t,schedule:r}=this.core,{assetsPath:i=this.core.assetsPath}=e;if(!i)throw new UG({code:OG.INVALID_PARAMETER,message:"you need to deploy the assets of the npm package and set assetsPath param in TRTC.create()"});if(this.core.validateSourceNode(),yield this.preload("".concat(i,"/denoiser-wasm").concat(yP()?"":"-nosimd",".js")),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:i,sign:o,status:n,message:a}=yield function(e,t){return nw(this,arguments,(function(e,t){let{sdkAppId:r,userId:i,userSig:n,timestamp:a}=t;return function*(){try{let{data:{errCode:t,errMsg:o,sign:s,status:l}}=yield e.getAbilityConfig(r,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:r,userId:i,userSig:n,timestamp:a});if("1"===l)return{auth:!0,sign:s,status:l,message:o};let c=AD(r)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",d="Init RTCAIDenoiser failed.",u="";switch(t){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: ".concat(c);break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: ".concat(c);break;case 5:u="Your packages is expired. Refer to: ".concat(c);break;case 6:u="Your version is not supported."}return{auth:!1,status:l,message:o?"".concat(d," Reason: ").concat(o,". ").concat(u):"".concat(d,", ").concat(u)}}catch(o){return{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(o)}}}()}))}(r,$b(Qb({},e),{timestamp:t}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(a)),new UG({code:OG.INVALID_PARAMETER,message:a});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:o,status:n}}),this.workletNode.port.onmessage=e=>{var t;let{data:r}=e;if("cost"===r.type){let e=(null==r?void 0:r.max)>20?"warn":(null==r?void 0:r.max)>10?"info":"debug";this.log[e]("avg cost: ".concat(r.value," max: ").concat(null==r?void 0:r.max,"(").concat(Ew(new Date(null==r?void 0:r.maxCostTimestamp)),") hist: ").concat(null==(t=null==r?void 0:r.hist)?void 0:t.join(" ")))}else"log"===r.type&&this.log[r.logLevel]("".concat(r.value))}}this.updateConfig(e),this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(e){return nw(this,null,(function*(){this.updateConfig(e)}))}stop(){return nw(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}updateConfig(e){if(!this.workletNode)return;let t=!1;jD(e.mode)||(0===e.mode?this.config.enableFarFieldReduce=!1:1===e.mode&&(this.config.enableFarFieldReduce=!0),t=!0),jD(e.farFieldReduceThreshold)||(this.config.farFieldReduceThreshold=e.farFieldReduceThreshold,t=!0),t&&this.workletNode.port.postMessage({type:"setConfig",data:this.config})}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};iw(Xj,"updateValidateRule",{type:"object",properties:{mode:{type:"number",required:!1,values:[0,1]},farFieldReduceThreshold:{type:"number",required:!1,min:0,max:1}}}),iw(Xj,"stopValidateRule",{type:"object"}),iw(Xj,"Name","AIDenoiser");var Qj=Xj;var $j=tw(aw(),1),Zj=class extends $j.EventEmitter{constructor(){super(),iw(this,"observer"),iw(this,"state","nominal"),this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return nw(this,null,(function*(){if(!this.observer)try{"PressureObserver"in window&&!lk&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(Sw){ex.uploadEvent({log:"stat-pressure-detector-start-failed",error:Sw})}}))}onPressureChange(e){let t=this.stateNum,r=e[e.length-1];this.state=r.state,(this.stateNum>3||t>3)&&ZO.info("".concat(r.source,": ").concat(r.state)),this.emit("state-changed",{type:r.source,state:this.state})}destroy(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(CC){ex.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:CC})}}},ez=new Zj;function tz(e){let[t,r]=e,i=r.byteLength,o=parseInt(String(i/255),10),n=i%255,a=[];a.push(0,0,0,1,6,t);for(let l=0;l<o;l++)a.push(255);a.push(n);let s=new DataView(r);return a.push(...new Uint8Array(s.buffer)),a.push(128),new sB(new DataView(new Uint8Array(a).buffer),!0)}function rz(e){let{frame:t,seiMessageList:r}=e;if(!r||0===r.length||0===t.data.byteLength)return t;let i=9-function(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}(t.data);if(i<=0)return t;let o=r.splice(0,i).reverse().map(tz),n=o.reduce(((e,t)=>e+t.dataView.byteLength),0),a=new ArrayBuffer(n+t.data.byteLength),s=new DataView(a),l=new DataView(t.data),c=0;for(let d=0;d<o.length;d++)for(let e=0;e<o[d].dataView.byteLength;e++)s.setInt8(c++,o[d].dataView.getInt8(e));for(let d=0;d<t.data.byteLength;d++)s.setInt8(c++,l.getInt8(d));return t.data=a,t}function iz(e){let{frame:t,onSEI:r}=e;try{let e=new DataView(t.data);if(function(e){return"empty"===e.type||0===e.data.byteLength}(t)||!function(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}(e))return t;let i=[],o=0,n=-1,a=-1;for(let r=0;r<t.data.byteLength;r++){let s=e.getUint8(r);if(0===s)o++;else if(1===s){if(2===o||3===o){let s=r-o;if(-1===n?n=s:-1===a&&(a=s,i.push(new sB(new DataView(e.buffer.slice(n,a)))),n=s,a=-1),6!==e.getUint8(r+1)){t.data=e.buffer.slice(s);break}}o=0}else o=0}null==r||r(i.reverse())}catch(Sw){}return t}var oz=0,nz=class e{constructor(e){this.core=e,iw(this,"log"),iw(this,"_seiMessageList",[]),iw(this,"_smallSeiMessageList",[]),iw(this,"_subStreamSeiMessageList",[]),oz++,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(oz)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(oz)),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode(e){let{frame:t,mediaType:r}=e;try{return rz({frame:t,seiMessageList:8===r?this._smallSeiMessageList:2===r?this._subStreamSeiMessageList:this._seiMessageList})}catch(CC){this.log.warn(CC)}return t}decode(e){let{frame:t,track:r}=e;return iz({frame:t,onSEI:e=>{e.forEach((e=>{this.core.trtc.emit(uj.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}destroy(){this.log.debug("destroy"),this.stop(),delete this.core}getValidateRule(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:pP?this.encode:rz,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:pP?this.decode:iz,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update(e){let{buffer:t,options:r}=e;var i;let o=[r.seiPayloadType,t],n=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(o):(this._seiMessageList.push(o),n&&this._smallSeiMessageList.push(o)),null==(i=this.core.room.scriptTransformWorker)||i.postMessage({type:"sei",data:o,isMain:!r.toSubStream,small:n})}getName(){return e.Name}getAlias(){return"sei"}getGroup(){return"sei"}};iw(nz,"autoStart",!0),iw(nz,"Name","SEI");var az,sz=nz,lz=0,cz=class e{constructor(e){this.core=e,iw(this,"_core"),iw(this,"log"),iw(this,"dialog"),this._core=e,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(++lz)}),this.log.info("created")}getName(){return e.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}start(){return nw(this,null,(function*(){var e;!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_ENABLE_DEBUG_PLUGIN"))||(yield this.openDebugDiaLog())}))}update(e){return nw(this,arguments,(function(e){var t=this;let{visible:r}=e;return function*(){r?yield t.openDebugDiaLog():t.closeDebugDiaLog()}()}))}stop(){this.closeDebugDiaLog()}destroy(){this.stop()}openDebugDiaLog(){return nw(this,null,(function*(){var e;if(!this.dialog)try{if(az)yield az;else{let t=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(Iw,"/assets/debug-dialog.js");az=this._core.fileDownloader.loadScript(t),yield az}this.dialog=new TRTCDebugDialog(this._core,this.log),this._core.kvStatManager.addSuccessEvent({key:592705})}catch(Sw){this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(Sw))}}))}closeDebugDiaLog(){this.dialog&&(this.dialog.closeDialog(),this.dialog=null)}};iw(cz,"Name","Debug"),iw(cz,"autoStart",!0);var dz=cz,uz=e=>{switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},hz=class{constructor(e,t,r){iw(this,"trackDoneOB"),iw(this,"startOB"),iw(this,"stopOB"),iw(this,"inputFrameCount",0),iw(this,"decodedFrameCount",0),iw(this,"type","auto"),iw(this,"config"),iw(this,"decoder"),iw(this,"_decodeSink");let{kvStatManager:i,trtc:o}=e;this.config=r.config,this.trackDoneOB=DV(t,WP.INIT),this.stopOB=_V(),this.startOB=_V(),"auto"===r.type?this.type="webCodecs":this.type=r.type;let n=_V();JU(this.startOB,uV(0),CF((e=>{let r=this.pipe(t);return n.next("STARTING"),t.log.info("decoder type: ".concat(this.type)),JU(r,QV(this.stopOB),$F((()=>{}),(r=>{t.log.error(r),i.addFailedEvent({key:uz(this.type),error:r}),e>4?this.startOB.error(r):this.startOB.next(e+1)}))),JU(r,XV(1),qF(HV))})),QV(this.stopOB),$F((()=>{t.player.setOutput(),n.next("STARTED")}),(e=>{n.next("FAILED")}),(()=>{i.addSuccessEvent({key:uz(this.type)}),i.addSuccessEvent({key:504702})})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}close(e){this.stopOB.next(e)}pipe(e){return iV()((t=>nw(this,null,(function*(){this._decodeSink=t,t.defer((()=>{var e;null==(e=this.decoder)||e.close()}));let{type:r}=this;try{if("webCodecs"===r)this.decoder=new AudioDecoder({error:r=>{e.log.error(r),t.error(4)},output:r=>{this.decodedFrameCount++,t.next(r),e.player.write(r)}});this.decoder.configure(this.config)}catch(cM){e.log.error(cM),t.error("webCodecs"===r?2:6)}}))))}decodeFrame(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}},pz={type:"object"},mz=class e{constructor(e){this.core=e,iw(this,"log"),iw(this,"contextMap",new Map),iw(this,"decodeProcessorMap",new WeakMap),this.log=e.log.createChild({id:"".concat(this.getAlias())})}getAlias(){return e.Name}getGroup(e){return e.track.userId+e.track.streamType}getName(){return e.Name}getValidateRule(e){return pz}start(e){let{track:t}=e;this.decodeProcessorMap.set(t,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;return this.decodeProcessorMap.has(r)?this.decodeProcessorMap.get(r)({frame:t,track:r}):t},type:3})}decode(e){return t=>{let{frame:r,track:i}=t;if(i!==e.track)return r;if(this.contextMap.has(i))return this.contextMap.get(i).decodeFrame(r);let o=new hz(this.core,i,e);return JU(o.trackDoneOB,XV(1),$F((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:i})}))),this.contextMap.set(i,o),o.decodeFrame(r)}}stop(e){let{track:t}=e,r=this.contextMap.get(t);r&&(r.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}update(e){let t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new hz(this.core,e.track,e))}}};iw(mz,"Name","TRTCAudioDecoder");var fz=mz,_z=class{constructor(){iw(this,"log"),this.log=ZO.createLogger({id:"exp"})}call(e,t){return nw(this,null,(function*(){return GD(this[e])?this[e](t):Promise.reject(new mw({code:hw.INVALID_PARAMETER,message:mL({key:dL.API_NOT_EXIST,data:{name:e}})}))}))}enableAudioFrameEvent(e){return nw(this,null,(function*(){let{trtcInstance:t,enable:r,userId:i,sampleRate:o=48e3,channelCount:n=1,port:a}=e,{audioManager:s}=t.room,{getPCMAbortCtrlMap:l,audioFrameEventConfigMap:c}=s;if(c.set(i,{enable:r,sampleRate:o,channelCount:n,port:a}),r)if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isAvailable){if(l.get(e.userId))return;let r=s.getPCM((e=>{t.emit(uj.AUDIO_FRAME,e)}),e.userId);l.set(e.userId,r)}}));else{if(l.get(i))return;let e=s.getPCM((e=>{t.emit(uj.AUDIO_FRAME,e)}),i);l.set(i,e)}else if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isSubscribed){let{userId:t}=e,r=l.get(t);null==r||r.abort("disable"),l.delete(t)}}));else{let e=l.get(i);null==e||e.abort("disable"),l.delete(i)}}))}resumeRemotePlayer(e){return nw(this,null,(function*(){if("*"===e.userId){let t=[];return e.trtcInstance.room.remotePublishedUserMap.forEach((r=>{let{remoteAudioTrack:i,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=r;e.streamType?"main"===e.streamType?(i.isAvailable&&t.push(i.player.resume()),o.isAvailable&&t.push(o.player.resume())):n.isAvailable&&t.push(n.player.resume()):(i.isAvailable&&t.push(i.player.resume()),o.isAvailable&&t.push(o.player.resume()),n.isAvailable&&t.push(n.player.resume()))})),Promise.all(t)}let t=e.trtcInstance.room.remotePublishedUserMap.get(e.userId);if(t)return"main"===e.streamType?Promise.all([t.remoteAudioTrack.player.resume(),t.remoteVideoTrack.player.resume()]):t.remoteAuxiliaryTrack.player.resume()}))}pauseRemotePlayer(e){if("*"===e.userId)e.trtcInstance.room.remotePublishedUserMap.forEach((t=>{let{remoteAudioTrack:r,remoteVideoTrack:i,remoteAuxiliaryTrack:o}=t;e.streamType?"main"===e.streamType?(r.isAvailable&&r.player.pause(),i.isAvailable&&i.player.pause()):o.isAvailable&&o.player.pause():(r.isAvailable&&r.player.pause(),i.isAvailable&&i.player.pause(),o.isAvailable&&o.player.pause())}));else{let t=e.trtcInstance.room.remotePublishedUserMap.get(e.userId);t&&("main"===e.streamType?(t.remoteAudioTrack.player.pause(),t.remoteVideoTrack.player.pause()):t.remoteAuxiliaryTrack.player.pause())}}};rw([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return DU(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return eH.call(this,t,o,r,this._name),e.apply(this,o)}))}({name:"options",type:"object",required:!0,properties:{enable:{required:!0,type:"boolean"},userId:{required:!0,type:"string"},sampleRate:{type:"number",values:[8e3,16e3,32e3,44100,48e3]},channelCount:{type:"number",values:[1,2]},port:{type:"messageport"}}})],_z.prototype,"enableAudioFrameEvent",1);var gz=new _z,Ez=tw(aw(),1),vz=class extends Ez.EventEmitter{constructor(){super(),iw(this,"states",{}),iw(this,"permissionChangeHandler"),iw(this,"log"),this.log=ZO.createLogger({id:"pm"}),this.permissionChangeHandler=()=>{var e,t;this.emit("permission-state-change",{camera:null==(e=this.states.camera)?void 0:e.state,microphone:null==(t=this.states.microphone)?void 0:t.state})}}request(e){return nw(this,null,(function*(){if(this.log.info("request ".concat(e.join(", "))),0===e.length)return Promise.resolve();(yield navigator.mediaDevices.getUserMedia({video:e.includes("camera"),audio:e.includes("microphone")})).getTracks().forEach((e=>e.stop()))}))}get(e){return nw(this,null,(function*(){try{return this.states[e]||(this.states[e]=yield navigator.permissions.query({name:e}),this.states[e].addEventListener("change",this.permissionChangeHandler)),this.log.info("get ".concat(e," permission state: ").concat(this.states[e].state)),this.states[e].state}catch(CC){return this.log.error("get ".concat(e," permission failed, error: ").concat(CC instanceof Error?CC.message:CC)),null}}))}destroy(){Object.values(this.states).forEach((e=>{null==e||e.removeEventListener("change",this.permissionChangeHandler)})),this.states={}}},yz=new vz,Tz=0,Iz=new Set,Az=null;Aw(Oj),tM.checkStorage();var Sz=class e extends wG.EventEmitter{constructor(t,r){super(),iw(this,"_room"),iw(this,"_eventListened",new Set),iw(this,"_localVideoTrack",null),iw(this,"_localAudioTrack",null),iw(this,"_localScreenTrack",null),iw(this,"_localScreenAudioTrack",null),iw(this,"_localVideoConfig",null),iw(this,"_localScreenConfig",null),iw(this,"_localAudioConfig",null),iw(this,"_remoteVideoConfigMap",new Map),iw(this,"_remoteAudioConfigMap",new Map),iw(this,"_remoteAudioVolumeMap",new Map),iw(this,"_remoteAudioMuteMap",new Map),iw(this,"_mediaTrackMap",new WeakMap),iw(this,"_log",ZO.createLogger({id:"t".concat(++Tz)})),iw(this,"_plugins",new Map),iw(this,"_networkQuality",null),iw(this,"_speakerId"),iw(this,"enterRoomParams"),iw(this,"_enableAutoSwitchWhenRecapturing",!0),this._room=new t(Qb({logger:this._log,frameWorkType:e.frameWorkType},r)),this._room.videoDecodeFallbackType=r.videoDecodeFallback,qD(r.enableAutoSwitchWhenRecapturing)&&(this._enableAutoSwitchWhenRecapturing=r.enableAutoSwitchWhenRecapturing),this._log.info("create() ".concat(JSON.stringify(r,((e,t)=>"plugins"===e?t.map((e=>e.Name)):t)))),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}}),r.plugins&&r.plugins.forEach((e=>{this._use(e,r.assetsPath)})),this._use(Yj,r.assetsPath),this._use(Wj,r.assetsPath),this._use(Qj,r.assetsPath),this._use(fz,r.assetsPath),this._use(dz),r.enableSEI&&fP&&this._use(sz),this._room.on("audio-volume",(e=>{var t,i;!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*(null!=(t=this._localAudioTrack.getInternalAudioLevelAfter3A())?t:this._localAudioTrack.getAudioLevel())),floatVolume:null!=(i=this._localAudioTrack.getInternalAudioLevelAfter3A())?i:this._localAudioTrack.getInternalAudioLevel()}),1===r.volumeType&&e.forEach((e=>{var t;let r=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;r&&(e.volume=r.dbVolume)})),r.enableDbVolume&&e.forEach((e=>{var t;let r=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;r&&(e.volume=r.dbVolume)})),this.emit(uj.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{this._log.error(new UG({code:OG.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:r}=e;e.emit=function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{return r.apply(e,o)}catch(cM){let r=mL({key:dL.CATCH_HANDLER_ERROR,data:{name:t,event:o[0]},addDocLink:!1});return ZO.warn("".concat(r,"\n\n").concat(cM.stack)),!1}}})(this,"trtc")}static create(e){}static _create(t,r){!function(){var e;if(NG){NG=!1,5!==ZO.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(Pw,"/en/index.html")),console.info("* Changelog: ".concat(Pw,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),ZO.info("TRTC Web SDK Version:",Iw),DO||ZO.debug("Build Time:","2025-12-08 15:52:55");let t="UA: ".concat(navigator.userAgent," \nCPU core: ").concat(navigator.hardwareConcurrency,", GPU: ").concat(UO()),r=navigator.deviceMemory;r&&(t+=", minRAM: ".concat(r,"GB")),ZO.info(t),ZO.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),xO().then((e=>{e&&ZO.info(PO)}))}}();let i=new e(t,r||{});return Iz.add(i),i.__v_skip=!0,i}get room(){return this._room}_listenEvents(){$P(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(uj.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(uj.REMOTE_USER_EXIT,{userId:e})})).add("banned",(e=>{Ej(!0),this._exitRoom().finally((()=>{this.emit(uj.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().finally((()=>{this.emit(uj.ERROR,UG.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(uj.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e;let t=$b(Qb({},e),{uplinkRTT:Math.min(e.uplinkRTT,tD),downlinkRTT:Math.min(e.downlinkRTT,tD)});this.emit(uj.NETWORK_QUALITY,t)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{$P(t,t).add("player-state-changed",(r=>{let i=$b(Qb({},r),{userId:e.userId});t.kind===eC.VIDEO&&(i.streamType=VG(t.streamType)),this.emit(t.kind===eC.AUDIO?uj.AUDIO_PLAY_STATE_CHANGED:uj.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(e=>{e.getCode()===hw.PLAY_NOT_ALLOWED&&this.emit(uj.AUTOPLAY_FAILED,{userId:t.userId,mediaType:t.strMediaType,resume:()=>t.player.resume()})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{ZP(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:r}=e,{userId:i}=r,o=t.audioAvailable,n=t.videoAvailable,{audioAvailable:a,videoAvailable:s}=r;a||this._remoteAudioConfigMap.delete(i),s||this._removeRemoteVideoConfig(i,"main"),r.hasAuxiliary||this._removeRemoteVideoConfig(i,"sub"),n!==s&&(s?this._onVideoAvailable({userId:i,streamType:"main"}):this._onVideoUnavailable({userId:i,streamType:"main"}),this.emit(s?uj.REMOTE_VIDEO_AVAILABLE:uj.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==a&&(a?this._onAudioAvailable({userId:i}):this._onAudioUnavailable({userId:i,muteState:r}),this.emit(a?uj.REMOTE_AUDIO_AVAILABLE:uj.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),t.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?this._onVideoAvailable({userId:i,streamType:"sub"}):this._onVideoUnavailable({userId:i,streamType:"sub"}),this.emit(r.hasAuxiliary?uj.REMOTE_VIDEO_AVAILABLE:uj.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(e=>{this.emit(uj.SEI_MESSAGE,$b(Qb({},e),{streamType:VG(e.streamType)}))})).add("firewall-restriction",(()=>{this.emit(uj.ERROR,new UG({code:OG.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(e=>{var t,r,i,o,n,a,s;let l={2:"big",3:"small",7:"sub"},c={rtt:Math.min(e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(r=this._networkQuality)?void 0:r.uplinkRTT)||(null==(i=this._networkQuality)?void 0:i.downlinkRTT)||0,tD),upLoss:(null==(o=this._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(n=this._networkQuality)?void 0:n.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_level)||0)/JM},video:e.msg_up_stream_info.msg_video_status.filter((e=>l[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:l[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/JM,point2pointDelay:(e.msg_audio_status.uint32_audio_p2p_delay||0)+(e.msg_audio_status.uint32_audio_cache_ms||0),jitterBufferDelay:e.msg_audio_status.uint32_audio_cache_ms||0},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:l[e.uint32_video_stream_type],point2pointDelay:(e.uint32_video_p2p_delay||0)+(e.uint32_video_cache_ms||0),jitterBufferDelay:e.uint32_video_cache_ms||0,codec:e.uint32_video_codec})))})))};this.emit(uj.STATISTICS,c)})).add("custom-message",(e=>{this.emit(uj.CUSTOM_MESSAGE,e)})).add("layerData",(e=>this.emit(uj.LAYER_DATA,e))).add("first-video-frame",(e=>{this.emit(uj.FIRST_VIDEO_FRAME,$b(Qb({},e),{streamType:VG(e.streamType)}))})).add("audio-frame",(e=>{this.emit(uj.AUDIO_FRAME,e)})),$P(this,aU).add("audioInputAdded",(e=>{this.emit(uj.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(uj.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(uj.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(uj.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>nw(this,null,(function*(){if(this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),Az&&Az.deviceId===YC){let e=(yield hU()).find((e=>e.deviceId===YC));e&&Az.groupId!==e.groupId&&(Az=e,this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>nw(this,null,(function*(){this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield hU())[0];if(!t||!Az||Az.groupId===t.groupId)return;let r=Az.deviceId===e.deviceId,i=Az.deviceId===YC&&Az.deviceId===t.deviceId;(r||i)&&(Az=t,this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))})))),$P(this,yz).add("permission-state-change",(e=>{this.emit(uj.PERMISSION_STATE_CHANGE,e)})),this.room.enableSEI&&this.on(uj.SEI_MESSAGE,(e=>{var t;let r=null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteVideoTrack;r&&r.updateAlphaRenderInfo(e)}))}getNetworkTime(){return _w()}use(e){let t,r;return"plugin"in e?(t=e.plugin,r=e.assetsPath):t=e,"Chorus"===t.Name&&(this.room.enableChorus=!0),this._use(t,r)}_use(t,r){let i=this._plugins.get(t.Name);if(i)return this._log.warn("duplicate install plugin",t.Name),i;let o=new t(Nj.call(this,{TRTC:e,room:this._room,assetsPath:r,errorModule:{RtcError:UG,ErrorCode:OG,CoreErrorCode:hw,ErrorCodeDictionary:MG}}));return this._plugins.set(t.Name,o),o.__v_skip=!0,t.autoStart&&this.startPlugin(t.Name),o}enterRoom(t){return nw(this,null,(function*(){var r,i;this.enterRoomParams=t;let{scene:o="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:a=!0,autoReceiveVideo:s=!1}=t;t.proxy&&(this._room.setProxyServer(t.proxy),!zD(t.proxy)&&t.proxy.turnServer&&(null==(i=(r=this._room).setTurnServer)||i.call(r,t.proxy.turnServer,t.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=a,this._room.autoReceiveVideo=s,qD(t.preferHW)&&(this._room.preferHW=t.preferHW),t.playoutDelay&&(this._room.playoutDelay=t.playoutDelay),t.jitterBufferDelay&&(this._room.jitterBufferDelay=t.jitterBufferDelay);let l={sdkAppId:t.sdkAppId,userId:t.userId,userSig:t.userSig,privateMapKey:t.privateMapKey||null,latencyLevel:t.latencyLevel,role:"audience"===t.role?21:20,roomId:t.roomId||0,strRoomId:t.strRoomId||"",businessInfo:t.businessInfo||null,streamId:null,userDefineRecordId:t.userDefineRecordId||null,frameWorkType:t.frameWorkType,component:t.component,language:t.language,priority:t.priority,useVp8:t.useVp8,useH265:t.useH265||!1,keepAlive:t.keepAlive};t.strRoomId&&!t.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,yield this._room.join(l,o,e.frameWorkType),this._checkTrackToPublish(),ez.start()}))}exitRoom(){return nw(this,null,(function*(){return yield this._exitRoom()}))}switchRoom(e){return nw(this,null,(function*(){if(this.room.isSwitchRoomSupported())try{this._clearRemoteTracks(),yield this._room.switchRoom(e)}catch(CC){if(!(CC instanceof pw)||CC.code!==hw.API_CALL_TIMEOUT&&CC.code!==hw.SWITCH_ROOM_FAILED)throw CC;this._log.warn("switchRoom ".concat(CC.code===hw.API_CALL_TIMEOUT?"timeout":"failed",", fallback to exitRoom() and enterRoom()")),yield this._rejoinRoom(e)}else yield this._rejoinRoom(e)}))}_rejoinRoom(e){return nw(this,null,(function*(){yield this.exitRoom();let t=Qb(Qb({},this.enterRoomParams),e);yield this.enterRoom(t)}))}_clearRemoteTracks(){new Set([...this._remoteAudioConfigMap.keys(),...this._remoteAudioMuteMap.keys()]).forEach((e=>{this._stopRemoteAudio({userId:e}).catch((()=>{}))})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",r=e.split("_".concat(t))[0];r&&this._stopRemoteVideo({userId:r,streamType:t}).catch((()=>{}))})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),function(e){let t=kj.get(e);t&&(t.forEach((e=>clearTimeout(e))),kj.delete(e))}(this),this._room.remotePublishedUserMap.forEach((e=>{ZP(e.remoteAudioTrack),ZP(e.remoteVideoTrack),ZP(e.remoteAuxiliaryTrack)}))}switchRole(e,t){return nw(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){this._plugins.forEach((e=>{var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),ZP(this),this.removeAllListeners(),this._room.destroy(),Iz.delete(this),0===Iz.size&&ez.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),YO.off("102",this._onLocalTrackCaptured,this)}startLocalAudio(){return nw(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:r=!0,mute:i,option:o}=t,n=new aB(e._room.audioManager),a={},s={muted:!0};o&&(jD(o.microphoneId)?jD(o.audioTrack)||(a.customSource=o.audioTrack):a.deviceId=o.microphoneId,o&&KD(o.captureVolume)&&n.setCaptureVolume(o.captureVolume),jD(o.profile)||(zD(o.profile)?Jw[o.profile]&&n.setProfile(Jw[o.profile]):n.setProfile(o.profile)),KD(o.earMonitorVolume)&&(s.muted=!(o.earMonitorVolume>0),s.volume=o.earMonitorVolume),jD(o.echoCancellation)||(n.profile.echoCancellation=o.echoCancellation),jD(o.noiseSuppression)||(n.profile.noiseSuppression=o.noiseSuppression),jD(o.autoGainControl)||(n.profile.autoGainControl=o.autoGainControl),qD(e._enableAutoSwitchWhenRecapturing)&&(n.enableAutoSwitchWhenRecapturing=e._enableAutoSwitchWhenRecapturing)),n.on("5",(t=>{e.emit(uj.ERROR,new UG({code:OG.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),n.on("2",(t=>{e.emit(uj.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),n.on("4",(t=>{let r;t.error&&(r=UG.convertFrom(t.error)),e.emit(uj.PUBLISH_STATE_CHANGED,$b(Qb({},t),{error:r}))})),n.on("6",(()=>{})),e._listenOutputTrackChanged(n),e._speakerId&&n.setAudioOutput(e._speakerId),yield n.capture(a),jD(i)||n.setMute(i),$P(n,n).add("player-state-changed",(t=>{e.emit(uj.AUDIO_PLAY_STATE_CHANGED,$b(Qb({},t),{userId:""}))})),r&&e._room.isJoined&&e._room.publish(n).catch((()=>{})),e._localAudioTrack=n,e._localAudioConfig=$b(Qb({},t),{publish:r}),yield e._updateAudioPlayOption({playOption:s,track:n}),YO.emit("113",{userId:"",room:e.room})}()}))}updateLocalAudio(e){return nw(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:r,option:i}=e,o={};i&&(i.microphoneId?yield this._localAudioTrack.switchDevice(i.microphoneId):jD(i.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack)),jD(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),jD(i.earMonitorVolume)||(o.muted=!(i.earMonitorVolume>0),o.volume=i.earMonitorVolume),yield this._localAudioTrack.update3A(i)),this._room.isJoined&&!jD(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),jD(r)||this._localAudioTrack.setMute(r),yield this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),hN(this._localAudioConfig,e)}))}stopLocalAudio(){return nw(this,null,(function*(){this._localAudioTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),YO.emit("114",{userId:"",room:this.room}),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),ZP(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return nw(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null,capture:!0};return function*(){var r;if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:o=!0,capture:n=!0,mute:a,option:s}=t,l=new dB(e._room.videoManager),c={},d={};s&&(qD(s.avoidCropping)&&(l.avoidCropping=s.avoidCropping),s.cameraId?c.deviceId=s.cameraId:jD(s.useFrontCamera)?jD(s.videoTrack)||(c.customSource=s.videoTrack):c.facingMode=s.useFrontCamera?eC.FACING_MODE_USER:eC.FACING_MODE_ENVIRONMENT,jD(s.retryWhenExactFailed)||(c.retryWhenExactFailed=s.retryWhenExactFailed),s.qosPreference&&(c.contentHint=FG(s.qosPreference)),jD(s.profile)||(zD(s.profile)?Xw[s.profile]&&l.setProfile(Xw[s.profile]):l.setProfile(s.profile)),jD(s.fillMode)||(d.objectFit=s.fillMode),jD(s.mirror)||(d.mirror=s.mirror),jD(s.small)||(jD(s.smallMode)||(e._room.smallMode=s.smallMode),qD(s.small)&&!1===s.small?l.stopSmall():l.updateSmallConfig(BG(s.small,!0))),jD(s.rotation)||l.setRotation(s.rotation),qD(e._enableAutoSwitchWhenRecapturing)&&(l.enableAutoSwitchWhenRecapturing=e._enableAutoSwitchWhenRecapturing)),l.once("first-video-frame",(t=>{e.emit(uj.FIRST_VIDEO_FRAME,$b(Qb({},t),{streamType:VG(t.streamType)}))})),l.on("5",(t=>{e.emit(uj.ERROR,new UG({code:OG.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),l.on("2",(t=>{e.emit(uj.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),l.on("4",(t=>{let r;t.error&&(r=UG.convertFrom(t.error)),e.emit(uj.PUBLISH_STATE_CHANGED,$b(Qb({},t),{error:r}))})),l.on("6",(()=>{})),e._listenOutputTrackChanged(l),n?yield l.capture(c):null==(r=l.manager)||r.changeInput(l),jD(a)||(yield l.setMute(a)),$P(l,l).add("player-state-changed",(t=>{e.emit(uj.VIDEO_PLAY_STATE_CHANGED,$b(Qb({},t),{userId:"",streamType:"main"}))})).add("video-size-changed",(t=>{e.emit(uj.VIDEO_SIZE_CHANGED,$b(Qb({},t),{streamType:VG(t.streamType)}))})),o&&e._room.isJoined&&e._room.publish(l).catch((()=>{})),e._localVideoTrack=l,e._localVideoConfig=$b(Qb({},t),{view:i,publish:o,capture:n}),yield e._updateVideoPlayOption({view:i,playOption:d,track:l})}()}))}updateLocalVideo(e){return nw(this,null,(function*(){var t,r,i;if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:o,publish:n,mute:a,capture:s,option:l}=e,c={};if(this._localVideoConfig.capture)!1!==s?null!=l&&l.cameraId?yield this._localVideoTrack.switchDevice(null==l?void 0:l.cameraId):jD(null==l?void 0:l.useFrontCamera)?jD(null==l?void 0:l.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(null==l?void 0:l.videoTrack)):yield this._localVideoTrack.switchDevice(null!=l&&l.useFrontCamera?eC.FACING_MODE_USER:eC.FACING_MODE_ENVIRONMENT):this._localVideoTrack.stopCapture();else if(s){let e={};e.deviceId=(null==l?void 0:l.cameraId)||(null==(t=this._localVideoConfig.option)?void 0:t.cameraId),e.facingMode=null!=l&&l.useFrontCamera||null!=(r=this._localVideoConfig.option)&&r.useFrontCamera?eC.FACING_MODE_USER:eC.FACING_MODE_ENVIRONMENT,e.customSource=(null==l?void 0:l.videoTrack)||(null==(i=this._localVideoConfig.option)?void 0:i.videoTrack),yield this._localVideoTrack.capture(e)}l&&(jD(l.profile)||(zD(l.profile)?Xw[l.profile]&&this._localVideoTrack.setProfile(Xw[l.profile]):this._localVideoTrack.setProfile(l.profile),(!l.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(l.cameraId))&&jD(l.useFrontCamera)&&(yield this._localVideoTrack.applyProfile())),jD(l.fillMode)||(c.objectFit=l.fillMode),jD(l.mirror)||(c.mirror=l.mirror),jD(l.rotation)||this._localVideoTrack.setRotation(l.rotation),l.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(FG(l.qosPreference)),jD(l.small)||(qD(l.small)&&!l.small?this._localVideoTrack.stopSmall():this._localVideoTrack.updateSmallConfig(BG(l.small,!0)))),this._room.isJoined&&jD(n)&&this._localVideoConfig.publish&&s&&!this._localVideoConfig.capture&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._room.isJoined&&((null!=n?n:this._localVideoConfig.publish)?this._room.publish(this._localVideoTrack).catch((()=>{})):this._room.unpublish(this._localVideoTrack).catch((()=>{}))),jD(a)||(yield this._localVideoTrack.setMute(a)),yield this._updateVideoPlayOption({view:o,playOption:c,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),hN(this._localVideoConfig,e)}))}stopLocalVideo(){return nw(this,null,(function*(){this._localVideoTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),ZP(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return nw(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){var r,i;if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:o=null,publish:n=!0,muteSystemAudio:a,option:s}=t,l=new BB(e._room.videoManager);l.on("4",(t=>{let r;t.error&&(r=UG.convertFrom(t.error)),e.emit(uj.PUBLISH_STATE_CHANGED,$b(Qb({},t),{error:r}))})),l.once("first-video-frame",(t=>{e.emit(uj.FIRST_VIDEO_FRAME,$b(Qb({},t),{streamType:VG(t.streamType)}))})),e._listenOutputTrackChanged(l),"main"===t.streamType&&(l.mediaType=4);let c=null,d={},u={};s&&(jD(s.profile)||(zD(s.profile)?Zw[s.profile]&&l.setProfile(Zw[s.profile]):l.setProfile(s.profile)),s.systemAudio&&(d.systemAudio=!0,d.echoCancellation=s.echoCancellation,d.noiseSuppression=s.noiseSuppression,d.autoGainControl=s.autoGainControl),jD(s.fillMode)||(u.objectFit=s.fillMode),s.videoTrack&&(d.videoTrack=s.videoTrack),s.audioTrack&&(d.audioTrack=s.audioTrack),s.captureElement&&(d.captureElement=s.captureElement),s.preferDisplaySurface&&(d.preferDisplaySurface=s.preferDisplaySurface),s.qosPreference&&(d.contentHint=FG(s.qosPreference)));let h=yield l.capture(d);if(l.mediaTrack.addEventListener(eC.ENDED,(()=>{e._stopScreenShare(),e.emit(uj.SCREEN_SHARE_STOPPED)})),h.getAudioTracks()[0]){c=new WB(e._room.audioManager);let o=h.getAudioTracks()[0];null!=(r=t.option)&&r.systemAudio&&!(null!=(i=t.option)&&i.audioTrack)&&(c.sourceTrack=o),yield c.setInputMediaStreamTrack(o),qD(a)&&c.mediaTrack&&(c.mediaTrack.enabled=!a),e._speakerId&&c.setAudioOutput(e._speakerId)}if($P(l,l).add("player-state-changed",(t=>{e.emit(uj.VIDEO_PLAY_STATE_CHANGED,$b(Qb({},t),{userId:"",streamType:"sub"}))})),n&&e._room.isJoined){let t=[l];c&&(t.push(c),e._checkScreenAudioEchoCancellation(l,c)),t.forEach((t=>e._room.publish(t).catch((()=>{}))))}e._localScreenTrack=l,e._localScreenAudioTrack=c,e._localScreenConfig=$b(Qb({},t),{view:o,publish:n}),yield e._updateVideoPlayOption({view:o,playOption:u,track:l})}()}))}updateScreenShare(e){return nw(this,null,(function*(){var t;if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:r,publish:i,muteSystemAudio:o,option:n}=e,a={};if(n&&(jD(n.fillMode)||(a.objectFit=n.fillMode),n.qosPreference)){let e=FG(n.qosPreference);this._localScreenTrack.setContentHint(e)}if(this._room.isJoined&&!jD(i)){if(i&&!this._localScreenConfig.publish){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),e.forEach((e=>this._room.publish(e).catch((()=>{}))))}if(this._localScreenConfig.publish&&!i){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),e.forEach((e=>this._room.unpublish(e).catch((()=>{}))))}}null!=(t=this._localScreenAudioTrack)&&t.mediaTrack&&qD(o)&&(this._localScreenAudioTrack.mediaTrack.enabled=!o),yield this._updateVideoPlayOption({view:r,playOption:a,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),hN(this._localScreenConfig,e)}))}stopScreenShare(){return nw(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return nw(this,null,(function*(){let{view:t,userId:r,streamType:i,option:o}=e,n="".concat(r,"_").concat(i);if(this._remoteVideoConfigMap.has(n))return void this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i));let a=this._room.remotePublishedUserMap.get(r);if(!a)return;let s={},l="main"===i?a.remoteVideoTrack:a.remoteAuxiliaryTrack;l.on("decode-failed",(e=>{this.emit(uj.ERROR,new UG({code:OG.OPERATION_FAILED,extraCode:5507,message:"video decode failed"}))})),l.on("video-size-changed",(e=>{this.emit(uj.VIDEO_SIZE_CHANGED,$b(Qb({},e),{streamType:VG(e.streamType)}))})),this._listenOutputTrackChanged(l),o&&(jD(o.fillMode)||(s.objectFit=o.fillMode),jD(o.mirror)||(s.mirror=o.mirror),jD(o.poster)||(s.poster=o.poster),s.canvasRender=o.canvasRender,"main"===i&&!jD(o.small)&&(!a.remoteVideoTrack.isSubscribing&&!a.remoteVideoTrack.isSubscribed&&a.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,l.user)),jD(o.draggable)||l.setDraggable(o.draggable)),yield this._room.subscribe(l),yield this._enableVideoDecodeFallback(l,i),yield this._updateVideoPlayOption({view:t,playOption:s,track:l}),this._emitTrackEvent(l),this._remoteVideoConfigMap.set(n,{config:e}),o&&!jD(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:l,view:t,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot})}))}updateRemoteVideo(e){return nw(this,null,(function*(){var t,r;let{view:i,userId:o,streamType:n,option:a,mute:s}=e,l="".concat(o,"_").concat(n),c=this._remoteVideoConfigMap.get(l);if(!c||!this._room.remotePublishedUserMap.has(o))return;let d={};a&&(jD(a.fillMode)||(d.objectFit=a.fillMode),jD(a.mirror)||(d.mirror=a.mirror));let u=null,h=this._room.remotePublishedUserMap.get(o);if("main"===n&&null!=h&&h.muteState.hasVideo&&(u=h.remoteVideoTrack),"sub"===n&&null!=h&&h.muteState.hasAuxiliary&&(u=h.remoteAuxiliaryTrack),!u)return;let{config:p}=c;"main"===n&&a&&!jD(a.small)&&this._room.changeType(a.small,u.user),a&&!jD(a.draggable)&&u.setDraggable(a.draggable),qD(s)&&(u.ignoreUpdatePlayingState=!0,s?(yield u.player.pause(),yield this.room.unsubscribe(u)):(yield this.room.subscribe(u),yield u.player.resume())),yield this._updateVideoPlayOption({view:i,playOption:d,track:u,prevConfig:p}),hN(p,e);let m=jD(null==a?void 0:a.receiveWhenViewVisible)?null==(t=p.option)?void 0:t.receiveWhenViewVisible:a.receiveWhenViewVisible,f=jD(i)?p.view:i,_=jD(null==a?void 0:a.viewRoot)?null==(r=p.option)?void 0:r.viewRoot:a.viewRoot;this._observeView({remoteTrack:u,view:f,receiveWhenViewVisible:m,viewRoot:_})}))}stopRemoteVideo(e){return nw(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return nw(this,null,(function*(){let r=[],i=this._room.remotePublishedUserMap.get(e.userId);if(i){let{muteState:t,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=i;"main"===e.streamType&&(o.stop(),t.hasVideo&&r.push(o)),"sub"===e.streamType&&(n.stop(),t.hasAuxiliary&&r.push(n))}for(let e of r)t&&(delete e.ignoreUpdatePlayingState,yield this._room.unsubscribe(e),this._mediaTrackMap.delete(e.outMediaTrack));this._removeRemoteVideoConfig(e.userId,e.streamType)}))}_removeRemoteVideoConfig(e,t){let r="".concat(e,"_").concat(t),i=this._remoteVideoConfigMap.get(r);i&&i.observer&&i.observer.disconnect(),this._remoteVideoConfigMap.delete(r)}muteRemoteAudio(e,t){return nw(this,null,(function*(){this._remoteAudioMuteMap.set(e,t);try{if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&!this._remoteAudioConfigMap.has(t.userId)&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):this._remoteAudioConfigMap.has(e)||(yield this._startRemoteAudio({userId:e}))}catch(cM){throw cM.code!==OG.OPERATION_ABORT&&this._remoteAudioMuteMap.delete(e),cM}}))}setRemoteAudioVolume(e,t){if("*"===e){this._remoteAudioVolumeMap.set("*",t),this._remoteAudioVolumeMap.forEach(((e,r)=>this._remoteAudioVolumeMap.set(r,t)));let e=[...this._room.remotePublishedUserMap.values()];for(let r of e)this._remoteAudioVolumeMap.set(r.userId,t),r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}else if(e){let r=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),r&&r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}}startPlugin(e,t){return nw(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return nw(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return nw(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,r){if(this.listeners(e).includes(t))return this;if(this._log.debug("on",e),super.on(e,t,r),this._eventListened.add(e),this.listeners(uj.AUDIO_FRAME).length>0){let{audioFrameEventConfigMap:e}=this.room.audioManager;e.get("")||e.set("",{enable:!0}),this._localAudioTrack&&this.room.audioManager.handleLocalTrackStarted({userId:"",room:this.room})}return this}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];try{hj.has(e)||this._log.debug("emit ".concat(e," ").concat(JSON.stringify(r)))}catch(cM){}return super.emit(e,...r)}off(t,r,i){if(this._log.debug("off",t),"*"===t?(this._eventListened.clear(),this.removeAllListeners()):super.off(t,r,i),(t===e.EVENT.AUDIO_FRAME||"*"===t)&&0===this.listeners(e.EVENT.AUDIO_FRAME).length){let{getPCMAbortCtrlMap:e}=this.room.audioManager;e.forEach((e=>{null==e||e.abort("off")})),e.clear()}return this}getAudioTrack(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},r=null,i="main",o=!1;if(zD(t)?e=t:(e=t.userId,o=!0===t.processed,t.streamType&&(i=t.streamType)),e){let t=this._room.remotePublishedUserMap.get(e);t&&(r=t.remoteAudioTrack)}else r="sub"===i?this._localScreenAudioTrack:this._localAudioTrack;return r?o&&r.outMediaTrack&&r.outMediaTrack!==r.mediaTrack?r.outMediaTrack.clone():r.mediaTrack:null}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:r="main",processed:i=!1}=e,o=null;if(""===t)"main"===r&&this._localVideoTrack&&(o=this._localVideoTrack),"sub"===r&&this._localScreenTrack&&(o=this._localScreenTrack);else{let e=this._room.remotePublishedUserMap.get(t);e&&(o="main"===r?e.remoteVideoTrack:e.remoteAuxiliaryTrack)}return o?i&&o.outMediaTrack&&o.outMediaTrack!==o.mediaTrack?o.outMediaTrack.clone():o.mediaTrack:null}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:r="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=e&&e.muteState.hasVideo)return e.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=e&&e.muteState.hasAuxiliary)return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}_setCurrentSpeaker(e){var t,r;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(r=this._localScreenAudioTrack)||r.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}setCurrentSpeaker(e){return nw(this,null,(function*(){(yield hU()).forEach((t=>{t.deviceId===e&&(this._setCurrentSpeaker(e),this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),Az=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: '.concat(Pw,"/en/TRTC.html#.setCurrentSpeaker"))}))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return nw(this,null,(function*(){var t;let{userId:r}=e;if(this._remoteAudioConfigMap.has(r))return void this._log.warn("remote audio has already started. userId:".concat(r));let i=this._room.remotePublishedUserMap.get(r);if(!i)return;let o={},n=i.remoteAudioTrack;n.on("decode-failed",(e=>{this.emit(uj.ERROR,new UG({code:OG.OPERATION_FAILED,extraCode:5508,message:"audio decode failed"}))})),this._listenOutputTrackChanged(n),this._speakerId&&n.setAudioOutput(this._speakerId);try{let i=null!=(t=this._remoteAudioVolumeMap.get(r))?t:this._remoteAudioVolumeMap.get("*"),a=KD(i)?i:100;o.volume=a,this._remoteAudioConfigMap.set(r,e),yield this._room.subscribe(n),JU(DV(n,"decode-failed"),QV(DV(n,WP.INIT)),$F((()=>{this.startPlugin(fz.Name,{track:n,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),yield this._updateAudioPlayOption({playOption:o,track:n}),YO.emit("115",{userId:r,room:this.room}),n.outMediaTrack&&this.room.audioManager.updateAudioReference({type:"add",audioReference:n.outMediaTrack,refId:"ra-".concat(r)})}catch(uM){throw this._remoteAudioConfigMap.delete(r),uM}this._emitTrackEvent(n)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return nw(this,null,(function*(){let r=this._room.remotePublishedUserMap.get(e.userId);r&&(r.remoteAudioTrack.stop(),r.muteState.hasAudio&&t&&(yield this._room.unsubscribe(r.remoteAudioTrack)),this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId)),YO.emit("116",{userId:e.userId,room:this.room}),this.room.audioManager.updateAudioReference({type:"remove",refId:"ra-".concat(e.userId)})}))}_enableVideoDecodeFallback(e,t){let r,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),JU(DV(e,"decode-failed"),QV(DV(e,WP.INIT)),ZF((()=>{"h265"!==this._room.downlinkVideoCodec&&this.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),NF(DV(e,"decode-downgrade-state-changed")),$F((i=>{r=i.state,this.emit(uj.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,$b(Qb({},i),{streamType:t,userId:e.userId}))}),(t=>{e.log.error("fallback",t)}),(()=>{"STARTED"===r&&e.log.info("fallback complete")}))))}_updateVideoPlayOption(e){return nw(this,arguments,(function(e){let{view:t,playOption:r,track:i,prevConfig:o}=e;return function*(){if(i.setMirror(r.mirror),jD(t)&&o&&o.view&&!lN(r)){let e=mN(o.view);e.length>0&&(yield i.play(e,r))}if(!jD(t)){let e=mN(t);e.length>0?yield i.play(e,r):i.stop()}}()}))}_updateAudioPlayOption(e){return nw(this,arguments,(function(e){var t=this;let{playOption:r={},track:i,prevConfig:o}=e;return function*(){if(!i.isPlayCalled)try{yield i.play(null,r)}catch(Rw){}if(jD(r.muted)||i.setPlayerMute(r.muted),jD(r.volume)||i.setAudioVolume(r.volume/100),i instanceof aB&&i.mediaTrack){let e=!1===r.muted&&!jD(r.volume)&&r.volume>0?"add":"remove";t.room.audioManager.updateAudioReference({type:e,audioReference:i.mediaTrack,refId:"em"})}else if(i instanceof qB){let e=r.muted?0:r.volume;if(jD(e))return;t.room.audioManager.updateAudioReference({type:"updateVolume",refId:"ra-".concat(i.userId),volume:r.volume})}}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e,!1)))}_emitTrackEvent(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===r||(this._mediaTrackMap.set(e.outMediaTrack,r),this.emit(uj.TRACK,{userId:r,streamType:VG(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}_checkTrackToPublish(){var e,t,r;let i=[];if(null!=(e=this._localAudioConfig)&&e.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(t=this._localVideoConfig)&&t.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack),this._checkScreenAudioEchoCancellation(this._localScreenTrack,this._localScreenAudioTrack)),0!==i.length)return Promise.all(i.map((e=>this._room.publish(e).catch((()=>{})))))}_observeView(e){let{remoteTrack:t,view:r,receiveWhenViewVisible:i,viewRoot:o}=e;if(jD(r)||jD(i))return;let n=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(VG(t.streamType)));if(!n)return;let a=n.observer||void 0;if(null===r||JD(r)&&0===r.length||!i)return null==a||a.disconnect(),void(t.isSubscribed||(this._log.info("_observeView observer disconnect, resubscribe",t.userId,t.strMediaType),this._room.subscribe(t).catch((()=>{}))));let s=n.visibleViewMap||new Map,l=-1;(!a||a.root!==o)&&(null==a||a.disconnect(),s.clear(),a=new IntersectionObserver((e=>{e.forEach((e=>{s.set(e.target,e.isIntersecting),t.log.info("view ".concat(e.target.id," is").concat(e.isIntersecting?"":" not"," visible"))})),clearTimeout(l),l=window.setTimeout((()=>{[...s.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:o}));let c=new Set(mN(r));s.forEach(((e,t)=>{c.has(t)||(a.unobserve(t),s.delete(t))})),c.forEach((e=>{s.set(e,!0),a.observe(e)})),a.takeRecords().forEach((e=>{s.set(e.target,e.isIntersecting)})),n.visibleViewMap=s,n.observer=a}_exitRoom(){return nw(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),this._clearRemoteTracks()}))}_stopScreenShare(){return nw(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let e=[this._localScreenTrack];this._localScreenAudioTrack&&e.push(this._localScreenAudioTrack),yield Promise.all(e.map((e=>this._room.unpublish(e).catch((()=>{})))))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(!1===(null==(e=this._localScreenAudioTrack.trackSettings)?void 0:e.echoCancellation)&&this.stopPlugin("AudioProcessor"),this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),ZP(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_checkScreenAudioEchoCancellation(e,t){return nw(this,null,(function*(){var r,i;if(!e||!t)return;let o=null==(r=e.trackSettings)?void 0:r.displaySurface;if(!1===(null==(i=t.trackSettings)?void 0:i.echoCancellation)&&("monitor"===o||"browser"===o&&e.isShareCurrentTab)){this._log.warn("echoCancellation of screen audio track is disable. Try starting audioProcessor plugin");try{yield this.startPlugin("AudioProcessor",{sdkAppId:Number(this.room.sdkAppId),userId:this._room.userId,userSig:this.room.userSig,isScreenAudioNeedAudioProcess:!0,isLocalAudioNeedAudioProcess:!1})}catch(lM){this._log.warn("start audioProcessor plugin failed: ",lM)}}}))}_onLocalTrackCaptured(e){let{track:t}=e;"audio"===t.kind&&(!Az||sU(Az))&&(this._initActiveSpeaker(),YO.off("102",this._onLocalTrackCaptured,this))}_initActiveSpeaker(){return nw(this,null,(function*(){if(Az&&!sU(Az))this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:Az});else{let e=yield hU();e[0]&&!sU(e[0])?(Az=e[0],this.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]})):YO.on("102",this._onLocalTrackCaptured,this)}}))}_onAudioAvailable(e){let{userId:t}=e,r=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===r||this._room.autoReceiveAudio&&!r)&&this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:r}=e;if(!this._room.autoReceiveVideo)return;let i=this._room.remotePublishedUserMap.get(t);if(i){let e="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,t=[e];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&t.push(i.remoteAudioTrack),this._room.subscribe(...t).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:r}=e;r.hasAudio&&r.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:r}=e;this._stopRemoteVideo({userId:t,streamType:r},!1).catch((()=>{}))}sendSEIMessage(e,t){var r;let i=this._plugins.get("SEI");i&&(i.update({buffer:e,options:$b(Qb({seiPayloadType:243},t),{small:!(null==(r=this._localVideoTrack)||!r.small)})}),RL.addCount({key:5e5,useUV:!0}))}sendCustomMessage(e){var t,r;null==(r=(t=this._room).sendCustomMessage)||r.call(t,e),RL.addCount({key:500001,useUV:!0})}callExperimentalAPI(e,t){return nw(this,null,(function*(){return this._log.info("callExperimentalAPI(".concat(e,", ").concat(JSON.stringify(t),")")),gz.call(e,Qb({trtcInstance:this},t))}))}static setLogLevel(e,t){ZO.setLogLevel(e),jD(t)||(t?ZO.enableUploadLog():ZO.disableUploadLog())}static isSupported(){return VL(e.frameWorkType)}static getPermissions(e){return nw(this,arguments,(function(e){let{request:t=!0,types:r=["camera","microphone"]}=e;return function*(){t&&(yield yz.request(r).catch((e=>{var t;return ZO.error("getPermissions request failed, error: ".concat(null!=(t=null==e?void 0:e.message)?t:e))})));let[e,i]=yield Promise.all([yz.get("camera"),yz.get("microphone")]);return{camera:e,microphone:i}}()}))}static getCameraList(){return dU(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getMicrophoneList(){return cU(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getSpeakerList(){return hU(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static setCurrentSpeaker(t){return nw(this,null,(function*(){if(!lk||t!==kG.SPEAKER&&t!==kG.HEADSET)(yield hU()).forEach((e=>{e.deviceId===t&&(Iz.forEach((r=>{r._setCurrentSpeaker(t),r.emit(uj.DEVICE_CHANGED,{type:"speaker",action:"active",device:e})})),Az=e)}));else{let r=yield e.getMicrophoneList(),i="";if(r.forEach((e=>{e.label===t&&(i=e.deviceId)})),!i)return;Iz.forEach((e=>nw(this,null,(function*(){e._localAudioTrack&&(yield e.updateLocalAudio({option:{microphoneId:i}}))}))))}}))}static _addKVStat(e){let{type:t,key:r,value:i,base:o,useUV:n,version:a,max:s}=e;switch(a&&(SL.version=a),t){case"count":SL.addCount({key:r,useUV:n});break;case"enum":SL.addEnum({key:r,value:i,useUV:n});break;case"number":SL.addNumber({key:r,value:i,split:o,max:s})}}};iw(Sz,"VERSION",Oj),iw(Sz,"_loggerManager",ZO),iw(Sz,"EVENT",uj),iw(Sz,"ERROR_CODE",OG),iw(Sz,"TYPE",kG),iw(Sz,"frameWorkType",30),rw([Uj({replaceArg:e=>({argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}})})],Sz.prototype,"use",1),rw([Mj($G.TRTC.enterRoom),sj("room",((e,t)=>{let[r]=e,[i]=t;return(r.roomId||r.strRoomId)===(i.roomId||i.strRoomId)&&r.userId===i.userId&&r.sdkAppId===i.sdkAppId})),DU((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),Uj()],Sz.prototype,"enterRoom",1),rw([Uj()],Sz.prototype,"exitRoom",1),rw([Mj($G.TRTC.switchRoom),Uj(),PU()],Sz.prototype,"switchRoom",1),rw([Mj($G.TRTC.switchRole),lj("room",{merge:(e,t)=>t}),Uj()],Sz.prototype,"switchRole",1),rw([Uj()],Sz.prototype,"destroy",1),rw([Mj($G.TRTC.startLocalAudio),sj("audio",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)===(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)})),Uj()],Sz.prototype,"startLocalAudio",1),rw([Mj($G.TRTC.updateLocalAudio),lj("audio",{debounce:{delay:200,getKey:()=>"".concat(Tz,"-localAudio"),isNeedToDebounce:e=>{var t;return!jD(null==(t=e.option)?void 0:t.captureVolume)}}}),Uj()],Sz.prototype,"updateLocalAudio",1),rw([cj("audio"),Uj()],Sz.prototype,"stopLocalAudio",1),rw([Mj($G.TRTC.startLocalVideo),sj("video",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)===(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)})),Uj()],Sz.prototype,"startLocalVideo",1),rw([Mj($G.TRTC.updateLocalVideo),lj("video"),Uj()],Sz.prototype,"updateLocalVideo",1),rw([cj("video"),Uj()],Sz.prototype,"stopLocalVideo",1),rw([Mj($G.TRTC.startScreenShare),sj("screen",(()=>!0)),Uj()],Sz.prototype,"startScreenShare",1),rw([Mj($G.TRTC.updateScreenShare),lj("screen"),Uj()],Sz.prototype,"updateScreenShare",1),rw([Uj()],Sz.prototype,"stopScreenShare",1),rw([Mj($G.TRTC.startRemoteVideo),sj((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),Uj({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Sz.prototype,"startRemoteVideo",1),rw([Mj($G.TRTC.updateRemoteVideo),lj((e=>"v".concat(e.userId).concat(e.streamType))),Uj({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Sz.prototype,"updateRemoteVideo",1),rw([Mj($G.TRTC.stopRemoteVideo),DU((e=>function(t){return nw(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),Uj({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],Sz.prototype,"stopRemoteVideo",1),rw([cj((e=>"v".concat(e.userId).concat(e.streamType)))],Sz.prototype,"_stopRemoteVideo",1),rw([Mj(...$G.TRTC.muteRemoteAudio),Uj({getRemoteId:e=>e})],Sz.prototype,"muteRemoteAudio",1),rw([Lj(...$G.TRTC.setRemoteAudioVolume),function(e,t){return DU(((r,i)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a=kj.get(this);a||(a=new Map,kj.set(this,a));let s=t(...o),l=a.get(s);if(!l||l<=0){r.apply(this,o);let t=setTimeout((()=>{var e;null==(e=kj.get(this))||e.delete(s)}),e);a.set(s,t)}else{clearTimeout(l);let t=window.setTimeout((()=>{var e;r.apply(this,o),null==(e=kj.get(this))||e.delete(s)}),e);a.set(s,t)}}))}(200,(e=>e)),Uj({getRemoteId:e=>e})],Sz.prototype,"setRemoteAudioVolume",1),rw([Fj("start"),CU((e=>{var t;return null==(t=e.afterStart)?void 0:t.call(e)})),sj(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),Uj({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>vL[e.getName()],ignoreLog:e=>"Debug"===e.getName(),ignoreErrorLog:e=>"AudioProcessor"===e.getName()})],Sz.prototype,"startPlugin",1),rw([Fj("update"),lj(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t)),{merge:(e,t)=>(hN(e[1],t[1]),e)}),Uj({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>yL[e.getName()]})],Sz.prototype,"updatePlugin",1),rw([Fj("stop"),cj(((e,t)=>{if(e.disableRandomCall)return null;let r=e.getGroup(t),i=e.getAlias();return"*"===r?new RegExp("".concat(i,".*")):i+r})),Uj({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>TL[e.getName()]})],Sz.prototype,"stopPlugin",1),rw([Lj(...$G.TRTC.enableAudioVolumeEvaluation)],Sz.prototype,"enableAudioVolumeEvaluation",1),rw([Uj()],Sz.prototype,"getVideoSnapshot",1),rw([Uj()],Sz.prototype,"_setCurrentSpeaker",1),rw([sj((e=>"a".concat(e.userId)),(()=>!0))],Sz.prototype,"_startRemoteAudio",1),rw([DU((e=>function(t){return nw(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio($b(Qb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),cj((e=>"a".concat(e.userId)))],Sz.prototype,"_stopRemoteAudio",1),rw([cj("room")],Sz.prototype,"_exitRoom",1),rw([cj("screen")],Sz.prototype,"_stopScreenShare",1),rw([Mj(...$G.TRTC.sendSEIMessage),CG({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].byteLength}})],Sz.prototype,"sendSEIMessage",1),rw([Mj($G.TRTC.sendCustomMessage),CG({timesInSecond:30,maxSizeInSecond:8e3,getSize:e=>e.data.byteLength})],Sz.prototype,"sendCustomMessage",1),rw([dj()],Sz,"create",1),rw([Mj($G.TRTC.create)],Sz,"_create",1),rw([dj()],Sz,"setLogLevel",1),rw([dj()],Sz,"isSupported",1),rw([dj()],Sz,"getPermissions",1),rw([dj()],Sz,"getCameraList",1),rw([dj()],Sz,"getMicrophoneList",1),rw([dj()],Sz,"getSpeakerList",1);var Rz=Sz,bz=class{constructor(e,t){iw(this,"_flag"),iw(this,"terminalType"),iw(this,"userId"),iw(this,"tinyId"),iw(this,"role"),iw(this,"remoteAudioTrack"),iw(this,"remoteVideoTrack"),iw(this,"remoteAuxiliaryTrack"),this.userId=t.userId||"",this.tinyId=t.tinyId||"",this.role=t.role||"audience",this.terminalType=t.terminalType,this.remoteAudioTrack=new qB(e,this),this.remoteVideoTrack=new JB(e,this),this.remoteAuxiliaryTrack=new XB(e,this),this.flag=t.flag||0}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return cN(this.flag,this.userId)}get flag(){return this._flag}set flag(e){if(e===this._flag)return;let t,r=this.muteState;this._flag=e;let i=this.muteState;for(t in i)r[t]!=i[t]&&console.log(this.userId,t,r[t],"->",i[t]);this.remoteAudioTrack.onFlagChanged(),this.remoteVideoTrack.onFlagChanged(),this.remoteAuxiliaryTrack.onFlagChanged()}},wz=class{constructor(){iw(this,"_set",new Set),YO.on(XO.LEAVE_SUCCESS,this.delete,this),YO.on(XO.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess,this)}add(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,r||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(i)}delete(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,t.roomId||r,t.sdkAppId,t.useStringRoomId);this._set.delete(i)}getKey(e,t,r,i){return"".concat(r,"_").concat(t,"_").concat(e,"_").concat(i)}isJoined(e){let{userId:t,roomId:r,sdkAppId:i,room:o}=e;return"rtc"!==o.scene&&this._set.has(this.getKey(t,r,i,o.useStringRoomId))}handleSwitchRoomSuccess(e){let{room:t,currentRoomId:r,targetRoomId:i}=e;"rtc"!==t.scene&&(this._set.delete(this.getKey(t.userId,r,t.sdkAppId,t.useStringRoomId)),this._set.add(this.getKey(t.userId,i,t.sdkAppId,t.useStringRoomId)))}};function Cz(){return nw(this,null,(function*(){let e,t;try{let t=yield cU();e=t&&t.length}catch(p){}try{let e=yield dU();t=e&&e.length}catch(p){}let r={microphone:e,camera:t},{isH264EncodeSupported:i,isVp8EncodeSupported:o,isH264DecodeSupported:n,isVp8DecodeSupported:a,isH265EncodeSupported:s,isH265DecodeSupported:l}=this.checkSystemResult.detail,c=rM.basis(),d={webRTC:c.isWebRTCSupported,getUserMedia:c.isGetUserMediaSupported,webSocket:c.isWebSocketsSupported,screenShare:c.isScreenShareSupported,webAudio:c.isWebAudioSupported,h264Encode:i,h264Decode:n,vp8Encode:o,vp8Decode:a,h265Encode:s,h265Decode:l},u={browser:c.browser,os:c.os,trtc:d,devices:r},h={isWebCodecSupported:c.isWebCodecSupported,isMediaSessionSupported:c.isMediaSessionSupported,isWebTransportSupported:c.isWebTransportSupported};ex.uploadEvent({log:"trtcstats-".concat(JSON.stringify(u)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(u))),ex.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(h)),userId:this.userId}),DP()}))}var Dz=class{constructor(e){iw(this,"_frameWorkType"),iw(this,"_component"),iw(this,"_language"),iw(this,"connectionType"),iw(this,"_room"),iw(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0,reportToken:void 0}),iw(this,"_keyPrefix"),iw(this,"_log"),iw(this,"_intervalId"),iw(this,"_firstPublishedUserList"),iw(this,"_networkQuality"),iw(this,"_basicInfo"),iw(this,"_pathJoinRoom"),iw(this,"_pathLeaveRoom"),iw(this,"_pathMainVideoMap"),iw(this,"_pathMainAudioMap"),iw(this,"_pathAuxiliaryMap"),iw(this,"_remoteStreamStatMap"),iw(this,"_localStreamStat"),iw(this,"_eventMap",new Map),iw(this,"_captureCostSum",0),iw(this,"_captureCostCount",0),iw(this,"isDestroyed",!1),this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=ZO.createLogger({parent:this._room.getLogger(),id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&GD(this[e])&&(this[e]=function(e){let{fn:t,context:r}=e;return function(){try{for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];let n=t.apply(r,i);return $D(n)?n.catch((e=>ZO.error("".concat(t.name,"() error observed ").concat(e)))):n}catch(CC){ZO.error("".concat(t.name,"() error observed ").concat(CC))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents()}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:Iw,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0,uint32_audio_capture_thread_health_zero_cnt:0,uint32_after3a_silence_duration:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,xO().then((()=>{this._basicInfo.string_os_version=jO(),this._basicInfo.string_device_name=VO()||this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),YO.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(XO.JOIN_START,this.handleJoinStart).addEvent(XO.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(XO.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(XO.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(XO.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(XO.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(XO.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(XO.JOIN_FAILED,this.handleJoinFailed).addEvent(XO.LEAVE_START,this.handleLeaveStart).addEvent(XO.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(XO.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(XO.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(XO.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(XO.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(XO.PUBLISH_START,this.handlePublishStart).addEvent(XO.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(XO.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(XO.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(XO.PLAY_TRACK_START,this.handlePlayStart).addEvent(XO.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(XO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,type:i}=e;!t.isRemote||!this.hitTest(t.room)||"PLAYING"===r&&(i===eC.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(XO.SWITCH_ROOM_START,this.handleSwitchRoomStart).addEvent(XO.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess).addEvent(XO.SWITCH_ROOM_FAILED,this.handleSwitchRoomFailed).addEvent(XO.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(XO.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(XO.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(XO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let o=r.hasAudio||r.hasVideo||r.hasSmall,n=r.hasAuxiliary,a=i.hasAudio||i.hasVideo||i.hasSmall,s=i.hasAuxiliary;!o&&a&&this.handleRemoteStreamAdded(i.userId,"main"),!n&&s&&this.handleRemoteStreamAdded(i.userId,"auxiliary")})).addEvent(XO.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:r}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=r.ice,this._pathJoinRoom.int32_dtls_cost=r.dtls,this._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}uninstallEvents(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach(((e,t)=>YO.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),YP.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(jD(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),jD(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),jD(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:r}=e;if(this.hitTest(t)&&r){let{totalCost:e,local:t,dns:i,tcp:o,tls:n,request:a,response:s}=r;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=i,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=n,this._pathJoinRoom.int32_schedule_request=a,this._pathJoinRoom.int32_schedule_response=s}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:r}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),r&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=r instanceof mw?Number(r.getExtraCode()||r.getCode()):hw.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:r}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){var t;if(this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time){if(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time){this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time;let e=null==(t=this._room.audioManager.localAudioTrack)?void 0:t.after3aSilenceStartTime;e&&(this._localStreamStat.statsToReport.uint32_after3a_silence_duration=oN()-e)}else this._log.warn("pathJoinRoom endTime is 0");this.report()}}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleSwitchRoomStart(e){if(this.hitTest(e.room)){let e=Date.now();this.report().then((()=>{this._pathJoinRoom.uint64_start_time=e,this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=e}))}}handleSwitchRoomSuccess(e){let{room:t}=e;if(this.hitTest(t)&&0===this._pathJoinRoom.uint64_end_time){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,this._pathJoinRoom.int32_end_ret}}handleSwitchRoomFailed(e){let{room:t,error:r}=e;if(this.hitTest(t)){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,r&&(this._pathJoinRoom.int32_end_ret=r instanceof mw?Number(r.getExtraCode()||r.getCode()):hw.UNKNOWN)}}handleRemoteStreamAdded(e,t){var r;let i="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(i)){let o={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:$b(Qb({},kz),{msg_user_info:new Oz({userId:e,tinyId:null==(r=this._room.remotePublishedUserMap.get(e))?void 0:r.tinyId,role:20})})};o.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(i,o)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:r,streamType:i,subscribeState:o}=e;if(!this.hitTest(t))return;let{userId:n,tinyId:a,role:s}=r,l=new Oz({userId:n,tinyId:a,role:"anchor"===s?20:21}),c=Date.now(),d="".concat(n,"_").concat(i),u=this._remoteStreamStatMap.get(d);u&&0===u.subscribeStartTime&&(u.subscribeStartTime=c),"main"===i?(r.muteState.hasVideo&&(o.video||o.smallVideo)&&!this._pathMainVideoMap.has(d)&&this._pathMainVideoMap.set(d,{statsToReport:{msg_user_info:l,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:n,sendSubscribeCMDTime:c}),r.muteState.hasAudio&&o.audio&&!this._pathMainAudioMap.has(d)&&this._pathMainAudioMap.set(d,{statsToReport:{msg_user_info:l,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:n,sendSubscribeCMDTime:c})):r.muteState.hasAuxiliary&&o.auxiliary&&!this._pathAuxiliaryMap.has(d)&&this._pathAuxiliaryMap.set(d,{sendSubscribeCMDTime:c})}handleSubscribed(e){let{room:t,remotePublishedUser:r,streamType:i}=e;if(this.hitTest(t)){let e="".concat(r.userId,"_").concat(i),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._remoteStreamStatMap.get(r);0===(null==i?void 0:i.playStreamTime)&&(i.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._pathMainVideoMap.get(r);i&&0===i.statsToReport.uint64_combine_first_frame_time&&(i.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=Date.now(),i=this._pathMainVideoMap.get(t),o=this._remoteStreamStatMap.get(t);if(o){let{statsToReport:t}=o;if(t.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){let e=r-this._pathJoinRoom.uint64_start_time;t.uint32_video_render_first=e,RL.addNumber({key:516820,value:e})}}0===(null==i?void 0:i.statsToReport.uint64_render_first_frame_time)&&(i.statsToReport.uint64_render_first_frame_time=r)}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=this._pathMainAudioMap.get(t);r&&0===r.statsToReport.uint64_play_first_frame_time&&(r.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:r,userId:i,videoDelay:o,audioDelay:n}=e,a=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(a)a.totalRTT+=t,a.totalLoss+=r,o&&(a.totalVideoDelay=(a.totalVideoDelay||0)+o,a.videoDelayCount=(a.videoDelayCount||0)+1),n&&(a.totalAudioDelay=(a.totalAudioDelay||0)+n,a.audioDelayCount=(a.audioDelayCount||0)+1),a.count++;else{let e,a,s,l;o&&(a=o,s=1),n&&(e=n,l=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(i,{totalRTT:t,totalLoss:r,count:1,totalAudioDelay:e,totalVideoDelay:a,audioDelayCount:l,videoDelayCount:s})}})))}handleHeartbeatStats(e){var t;if(this.hitTest(e.room)){let{msg_device_info:r,msg_up_stream_info:i,msg_down_stream_info:o}=e.report;if(i.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:t,uint32_video_width:r,uint32_video_height:o}=i.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=t,this._localStreamStat.totalVideoWidth+=r,this._localStreamStat.totalVideoHeight+=o,this._localStreamStat.videoCount++}if(i.msg_audio_status){let{uint32_audio_level:e}=i.msg_audio_status;Math.floor(e/JM*100)>0&&(this._localStreamStat.totalAudioLevel+=e/JM,this._localStreamStat.audioLevelCount++)}o.forEach((e=>{let{msg_user_info:t,msg_audio_status:r,msg_video_status:i}=e,o=t.str_identifier,n=this._room.remotePublishedUserMap.get(o);if(i.forEach((e=>{let t=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(o,"_").concat(t?"main":"auxiliary"),a=this._remoteStreamStatMap.get(i);if(a&&(t&&null!=n&&n.remoteVideoTrack.isSubscribed||r&&null!=n&&n.remoteAuxiliaryTrack)){a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height);let r=t?n.remoteVideoTrack:n.remoteAuxiliaryTrack;r.stat.jitterBufferDelay&&(a.videoJitterBufferDelay=r.stat.jitterBufferDelay),r.stat.framesReceived&&(a.statsToReport.uint32_video_consume_render_rate=Math.floor(r.stat.framesDecoded/r.stat.framesReceived*Jb(10,6)))}})),!lN(r)){let e="".concat(o,"_main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&null!=n&&n.remoteAudioTrack.isSubscribed&&(t.totalAudioBitrate+=r.uint32_audio_codec_bitrate,t.audioCount++,n.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=n.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/JM*100)>0&&(t.totalAudioLevel+=r.uint32_audio_level/JM,t.audioLevelCount++),r.uint32_audio_block_time&&(t.statsToReport.uint32_audio_block_time+=r.uint32_audio_block_time))}})),r.uint32_audio_capture_cost&&(this._captureCostSum+=r.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0)),0===r.uint32_audio_capture_cost&&!1===(null==(t=this._room.audioManager.localAudioTrack)?void 0:t.muted)&&(this._localStreamStat.statsToReport.uint32_audio_capture_thread_health_zero_cnt+=1)}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:r}=e,i={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[r.name]||(r instanceof mw?r.getExtraCode()||r.getCode():hw.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=i,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=i,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&oC))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&sC))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&aC))>=0}hitTest(e){return e===this._room}prepareReport(){if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:r}=e,i=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){let{totalLoss:t,count:r,audioDelayCount:o,videoDelayCount:n,totalAudioDelay:a,totalVideoDelay:s}=i;e.statsToReport.uint32_avg_down_loss=Math.floor(t/r),o&&a&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(a/o),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),n&&s&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/n))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:o}=this._room;o&&(e.statsToReport.uint32_audio_play_time=o.getDuration(t,eC.AUDIO),e.statsToReport.uint32_video_play_time=o.getDuration(t,eC.VIDEO)),e.statsToReport.uint32_video_render_first&&(e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,Nz));let{badCaseDetector:n}=this._room,{dataFreeze:a,count:s}=n.getDataFreezeDuration(t),{renderFreeze:l}=n.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=s,e.statsToReport.uint32_video_block_time=Math.min(a,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(l,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_audio_block_time=Math.min(e.statsToReport.uint32_audio_block_time,e.statsToReport.uint32_audio_play_time),n.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>Nz&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+Nz):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>Nz&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+Nz):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>Nz&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+Nz)}getReportData(){this._basicInfo.uint32_networkType=kD();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new Oz({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:uN(this._signalInfo.relayIp),uint32_client_ip:uN(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Jb(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:uN(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend,str_user_sig:this._room.userSig,bytes_report_token:this._signalInfo.reportToken};return AN(e),e}report(){return nw(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),this.initData()}catch(sM){this._log.warn(sM)}finally{this.isDestroyed&&(this._room=null)}}))}upload(e){return nw(this,null,(function*(){if(0===e.msg_path_enter_room.uint64_start_time)return;let t=Number(this._room.sdkAppId),r=QO.enable?MN(e,2001,t):yield WN(e),i=r instanceof ArrayBuffer,o="".concat(SD(t,Ww.KEY_POINT),"&gzip=").concat(+i),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,r));let a=[this.uploadKVStat(RL),this.uploadKVStat(SL)];n||a.push(HN({url:o,body:r,priority:"low"})),yield Promise.all(a)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return nw(this,null,(function*(){let t=e.getReportData(this._room.userSig,this._signalInfo.reportToken);if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=$b(Qb({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let r=QO.enable?MN(t,2003,this._room.sdkAppId):yield WN(t),i=r instanceof ArrayBuffer,o="".concat(SD(+this._room.sdkAppId,Ww.KV_STAT),"&gzip=").concat(+i),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,r)),n||HN({url:o,body:r})}))}};rw([rx({settings:{timeout:500,retries:3}})],Dz.prototype,"upload",1);var Nz=5e3,kz={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},Oz=class{constructor(e){iw(this,"str_identifier"),iw(this,"str_tinyid"),iw(this,"uint32_role"),this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},Mz=Dz,Lz=class{constructor(){iw(this,"_startTime"),iw(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=oN())}stop(){0===this._endTime&&(this._endTime=oN())}getDuration(){return 0===this._endTime?oN()-this._startTime:this._endTime-this._startTime}get startTime(){return this._startTime}get endTime(){return this._endTime}},Pz=class{constructor(e){iw(this,"_room",null),iw(this,"_durationMap"),iw(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(XO.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(XO.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(XO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;var o;let{userId:n}=i;if(!this.hitTest(t))return;r.hasAudio&&!i.hasAudio&&this.stopDurationItem("".concat(n,"_main"),eC.AUDIO),r.hasVideo&&!i.hasVideo&&this.stopDurationItem("".concat(n,"_main"),eC.VIDEO),r.hasAuxiliary&&!i.hasAuxiliary&&this.stopDurationItem("".concat(n,"_auxiliary"),eC.VIDEO);let a=null==(o=this._room)?void 0:o.remotePublishedUserMap.get(n);a&&(!r.hasAudio&&i.hasAudio&&a.remoteAudioTrack.isSubscribed&&this.addDuractionItem(n,eC.AUDIO,"main"),!r.hasVideo&&i.hasVideo&&a.remoteVideoTrack.isSubscribed&&this.addDuractionItem(n,eC.VIDEO,"main"),!r.hasAuxiliary&&i.hasAuxiliary&&a.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(n,eC.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>YO.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>YO.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{track:t}=e;if(!this.hitTest(t.room))return;let{userId:r,streamType:i,kind:o}=t;t.isSubscribed?this.addDuractionItem(r,o,i):this.stopDurationItem("".concat(r,"_").concat(i),o)}handleUnsubscribed(e){let{track:t}=e;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,r){let i="".concat(e,"_").concat(r),o=new Lz,n=this._durationMap.get(i);n?this.isRecording(n[t])||n[t].push(o):this._durationMap.set(i,{userId:e,type:r,audio:t===eC.AUDIO?[o]:[],video:t===eC.AUDIO?[]:[o]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let r=this._durationMap.get(e)[t].find((e=>0===e.endTime));r&&r.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},xz=class{constructor(){iw(this,"renderFreezeMap",new Map),iw(this,"dataFreezeMap",new Map)}get(e,t){let r=this.renderFreezeMap.get(e),i=this.dataFreezeMap.get(e);return t?"data"===t?i:r:(gO||hk)&&r&&i&&r.duration>i.duration?r:i}set(e,t,r){"data"===r?this.dataFreezeMap.set(e,t):this.renderFreezeMap.set(e,t)}clear(){this.renderFreezeMap.clear(),this.dataFreezeMap.clear()}},Uz=class{constructor(e){iw(this,"_room"),iw(this,"_renderFreezeMap",new Map),iw(this,"_isVideoPlayingEventFiredMap",new Map),iw(this,"_dataFreezeMap",new Map),iw(this,"_monitorFreezeData",new xz),iw(this,"_eventMap",new Map),iw(this,"_videoEncodeFailedCount",0),iw(this,"_audioEncodeFailedCount",0),iw(this,"_encodeFailedThreshold",3),iw(this,"eventListenerMap",new Map),this._room=e.room,this.installEvents()}getRenderFreezeMap(){return this._renderFreezeMap}getDataFreezeMap(){return this._dataFreezeMap}installEvents(){this._eventMap.set(XO.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(XO.PLAY_TRACK_START,this.onPlayTrackStart).set(XO.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:r,remotePublishedUser:i}=e;if(!this.hitTest(t))return;let{userId:o}=i,n="".concat(o,"_").concat(r);this.stopDataFreeze({key:n,userId:o,type:r})})).set(XO.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let{userId:o}=i;if(r.hasVideo&&!i.hasVideo){let e="main",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}if(r.hasAuxiliary&&!i.hasAuxiliary){let e="auxiliary",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}})).set(XO.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,reason:i,type:o}=e;if(t.isRemote&&t.room&&this.hitTest(t.room)&&o===eC.VIDEO){if("PLAYING"===r){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}i===eC.MUTE?this.onVideoTrackMuted(t):i===eC.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(XO.HEARTBEAT_REPORT,this.onHearBeatReport).set(XO.REMOTE_VIDEO_PLAY_START,this.onRemoteVideoPlayStart).set(XO.REMOTE_VIDEO_PLAY_FINISH,this.onRemoteVideoPlayEnd),this._eventMap.forEach(((e,t)=>YO.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>YO.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r),o=this._dataFreezeMap.get(i),n=new Lz;o?o.durationItemList.push(n):this._dataFreezeMap.set(i,{userId:t,type:r,durationItemList:[n],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r);this.stopDataFreeze({key:i,userId:t,type:r})}onHearBeatReport(e){let{room:t,report:r}=e;if(this.hitTest(t)){if(r.msg_up_stream_info.msg_video_status){let e=r.msg_up_stream_info.msg_video_status,t=Array.from(this._room.localTracks).find((e=>"video"===e.kind&&!e.isScreen)),i=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||i<=0||null!=t&&t.isUseCustomSource)return;e.forEach((e=>{2===e.uint32_video_stream_type&&(0!==e.uint32_video_capture_fps&&0===e.uint32_video_codec_bitrate&&0===e.uint32_video_enc_fps&&null!=t&&t.isPublished?(this._videoEncodeFailedCount+=1,this._videoEncodeFailedCount===this._encodeFailedThreshold&&ex.uploadEvent({userId:this._room.userId,log:"stat-".concat(NC.VIDEO_ENCODE_FAILED_DURING_CALL)})):this._videoEncodeFailedCount=0)}))}if(r.msg_up_stream_info.msg_audio_status){let e=r.msg_up_stream_info.msg_audio_status,t=Array.from(this._room.localTracks).find((e=>"audio"===e.kind)),i=(null==t?void 0:t.stat.bytesSent)||0;if(!1===(null==t?void 0:t.isMediaTrackActive)||i<=0)return;0===e.uint32_audio_codec_bitrate&&null!=t&&t.isPublished?(this._audioEncodeFailedCount+=1,this._audioEncodeFailedCount===this._encodeFailedThreshold&&ex.uploadEvent({userId:this._room.userId,log:"stat-".concat(NC.AUDIO_ENCODE_FAILED_DURING_CALL)})):this._audioEncodeFailedCount=0}}}stopDataFreeze(e){let{key:t,userId:r,type:i}=e,o=this._dataFreezeMap.get(t);if(!o||!o.isFreezing())return;let n=o.durationItemList[o.durationItemList.length-1];n.stop();let a=n.getDuration();if(a>VC){let e=this._monitorFreezeData.get(t,"data");this._monitorFreezeData.set(t,{userId:r,type:i,duration:e?e.duration+a:a},"data")}else o.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let r=t.getDuration();return e+Math.min(r,5e3)}),0)}onPlayTrackStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room)||t.kind!==eC.VIDEO||!t.isRemotePublished)return;let r="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(r)||this._isVideoPlayingEventFiredMap.set(r,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},r=this._dataFreezeMap.get(e);if(r){if(r.isFreezing()){let e=r.durationItemList[r.durationItemList.length-1];e.stop(),e.getDuration()<VC&&r.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(r.durationItemList),t.count=r.durationItemList.length}return t}getRenderFreezeDuration(e){let t={renderFreeze:0,count:0},r=this._renderFreezeMap.get(e);return r&&(t.renderFreeze=r.totalDuration,t.count=r.count),t}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}onRemoteVideoPlayStart(e){let{track:t,player:r}=e;var i;if(!RP())return;let o=0,n=()=>{document.hidden||(o=0)};document.addEventListener("visibilitychange",n);let a=(e,i)=>{var n;if(o){let e=t.decodeFPS,r=e>0&&e<=5?600+1e3/e:600,n=i.presentationTime-o;if(n>r){n=Math.min(n,5e3);let e="".concat(t.userId,"_").concat(t.streamType),r=this._monitorFreezeData.get(e,"render");r?r.duration+=n:this._monitorFreezeData.set(e,{userId:t.userId,type:t.streamType,duration:n},"render");let i=this._renderFreezeMap.get(e);i?(i.totalDuration+=n,i.count+=1):this._renderFreezeMap.set(e,{userId:t.userId,type:t.streamType,totalDuration:n,count:1})}}o=i.presentationTime,null==(n=r.element)||n.requestVideoFrameCallback(a)};null==(i=r.element)||i.requestVideoFrameCallback(a),this.eventListenerMap.set("".concat(t.userId,"_").concat(t.streamType),{onVisibilityChange:n})}onRemoteVideoPlayEnd(e){let{track:t,player:r}=e,i="".concat(t.userId,"_").concat(t.streamType),o=this.eventListenerMap.get(i);o&&document.removeEventListener("visibilitychange",o.onVisibilityChange)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},Vz=tw(aw(),1),Fz=class{constructor(e,t,r,i,o){let n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:4/3;this.vbMode=e,this.faceDetectorHash=r,this.visionTaskRegistry=i,this.logger=o,iw(this,"animationState"),iw(this,"originalAspect"),iw(this,"totalOffsetX",0),iw(this,"totalOffsetY",0),iw(this,"defaultScaleRatio",.1),iw(this,"isRecovering",!1),iw(this,"boundaryY",280),iw(this,"lastActionTime",0),iw(this,"restTime",400),this.animationState={current:null,target:null,animating:!1,debounceTimer:null,startTime:0,duration:3e3,debounceTime:150,movementThreshold:30,debounceThreshold:15},this.addEvent(this.vbMode,!!this.faceDetectorHash),this.originalAspect=n||4/3,this.visionTaskRegistry.setVideo(this.faceDetectorHash,t)}addEvent(e,t,r){let i=[{key:570704,error:null!=r?r:t?void 0:11},{key:570705,error:null!=r?r:t?void 0:22}][e-1];i&&(t?RL.addSuccessEvent({key:i.key}):RL.addFailedEvent({key:i.key,error:i.error}))}actionCentering(e){let t=Date.now();if(this.animation(),!this.faceDetectorHash||t-this.lastActionTime<this.restTime||this.animationState.animating)return;let{videoWidth:r,videoHeight:i}=e;this.animationState.debounceThreshold=r/30,this.animationState.movementThreshold=r/20,this.boundaryY=.6*i;try{let e=this.visionTaskRegistry.getResult(this.faceDetectorHash);if(e.detections.length<=0)return void(1===this.vbMode&&this.recoverOriginal(r,i));let t=e.detections[0].boundingBox,o=t.originX,n=t.originY,a=t.width,s=t.height;1===this.vbMode?this.dualStageCropping(r,i,o,n,a,s):2===this.vbMode&&this.movingPortrait(r,i,o,n,a,s)}catch(hM){this.logger.error(hM)}this.lastActionTime=t}calculateBoundary(e,t,r,i){let o,n;return e>t/2?(o=t-r-i,n=r-o):(o=r,n=0),{min:o,offset:n}}calculateTargetPosition(e,t,r,i,o,n){let a,s,l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.4,c=e+r/2,d=t+i/2,{min:u,offset:h}=this.calculateBoundary(c,o,e,r),{min:p,offset:m}=this.calculateBoundary(d,n,t,i);return a=2*u+r,s=2*p+i,a/s>this.originalAspect?(a=s*this.originalAspect,h=c-a/2):(s=a/this.originalAspect,m=d-s/2),r/o>l&&(h=0,m=0,a=o,s=n),h=Math.max(0,Math.min(h,o-a)),m=Math.max(0,Math.min(m,n-s)),{sx:h,sy:m,cropWidth:a,cropHeight:s,timestamp:Date.now()}}processFacePositionCrop(e,t,r){if(!this.animationState.current||!this.animationState.target){let e={sx:0,sy:0,cropWidth:t,cropHeight:r,timestamp:Date.now()};return this.animationState.current=e,void(this.animationState.target=e)}let i=this.positionDistance(this.animationState.target,e),o=this.positionDistance(this.animationState.current,e),n=this.animationState.current.cropWidth/t;i>this.animationState.debounceThreshold*n&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&o>this.animationState.movementThreshold*n&&(this.animationState.target=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}processFacePositionPortrait(e){if(!this.animationState.current||!this.animationState.target)return this.animationState.current=Qb({},e),void(this.animationState.target=Qb({},e));let t=this.positionDistance(this.animationState.current,e),r=this.positionDistance(this.animationState.target,e);t>this.animationState.debounceThreshold&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&r>this.animationState.movementThreshold&&(this.animationState.current=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}animation(){if(!this.animationState.animating)return;let e=Date.now()-this.animationState.startTime,t=Math.min(e/this.animationState.duration,1),r=e=>e<.5?2*e*e:(4-2*e)*e-1;if(this.animationState.current&&this.animationState.target){let e=(this.animationState.target.sx-this.animationState.current.sx)*r(t);this.animationState.current.sx+=e,this.totalOffsetX+=e;let i=(this.animationState.target.sy-this.animationState.current.sy)*r(t);if(this.animationState.current.sy+=i,this.totalOffsetY+=i,this.animationState.current.cropWidth+=(this.animationState.target.cropWidth-this.animationState.current.cropWidth)*r(t),this.animationState.current.cropHeight+=(this.animationState.target.cropHeight-this.animationState.current.cropHeight)*r(t),this.animationState.current.scaleRatio&&this.animationState.target.scaleRatio&&(this.animationState.current.scaleRatio+=(this.animationState.target.scaleRatio-this.animationState.current.scaleRatio)*r(t)),KD(this.animationState.current.scaleOffsetX)&&KD(this.animationState.target.scaleOffsetX)&&KD(this.animationState.current.scaleOffsetY)&&KD(this.animationState.target.scaleOffsetY)){let e=(this.animationState.target.scaleOffsetX-this.animationState.current.scaleOffsetX)*r(t);this.animationState.current.scaleOffsetX+=e;let i=(this.animationState.target.scaleOffsetY-this.animationState.current.scaleOffsetY)*r(t);this.animationState.current.scaleOffsetY+=i}}t>=1&&(this.animationState.animating=!1,this.animationState.current=this.animationState.target,this.isRecovering=!1)}positionDistance(e,t){return Math.sqrt(Jb(e.sx-t.sx,2)+Jb(e.sy-t.sy,2))}recoverOriginal(e,t){this.animationState.target={sx:0,sy:0,cropWidth:e,cropHeight:t,timestamp:Date.now()},this.animationState.animating=!0,this.animationState.startTime=Date.now(),this.isRecovering=!0}dualStageCropping(e,t,r,i,o,n){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.3;if(this.isRecovering)return;let s=this.calculateTargetPosition(r,i,o,n,e,t);this.processFacePositionCrop(s,e,t),o*n/s.cropWidth/s.cropHeight>a&&this.recoverOriginal(e,t)}movingPortrait(e,t,r,i,o,n){var a,s,l,c,d,u,h,p,m,f,_,g;let E={sx:r+o/2+this.totalOffsetX,sy:i+n/2+this.totalOffsetY,cropWidth:e,cropHeight:t,scaleRatio:null!=(s=null==(a=this.animationState.current)?void 0:a.scaleRatio)?s:1,scaleOffsetX:null!=(c=null==(l=this.animationState.current)?void 0:l.scaleOffsetX)?c:0,scaleOffsetY:null!=(u=null==(d=this.animationState.current)?void 0:d.scaleOffsetY)?u:0,timestamp:Date.now()};this.animationState.target={sx:e/2,sy:i+n/2,cropWidth:e,cropHeight:t,scaleRatio:null!=(p=null==(h=this.animationState.target)?void 0:h.scaleRatio)?p:1,scaleOffsetX:null!=(f=null==(m=this.animationState.target)?void 0:m.scaleOffsetX)?f:0,scaleOffsetY:null!=(g=null==(_=this.animationState.target)?void 0:_.scaleOffsetY)?g:0,timestamp:Date.now()},this.animationState.animating||(this.animationState.target.scaleRatio=Math.sqrt(o*n/e/t/this.defaultScaleRatio),this.animationState.target.scaleOffsetX=-this.animationState.target.scaleRatio/2+.5,this.animationState.target.scaleOffsetY=1-this.animationState.target.scaleRatio,(this.animationState.target.sy-this.animationState.target.scaleOffsetY*this.animationState.target.cropHeight)/this.animationState.target.scaleRatio<this.boundaryY&&(this.animationState.target.scaleOffsetY=(this.animationState.target.sy-this.boundaryY*this.animationState.target.scaleRatio)/this.animationState.target.cropHeight)),this.processFacePositionPortrait(E)}set aspectRatio(e){this.originalAspect=e}get current(){return this.animationState.current}get offset(){return{offsetX:this.totalOffsetX,offsetY:this.totalOffsetY}}get targetCrop(){return this.animationState.target}},Bz=class extends RB{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,width:t.width,height:t.height,logger:e.log}),iw(this,"_bgTexture"),iw(this,"_waterMarkTexture"),iw(this,"_lastMaskTexture"),iw(this,"_lastMaskFbo"),iw(this,"_textureValid",!1),iw(this,"_selfieTextureValid",!1),iw(this,"_selfieSegmentationHash"),iw(this,"wasm"),iw(this,"predictReady"),iw(this,"_color"),iw(this,"_prePrograme"),iw(this,"_segmentationMask"),iw(this,"_weixin",!1),iw(this,"_centerFace"),iw(this,"_textureMatrixLocation"),iw(this,"_offsetMatrixLocation"),iw(this,"_colorLocation"),iw(this,"_enableFaceCentering",!1),iw(this,"_enableEffectOptimization",!1),iw(this,"_mat4"),iw(this,"_postProcessing"),iw(this,"_onAbort"),iw(this,"_visionTaskRegistry"),iw(this,"resolvePreditReady"),this.init(t).catch((t=>{e.log.error(t),e.destroy(new mw({code:hw.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(t.message||t)})),this.resolvePreditReady()}))}init(e){return nw(this,null,(function*(){var t,r,i;this.predictReady=new Promise((e=>{this.resolvePreditReady=e}));let o=e.Wasm,n=this.context.ctx;if(e.color&&(this._color=e.color),e.mat4&&(this._mat4=e.mat4),e.postProcessing&&(this._postProcessing=e.postProcessing),this._enableFaceCentering=null!=(t=e.enableFaceCentering)&&t,this._enableEffectOptimization=null!=(r=e.enableEffectOptimization)&&r,this.wasm=new o.AllIn1(n),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.rotation=e.rotation||0,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"color"===e.bg?3:0,this._onAbort=e.onAbort,e.bg||this.resolvePreditReady(),e.waterMark){let{x:t,y:r,width:i,height:o}=e.waterMark;this.wasm.setWaterMark(t,r,i,o)}if(e.beautyParams){let{beauty:t,brightness:r,ruddy:i}=e.beautyParams;this.wasm.setBeauty(t,r,i,null==e?void 0:e.width,null==e?void 0:e.height)}this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(n.uniform1i(n.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(n.uniform1i(n.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image));let a=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);if(this._textureMatrixLocation=n.getUniformLocation(this.program,"u_textureMatrix"),n.uniformMatrix4fv(this._textureMatrixLocation,!1,a),this._offsetMatrixLocation=n.getUniformLocation(this.program,"u_offsetMatrix"),n.uniformMatrix4fv(this._offsetMatrixLocation,!1,a),this._colorLocation=n.getUniformLocation(this.program,"u_color"),n.uniform1i(n.getUniformLocation(this.program,"lastMask"),4),this._weixin){let e=this.context.createShader(n.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),t=this.context.createShader(n.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(t,e),n.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),n.uniform1i(n.getUniformLocation(this._prePrograme,"mask"),1)}!this._enableEffectOptimization||2!==this.wasm.vbMode&&3!==this.wasm.vbMode?this._postProcessing=void 0:LO()?(this._postProcessing=void 0,this.log.warn("Virtual background post-processing isn't allowed on mobile.")):null==(i=this._postProcessing)||i.init(n,this.positionBuffer,this.texCoordBuffer,4/3),yield this.initVisionTasks(e)}))}initVisionTasks(e){return nw(this,null,(function*(){if(e.bg){if(this._visionTaskRegistry=yield window.VisionTaskRegistry.getInstance(),!window.VisionTaskRegistry||!this._visionTaskRegistry||!this._visionTaskRegistry.visionWasm)throw new Error("Virtual background assets not found. Please redeploy the assets of the npm package.");if(this._selfieSegmentationHash=yield this._visionTaskRegistry.register(window.VisionTaskType.ImageSegmenter,{canvas:this.context._canvas}),this._visionTaskRegistry.setVideo(this._selfieSegmentationHash,this.image),this._enableFaceCentering)try{this._visionTaskRegistry.models.has(window.VisionTaskType.FaceDetector)||(yield this._visionTaskRegistry.preloadModels([window.VisionTaskType.FaceDetector]));let e=yield this._visionTaskRegistry.register(window.VisionTaskType.FaceDetector);if(!e)return;this._centerFace=new Fz(this.wasm.vbMode,this.image,e,this._visionTaskRegistry,this.context.log)}catch(CC){this.log.error("Face detector model not found. Please redeploy the assets of the npm package.")}}}))}onPredict(e){let t=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture)));let r=this.getMaskTexture(e);if(!r)return;let i=r;this._postProcessing&&(this._postProcessing.ratio=this.image.videoWidth/this.image.videoHeight,i=this._postProcessing.postProcessing(r)),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),this.useTexture(),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,i||null),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),3===this.wasm.vbMode&&t.uniform3fv(this._colorLocation,this._color),this.useBufferFrame(),this._segmentationMask=e,this.totalFrames++,this.centerFace(),DN(this.wasm.rotation)&&this.resize(this.image.height,this.image.width),t.viewport(0,0,t.canvas.width,t.canvas.height),t.drawArrays(t.TRIANGLE_STRIP,0,4),e.close()}getMaskTexture(e){return e.confidenceMasks?e.confidenceMasks[0].getAsWebGLTexture():void 0}onFirstFrame(){this.waitingFirstFrame=!1;let e=this.context.ctx;this.useTexture(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}render(e){let t=this.context.ctx,{image:r}=this;this.tryVideoFrameCallback();let{videoWidth:i,videoHeight:o}=r;if(DN(this.wasm.rotation)&&!this._visionTaskRegistry&&([i,o]=[o,i]),0===i||0===o||!this.available)return!1;r.width=i,r.height=o;let n=!1;if(this.totalFrames)this.useTexture(),n=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),n=this._textureValid,this._textureValid=!0}if(this.width===i&&this.height===o&&n?t.texSubImage2D(t.TEXTURE_2D,0,0,0,t.RGBA,t.UNSIGNED_BYTE,r):(this.resize(i,o),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r)),this._weixin){if(t.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask){let e=this.getMaskTexture(this._segmentationMask);t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,e||null),t.bindFramebuffer(t.FRAMEBUFFER,this._lastMaskFbo||null)}t.drawArrays(t.TRIANGLE_STRIP,0,4),this.useTexture(),this._segmentationMask?t.copyTexSubImage2D(t.TEXTURE_2D,0,0,0,0,0,i,o):t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,i,o,0)}try{if(this._selfieSegmentationHash&&this._visionTaskRegistry){let e=this._visionTaskRegistry.getResult(this._selfieSegmentationHash);1===this.totalFrames&&this.context._canvas&&this.resolvePreditReady(),this.onPredict(e)}}catch(uM){this._onAbort&&this._onAbort(uM)}return this.totalFrames||(t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this._bgTexture||null),t.activeTexture(t.TEXTURE3),t.bindTexture(t.TEXTURE_2D,this._waterMarkTexture||null),t.drawArrays(t.TRIANGLE_STRIP,0,4)),this._visionTaskRegistry&&this._visionTaskRegistry.resetHashResults(),!1}centerFace(){if(!this._centerFace||!this._enableFaceCentering)return;let e=this.context.ctx;this._centerFace.aspectRatio=e.canvas.width/e.canvas.height,this._centerFace.actionCentering(this.image);let{current:t,offset:r}=this._centerFace;if(t&&(1===this.wasm.vbMode&&this.drawImage(t.sx,t.sy,t.cropWidth,t.cropHeight),r&&2===this.wasm.vbMode)){if(!this._mat4)return;let i=this._mat4.create(),{scaleRatio:o=1,scaleOffsetX:n=0,scaleOffsetY:a=0}=t;this._mat4.fromTranslation(i,[-r.offsetX/e.canvas.width+n,a,0]),this._mat4.scale(i,i,[o,o,1]),e.uniformMatrix4fv(this._offsetMatrixLocation,!1,i)}}drawImage(e,t,r,i){let o=this.context.ctx;if(!this._mat4)return;let{width:n,height:a}=o.canvas,s=this._mat4.create();this._mat4.fromTranslation(s,[e/n,1-(t+i)/a,0]),this._mat4.scale(s,s,[r/n,i/a,1]),o.uniformMatrix4fv(this._textureMatrixLocation,!1,s)}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),this._postProcessing&&this._postProcessing.close(),null==(e=this.wasm)||e.close()}},Hz=class extends fB{constructor(e){super(e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}),iw(this,"yTextureRef"),iw(this,"uTextureRef"),iw(this,"vTextureRef"),iw(this,"Y"),iw(this,"U"),iw(this,"V"),this.useProgram();let t=this.context.ctx;t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),this.setTexBuffer([0,1,1,1,0,0,1,0]),this.yTextureRef=this._initTexture("ySampler",0),this.uTextureRef=this._initTexture("uSampler",1),this.vTextureRef=this._initTexture("vSampler",2),this._canvas=e._canvas}_initTexture(e,t){let r=this.context.ctx,i=r.createTexture();return r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),r.uniform1i(r.getUniformLocation(this.program,e),t),i}render(e){let t=this.context.ctx,r=this.width,i=this.height;return this.useProgram(),t.viewport(0,0,r,i),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r,i,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}resize(e,t){super.resize(e,t);let r=this.context.ctx;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.yTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e,t,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this.uTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this.vTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null)}},Wz=(e,t)=>{switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")};var Gz=0,jz=class{constructor(e){iw(this,"id",Gz++),iw(this,"trackDoneOB"),iw(this,"startOB"),iw(this,"stopOB"),iw(this,"decoder"),iw(this,"videoContext"),iw(this,"gop",0),iw(this,"gop_helper",0),iw(this,"waitFirstKeyFrame",!0),iw(this,"startTimestamp",0),iw(this,"startTime",0),iw(this,"startPerformanceTime",0),iw(this,"inputFrameCount",0),iw(this,"decodedFrameCount",0),iw(this,"decodeFrameCount",0),iw(this,"downgradeLevel",0),iw(this,"lastDowngradeTime",0),iw(this,"lastFrameDiff",0),iw(this,"lastDecodeFrameTimestamp",0),iw(this,"config"),iw(this,"gop_before_configure",[]),iw(this,"videoElement"),iw(this,"type","wasm"),iw(this,"goodType"),iw(this,"renderer","2d"),iw(this,"wasmOption"),iw(this,"createDecoder"),iw(this,"_decodeSink"),iw(this,"isReported",!1),iw(this,"track"),iw(this,"stateChangeOB"),iw(this,"failedReason");let{track:t,createDecoder:r}=e;if(this.stateChangeOB=_V(),this.track=t,this.createDecoder=r,this.wasmOption={yuvMode:"webgl"===e.renderer,wasmPath:e.wasmPath,workerMode:e.workerMode,canvas:e.canvas},this.config=e.config,this.videoElement=e.videoElement,this.renderer=e.renderer,this.trackDoneOB=DV(t.availableState,WP.OFF),this.stopOB=_V(),"auto"===e.type){switch(e.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=e.type;this.changeRenderer(this.renderer),JU(this.stateChangeOB,vF(((e,r)=>(e!==r&&t.onDecodeDowngradeStateChanged({type:this.type,renderer:this.renderer,reason:this.failedReason,prevState:e,state:r}),r)),"INITIALIZED"),QV(this.stopOB),$F()),this.start()}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");let t=JU(this.pipe(this.track),QV(this.stopOB),iV());JU(t,$F((()=>{this.track.stat.framesDecoded++}),(t=>{if(this.track.log.error("".concat(this.id," play failed: ").concat(t," retryCount: ").concat(e)),RL.addFailedEvent({key:Wz(this.type,this.renderer),error:t}),e>4)this.failedReason=t,this.stateChangeOB.next("FAILED"),RL.addFailedEvent({key:514704});else{if(this.goodType)return void this.start(e);switch(this.type){case"webCodecs":this.type="wasm",this.changeRenderer("webgl");break;case"wasm":if("webgl"===this.renderer)this.changeRenderer("videoFrame")}this.start(e+1)}}),(()=>{this.track.log.warn("".concat(this.id," decoderOB completed")),RL.addSuccessEvent({key:Wz(this.type,this.renderer)}),RL.addSuccessEvent({key:514704})}))),JU(t,XV(1),$F((()=>{this.track.player.handlePlaying("canvas"),this.goodType=this.type,this.stateChangeOB.next("STARTED")})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.start()}close(e){this.stopOB.next(e)}changeRenderer(e){this.renderer=e,"videoFrame"===this.renderer&&!LL()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}decode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;if(this.failedReason)return;this.inputFrameCount++;let o=new Uint8Array(e.data);if(!function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]}(o)||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;let n=!1;switch(31&o[4]){case 5:case 7:n=!0}if("configured"!==(null==(r=this.decoder)?void 0:r.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),n&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!t&&(this.gop_before_configure.forEach((e=>this.decode(e,!0))),this.gop_before_configure=[]);let{timestamp:a}=e;if(n?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!n)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=a,this.startTime=Date.now(),this.startPerformanceTime=oN()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(a," ").concat(null==(i=e.getMetadata)?void 0:i.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=a,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}checkDowngradeByFrameDiff(){let e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}checkDowngradeByTimestampDiff(e){let t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}pipe(e){return t=>nw(this,null,(function*(){this._decodeSink=t;let r,i=e.mediaTrack;t.defer((()=>{var t;i&&(e.player.setCanvas(),e.setInputMediaStreamTrack(i)),null==r||r.close(),null==(t=this.videoContext)||t.destroy(),delete this._decodeSink}));let{renderer:o,type:n}=this;e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer));try{switch(n){case"wasm":r=this.createDecoder(n,this.wasmOption);break;case"webCodecs":r=this.createDecoder(n);break;default:throw new Error("not supported yet")}let i=0;if(r.on("videoFrame",(r=>{this.decodedFrameCount++,i++,(i<=10||i%500==0)&&e.log.debug("frame ".concat(i," ").concat(this.decodedFrameCount,"/").concat(this.decodeFrameCount," decoded ").concat(r.timestamp)),Date.now()-this.lastDowngradeTime>5e3&&("webCodecs"===this.type?this.checkDowngradeByFrameDiff():"wasm"===this.type&&this.checkDowngradeByTimestampDiff(r.timestamp)),t.next(r)})),r.on("error",(r=>{e.log.error(r),t.error("webCodecs"===n?4:8)})),yield r.initialize(this.videoElement),!this._decodeSink)return;if(r.configure(this.config),"wasm"===n&&"webgl"===o){this.videoContext=new NB({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(NB.UNAVAILABLE,(r=>{e.log.error(r),t.error(7)}));let i=new Hz(this.videoContext);r.on("videoCodecInfo",(e=>i.resize(e.width,e.height))),r.on("videoFrame",(e=>{({y:i.Y,u:i.U,v:i.V}=e),1===this.downgradeLevel?this.decodedFrameCount%2==0&&i.render(this.decodedFrameCount):i.render(this.decodedFrameCount)})),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}else if("videoFrame"===o){e.player.setCanvas();let t=new MediaStreamTrackGenerator({kind:"video"}),i=t.writable.getWriter();e.setInputMediaStreamTrack(t),r.on("videoFrame",(e=>i.write(e)))}else{this.videoContext=new kB({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1});let i=this.videoContext.createVideoImageSource();r.on("videoFrame",(r=>{try{i.image=r,i.update()}catch(o){delete this.goodType,e.log.error(o),t.error(11)}}));let o=new vB(this.videoContext,{name:"remotePlayer",logger:e.log});i.connect(o),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}this.decoder=r}catch(lM){e.log.error(lM),t.error("webCodecs"===n?2:6)}}))}},zz=Promise.resolve(),Kz=class extends Vz.EventEmitter{constructor(e){super(),this.room=e,iw(this,"videoContext"),iw(this,"_glVideoContext"),iw(this,"_2dVideoContext"),iw(this,"destination"),iw(this,"smallVideoContext"),iw(this,"smallDestination"),iw(this,"smallTrackSource"),iw(this,"smallImageSource"),iw(this,"_isMirror",!1),iw(this,"_rotation",0),iw(this,"cameraTrack"),iw(this,"cameraNode"),iw(this,"transformNode"),iw(this,"mixNode"),iw(this,"screenTrack"),iw(this,"screenNode"),iw(this,"selfModel",!1),iw(this,"blurRadius",3),iw(this,"arTrack"),iw(this,"_enableFaceCentering",!1),iw(this,"_enableEffectOptimization",!1),iw(this,"onAbort"),iw(this,"_color"),iw(this,"Wasm"),iw(this,"waterMarkNode"),iw(this,"_waterMarkOption"),iw(this,"watermarkImageList",[]),iw(this,"_beautyParams"),iw(this,"isUsingArTrack",!1),iw(this,"mixTrack"),iw(this,"_isMixScreen",!1),iw(this,"_virtualBackground"),iw(this,"_virtualBackgroundAbortCallback"),iw(this,"virtualBackgroundInstance"),iw(this,"_bgAssetPath"),iw(this,"log"),iw(this,"_mat4"),iw(this,"_postProcessing"),iw(this,"_checkId",0),iw(this,"_use2d",!1),iw(this,"_autoSwitchRenderMode",!0),iw(this,"encodePipeline",[]),iw(this,"decodePipeline",[]),iw(this,"updated",zz),iw(this,"_updateFlag",!1),this.log=ZO.createLogger({parent:null==e?void 0:e.getLogger(),id:"vm",userId:null==e?void 0:e.userId,sdkAppId:null==e?void 0:e.sdkAppId}),this.smallVideoContext=new kB({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get smallMode(){var e;return(null==(e=this.room)?void 0:e.smallMode)||"canvas"}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get _isRotate(){return 0!==this._rotation}get _isTransform(){return this._isMirror||this._isRotate}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get cameraResolution(){var e;let{width:t,height:r}=(null==(e=this.cameraTrack)?void 0:e.settings)||{};return DN(this._rotation)?{width:r,height:t}:{width:t,height:r}}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new kB({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new NB({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}initializeGlVideoContext(){try{this._glVideoContext.create(_O<=22),this._glVideoContext.on(NB.UNAVAILABLE,(e=>{var t;this.emit("error",e),this.log.warn("video context unavailable",e),null==(t=this._virtualBackgroundAbortCallback)||t.call(this,e),this.update().catch((e=>{this.log.error(e)}))}))}catch(Sw){this.emit("error",Sw)}}initVirtualBackground(e,t,r){this.onAbort=e,this._mat4=t,this._postProcessing=r}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=YP.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),YP.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(EO||this._isMixScreen||this._isTransform||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?RL.addFailedEvent({key:t,error:e}):RL.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new NB({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}setSmallVideo(e,t){if("api"!==this.smallMode)if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new IB(this.smallVideoContext,e,this.log),this.smallVideoContext.on(NB.UNAVAILABLE,(e=>{this.log.warn("small video context lost",e)}))}if(this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t)this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.resize(t.width,t.height),this.smallImageSource.connect(this.smallDestination));else if(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource)this.smallTrackSource.replaceTrack(this.initialTrack);else{this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource");let{width:e,height:t}=this.cameraTrack.settings;this.smallTrackSource.resize(e,t),this.smallTrackSource.connect(this.smallDestination)}}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}_setMainOutput(e){var t;try{let r=this.cameraTrack,{small:i,player:o}=r;EO&&o.setCanvas(e);let n=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),n=this.arTrack),this.log.info("set main output ".concat(n?n.label:"no output track")),this.setSmallVideo(i,e),r.setOutputMediaStreamTrack(n)}catch(cM){this.log.error("set main output failed",cM)}}update(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return nw(this,null,(function*(){var t;if(!this.cameraTrack||!this.initialTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:r,profile:i}=this.cameraTrack;if(this._use2d||!this._virtualBackground&&!this._beautyParams)this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}),this.destination.on(fB.RENDER,(e=>{var t;null==(t=this.cameraTrack)||t.emit("render",e)}))),16===SO?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof RB?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof RB?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(r.width,r.height);else if(e&&this.cameraNode&&this.destination)this.cameraNode.replaceTrack(this.initialTrack);else{this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():(this.destination=new TB(this.videoContext,{name:"mainDestination",logger:this.log}),this.destination.on(fB.RENDER,(e=>{var t;null==(t=this.cameraTrack)||t.emit("render",e)})));let{width:e,height:t}=this.cameraResolution,r=yield this.getWatermarkImage(e,t);this._waterMarkOption={x:0,y:0,width:r.width,height:r.height,image:r},this.cameraNode=new Bz(this.videoContext,{input:this.initialTrack,width:e,height:t,mirror:this._isMirror,rotation:this._rotation,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,Wasm:this.Wasm,enableFaceCentering:this._enableFaceCentering,enableEffectOptimization:this._enableEffectOptimization,onAbort:this.onAbort,mat4:this._mat4,postProcessing:this._postProcessing,color:this._color}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute(),yield this.cameraNode.predictReady}if(this.videoContext.frameRate=i.frameRate,this._use2d){let e=this.cameraNode;if(e.disconnect(),this._isTransform&&(this.transformNode?(this.transformNode.mirror=this._isMirror,this.transformNode.rotation=this._rotation):this.transformNode=new xB(this.videoContext,this.log,this._isMirror,this._rotation),e=e.connect(this.transformNode),e.disconnect(),this.log.info("start mirror ".concat(this._isMirror," rotate ").concat(this.rotation))),this.mixNode&&this.mixNode.close(),delete this.mixNode,this._isMixScreen||this._hasWaterMark){if(this.mixNode=new LB(this.videoContext,this.log),e.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption)this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y;else if(this.waterMarkNode){let{width:e,height:t}=this.cameraResolution;this.waterMarkNode.image=yield this.getWatermarkImage(e,t),e&&t&&this.waterMarkNode.resize(e,t)}null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&(this.screenNode||(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource"),this.screenNode.resize(this.screenTrack.settings.width,this.screenTrack.settings.height)),this.screenNode.shouldUpdate=!1,this.screenNode.connect(this.mixNode,{zIndex:0})),e=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))}e.connect(this.destination)}return this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext.canvas)}))}clearLastFrame(){var e;this.destination&&(null==(e=this.destination.ctx2d)||e.clearRect(0,0,this.destination.width,this.destination.height))}changeInput(e){var t,r,i,o,n;if(e instanceof BB)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof dB)return this.log.info("change video input",null==(r=e.mediaTrack)?void 0:r.label),this.setCameraTrack(e);if(e instanceof JB){this.log.info("change remote input",null==(i=e.mediaTrack)?void 0:i.label);let t=e.mediaTrack;return e.setOutputMediaStreamTrack(t)}if(e instanceof UB)return this.log.info("change mix input",null==(o=e.outMediaTrack)?void 0:o.label),this.setMixTrack(e);this.log.warn("change unknown input",null==(n=e.mediaTrack)?void 0:n.label)}removeInput(e){var t;e instanceof BB?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof dB?this._isMixScreen?(delete this.cameraNode,this.cameraTrack._inputTrack=null,this.update()):(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof JB?e.source&&e.source.context.destroy():e instanceof UB&&(delete this.mixTrack,this.update())}setMixTrack(e){this.mixTrack=e}setCameraTrack(e){return this.cameraTrack=e,this.update(!0)}setScreenTrack(e){return nw(this,null,(function*(){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):yield this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}))}getWatermarkImage(e,t){return nw(this,null,(function*(){let r=document.createElement("canvas");t&&e&&(r.height=t,r.width=e);let i=r.getContext("2d");if(!i)throw new mw({code:hw.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((r=>{let{image:o,x:n,y:a,width:s,height:l,fillVideo:c}=r,d=c&&e||s,u=c&&t||l,h=c?0:n,p=c?0:a;i.drawImage(o,h,p,d,u)})),TN(r.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex&&t.fillVideo===e.fillVideo))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setBeautyParams(e){return nw(this,null,(function*(){this._beautyParams=e,this.update()}))}stopBeauty(){return nw(this,null,(function*(){this._beautyParams=void 0,this.update()}))}setWatermark(e){return nw(this,null,(function*(){let t;try{t=yield TN((null==e?void 0:e.imageElement)||e.imageUrl)}catch(oM){throw new mw({code:hw.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:r=0,y:i=0,width:o=t.width,height:n=t.height,type:a="watermark",zIndex:s=2,fillVideo:l=!1}=e;this.watermarkImageList.some((e=>e.type===a))?(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==a)),this.pushWaterMarkImageList({x:r,y:i,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl,fillVideo:l}),t=yield this.getWatermarkImage(this.cameraResolution.width,this.cameraResolution.height),this._waterMarkOption={x:0,y:0,width:t.width,height:t.height,image:t},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(t.width,t.height),this.waterMarkNode.image=t):this.update()):(this.pushWaterMarkImageList({x:r,y:i,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl,fillVideo:l}),yield this.freshWatermark()),this.log.info("set watermark",JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t)))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return nw(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t))),yield this.freshWatermark()}))}freshWatermark(){return nw(this,null,(function*(){var e;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let{width:t,height:r}=this.cameraResolution,i=yield this.getWatermarkImage(t,r);this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update()}))}setVirtualBackground(e){return nw(this,null,(function*(){var t,r,i;if(e){if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield TN(e.imageUrl):(this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type),this._enableFaceCentering=null!=(t=e.enableFaceCentering)?t:this._enableFaceCentering,this._enableEffectOptimization=null!=(r=e.enableEffectOptimization)?r:this._enableEffectOptimization,this._color=null!=(i=e.color)?i:[0,1,0]}else delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;if(this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),yield this.update(),this._virtualBackground&&!this._glVideoContext.available)throw new mw({code:hw.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)})}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get mirror(){return this._isMirror}set rotation(e){var t;this._rotation!==e&&(this._rotation=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get rotation(){return this._rotation}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return nw(this,null,(function*(){var e;null!=(e=this.cameraTrack)&&e.mediaTrack&&(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}createDecodeContext(e){return new jz(e)}clear(){var e,t;null==(e=this.videoContext)||e.disconnect(),null==(t=this.destination)||t.removeAllListeners(),delete this.destination,delete this.cameraNode,delete this.transformNode,delete this.screenNode,delete this.waterMarkNode}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}};rw([function(e){return DU(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return nw(this,null,(function*(){try{return yield t.apply(this,i)}catch(cM){e.call(this,cM)}}))}))}((function(e){this.log.error("update failed",e)})),DU((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return nw(this,null,(function*(){this._updateFlag||(this._updateFlag=!0,yield zz,this.updated=new Promise(((t,i)=>{e.apply(this,r).then(t,i),setTimeout(i,5e3,new mw({code:hw.API_CALL_TIMEOUT,message:"update timeout"}))})),this._updateFlag=!1,yield this.updated)}))}))],Kz.prototype,"update",1);var qz=0,Yz=class extends WP{constructor(e){super("room"),iw(this,"seq",++qz),iw(this,"sdkAppId"),iw(this,"userId"),iw(this,"userSig"),iw(this,"privateMapKey"),iw(this,"latencyLevel"),iw(this,"tinyId"),iw(this,"scene"),iw(this,"roomId"),iw(this,"useStringRoomId"),iw(this,"role","anchor"),iw(this,"joinParams",null),iw(this,"localPublishFlag",0),iw(this,"localTracks",new Set),iw(this,"enableAutoPlayDialog",!0),iw(this,"autoReceiveAudio",!0),iw(this,"autoReceiveVideo",!0),iw(this,"proxy_ws"),iw(this,"proxy_wt"),iw(this,"proxy_unified"),iw(this,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0,isH265EncodeSupported:!0,isH265DecodeSupported:!0}}),iw(this,"keyPointManager"),iw(this,"audioManager"),iw(this,"videoManager"),iw(this,"callDurationCalculator"),iw(this,"badCaseDetector"),iw(this,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),iw(this,"videoDecodeFallbackType"),iw(this,"smallMode","canvas"),iw(this,"enableChorus",!1),iw(this,"_isUsingCachedSchedule",!1),iw(this,"_log"),iw(this,"_joinedTimestamp",0),iw(this,"_sdkType"),iw(this,"heartbeatReport"),iw(this,"heartbeatCount",0),iw(this,"quality"),iw(this,"enableSEI"),iw(this,"isDestroyed",!1),this._log=ZO.createLogger({parent:e.logger,id:"r".concat(this.seq)}),this.useStringRoomId=!!e.useStringRoomId,qD(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),qD(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),qD(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new Mz({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new Pz({room:this}),this.badCaseDetector=new Uz({room:this}),this.audioManager=new jB(this),this.videoManager=new Kz(this)}get videoCodec(){return"h264"}get scriptTransformWorker(){}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}get localMainAudioTrack(){for(let e of this.localTracks)if(1&e.mediaType)return e;return null}get localMainVideoTrack(){for(let e of this.localTracks)if(4&e.mediaType)return e;return null}get localAuxVideoTrack(){for(let e of this.localTracks)if(2&e.mediaType)return e;return null}get publishState(){let e={audio:!1,bigVideo:!1,smallVideo:!1,auxVideo:!1};return this.localTracks.forEach((t=>{if(t.isPublished||t.isPublishing)switch(t.mediaType){case 1:e.audio=!0;break;case 4:e.bigVideo=!0,e.smallVideo=t.hasSmall;break;case 2:e.auxVideo=!0}})),e}get muteState(){var e,t,r;return{audio:!(null==(e=this.localMainAudioTrack)||!e.muted),bigVideo:!(null==(t=this.localMainVideoTrack)||!t.muted),auxVideo:!(null==(r=this.localAuxVideoTrack)||!r.muted)}}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return nw(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return nw(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return nw(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(zD(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(FD(e)){let{websocketProxy:t,webtransportProxy:r,loggerProxy:i,scheduleProxy:o,unifiedProxy:n}=e;this.proxy_ws=t,this.proxy_wt=r,this.proxy_unified=n,n?(Tj([n,n]),Nw("https://".concat(n))):(i&&Nw(i),o&&Tj(o))}YO.once(XO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:yj.main,sched_back_domain:yj.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return nw(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return nw(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let r of this.quality.downlinkInfo)t.downlinksRTT[r.userId]=r.rtt;return t}))}getRemoteVideoStats(){return nw(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let r={};return e.remotePublishedUserMap.forEach((e=>{let i="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=i.stat})),r}()}))}checkDestroy(){if(this.isDestroyed)throw new mw({code:hw.INVALID_OPERATION,message:mL({key:dL.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(uL.INVALID_DESTROY),new mw({code:hw.INVALID_OPERATION,message:mL({key:dL.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,YO.emit(XO.ROOM_DESTROY,{room:this})}schedule(e,t){return nw(this,null,(function*(){var r,i,o,n;let a=oN();try{let{isCached:s,result:l,detailCost:c}=yield vj({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:Iw,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});this._isUsingCachedSchedule=s,this._log.info("schedule cache:".concat(+s," ").concat(gN(l,{keysToExclude:["username","credential"]}))),s&&YO.once(XO.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=Qb(Qb({},this.scheduleResult),l),KD(null==(r=l.config)?void 0:r.retryCount)&&bC(l.config.retryCount),zD(null==(i=l.config)?void 0:i.loggerDomain)&&Nw(l.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=l.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,this.smallMode=(null==(n=l.config)?void 0:n.smallMode)||this.smallMode,YO.emit(XO.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:c}),RL.addSuccessEvent({key:521700,cost:oN()-a})}catch(nM){throw RL.addFailedEvent({key:521700,error:nM}),nM}}))}sendAbilityStatus(e){}enableInsertableStreams(){return Promise.resolve()}switchRoom(e){return Promise.reject()}isSwitchRoomSupported(){return!1}};var Jz={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},Xz="__INLINE__WORKER__",Qz="__INLINE__WASM__",{debug:$z}=console;Jz.debug||(console.debug=()=>{});var Zz,eK=!Xz.startsWith("__"),tK=!Qz.startsWith("__");function rK(){let e=bN("".concat(Jz.assetsPath?"".concat(Jz.assetsPath,"/"):"","worker.js"));return eK?URL.createObjectURL(new Blob([atob(Xz)],{type:"application/javascript"})):e.startsWith("http")?fetch(e).then((e=>e.blob().then((e=>URL.createObjectURL(e))))):e}function iK(){return nw(this,null,(function*(){let e=Jz.assetsPath?"".concat(Jz.assetsPath,"/"):"";return Zz||(Zz=tK?(new TextEncoder).encode(atob(Qz)).buffer:yield fetch(bN("".concat(e,"av_processing.wasm"))).then((e=>e.arrayBuffer())),Zz)}))}var oK=new class{constructor(){iw(this,"playPort"),iw(this,"playPortSent",!1),iw(this,"worklet"),iw(this,"workletPromise")}init(){return this.workletPromise||(this.workletPromise=this._init()),this.workletPromise}_init(){return nw(this,null,(function*(){let e=jx(),t=rK();try{yield e.audioWorklet.addModule("string"==typeof t?t:yield t),ZO.info("global audio player worklet addModule success",t)}catch(CC){throw ZO.error("global audio player worklet addModule failed:",CC),CC}return this.worklet=new AudioWorkletNode(e,"global-audio-player",{processorOptions:{wasm:yield iK(),flag:Jz},numberOfInputs:2}),ZO.info("global audio player worklet created",e.state),this.worklet.connect(e.destination),this.playPort=this.worklet.port,this.playPort}))}playAudio(e){return nw(this,null,(function*(){var t;yield this.init();let r=new MessageChannel;null==(t=this.playPort)||t.postMessage(null,[r.port1]),e(r.port2)}))}},nK="undefined"!=typeof self&&(!("top"in self)||self===top)&&"showOpenFilePicker"in self&&"showOpenFilePicker";nK?Promise.resolve().then((function(){return cK})):Promise.resolve().then((function(){return fK})),nK?Promise.resolve().then((function(){return pK})):Promise.resolve().then((function(){return _K}));var aK=nK?Promise.resolve().then((function(){return mK})):Promise.resolve().then((function(){return gK}));function sK(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(this,null,(function*(){return(yield aK).default(...t)}))}var lK=e=>nw(void 0,null,(function*(){let t=yield e.getFile();return t.handle=e,t})),cK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){Array.isArray(e)||(e=[e]);let t=[];e.forEach(((e,r)=>{t[r]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map((i=>{t[r].accept[i]=e.extensions||[]})):t[r].accept["*/*"]=e.extensions||[]}));let r=yield window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=yield Promise.all(r.map(lK));return e[0].multiple?i:i[0]}()}))}};function dK(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return dK=function(e){this.s=e,this.n=e.next},dK.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?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new dK(e)}var uK,hK=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return nw(void 0,[e,t,...i],(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.name,i=arguments.length>3?arguments[3]:void 0;return function*(){let o=[],n=[];var a,s=!1,l=!1;try{for(var c,d=function(e){var t,r,i,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,i=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(i&&null!=(t=e[i]))return new dK(t.call(e));r="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(c=yield d.next()).done;s=!1){let a=c.value,s="".concat(r,"/").concat(a.name);"file"===a.kind?n.push(a.getFile().then((t=>(t.directoryHandle=e,t.handle=a,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>s}))))):"directory"!==a.kind||!t||i&&i(a)||o.push(hK(a,t,s,i))}}catch(u){l=!0,a=u}finally{try{s&&null!=d.return&&(yield d.return())}finally{if(l)throw a}}return[...(yield Promise.all(o)).flat(),...yield Promise.all(n)]}()}))},pK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){e.recursive=e.recursive||!1,e.mode=e.mode||"read";let t=yield window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return hK(t,e.recursive,void 0,e.skipDirectory)}()}))}},mK={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return nw(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[{}],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return function*(){Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";let n=[],a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach(((e,t)=>{n[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&a&&e.mimeTypes.push(a),e.mimeTypes.map((r=>{n[t].accept[r]=e.extensions||[]}))):a?n[t].accept[a]=e.extensions||[]:n[t].accept["*/*"]=e.extensions||[]})),r)try{yield r.getFile()}catch(c){if(r=null,i)throw c}let s=r||(yield window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:n,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1}));!r&&o&&o(s);let l=yield s.createWritable();return"stream"in e?(yield e.stream().pipeTo(l),s):"body"in e?(yield e.body.pipeTo(l),s):(yield l.write(yield e),yield l.close(),s)}()}))}},fK={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),new Promise(((t,r)=>{let i=document.createElement("input");i.type="file";let o=[...e.map((e=>e.mimeTypes||[])),...e.map((e=>e.extensions||[]))].join();i.multiple=e[0].multiple||!1,i.accept=o||"",i.style.display="none",document.body.append(i);let n=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(n,(()=>a(r)),i),s=()=>{window.removeEventListener("focus",s),i.remove()};i.addEventListener("click",(()=>{window.addEventListener("focus",s)})),i.addEventListener("change",(()=>{window.removeEventListener("focus",s),i.remove(),n(i.multiple?Array.from(i.files):i.files[0])})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},_K={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise(((t,r)=>{let i=document.createElement("input");i.type="file",i.webkitdirectory=!0;let o=e=>{"function"==typeof n&&n(),t(e)},n=e[0].legacySetup&&e[0].legacySetup(o,(()=>n(r)),i);i.addEventListener("change",(()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter((t=>t.webkitRelativePath.split("/").every((t=>!e[0].skipDirectory({name:t,kind:"directory"})))))):t=t.filter((e=>2===e.webkitRelativePath.split("/").length)),o(t)})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},gK={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return nw(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){Array.isArray(t)&&(t=t[0]);let r=document.createElement("a"),i=e;"body"in e&&(i=yield function(e,t){return nw(this,null,(function*(){let r=e.getReader(),i=new ReadableStream({start:e=>function t(){return nw(this,null,(function*(){return r.read().then((r=>{let{done:i,value:o}=r;if(!i)return e.enqueue(o),t();e.close()}))}))}()}),o=new Response(i),n=yield o.blob();return r.releaseLock(),new Blob([n],{type:t})}))}(e.body,e.headers.get("content-type"))),r.download=t.fileName||"Untitled",r.href=URL.createObjectURL(yield i);let o=()=>{"function"==typeof n&&n()},n=t.legacySetup&&t.legacySetup(o,(()=>n()),r);return r.addEventListener("click",(()=>{setTimeout((()=>URL.revokeObjectURL(r.href)),3e4),o()})),r.click(),null}()}))}},EK=class{constructor(e){this.name=e,iw(this,"ready"),iw(this,"worker"),iw(this,"ports"),iw(this,"ids",1),iw(this,"transactions",new Map),iw(this,"log"),iw(this,"addTransaction",(e=>(this.transactions.set(++this.ids,e),this.ids)))}postMessage(e,t){var r;null==(r=this.worker)||r.postMessage(e,t)}create(e){return nw(this,null,(function*(){if(this.ready)return this.ready;e||(e=this.name),console.time("createWorker_".concat(e));let t=rK(),r=new Worker("string"==typeof t?t:yield t,{name:e});return this.worker=r,this.ready=new Promise(((t,i)=>nw(this,null,(function*(){r.onmessage=r=>{let{data:{id:o,type:n,payload:a}}=r;var s;if(o)null==(s=this.transactions.get(o))||s(a),this.transactions.delete(o);else switch(n){case"error":console.timeEnd("createWorker_".concat(e)),console.warn("worker error:",a),i(a);break;case"ready":console.timeEnd("createWorker_".concat(e)),t(this);break;case"updateAFSM":if(a.value){let e="string"==typeof a.old?a.old:"".concat(a.old.action,"ing"),t="string"==typeof a.value?a.value:"".concat(a.value.action,"ing");console.log(_N(),a.group,a.name,e,"👉",t)}break;case"log":console.log(a);break;case"glog":window.dispatchEvent(new CustomEvent(n,{detail:a}))}},r.postMessage({wasm:yield iK(),flag:Jz},this.ports)}))))}))}destroy(){var e;console.log("destroy worker",this.name),delete this.ready,null==(e=this.worker)||e.terminate()}},vK=class{constructor(e,t,r){this.worker=e,iw(this,"channel",new MessageChannel),iw(this,"ready"),this.ready=new Promise(((e,r)=>{this.worker.postMessage({id:this.worker.addTransaction(e),payload:t},[this.channel.port2])})).then((e=>(0===e.err&&(this.worker.sessionCount++,this.channel.port1.onmessage=r),e)))}postMessage(){this.channel.port1.postMessage(...arguments)}destroy(){0==--this.worker.sessionCount&&this.worker.destroy()}},yK=new class e extends EK{constructor(){super("main"),iw(this,"switchValue",new Map),iw(this,"extendChannel"),iw(this,"sessionCount",0)}setSwitchValue(e,t){var r;this.switchValue.set(e,t),null==(r=this.extendChannel)||r.port1.postMessage([e,t])}create(){return nw(this,null,(function*(){return this.ready?this.ready:(this.extendChannel=new MessageChannel,this.ports=[this.extendChannel.port2],yield ow(e.prototype,this,"create").call(this),this.switchValue.forEach(((e,t)=>{this.extendChannel.port1.postMessage([t,e])})),this)}))}},TK=-1;function IK(e){return console.log(e),uK.push(e.slice()),uK.length>1e3&&uK.shift(),e}function AK(e){return nw(this,null,(function*(){switch(TK){case 0:this.edpl.willDecodeAudio=IK;break;case 2:this.edpl.didEncodeAudio=IK}yield yK.create(),YO.emit(XO.JOIN_SEND_CMD,{room:this});let t=new vK(yK,e,(e=>{let r=e.data;if("string"==typeof r)this.onWorkerEvent(r);else if(null==r)this.onWorkerEvent("client-banned",0),t.destroy();else{let{cmd:e,payload:t}=r;this.onWorkerEvent(e,t)}})),{err:r,data:i}=yield t.ready;if("number"==typeof r){if(YO.emit(XO.JOIN_RECEIVED_CMD_RES,{room:this,code:r}),0===r)return Object.assign(this,i,{session:t});throw new mw({code:hw.JOIN_ROOM_FAILED,extraCode:Number(r),message:mL({key:dL.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:r,errorMsg:""}})})}throw r}))}function SK(e){return nw(this,null,(function*(){yK.setSwitchValue("useAINS",e)}))}function RK(e){return nw(this,null,(function*(){yK.setSwitchValue("useV2",e)}))}function bK(e){let t=new MediaStreamTrackGenerator({kind:"audio"});e.setInputMediaStreamTrack(t),e.player.setVolume(0),this.postMessage({cmd:"pullAudio",payload:{tinyId:e.tinyId,writable:t.writable}},[t.writable])}function wK(e){return nw(this,null,(function*(){var t;this._log.info("pull video",e);let r=Date.now(),i=0,o=new MessageChannel;this.postMessage({cmd:"pullVideo",payload:{mediaType:e.mediaType,tinyId:e.tinyId}},[o.port1]),(t=e.stat).framesReceived||(t.framesReceived=0),JU(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Object.defineProperties(_V(),{postMessage:{value:e.postMessage.bind(e)},port:{get:()=>e,set(t){e.onmessage=FU,e.onmessageerror=FU,e=t,i()}}});function i(){e.onmessage=i=>{i.data?i.ports.length||t?r.next(i):r.next(i.data):(r.complete(),e.close())},e.onmessageerror=t=>{r.error(t),e.close()}}return i(),r}(o.port2),QV(DV(e,WP.INIT)),$F((t=>{let{data:o,packetsReceived:n}=t;e.stat.packetsReceived=n,e.stat.framesReceived++,i++;let a,s=31&o[4];if(i<=10){let e=Array.from(o.slice(0,10)).map((e=>e.toString(16).padStart(2,"0"))).join(" ");this._log.info("Frame ".concat(i," - Size: ").concat(o.length," bytes, Type: ").concat(s,", Timestamp: ").concat(Date.now()-r,"ms First 10 bytes: ").concat(e))}switch(s){case 5:case 7:a="key";break;default:a="delta"}e.isAvailable?e.decodeFrame({data:o.buffer,type:a,timestamp:1e3*(Date.now()-r)}):console.warn("track is not available")}),(()=>{}),(()=>{o.port2.postMessage(null),o.port2.close()})))}))}Object.defineProperties(window,{useAINS:{set:SK},useWt:{set:function(e){return nw(this,null,(function*(){yK.setSwitchValue("useWt",e)}))}},enableDebug:{set(e){console.debug=e?$z:()=>{},yK.setSwitchValue("enableDebug",e)}},useV2:{set:RK},dump:{value(){if(TK=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,uK||(console.warn("dump audio will be activated at next time join room"),uK=[]),!uK.length)return void console.warn("no audio data to dump,try it later");let e=[];return uK.forEach((t=>{e.push(new Uint16Array([t.length])),e.push(t)})),sK(new Blob(e),{fileName:"audio dump hex",extensions:[".hex"]})}},dumpAudio:{value(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"audio",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,r=[],i=new Promise((i=>{let o=new MessageChannel;yK.extendChannel.port1.postMessage(["dump",e],[o.port1]),o.port2.onmessage=n=>{let{data:a}=n;console.log(a),r.push(a),r.length>t&&(o.port2.onmessage=null,yK.extendChannel.port1.postMessage(["dump",e]),o.port2.close(),i(new Blob(r)))}}));return sK(i,{fileName:e,extensions:[".pcm"]})}},hardDec:{set(e){switch(e){case!0:Jz.useHardDecoder="prefer-hardware";break;case!1:Jz.useHardDecoder="prefer-software";break;default:Jz.useHardDecoder="no-preference"}}}});var CK=[];function DK(e){var t;let r=_V();if("joined"!==this.state)throw new Error("Room is not joined");if("publish"===e.state)return;for(let c=0;c<=CK.length;c++)if(!CK[c]){CK[c]=this,this.index=c;break}let i=e.profile;this._log.info("start push audio",this.index,i);let o=new MessageChannel,n=e.enableEncryptFrame?new MessageChannel:null;null==(t=this.session)||t.postMessage({cmd:"pushAudio",payload:Qb({index:this.index},i)},n?[o.port2,n.port2]:[o.port2]),o.port1.onmessage=t=>{null==t.data||("number"==typeof t.data?r.next(t.data):n&&n.port1.postMessage($b(Qb({},t.data),{data:new Uint8Array(e.encodeFrame({data:t.data.data.buffer,timestamp:t.data.timestamp}).data)})))};let a,s=new MediaStream,l=e=>{let t=s.getAudioTracks()[0];t&&(a.disconnect(),s.removeTrack(t)),s.addTrack(e),this._log.info("push audio track:",e.readyState,e.getSettings().deviceId),a=jx().createMediaStreamSource(s),a.connect(oK.worklet,0,this.index)};JU(DV(e,"output-media-track-changed"),QV(DV(e,"ready")),$F(l,console.error,(()=>{this._log.info("stop push audio",i),e.volume=0,a.disconnect(),CK[this.index]=null,n&&n.port1.postMessage(null),o.port1.postMessage(null)}))),JU(r,ZF((t=>e.volume=t)),NF(gB(1e3)),$F((()=>{e.volume=0}))),l(e.outMediaTrack)}var NK=class{constructor(e,t,r,i){this.localTrack=e,this.type=t,this.config=r,this.port=i,iw(this,"track"),iw(this,"label"),iw(this,"insertKeyFrame",!0),iw(this,"session"),iw(this,"tsMap",new Map),e._log.info("create Video Encoder",r)}trans(e,t,r){return nw(this,null,(function*(){let i=yield this.recreate(r,{recreateCount:0,frameEncoded:0,selectConfigIndex:0});t.signal.addEventListener("abort",(()=>{i.encoder.close()}));let o=0;return e.pipeThrough(new TransformStream({transform:(e,t)=>{"configured"===i.encoder.state&&(this.tsMap.set(o,Date.now()),this.encode(e),o++,t.enqueue(e))}}),t)}))}encode(e){var t,r;null==(r=null==(t=this.session)?void 0:t.encoder)||r.encode(e,{keyFrame:this.insertKeyFrame}),this.insertKeyFrame=!1}start(e,t,r){return nw(this,null,(function*(){let i=yield this.recreate(r,{recreateCount:0,frameEncoded:0,selectConfigIndex:0});this.session=i;let o=0;e.pipeTo(new WritableStream({write:e=>{"configured"===i.encoder.state&&(o<10&&this.localTrack.log.info("capture ".concat(this.label," track frame:"),o,Date.now(),e.timestamp,e.displayWidth,e.displayHeight),(e.displayWidth!==this.config.width||e.displayHeight!==this.config.height)&&(this.localTrack.log.info("resize video track frame:",e.displayWidth,e.displayHeight,this.config.width,this.config.height),this.configure({width:e.displayWidth,height:e.displayHeight},i)),this.tsMap.set(o,Date.now()),this.encode(e),o<10&&this.localTrack.log.info("encode ".concat(this.label," track frame:"),o),o++,e.close())}}),t).catch((e=>{this.localTrack.log.warn(e),i.encoder.close()}))}))}recreate(e,t){return nw(this,null,(function*(){let r=0,i=new VideoEncoder({output:i=>{let o=this.tsMap.get(r);if(this.tsMap.delete(i.timestamp),r<10&&(0===r&&0===t.recreateCount&&YO.emit(XO.SEND_FIRST_VIDEO_FRAME,{room:e}),this.localTrack.log.info("encoded ".concat(this.label," track frame:"),r,Date.now(),i.timestamp)),r++,t.frameEncoded=r,!1===this.track.enabled)return;let n=null;if(this.localTrack.enableEncodeFrame){n=new Uint8Array(i.byteLength),i.copyTo(n);let e=this.localTrack.encodeFrame({data:n.buffer},3===this.type);n=new Uint8Array(e.data)}n?(this.localTrack.stat.bytesSent+=n.length,this.port.postMessage({chunk:{type:i.type,timestamp:i.timestamp,data:n,duration:i.duration},timestamp:o},[n.buffer])):(this.localTrack.stat.bytesSent+=i.byteLength,this.port.postMessage({chunk:i,timestamp:o}))},error:r=>{this.localTrack.log.warn(r,this.config),t.recreateCount++,setTimeout((()=>this.recreate(e,t)),100)}});return t.encoder=i,yield this.configure(null,t),t}))}configure(e,t){return nw(this,null,(function*(){var r;e&&Object.assign(this.config,e),null==(r=t.encoder)||r.configure(this.config)}))}close(){this.port.postMessage(null),this.port.close()}};function kK(e,t){return nw(this,null,(function*(){let r=2===e.mediaType,i=r?"screen":"video",o={codec:"avc1.420028",latencyMode:"realtime",avc:{format:"annexb"},hardwareAcceleration:Jz.useHardEncoder,width:t.profile.width,height:t.profile.height,framerate:t.profile.frameRate,bitrate:1e3*t.profile.bitrate},n=new MessageChannel;this.postMessage({cmd:"pushVideo",payload:t},[n.port1]);let a=new NK(e,t.type,o,n.port2);return n.port2.onmessage=e=>{if(260===e.data)a.insertKeyFrame=!0;else if(!r){let{bitrate:t}=e.data;UD({configureBr:[e.data.bitrate,t]}),a.session&&a.configure({bitrate:t},a.session)}},this._log.info("start push",i,t),a}))}function OK(e){return nw(this,null,(function*(){var t;let r=2===e.mediaType,i=r?"screen":"video",o={type:r?7:2,profile:e.profile,trackType:r?"screen":"camera",crypto:!(null==(t=e.manager)||!t.encodePipeline[0])};!r&&e.outMediaTrack instanceof CanvasCaptureMediaStreamTrack&&(o.trackType="canvas");let{trackType:n}=o,{width:a,height:s}=e.outMediaTrack.getSettings();o.profile.width=a,o.profile.height=s;let l=yield kK.call(this,e,o);this._log.info("VideoEncoder created",o);let c,d=t=>nw(this,null,(function*(){if(null==c||c.abort("track changed"),!t)return;c=new AbortController;let{width:r,height:o,displaySurface:a}=t.getSettings();r&&(l.config.width=r),o&&(l.config.height=o);let s,d=QN.match(/Chrome\/(\d+)/);"114"===(null==d?void 0:d[1])&&"browser"===a&&delete l.config.hardwareAcceleration,this._log.info("push",i,"track:",t.readyState,t.getSettings()),s="undefined"==typeof MediaStreamTrackProcessor||t instanceof CanvasCaptureMediaStreamTrack?new ReadableStream({start(t){e.on("render",(r=>{if(0!==e.player.mode||document.hidden)try{t.enqueue(new VideoFrame(r,{timestamp:1e3*performance.now()}))}catch(i){console.warn(i)}}))},pull(t){return nw(this,null,(function*(){if(0===e.player.mode&&RP()&&e.player.element)return new Promise((r=>{e.player.element.requestVideoFrameCallback(((i,o)=>{try{let r=new VideoFrame(e.player.element);t.enqueue(r)}catch(n){console.warn(n)}r()}))}))}))}}):new MediaStreamTrackProcessor({track:t}).readable;let u="small"in e&&e.small;return u?(this.smallEncoder||(this.smallEncoder=yield kK.call(this,e,{profile:u,type:3,trackType:n})),this.smallEncoder.track=t,this.smallEncoder.label="small",s=yield this.smallEncoder.trans(s,c,this)):this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder),l.track=t,l.label=i,l.start(s,c,this)}));return JU(DV(e,"output-media-track-changed"),QV(DV(e,"ready")),$F(d,console.error,(()=>{var e;this._log.info("stop push",i,o),c.abort("unpublish"),l.close(),null==(e=this.smallEncoder)||e.close()}))),d(e.outMediaTrack)}))}var MK=class e extends WP{constructor(t){var r,i;super(null!=(i=null==(r=t.roomid)?void 0:r.toString())?i:t.name,"volumeEvaluation"),this.room=t,iw(this,"enableInBackground",!1),iw(this,"interval",400),t.on("joined",(()=>{this.emit(e.INTERVALCHANGED,this.interval)})),JU(DV(this,e.INTERVALCHANGED),CF((e=>"joined"===this.room.state?this.room.fromWorker("getAudioEnergy",e):JU((e=>t=>{let r=0,i=performance.now();JU(_B,IF((t=>(t-i)/e|0)),YV((e=>e!=r&&(r=e,!0))))(t)})(e),IF((()=>[]))))),$F((e=>{e.forEach((e=>{this.room.remotePublishedUserMap.has(e.userId)&&(this.room.remotePublishedUserMap.get(e.userId).remoteAudioTrack.volume=e.volume)})),(!document.hidden||this.enableInBackground)&&this.state==WP.ON&&this.room.emit("audio-volume",e)})))}start(t,r){this.interval=t,this.enableInBackground=r,this.emit(e.INTERVALCHANGED,this.interval)}stop(){}};iw(MK,"INTERVALCHANGED","intervalChanged"),rw([FP([WP.INIT,WP.OFF],WP.ON)],MK.prototype,"start",1),rw([FP([],WP.OFF)],MK.prototype,"stop",1);var LK=MK,PK=class extends Yz{constructor(e){super(e),iw(this,"index",0),iw(this,"session"),iw(this,"tinyid"),iw(this,"roomid"),iw(this,"openid"),iw(this,"socketid"),iw(this,"relayip"),iw(this,"clientip"),iw(this,"remotePublishedUserMap",new Map),iw(this,"bussinessInfo"),iw(this,"token"),iw(this,"audioVolumeEvalution",new LK(this)),iw(this,"enableAIVoice",SK),iw(this,"AbilityOption",{AVLimit:{EncVideoCodec:"H265",EncVideoWidth:0,EncVideoHeight:0,EncVideoBr:"0",EncVideoFps:0,EncAudioCodec:"opus",EncAudioFS:0,EncAudioCh:0,EncAudioBr:"0"},GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:navigator.platform,uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:zO(),uint32_device_type:0,str_os_verion:KO(),uint32_link_type:1,str_client_version:Iw,uint32_net_type:qw[vw.getNetworkType()],ua:navigator.userAgent,version:""}}),iw(this,"joinAbortController",new AbortController),iw(this,"smallAbortCtrl"),iw(this,"smallEncoder"),e.tinyId&&(this.tinyId=e.tinyId,RK(!0)),this._log||(this._log=e.logger),this.bussinessInfo=e.bussinessInfo,e.encodedDataProcessingListener&&this.setEncodedDataProcessingListener(e.encodedDataProcessingListener)}replaceTrack(e){return nw(this,null,(function*(){}))}getLogger(){return this._log}postMessage(e,t){this.session&&(e?"string"==typeof e?this.session.postMessage({cmd:e,payload:t}):this.session.postMessage(e,t):this.session.postMessage(null))}sendMessage(e,t){return new Promise(((r,i)=>{"joined"!=this.state&&i("join room first");let o=new MessageChannel;this.postMessage({cmd:e,payload:t},[o.port1]),o.port2.onmessageerror=i,o.port2.onmessage=e=>{o.port2.close(),r(e.data)}}))}fromWorker(e,t){if("joined"!=this.state)throw"join room first";return r=>{var i;let o=new MessageChannel;o.port2.onmessage=e=>{e.data?r.next(e.data):r.complete()},o.port2.onmessageerror=e=>r.error(e),r.defer((()=>{o.port2.postMessage(null),o.port2.close()})),null==(i=this.session)||i.postMessage({cmd:e,payload:t},[o.port1])}}switchRole(e){return nw(this,null,(function*(){if(e!==this.role)return this._log.info("switchRole() => switch role to: ".concat(e)),"audience"==e&&this.unpublish(...this.localTracks),this.sendMessage("switchRole","audience"==e?21:20).then((t=>{this.role=e}))}))}join(e,t,r){return nw(this,null,(function*(){var i,o,n;let a=vw.getEnv(),s=CL(),l={isH264EncodeSupported:this.checkSystemResult.detail.isH264EncodeSupported,isVp8EncodeSupported:this.checkSystemResult.detail.isVp8EncodeSupported,frameWorkType:r,params:e,proxy_wt:null==(i=this.proxy_wt)?void 0:i.replace("https://",""),proxy_ws:null==(o=this.proxy_ws)?void 0:o.replace("wss://",""),proxy_cloud:null!=(n=this.scheduleResult.iceServers)&&n.length?this.scheduleResult.iceServers[0].urls:[],proxy_unified:this.proxy_unified,domains:this.scheduleResult.domains,env:a,osName:HO(),browserInfo:CL(),tinyId:this.tinyId,joinReq:{useStrRoomid:!!this.useStringRoomId,roomid:String(e.roomId||e.strRoomId),sdkAppID:String(e.sdkAppId),userSig:e.userSig,privMapEncrypt:e.privateMapKey||"",privMap:"",pstnBizType:0,role:"user",jsSdkVersion:Iw,browserVersion:s.browserName+s.browserVersion,closeLocalMedia:!0,trtcscene:"live"===t?2:1,trtcrole:e.role,bussinessInfo:e.businessInfo||this.bussinessInfo||"",isAuxUser:0,autoSubscribe:this.autoReceiveAudio&&this.autoReceiveVideo,AbilityOption:this.AbilityOption}};yield AK.call(this,l),console.log(this),oK.playAudio((e=>this.postMessage({cmd:"setAudioWorkletPort"},[e]))),this.checkDestroy()}))}leave(){return nw(this,null,(function*(){this.remotePublishedUserMap.forEach((e=>{e.remoteAudioTrack.close(),e.remoteAuxiliaryTrack.close(),e.remoteVideoTrack.close()})),this.postMessage(null),this.remotePublishedUserMap.clear(),this.localTracks.forEach(((e,t)=>t.unpublish())),this.localTracks.clear()}))}getSignalInfo(){return{tinyId:this.tinyid,clientIp:this.clientip,signalIp:"",relayIp:this.relayip,relayInnerIp:"",relayPort:0}}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e<=0?this.audioVolumeEvalution.stop():this.audioVolumeEvalution.start(e,t)}getLocalAudioStats(){return this.sendMessage("getLocalAudioStats")}getLocalVideoStats(){return this.sendMessage("getLocalVideoStats")}afterJoin(){return nw(this,null,(function*(){let e=QV(DV(this,"left")),t=this.audioManager.decodePipeline.some((e=>e));JU((e=>nw(this,null,(function*(){let r=new MessageChannel;r.port2.onmessage=t=>{t.data?e.next({data:t.data,port:r.port2}):e.complete()},r.port2.onmessageerror=t=>e.error(t),e.defer((()=>{r.port2.postMessage(null),r.port2.close()})),this.postMessage({cmd:"decodeAudio",payload:t},[r.port1])}))),e,$F((e=>{let{data:t,port:r}=e;var i;let o={data:t.data.buffer};for(let[n,a]of this.audioManager.decodePipeline.entries())if(a&&(o=a({frame:o,track:null==(i=this.remotePublishedUserMap.get(t.userId))?void 0:i.remoteAudioTrack}),!o))return;r.postMessage($b(Qb({},t),{data:new Uint8Array(o.data)}),[o.data])})))}))}onWorkerEvent(e,t){switch("network-quality"!==e&&console.info(this.userId,"onWorkerEvent",e,JSON.stringify(t)),e){case XO.RECEIVED_PUBLISHED_USER_LIST:return void YO.emit(e,Qb({room:this},t));case"1":if(t.userId===this.userId)return;return void this.emit("peer-join",t);case"2":return void this.emit("peer-leave",t);case"3":let r=new bz(this,t);return this.remotePublishedUserMap.set(t.userId,r),void this.emit("remote-published",r);case"5":{let e=t,r=this.remotePublishedUserMap.get(e);r&&(r.remoteVideoTrack.close(),r.remoteAuxiliaryTrack.close(),r.remoteAudioTrack.close(),this.remotePublishedUserMap.delete(e),this.emit("remote-unpublished",r))}return;case"banned":switch(t){case 8:return void this.emit("banned",{reason:"kick",message:""});case 2:case 6:case 4:return void this.emit("banned",{reason:"banned",message:""});case 7:case 5:return void this.emit("banned",{reason:"room_disband",message:""})}break;case"6":{let{prevMuteState:e,muteState:r,flag:i}=t,o=this.remotePublishedUserMap.get(r.userId);if(!o)return void this.emit("remote-publish-state-changed",t);o.flag=i}return YO.emit(XO.REMOTE_PUBLISH_STATE_CHANGED,Qb({room:this},t)),void this.emit("remote-publish-state-changed",t);case"7":return void(this.localPublishFlag!==t.flag&&(this.localPublishFlag=t.flag,this.emit("local-publish-flag-changed",t.flag)));case"network-quality":this.quality=Qb({},t);let{uplinkLoss:i,uplinkRTT:o,uplinkInfo:n,downlinkInfo:a,msg_down_stream_info:s}=t,l={str_sdk_version:Iw,uint64_datetime:Date.now(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyid},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:qw[bD()]},msg_event_msg:ZB(this.userId),str_acc_ip:this.relayip,str_client_ip:this.clientip,msg_up_stream_info:n,msg_down_stream_info:s};YO.emit(XO.HEARTBEAT_REPORT,{room:this,report:l}),this.emit("heartbeat-report",l),YO.emit(XO.NETWORK_QUALITY,{room:this,uplink:{rtt:o,loss:i},downlinks:a}),delete t.downlinkInfo;break;case"signal-connection-state-changed":return void YO.emit(XO.SIGNAL_CONNECTION_STATE_CHANGED,Qb({room:this},t))}this.emit(e,t)}sendStartPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("publishCdn",e)}sendStopPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("stopPublishCdn",e)}sendStartMixTranscode(e){return this.sendMessage("startMcuMix",e)}sendStopMixTranscode(e){return this.sendMessage("stopMcuMix",e)}publish(e){return nw(this,null,(function*(){if(1===(yield this.sendMessage("publish",e.mediaType).then((e=>0!==e.err?Promise.reject(e.err):e)),$P(e,e).add("mute",(()=>{this.postMessage("mute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,remove:!0})})).add("unmute",(()=>{this.postMessage("unmute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,add:!0})})),e.mediaType))yield oK.init(),DK.call(this,e);else yield OK.call(this,e);e.muted&&this.postMessage("mute",{mediaType:e.mediaType,srctinyid:this.tinyid,userId:this.openid,remove:!0})}))}unpublish(e){return nw(this,null,(function*(){ZP(e)}))}subscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),{userId:r,tinyId:i,streamType:o}=t[0],n=this.remotePublishedUserMap.get(r),a=Qb({},n.subscribeState),s=Object.assign(new QM,a);s.mediaType|=e,YO.emit(XO.SUBSCRIBE_START,{room:this,streamType:o,remotePublishedUser:n,subscribeState:s});let l=yield this.sendMessage("subscribe",{mediaType:s.mediaType,userId:r,srctinyid:i,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8,2].filter((e=>s.mediaType&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}});console.dir("subscribe",l),yield Promise.all(t.filter((e=>!e.isSubscribed)).map((e=>1===e.mediaType?bK.call(this,e):wK.call(this,e)))),YO.emit(XO.SUBSCRIBE_SUCCESS,{room:this,streamType:o,remotePublishedUser:n})}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return nw(this,null,(function*(){let e=0;for(let r of t)e|=r.mediaType;if(t.length){let{userId:r,streamType:i,tinyId:o}=t[0];yield this.sendMessage("unSubscribe",{mediaType:e,srctinyid:o,userId:r});for(let e of t)e.unsubscribe();YO.emit(XO.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:this.remotePublishedUserMap.get(r)})}}))}enableSmall(e){return nw(this,null,(function*(){var t;if(e){if(this.videoManager.smallTrack){let e=this.videoManager.cameraTrack;this.smallEncoder=yield kK.call(this,e,{profile:e.small,type:3,trackType:"camera"});let t=new MediaStreamTrackProcessor({track:this.videoManager.smallTrack}).readable;this.smallEncoder.track=this.videoManager.smallTrack,this.smallEncoder.label="small",this.smallAbortCtrl=new AbortController,this.smallEncoder.start(t,this.smallAbortCtrl,this),this._log.info("push small")}}else null==(t=this.smallAbortCtrl)||t.abort("stop"),this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder)}))}changeType(e,t){let r=this.remotePublishedUserMap.get(t.userId);if(!r)return;let i=e?8:4;if(r.remoteVideoTrack.mediaType===i)return;let o={srctinyid:r.tinyId,mediaType:i,userId:t.userId,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8].filter((e=>i&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}};r.remoteVideoTrack.mediaType=o.mediaType,this.postMessage("changetype",o)}destroy(){this.isDestroyed||(super.destroy(),this.isDestroyed=!0,this.joinAbortController.abort("destroy"))}};rw([CU(PK.prototype.afterJoin),FP(["left",WP.INIT],"joined"),DU((e=>{let t=new wz;return function(r,i,o){return nw(this,null,(function*(){let n=String(r.roomId||r.strRoomId);if(this.userId=r.userId,this.sdkAppId=r.sdkAppId,this.userSig=r.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=i,r.privateMapKey=r.privateMapKey||"",this.isJoined)throw new mw({code:hw.INVALID_OPERATION,message:mL({key:dL.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:n,sdkAppId:this.sdkAppId,room:this}))throw new mw({code:hw.INVALID_OPERATION,message:mL({key:dL.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:n}),this.role=21===r.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(n," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),YO.emit(XO.JOIN_START,{room:this,roomId:n,params:r});let a=vw.getEnv();a||(a=Gw.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(rC.OLD_CLOUD_LADDER)?a=Gw.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(rC.WEBRTC)&&(a=Gw.WEBRTC))),ex.setConfig({env:a,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:n}),rM.checkSystemRequirementsInternal(o).then((e=>{this.checkSystemResult=e,Cz.call(this)}));try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!vw.getEnv()&&(yield this.schedule(r,o));let t=yield e.call(this,r,i,o);return this.roomId=n,this._joinedTimestamp=vw.performanceNow(),YO.emit(XO.JOIN_SUCCESS,{room:this}),30===o&&!r.component&&ex.uploadEvent({log:"stat-conv-".concat(Number(DO),"-").concat(location.hostname),userId:this.userId}),t}catch(lM){throw t.delete({room:this,roomId:n}),YO.emit(XO.JOIN_FAILED,{room:this,error:lM}),lM}}))}}))],PK.prototype,"join",1),rw([FP("joined","left",{ignoreError:!0}),DU((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return nw(this,null,(function*(){YO.emit(XO.LEAVE_START,{room:this}),yield e.call(this,...r),YO.emit(XO.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))}))],PK.prototype,"leave",1),rw([xU((e=>e.mediaType)),DU((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return nw(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||(r=r.filter((e=>e.outMediaTrack&&"ready"===e.state)),!r.length))return;YO.emit("61",{room:this});let t=e.apply(this,r);return Promise.all(r.map((e=>e.publish(this,t))))}))}))],PK.prototype,"publish",1),rw([xU((e=>e.mediaType)),DU((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>e.unpublish())),o}))],PK.prototype,"unpublish",1),rw([xU((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].userId})),DU((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>!e.isSubscribed&&e.subscribe(o))),o}))],PK.prototype,"subscribe",1);var xK=PK;return Rz.frameWorkType=37,Rz.create=function(e){let t=Rz._create.call(this,xK,e);return t._use(bG,null==e?void 0:e.assetsPath),null!=e&&e.assetsPath&&(Jz.assetsPath=null==e?void 0:e.assetsPath),console.log("trtc wasm sdk:",Iw,"created",Jz),t},Object.assign(Rz.prototype,{_setCurrentSpeaker(e){let t=jx();return null!=t&&t.setSinkId?t.setSinkId(e):Promise.reject("not support")},_enableVideoDecodeFallback(e,t){return nw(this,null,(function*(){return this.startPlugin(bG.Name,{type:"webCodecs",renderer:"videoFrame",track:e,config:{codec:"avc1.640028",hardwareAcceleration:"prefer-software",optimizeForLatency:!0},fallback:"wasm"}),new Promise(((t,r)=>{JU(DV(e,"decode-downgrade-state-changed"),YV((e=>"STARTED"===e.state)),XV(1),eB(1e4),QV(DV(e,WP.INIT)),$F(t,r))}))}))}}),SP(37),Rz}));