trtc-sdk-v5 5.17.2-beta.2 → 5.17.2-beta.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.
@@ -1,4 +1,4 @@
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).TRTCDebugDialog=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={},n=function(e){try{return!!e()}catch(t){return!0}},a=!n(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),o=!n(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),s=o,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 f,m,g=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_=o,v=Function.prototype,y=v.call,E=_&&v.bind.bind(y,y),b=_?E:function(e){return function(){return y.apply(e,arguments)}},w=b,I=w({}.toString),T=w("".slice),S=function(e){return T(I(e),8,-1)},k=n,A=S,R=Object,C=b("".split),D=k(function(){return!R("z").propertyIsEnumerable(0)})?function(e){return"String"===A(e)?C(e,""):R(e)}:R,O=function(e){return null==e},L=O,x=TypeError,N=function(e){if(L(e))throw new x("Can't call method on "+e);return e},P=D,M=N,U=function(e){return P(M(e))},B="object"==typeof document&&document.all,F=void 0===B&&void 0!==B?function(e){return"function"==typeof e||e===B}:function(e){return"function"==typeof e},V=F,W=function(e){return"object"==typeof e?null!==e:V(e)},H=r,j=F,z=function(e,t){return arguments.length<2?(r=H[e],j(r)?r:void 0):H[e]&&H[e][t];var r},G=b({}.isPrototypeOf),q=r.navigator,K=q&&q.userAgent,Y=K?String(K):"",X=r,Z=Y,J=X.process,Q=X.Deno,$=J&&J.versions||Q&&Q.version,ee=$&&$.v8;ee&&(m=(f=ee.split("."))[0]>0&&f[0]<4?1:+(f[0]+f[1])),!m&&Z&&(!(f=Z.match(/Edge\/(\d+)/))||f[1]>=74)&&(f=Z.match(/Chrome\/(\d+)/))&&(m=+f[1]);var te=m,re=te,ie=n,ne=r.String,ae=!!Object.getOwnPropertySymbols&&!ie(function(){var e=Symbol("symbol detection");return!ne(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41}),oe=ae&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=z,ce=F,le=G,de=Object,ue=oe?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"}},fe=F,me=pe,ge=TypeError,_e=function(e){if(fe(e))return e;throw new ge(me(e)+" is not a function")},ve=_e,ye=O,Ee=function(e,t){var r=e[t];return ye(r)?void 0:ve(r)},be=l,we=F,Ie=W,Te=TypeError,Se={exports:{}},ke=r,Ae=Object.defineProperty,Re=function(e,t){try{Ae(ke,e,{value:t,configurable:!0,writable:!0})}catch(r){ke[e]=t}return t},Ce=r,De=Re,Oe="__core-js_shared__",Le=Se.exports=Ce[Oe]||De(Oe,{});(Le.versions||(Le.versions=[])).push({version:"3.49.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"});var xe=Se.exports,Ne=xe,Pe=function(e,t){return Ne[e]||(Ne[e]=t||{})},Me=N,Ue=Object,Be=function(e){return Ue(Me(e))},Fe=Be,Ve=b({}.hasOwnProperty),We=Object.hasOwn||function(e,t){return Ve(Fe(e),t)},He=b,je=0,ze=Math.random(),Ge=He(1.1.toString),qe=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ge(++je+ze,36)},Ke=Pe,Ye=We,Xe=qe,Ze=ae,Je=oe,Qe=r.Symbol,$e=Ke("wks"),et=Je?Qe.for||Qe:Qe&&Qe.withoutSetter||Xe,tt=function(e){return Ye($e,e)||($e[e]=Ze&&Ye(Qe,e)?Qe[e]:et("Symbol."+e)),$e[e]},rt=l,it=W,nt=ue,at=Ee,ot=function(e,t){var r,i;if("string"===t&&we(r=e.toString)&&!Ie(i=be(r,e)))return i;if(we(r=e.valueOf)&&!Ie(i=be(r,e)))return i;if("string"!==t&&we(r=e.toString)&&!Ie(i=be(r,e)))return i;throw new Te("Can't convert object to primitive value")},st=TypeError,ct=tt("toPrimitive"),lt=function(e,t){if(!it(e)||nt(e))return e;var r,i=at(e,ct);if(i){if(void 0===t&&(t="default"),r=rt(i,e,t),!it(r)||nt(r))return r;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),ot(e,t)},dt=lt,ut=ue,ht=function(e){var t=dt(e,"string");return ut(t)?t:t+""},pt=W,ft=r.document,mt=pt(ft)&&pt(ft.createElement),gt=function(e){return mt?ft.createElement(e):{}},_t=gt,vt=!a&&!n(function(){return 7!==Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a}),yt=a,Et=l,bt=d,wt=g,It=U,Tt=ht,St=We,kt=vt,At=Object.getOwnPropertyDescriptor;i.f=yt?At:function(e,t){if(e=It(e),t=Tt(t),kt)try{return At(e,t)}catch(r){}if(St(e,t))return wt(!Et(bt.f,e,t),e[t])};var Rt={},Ct=a&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Dt=W,Ot=String,Lt=TypeError,xt=function(e){if(Dt(e))return e;throw new Lt(Ot(e)+" is not an object")},Nt=a,Pt=vt,Mt=Ct,Ut=xt,Bt=ht,Ft=TypeError,Vt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Ht="enumerable",jt="configurable",zt="writable";Rt.f=Nt?Mt?function(e,t,r){if(Ut(e),t=Bt(t),Ut(r),"function"==typeof e&&"prototype"===t&&"value"in r&&zt in r&&!r[zt]){var i=Wt(e,t);i&&i[zt]&&(e[t]=r.value,r={configurable:jt in r?r[jt]:i[jt],enumerable:Ht in r?r[Ht]:i[Ht],writable:!1})}return Vt(e,t,r)}:Vt:function(e,t,r){if(Ut(e),t=Bt(t),Ut(r),Pt)try{return Vt(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 Gt=Rt,qt=g,Kt=a?function(e,t,r){return Gt.f(e,t,qt(1,r))}:function(e,t,r){return e[t]=r,e},Yt={exports:{}},Xt=a,Zt=We,Jt=Function.prototype,Qt=Xt&&Object.getOwnPropertyDescriptor,$t=Zt(Jt,"name"),er={EXISTS:$t,PROPER:$t&&"something"===function(){}.name,CONFIGURABLE:$t&&(!Xt||Xt&&Qt(Jt,"name").configurable)},tr=F,rr=xe,ir=b(Function.toString);tr(rr.inspectSource)||(rr.inspectSource=function(e){return ir(e)});var nr,ar,or,sr=rr.inspectSource,cr=F,lr=r.WeakMap,dr=cr(lr)&&/native code/.test(String(lr)),ur=qe,hr=Pe("keys"),pr=function(e){return hr[e]||(hr[e]=ur(e))},fr={},mr=dr,gr=r,_r=W,vr=Kt,yr=We,Er=xe,br=pr,wr=fr,Ir="Object already initialized",Tr=gr.TypeError,Sr=gr.WeakMap;if(mr||Er.state){var kr=Er.state||(Er.state=new Sr);kr.get=kr.get,kr.has=kr.has,kr.set=kr.set,nr=function(e,t){if(kr.has(e))throw new Tr(Ir);return t.facade=e,kr.set(e,t),t},ar=function(e){return kr.get(e)||{}},or=function(e){return kr.has(e)}}else{var Ar=br("state");wr[Ar]=!0,nr=function(e,t){if(yr(e,Ar))throw new Tr(Ir);return t.facade=e,vr(e,Ar,t),t},ar=function(e){return yr(e,Ar)?e[Ar]:{}},or=function(e){return yr(e,Ar)}}var Rr={set:nr,get:ar,has:or,enforce:function(e){return or(e)?ar(e):nr(e,{})},getterFor:function(e){return function(t){var r;if(!_r(t)||(r=ar(t)).type!==e)throw new Tr("Incompatible receiver, "+e+" required");return r}}},Cr=b,Dr=n,Or=F,Lr=We,xr=a,Nr=er.CONFIGURABLE,Pr=sr,Mr=Rr.enforce,Ur=Rr.get,Br=String,Fr=Object.defineProperty,Vr=Cr("".slice),Wr=Cr("".replace),Hr=Cr([].join),jr=xr&&!Dr(function(){return 8!==Fr(function(){},"length",{value:8}).length}),zr=String(String).split("String"),Gr=Yt.exports=function(e,t,r){"Symbol("===Vr(Br(t),0,7)&&(t="["+Wr(Br(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Lr(e,"name")||Nr&&e.name!==t)&&(xr?Fr(e,"name",{value:t,configurable:!0}):e.name=t),jr&&r&&Lr(r,"arity")&&e.length!==r.arity&&Fr(e,"length",{value:r.arity});try{r&&Lr(r,"constructor")&&r.constructor?xr&&Fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var i=Mr(e);return Lr(i,"source")||(i.source=Hr(zr,"string"==typeof t?t:"")),e};Function.prototype.toString=Gr(function(){return Or(this)&&Ur(this).source||Pr(this)},"toString");var qr=Yt.exports,Kr=F,Yr=Rt,Xr=qr,Zr=Re,Jr=function(e,t,r,i){i||(i={});var n=i.enumerable,a=void 0!==i.name?i.name:t;if(Kr(r)&&Xr(r,a,i),i.global)n?e[t]=r:Zr(t,r);else{try{i.unsafe?e[t]&&(n=!0):delete e[t]}catch(o){}n?e[t]=r:Yr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},Qr={},$r=Math.ceil,ei=Math.floor,ti=Math.trunc||function(e){var t=+e;return(t>0?ei:$r)(t)},ri=function(e){var t=+e;return t!=t||0===t?0:ti(t)},ii=ri,ni=Math.max,ai=Math.min,oi=function(e,t){var r=ii(e);return r<0?ni(r+t,0):ai(r,t)},si=ri,ci=Math.min,li=function(e){var t=si(e);return t>0?ci(t,9007199254740991):0},di=li,ui=function(e){return di(e.length)},hi=U,pi=oi,fi=ui,mi=function(e){return function(t,r,i){var n=hi(t),a=fi(n);if(0===a)return!e&&-1;var o,s=pi(i,a);if(e&&r!=r){for(;a>s;)if((o=n[s++])!=o)return!0}else for(;a>s;s++)if((e||s in n)&&n[s]===r)return e||s||0;return!e&&-1}},gi={includes:mi(!0),indexOf:mi(!1)},_i=We,vi=U,yi=gi.indexOf,Ei=fr,bi=b([].push),wi=function(e,t){var r,i=vi(e),n=0,a=[];for(r in i)!_i(Ei,r)&&_i(i,r)&&bi(a,r);for(;t.length>n;)_i(i,r=t[n++])&&(~yi(a,r)||bi(a,r));return a},Ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ti=wi,Si=Ii.concat("length","prototype");Qr.f=Object.getOwnPropertyNames||function(e){return Ti(e,Si)};var ki={};ki.f=Object.getOwnPropertySymbols;var Ai=z,Ri=Qr,Ci=ki,Di=xt,Oi=b([].concat),Li=Ai("Reflect","ownKeys")||function(e){var t=Ri.f(Di(e)),r=Ci.f;return r?Oi(t,r(e)):t},xi=We,Ni=Li,Pi=i,Mi=Rt,Ui=function(e,t,r){for(var i=Ni(t),n=Mi.f,a=Pi.f,o=0;o<i.length;o++){var s=i[o];xi(e,s)||r&&xi(r,s)||n(e,s,a(t,s))}},Bi=n,Fi=F,Vi=/#|\.prototype\./,Wi=function(e,t){var r=ji[Hi(e)];return r===Gi||r!==zi&&(Fi(t)?Bi(t):!!t)},Hi=Wi.normalize=function(e){return String(e).replace(Vi,".").toLowerCase()},ji=Wi.data={},zi=Wi.NATIVE="N",Gi=Wi.POLYFILL="P",qi=Wi,Ki=r,Yi=i.f,Xi=Kt,Zi=Jr,Ji=Re,Qi=Ui,$i=qi,en=function(e,t){var r,i,n,a,o,s=e.target,c=e.global,l=e.stat;if(r=c?Ki:l?Ki[s]||Ji(s,{}):Ki[s]&&Ki[s].prototype)for(i in t){if(a=t[i],n=e.dontCallGetSet?(o=Yi(r,i))&&o.value:r[i],!$i(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==n){if(typeof a==typeof n)continue;Qi(a,n)}(e.sham||n&&n.sham)&&Xi(a,"sham",!0),Zi(r,i,a,e)}},tn={};tn[tt("toStringTag")]="z";var rn="[object z]"===String(tn),nn=F,an=S,on=tt("toStringTag"),sn=Object,cn="Arguments"===an(function(){return arguments}()),ln=rn?an: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=sn(e),on))?r:cn?an(t):"Object"===(i=an(t))&&nn(t.callee)?"Arguments":i},dn=ln,un=String,hn=function(e){if("Symbol"===dn(e))throw new TypeError("Cannot convert a Symbol value to a string");return un(e)},pn=qr,fn=Rt,mn=function(e,t,r){return r.get&&pn(r.get,t,{getter:!0}),r.set&&pn(r.set,t,{setter:!0}),fn.f(e,t,r)},gn=en,_n=a,vn=l,yn=b,En=We,bn=F,wn=G,In=hn,Tn=mn,Sn=Ui,kn=r.Symbol,An=kn&&kn.prototype;if(_n&&bn(kn)&&(!("description"in An)||void 0!==kn().description)){var Rn={},Cn=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:In(arguments[0]),t=wn(An,this)?new kn(e):void 0===e?kn():kn(e);return""===e&&(Rn[t]=!0),t};Sn(Cn,kn);var Dn=Cn.for;Cn.for={for:function(e){var t=In(e),r=vn(Dn,this,t);return""===t&&(Rn[r]=!0),r}}.for,Cn.prototype=An,An.constructor=Cn;var On="Symbol(description detection)"===String(kn("description detection")),Ln=yn(An.valueOf),xn=yn(An.toString),Nn=/^Symbol\((.*)\)[^)]+$/,Pn=yn("".replace),Mn=yn("".slice);Tn(An,"description",{configurable:!0,get:function(){var e=Ln(this);if(En(Rn,e))return"";var t=xn(e),r=On?Mn(t,7,-1):Pn(t,Nn,"$1");return""===r?void 0:r}}),gn({global:!0,constructor:!0,forced:!0},{Symbol:Cn})}var Un={},Bn=wi,Fn=Ii,Vn=Object.keys||function(e){return Bn(e,Fn)},Wn=a,Hn=Ct,jn=Rt,zn=xt,Gn=U,qn=Vn;Un.f=Wn&&!Hn?Object.defineProperties:function(e,t){zn(e);for(var r,i=Gn(t),n=qn(t),a=n.length,o=0;a>o;)jn.f(e,r=n[o++],i[r]);return e};var Kn,Yn=z("document","documentElement"),Xn=xt,Zn=Un,Jn=Ii,Qn=fr,$n=Yn,ea=gt,ta="prototype",ra="script",ia=pr("IE_PROTO"),na=function(){},aa=function(e){return"<"+ra+">"+e+"</"+ra+">"},oa=function(e){e.write(aa("")),e.close();var t=e.parentWindow.Object;return e=null,t},sa=function(){try{Kn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;sa="undefined"!=typeof document?document.domain&&Kn?oa(Kn):(t=ea("iframe"),r="java"+ra+":",t.style.display="none",$n.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(aa("document.F=Object")),e.close(),e.F):oa(Kn);for(var i=Jn.length;i--;)delete sa[ta][Jn[i]];return sa()};Qn[ia]=!0;var ca=Object.create||function(e,t){var r;return null!==e?(na[ta]=Xn(e),r=new na,na[ta]=null,r[ia]=e):r=sa(),void 0===t?r:Zn.f(r,t)},la=tt,da=ca,ua=Rt.f,ha=la("unscopables"),pa=Array.prototype;void 0===pa[ha]&&ua(pa,ha,{configurable:!0,value:da(null)});var fa=function(e){pa[ha][e]=!0},ma=en,ga=gi.includes,_a=n,va=fa,ya=_a(function(){return!Array(1).includes()}),Ea=_a(function(){return[,1].includes(void 0,1)});ma({target:"Array",proto:!0,forced:ya||Ea},{includes:function(e){return ga(this,e,arguments.length>1?arguments[1]:void 0)}}),va("includes");var ba,wa,Ia,Ta={},Sa=!n(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),ka=We,Aa=F,Ra=Be,Ca=Sa,Da=pr("IE_PROTO"),Oa=Object,La=Oa.prototype,xa=Ca?Oa.getPrototypeOf:function(e){var t=Ra(e);if(ka(t,Da))return t[Da];var r=t.constructor;return Aa(r)&&t instanceof r?r.prototype:t instanceof Oa?La:null},Na=n,Pa=F,Ma=W,Ua=xa,Ba=Jr,Fa=tt("iterator"),Va=!1;[].keys&&("next"in(Ia=[].keys())?(wa=Ua(Ua(Ia)))!==Object.prototype&&(ba=wa):Va=!0);var Wa=!Ma(ba)||Na(function(){var e={};return ba[Fa].call(e)!==e});Wa&&(ba={}),Pa(ba[Fa])||Ba(ba,Fa,function(){return this});var Ha={IteratorPrototype:ba,BUGGY_SAFARI_ITERATORS:Va},ja=Rt.f,za=We,Ga=tt("toStringTag"),qa=function(e,t,r){e&&!r&&(e=e.prototype),e&&!za(e,Ga)&&ja(e,Ga,{configurable:!0,value:t})},Ka=Ha.IteratorPrototype,Ya=ca,Xa=g,Za=qa,Ja=Ta,Qa=function(){return this},$a=function(e,t,r,i){var n=t+" Iterator";return e.prototype=Ya(Ka,{next:Xa(+!i,r)}),Za(e,n,!1),Ja[n]=Qa,e},eo=b,to=_e,ro=W,io=function(e){return ro(e)||null===e},no=String,ao=TypeError,oo=function(e,t,r){try{return eo(to(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},so=W,co=N,lo=function(e){if(io(e))return e;throw new ao("Can't set "+no(e)+" as a prototype")},uo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=oo(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return co(r),lo(i),so(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0),ho=en,po=l,fo=F,mo=$a,go=xa,_o=uo,vo=qa,yo=Kt,Eo=Jr,bo=Ta,wo=er.PROPER,Io=er.CONFIGURABLE,To=Ha.IteratorPrototype,So=Ha.BUGGY_SAFARI_ITERATORS,ko=tt("iterator"),Ao="keys",Ro="values",Co="entries",Do=function(){return this},Oo=function(e,t,r,i,n,a,o){mo(r,t,i);var s,c,l,d=function(e){if(e===n&&m)return m;if(!So&&e&&e in p)return p[e];switch(e){case Ao:case Ro:case Co:return function(){return new r(this,e)}}return function(){return new r(this)}},u=t+" Iterator",h=!1,p=e.prototype,f=p[ko]||p["@@iterator"]||n&&p[n],m=!So&&f||d(n),g="Array"===t&&p.entries||f;if(g&&(s=go(g.call(new e)))!==Object.prototype&&s.next&&(go(s)!==To&&(_o?_o(s,To):fo(s[ko])||Eo(s,ko,Do)),vo(s,u,!0)),wo&&n===Ro&&f&&f.name!==Ro&&(Io?yo(p,"name",Ro):(h=!0,m=function(){return po(f,this)})),n)if(c={values:d(Ro),keys:a?m:d(Ao),entries:d(Co)},o)for(l in c)(So||h||!(l in p))&&Eo(p,l,c[l]);else ho({target:t,proto:!0,forced:So||h},c);return p[ko]!==m&&Eo(p,ko,m,{name:n}),bo[t]=m,c},Lo=function(e,t){return{value:e,done:t}},xo=U,No=fa,Po=Ta,Mo=Rr,Uo=Rt.f,Bo=Oo,Fo=Lo,Vo=a,Wo="Array Iterator",Ho=Mo.set,jo=Mo.getterFor(Wo),zo=Bo(Array,"Array",function(e,t){Ho(this,{type:Wo,target:xo(e),index:0,kind:t})},function(){var e=jo(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Fo(void 0,!0);switch(e.kind){case"keys":return Fo(r,!1);case"values":return Fo(t[r],!1)}return Fo([r,t[r]],!1)},"values"),Go=Po.Arguments=Po.Array;if(No("keys"),No("values"),No("entries"),Vo&&"values"!==Go.name)try{Uo(Go,"name",{value:"values"})}catch(EU){}var qo=_e,Ko=Be,Yo=D,Xo=ui,Zo=TypeError,Jo="Reduce of empty array with no initial value",Qo=function(e){return function(t,r,i,n){var a=Ko(t),o=Yo(a),s=Xo(a);if(qo(r),0===s&&i<2)throw new Zo(Jo);var c=e?s-1:0,l=e?-1:1;if(i<2)for(;;){if(c in o){n=o[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw new Zo(Jo)}for(;e?c>=0:s>c;c+=l)c in o&&(n=r(n,o[c],c,a));return n}},$o={left:Qo(!1),right:Qo(!0)},es=n,ts=function(e,t){var r=[][e];return!!r&&es(function(){r.call(null,t||function(){return 1},1)})},rs=r,is=Y,ns=S,as=function(e){return is.slice(0,e.length)===e},os=as("Bun/")?"BUN":as("Cloudflare-Workers")?"CLOUDFLARE":as("Deno/")?"DENO":as("Node.js/")?"NODE":rs.Bun&&"string"==typeof Bun.version?"BUN":rs.Deno&&"object"==typeof Deno.version?"DENO":"process"===ns(rs.process)?"NODE":rs.window&&rs.document?"BROWSER":"REST",ss="NODE"===os,cs=$o.left;en({target:"Array",proto:!0,forced:!ss&&te>79&&te<83||!ts("reduce")},{reduce:function(e){var t=arguments.length;return cs(this,e,t,t>1?arguments[1]:void 0)}});var ls=$o.right;en({target:"Array",proto:!0,forced:!ss&&te>79&&te<83||!ts("reduceRight")},{reduceRight:function(e){return ls(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ds=S,us=Array.isArray||function(e){return"Array"===ds(e)},hs=en,ps=us,fs=b([].reverse),ms=[1,2];hs({target:"Array",proto:!0,forced:String(ms)===String(ms.reverse())},{reverse:function(){return ps(this)&&(this.length=this.length),fs(this)}});var gs="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,_s=Jr,vs=function(e,t,r){for(var i in t)_s(e,i,t[i],r);return e},ys=G,Es=TypeError,bs=function(e,t){if(ys(t,e))return e;throw new Es("Incorrect invocation")},ws=ri,Is=li,Ts=RangeError,Ss=function(e){if(void 0===e)return 0;var t=ws(e),r=Is(t);if(t!==r)throw new Ts("Wrong length or index");return r},ks=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},As=4503599627370496,Rs=ks,Cs=function(e){return e+As-As},Ds=Math.abs,Os=function(e,t,r,i){var n=+e,a=Ds(n),o=Rs(n);if(a<i)return o*Cs(a/i/t)*i*t;var s=(1+t/2220446049250313e-31)*a,c=s-(s-a);return c>r||c!=c?Infinity*o:o*c},Ls=Math.fround||function(e){return Os(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},xs=Array,Ns=Math.abs,Ps=Math.pow,Ms=Math.floor,Us=Math.log,Bs=Math.LN2,Fs={pack:function(e,t,r){var i,n,a,o=xs(r),s=8*r-t-1,c=(1<<s)-1,l=c>>1,d=23===t?Ps(2,-24)-Ps(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=Ns(e))!=e||Infinity===e?(n=e!=e?1:0,i=c):(i=Ms(Us(e)/Bs),e*(a=Ps(2,-i))<1&&(i--,a*=2),(e+=i+l>=1?d/a:d*Ps(2,1-l))*a>=2&&(i++,a/=2),i+l>=c?(n=0,i=c):i+l>=1?(n=(e*a-1)*Ps(2,t),i+=l):(n=e*Ps(2,l-1)*Ps(2,t),i=0));t>=8;)o[h++]=255&n,n/=256,t-=8;for(i=i<<t|n,s+=t;s>0;)o[h++]=255&i,i/=256,s-=8;return o[h-1]|=128*u,o},unpack:function(e,t){var r,i=e.length,n=8*i-t-1,a=(1<<n)-1,o=a>>1,s=n-7,c=i-1,l=e[c--],d=127&l;for(l>>=7;s>0;)d=256*d+e[c--],s-=8;for(r=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===d)d=1-o;else{if(d===a)return r?NaN:l?-Infinity:Infinity;r+=Ps(2,t),d-=o}return(l?-1:1)*r*Ps(2,d-t)}},Vs=Be,Ws=oi,Hs=ui,js=function(e){for(var t=Vs(this),r=Hs(t),i=arguments.length,n=Ws(i>1?arguments[1]:void 0,r),a=i>2?arguments[2]:void 0,o=void 0===a?r:Ws(a,r);o>n;)t[n++]=e;return t},zs=b([].slice),Gs=F,qs=W,Ks=uo,Ys=function(e,t,r){var i,n;return Ks&&Gs(i=t.constructor)&&i!==r&&qs(n=i.prototype)&&n!==r.prototype&&Ks(e,n),e},Xs=r,Zs=b,Js=a,Qs=gs,$s=Kt,ec=mn,tc=vs,rc=n,ic=bs,nc=ri,ac=Ss,oc=Ls,sc=Fs,cc=xa,lc=uo,dc=js,uc=zs,hc=Ys,pc=Ui,fc=qa,mc=Rr,gc=er.PROPER,_c=er.CONFIGURABLE,vc="ArrayBuffer",yc="DataView",Ec="prototype",bc="Wrong index",wc=mc.getterFor(vc),Ic=mc.getterFor(yc),Tc=mc.set,Sc=Xs[vc],kc=Sc,Ac=kc&&kc[Ec],Rc=Xs[yc],Cc=Rc&&Rc[Ec],Dc=Object.prototype,Oc=Xs.Array,Lc=Xs.RangeError,xc=Zs(dc),Nc=Zs([].reverse),Pc=sc.pack,Mc=sc.unpack,Uc=function(e){return[255&e]},Bc=function(e){return[255&e,e>>8&255]},Fc=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Vc=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Wc=function(e){return Pc(oc(e),23,4)},Hc=function(e){return Pc(e,52,8)},jc=function(e,t,r){ec(e[Ec],t,{configurable:!0,get:function(){return r(this)[t]}})},zc=function(e,t,r,i){var n=Ic(e),a=ac(r),o=!!i;if(a+t>n.byteLength)throw new Lc(bc);var s=n.bytes,c=a+n.byteOffset,l=uc(s,c,c+t);return o?l:Nc(l)},Gc=function(e,t,r,i,n,a){var o=Ic(e),s=ac(r),c=i(+n),l=!!a;if(s+t>o.byteLength)throw new Lc(bc);for(var d=o.bytes,u=s+o.byteOffset,h=0;h<t;h++)d[u+h]=c[l?h:t-h-1]};if(Qs){var qc=gc&&Sc.name!==vc;rc(function(){Sc(1)})&&rc(function(){new Sc(-1)})&&!rc(function(){return new Sc,new Sc(1.5),new Sc(NaN),1!==Sc.length||qc&&!_c})?qc&&_c&&$s(Sc,"name",vc):((kc=function(e){return ic(this,Ac),hc(new Sc(ac(e)),this,kc)})[Ec]=Ac,Ac.constructor=kc,pc(kc,Sc)),lc&&cc(Cc)!==Dc&&lc(Cc,Dc);var Kc=new Rc(new kc(2)),Yc=Zs(Cc.setInt8);Kc.setInt8(0,2147483648),Kc.setInt8(1,2147483649),!Kc.getInt8(0)&&Kc.getInt8(1)||tc(Cc,{setInt8:function(e,t){Yc(this,e,t<<24>>24)},setUint8:function(e,t){Yc(this,e,t<<24>>24)}},{unsafe:!0})}else Ac=(kc=function(e){ic(this,Ac);var t=ac(e);Tc(this,{type:vc,bytes:xc(Oc(t),0),byteLength:t}),Js||(this.byteLength=t,this.detached=!1)})[Ec],Cc=(Rc=function(e,t,r){ic(this,Cc),ic(e,Ac);var i=wc(e),n=i.byteLength,a=nc(t);if(a<0||a>n)throw new Lc("Wrong offset");if(a+(r=void 0===r?n-a:ac(r))>n)throw new Lc("Wrong length");Tc(this,{type:yc,buffer:e,byteLength:r,byteOffset:a,bytes:i.bytes}),Js||(this.buffer=e,this.byteLength=r,this.byteOffset=a)})[Ec],Js&&(jc(kc,"byteLength",wc),jc(Rc,"buffer",Ic),jc(Rc,"byteLength",Ic),jc(Rc,"byteOffset",Ic)),tc(Cc,{getInt8:function(e){return zc(this,1,e)[0]<<24>>24},getUint8:function(e){return zc(this,1,e)[0]},getInt16:function(e){var t=zc(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=zc(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Vc(zc(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Vc(zc(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Mc(zc(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Mc(zc(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Gc(this,1,e,Uc,t)},setUint8:function(e,t){Gc(this,1,e,Uc,t)},setInt16:function(e,t){Gc(this,2,e,Bc,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Gc(this,2,e,Bc,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Gc(this,4,e,Fc,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Gc(this,4,e,Fc,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Gc(this,4,e,Wc,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Gc(this,8,e,Hc,t,arguments.length>2&&arguments[2])}});fc(kc,vc),fc(Rc,yc);var Xc={ArrayBuffer:kc,DataView:Rc},Zc=z,Jc=mn,Qc=a,$c=tt("species"),el=function(e){var t=Zc(e);Qc&&t&&!t[$c]&&Jc(t,$c,{configurable:!0,get:function(){return this}})},tl=el,rl="ArrayBuffer",il=Xc[rl];en({global:!0,constructor:!0,forced:r[rl]!==il},{ArrayBuffer:il}),tl(rl);var nl=S,al=b,ol=function(e){if("Function"===nl(e))return al(e)},sl=en,cl=ol,ll=n,dl=xt,ul=oi,hl=li,pl=Xc.ArrayBuffer,fl=Xc.DataView,ml=fl.prototype,gl=cl(pl.prototype.slice),_l=cl(ml.getUint8),vl=cl(ml.setUint8);sl({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:ll(function(){return!new pl(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(gl&&void 0===t)return gl(dl(this),e);for(var r=dl(this).byteLength,i=ul(e,r),n=ul(void 0===t?r:t,r),a=new pl(hl(n-i)),o=new fl(this),s=new fl(a),c=0;i<n;)vl(s,c++,_l(o,i++));return a}});var yl=r,El=b,bl=n,wl=F,Il=ln,Tl=sr,Sl=function(){},kl=z("Reflect","construct"),Al=/^\s*(?:class|function)\b/,Rl=El(Al.exec),Cl=!Al.test(Sl),Dl=function(e){if(!wl(e))return!1;try{return kl(Sl,[],e),!0}catch(EU){return!1}},Ol=function(e){if(!wl(e))return!1;switch(Il(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Cl||!!Rl(Al,Tl(e))}catch(EU){return!0}};Ol.sham=!0;var Ll,xl,Nl,Pl,Ml=!kl||bl(function(){var e;return Dl(Dl.call)||!Dl(Object)||!Dl(function(){e=!0})||e})?Ol:Dl,Ul=Ml,Bl=pe,Fl=TypeError,Vl=function(e){if(Ul(e))return e;throw new Fl(Bl(e)+" is not a constructor")},Wl=xt,Hl=Vl,jl=O,zl=tt("species"),Gl=function(e,t){var r,i=Wl(e).constructor;return void 0===i||jl(r=Wl(i)[zl])?t:Hl(r)},ql=o,Kl=Function.prototype,Yl=Kl.apply,Xl=Kl.call,Zl="object"==typeof Reflect&&Reflect.apply||(ql?Xl.bind(Yl):function(){return Xl.apply(Yl,arguments)}),Jl=_e,Ql=o,$l=ol(ol.bind),ed=function(e,t){return Jl(e),void 0===t?e:Ql?$l(e,t):function(){return e.apply(t,arguments)}},td=TypeError,rd=function(e,t){if(e<t)throw new td("Not enough arguments");return e},id=Y,nd=/ipad|iphone|ipod/i.test(id)&&/applewebkit/i.test(id),ad=r,od=Zl,sd=ed,cd=F,ld=We,dd=n,ud=Yn,hd=zs,pd=gt,fd=rd,md=nd,gd=ss,_d=ad.setImmediate,vd=ad.clearImmediate,yd=ad.process,Ed=ad.Dispatch,bd=ad.Function,wd=ad.MessageChannel,Id=ad.String,Td=0,Sd={},kd="onreadystatechange";dd(function(){Ll=ad.location});var Ad=function(e){if(ld(Sd,e)){var t=Sd[e];delete Sd[e],t()}},Rd=function(e){return function(){Ad(e)}},Cd=function(e){Ad(e.data)},Dd=function(e){ad.postMessage(Id(e),Ll.protocol+"//"+Ll.host)};_d&&vd||(_d=function(e){fd(arguments.length,1);var t=cd(e)?e:bd(e),r=hd(arguments,1);return Sd[++Td]=function(){od(t,void 0,r)},xl(Td),Td},vd=function(e){delete Sd[e]},gd?xl=function(e){yd.nextTick(Rd(e))}:Ed&&Ed.now?xl=function(e){Ed.now(Rd(e))}:wd&&!md?(Pl=(Nl=new wd).port2,Nl.port1.onmessage=Cd,xl=sd(Pl.postMessage,Pl)):ad.addEventListener&&cd(ad.postMessage)&&!ad.importScripts&&Ll&&"file:"!==Ll.protocol&&!dd(Dd)?(xl=Dd,ad.addEventListener("message",Cd,!1)):xl=kd in pd("script")?function(e){ud.appendChild(pd("script"))[kd]=function(){ud.removeChild(this),Ad(e)}}:function(e){setTimeout(Rd(e),0)});var Od={set:_d,clear:vd},Ld=r,xd=a,Nd=Object.getOwnPropertyDescriptor,Pd=function(e){if(!xd)return Ld[e];var t=Nd(Ld,e);return t&&t.value},Md=function(){this.head=null,this.tail=null};Md.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 Ud,Bd,Fd,Vd,Wd,Hd=Md,jd=/ipad|iphone|ipod/i.test(Y)&&"undefined"!=typeof Pebble,zd=/web0s(?!.*chrome)/i.test(Y),Gd=r,qd=Pd,Kd=ed,Yd=Od.set,Xd=Hd,Zd=nd,Jd=jd,Qd=zd,$d=ss,eu=Gd.MutationObserver||Gd.WebKitMutationObserver,tu=Gd.document,ru=Gd.process,iu=Gd.Promise,nu=qd("queueMicrotask");if(!nu){var au=new Xd,ou=function(){var e,t;for($d&&(e=ru.domain)&&e.exit();t=au.get();)try{t()}catch(EU){throw au.head&&Ud(),EU}e&&e.enter()};Zd||$d||Qd||!eu||!tu?!Jd&&iu&&iu.resolve?((Vd=iu.resolve(void 0)).constructor=iu,Wd=Kd(Vd.then,Vd),Ud=function(){Wd(ou)}):$d?Ud=function(){ru.nextTick(ou)}:(Yd=Kd(Yd,Gd),Ud=function(){Yd(ou)}):(Bd=!0,Fd=tu.createTextNode(""),new eu(ou).observe(Fd,{characterData:!0}),Ud=function(){Fd.data=Bd=!Bd}),nu=function(e){au.head||Ud(),au.add(e)}}var su=nu,cu=function(e){try{return{error:!1,value:e()}}catch(EU){return{error:!0,value:EU}}},lu=r.Promise,du=r,uu=lu,hu=F,pu=qi,fu=sr,mu=tt,gu=os,_u=te;uu&&uu.prototype;var vu=mu("species"),yu=!1,Eu=hu(du.PromiseRejectionEvent),bu=pu("Promise",function(){var e=fu(uu),t=e!==String(uu);if(!t&&66===_u)return!0;if(!_u||_u<51||!/native code/.test(e)){var r=new uu(function(e){e(1)}),i=function(e){e(function(){},function(){})};if((r.constructor={})[vu]=i,!(yu=r.then(function(){})instanceof i))return!0}return!(t||"BROWSER"!==gu&&"DENO"!==gu||Eu)}),wu={CONSTRUCTOR:bu,REJECTION_EVENT:Eu,SUBCLASSING:yu},Iu={},Tu=_e,Su=TypeError,ku=function(e){var t,r;this.promise=new e(function(e,i){if(void 0!==t||void 0!==r)throw new Su("Bad Promise constructor");t=e,r=i}),this.resolve=Tu(t),this.reject=Tu(r)};Iu.f=function(e){return new ku(e)};var Au,Ru,Cu,Du,Ou=en,Lu=ss,xu=r,Nu=yl,Pu=l,Mu=Jr,Uu=uo,Bu=qa,Fu=el,Vu=_e,Wu=F,Hu=W,ju=bs,zu=Gl,Gu=Od.set,qu=su,Ku=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(EU){}},Yu=cu,Xu=Hd,Zu=Rr,Ju=lu,Qu=Iu,$u="Promise",eh=wu.CONSTRUCTOR,th=wu.REJECTION_EVENT,rh=wu.SUBCLASSING,ih=Zu.getterFor($u),nh=Zu.set,ah=Ju&&Ju.prototype,oh=Ju,sh=ah,ch=xu.TypeError,lh=xu.document,dh=xu.process,uh=Qu.f,hh=uh,ph=!!(lh&&lh.createEvent&&xu.dispatchEvent),fh="unhandledrejection",mh=function(e){var t;return!(!Hu(e)||!Wu(t=e.then))&&t},gh=function(e,t){var r,i,n,a=t.value,o=1===t.state,s=o?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{s?(o||(2===t.rejection&&bh(t),t.rejection=1),!0===s?r=a:(d&&d.enter(),r=s(a),d&&(d.exit(),n=!0)),r===e.promise?l(new ch("Promise-chain cycle")):(i=mh(r))?Pu(i,r,c,l):c(r)):l(a)}catch(EU){d&&!n&&d.exit(),l(EU)}},_h=function(e,t){e.notified||(e.notified=!0,qu(function(){for(var r,i=e.reactions;r=i.get();)gh(r,e);e.notified=!1,t&&!e.rejection&&yh(e)}))},vh=function(e,t,r){var i,n;ph?((i=lh.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),xu.dispatchEvent(i)):i={promise:t,reason:r},!th&&(n=xu["on"+e])?n(i):e===fh&&Ku("Unhandled promise rejection",r)},yh=function(e){Pu(Gu,xu,function(){var t,r=e.facade,i=e.value;if(Eh(e)&&(t=Yu(function(){Lu?dh.emit("unhandledRejection",i,r):vh(fh,r,i)}),e.rejection=Lu||Eh(e)?2:1,t.error))throw t.value})},Eh=function(e){return 1!==e.rejection&&!e.parent},bh=function(e){Pu(Gu,xu,function(){var t=e.facade;Lu?dh.emit("rejectionHandled",t):vh("rejectionhandled",t,e.value)})},wh=function(e,t,r){return function(i){e(t,i,r)}},Ih=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,_h(e,!0))},Th=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new ch("Promise can't be resolved itself");var i=mh(t);i?qu(function(){var r={done:!1};try{Pu(i,t,wh(Th,r,e),wh(Ih,r,e))}catch(EU){Ih(r,EU,e)}}):(e.value=t,e.state=1,_h(e,!1))}catch(EU){Ih({done:!1},EU,e)}}};if(eh&&(sh=(oh=function(e){ju(this,sh),Vu(e),Pu(Au,this);var t=ih(this);try{e(wh(Th,t),wh(Ih,t))}catch(EU){Ih(t,EU)}}).prototype,(Au=function(e){nh(this,{type:$u,done:!1,notified:!1,parent:!1,reactions:new Xu,rejection:!1,state:0,value:null})}).prototype=Mu(sh,"then",function(e,t){var r=ih(this),i=uh(zu(this,oh));return r.parent=!0,i.ok=!Wu(e)||e,i.fail=Wu(t)&&t,i.domain=Lu?dh.domain:void 0,0===r.state?r.reactions.add(i):qu(function(){gh(i,r)}),i.promise}),Ru=function(){var e=new Au,t=ih(e);this.promise=e,this.resolve=wh(Th,t),this.reject=wh(Ih,t)},Qu.f=uh=function(e){return e===oh||e===Cu?new Ru(e):hh(e)},Wu(Ju)&&ah!==Object.prototype)){Du=ah.then,rh||Mu(ah,"then",function(e,t){var r=this;return new oh(function(e,t){Pu(Du,r,e,t)}).then(e,t)},{unsafe:!0});try{delete ah.constructor}catch(EU){}Uu&&Uu(ah,sh)}Ou({global:!0,constructor:!0,wrap:!0,forced:eh},{Promise:oh}),Cu=Nu.Promise,Bu(oh,$u,!1),Fu($u);var Sh=Ta,kh=tt("iterator"),Ah=Array.prototype,Rh=function(e){return void 0!==e&&(Sh.Array===e||Ah[kh]===e)},Ch=ln,Dh=Ee,Oh=O,Lh=Ta,xh=tt("iterator"),Nh=function(e){if(!Oh(e))return Dh(e,xh)||Dh(e,"@@iterator")||Lh[Ch(e)]},Ph=l,Mh=_e,Uh=xt,Bh=pe,Fh=Nh,Vh=TypeError,Wh=function(e,t){var r=arguments.length<2?Fh(e):t;if(Mh(r))return Uh(Ph(r,e));throw new Vh(Bh(e)+" is not iterable")},Hh=l,jh=xt,zh=Ee,Gh=function(e,t,r){var i,n;jh(e);try{if(!(i=zh(e,"return"))){if("throw"===t)throw r;return r}i=Hh(i,e)}catch(EU){n=!0,i=EU}if("throw"===t)throw r;if(n)throw i;return jh(i),r},qh=ed,Kh=l,Yh=xt,Xh=pe,Zh=Rh,Jh=ui,Qh=G,$h=Wh,ep=Nh,tp=Gh,rp=TypeError,ip=function(e,t){this.stopped=e,this.result=t},np=ip.prototype,ap=function(e,t,r){var i,n,a,o,s,c,l,d=r&&r.that,u=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),m=qh(t,d),g=function(e){var t=i;return i=void 0,t&&tp(t,"normal"),new ip(!0,e)},_=function(e){return u?(Yh(e),f?m(e[0],e[1],g):m(e[0],e[1])):f?m(e,g):m(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(n=ep(e)))throw new rp(Xh(e)+" is not iterable");if(Zh(n)){for(a=0,o=Jh(e);o>a;a++)if((s=_(e[a]))&&Qh(np,s))return s;return new ip(!1)}i=$h(e,n)}for(c=h?e.next:i.next;!(l=Kh(c,i)).done;){var v=l.value;try{s=_(v)}catch(EU){if(!i)throw EU;tp(i,"throw",EU)}if("object"==typeof s&&s&&Qh(np,s))return s}return new ip(!1)},op=tt("iterator"),sp=!1;try{var cp=0,lp={next:function(){return{done:!!cp++}},return:function(){sp=!0}};lp[op]=function(){return this},Array.from(lp,function(){throw 2})}catch(EU){}var dp=function(e,t){try{if(!t&&!sp)return!1}catch(EU){return!1}var r=!1;try{var i={};i[op]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(EU){}return r},up=lu,hp=wu.CONSTRUCTOR||!dp(function(e){up.all(e).then(void 0,function(){})}),pp=l,fp=_e,mp=Iu,gp=cu,_p=ap;en({target:"Promise",stat:!0,forced:hp},{all:function(e){var t=this,r=mp.f(t),i=r.resolve,n=r.reject,a=gp(function(){var r=fp(t.resolve),a=[],o=0,s=1;_p(e,function(e){var c=o++,l=!1;s++,pp(r,t,e).then(function(e){l||(l=!0,a[c]=e,--s||i(a))},n)}),--s||i(a)});return a.error&&n(a.value),r.promise}});var vp=en,yp=wu.CONSTRUCTOR,Ep=lu,bp=z,wp=F,Ip=Jr,Tp=Ep&&Ep.prototype;if(vp({target:"Promise",proto:!0,forced:yp,real:!0},{catch:function(e){return this.then(void 0,e)}}),wp(Ep)){var Sp=bp("Promise").prototype.catch;Tp.catch!==Sp&&Ip(Tp,"catch",Sp,{unsafe:!0})}var kp=l,Ap=_e,Rp=Iu,Cp=cu,Dp=ap;en({target:"Promise",stat:!0,forced:hp},{race:function(e){var t=this,r=Rp.f(t),i=r.reject,n=Cp(function(){var n=Ap(t.resolve);Dp(e,function(e){kp(n,t,e).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var Op=Iu;en({target:"Promise",stat:!0,forced:wu.CONSTRUCTOR},{reject:function(e){var t=Op.f(this);return(0,t.reject)(e),t.promise}});var Lp=xt,xp=W,Np=Iu,Pp=function(e,t){if(Lp(e),xp(t)&&t.constructor===e)return t;var r=Np.f(e);return(0,r.resolve)(t),r.promise},Mp=en,Up=wu.CONSTRUCTOR,Bp=Pp;z("Promise"),Mp({target:"Promise",stat:!0,forced:Up},{resolve:function(e){return Bp(this,e)}});var Fp=en,Vp=lu,Wp=n,Hp=z,jp=F,zp=Gl,Gp=Pp,qp=Jr,Kp=Vp&&Vp.prototype;if(Fp({target:"Promise",proto:!0,real:!0,forced:!!Vp&&Wp(function(){Kp.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=zp(this,Hp("Promise")),r=jp(e);return this.then(r?function(r){return Gp(t,e()).then(function(){return r})}:e,r?function(r){return Gp(t,e()).then(function(){throw r})}:e)}}),jp(Vp)){var Yp=Hp("Promise").prototype.finally;Kp.finally!==Yp&&qp(Kp,"finally",Yp,{unsafe:!0})}var Xp=W,Zp=S,Jp=tt("match"),Qp=function(e){var t;return Xp(e)&&(void 0!==(t=e[Jp])?!!t:"RegExp"===Zp(e))},$p=n,ef=r.RegExp,tf=!$p(function(){var e=!0;try{ef(".","d")}catch(EU){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",n=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in e&&(a.hasIndices="d"),a)n(o,a[o]);return Object.getOwnPropertyDescriptor(ef.prototype,"flags").get.call(t)!==i||r!==i}),rf={correct:tf},nf=xt,af=function(){var e=nf(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},of=l,sf=We,cf=G,lf=rf,df=af,uf=RegExp.prototype,hf=lf.correct?function(e){return e.flags}:function(e){return lf.correct||!cf(uf,e)||sf(e,"flags")?e.flags:of(df,e)},pf=n,ff=r.RegExp,mf=pf(function(){var e=ff("a","y");return e.lastIndex=2,null!==e.exec("abcd")}),gf=mf||pf(function(){return!ff("a","y").sticky}),_f={BROKEN_CARET:mf||pf(function(){var e=ff("^r","gy");return e.lastIndex=2,null!==e.exec("str")}),MISSED_STICKY:gf,UNSUPPORTED_Y:mf},vf=Rt.f,yf=n,Ef=r.RegExp,bf=yf(function(){var e=Ef(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)}),wf=n,If=r.RegExp,Tf=wf(function(){var e=If("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}),Sf=a,kf=r,Af=b,Rf=qi,Cf=Ys,Df=Kt,Of=ca,Lf=Qr.f,xf=G,Nf=Qp,Pf=hn,Mf=hf,Uf=_f,Bf=function(e,t,r){r in e||vf(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},Ff=Jr,Vf=n,Wf=We,Hf=Rr.enforce,jf=el,zf=bf,Gf=Tf,qf=tt("match"),Kf=kf.RegExp,Yf=Kf.prototype,Xf=kf.SyntaxError,Zf=Af(Yf.exec),Jf=Af("".charAt),Qf=Af("".replace),$f=Af("".indexOf),em=Af("".slice),tm=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,rm=/a/g,im=/a/g,nm=new Kf(rm)!==rm,am=Uf.MISSED_STICKY,om=Uf.UNSUPPORTED_Y,sm=Sf&&(!nm||am||zf||Gf||Vf(function(){return im[qf]=!1,Kf(rm)!==rm||Kf(im)===im||"/a/i"!==String(Kf(rm,"i"))}));if(Rf("RegExp",sm)){for(var cm=function(e,t){var r,i,n,a,o,s,c=xf(Yf,this),l=Nf(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===cm)return e;if((l||xf(Yf,e))&&(e=e.source,d&&(t=Mf(h))),e=void 0===e?"":Pf(e),t=void 0===t?"":Pf(t),h=e,zf&&"dotAll"in rm&&(i=!!t&&$f(t,"s")>-1)&&(t=Qf(t,/s/g,"")),r=t,am&&"sticky"in rm&&(n=!!t&&$f(t,"y")>-1)&&om&&(t=Qf(t,/y/g,"")),Gf&&(a=function(e){for(var t,r=e.length,i=0,n="",a=[],o=Of(null),s=!1,c=!1,l=0,d="";i<r;i++){if("\\"===(t=Jf(e,i))){if(t+=Jf(e,++i),!c&&"\\"===Jf(t,1)){n+="\\x5c";continue}}else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:n+=t,Zf(tm,em(e,i+1))?(i+=2,c=!0,l++):"?"!==Jf(e,i+1)&&l++;continue;case">"===t&&c:if(""===d||Wf(o,d))throw new Xf("Invalid capture group name");o[d]=!0,a[a.length]=[d,l],c=!1,d="";continue}c?d+=t:n+=t}for(var u=0;u<a.length;u++)for(var h="\\k<"+a[u][0]+">",p="\\"+a[u][1];$f(n,h)>-1;)n=Qf(n,h,p);return[n,a]}(e),e=a[0],u=a[1]),o=Cf(Kf(e,t),c?this:Yf,cm),(i||n||u.length)&&(s=Hf(o),i&&(s.dotAll=!0,s.raw=cm(function(e){for(var t,r=e.length,i=0,n="",a=!1;i<r;i++)"\\"!==(t=Jf(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),n+=t):n+="[\\s\\S]":n+=t+Jf(e,++i);return n}(e),r)),n&&(s.sticky=!0),u.length&&(s.groups=u)),e!==h)try{Df(o,"source",""===h?"(?:)":h)}catch(EU){}return o},lm=Lf(Kf),dm=0;lm.length>dm;)Bf(cm,Kf,lm[dm++]);Yf.constructor=cm,cm.prototype=Yf,Ff(kf,"RegExp",cm,{constructor:!0})}jf("RegExp");var um=l,hm=b,pm=hn,fm=af,mm=_f,gm=ca,_m=Rr.get,vm=bf,ym=Tf,Em=Pe("native-string-replace",String.prototype.replace),bm=RegExp.prototype.exec,wm=bm,Im=hm("".charAt),Tm=hm("".indexOf),Sm=hm("".replace),km=hm("".slice),Am=function(){var e=/a/,t=/b*/g;return um(bm,e,"a"),um(bm,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Rm=mm.BROKEN_CARET,Cm=void 0!==/()??/.exec("")[1],Dm=function(e,t){for(var r=e.groups=gm(null),i=0;i<t.length;i++){var n=t[i];r[n[0]]=e[n[1]]}};(Am||Cm||Rm||vm||ym)&&(wm=function(e){var t,r,i,n=this,a=_m(n),o=pm(e),s=a.raw;if(s)return s.lastIndex=n.lastIndex,t=um(wm,s,o),n.lastIndex=s.lastIndex,t&&a.groups&&Dm(t,a.groups),t;var c=a.groups,l=Rm&&n.sticky,d=um(fm,n),u=n.source,h=0,p=o;if(l){d=Sm(d,"y",""),-1===Tm(d,"g")&&(d+="g"),p=km(o,n.lastIndex);var f=n.lastIndex>0&&Im(o,n.lastIndex-1);n.lastIndex>0&&(!n.multiline||n.multiline&&"\n"!==f&&"\r"!==f&&"\u2028"!==f&&"\u2029"!==f)&&(u="(?: (?:"+u+"))",p=" "+p,h++),r=new RegExp("^(?:"+u+")",d)}Cm&&(r=new RegExp("^"+u+"$(?!\\s)",d)),Am&&(i=n.lastIndex);var m=um(bm,l?r:n,p);return l?m?(m.input=o,m[0]=km(m[0],h),m.index=n.lastIndex,n.lastIndex+=m[0].length):n.lastIndex=0:Am&&m&&(n.lastIndex=n.global?m.index+m[0].length:i),Cm&&m&&m.length>1&&um(Em,m[0],r,function(){for(var e=1;e<arguments.length-2;e++)void 0===arguments[e]&&(m[e]=void 0)}),m&&c&&Dm(m,c),m});var Om=wm;en({target:"RegExp",proto:!0,forced:/./.exec!==Om},{exec:Om});var Lm=mn,xm=rf,Nm=af;a&&!xm.correct&&(Lm(RegExp.prototype,"flags",{configurable:!0,get:Nm}),xm.correct=!0);var Pm=ri,Mm=hn,Um=N,Bm=RangeError,Fm=Math.floor,Vm=b,Wm=li,Hm=hn,jm=N,zm=Vm(function(e){var t=Mm(Um(this)),r="",i=Pm(e);if(i<0||Infinity===i)throw new Bm("Wrong number of repetitions");for(;i>0;(i=Fm(i/2))&&(t+=t))i%2&&(r+=t);return r}),Gm=Vm("".slice),qm=Math.ceil,Km=function(e){return function(t,r,i){var n=Hm(jm(t)),a=Wm(r),o=n.length;if(a<=o)return n;var s,c,l=void 0===i?" ":Hm(i);return""===l?n:((c=zm(l,qm((s=a-o)/l.length))).length>s&&(c=Gm(c,0,s)),e?n+c:c+n)}},Ym={start:Km(!1),end:Km(!0)},Xm=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Y),Zm=Ym.start;en({target:"String",proto:!0,forced:Xm},{padStart:function(e){return Zm(this,e,arguments.length>1?arguments[1]:void 0)}});var Jm=l,Qm=Jr,$m=Om,eg=n,tg=tt,rg=Kt,ig=tg("species"),ng=RegExp.prototype,ag=b,og=ri,sg=hn,cg=N,lg=ag("".charAt),dg=ag("".charCodeAt),ug=ag("".slice),hg=function(e){return function(t,r){var i,n,a=sg(cg(t)),o=og(r),s=a.length;return o<0||o>=s?e?"":void 0:(i=dg(a,o))<55296||i>56319||o+1===s||(n=dg(a,o+1))<56320||n>57343?e?lg(a,o):i:e?ug(a,o,o+2):n-56320+(i-55296<<10)+65536}},pg={codeAt:hg(!1),charAt:hg(!0)},fg=pg.charAt,mg=b,gg=Be,_g=Math.floor,vg=mg("".charAt),yg=mg("".replace),Eg=mg("".slice),bg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,wg=/\$([$&'`]|\d{1,2})/g,Ig=function(e,t,r,i,n,a){var o=r+e.length,s=i.length,c=wg;return void 0!==n&&(n=gg(n),c=bg),yg(a,c,function(a,c){var l;switch(vg(c,0)){case"$":return"$";case"&":return e;case"`":return Eg(t,0,r);case"'":return Eg(t,o);case"<":l=n[Eg(c,1,-1)];break;default:var d=+c;if(0===d)return a;if(d>s){var u=_g(d/10);return 0===u?a:u<=s?void 0===i[u-1]?vg(c,1):i[u-1]+vg(c,1):a}l=i[d-1]}return void 0===l?"":l})},Tg=l,Sg=xt,kg=F,Ag=S,Rg=Om,Cg=TypeError,Dg=Zl,Og=l,Lg=b,xg=function(e,t,r,i){var n=tg(e),a=!eg(function(){var t={};return t[n]=function(){return 7},7!==""[e](t)}),o=a&&!eg(function(){var t=!1,r=/a/;if("split"===e){var i={};i[ig]=function(){return r},(r={constructor:i,flags:""})[n]=/./[n]}return r.exec=function(){return t=!0,null},r[n](""),!t});if(!a||!o||r){var s=/./[n],c=t(n,""[e],function(e,t,r,i,n){var o=t.exec;return o===$m||o===ng.exec?a&&!n?{done:!0,value:Jm(s,t,r,i)}:{done:!0,value:Jm(e,r,t,i)}:{done:!1}});Qm(String.prototype,e,c[0]),Qm(ng,n,c[1])}i&&rg(ng[n],"sham",!0)},Ng=n,Pg=xt,Mg=F,Ug=W,Bg=ri,Fg=li,Vg=hn,Wg=N,Hg=function(e,t,r){return t+(r&&fg(e,t).length||1)},jg=Ee,zg=Ig,Gg=hf,qg=function(e,t){var r=e.exec;if(kg(r)){var i=Tg(r,e,t);return null!==i&&Sg(i),i}if("RegExp"===Ag(e))return Tg(Rg,e,t);throw new Cg("RegExp#exec called on incompatible receiver")},Kg=tt("replace"),Yg=Math.max,Xg=Math.min,Zg=Lg([].concat),Jg=Lg([].push),Qg=Lg("".indexOf),$g=Lg("".slice),e_=function(e){return void 0===e?e:String(e)},t_="$0"==="a".replace(/./,"$0"),r_=!!/./[Kg]&&""===/./[Kg]("a","$0");xg("replace",function(e,t,r){var i=r_?"$":"$0";return[function(e,r){var i=Wg(this),n=Ug(e)?jg(e,Kg):void 0;return n?Og(n,e,i,r):Og(t,Vg(i),e,r)},function(e,n){var a=Pg(this),o=Vg(e),s=Mg(n);s||(n=Vg(n));var c=Vg(Gg(a));if("string"==typeof n&&!~Qg(n,i)&&!~Qg(n,"$<")&&!~Qg(c,"y")){var l=r(t,a,o,n);if(l.done)return l.value}var d,u=!!~Qg(c,"g");u&&(d=!!~Qg(c,"u")||!!~Qg(c,"v"),a.lastIndex=0);for(var h,p=[];null!==(h=qg(a,o))&&(Jg(p,h),u);){""===Vg(h[0])&&(a.lastIndex=Hg(o,Fg(a.lastIndex),d))}for(var f="",m=0,g=0;g<p.length;g++){for(var _,v=Vg((h=p[g])[0]),y=Yg(Xg(Bg(h.index),o.length),0),E=[],b=1;b<h.length;b++)Jg(E,e_(h[b]));var w=h.groups;if(s){var I=Zg([v],E,y,o);void 0!==w&&Jg(I,w),_=Vg(Dg(n,void 0,I))}else _=zg(v,o,y,E,w,n);y>=m&&(f+=$g(o,m,y)+_,m=y+v.length)}return f+$g(o,m)}]},!!Ng(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})||!t_||r_);var i_="\t\n\v\f\r                 \u2028\u2029\ufeff",n_=N,a_=hn,o_=i_,s_=b("".replace),c_=RegExp("^["+o_+"]+"),l_=RegExp("(^|[^"+o_+"])["+o_+"]+$"),d_=function(e){return function(t){var r=a_(n_(t));return 1&e&&(r=s_(r,c_,"")),2&e&&(r=s_(r,l_,"$1")),r}},u_={start:d_(1),end:d_(2),trim:d_(3)},h_=er.PROPER,p_=n,f_=i_,m_=u_.trim;en({target:"String",proto:!0,forced:function(e){return p_(function(){return!!f_[e]()||"​…᠎"!=="​…᠎"[e]()||h_&&f_[e].name!==e})}("trim")},{trim:function(){return m_(this)}});var g_,__,v_,y_={exports:{}},E_=gs,b_=a,w_=r,I_=F,T_=W,S_=We,k_=ln,A_=pe,R_=Kt,C_=Jr,D_=mn,O_=G,L_=xa,x_=uo,N_=tt,P_=qe,M_=Rr.enforce,U_=Rr.get,B_=w_.Int8Array,F_=B_&&B_.prototype,V_=w_.Uint8ClampedArray,W_=V_&&V_.prototype,H_=B_&&L_(B_),j_=F_&&L_(F_),z_=Object.prototype,G_=w_.TypeError,q_=N_("toStringTag"),K_=P_("TYPED_ARRAY_TAG"),Y_="TypedArrayConstructor",X_=E_&&!!x_&&"Opera"!==k_(w_.opera),Z_=!1,J_={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Q_={BigInt64Array:8,BigUint64Array:8},$_=function(e){var t=L_(e);if(T_(t)){var r=U_(t);return r&&S_(r,Y_)?r[Y_]:$_(t)}},ev=function(e){if(!T_(e))return!1;var t=k_(e);return S_(J_,t)||S_(Q_,t)};for(g_ in J_)(v_=(__=w_[g_])&&__.prototype)?M_(v_)[Y_]=__:X_=!1;for(g_ in Q_)(v_=(__=w_[g_])&&__.prototype)&&(M_(v_)[Y_]=__);if((!X_||!I_(H_)||H_===Function.prototype)&&(H_=function(){throw new G_("Incorrect invocation")},X_))for(g_ in J_)w_[g_]&&x_(w_[g_],H_);if((!X_||!j_||j_===z_)&&(j_=H_.prototype,X_))for(g_ in J_)w_[g_]&&x_(w_[g_].prototype,j_);if(X_&&L_(W_)!==j_&&x_(W_,j_),b_&&!S_(j_,q_))for(g_ in Z_=!0,D_(j_,q_,{configurable:!0,get:function(){return T_(this)?this[K_]:void 0}}),J_)w_[g_]&&R_(w_[g_].prototype,K_,g_);var tv={NATIVE_ARRAY_BUFFER_VIEWS:X_,TYPED_ARRAY_TAG:Z_&&K_,aTypedArray:function(e){if(ev(e))return e;throw new G_("Target is not a typed array")},aTypedArrayConstructor:function(e){if(I_(e)&&(!x_||O_(H_,e)))return e;throw new G_(A_(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(b_){if(r)for(var n in J_){var a=w_[n];if(a&&S_(a.prototype,e))try{delete a.prototype[e]}catch(EU){try{a.prototype[e]=t}catch(o){}}}j_[e]&&!r||C_(j_,e,r?t:X_&&F_[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,n;if(b_){if(x_){if(r)for(i in J_)if((n=w_[i])&&S_(n,e))try{delete n[e]}catch(EU){}if(H_[e]&&!r)return;try{return C_(H_,e,r?t:X_&&H_[e]||t)}catch(EU){}}for(i in J_)!(n=w_[i])||n[e]&&!r||C_(n,e,t)}},getTypedArrayConstructor:$_,isView:function(e){if(!T_(e))return!1;var t=k_(e);return"DataView"===t||S_(J_,t)||S_(Q_,t)},isTypedArray:ev,TypedArray:H_,TypedArrayPrototype:j_},rv=r,iv=n,nv=dp,av=tv.NATIVE_ARRAY_BUFFER_VIEWS,ov=rv.ArrayBuffer,sv=rv.Int8Array,cv=!av||!iv(function(){sv(1)})||!iv(function(){new sv(-1)})||!nv(function(e){new sv,new sv(null),new sv(1.5),new sv(e)},!0)||iv(function(){return 1!==new sv(new ov(2),1,void 0).length}),lv=W,dv=Math.floor,uv=Number.isInteger||function(e){return!lv(e)&&isFinite(e)&&dv(e)===e},hv=ri,pv=RangeError,fv=function(e){var t=hv(e);if(t<0)throw new pv("The argument can't be less than 0");return t},mv=RangeError,gv=function(e,t){var r=fv(e);if(r%t)throw new mv("Wrong offset");return r},_v=Math.floor,vv=ln,yv=lt,Ev=TypeError,bv=function(e){var t=yv(e,"number");if("number"==typeof t)throw new Ev("Can't convert number to bigint");return BigInt(t)},wv=ed,Iv=l,Tv=_e,Sv=Vl,kv=Be,Av=ui,Rv=Wh,Cv=Nh,Dv=Rh,Ov=function(e){var t=vv(e);return"BigInt64Array"===t||"BigUint64Array"===t},Lv=tv.aTypedArrayConstructor,xv=bv,Nv=function(e){var t=Sv(this),r=arguments.length,i=r>1?arguments[1]:void 0,n=void 0!==i;n&&Tv(i);var a,o,s,c,l,d,u,h,p=kv(e),f=Cv(p);if(f&&!Dv(f))for(h=(u=Rv(p,f)).next,p=[];!(d=Iv(h,u)).done;)p.push(d.value);for(n&&r>2&&(i=wv(i,arguments[2])),o=Av(p),s=new(Lv(t))(o),c=Ov(s),a=0;o>a;a++)l=n?i(p[a],a):p[a],s[a]=c?xv(l):+l;return s},Pv=us,Mv=Ml,Uv=W,Bv=tt("species"),Fv=Array,Vv=function(e){var t;return Pv(e)&&(t=e.constructor,(Mv(t)&&(t===Fv||Pv(t.prototype))||Uv(t)&&null===(t=t[Bv]))&&(t=void 0)),void 0===t?Fv:t},Wv=a,Hv=Rt,jv=g,zv=function(e,t,r){Wv?Hv.f(e,t,jv(0,r)):e[t]=r},Gv=ed,qv=D,Kv=Be,Yv=ui,Xv=function(e,t){return new(Vv(e))(0===t?0:t)},Zv=zv,Jv=function(e){var t=1===e,r=2===e,i=3===e,n=4===e,a=6===e,o=7===e,s=5===e||a;return function(c,l,d){for(var u,h,p=Kv(c),f=qv(p),m=Yv(f),g=Gv(l,d),_=0,v=0,y=t?Xv(c,m):r||o?Xv(c,0):void 0;m>_;_++)if((s||_ in f)&&(h=g(u=f[_],_,p),e))if(t)Zv(y,_,h);else if(h)switch(e){case 3:return!0;case 5:return u;case 6:return _;case 2:Zv(y,v++,u)}else switch(e){case 4:return!1;case 7:Zv(y,v++,u)}return a?-1:i||n?n:y}},Qv={forEach:Jv(0),map:Jv(1),filter:Jv(2),some:Jv(3),every:Jv(4),find:Jv(5),findIndex:Jv(6),filterReject:Jv(7)},$v=ui,ey=en,ty=r,ry=l,iy=a,ny=cv,ay=tv,oy=Xc,sy=bs,cy=g,ly=Kt,dy=uv,uy=Ss,hy=gv,py=function(e){var t=+e;if(t!=t||t<=0)return 0;if(t>=255)return 255;var r=_v(t);return r+.5<t?r+1:t<r+.5||r%2==0?r:r+1},fy=ht,my=We,gy=ln,_y=W,vy=ue,yy=ca,Ey=G,by=uo,wy=Qr.f,Iy=Nv,Ty=Qv.forEach,Sy=el,ky=mn,Ay=Rt,Ry=i,Cy=function(e,t,r){for(var i=0,n=arguments.length>2?r:$v(t),a=new e(n);n>i;)a[i]=t[i++];return a},Dy=Ys,Oy=Rr.get,Ly=Rr.set,xy=Rr.enforce,Ny=Ay.f,Py=Ry.f,My=ty.RangeError,Uy=oy.ArrayBuffer,By=Uy.prototype,Fy=oy.DataView,Vy=ay.NATIVE_ARRAY_BUFFER_VIEWS,Wy=ay.TYPED_ARRAY_TAG,Hy=ay.TypedArray,jy=ay.TypedArrayPrototype,zy=ay.isTypedArray,Gy="BYTES_PER_ELEMENT",qy="Wrong length",Ky=function(e,t){ky(e,t,{configurable:!0,get:function(){return Oy(this)[t]}})},Yy=function(e){var t;return Ey(By,e)||"ArrayBuffer"===(t=gy(e))||"SharedArrayBuffer"===t},Xy=function(e,t){return zy(e)&&!vy(t)&&t in e&&dy(+t)&&t>=0},Zy=function(e,t){return t=fy(t),Xy(e,t)?cy(2,e[t]):Py(e,t)},Jy=function(e,t,r){return t=fy(t),!(Xy(e,t)&&_y(r)&&my(r,"value"))||my(r,"get")||my(r,"set")||r.configurable||my(r,"writable")&&!r.writable||my(r,"enumerable")&&!r.enumerable?Ny(e,t,r):(e[t]=r.value,e)};iy?(Vy||(Ry.f=Zy,Ay.f=Jy,Ky(jy,"buffer"),Ky(jy,"byteOffset"),Ky(jy,"byteLength"),Ky(jy,"length")),ey({target:"Object",stat:!0,forced:!Vy},{getOwnPropertyDescriptor:Zy,defineProperty:Jy}),y_.exports=function(e,t,r){var i=e.match(/\d+/)[0]/8,n=e+(r?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=ty[n],c=s,l=c&&c.prototype,d={},u=function(e,t){Ny(e,t,{get:function(){return function(e,t){var r=Oy(e);return r.view[a](t*i+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var a=Oy(e);a.view[o](t*i+a.byteOffset,r?py(n):n,!0)}(this,t,e)},enumerable:!0})};Vy?ny&&(c=t(function(e,t,r,n){return sy(e,l),Dy(_y(t)?Yy(t)?void 0!==n?new s(t,hy(r,i),n):void 0!==r?new s(t,hy(r,i)):new s(t):zy(t)?Cy(c,t):ry(Iy,c,t):new s(uy(t)),e,c)}),by&&by(c,Hy),Ty(wy(s),function(e){e in c||ly(c,e,s[e])}),c.prototype=l):(c=t(function(e,t,r,n){sy(e,l);var a,o,s,d=0,h=0;if(_y(t)){if(!Yy(t))return zy(t)?Cy(c,t):ry(Iy,c,t);a=t,h=hy(r,i);var p=t.byteLength;if(void 0===n){if(p%i)throw new My(qy);if((o=p-h)<0)throw new My(qy)}else if((o=uy(n)*i)+h>p)throw new My(qy);s=o/i}else s=uy(t),a=new Uy(o=s*i);for(Ly(e,{buffer:a,byteOffset:h,byteLength:o,length:s,view:new Fy(a)});d<s;)u(e,d++)}),by&&by(c,Hy),l=c.prototype=yy(jy)),l.constructor!==c&&ly(l,"constructor",c),xy(l).TypedArrayConstructor=c,Wy&&ly(l,Wy,n);var h=c!==s;d[n]=c,ey({global:!0,constructor:!0,forced:h,sham:!Vy},d),Gy in c||ly(c,Gy,i),Gy in l||ly(l,Gy,i),Sy(n)}):y_.exports=function(){};var Qy=y_.exports;Qy("Float32",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Int32",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint8",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint16",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint32",function(e){return function(t,r,i){return e(this,t,r,i)}});var $y=js,eE=bv,tE=ln,rE=l,iE=n,nE=tv.aTypedArray,aE=tv.exportTypedArrayMethod,oE=b("".slice);aE("fill",function(e){var t=arguments.length;nE(this);var r="Big"===oE(tE(this),0,3)?eE(e):+e;return rE($y,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},iE(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})),(0,tv.exportTypedArrayStaticMethod)("from",Nv,cv);var sE=r,cE=l,lE=tv,dE=ui,uE=gv,hE=Be,pE=n,fE=sE.RangeError,mE=sE.Int8Array,gE=mE&&mE.prototype,_E=gE&&gE.set,vE=lE.aTypedArray,yE=lE.exportTypedArrayMethod,EE=!pE(function(){var e=new Uint8ClampedArray(2);return cE(_E,e,{length:1,0:3},1),3!==e[1]}),bE=EE&&lE.NATIVE_ARRAY_BUFFER_VIEWS&&pE(function(){var e=new mE(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]});yE("set",function(e){vE(this);var t=uE(arguments.length>1?arguments[1]:void 0,1),r=hE(e);if(EE)return cE(_E,this,r,t);var i=this.length,n=dE(r),a=0;if(n+t>i)throw new fE("Wrong length");for(;a<n;)this[t+a]=r[a++]},!EE||bE);var wE=zs,IE=Math.floor,TE=function(e,t){var r=e.length;if(r<8)for(var i,n,a=1;a<r;){for(n=a,i=e[a];n&&t(e[n-1],i)>0;)e[n]=e[--n];n!==a++&&(e[n]=i)}else for(var o=IE(r/2),s=TE(wE(e,0,o),t),c=TE(wE(e,o),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},SE=TE,kE=Y.match(/firefox\/(\d+)/i),AE=!!kE&&+kE[1],RE=/MSIE|Trident/.test(Y),CE=Y.match(/AppleWebKit\/(\d+)\./),DE=!!CE&&+CE[1],OE=ol,LE=n,xE=_e,NE=SE,PE=AE,ME=RE,UE=te,BE=DE,FE=tv.aTypedArray,VE=tv.exportTypedArrayMethod,WE=r.Uint16Array,HE=WE&&OE(WE.prototype.sort),jE=!(!HE||LE(function(){HE(new WE(2),null)})&&LE(function(){HE(new WE(2),{})})),zE=!!HE&&!LE(function(){if(UE)return UE<74;if(PE)return PE<67;if(ME)return!0;if(BE)return BE<602;var e,t,r=new WE(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(HE(r,function(e,t){return(e/4|0)-(t/4|0)}),e=0;e<516;e++)if(r[e]!==i[e])return!0});VE("sort",function(e){return void 0!==e&&xE(e),zE?HE(this,e):NE(FE(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?t!=t?0:-1:t!=t?1:0===t&&0===r?1/t>0?1/r>0?0:1:1/r>0?-1:0:t>r?1:t<r?-1:0}}(e))},!zE||jE);var GE=en,qE=l,KE=b,YE=N,XE=F,ZE=W,JE=Qp,QE=hn,$E=Ee,eb=hf,tb=Ig,rb=tt("replace"),ib=TypeError,nb=KE("".indexOf);KE("".replace);var ab=KE("".slice),ob=Math.max;GE({target:"String",proto:!0},{replaceAll:function(e,t){var r,i,n,a,o,s,c,l,d,u=YE(this),h=0,p="";if(ZE(e)){if(JE(e)&&(r=QE(YE(eb(e))),!~nb(r,"g")))throw new ib("`.replaceAll` does not allow non-global regexes");if(i=$E(e,rb))return qE(i,e,u,t)}for(n=QE(u),a=QE(e),(o=XE(t))||(t=QE(t)),s=a.length,c=ob(1,s),l=nb(n,a);-1!==l;)d=o?QE(t(a,l,n)):tb(a,n,l,[],void 0,t),p+=ab(n,h,l)+d,h=l+s,l=l+c>n.length?-1:nb(n,a,l+c);return h<n.length&&(p+=ab(n,h)),p}});var sb={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},cb=gt("span").classList,lb=cb&&cb.constructor&&cb.constructor.prototype,db=lb===Object.prototype?void 0:lb,ub=Qv.forEach,hb=ts("forEach")?[].forEach:function(e){return ub(this,e,arguments.length>1?arguments[1]:void 0)},pb=r,fb=sb,mb=db,gb=hb,_b=Kt,vb=function(e){if(e&&e.forEach!==gb)try{_b(e,"forEach",gb)}catch(EU){e.forEach=gb}};for(var yb in fb)fb[yb]&&vb(pb[yb]&&pb[yb].prototype);vb(mb);var Eb=r,bb=sb,wb=db,Ib=zo,Tb=Kt,Sb=qa,kb=tt("iterator"),Ab=Ib.values,Rb=function(e,t){if(e){if(e[kb]!==Ab)try{Tb(e,kb,Ab)}catch(EU){e[kb]=Ab}if(Sb(e,t,!0),bb[t])for(var r in Ib)if(e[r]!==Ib[r])try{Tb(e,r,Ib[r])}catch(EU){e[r]=Ib[r]}}};for(var Cb in bb)Rb(Eb[Cb]&&Eb[Cb].prototype,Cb);Rb(wb,"DOMTokenList");var Db=Od.clear;en({global:!0,bind:!0,enumerable:!0,forced:r.clearImmediate!==Db},{clearImmediate:Db});var Ob=r,Lb=Zl,xb=F,Nb=os,Pb=Y,Mb=zs,Ub=rd,Bb=Ob.Function,Fb=/MSIE .\./.test(Pb)||"BUN"===Nb&&function(){var e=Ob.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),Vb=en,Wb=r,Hb=Od.set,jb=function(e,t){var r=t?2:1;return Fb?function(i,n){var a=Ub(arguments.length,1)>r,o=xb(i)?i:Bb(i),s=a?Mb(arguments,r):[],c=a?function(){Lb(o,this,s)}:o;return t?e(c,n):e(c)}:e},zb=Wb.setImmediate?jb(Hb,!1):Hb;Vb({global:!0,bind:!0,enumerable:!0,forced:Wb.setImmediate!==zb},{setImmediate:zb});var Gb=pg.charAt,qb=hn,Kb=Rr,Yb=Oo,Xb=Lo,Zb="String Iterator",Jb=Kb.set,Qb=Kb.getterFor(Zb);Yb(String,"String",function(e){Jb(this,{type:Zb,string:qb(e),index:0})},function(){var e,t=Qb(this),r=t.string,i=t.index;return i>=r.length?Xb(void 0,!0):(e=Gb(r,i),t.index+=e.length,Xb(e,!1))});var $b=n,ew=a,tw=tt("iterator"),rw=!$b(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&&!ew||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[tw]||"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}),iw=a,nw=b,aw=l,ow=n,sw=Vn,cw=ki,lw=d,dw=Be,uw=D,hw=Object.assign,pw=Object.defineProperty,fw=nw([].concat),mw=!hw||ow(function(){if(iw&&1!==hw({b:1},hw(pw({},"a",{enumerable:!0,get:function(){pw(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!==hw({},e)[r]||sw(hw({},t)).join("")!==i})?function(e,t){for(var r=dw(e),i=arguments.length,n=1,a=cw.f,o=lw.f;i>n;)for(var s,c=uw(arguments[n++]),l=a?fw(sw(c),a(c)):sw(c),d=l.length,u=0;d>u;)s=l[u++],iw&&!aw(o,c,s)||(r[s]=c[s]);return r}:hw,gw=xt,_w=Gh,vw=a,yw=us,Ew=TypeError,bw=Object.getOwnPropertyDescriptor,ww=vw&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(EU){return EU instanceof TypeError}}(),Iw=ed,Tw=l,Sw=Be,kw=function(e,t,r,i){try{return i?t(gw(r)[0],r[1]):t(r)}catch(EU){_w(e,"throw",EU)}},Aw=Rh,Rw=Ml,Cw=ui,Dw=zv,Ow=ww?function(e,t){if(yw(e)&&!bw(e,"length").writable)throw new Ew("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},Lw=Wh,xw=Nh,Nw=Gh,Pw=Array,Mw=b,Uw=2147483647,Bw=/[^\0-\u007E]/,Fw=/[.\u3002\uFF0E\uFF61]/g,Vw="Overflow: input needs wider integers to process",Ww=RangeError,Hw=Mw(Fw.exec),jw=Math.floor,zw=String.fromCharCode,Gw=Mw("".charCodeAt),qw=Mw([].join),Kw=Mw([].push),Yw=Mw("".replace),Xw=Mw("".split),Zw=Mw("".toLowerCase),Jw=function(e){return e+22+75*(e<26)},Qw=function(e,t,r){var i=0;for(e=r?jw(e/700):e>>1,e+=jw(e/t);e>455;)e=jw(e/35),i+=36;return jw(i+36*e/(e+38))},$w=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=Gw(e,r++);if(n>=55296&&n<=56319&&r<i){var a=Gw(e,r++);56320==(64512&a)?Kw(t,((1023&n)<<10)+(1023&a)+65536):(Kw(t,n),r--)}else Kw(t,n)}return t}(e);var r,i,n=e.length,a=128,o=0,s=72;for(r=0;r<e.length;r++)(i=e[r])<128&&Kw(t,zw(i));var c=t.length,l=c;for(c&&Kw(t,"-");l<n;){var d=Uw;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<d&&(d=i);var u=l+1;if(d-a>jw((Uw-o)/u))throw new Ww(Vw);for(o+=(d-a)*u,a=d,r=0;r<e.length;r++){if((i=e[r])<a&&++o>Uw)throw new Ww(Vw);if(i===a){for(var h=o,p=36;;){var f=p<=s?1:p>=s+26?26:p-s;if(h<f)break;var m=h-f,g=36-f;Kw(t,zw(Jw(f+m%g))),h=jw(m/g),p+=36}Kw(t,zw(Jw(h))),s=Qw(o,u,l===c),o=0,l++}}o++,a++}return qw(t,"")},eI=en,tI=b,rI=oi,iI=RangeError,nI=String.fromCharCode,aI=String.fromCodePoint,oI=tI([].join);eI({target:"String",stat:!0,arity:1,forced:!!aI&&1!==aI.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,n=0;i>n;){if(rI(t=+arguments[n],1114111)!==t)throw new iI(t+" is not a valid code point");r[n++]=t<65536?nI(t):nI(55296+((t-=65536)>>10),t%1024+56320)}return oI(r,"")}});var sI=en,cI=r,lI=Pd,dI=z,uI=l,hI=b,pI=a,fI=rw,mI=Jr,gI=mn,_I=vs,vI=qa,yI=$a,EI=Rr,bI=bs,wI=F,II=We,TI=ed,SI=ln,kI=xt,AI=W,RI=hn,CI=ca,DI=g,OI=Wh,LI=Nh,xI=Lo,NI=rd,PI=SE,MI=tt("iterator"),UI="URLSearchParams",BI=UI+"Iterator",FI=EI.set,VI=EI.getterFor(UI),WI=EI.getterFor(BI),HI=lI("fetch"),jI=lI("Request"),zI=lI("Headers"),GI=jI&&jI.prototype,qI=zI&&zI.prototype,KI=cI.TypeError,YI=cI.encodeURIComponent,XI=String.fromCharCode,ZI=dI("String","fromCodePoint"),JI=parseInt,QI=hI("".charAt),$I=hI([].join),eT=hI([].push),tT=hI("".replace),rT=hI([].shift),iT=hI([].splice),nT=hI("".split),aT=hI("".slice),oT=hI(/./.exec),sT=/\+/g,cT=/^[0-9a-f]+$/i,lT=function(e,t){var r=aT(e,t,t+2);return oT(cT,r)?JI(r,16):NaN},dT=function(e){for(var t=0,r=128;r>0&&0!==(e&r);r>>=1)t++;return t},uT=function(e){var t=null,r=e.length;switch(r){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 null===t||t>1114111||t>=55296&&t<=57343||t<(r>3?65536:r>2?2048:r>1?128:0)?null:t},hT=function(e){for(var t=(e=tT(e,sT," ")).length,r="",i=0;i<t;){var n=QI(e,i);if("%"===n){if("%"===QI(e,i+1)||i+3>t){r+="%",i++;continue}var a=lT(e,i+1);if(a!=a){r+=n,i++;continue}i+=2;var o=dT(a);if(0===o)n=XI(a);else{if(1===o||o>4){r+="�",i++;continue}for(var s=[a],c=1;c<o&&!(++i+3>t||"%"!==QI(e,i));){var l=lT(e,i+1);if(l!=l||l>191||l<128)break;if(1===c){if(224===a&&l<160)break;if(237===a&&l>159)break;if(240===a&&l<144)break;if(244===a&&l>143)break}eT(s,l),i+=2,c++}if(s.length!==o){r+="�";continue}var d=uT(s);if(null===d){for(var u=0;u<o;u++)r+="�";i++;continue}n=ZI(d)}}r+=n,i++}return r},pT=/[!'()~]|%20/g,fT={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},mT=function(e){return fT[e]},gT=function(e){return tT(YI(e),pT,mT)},_T=yI(function(e,t){FI(this,{type:BI,target:VI(e).entries,index:0,kind:t})},UI,function(){var e=WI(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,xI(void 0,!0);var i=t[r];switch(e.kind){case"keys":return xI(i.key,!1);case"values":return xI(i.value,!1)}return xI([i.key,i.value],!1)},!0),vT=function(e){this.entries=[],this.url=null,void 0!==e&&(AI(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===QI(e,0)?aT(e,1):e:RI(e)))};vT.prototype={type:UI,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,o,s,c=this.entries,l=LI(e);if(l)for(r=(t=OI(e,l)).next;!(i=uI(r,t)).done;){if(a=(n=OI(kI(i.value))).next,(o=uI(a,n)).done||(s=uI(a,n)).done||!uI(a,n).done)throw new KI("Expected sequence with length 2");eT(c,{key:RI(o.value),value:RI(s.value)})}else for(var d in e)II(e,d)&&eT(c,{key:d,value:RI(e[d])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,n=nT(e,"&"),a=0;a<n.length;)(t=n[a++]).length&&(r=nT(t,"="),eT(i,{key:hT(rT(r)),value:hT($I(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],eT(r,gT(e.key)+"="+gT(e.value));return $I(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var yT=function(){bI(this,ET);var e=FI(this,new vT(arguments.length>0?arguments[0]:void 0));pI||(this.size=e.entries.length)},ET=yT.prototype;if(_I(ET,{append:function(e,t){var r=VI(this);NI(arguments.length,2),eT(r.entries,{key:RI(e),value:RI(t)}),pI||this.size++,r.updateURL()},delete:function(e){for(var t=VI(this),r=NI(arguments.length,1),i=t.entries,n=RI(e),a=r<2?void 0:arguments[1],o=void 0===a?a:RI(a),s=0;s<i.length;){var c=i[s];c.key!==n||void 0!==o&&c.value!==o?s++:iT(i,s,1)}pI||(this.size=i.length),t.updateURL()},get:function(e){var t=VI(this).entries;NI(arguments.length,1);for(var r=RI(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){var t=VI(this).entries;NI(arguments.length,1);for(var r=RI(e),i=[],n=0;n<t.length;n++)t[n].key===r&&eT(i,t[n].value);return i},has:function(e){for(var t=VI(this).entries,r=NI(arguments.length,1),i=RI(e),n=r<2?void 0:arguments[1],a=void 0===n?n:RI(n),o=0;o<t.length;){var s=t[o++];if(s.key===i&&(void 0===a||s.value===a))return!0}return!1},set:function(e,t){var r=VI(this);NI(arguments.length,2);for(var i,n=r.entries,a=!1,o=RI(e),s=RI(t),c=0;c<n.length;c++)(i=n[c]).key===o&&(a?iT(n,c--,1):(a=!0,i.value=s));a||eT(n,{key:o,value:s}),pI||(this.size=n.length),r.updateURL()},sort:function(){var e=VI(this);PI(e.entries,function(e,t){return e.key>t.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,r=VI(this).entries,i=TI(e,arguments.length>1?arguments[1]:void 0),n=0;n<r.length;)i((t=r[n++]).value,t.key,this)},keys:function(){return new _T(this,"keys")},values:function(){return new _T(this,"values")},entries:function(){return new _T(this,"entries")}},{enumerable:!0}),mI(ET,MI,ET.entries,{name:"entries"}),mI(ET,"toString",function(){return VI(this).serialize()},{enumerable:!0}),pI&&gI(ET,"size",{get:function(){return VI(this).entries.length},configurable:!0,enumerable:!0}),vI(yT,UI),sI({global:!0,constructor:!0,forced:!fI},{URLSearchParams:yT}),!fI&&wI(zI)){var bT=hI(qI.has),wT=hI(qI.set),IT=function(e){if(AI(e)){var t,r=e.body;if(SI(r)===UI)return t=e.headers?new zI(e.headers):new zI,bT(t,"content-type")||wT(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),CI(e,{body:DI(0,RI(r)),headers:DI(0,t)})}return e};if(wI(HI)&&sI({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return HI(e,arguments.length>1?IT(arguments[1]):{})}}),wI(jI)){var TT=function(e){return bI(this,GI),new jI(e,arguments.length>1?IT(arguments[1]):{})};GI.constructor=TT,TT.prototype=GI,sI({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:TT})}}var ST,kT=en,AT=a,RT=rw,CT=r,DT=ed,OT=b,LT=Jr,xT=mn,NT=bs,PT=We,MT=mw,UT=function(e){var t=Rw(this),r=arguments.length,i=r>1?arguments[1]:void 0,n=void 0!==i;n&&(i=Iw(i,r>2?arguments[2]:void 0));var a,o,s,c,l,d,u=Sw(e),h=xw(u),p=0;if(!h||this===Pw&&Aw(h))for(a=Cw(u),o=t?new this(a):Pw(a);a>p;p++)d=n?i(u[p],p):u[p],Dw(o,p,d);else for(o=t?new this:[],l=(c=Lw(u,h)).next;!(s=Tw(l,c)).done;p++){d=n?kw(c,i,[s.value,p],!0):s.value;try{Dw(o,p,d)}catch(EU){Nw(c,"throw",EU)}}return Ow(o,p),o},BT=zs,FT=pg.codeAt,VT=function(e){var t,r,i=[],n=Xw(Yw(Zw(e),Fw,"."),".");for(t=0;t<n.length;t++)r=n[t],Kw(i,Hw(Bw,r)?"xn--"+$w(r):r);return qw(i,".")},WT=hn,HT=qa,jT=rd,zT={URLSearchParams:yT,getState:VI},GT=Rr,qT=GT.set,KT=GT.getterFor("URL"),YT=zT.URLSearchParams,XT=zT.getState,ZT=CT.URL,JT=CT.TypeError,QT=CT.encodeURIComponent,$T=CT.parseInt,eS=Math.floor,tS=Math.pow,rS=OT("".charAt),iS=OT(/./.exec),nS=OT([].join),aS=OT(1.1.toString),oS=OT([].pop),sS=OT([].push),cS=OT("".replace),lS=OT([].shift),dS=OT("".split),uS=OT("".slice),hS=OT("".toLowerCase),pS=OT([].unshift),fS="Invalid scheme",mS="Invalid host",gS="Invalid port",_S=/[a-z]/i,vS=/[\d+\-.a-z]/i,yS=/\d/,ES=/^0x/i,bS=/^[0-7]+$/,wS=/^\d+$/,IS=/^[\da-f]+$/i,TS=/[\0\t\n\r #%/:<>?@[\\\]^|]/,SS=/[\0\t\n\r #/:<>?@[\\\]^|]/,kS=/^[\u0000-\u0020]+/,AS=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,RS=/[\t\n\r]/g,CS=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)pS(t,e%256),e=eS(e/256);return nS(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,n=0,a=0;a<8;a++)0!==e[a]?(n>r&&(t=i,r=n),i=null,n=0):(null===i&&(i=a),++n);return n>r?i:t}(e),r=0;r<8;r++)n&&0===e[r]||(n&&(n=!1),i===r?(t+=r?":":"::",n=!0):(t+=aS(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},DS={},OS=MT({},DS,{" ":1,'"':1,"#":1,"<":1,">":1}),LS=MT({},OS,{"'":1}),xS=MT({},DS,{" ":1,'"':1,"<":1,">":1,"`":1}),NS=MT({},xS,{"#":1,"?":1,"{":1,"}":1,"^":1}),PS=MT({},NS,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),MS=function(e,t){var r=FT(e,0);return r>=32&&r<127&&!PT(t,e)?e:"'"===e&&PT(t,e)?"%27":QT(e)},US={ftp:21,file:null,http:80,https:443,ws:80,wss:443},BS=function(e,t){var r;return 2===e.length&&iS(_S,rS(e,0))&&(":"===(r=rS(e,1))||!t&&"|"===r)},FS=function(e){var t;return e.length>1&&BS(uS(e,0,2))&&(2===e.length||"/"===(t=rS(e,2))||"\\"===t||"?"===t||"#"===t)},VS=function(e){return"."===e||"%2e"===hS(e)},WS=function(e){return".."===(e=hS(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},HS={},jS={},zS={},GS={},qS={},KS={},YS={},XS={},ZS={},JS={},QS={},$S={},ek={},tk={},rk={},ik={},nk={},ak={},ok={},sk={},ck={},lk=function(e,t,r){var i,n,a,o=WT(e);if(t){if(n=this.parse(o))throw new JT(n);this.searchParams=null}else{if(void 0!==r&&(i=new lk(r,!0)),n=this.parse(o,null,i))throw new JT(n);(a=XT(new YT)).bindURL(this),this.searchParams=a}};lk.prototype={type:"URL",parse:function(e,t,r){var i,n,a,o,s=this,c=t||HS,l=0,d="",u=!1,h=!1,p=!1;for(e=WT(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=cS(e,kS,""),e=cS(e,AS,"$1")),e=cS(e,RS,""),i=UT(e);l<=i.length;){switch(n=i[l],c){case HS:if(!n||!iS(_S,n)){if(t)return fS;c=zS;continue}d+=hS(n),c=jS;break;case jS:if(n&&iS(vS,n))d+=hS(n);else{if(":"!==n){if(t)return fS;d="",c=zS,l=0;continue}if(t&&(s.isSpecial()!==PT(US,d)||"file"===d&&(s.includesCredentials()||null!==s.port)||"file"===s.scheme&&""===s.host))return;if(s.scheme=d,t)return void(s.isSpecial()&&US[s.scheme]===s.port&&(s.port=null));d="","file"===s.scheme?c=tk:s.isSpecial()&&r&&r.scheme===s.scheme?c=GS:s.isSpecial()?c=XS:"/"===i[l+1]?(c=qS,l++):(s.cannotBeABaseURL=!0,sS(s.path,""),c=ok)}break;case zS:if(!r||r.cannotBeABaseURL&&"#"!==n)return fS;if(r.cannotBeABaseURL&&"#"===n){s.scheme=r.scheme,s.path=BT(r.path),s.query=r.query,s.fragment="",s.cannotBeABaseURL=!0,c=ck;break}c="file"===r.scheme?tk:KS;continue;case GS:if("/"!==n||"/"!==i[l+1]){c=KS;continue}c=ZS,l++;break;case qS:if("/"===n){c=JS;break}c=ak;continue;case KS:if(s.scheme=r.scheme,n===ST)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query=r.query;else if("/"===n||"\\"===n&&s.isSpecial())c=YS;else if("?"===n)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query="",c=sk;else{if("#"!==n){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.path.length&&s.path.length--,c=ak;continue}s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query=r.query,s.fragment="",c=ck}break;case YS:if(!s.isSpecial()||"/"!==n&&"\\"!==n){if("/"!==n){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,c=ak;continue}c=JS}else c=ZS;break;case XS:if(c=ZS,"/"!==n||"/"!==i[l+1])continue;l++;break;case ZS:if("/"!==n&&"\\"!==n){c=JS;continue}break;case JS:if("@"===n){u&&(d="%40"+d),u=!0,a=UT(d);for(var f=0;f<a.length;f++){var m=a[f];if(":"!==m||p){var g=MS(m,PS);p?s.password+=g:s.username+=g}else p=!0}d=""}else if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()){if(u&&""===d)return"Invalid authority";l-=UT(d).length+1,d="",c=QS}else d+=n;break;case QS:case $S:if(t&&"file"===s.scheme){c=ik;continue}if(":"!==n||h){if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()){if(s.isSpecial()&&""===d)return mS;if(t&&""===d&&(s.includesCredentials()||null!==s.port))return;if(o=s.parseHost(d))return o;if(d="",c=nk,t)return;continue}"["===n?h=!0:"]"===n&&(h=!1),d+=n}else{if(""===d)return mS;if(t===$S)return;if(o=s.parseHost(d))return o;d="",c=ek}break;case ek:if(!iS(yS,n)){if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()||t){if(""!==d){var _=$T(d,10);if(_>65535)return gS;s.port=s.isSpecial()&&_===US[s.scheme]?null:_,d=""}if(t)return;c=nk;continue}return gS}d+=n;break;case tk:if(s.scheme="file",s.host="","/"===n||"\\"===n)c=rk;else{if(!r||"file"!==r.scheme){c=ak;continue}switch(n){case ST:s.host=r.host,s.path=BT(r.path),s.query=r.query;break;case"?":s.host=r.host,s.path=BT(r.path),s.query="",c=sk;break;case"#":s.host=r.host,s.path=BT(r.path),s.query=r.query,s.fragment="",c=ck;break;default:s.host=r.host,FS(nS(BT(i,l),""))||(s.path=BT(r.path),s.shortenPath()),c=ak;continue}}break;case rk:if("/"===n||"\\"===n){c=ik;break}r&&"file"===r.scheme&&(s.host=r.host,!FS(nS(BT(i,l),""))&&BS(r.path[0],!0)&&sS(s.path,r.path[0])),c=ak;continue;case ik:if(n===ST||"/"===n||"\\"===n||"?"===n||"#"===n){if(!t&&BS(d))c=ak;else if(""===d){if(s.host="",t)return;c=nk}else{if(o=s.parseHost(d))return o;if("localhost"===s.host&&(s.host=""),t)return;d="",c=nk}continue}d+=n;break;case nk:if(s.isSpecial()){if(c=ak,"/"!==n&&"\\"!==n)continue}else if(t||"?"!==n)if(t||"#"!==n){if(n!==ST&&(c=ak,"/"!==n))continue}else s.fragment="",c=ck;else s.query="",c=sk;break;case ak:if(n===ST||"/"===n||"\\"===n&&s.isSpecial()||!t&&("?"===n||"#"===n)){if(WS(d)?(s.shortenPath(),"/"===n||"\\"===n&&s.isSpecial()||sS(s.path,"")):VS(d)?"/"===n||"\\"===n&&s.isSpecial()||sS(s.path,""):("file"===s.scheme&&!s.path.length&&BS(d)&&(null!==s.host&&""!==s.host&&(s.host=""),d=rS(d,0)+":"),sS(s.path,d)),d="","file"===s.scheme&&(n===ST||"?"===n||"#"===n))for(;s.path.length>1&&""===s.path[0];)lS(s.path);"?"===n?(s.query="",c=sk):"#"===n&&(s.fragment="",c=ck)}else d+=MS(n,NS);break;case ok:"?"===n?(s.query="",c=sk):"#"===n?(s.fragment="",c=ck):n!==ST&&(s.path[0]+=MS(n,DS));break;case sk:t||"#"!==n?n!==ST&&(s.query+=MS(n,s.isSpecial()?LS:OS)):(s.fragment="",c=ck);break;case ck:n!==ST&&(s.fragment+=MS(n,xS))}l++}},parseHost:function(e){var t,r,i;if("["===rS(e,0)){if("]"!==rS(e,e.length-1))return mS;if(t=function(e){var t,r,i,n,a,o,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=r=0;r<4&&iS(IS,h());)t=16*t+$T(h(),16),u++,r++;if("."===h()){if(0===r)return;if(u-=r,l>6)return;for(i=0;h();){if(n=null,i>0){if(!("."===h()&&i<4))return;u++}if(!iS(yS,h()))return;for(;iS(yS,h());){if(a=$T(h(),10),null===n)n=a;else{if(0===n)return;n=10*n+a}if(n>255)return;u++}c[l]=256*c[l]+n,2!==++i&&4!==i||l++}if(4!==i)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(o=l-d,l=7;0!==l&&o>0;)s=c[l],c[l--]=c[d+o-1],c[d+--o]=s;else if(8!==l)return;return c}(uS(e,1,-1)),!t)return mS;this.host=t}else if(this.isSpecial()){if(e=VT(e),iS(TS,e))return mS;if(function(e){var t,r,i=dS(e,".");if(""===i[i.length-1]){if(1===i.length)return!1;i.length--}return t=i[i.length-1],!!iS(wS,t)||!!iS(ES,t)&&(""===(r=uS(t,2))||!!iS(IS,r))}(e)){if(t=function(e){var t,r,i,n,a,o,s,c=dS(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return null;for(r=[],i=0;i<t;i++){if(""===(n=c[i]))return null;if(a=10,n.length>1&&"0"===rS(n,0)&&(a=iS(ES,n)?16:8,n=uS(n,8===a?1:2)),""===n)o=0;else{if(!iS(10===a?wS:8===a?bS:IS,n))return null;o=$T(n,a)}sS(r,o)}for(i=0;i<t;i++)if(o=r[i],i===t-1){if(o>=tS(256,5-t))return null}else if(o>255)return null;for(s=oS(r),i=0;i<r.length;i++)s+=r[i]*tS(256,3-i);return s}(e),null===t)return mS;this.host=t}else this.host=e}else{if(iS(SS,e))return mS;for(t="",r=UT(e),i=0;i<r.length;i++)t+=MS(r[i],DS);this.host=t}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return PT(US,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&BS(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,n=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,l=t+":";return null!==n?(l+="//",e.includesCredentials()&&(l+=r+(i?":"+i:"")+"@"),l+=CS(n),null!==a&&(l+=":"+a)):"file"===t&&(l+="//"),null===n&&!e.cannotBeABaseURL&&o.length>1&&""===o[0]&&(l+="/."),l+=e.cannotBeABaseURL?o[0]:o.length?"/"+nS(o,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw new JT(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new dk(this.path[0]).origin}catch(EU){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+CS(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(WT(e)+":",HS)},getUsername:function(){return this.username},setUsername:function(e){var t=UT(WT(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=MS(t[r],PS)}},getPassword:function(){return this.password},setPassword:function(e){var t=UT(WT(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=MS(t[r],PS)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?CS(e):CS(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,QS)},getHostname:function(){var e=this.host;return null===e?"":CS(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,$S)},getPort:function(){var e=this.port;return null===e?"":WT(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=WT(e))?this.port=null:this.parse(e,ek))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+nS(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,nk))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=WT(e))?this.query=null:("?"===rS(e,0)&&(e=uS(e,1)),this.query="",this.parse(e,sk)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=WT(e))?("#"===rS(e,0)&&(e=uS(e,1)),this.fragment="",this.parse(e,ck)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var dk=function(e){var t=NT(this,uk),r=jT(arguments.length,1)>1?arguments[1]:void 0,i=qT(t,new lk(e,!1,r));AT||(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())},uk=dk.prototype,hk=function(e,t){return{get:function(){return KT(this)[e]()},set:t&&function(e){return KT(this)[t](e)},configurable:!0,enumerable:!0}};if(AT&&(xT(uk,"href",hk("serialize","setHref")),xT(uk,"origin",hk("getOrigin")),xT(uk,"protocol",hk("getProtocol","setProtocol")),xT(uk,"username",hk("getUsername","setUsername")),xT(uk,"password",hk("getPassword","setPassword")),xT(uk,"host",hk("getHost","setHost")),xT(uk,"hostname",hk("getHostname","setHostname")),xT(uk,"port",hk("getPort","setPort")),xT(uk,"pathname",hk("getPathname","setPathname")),xT(uk,"search",hk("getSearch","setSearch")),xT(uk,"searchParams",hk("getSearchParams")),xT(uk,"hash",hk("getHash","setHash"))),LT(uk,"toJSON",function(){return KT(this).serialize()},{enumerable:!0}),LT(uk,"toString",function(){return KT(this).serialize()},{enumerable:!0}),ZT){var pk=ZT.createObjectURL,fk=ZT.revokeObjectURL;pk&&LT(dk,"createObjectURL",DT(pk,ZT)),fk&&LT(dk,"revokeObjectURL",DT(fk,ZT))}HT(dk,"URL"),kT({global:!0,constructor:!0,forced:!RT,sham:!AT},{URL:dk});var mk=l;en({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return mk(URL.prototype.toString,this)}});var gk,_k,vk=Object.create,yk=Object.defineProperty,Ek=Object.defineProperties,bk=Object.getOwnPropertyDescriptor,wk=Object.getOwnPropertyDescriptors,Ik=Object.getOwnPropertyNames,Tk=Object.getOwnPropertySymbols,Sk=Object.getPrototypeOf,kk=Object.prototype.hasOwnProperty,Ak=Object.prototype.propertyIsEnumerable,Rk=(e,t,r)=>t in e?yk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ck=(e,t)=>{for(var r in t||(t={}))kk.call(t,r)&&Rk(e,r,t[r]);if(Tk)for(var r of Tk(t))Ak.call(t,r)&&Rk(e,r,t[r]);return e},Dk=(e,t)=>Ek(e,wk(t)),Ok=(gk=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(gk,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):gk),Lk=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xk=(e,t)=>{for(var r in t)yk(e,r,{get:t[r],enumerable:!0})},Nk=(e,t,r)=>(r=null!=e?vk(Sk(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of Ik(t))!kk.call(e,n)&&n!==r&&yk(e,n,{get:()=>t[n],enumerable:!(i=bk(t,n))||i.enumerable});return e})(!t&&e&&e.__esModule?r:yk(r,"default",{value:e,enumerable:!0}),e)),Pk=(e,t,r,i)=>{for(var n,a=i>1?void 0:i?bk(t,r):t,o=e.length-1;o>=0;o--)(n=e[o])&&(a=(i?n(t,r,a):n(a))||a);return i&&a&&yk(t,r,a),a},Mk=(e,t,r)=>Rk(e,"symbol"!=typeof t?t+"":t,r),Uk=Lk((e,t)=>{!function(r){"object"==typeof e&&void 0!==t?t.exports=r():"function"==typeof define&&define.amd?define([],r):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=r()}(function(){return function e(t,r,i){function n(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof Ok&&Ok;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var d=r[o]={exports:{}};t[o][0].call(d.exports,function(e){return n(t[o][1][e]||e)},d,d.exports,e,t,r,i)}return r[o].exports}for(var a="function"==typeof Ok&&Ok,o=0;o<i.length;o++)n(i[o]);return n}({1:[function(e,t,r){var i=e("./utils"),n=e("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,o,s,c,l,d=[],u=0,h=e.length,p=h,f="string"!==i.getTypeOf(e);u<e.length;)p=h-u,n=f?(t=e[u++],r=u<h?e[u++]:0,u<h?e[u++]:0):(t=e.charCodeAt(u++),r=u<h?e.charCodeAt(u++):0,u<h?e.charCodeAt(u++):0),o=t>>2,s=(3&t)<<4|r>>4,c=1<p?(15&r)<<2|n>>6:64,l=2<p?63&n:64,d.push(a.charAt(o)+a.charAt(s)+a.charAt(c)+a.charAt(l));return d.join("")},r.decode=function(e){var t,r,i,o,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)===a.charAt(64)&&p--,e.charAt(e.length-2)===a.charAt(64)&&p--,p%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=n.uint8array?new Uint8Array(0|p):new Array(0|p);l<e.length;)t=a.indexOf(e.charAt(l++))<<2|(o=a.indexOf(e.charAt(l++)))>>4,r=(15&o)<<4|(s=a.indexOf(e.charAt(l++)))>>2,i=(3&s)<<6|(c=a.indexOf(e.charAt(l++))),h[d++]=t,64!==s&&(h[d++]=r),64!==c&&(h[d++]=i);return h}},{"./support":30,"./utils":32}],2:[function(e,t,r){var i=e("./external"),n=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function s(e,t,r,i,n){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=i,this.compressedContent=n}s.prototype={getContentWorker:function(){var e=new n(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("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 n(i.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,r){return e.pipe(new a).pipe(new o("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){var i=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){var i=e("./utils"),n=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==i.getTypeOf(e)?function(e,t,r){var i=n,a=0+r;e^=-1;for(var o=0;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}(0|t,e,e.length):function(e,t,r){var i=n,a=0+r;e^=-1;for(var o=0;o<a;o++)e=e>>>8^i[255&(e^t.charCodeAt(o))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){var i;i="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:i}},{lie:37}],7:[function(e,t,r){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=e("pako"),a=e("./utils"),o=e("./stream/GenericWorker"),s=i?"uint8array":"array";function c(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",a.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(s,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},r.compressWorker=function(e){return new c("Deflate",e)},r.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){function i(e,t){var r,i="";for(r=0;r<t;r++)i+=String.fromCharCode(255&e),e>>>=8;return i}function n(e,t,r,n,o,d){var u,h,p=e.file,f=e.compression,m=d!==s.utf8encode,g=a.transformTo("string",d(p.name)),_=a.transformTo("string",s.utf8encode(p.name)),v=p.comment,y=a.transformTo("string",d(v)),E=a.transformTo("string",s.utf8encode(v)),b=_.length!==p.name.length,w=E.length!==v.length,I="",T="",S="",k=p.dir,A=p.date,R={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(R.crc32=e.crc32,R.compressedSize=e.compressedSize,R.uncompressedSize=e.uncompressedSize);var C=0;t&&(C|=8),m||!b&&!w||(C|=2048);var D,O,L,x=0,N=0;k&&(x|=16),"UNIX"===o?(N=798,x|=(D=p.unixPermissions,O=k,L=D,D||(L=O?16893:33204),(65535&L)<<16)):(N=20,x|=function(e){return 63&(e||0)}(p.dosPermissions)),u=A.getUTCHours(),u<<=6,u|=A.getUTCMinutes(),u<<=5,u|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),b&&(T=i(1,1)+i(c(g),4)+_,I+="up"+i(T.length,2)+T),w&&(S=i(1,1)+i(c(y),4)+E,I+="uc"+i(S.length,2)+S);var P="";return P+="\n\0",P+=i(C,2),P+=f.magic,P+=i(u,2),P+=i(h,2),P+=i(R.crc32,4),P+=i(R.compressedSize,4),P+=i(R.uncompressedSize,4),P+=i(g.length,2),P+=i(I.length,2),{fileRecord:l.LOCAL_FILE_HEADER+P+g+I,dirRecord:l.CENTRAL_FILE_HEADER+i(N,2)+P+i(y.length,2)+"\0\0\0\0"+i(x,4)+i(n,4)+g+I+y}}var a=e("../utils"),o=e("../stream/GenericWorker"),s=e("../utf8"),c=e("../crc32"),l=e("../signature");function d(e,t,r,i){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(d,o),d.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-i-1))/r: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 r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(e){this.accumulate=!1;var t,r=this.streamFiles&&!e.file.dir,a=n(e,r,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(a.dirRecord),r)this.push({data:(t=e,l.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:a.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 r,n,o,s,c,d,u=this.bytesWritten-e,h=(r=this.dirRecords.length,n=u,o=e,s=this.zipComment,c=this.encodeFileName,d=a.transformTo("string",c(s)),l.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(r,2)+i(r,2)+i(n,4)+i(o,4)+i(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!!o.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(!o.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(i){}return!0},d.prototype.lock=function(){o.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,r){var i=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,t,r){var a=new n(t.streamFiles,r,t.platform,t.encodeFileName),o=0;try{e.forEach(function(e,r){o++;var n=function(e,t){var r=e||t,n=i[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(r.options.compression,t.compression),s=r.options.compressionOptions||t.compressionOptions||{},c=r.dir,l=r.date;r._compressWorker(n,s).withStreamInfo("file",{name:e,dir:c,date:l,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(a)}),a.entriesCount=o}catch(s){a.error(s)}return a}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){function i(){if(!(this instanceof i))return new i;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 i;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(e,t){return(new i).loadAsync(e,t)},i.external=e("./external"),t.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){var i=e("./utils"),n=e("./external"),a=e("./utf8"),o=e("./zipEntries"),s=e("./stream/Crc32Probe"),c=e("./nodejsUtils");function l(e){return new n.Promise(function(t,r){var i=e.decompressed.getContentWorker().pipe(new s);i.on("error",function(e){r(e)}).on("end",function(){i.streamInfo.crc32!==e.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}t.exports=function(e,t){var r=this;return t=i.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(e)?n.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(e){var r=new o(t);return r.load(e),r}).then(function(e){var r=[n.Promise.resolve(e)],i=e.files;if(t.checkCRC32)for(var a=0;a<i.length;a++)r.push(l(i[a]));return n.Promise.all(r)}).then(function(e){for(var n=e.shift(),a=n.files,o=0;o<a.length;o++){var s=a[o],c=s.fileNameStr,l=i.resolve(s.fileNameStr);r.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||(r.file(l).unsafeOriginalName=c)}return n.zipComment.length&&(r.comment=n.zipComment),r})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){var i=e("../utils"),n=e("../stream/GenericWorker");function a(e,t){n.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}i.inherits(a,n),a.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()})},a.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){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,r){function i(e,t,r){var i,n=a.getTypeOf(t),s=a.extend(r||{},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=m(e)),s.createFolders&&(i=f(e))&&g.call(this,i,!0);var u="string"===n&&!1===s.binary&&!1===s.base64;r&&void 0!==r.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",n="string");var _;_=t instanceof l||t instanceof o?t:h.isNode&&h.isStream(t)?new p(e,t):a.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var v=new d(e,_,s);this.files[e]=v}var n=e("./utf8"),a=e("./utils"),o=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"),f=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},m=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},g=function(e,t){return t=void 0!==t?t:c.createFolders,e=m(e),this.files[e]||i.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function _(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,r,i;for(t in this.files)i=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,i)},filter:function(e){var t=[];return this.forEach(function(r,i){e(r,i)&&t.push(i)}),t},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,i.call(this,e,t,r),this;if(_(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var a=this.files[this.root+e];return a&&!a.dir?a:null},folder:function(e){if(!e)return this;if(_(e))return this.filter(function(t,r){return r.dir&&e.test(t)});var t=this.root+e,r=g.call(this,t),i=this.clone();return i.root=r.name,i},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 r=this.filter(function(t,r){return r.name.slice(0,e.length)===e}),i=0;i<r.length;i++)delete this.files[r[i].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,r={};try{if((r=a.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");a.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var i=r.comment||this.comment||"";t=u.generateWorker(this,r,i)}catch(c){(t=new o("error")).error(c)}return new s(t,r.type||"string",r.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,r){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){var i=e("./DataReader");function n(e){i.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(n,i),n.prototype.byteAt=function(e){return this.data[this.zero+e]},n.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2),n=e.charCodeAt(3),a=this.length-4;0<=a;--a)if(this.data[a]===t&&this.data[a+1]===r&&this.data[a+2]===i&&this.data[a+3]===n)return a-this.zero;return-1},n.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2),n=e.charCodeAt(3),a=this.readData(4);return t===a[0]&&r===a[1]&&i===a[2]&&n===a[3]},n.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=n},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){var i=e("../utils");function n(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}n.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,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return i.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=n},{"../utils":32}],19:[function(e,t,r){var i=e("./Uint8ArrayReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.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=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){var i=e("./DataReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},n.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},n.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},n.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=n},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){var i=e("./ArrayReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.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=n},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){var i=e("../utils"),n=e("../support"),a=e("./ArrayReader"),o=e("./StringReader"),s=e("./NodeBufferReader"),c=e("./Uint8ArrayReader");t.exports=function(e){var t=i.getTypeOf(e);return i.checkSupport(t),"string"!==t||n.uint8array?"nodebuffer"===t?new s(e):n.uint8array?new c(i.transformTo("uint8array",e)):new a(i.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){var i=e("./GenericWorker"),n=e("../utils");function a(e){i.call(this,"ConvertWorker to "+e),this.destType=e}n.inherits(a,i),a.prototype.processChunk=function(e){this.push({data:n.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){var i=e("./GenericWorker"),n=e("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,i),a.prototype.processChunk=function(e){this.streamInfo.crc32=n(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){var i=e("../utils"),n=e("./GenericWorker");function a(e){n.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}i.inherits(a,n),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}n.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){var i=e("../utils"),n=e("./GenericWorker");function a(e){n.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=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}i.inherits(a,n),a.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.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=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){function i(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}i.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(e){this.emit("error",e)}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 r=0;r<this._listeners[e].length;r++)this._listeners[e][r].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=i},{}],29:[function(e,t,r){var i=e("../utils"),n=e("./ConvertWorker"),a=e("./GenericWorker"),o=e("../base64"),s=e("../support"),c=e("../external"),l=null;if(s.nodestream)try{l=e("../nodejs/NodejsStreamOutputAdapter")}catch(u){}function d(e,t,r){var o=t;switch(t){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=t,this._mimeType=r,i.checkSupport(o),this._worker=e.pipe(new n(o)),e.lock()}catch(s){this._worker=new a("error"),this._worker.error(s)}}d.prototype={accumulate:function(e){return function(e,t){return new c.Promise(function(r,n){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on("data",function(e,r){a.push(e),t&&t(r)}).on("error",function(e){a=[],n(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return i.newBlob(i.transformTo("arraybuffer",t),r);case"base64":return o.encode(t);default:return i.transformTo(e,t)}}(c,function(e,t){var r,i=0,n=null,a=0;for(r=0;r<t.length;r++)a+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(n=new Uint8Array(a),r=0;r<t.length;r++)n.set(t[r],i),i+=t[r].length;return n;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(s,a),l);r(e)}catch(t){n(t)}a=[]}).resume()})}(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){i.delay(t,arguments,r)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(i.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,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var i=new ArrayBuffer(0);try{r.blob=0===new Blob([i],{type:"application/zip"}).size}catch(a){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(i),r.blob=0===n.getBlob("application/zip").size}catch(Xk){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(a){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,r){for(var i=e("./utils"),n=e("./support"),a=e("./nodejsUtils"),o=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(){o.call(this,"utf-8 decode"),this.leftOver=null}function d(){o.call(this,"utf-8 encode")}s[254]=s[254]=1,r.utf8encode=function(e){return n.nodebuffer?a.newBufferFrom(e,"utf-8"):function(e){var t,r,i,a,o,s=e.length,c=0;for(a=0;a<s;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(i=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(i-56320),a++),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=n.uint8array?new Uint8Array(c):new Array(c),a=o=0;o<c;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(i=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(i-56320),a++),r<128?t[o++]=r:(r<2048?t[o++]=192|r>>>6:(r<65536?t[o++]=224|r>>>12:(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63),t[o++]=128|r>>>6&63),t[o++]=128|63&r);return t}(e)},r.utf8decode=function(e){return n.nodebuffer?i.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,a,o=e.length,c=new Array(2*o);for(t=r=0;t<o;)if((n=e[t++])<128)c[r++]=n;else if(4<(a=s[n]))c[r++]=65533,t+=a-1;else{for(n&=2===a?31:3===a?15:7;1<a&&t<o;)n=n<<6|63&e[t++],a--;1<a?c[r++]=65533:n<65536?c[r++]=n:(n-=65536,c[r++]=55296|n>>10&1023,c[r++]=56320|1023&n)}return c.length!==r&&(c.subarray?c=c.subarray(0,r):c.length=r),i.applyFromCharCode(c)}(e=i.transformTo(n.uint8array?"uint8array":"array",e))},i.inherits(l,o),l.prototype.processChunk=function(e){var t=i.transformTo(n.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+s[e[r]]>t?r:t}(t),c=t;o!==t.length&&(n.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:r.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=l,i.inherits(d,o),d.prototype.processChunk=function(e){this.push({data:r.utf8encode(e.data),meta:e.meta})},r.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,r){var i=e("./support"),n=e("./base64"),a=e("./nodejsUtils"),o=e("./external");function s(e){return e}function c(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),r.newBlob=function(e,t){r.checkSupport("blob");try{return new Blob([e],{type:t})}catch(n){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return i.append(e),i.getBlob(t)}catch(a){throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(e,t,r){var i=[],n=0,a=e.length;if(a<=r)return String.fromCharCode.apply(null,e);for(;n<a;)"array"===t||"nodebuffer"===t?i.push(String.fromCharCode.apply(null,e.slice(n,Math.min(n+r,a)))):i.push(String.fromCharCode.apply(null,e.subarray(n,Math.min(n+r,a)))),n+=r;return i.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch(e){return!1}}()}};function d(e){var t=65536,i=r.getTypeOf(e),n=!0;if("uint8array"===i?n=l.applyCanBeUsed.uint8array:"nodebuffer"===i&&(n=l.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return l.stringifyByChunk(e,i,t)}catch(a){t=Math.floor(t/2)}return l.stringifyByChar(e)}function u(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}r.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,a.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 a.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 a.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 a.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},r.transformTo=function(e,t){if(t=t||"",!e)return t;r.checkSupport(e);var i=r.getTypeOf(t);return h[i][e](t)},r.resolve=function(e){for(var t=e.split("/"),r=[],i=0;i<t.length;i++){var n=t[i];"."===n||""===n&&0!==i&&i!==t.length-1||(".."===n?r.pop():r.push(n))}return r.join("/")},r.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":i.nodebuffer&&a.isBuffer(e)?"nodebuffer":i.uint8array&&e instanceof Uint8Array?"uint8array":i.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(e){if(!i[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(e){var t,r,i="";for(r=0;r<(e||"").length;r++)i+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return i},r.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})},r.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},r.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},r.prepareContent=function(e,t,a,s,l){return o.Promise.resolve(t).then(function(e){return i.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new o.Promise(function(t,r){var i=new FileReader;i.onload=function(e){t(e.target.result)},i.onerror=function(e){r(e.target.error)},i.readAsArrayBuffer(e)}):e}).then(function(t){var d,u=r.getTypeOf(t);return u?("arraybuffer"===u?t=r.transformTo("uint8array",t):"string"===u&&(l?t=n.decode(t):a&&!0!==s&&(t=c(d=t,i.uint8array?new Uint8Array(d.length):new Array(d.length)))),t):o.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,r){var i=e("./reader/readerFor"),n=e("./utils"),a=e("./signature"),o=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 ("+n.pretty(t)+", expected "+n.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var i=this.reader.readString(4)===t;return this.reader.setIndex(r),i},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",r=n.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},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,r,i=this.zip64EndOfCentralSize-44;0<i;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},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(a.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(e=new o({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(a.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,a.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(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var i=t-r;if(0<i)this.isSignature(t,a.CENTRAL_FILE_HEADER)||(this.reader.zero=i);else if(i<0)throw new Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},prepareReader:function(e){this.reader=i(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,r){var i=e("./reader/readerFor"),n=e("./utils"),a=e("./compressedObject"),o=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,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-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 "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new a(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=i(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,i,n=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<n;)t=e.readInt(2),r=e.readInt(2),i=e.readData(r),this.extraFields[t]={id:t,length:r,value:i};e.setIndex(n)},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 r=n.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var i=this.findExtraFieldUnicodeComment();if(null!==i)this.fileCommentStr=i;else{var a=n.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(a)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=i(e.value);return 1!==t.readInt(1)||o(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=i(e.value);return 1!==t.readInt(1)||o(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,r){function i(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var n=e("./stream/StreamHelper"),a=e("./stream/DataWorker"),o=e("./utf8"),s=e("./compressedObject"),c=e("./stream/GenericWorker");i.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var i="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var a=!this._dataBinary;a&&!i&&(t=t.pipe(new o.Utf8EncodeWorker)),!a&&i&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(s){(t=new c("error")).error(s)}return new n(t,r,"")},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 r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new o.Utf8EncodeWorker)),s.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof c?this._data:new a(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++)i.prototype[l[u]]=d;t.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,r){(function(e){var r,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var a=0,o=new n(d),s=e.document.createTextNode("");o.observe(s,{characterData:!0}),r=function(){s.data=a=++a%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="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,r=function(){c.port2.postMessage(0)}}var l=[];function d(){var e,t;i=!0;for(var r=l.length;r;){for(t=l,l=[],e=-1;++e<r;)t[e]();r=l.length}i=!1}t.exports=function(e){1!==l.push(e)||i||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){var i=e("immediate");function n(){}var a={},o=["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!==n&&p(this,e)}function d(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function u(e,t,r){i(function(){var i;try{i=t(r)}catch(nL){return a.reject(e,nL)}i===e?a.reject(e,new TypeError("Cannot resolve promise with itself")):a.resolve(e,i)})}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 r=!1;function i(t){r||(r=!0,a.reject(e,t))}function n(t){r||(r=!0,a.resolve(e,t))}var o=f(function(){t(n,i)});"error"===o.status&&i(o.value)}function f(e,t){var r={};try{r.value=e(t),r.status="success"}catch(i){r.status="error",r.value=i}return r}(t.exports=l).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then(function(r){return t.resolve(e()).then(function(){return r})},function(r){return t.resolve(e()).then(function(){throw r})})},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===o)return this;var r=new this.constructor(n);return this.state!==c?u(r,this.state===s?e:t,this.outcome):this.queue.push(new d(r,e,t)),r},d.prototype.callFulfilled=function(e){a.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){a.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},a.resolve=function(e,t){var r=f(h,t);if("error"===r.status)return a.reject(e,r.value);var i=r.value;if(i)p(e,i);else{e.state=s,e.outcome=t;for(var n=-1,o=e.queue.length;++n<o;)e.queue[n].callFulfilled(t)}return e},a.reject=function(e,t){e.state=o,e.outcome=t;for(var r=-1,i=e.queue.length;++r<i;)e.queue[r].callRejected(t);return e},l.resolve=function(e){return e instanceof this?e:a.resolve(new this(n),e)},l.reject=function(e){var t=new this(n);return a.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 r=e.length,i=!1;if(!r)return this.resolve([]);for(var o=new Array(r),s=0,c=-1,l=new this(n);++c<r;)d(e[c],c);return l;function d(e,n){t.resolve(e).then(function(e){o[n]=e,++s!==r||i||(i=!0,a.resolve(l,o))},function(e){i||(i=!0,a.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,r=e.length,i=!1;if(!r)return this.resolve([]);for(var o=-1,s=new this(n);++o<r;)t=e[o],this.resolve(t).then(function(e){i||(i=!0,a.resolve(s,e))},function(e){i||(i=!0,a.reject(s,e))});return s}},{immediate:36}],38:[function(e,t,r){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){var i=e("./zlib/deflate"),n=e("./utils/common"),a=e("./utils/strings"),o=e("./zlib/messages"),s=e("./zlib/zstream"),c=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.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 r=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(o[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var d;if(d="string"==typeof t.dictionary?a.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=i.deflateSetDictionary(this.strm,d)))throw new Error(o[r]);this._dict_set=!0}}function d(e,t){var r=new l(t);if(r.push(e,!0),r.err)throw r.msg||o[r.err];return r.result}l.prototype.push=function(e,t){var r,o,s=this.strm,l=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?s.input=a.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 n.Buf8(l),s.next_out=0,s.avail_out=l),1!==(r=i.deflate(s,o))&&0!==r)return this.onEnd(r),!(this.ended=!0);0!==s.avail_out&&(0!==s.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(a.buf2binstring(n.shrinkBuf(s.output,s.next_out))):this.onData(n.shrinkBuf(s.output,s.next_out)))}while((0<s.avail_in||0===s.avail_out)&&1!==r);return 4===o?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==o||(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=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=l,r.deflate=d,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},r.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,r){var i=e("./zlib/inflate"),n=e("./utils/common"),a=e("./utils/strings"),o=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=n.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 r=i.inflateInit2(this.strm,t.windowBits);if(r!==o.Z_OK)throw new Error(s[r]);this.header=new l,i.inflateGetHeader(this.strm,this.header)}function h(e,t){var r=new u(t);if(r.push(e,!0),r.err)throw r.msg||s[r.err];return r.result}u.prototype.push=function(e,t){var r,s,c,l,u,h,p=this.strm,f=this.options.chunkSize,m=this.options.dictionary,g=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?p.input=a.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 n.Buf8(f),p.next_out=0,p.avail_out=f),(r=i.inflate(p,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&m&&(h="string"==typeof m?a.string2buf(m):"[object ArrayBuffer]"===d.call(m)?new Uint8Array(m):m,r=i.inflateSetDictionary(this.strm,h)),r===o.Z_BUF_ERROR&&!0===g&&(r=o.Z_OK,g=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),!(this.ended=!0);p.next_out&&(0!==p.avail_out&&r!==o.Z_STREAM_END&&(0!==p.avail_in||s!==o.Z_FINISH&&s!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(c=a.utf8border(p.output,p.next_out),l=p.next_out-c,u=a.buf2string(p.output,c),p.next_out=l,p.avail_out=f-l,l&&n.arraySet(p.output,p.output,c,l,0),this.onData(u)):this.onData(n.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(g=!0)}while((0<p.avail_in||0===p.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(s=o.Z_FINISH),s===o.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):s!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(p.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=u,r.inflate=h,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},r.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,r){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(var a=0;a<i;a++)e[n+a]=t[r+a]},flattenChunks:function(e){var t,r,i,n,a,o;for(t=i=0,r=e.length;t<r;t++)i+=e[t].length;for(o=new Uint8Array(i),t=n=0,r=e.length;t<r;t++)a=e[t],o.set(a,n),n+=a.length;return o}},a={arraySet:function(e,t,r,i,n){for(var a=0;a<i;a++)e[n+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,n)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(i)},{}],42:[function(e,t,r){var i=e("./common"),n=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch(l){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(l){a=!1}for(var o=new i.Buf8(256),s=0;s<256;s++)o[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&&a||!e.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var r="",o=0;o<t;o++)r+=String.fromCharCode(e[o]);return r}o[254]=o[254]=1,r.string2buf=function(e){var t,r,n,a,o,s=e.length,c=0;for(a=0;a<s;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=new i.Buf8(c),a=o=0;o<c;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?t[o++]=r:(r<2048?t[o++]=192|r>>>6:(r<65536?t[o++]=224|r>>>12:(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63),t[o++]=128|r>>>6&63),t[o++]=128|63&r);return t},r.buf2binstring=function(e){return c(e,e.length)},r.binstring2buf=function(e){for(var t=new i.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,i,n,a,s=t||e.length,l=new Array(2*s);for(r=i=0;r<s;)if((n=e[r++])<128)l[i++]=n;else if(4<(a=o[n]))l[i++]=65533,r+=a-1;else{for(n&=2===a?31:3===a?15:7;1<a&&r<s;)n=n<<6|63&e[r++],a--;1<a?l[i++]=65533:n<65536?l[i++]=n:(n-=65536,l[i++]=55296|n>>10&1023,l[i++]=56320|1023&n)}return c(l,i)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+o[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){t.exports=function(e,t,r,i){for(var n=65535&e,a=e>>>16&65535,o=0;0!==r;){for(r-=o=2e3<r?2e3:r;a=a+(n=n+t[i++]|0)|0,--o;);n%=65521,a%=65521}return n|a<<16}},{}],44:[function(e,t,r){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,r){var i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var a=i,o=n+r;e^=-1;for(var s=n;s<o;s++)e=e>>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,r){var i,n=e("../utils/common"),a=e("./trees"),o=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 f(e){return(e<<1)-(4<e?9:0)}function m(e){for(var t=e.length;0<=--t;)e[t]=0}function g(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function _(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,g(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function y(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function E(e,t){var r,i,n=e.max_chain_length,a=e.strstart,o=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,f=e.strstart+d,m=l[a+o-1],g=l[a+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(l[(r=t)+o]===g&&l[r+o-1]===m&&l[r]===l[a]&&l[++r]===l[a+1]){a+=2,r++;do{}while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&a<f);if(i=d-(f-a),a=f-d,o<i){if(e.match_start=t,s<=(o=i))break;m=l[a+o-1],g=l[a+o]}}}while((t=p[t&h])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead}function b(e){var t,r,i,a,c,l,d,h,p,f,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-u)){for(n.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=r=e.hash_size;i=e.head[--t],e.head[t]=m<=i?i-m:0,--r;);for(t=r=m;i=e.prev[--t],e.prev[t]=m<=i?i-m:0,--r;);a+=m}if(0===e.strm.avail_in)break;if(l=e.strm,d=e.window,h=e.strstart+e.lookahead,f=void 0,(p=a)<(f=l.avail_in)&&(f=p),r=0===f?0:(l.avail_in-=f,n.arraySet(d,l.input,l.next_in,f,h),1===l.state.wrap?l.adler=o(l.adler,d,f,h):2===l.state.wrap&&(l.adler=s(l.adler,d,f,h)),l.next_in+=f,l.total_in+=f,f),e.lookahead+=r,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 w(e,t){for(var r,i;;){if(e.lookahead<u){if(b(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-u&&(e.match_length=E(e,r)),e.match_length>=3)if(i=a._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,r=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 i=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function I(e,t){for(var r,i,n;;){if(e.lookahead<u){if(b(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-u&&(e.match_length=E(e,r),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(n=e.strstart+e.lookahead-3,i=a._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<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(_(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=a._tr_tally(e,0,e.window[e.strstart-1]))&&_(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&&(i=a._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function T(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}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 n.Buf16(1146),this.dyn_dtree=new n.Buf16(122),this.bl_tree=new n.Buf16(78),m(this.dyn_ltree),m(this.dyn_dtree),m(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(16),this.heap=new n.Buf16(573),m(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(573),m(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 k(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,a._tr_init(t),0):p(e,l)}function A(e){var t,r=k(e);return 0===r&&((t=e.state).window_size=2*t.w_size,m(t.head),t.max_lazy_match=i[t.level].max_lazy,t.good_match=i[t.level].good_length,t.nice_match=i[t.level].nice_length,t.max_chain_length=i[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function R(e,t,r,i,a,o){if(!e)return l;var s=1;if(-1===t&&(t=6),i<0?(s=0,i=-i):15<i&&(s=2,i-=16),a<1||9<a||8!==r||i<8||15<i||t<0||9<t||o<0||4<o)return p(e,l);8===i&&(i=9);var c=new S;return(e.state=c).strm=e,c.wrap=s,c.gzhead=null,c.w_bits=i,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=a+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 n.Buf8(2*c.w_size),c.head=new n.Buf16(c.hash_size),c.prev=new n.Buf16(c.w_size),c.lit_bufsize=1<<a+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new n.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=o,c.method=r,A(e)}i=[new T(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(b(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,_(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-u&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_(e,!1),e.strm.avail_out),1)}),new T(4,4,8,4,w),new T(4,5,16,8,w),new T(4,6,32,32,w),new T(4,4,16,16,I),new T(8,16,32,32,I),new T(8,16,128,128,I),new T(8,32,128,256,I),new T(32,128,258,1024,I),new T(32,258,258,4096,I)],r.deflateInit=function(e,t){return R(e,t,8,15,8,0)},r.deflateInit2=R,r.deflateReset=A,r.deflateResetKeep=k,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?l:(e.state.gzhead=t,0):l},r.deflate=function(e,t){var r,n,o,c;if(!e||!e.state||5<t||t<0)return e?p(e,l):l;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&4!==t)return p(e,0===e.avail_out?-5:l);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,v(n,31),v(n,139),v(n,8),n.gzhead?(v(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),v(n,255&n.gzhead.time),v(n,n.gzhead.time>>8&255),v(n,n.gzhead.time>>16&255),v(n,n.gzhead.time>>24&255),v(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),v(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(v(n,255&n.gzhead.extra.length),v(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=s(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(v(n,0),v(n,0),v(n,0),v(n,0),v(n,0),v(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),v(n,3),n.status=h);else{var u=8+(n.w_bits-8<<4)<<8;u|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(u|=32),u+=31-u%31,n.status=h,y(n,u),0!==n.strstart&&(y(n,e.adler>>>16),y(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending!==n.pending_buf_size));)v(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,v(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,v(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&g(e),n.pending+2<=n.pending_buf_size&&(v(n,255&e.adler),v(n,e.adler>>8&255),e.adler=0,n.status=h)):n.status=h),0!==n.pending){if(g(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&f(t)<=f(r)&&4!==t)return p(e,-5);if(666===n.status&&0!==e.avail_in)return p(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&666!==n.status){var E=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(b(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,i,n,o,s=e.window;;){if(e.lookahead<=d){if(b(e),e.lookahead<=d&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0<e.strstart&&(i=s[n=e.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){o=e.strstart+d;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<o);e.match_length=d-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=a._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(n,t):i[n.level].func(n,t);if(3!==E&&4!==E||(n.status=666),1===E||3===E)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===E&&(1===t?a._tr_align(n):5!==t&&(a._tr_stored_block(n,0,0,!1),3===t&&(m(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),g(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(v(n,255&e.adler),v(n,e.adler>>8&255),v(n,e.adler>>16&255),v(n,e.adler>>24&255),v(n,255&e.total_in),v(n,e.total_in>>8&255),v(n,e.total_in>>16&255),v(n,e.total_in>>24&255)):(y(n,e.adler>>>16),y(n,65535&e.adler)),g(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?0:1)},r.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},r.deflateSetDictionary=function(e,t){var r,i,a,s,c,d,u,h,p=t.length;if(!e||!e.state||2===(s=(r=e.state).wrap)||1===s&&42!==r.status||r.lookahead)return l;for(1===s&&(e.adler=o(e.adler,t,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(m(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new n.Buf8(r.w_size),n.arraySet(h,t,p-r.w_size,r.w_size,0),t=h,p=r.w_size),c=e.avail_in,d=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,b(r);r.lookahead>=3;){for(i=r.strstart,a=r.lookahead-2;r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+3-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,--a;);r.strstart=i,r.lookahead=2,b(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=d,e.input=u,e.avail_in=c,r.wrap=s,0},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){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,r){t.exports=function(e,t){var r,i,n,a,o,s,c,l,d,u,h,p,f,m,g,_,v,y,E,b,w,I,T,S,k;r=e.state,i=e.next_in,S=e.input,n=i+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=r.dmax,l=r.wsize,d=r.whave,u=r.wnext,h=r.window,p=r.hold,f=r.bits,m=r.lencode,g=r.distcode,_=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{f<15&&(p+=S[i++]<<f,f+=8,p+=S[i++]<<f,f+=8),y=m[p&_];t:for(;;){if(p>>>=E=y>>>24,f-=E,0==(E=y>>>16&255))k[a++]=65535&y;else{if(!(16&E)){if(!(64&E)){y=m[(65535&y)+(p&(1<<E)-1)];continue t}if(32&E){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&y,(E&=15)&&(f<E&&(p+=S[i++]<<f,f+=8),b+=p&(1<<E)-1,p>>>=E,f-=E),f<15&&(p+=S[i++]<<f,f+=8,p+=S[i++]<<f,f+=8),y=g[p&v];r:for(;;){if(p>>>=E=y>>>24,f-=E,!(16&(E=y>>>16&255))){if(!(64&E)){y=g[(65535&y)+(p&(1<<E)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(w=65535&y,f<(E&=15)&&(p+=S[i++]<<f,(f+=8)<E&&(p+=S[i++]<<f,f+=8)),c<(w+=p&(1<<E)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=E,f-=E,(E=a-o)<w){if(d<(E=w-E)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=h,(I=0)===u){if(I+=l-E,E<b){for(b-=E;k[a++]=h[I++],--E;);I=a-w,T=k}}else if(u<E){if(I+=l+u-E,(E-=u)<b){for(b-=E;k[a++]=h[I++],--E;);if(I=0,u<b){for(b-=E=u;k[a++]=h[I++],--E;);I=a-w,T=k}}}else if(I+=u-E,E<b){for(b-=E;k[a++]=h[I++],--E;);I=a-w,T=k}for(;2<b;)k[a++]=T[I++],k[a++]=T[I++],k[a++]=T[I++],b-=3;b&&(k[a++]=T[I++],1<b&&(k[a++]=T[I++]))}else{for(I=a-w;k[a++]=k[I++],k[a++]=k[I++],k[a++]=k[I++],2<(b-=3););b&&(k[a++]=k[I++],1<b&&(k[a++]=k[I++]))}break}}break}}while(i<n&&a<s);i-=b=f>>3,p&=(1<<(f-=b<<3))-1,e.next_in=i,e.next_out=a,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=a<s?s-a+257:257-(a-s),r.hold=p,r.bits=f}},{}],49:[function(e,t,r){var i=e("../utils/common"),n=e("./adler32"),a=e("./crc32"),o=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 i.Buf16(320),this.work=new i.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 i.Buf32(852),t.distcode=t.distdyn=new i.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 r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?c:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,h(e))):c}function f(e,t){var r,i;return e?(i=new d,(e.state=i).window=null,0!==(r=p(e,t))&&(e.state=null),r):c}var m,g,_=!0;function v(e){if(_){var t;for(m=new i.Buf32(512),g=new i.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,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(2,e.lens,0,32,g,0,e.work,{bits:5}),_=!1}e.lencode=m,e.lenbits=9,e.distcode=g,e.distbits=5}function y(e,t,r,n){var a,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new i.Buf8(o.wsize)),n>=o.wsize?(i.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n<(a=o.wsize-o.wnext)&&(a=n),i.arraySet(o.window,t,r-n,a,o.wnext),(n-=a)?(i.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}r.inflateReset=h,r.inflateReset2=p,r.inflateResetKeep=u,r.inflateInit=function(e){return f(e,15)},r.inflateInit2=f,r.inflate=function(e,t){var r,d,u,h,p,f,m,g,_,E,b,w,I,T,S,k,A,R,C,D,O,L,x,N,P=0,M=new i.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===(r=e.state).mode&&(r.mode=13),p=e.next_out,u=e.output,m=e.avail_out,h=e.next_in,d=e.input,f=e.avail_in,g=r.hold,_=r.bits,E=f,b=m,L=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(2&r.wrap&&35615===g){M[r.check=0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0),_=g=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&g)<<8)+(g>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&g)){e.msg="unknown compression method",r.mode=30;break}if(_-=4,O=8+(15&(g>>>=4)),0===r.wbits)r.wbits=O;else if(O>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<O,e.adler=r.check=1,r.mode=512&g?10:12,_=g=0;break;case 2:for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(r.flags=g,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=g>>8&1),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0,r.mode=3;case 3:for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.head&&(r.head.time=g),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,M[2]=g>>>16&255,M[3]=g>>>24&255,r.check=a(r.check,M,4,0)),_=g=0,r.mode=4;case 4:for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.head&&(r.head.xflags=255&g,r.head.os=g>>8),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0,r.mode=5;case 5:if(1024&r.flags){for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.length=g,r.head&&(r.head.extra_len=g),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(f<(w=r.length)&&(w=f),w&&(r.head&&(O=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,d,h,w,O)),512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,r.length-=w),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===f)break e;for(w=0;O=d[h+w++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O)),O&&w<f;);if(512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,O)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===f)break e;for(w=0;O=d[h+w++],r.head&&O&&r.length<65536&&(r.head.comment+=String.fromCharCode(O)),O&&w<f;);if(512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,O)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}_=g=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}e.adler=r.check=l(g),_=g=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){g>>>=7&_,_-=7&_,r.mode=27;break}for(;_<3;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}switch(r.last=1&g,_-=1,3&(g>>>=1)){case 0:r.mode=14;break;case 1:if(v(r),r.mode=20,6!==t)break;g>>>=2,_-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}g>>>=2,_-=2;break;case 14:for(g>>>=7&_,_-=7&_;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if((65535&g)!=(g>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&g,_=g=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(w=r.length){if(f<w&&(w=f),m<w&&(w=m),0===w)break e;i.arraySet(u,d,h,w,p),f-=w,h+=w,m-=w,p+=w,r.length-=w;break}r.mode=12;break;case 17:for(;_<14;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(r.nlen=257+(31&g),g>>>=5,_-=5,r.ndist=1+(31&g),g>>>=5,_-=5,r.ncode=4+(15&g),g>>>=4,_-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;_<3;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.lens[U[r.have++]]=7&g,g>>>=3,_-=3}for(;r.have<19;)r.lens[U[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},L=s(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,L){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;k=(P=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(A<16)g>>>=S,_-=S,r.lens[r.have++]=A;else{if(16===A){for(N=S+2;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g>>>=S,_-=S,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}O=r.lens[r.have-1],w=3+(3&g),g>>>=2,_-=2}else if(17===A){for(N=S+3;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}_-=S,O=0,w=3+(7&(g>>>=S)),g>>>=3,_-=3}else{for(N=S+7;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}_-=S,O=0,w=11+(127&(g>>>=S)),g>>>=7,_-=7}if(r.have+w>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;w--;)r.lens[r.have++]=O}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,x={bits:r.lenbits},L=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,L){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},L=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,L){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=f&&258<=m){e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,o(e,b),p=e.next_out,u=e.output,m=e.avail_out,h=e.next_in,d=e.input,f=e.avail_in,g=r.hold,_=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;k=(P=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(k&&!(240&k)){for(R=S,C=k,D=A;k=(P=r.lencode[D+((g&(1<<R+C)-1)>>R)])>>>16&255,A=65535&P,!(R+(S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}g>>>=R,_-=R,r.back+=R}if(g>>>=S,_-=S,r.back+=S,r.length=A,0===k){r.mode=26;break}if(32&k){r.back=-1,r.mode=12;break}if(64&k){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&k,r.mode=22;case 22:if(r.extra){for(N=r.extra;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.length+=g&(1<<r.extra)-1,g>>>=r.extra,_-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;k=(P=r.distcode[g&(1<<r.distbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(!(240&k)){for(R=S,C=k,D=A;k=(P=r.distcode[D+((g&(1<<R+C)-1)>>R)])>>>16&255,A=65535&P,!(R+(S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}g>>>=R,_-=R,r.back+=R}if(g>>>=S,_-=S,r.back+=S,64&k){e.msg="invalid distance code",r.mode=30;break}r.offset=A,r.extra=15&k,r.mode=24;case 24:if(r.extra){for(N=r.extra;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.offset+=g&(1<<r.extra)-1,g>>>=r.extra,_-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===m)break e;if(w=b-m,r.offset>w){if((w=r.offset-w)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}I=w>r.wnext?(w-=r.wnext,r.wsize-w):r.wnext-w,w>r.length&&(w=r.length),T=r.window}else T=u,I=p-r.offset,w=r.length;for(m<w&&(w=m),m-=w,r.length-=w;u[p++]=T[I++],--w;);0===r.length&&(r.mode=21);break;case 26:if(0===m)break e;u[p++]=r.length,m--,r.mode=21;break;case 27:if(r.wrap){for(;_<32;){if(0===f)break e;f--,g|=d[h++]<<_,_+=8}if(b-=m,e.total_out+=b,r.total+=b,b&&(e.adler=r.check=r.flags?a(r.check,u,b,p-b):n(r.check,u,b,p-b)),b=m,(r.flags?g:l(g))!==r.check){e.msg="incorrect data check",r.mode=30;break}_=g=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}_=g=0}r.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;default:return c}return e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,(r.wsize||b!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&y(e,e.output,e.next_out,b-e.avail_out)?(r.mode=31,-4):(E-=e.avail_in,b-=e.avail_out,e.total_in+=E,e.total_out+=b,r.total+=b,r.wrap&&b&&(e.adler=r.check=r.flags?a(r.check,u,b,e.next_out-b):n(r.check,u,b,e.next_out-b)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==E&&0===b||4===t)&&0===L&&(L=-5),L)},r.inflateEnd=function(e){if(!e||!e.state)return c;var t=e.state;return t.window&&(t.window=null),e.state=null,0},r.inflateGetHeader=function(e,t){var r;return e&&e.state&&2&(r=e.state).wrap?((r.head=t).done=!1,0):c},r.inflateSetDictionary=function(e,t){var r,i=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?c:11===r.mode&&n(1,t,i,0)!==r.check?-3:y(e,t,i,i)?(r.mode=31,-4):(r.havedict=1,0):c},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){var i=e("../utils/common"),n=[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],a=[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],o=[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,r,c,l,d,u,h){var p,f,m,g,_,v,y,E,b,w=h.bits,I=0,T=0,S=0,k=0,A=0,R=0,C=0,D=0,O=0,L=0,x=null,N=0,P=new i.Buf16(16),M=new i.Buf16(16),U=null,B=0;for(I=0;I<=15;I++)P[I]=0;for(T=0;T<c;T++)P[t[r+T]]++;for(A=w,k=15;1<=k&&0===P[k];k--);if(k<A&&(A=k),0===k)return l[d++]=20971520,l[d++]=20971520,h.bits=1,0;for(S=1;S<k&&0===P[S];S++);for(A<S&&(A=S),I=D=1;I<=15;I++)if(D<<=1,(D-=P[I])<0)return-1;if(0<D&&(0===e||1!==k))return-1;for(M[1]=0,I=1;I<15;I++)M[I+1]=M[I]+P[I];for(T=0;T<c;T++)0!==t[r+T]&&(u[M[t[r+T]]++]=T);if(v=0===e?(x=U=u,19):1===e?(x=n,N-=257,U=a,B-=257,256):(x=o,U=s,-1),I=S,_=d,C=T=L=0,m=-1,g=(O=1<<(R=A))-1,1===e&&852<O||2===e&&592<O)return 1;for(;;){for(y=I-C,b=u[T]<v?(E=0,u[T]):u[T]>v?(E=U[B+u[T]],x[N+u[T]]):(E=96,0),p=1<<I-C,S=f=1<<R;l[_+(L>>C)+(f-=p)]=y<<24|E<<16|b,0!==f;);for(p=1<<I-1;L&p;)p>>=1;if(0!==p?(L&=p-1,L+=p):L=0,T++,0==--P[I]){if(I===k)break;I=t[r+u[T]]}if(A<I&&(L&g)!==m){for(0===C&&(C=A),_+=S,D=1<<(R=I-C);R+C<k&&!((D-=P[R+C])<=0);)R++,D<<=1;if(O+=1<<R,1===e&&852<O||2===e&&592<O)return 1;l[m=L&g]=A<<24|R<<16|_-d}}return 0!==L&&(l[_+L]=I-C<<24|64<<16),h.bits=A,0}},{"../utils/common":41}],51:[function(e,t,r){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,r){var i=e("../utils/common");function n(e){for(var t=e.length;0<=--t;)e[t]=0}var a=256,o=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);n(p);var f=new Array(60);n(f);var m=new Array(512);n(m);var g=new Array(256);n(g);var _=new Array(29);n(_);var v,y,E,b=new Array(s);function w(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}function I(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function T(e){return e<256?m[e]:m[256+(e>>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,S(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function A(e,t,r){k(e,r[2*t],r[2*t+1])}function R(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function C(e,t,r){var i,n,a=new Array(16),o=0;for(i=1;i<=c;i++)a[i]=o=o+r[i-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=R(a[s]++,s))}}function D(e){var t;for(t=0;t<o;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 O(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 L(e,t,r,i){var n=2*t,a=2*r;return e[n]<e[a]||e[n]===e[a]&&i[t]<=i[r]}function x(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&L(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!L(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function N(e,t,r){var i,n,o,s,c=0;if(0!==e.last_lit)for(;i=e.pending_buf[e.d_buf+2*c]<<8|e.pending_buf[e.d_buf+2*c+1],n=e.pending_buf[e.l_buf+c],c++,0===i?A(e,n,t):(A(e,(o=g[n])+a+1,t),0!==(s=l[o])&&k(e,n-=_[o],s),A(e,o=T(--i),r),0!==(s=d[o])&&k(e,i-=b[o],s)),c<e.last_lit;);A(e,256,t)}function P(e,t){var r,i,n,a=t.dyn_tree,o=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,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=d=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(n=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[n]=0,e.opt_len--,s&&(e.static_len-=o[2*n+1]);for(t.max_code=d,r=e.heap_len>>1;1<=r;r--)x(e,a,r);for(n=l;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],x(e,a,1),i=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=i,a[2*n]=a[2*r]+a[2*i],e.depth[n]=(e.depth[r]>=e.depth[i]?e.depth[r]:e.depth[i])+1,a[2*r+1]=a[2*i+1]=n,e.heap[1]=n++,x(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,i,n,a,o,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,f=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=c;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)m<(a=l[2*l[2*(i=e.heap[r])+1]+1]+1)&&(a=m,g++),l[2*i+1]=a,d<i||(e.bl_count[a]++,o=0,f<=i&&(o=p[i-f]),s=l[2*i],e.opt_len+=s*(a+o),h&&(e.static_len+=s*(u[2*i+1]+o)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(0<g);for(a=m;0!==a;a--)for(i=e.bl_count[a];0!==i;)d<(n=e.heap[--r])||(l[2*n+1]!==a&&(e.opt_len+=(a-l[2*n+1])*l[2*n],l[2*n+1]=a),i--)}}(e,t),C(a,d,e.bl_count)}function M(e,t,r){var i,n,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++s<c&&n===o||(s<l?e.bl_tree[2*n]+=s:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=n,l=(s=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4))}function U(e,t,r){var i,n,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),i=0;i<=r;i++)if(n=o,o=t[2*(i+1)+1],!(++s<c&&n===o)){if(s<l)for(;A(e,n,e.bl_tree),0!=--s;);else 0!==n?(n!==a&&(A(e,n,e.bl_tree),s--),A(e,16,e.bl_tree),k(e,s-3,2)):s<=10?(A(e,17,e.bl_tree),k(e,s-3,3)):(A(e,18,e.bl_tree),k(e,s-11,7));a=n,l=(s=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4)}}n(b);var B=!1;function F(e,t,r,n){var a,o,s;k(e,0+(n?1:0),3),o=t,s=r,O(a=e),S(a,s),S(a,~s),i.arraySet(a.pending_buf,a.window,o,s,a.pending),a.pending+=s}r._tr_init=function(e){B||(function(){var e,t,r,i,n,a=new Array(16);for(i=r=0;i<28;i++)for(_[i]=r,e=0;e<1<<l[i];e++)g[r++]=i;for(g[r-1]=i,i=n=0;i<16;i++)for(b[i]=n,e=0;e<1<<d[i];e++)m[n++]=i;for(n>>=7;i<s;i++)for(b[i]=n<<7,e=0;e<1<<d[i]-7;e++)m[256+n++]=i;for(t=0;t<=c;t++)a[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,a[8]++;for(;e<=255;)p[2*e+1]=9,e++,a[9]++;for(;e<=279;)p[2*e+1]=7,e++,a[7]++;for(;e<=287;)p[2*e+1]=8,e++,a[8]++;for(C(p,287,a),e=0;e<s;e++)f[2*e+1]=5,f[2*e]=R(e,5);v=new w(p,l,257,o,c),y=new w(f,d,0,s,c),E=new w(new Array(0),u,0,19,7)}(),B=!0),e.l_desc=new I(e.dyn_ltree,v),e.d_desc=new I(e.dyn_dtree,y),e.bl_desc=new I(e.bl_tree,E),e.bi_buf=0,e.bi_valid=0,D(e)},r._tr_stored_block=F,r._tr_flush_block=function(e,t,r,i){var n,o,s=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<a;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(M(e,e.dyn_ltree,e.l_desc.max_code),M(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),n=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=n&&(n=o)):n=o=r+5,r+4<=n&&-1!==t?F(e,t,r,i):4===e.strategy||o===n?(k(e,2+(i?1:0),3),N(e,p,f)):(k(e,4+(i?1:0),3),function(e,t,r,i){var n;for(k(e,t-257,5),k(e,r-1,5),k(e,i-4,4),n=0;n<i;n++)k(e,e.bl_tree[2*h[n]+1],3);U(e,e.dyn_ltree,t-1),U(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),N(e,e.dyn_ltree,e.dyn_dtree)),D(e),i&&O(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(g[r]+a+1)]++,e.dyn_dtree[2*T(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){var t;k(e,2,3),A(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,r){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,r){(function(e){!function(e){if(!e.setImmediate){var t,r,i,n,a=1,o={},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,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(n="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",h,!1):e.attachEvent("onmessage",h),function(t){e.postMessage(n+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){u(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){u(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(u,0,e)},l.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var r=new Array(arguments.length-1),i=0;i<r.length;i++)r[i]=arguments[i+1];var n={callback:e,args:r};return o[a]=n,t(a),a++},l.clearImmediate=d}function d(e){delete o[e]}function u(e){if(s)setTimeout(u,0,e);else{var t=o[e];if(t){s=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(void 0,r)}}(t)}finally{d(e),s=!1}}}}function h(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(n)&&u(+t.data.slice(n.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)})}),Bk=Lk((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,n,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new a(r,n||e,o),c=i?i+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.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 n=0,a=r.length,o=new Array(a);n<a;n++)o[n]=r[n].fn;return o},c.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,n,a,o){var s=i?i+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,r),!0;case 4:return d.fn.call(d.context,t,r,n),!0;case 5:return d.fn.call(d.context,t,r,n,a),!0;case 6:return d.fn.call(d.context,t,r,n,a,o),!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,r);break;case 4:d[l].fn.call(d[l].context,t,r,n);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,n){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!n||o.once)&&(!r||o.context===r)&&s(this,a);else{for(var c=0,l=[],d=o.length;c<d;c++)(o[c].fn!==t||n&&!o[c].once||r&&o[c].context!==r)&&l.push(o[c]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)}),Fk=Lk((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")})})}),Vk=Lk(e=>{var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,i){var n=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:n&&!r[e.name]&&(r[e.name]={});var a=e.push?{}:n?r[e.name]:r;(function(e,r,i,n){if(n&&!i)r[n]=t(e[1]);else for(var a=0;a<i.length;a+=1)null!=e[a+1]&&(r[i[a]]=t(e[a+1]))})(i.match(e.reg),a,e.names,e.name),e.push&&r[e.push].push(a)},i=Fk(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach(function(e){var t=e[0],n=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(n))return r(c,o,n)}}),t.media=a,t};var a=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(a,{})},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),n=0;n<i.length;n+=3)r.push({component:i[n],ip:i[n+1],port:i[n+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})})},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}})})}}),Wk=Lk((e,t)=>{var r=Fk(),i=/%[sdv%]/g,n=function(e){var t=1,r=arguments,n=r.length;return e.replace(i,function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},a=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 a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?i.push(r[t.name][o]):i.push(r[t.names[a]])}else i.push(r[t.name]);return n.apply(null,i)},o=["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||o,n=t.innerOrder||s,c=[];return i.forEach(function(t){r[t].forEach(function(r){r.name in e&&null!=e[r.name]?c.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){c.push(a(t,r,e))})})}),e.media.forEach(function(e){c.push(a("m",r.m[0],e)),n.forEach(function(t){r[t].forEach(function(r){r.name in e&&null!=e[r.name]?c.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){c.push(a(t,r,e))})})})}),c.join("\r\n")+"\r\n"}}),Hk=Lk(e=>{var t=Vk(),r=Wk(),i=Fk();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}),jk=((_k=jk||{}).ROOM_DESTROY="1",_k.JOIN_START="21",_k.JOIN_SCHEDULE_SUCCESS="22",_k.JOIN_SIGNAL_CONNECTION_START="23",_k.JOIN_SIGNAL_CONNECTION_END="24",_k.JOIN_SEND_CMD="25",_k.JOIN_RECEIVED_CMD_RES="26",_k.JOIN_SUCCESS="27",_k.JOIN_FAILED="28",_k.WHIP_REQUEST_COST="29",_k.WHIP_PULL_RESULT="30",_k.LEAVE_START="51",_k.LEAVE_SEND_CMD="52",_k.LEAVE_SUCCESS="53",_k.PUBLISH_START="61",_k.SEND_FIRST_VIDEO_FRAME="62",_k.PUBLISH_FAILED="63",_k.SUBSCRIBE_START="81",_k.SUBSCRIBE_SUCCESS="82",_k.SUBSCRIBE_FAILED="84",_k.UNSUBSCRIBE_SUCCESS="83",_k.LOCAL_TRACK_CAPTURE_START="101",_k.LOCAL_TRACK_CAPTURE_SUCCESS="102",_k.LOCAL_TRACK_CAPTURE_FAILED="103",_k.LOCAL_TRACK_PUBLISHED="104",_k.LOCAL_TRACK_UNPUBLISHED="105",_k.LOCAL_TRACK_REPLACED="106",_k.SWITCH_DEVICE_SUCCESS="107",_k.TRACK_MUTED="108",_k.TRACK_UNMUTED="109",_k.REMOTE_TRACK_SUBSCRIBED="110",_k.REMOTE_TRACK_UNSUBSCRIBED="111",_k.LOCAL_TRACK_RECAPTURE="112",_k.LOCAL_AUDIO_STARTED="113",_k.LOCAL_AUDIO_STOPPED="114",_k.REMOTE_AUDIO_STARTED="115",_k.REMOTE_AUDIO_STOPPED="116",_k.LOCAL_TRACK_STOPPED="117",_k.LOCAL_VIDEO_TRACK_PREPROCESSED="118",_k.PLAY_TRACK_START="151",_k.PLAYER_STATE_CHANGED="152",_k.VIDEO_LOADED_DATA="153",_k.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",_k.AUDIO_CONTEXT_LONG_SUSPENDED="155",_k.REMOTE_VIDEO_PLAY_START="156",_k.REMOTE_VIDEO_PLAY_FINISH="157",_k.SIGNAL_CONNECTION_STATE_CHANGED="201",_k.PEER_CONNECTION_STATE_CHANGED="202",_k.SINGLE_CONNECTION_STAT="203",_k.SPC_RECONNECTED="204",_k.HEARTBEAT_REPORT="251",_k.RECEIVED_PUBLISHED_USER_LIST="252",_k.REMOTE_PUBLISH_STATE_CHANGED="253",_k.AUDIO_LEVEL_INTERVAL="260",_k.NETWORK_QUALITY="261",_k.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",_k.QUALITY_LIMITATION_CHANGED="263",_k.LOG="264",_k.AUDIO_PROCESSOR_DEBUG="265",_k.SSO_SWITCH="266",_k.SEI_MESSAGE="267",_k.USER_PAUSE_IN_PIP="268",_k.USER_RESUME_IN_PIP="269",_k.ENTER_PICTURE_IN_PICTURE="270",_k.LEAVE_PICTURE_IN_PICTURE="271",_k.SWITCH_ROOM_START="401",_k.SWITCH_ROOM_SUCCESS="407",_k.SWITCH_ROOM_FAILED="408",_k);function zk(e){return Gk((t,r)=>async function(){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];let a=await t.apply(this,i);return await e.call(this,...i),a})}function Gk(e){return function(t,r,i){return i.value=e(i.value,r),i}}var qk=new WeakMap;function Kk(e,t){return Gk((r,i)=>function(){for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];let o=qk.get(this);o||(o=new Map,qk.set(this,o));let s=t(...n),c=o.get(s);if(!c||c<=0){r.apply(this,n);let t=setTimeout(()=>{var e;null==(e=qk.get(this))||e.delete(s)},e);o.set(s,t)}else{clearTimeout(c);let t=window.setTimeout(()=>{var e;r.apply(this,n),null==(e=qk.get(this))||e.delete(s)},e);o.set(s,t)}})}var Yk,Xk,Zk=((Yk=Zk||{})[Yk.none=0]="none",Yk[Yk.horizontal=1]="horizontal",Yk[Yk.vertical=2]="vertical",Yk),Jk="5.0.0",Qk="undefined"!=typeof importScripts,$k="undefined"!=typeof registerProcessor,eA="https://".concat("web.sdk.qcloud.com","/trtc/webrtc/doc"),tA="https://cloud.tencent.com/document/product/647/85386",rA="https://trtc.io/document/56025",iA="jssdk_log",nA="qcloud",aA=((Xk=aA||{})[Xk.TRACE=0]="TRACE",Xk[Xk.DEBUG=1]="DEBUG",Xk[Xk.INFO=2]="INFO",Xk[Xk.WARN=3]="WARN",Xk[Xk.ERROR=4]="ERROR",Xk[Xk.NONE=5]="NONE",Xk),oA={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5,"5g":6},sA={width:640,height:480,frameRate:15,bitrate:500},cA="canvas",lA="audio",dA="video",uA="screen",hA="big",pA="mute",fA="unmute",mA="ended",gA="playing",_A="pause",vA="error",yA="loadstart",EA="loadeddata",bA="loadedmetadata",wA="audioinput",IA="videoinput",TA="enterpictureinpicture",SA="leavepictureinpicture",kA="fullscreenchange",AA="resize",RA="player-error",CA="load-worklet",DA="getUserMedia-retry",OA="default",LA=2e3,xA=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],NA={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"};function PA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function MA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function UA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function BA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}var FA="Log",VA="Network",WA="Dump",HA="Dump (PCM)",jA="Dump (Opus)",zA="Dumping",GA="End",qA="Upload Log",KA="Export Log",YA="Hide",XA="goBottom",ZA="backTop",JA="Clear Log",QA="Uplink",$A="Downlink",eR="No Data",tR="Basic",rR="Duration",iR="Video",nR="Audio",aR="Screen",oR={"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=>{oR["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}});var sR,cR=Object.keys(oR),lR=Nk(Uk()),dR=((sR=dR||{})[sR.INVALID_PARAMETER=4096]="INVALID_PARAMETER",sR[sR.INVALID_OPERATION=4097]="INVALID_OPERATION",sR[sR.NOT_SUPPORTED=4098]="NOT_SUPPORTED",sR[sR.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",sR[sR.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",sR[sR.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",sR[sR.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",sR[sR.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",sR[sR.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",sR[sR.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",sR[sR.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",sR[sR.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",sR[sR.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",sR[sR.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",sR[sR.CLIENT_BANNED=16448]="CLIENT_BANNED",sR[sR.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",sR[sR.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",sR[sR.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",sR[sR.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",sR[sR.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",sR[sR.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",sR[sR.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",sR[sR.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",sR[sR.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",sR[sR.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",sR[sR.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",sR[sR.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",sR[sR.API_CALL_ABORTED=16461]="API_CALL_ABORTED",sR[sR.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",sR[sR.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",sR[sR.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",sR[sR.VIDEO_ENCODE_FAILED=16465]="VIDEO_ENCODE_FAILED",sR[sR.AUDIO_ENCODE_FAILED=16466]="AUDIO_ENCODE_FAILED",sR[sR.WHIP_REQUEST_FAILED=16467]="WHIP_REQUEST_FAILED",sR[sR.UNKNOWN=65535]="UNKNOWN",sR),uR=dR,hR=class extends Error{constructor(e){let{name:t="RtcError",message:r,code:i=uR.UNKNOWN,extraCode:n=0,constraint:a}=e,o="<".concat(function(e){for(let t in uR)if(uR[t]===e)return t;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(r).concat(a?" constraint: ".concat(a):"").concat(null!=r&&r.includes(o)?"":" ".concat(o));super(s),Mk(this,"code"),Mk(this,"extraCode"),Mk(this,"message"),Mk(this,"originMessage"),Mk(this,"name"),Mk(this,"constraint"),this.code=i,this.extraCode=n,this.name=t,this.message=s,this.constraint=a,this.originMessage=r}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},pR=hR,fR=function(){return Date.now()+0},mR=function(){let e=new Date;return e.setTime(fR()),e.toLocaleString()};xk({},{REPORT_TYPE:()=>YC,buildSSOPackage:()=>XC,bytes2ms:()=>YR,calculateScaleResolutionDownNumber:()=>zC,concatArrayBuffers:()=>ZC,convertObjectNumberToInt:()=>FC,copyProperties:()=>KR,deepClone:()=>CC,deepCloneBasic:()=>KC,deepMerge:()=>RC,delay:()=>VC,detectImageType:()=>eD,fibonacci:()=>tC,formatedTime:()=>LC,getConstructorName:()=>mC,getContainerFromElement:()=>OC,getEnv:()=>MR,getFirst16Bits:()=>QC,getInternalVersion:()=>bC,getLast16Bits:()=>JC,getLoggerUrl:()=>FR,getMediaStreamTrackInfo:()=>jC,getMuteStateFromFlag:()=>SC,getNetworkType:()=>WR,getNumNetworkType:()=>qR,getReconnectionTimeout:()=>rC,getStringByteLength:()=>PC,getTestSignalDomain:()=>UR,getTurnServer:()=>kC,getUint32Version:()=>BC,getValueType:()=>iC,getVersionFromInternalVersion:()=>wC,getViewListFromView:()=>DC,glog:()=>QR,ipv4ToUint32:()=>AC,isArray:()=>dC,isAudioWorkletSupported:()=>gC,isBoolean:()=>cC,isConstructor:()=>fC,isEmpty:()=>TC,isFunction:()=>nC,isLangChinese:()=>$R,isMediaStreamTrack:()=>uC,isNumber:()=>sC,isObject:()=>lC,isOverseaSdkAppId:()=>BR,isPlainObject:()=>eC,isPortrait:()=>MC,isPromise:()=>pC,isRemoteTrack:()=>hC,isRotate90Or270:()=>GC,isSetSinkIdSupported:()=>_C,isString:()=>oC,isUndefined:()=>aC,isVideoMixerOutputTrack:()=>$C,loadImage:()=>UC,loadVideo:()=>qC,ms2bytes:()=>ZR,ms2samples:()=>JR,normalizeUrl:()=>HC,performanceNow:()=>yC,promiseAny:()=>vC,samples2ms:()=>XR,setNetworkTypeFromWebRTC:()=>GR,stringify:()=>xC,stringifyIncludeValue:()=>NC,throttlePromise:()=>WC});var gR=function(e,t,r,i){return new(r||(r=Promise))(function(n,a){function o(e){try{c(i.next(e))}catch(t){a(t)}}function s(e){try{c(i.throw(e))}catch(t){a(t)}}function c(e){e.done?n(e.value):function(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(o,s)}c((i=i.apply(e,t||[])).next())})},_R=Symbol(32),vR=Symbol(16),yR=Symbol(8),ER=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 gR(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(_R)}readU16(){return this.read(vR)}readU8(){return this.read(yR)}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===_R){if(i(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===vR){if(i(2))return;e=t[0]<<8|t[1]}else if(this.need===yR){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}};ER.U32=_R,ER.U16=vR,ER.U8=yR;var bR=128;function wR(e){let t=new ER;for(;e>=128;)t.malloc(1)[0]=255&e|bR,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function IR(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new ER,i=t<<3;switch(typeof e){case"boolean":let n=r.malloc(2);n[0]=i,n[1]=e?1:0;break;case"number":r.malloc(1)[0]=i,r.write(wR(e));break;case"string":r.malloc(1)[0]=2|i;let a=(new TextEncoder).encode(e);r.write(wR(a.length));let o=r.malloc(a.length);for(let e=0;e<a.length;e++)o[e]=a[e];break;case"object":let s=new ER;if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=IR(e[t],t+1);r&&s.write(r)}else{let t=1;for(let r in e){let i=IR(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(wR(s.buffer.length)),r.write(s.buffer)))}return r.buffer||new Uint8Array(0)}var TR=class{constructor(){Mk(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 SR(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 kR(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function AR(e,t){return e[t]}function RR(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var CR=0,DR=2654435769,OR=16,LR=2,xR=7;function NR(e,t){let r=new TR,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,CR);CR=CR+1&2147483647,r.writeInt32(0),r.writeInt32(i.version),r.writeByte(i.encryption);let n=(new TextEncoder).encode(i.d2);r.writeInt32(n.length+4),n&&r.writeBytes(n),r.writeByte(i.uinType);let a=(new TextEncoder).encode(i.uin);r.writeInt32(a.length+4),a.length&&r.writeBytes(a);let o=new TR;o.writeInt32(0),o.writeInt32(i.reqHead.seqNumber),o.writeInt32(i.reqHead.appId),o.writeByte(i.reqHead.appId>>>24&255),o.writeByte(i.reqHead.appId>>>16&255),o.writeByte(i.reqHead.appId>>>8&255),o.writeByte(255&i.reqHead.appId);for(let v=4;v<16;v++)o.writeByte(0);let s=(new TextEncoder).encode(i.reqHead.a2);o.writeInt32(s.length+4),s.length&&o.writeBytes(s);let c=(new TextEncoder).encode(i.reqHead.serviceCmd);o.writeInt32(c.length+4),c.length&&o.writeBytes(c);let l=(new TextEncoder).encode(i.reqHead.cookie);o.writeInt32(l.length+4),l.length&&o.writeBytes(l);let d=(new TextEncoder).encode(i.reqHead.imei);o.writeInt32(d.length+4),d.length&&o.writeBytes(d);let u=(new TextEncoder).encode(i.reqHead.ksid);o.writeInt32(u.length+4),u.length&&o.writeBytes(u);let h=(new TextEncoder).encode(i.reqHead.clientVersionInfo);o.writeInt16(h.length+2),h.length&&o.writeBytes(h);let p=o.length;o.data[0]=p>>>24&255,o.data[1]=p>>>16&255,o.data[2]=p>>>8&255,o.data[3]=255&p,oC(e)&&(e=(new TextEncoder).encode(e)),o.writeInt32(e.length+4),e.length&&o.writeBytes(e);let f=new Uint8Array(o.data),m=null;1===i.encryption?m=(new TextEncoder).encode(i.uin):2===i.encryption&&(m=new Uint8Array(16)),m&&(f=function(e,t){let r=e.length,i=(r+1+LR+xR)%8;i&&(i=8-i);let n=r+1+LR+xR+i,a=new Uint8Array(n),o=0,s=new Uint8Array(8),c=new Uint8Array(8),l=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<LR;)if(d<8&&(s[d]=255&Math.floor(256*Math.random()),d+=1,h+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}let u=0;for(;u<r;)if(d<8&&(s[d]=e[u],d+=1,u+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}for(let h=0;h<xR;)if(d<8&&(s[d]=0,d+=1,h+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}return a}(f,m)),r.writeBytes(f);let g=new Uint8Array(r.data),_=g.length;return g[0]=_>>>24&255,g[1]=_>>>16&255,g[2]=_>>>8&255,g[3]=255&_,g}function PR(e,t,r,i,n,a){for(let o=0;o<8;o++)e[o]^=i[o];!function(e,t,r,i){let n=kR(e,0),a=kR(e,4),o=[];for(let c=0;c<4;c++)o[c]=kR(t,4*c);let s=0;for(let c=0;c<OR;c++)s+=DR,s>>>=0,n+=(a<<4)+o[0]^a+s^(a>>>5)+o[1],n>>>=0,a+=(n<<4)+o[2]^n+s^(n>>>5)+o[3],a>>>=0;SR(r,n,i),SR(r,a,i+4)}(e,t,n,a);for(let o=0;o<8;o++)n[a+o]^=r[o];for(let o=0;o<8;o++)r[o]=e[o]}var MR=function(){return new URLSearchParams(location.search).get("trtc_env")||""},UR=function(e){return e.includes(".")?e:"".concat(e).concat(".rtc.qq.com")},BR=e=>Number(e)<14e8,FR=function(e,t){let r;r=BR(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";let i=Math.floor(Math.random()*2**31);return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},VR="unknown";function WR(){!function(){var e;jR||(jR=!0,null==(e=navigator.connection)||e.addEventListener("typechange",HR))}();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(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===n&&(n="2g"),i?zR(i,n):VR}function HR(){ZO.warn("netType changed",WR())}var jR=!1;function zR(e,t){if(oA[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function GR(e){VR=zR(e)}function qR(){return oA[WR()]}function KR(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 YR(e){return XR(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function XR(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function ZR(e){return 4*JR(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function JR(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var QR="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},$R=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},eC=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 tC(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:tC(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function rC(e){return e>8?3e4:1e3*tC(e)}function iC(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var nC=e=>"function"==typeof e,aC=e=>void 0===e,oC=e=>"string"==typeof e,sC=e=>"number"==typeof e,cC=e=>"boolean"==typeof e,lC=e=>"object"===iC(e),dC=e=>"array"===iC(e),uC=e=>iC(e)==="MediaStreamTrack".toLowerCase(),hC=e=>e.isRemote,pC=e=>"promise"===iC(e),fC=e=>nC(e)&&e.prototype.constructor===e,mC=e=>fC(e)?e.prototype.constructor.name:"",gC="undefined"!=typeof AudioWorkletNode,_C="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function vC(e){return new Promise((t,r)=>{let i=[];e.forEach(n=>{n.then(t).catch(t=>{i.push(t),i.length===e.length&&r(i)})})})}function yC(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var EC=e=>+e<10?"0".concat(e):e,bC=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let r=t.split("."),i=EC(r[1])+EC(r[2]);return r[1]-15>0&&(r[1]="15"),r[2]-15>0&&(r[2]="15"),"".concat(r.join("."),".").concat(i)},wC=e=>{let t=e.split(".");if(4!==t.length)return e;let r=t[0],i=t[3];if(i.length<4)return e;let n=parseInt(i.substring(0,i.length-2),10),a=parseInt(i.substring(i.length-2),10);return"".concat(r,".").concat(n,".").concat(a)},IC=Object.prototype.hasOwnProperty;function TC(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(eC(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(IC.call(e,t))return!1;return!0}return!1}function SC(e,t){return{userId:t,hasAudio:!!(8&e),hasVideo:!!(1&e),hasAuxiliary:!!(4&e),hasSmall:!!(2&e),audioMuted:!!(64&e),videoMuted:!!(16&e),audioAvailable:!(!(8&e)||64&e),videoAvailable:!(!(1&e)||16&e),hasDatachannel:!!(256&e)}}function kC(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!aC(e.username)&&!aC(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",aC(e.credentialType)||(t.credentialType=e.credentialType)),t}function AC(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!oC(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 RC=function(e,t,r,i){if(!lC(e)||!lC(t))return 0;let n,a=0,o=Object.keys(t);for(let s=0,c=o.length;s<c;s++)if(n=o[s],!(aC(t[n])||r&&r.includes(n)))if(lC(e[n])&&lC(t[n]))a+=RC(e[n],t[n],r,i);else{if(i&&i.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=CC(t[n]),a+=1)}return a};function CC(e){if(dC(e)){let t=[];return e.forEach((e,r)=>{t[r]=CC(e)}),t}if(lC(e)){let t={};return Object.keys(e).forEach(r=>{t[r]=CC(e[r])}),t}return e}var DC=e=>{let t=[];if(dC(e))t=[...e];else if(oC(e)){let r=document.getElementById(e);r&&t.push(r)}else e&&t.push(e);return t},OC=e=>oC(e)?document.getElementById(e):e,LC=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),r=e.getFullYear(),i=e.getMonth()+1,n=e.getDate(),a=t(e.getHours()),o=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(r,"/").concat(i,"/").concat(n," ").concat(a,":").concat(o,":").concat(s)})(new Date);function xC(e,t){let{keysToInclude:r,keysToExclude:i}=t;try{if(dC(e))return"[".concat(e.map(e=>xC(e,{keysToInclude:r,keysToExclude:i})).join(","),"]");if(!eC(e)||!dC(r)&&!dC(i))return JSON.stringify(e);let t={},n=new Set(r),a=new Set(i);return Object.keys(e).forEach(o=>{(0===a.size&&n.has(o)||0===n.size&&!a.has(o))&&(t[o]=eC(e[o])||dC(e[o])?JSON.parse(xC(e[o],{keysToExclude:i,keysToInclude:r})):e[o])}),JSON.stringify(t)}catch(Yk){return"{}"}}function NC(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)}),xC(e,{keysToInclude:r})}function PC(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var MC=()=>{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},UC=async e=>new Promise((t,r)=>{let i;if(oC(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 pR({code:uR.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}),BC=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},FC=e=>(Object.keys(e).forEach(t=>{sC(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(eC(e[t])||dC(e[t]))&&FC(e[t])}),e);function VC(e,t){return new Promise(r=>{let i=setTimeout(r,e);t&&t(i)})}function WC(e,t){let r=null;return function(){for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return r||(r=e.apply(t||this,n),r.finally(()=>r=null),r)}}function HC(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function jC(e){var t;try{let{width:r,height:i,frameRate:n,sampleRate:a,sampleSize:o,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),c=e.kind===lA?"".concat(a,"x").concat(o,"@").concat(s):"".concat(r,"x").concat(i,"@").concat(n),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(zP){return""}}function zC(e,t){return e.width*e.height===t.width*t.height?1:MC()&&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 GC(e){return 90===e||270===e}async function qC(e){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 KC(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]=KC(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]=KC(e[i],t)}),r}return e}var YC=(e=>(e[e.END_REPORT=2001]="END_REPORT",e[e.LOG=2002]="LOG",e[e.KEY_METRIC_REPORT=2003]="KEY_METRIC_REPORT",e))(YC||{});function XC(e,t,r,i){try{let n=function(e,t,r,i){let n={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:r};return aC(i)||(n=Dk(Ck({},n),{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(n)}}}(e,t,r,i);return NR(IR(n),r)}catch(n){return JSON.stringify(e)}}function ZC(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 JC(e){return(65535&e)>>>0}function QC(e){return(4294901760&e)>>>0}function $C(e,t){return ZO.debug("isVideoMixerOutputTrack",e,t,e===(null==t?void 0:t.videoMixerOutputTrack)),!(!e||null==t||!t.isUsingVideoMixerInternalTrack)&&!(!t.videoMixerOutputTrack||e!==t.videoMixerOutputTrack)}function eD(e){var t;if(!e)return{animated:!1};if(e.startsWith("data:")){let t=e.match(/^data:(image\/[^;,]+)/);if(t){let e=t[1].toLowerCase();return{animated:"image/gif"===e||"image/apng"===e,mimeType:e}}return{animated:!1}}if(e.startsWith("blob:"))return{animated:!1};try{let r=null==(t=new URL(e,"https://placeholder.invalid").pathname.split(".").pop())?void 0:t.toLowerCase();if("gif"===r)return{animated:!0,mimeType:"image/gif"};if("apng"===r)return{animated:!0,mimeType:"image/apng"}}catch(zP){}return{animated:!1}}function tD(e){let t=function(e){try{let t={},r=0;t.totalLength=kR(e,r),r+=4,t.version=kR(e,r),r+=4,t.encryption=AR(e,r),r+=1,t.uinType=AR(e,r),r+=1,t.uinLength=kR(e,r),r+=4,t.uin=t.uinLength>4?RR(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),n=new Uint8Array(e.slice(0,8)),a=rD(n,t),o=7&a[0],s=e.length-1-o-LR-xR,c=new Uint8Array(s),l=0,d=i,u=e.slice(0,8);r=8;let h=1;h+=o;for(let f=1;f<=LR;)if(h<8)h++,f++;else if(8===h){let i=iD(e,r,d,u,a,t);d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}let p=s;for(;p>0;)if(h<8)c[l++]=a[h]^d[h],h++,p--;else if(8===h){let i=iD(e,r,d,u,a,t);d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}for(let f=1;f<=xR;)if(h<8)a[h],d[h],h++,f++;else if(8===h){if(r>=e.length)break;let i=iD(e,r,d,u,a,t);if(!i.success)break;d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}return c}(i,new Uint8Array(16).fill(0)),t.decrypted=!0,r=0}else e=i,r=0;return t.rspHeadLength=kR(e,r),r+=4,t.seqNo=kR(e,r),r+=4,t.retCode=kR(e,r),r+=4,t.retStrLength=kR(e,r),r+=4,t.retStr=t.retStrLength?RR(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=kR(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?RR(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=kR(e,r),r+=4,t.cookie=t.cookieLength?RR(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=kR(e,r),r+=4,t.busiBuffLength=kR(e,r),r+=4,t.busiBuff=t.busiBuffLength?RR(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function rD(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 n=DR*OR>>>0;for(let a=0;a<OR;a++)i-=(r<<4)+t[2]^r+n^(r>>>5)+t[3],i>>>=0,r-=(i<<4)+t[0]^i+n^(i>>>5)+t[1],r>>>=0,n-=DR,n>>>=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 iD(e,t,r,i,n,a){if(t+8>e.length)return{success:!1};let o=new Uint8Array(i),s=e.slice(t,t+8),c=new Uint8Array(8);for(let l=0;l<8;l++)c[l]=n[l]^s[l];return{success:!0,ivPreCrypt:o,ivCurCrypt:s,debiBuf:rD(c,a),bufPos:t+8}}var nD="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function aD(e){let{url:t,body:r,method:i="POST",timeout:n,priority:a}=e;return new Promise((e,o)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:a}).then(e=>e.clone().json().then(e=>({data:e}),()=>e.arrayBuffer().then(e=>({data:tD(new Uint8Array(e))||(nD?nD.decode(e):e)})))).then(e,o);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(t){e({data:s.response})}else o({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=n||5e3,s.open(i,t,!0),s.send(r)})}var oD=Object.prototype.hasOwnProperty,sD=e=>"function"==typeof e,cD=e=>void 0===e,lD=e=>e.isRemote;function dD(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(oD.call(e,t))return!1;return!0}return!1}var uD=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:n,onRetryFailed:a,onRetrySuccess:o,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}=r,h=0,p=-1,f=0,m=async(e,r)=>{let l=s||this;try{let r=await t.apply(l,c);h>0&&o&&o.call(this,h),h=0,e(r)}catch(g){let t=()=>{clearTimeout(p),h=0,f=2,r(g)},o=()=>{2!==f&&h<(sD(d)?d():d)?(h++,f=1,sD(n)&&n.call(this,h,t),p=window.setTimeout(()=>{p=-1,m(e,r)},sD(u)?u(h):u)):(t(),sD(a)&&a.call(this,g))};sD(i)?i.call(this,{error:g,retry:o,reject:r,retryFuncArgs:c,retriedCount:h}):o()}};return new Promise(m)}},hD=class e{constructor(e){Mk(this,"_parentPath"),Mk(this,"userId"),Mk(this,"remoteUserId"),Mk(this,"id"),Mk(this,"sdkAppId"),Mk(this,"type"),Mk(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:cD(t.userId)?this.userId:t.userId,sdkAppId:cD(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:cD(t.type)?this.type:t.type,isLocal:cD(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:cD(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId,this.debug("bindParent: ".concat(e.id)))}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,cD(this.userId)||dD(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)}},pD="undefined"==typeof navigator?"":navigator.userAgent,fD=e=>new RegExp(e,"i").test(pD),mD=e=>{if(fD(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=pD.match(t);if(r&&r[1])return r[1]}return""},gD=e=>{if(fD(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=pD.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},_D=/AppleWebKit\/([\d.]+)/i.exec(pD);_D&&parseFloat(_D[1]);var vD=fD("iPad"),yD="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&fD("Macintosh"),ED=fD("iPhone")&&!vD,bD=fD("iPod"),wD=ED||vD||bD||yD,ID=()=>{try{return wD&&navigator.maxTouchPoints>1&&navigator.vendor.includes("Apple")}catch(gk){return wD}},TD=fD("Android"),SD=function(){if(TD){let e=pD.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}();TD&&fD("webkit");var kD=fD("Firefox"),AD=mD("Firefox"),RD=gD("Firefox"),CD=fD("Edge"),DD=mD("Edge"),OD=fD("Edg"),LD=mD("Edg"),xD=gD("Edg"),ND=fD("SogouMobileBrowser"),PD=mD("SogouMobileBrowser"),MD=fD("MetaSr\\s"),UD=mD("MetaSr\\s"),BD=fD("TBS"),FD=mD("TBS"),VD=fD("XWEB"),WD=mD("XWEB");fD("MSIE\\s8\\.0");var HD=fD("MSIE\\/\\d+");!function(){if(HD){let e=/MSIE\s(\d+)\.\d/.exec(pD),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(pD)&&/rv:11.0/.test(pD)&&(t=11),t}}();var jD=fD("(micromessenger|webbrowser)"),zD=mD("MicroMessenger"),GD=!BD&&fD("MQQBrowser")&&fD("COVC"),qD=!BD&&fD("MQQBrowser")&&!fD("COVC"),KD=qD||GD?mD("MQQBrowser"):"",YD=!BD&&fD(" QQBrowser"),XD=mD(" QQBrowser"),ZD=!BD&&fD("QQBrowserLite"),JD=mD("QQBrowserLite"),QD=!BD&&fD("MQBHD"),$D=mD("MQBHD"),eO=fD("Windows"),tO=!wD&&fD("MAC OS X"),rO=!TD&&fD("Linux"),iO=fD("CrOS");fD("MicroMessenger");var nO=fD("UCBrowser"),aO=fD("Electron"),oO=fD("MiuiBrowser"),sO=mD("MiuiBrowser"),cO=fD("HuaweiBrowser"),lO=fD("Huawei")||fD("HUAWEI"),dO=fD("Honor")||fD("HONOR"),uO=mD("HuaweiBrowser"),hO=fD("SamsungBrowser"),pO=mD("SamsungBrowser"),fO=fD("HeyTapBrowser"),mO=mD("HeyTapBrowser"),gO=fD("VivoBrowser"),_O=mD("VivoBrowser"),vO=fD("OpenHarmony");mD("OpenHarmony");var yO=()=>gD("Chrome"),EO=fD("CriOS"),bO=fD("Chrome"),wO=!CD&&!MD&&!ND&&!BD&&!VD&&!OD&&!YD&&!oO&&!cO&&!hO&&!fO&&!gO&&bO,IO=fD("HeadlessChrome"),TO=yO(),SO=bO&&TO>=128&&TO<=143,kO=mD("Chrome"),AO=gD("Electron"),RO=!bO&&!qD&&!GD&&!ZD&&!QD&&fD("Safari"),CO=RO||wD,DO=mD("Version"),OO=/Android.*(wv|.0.0.0)/.test(pD),LO=(()=>{if(yD)return DO;if(wD){let e=pD.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function xO(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.split(".").map(e=>Number(e)),n=t.split(".").map(e=>Number(e));for(let a=0;a<Math.max(i.length,n.length);a++){let e=i[a]||0,t=n[a]||0;if(e>t)return!0;if(e<t)return!1}return r}var NO=Number(LO.split(".")[0]),PO="15.1"===LO,MO=(()=>{let e=Number(LO.split(".")[0]);return 14===e||13===e})(),UO=EO&&"11.1.1"===DO,BO="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),FO=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(t){e=!1}return e}})(),VO=function(){let e=new Map([[kD,["Firefox",AD]],[OD,["Edg",LD]],[wO,["Chrome",kO]],[EO,["ChiOS",mD("CriOS")]],[RO&&!EO,["Safari",DO]],[BD,["TBS",FD]],[VD,["XWEB",WD]],[jD&&ED,["WeChat",zD]],[YD,["QQ(Win)",XD]],[qD,["QQ(Mobile)",KD]],[GD,["QQ(Mobile X5)",KD]],[ZD,["QQ(Mac)",JD]],[QD,["QQ(iPad)",$D]],[oO,["MI",sO]],[cO,["HW",uO]],[hO,["Samsung",pO]],[fO,["OPPO",mO]],[gO,["VIVO",_O]],[CD,["EDGE",DD]],[ND,["SogouMobile",PD]],[MD,["Sogou",UD]]]),t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}();function WO(){return function(){let e=/;\s*([^;)]+)\s+Build\//,t=pD.match(e);return null!=t&&t[1]?t[1].trim():null}()||""}var HO=new Map([[TD,"Android"],[wD,"iOS"],[eO,"Windows"],[tO,"MacOS"],[rO,"Linux"],[iO,"ChromeOS"]]),jO=function(){return HO.get(!0)?HO.get(!0):"unknown"};function zO(){return eO?1:TD?2:tO?3:wD?4:rO?5:iO?6:vO?7:0}var GO=()=>{let e=jO();return wD?e+="/".concat(LO):TD&&(e+="/".concat(SD)),e+="/".concat(VO.name,"/").concat(RO&&!EO?VO.version:VO.version.split(".")[0]),e},qO=new(Nk(Bk(),1).default),KO=jk,YO=new class{constructor(){Mk(this,"enable",!1),Mk(this,"ssoFailCount",0),qO.on("22",e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.sso&&qO.emit("266",{enable:!0})}),qO.on("266",e=>{let{enable:t}=e;this.enable=t})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&qO.emit("266",{enable:!1})}},XO=class e{constructor(){Mk(this,"_isEnableUploadLog",!0),Mk(this,"_localJoinedUser",new Map),Mk(this,"_queue",[]),Mk(this,"_timeoutId",-1),Mk(this,"_logLevel",1),Mk(this,"_logLevelToUpload",2),!Qk&&!$k&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){qO.on(KO.JOIN_SCHEDULE_SUCCESS,e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&aA[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),qO.on(KO.JOIN_START,e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),qO.on(KO.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:n}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:n,logs:[r]})});else if(oC(r.userId)&&sC(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}async upload(){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:n}=t[e],a={timestamp:mR(),sdkAppId:String(i),userId:r,version:Jk,log:n.map(e=>e.log).join("\n")},o=JSON.stringify(a),s=YO.enable?XC(a,2002,i):o;await this.uploadLogWithRetry(s,i,s instanceof Uint8Array,o),n.forEach(e=>e.uploaded=!0)}}catch(i){}let r=t.filter(e=>!e.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(e,t,r,i){return uD({retryFunction:()=>aD({url:FR(t,iA),body:e,timeout:5e3,priority:"low"}).then(e=>{r&&"ok"!==e.data&&(YO.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(fR()),"[".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(aA[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){aC(aA[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(oC(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(zP){return""}}addLogToQueue(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0,a={log:t.reduce((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim(),""),level:e,userId:i,sdkAppId:n,forAllJoinedClients:r};qO.emit(KO.LOG,{log:a}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(a)}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;var o;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,i,n,a),t<this._logLevel)return;let s=(null==(o=aA[t])?void 0:o.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 hD){let t=e,{parent:r}=t,i=((e,t)=>{var r={};for(var i in e)kk.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&Tk)for(var i of Tk(e))t.indexOf(i)<0&&Ak.call(e,i)&&(r[i]=e[i]);return r})(t,["parent"]),n=new hD(i);return n.bindParent(r),n}return new hD(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;aA[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};Mk(XO,"PRINT_LOG_TAG",!(wD||TD||IO));var ZO=new XO,JO=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)})},QO=new class{constructor(){Mk(this,"_prefix","TRTC"),Mk(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){FO()&&(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(t){return!1}return!1}).forEach(e=>localStorage.removeItem(e)))}doFlush(){if(FO())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(e){ZO.warn(e)}}getItem(e){if(!FO())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(zP){ZO.warn(zP)}}setItem(e,t){if(FO())try{let r={expiresIn:Date.now()+6048e5,value:t};this._queue.set(this.getRealKey(e),r)}catch(Yk){ZO.warn(Yk)}}deleteItem(e){if(!FO())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(zP){return ZO.warn(zP),!1}}clear(){if(FO())try{localStorage.clear()}catch(e){ZO.warn(e)}}};xk({},{HTTPS_API:()=>CL,IS_GET_CAPABILITIES_FROM_INPUTDEVICE_SUPPORTED:()=>JL,IS_GET_CAPABILITIES_SUPPORTED:()=>ZL,IS_GET_SETTINGS_SUPPORTED:()=>XL,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>YL,IS_INSERTABLE_STREAM_SUPPORTED:()=>QL,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>ux,IS_RTC_RTP_SENDER_SUPPORTED:()=>GL,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>$L,IS_SEI_SUPPORTED:()=>ex,IS_SPC_SUPPORTED:()=>jL,basis:()=>ox,capabilityCheck:()=>lx,checkSystemRequirementsInternal:()=>wL,decodeSupportStatus:()=>bL,detectH264SupportedByFakeStreaming:()=>AL,detectVideoCodecCapabilities:()=>fx,detectVideoDecoderCapabilities:()=>gx,detectVideoEncoderCapabilities:()=>mx,encodeSupportStatus:()=>EL,getBrowserInfo:()=>hL,getDisplayResolution:()=>OL,getH264ProfileLevelIds:()=>_x,isAddTransceiverSupported:()=>HL,isBrowserSupported:()=>pL,isCanvasCaptureStreamAPISupported:()=>NL,isCanvasSmallStreamSupported:()=>PL,isGetReceiversSupported:()=>FL,isGetSendersSupported:()=>VL,isGetTransceiversSupported:()=>WL,isGetUserMediaSupported:()=>LL,isMediaDevicesSupported:()=>mL,isMediaSessionSupported:()=>ix,isMediaStreamTrackGeneratorSupported:()=>yL,isMediaStreamTrackProcessorSupported:()=>vL,isOffscreenCanvasWorkerSupported:()=>bx,isReplaceTrackSupported:()=>qL,isRequestVideoFrameCallbackSupported:()=>dx,isSIMDSupported:()=>ax,isScaleResolutionDownBySupported:()=>ML,isScreenCaptureApiAvailable:()=>TL,isSelectedCandidatePair:()=>DL,isSetParametersSupported:()=>KL,isSetSinkIdSupported:()=>SL,isSmallStreamSupported:()=>UL,isStopTransceiverSupported:()=>zL,isTRTCSupported:()=>IL,isTrackGeneratorOutputSupported:()=>yx,isUnifiedPlanDefault:()=>BL,isUsedInHttpProtocol:()=>_L,isWebAudioSupported:()=>xL,isWebCodecSupported:()=>rx,isWebCodecsSupported:()=>fL,isWebRTCSupported:()=>tx,isWebTransportSupported:()=>nx});var $O={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",SWITCH_PLAYBACK_QUALITY_TIMEOUT:"SWITCH_PLAYBACK_QUALITY_TIMEOUT"},eL={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:n}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:n}=e,a="".concat(t||r.name),o="";return o=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(a,"' must be type of ").concat(o," when calling ").concat(i,"(), received type: ").concat(iC(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:n}=e;return"'".concat(t||r.name,"' cannot be '").concat(n,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:n}=e,a="".concat(t||r.name),o="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(i,"(), received type: ").concat(iC(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:n}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(n,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,fnName:i,value:n}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,fnName:i,value:n}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(n,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code: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:n}=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:n}=e;return"api ".concat(r," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(n," 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,"()"),SWITCH_PLAYBACK_QUALITY_TIMEOUT:e=>"switchPlaybackQuality timeout: waiting for first frame of user ".concat(e.userId,".")},tL=(e,t)=>t?"".concat(eA,"/").concat(e,"/").concat(t):"".concat(eA,"/").concat(e,"/index.html"),rL=()=>{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("trtc_error_assistance");if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let 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 iL(e){let{key:t,data:r,link:i,addDocLink:n=!0}=e,a="",o="",s="";nC(eL[t])?a=eL[t](r):oC(eL[t])&&(a=eL[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=rL();i?s="".concat(i.className,".html#").concat(i.fnName):l&&l[t]&&(nC(l[t])?s=l[t](r):oC(l[t])&&(s=l[t]));let d=a;return $R()&&(c&&c[t]&&(nC(c[t])?o=c[t](r):oC(c[t])&&(o=c[t])),o&&(d=n?"".concat(o,"\n请查看文档: ").concat(tL("zh-cn",s),"\n\n"):"".concat(o,"\n\n"),d+=a)),n&&(d+=" \nRefer to: ".concat(tL("en",s),"\n")),d}var nL,aL=Nk(Hk(),1),oL=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Mk(this,"countMap",new Map),Mk(this,"distributionMap",new Map),Mk(this,"version"),Mk(this,"log",ZO.createLogger({id:"kv"})),e&&(qO.on("102",e=>{let{track:t,cost:r}=e;this.addSuccessEvent({key:t.kind===lA?501700:511700,cost:r})}),qO.on("103",e=>{let{track:t,error:r}=e;this.addFailedEvent({key:t.kind===lA?501700:511700,error:r})}),qO.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:BC(this.version||Jk),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 n;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 a=(null==(n=this.distributionMap)?void 0:n.get(t))||new Map;a.set(r,(a.get(r)||0)+1),this.distributionMap.set(t,a)}addNumber(e){let{key:t,value:r,split:i=100,useUV:n=!1,max:a=5e3}=e;var o;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(n&&this.countMap.has(t))return;r>a&&(r=a),this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map,c=0;if(sC(i))c=Math.floor(r/i);else for(let l=i.length-1;l>0;l--)if(r>i[l]){c=l;break}s.set(c,(s.get(c)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:r,timeKey:i,split:n}=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:n}):i||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:r}=e;if(!t)return;let i=uR.UNKNOWN;r&&(sC(r)?i=r:(!aC(r.extraCode)||!aC(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})}},sL=((nL=sL||{})[nL.DECODER_TYPE=514700]="DECODER_TYPE",nL[nL.DECODER_HW_SW=514701]="DECODER_HW_SW",nL[nL.DECODE_RESULT=514702]="DECODE_RESULT",nL[nL.DECODE_FAILED_OS=514703]="DECODE_FAILED_OS",nL[nL.DOWNGRADE_RESULT=514704]="DOWNGRADE_RESULT",nL[nL.DOWNGRADE_WEBCODECS_VIDEO=514705]="DOWNGRADE_WEBCODECS_VIDEO",nL[nL.DOWNGRADE_WEBCODECS_2D=514706]="DOWNGRADE_WEBCODECS_2D",nL[nL.DOWNGRADE_WASM_WEGBL=514707]="DOWNGRADE_WASM_WEGBL",nL[nL.DOWNGRADE_WASM_VIDEO=514708]="DOWNGRADE_WASM_VIDEO",nL[nL.DOWNGRADE_WASM_2D=514709]="DOWNGRADE_WASM_2D",nL[nL.DECODE_H264_RESULT=514710]="DECODE_H264_RESULT",nL[nL.DECODE_H265_RESULT=514711]="DECODE_H265_RESULT",nL[nL.DECODE_VP8_RESULT=514712]="DECODE_VP8_RESULT",nL[nL.DECODE_CAPABILITIES=514713]="DECODE_CAPABILITIES",nL[nL.H264_PROFILE_LEVEL_ID_HIGH=514714]="H264_PROFILE_LEVEL_ID_HIGH",nL[nL.H264_PROFILE_LEVEL_ID_MAIN=514715]="H264_PROFILE_LEVEL_ID_MAIN",nL[nL.RENDER_FREEZE_RATE=514850]="RENDER_FREEZE_RATE",nL[nL.DATA_FREEZE_RATE=514851]="DATA_FREEZE_RATE",nL[nL.VIDEO_CONSUME_RENDER_RATE=514852]="VIDEO_CONSUME_RENDER_RATE",nL),cL=new oL(!0);new oL(!1);var lL=cL,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}},uL=new Map([[kD,["Firefox",AD]],[OD,["Edg",LD]],[wO,["Chrome",kO]],[RO,["Safari",DO]],[BD,["TBS",FD]],[VD,["XWEB",WD]],[jD&&ED,["WeChat",zD]],[YD,["QQ(Win)",XD]],[qD,["QQ(Mobile)",KD]],[GD,["QQ(Mobile X5)",KD]],[ZD,["QQ(Mac)",JD]],[QD,["QQ(iPad)",$D]],[oO,["MI",sO]],[cO,["HW",uO]],[hO,["Samsung",pO]],[fO,["OPPO",mO]],[gO,["VIVO",_O]],[CD,["EDGE",DD]],[ND,["SogouMobile",PD]],[MD,["Sogou",UD]]]);function hL(){let e=uL.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var pL=function(){return!(nO||CD||OD&&xD<80||kD&&RD<56)},fL=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every(e=>e in window)},mL=function(){if(!navigator.mediaDevices)return _L()||ZO.error(eL.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter(e=>e in navigator.mediaDevices).length===e.length},gL=!1;function _L(){return"http:"===location.protocol&&!BO&&(gL||ZO.error(iL({key:$O.NOT_SUPPORTED_HTTP})),gL=!0,!0)}var vL=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},yL=function(){return!(null==window||!window.MediaStreamTrackGenerator)},EL=async function(){var e,t,r;if(dL.detail.isH264EncodeSupported&&dL.detail.isVp8EncodeSupported)return{isH264EncodeSupported:dL.detail.isH264EncodeSupported,isVp8EncodeSupported:dL.detail.isVp8EncodeSupported,isH265EncodeSupported:dL.detail.isH265EncodeSupported};let i,n=!1,a=!1,o=!1;try{let s=new RTCPeerConnection,c=document.createElement(cA);c.getContext("2d");let l=c.captureStream(0);return s.addTrack(l.getVideoTracks()[0],l),i=await s.createOffer(),n=-1!==(null==(e=i.sdp)?void 0:e.toLowerCase().indexOf("h264")),a=-1!==(null==(t=i.sdp)?void 0:t.toLowerCase().indexOf("vp8")),o=-1!==(null==(r=i.sdp)?void 0:r.toLowerCase().indexOf("h265")),s.close(),{isH264EncodeSupported:n,isVp8EncodeSupported:a,isH265EncodeSupported:o}}catch(s){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1}}},bL=async 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,r=!1,i=!1;try{let n=new RTCPeerConnection;HL()?(n.addTransceiver(dA,{direction:"recvonly"}),t=await n.createOffer()):t=await n.createOffer({offerToReceiveVideo:!0}),-1!==t.sdp.toLowerCase().indexOf("h264")&&!(OO&&TO<79)&&(r=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(i=!0);let a=-1!==(null==(e=t.sdp)?void 0:e.toLowerCase().indexOf("h265"));return n.close(),{isH264DecodeSupported:r,isVp8DecodeSupported:i,isH265DecodeSupported:a}}catch(n){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}}};var wL=WC(async e=>{let t=Date.now(),r=tx(),i=mL(),n=fL();if(dL.detail.isWebRTCSupported=r,dL.detail.isMediaDevicesSupported=i,dL.detail.isWebCodecsSupported=n,dL.detail.isScreenShareSupported=TL(),dL.detail.isSmallStreamSupported=UL(),37===e)return Object.assign(dL.detail,await async function(){return RL||(RL=new Promise(async e=>{let t={isH264EncodeSupported:!1,isH264DecodeSupported:!1,isVp8EncodeSupported:!1,isVp8DecodeSupported:!1};if(!fL())return void e(t);let r=null,i=null,n=null,a=()=>{n&&clearTimeout(n),r=null,i=null};try{r=document.createElement("canvas"),i=r.getContext("2d"),r.width=320,r.height=240;let o=0,s=()=>{!i||!r||(i.fillStyle="hsl(".concat(o%360,", 50%, 50%)"),i.fillRect(0,0,r.width,r.height),i.fillStyle="white",i.font="20px Arial",i.fillText("Frame ".concat(o),10,30),o++)};n=setTimeout(()=>{a(),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"}}];(await Promise.all(c.map(async e=>{let t,i={type:e.type,encodeSupported:!1,decodeSupported:!1};try{t=await new Promise(async(t,n)=>{try{let a=new VideoEncoder({output:e=>{t(e),i.encodeSupported=!0},error:n});a.configure(e.encodeConfig),s();let o=new VideoFrame(r,{timestamp:0});a.encode(o,{keyFrame:!0}),o.close(),await a.flush(),a.close()}catch(a){n(a)}})}catch(p){return ZO.warn("".concat(e.type," encoder error:"),p),i}try{await new Promise(async(r,n)=>{try{let a=new VideoDecoder({output:e=>{i.decodeSupported=!0,r(0),e.close()},error:n});a.configure(e.decodeConfig),a.decode(t),await a.flush(),a.close()}catch(a){n(a)}})}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)}),a(),e(t)}catch(o){a(),ZO.warn("detectWebCodecsSupported failed:",o),e(t)}}),RL)}()),dL.detail.isBrowserSupported=n,dL.result=i&&n,dL.result||ZO.error("".concat(navigator.userAgent," ").concat(NC(dL.detail,!1))),cx(e),lL.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 a=pL(),{encode:o,decode:s}=await async function(){let[e,t]=await Promise.all([EL(),bL()]);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}=o,{h264:d}=s,{h265:u}=o,{vp8:h,h265:p}=s;if(!c||!l){let e=await EL();ZO.warn("detect encode again h264:".concat(c," vp8:").concat(l," result: ").concat(JSON.stringify(e))),c=e.isH264EncodeSupported,l=e.isVp8EncodeSupported}if(c&&d&&TD&&bO&&!VD&&!BD&&(!fO||115!==TO)){let{encode:e,decode:t}=await AL();c=e,d=t}return dL.result=a&&r&&i&&(c||l)&&(d||h),dL.detail.isBrowserSupported=a,dL.detail.isWebRTCSupported=r,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||ZO.error("".concat(navigator.userAgent," ").concat(NC(dL.detail,!1))),cx(),lL.addNumber({key:523800,value:Date.now()-t}),dL}),IL=function(){return dL.result},TL=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},SL="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype,kL=null;async function AL(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;return kL||(kL=new Promise(async t=>{let r={encode:!1,decode:!1},i=()=>{};try{let n=document.createElement("canvas"),a=n.getContext("2d");n.width=640,n.height=480;let o=setInterval(()=>{a.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},66),s=-1,c=-1;i=()=>{clearInterval(s),clearInterval(o),clearTimeout(c),d.close(),u.close(),l.getTracks().forEach(e=>e.stop())},c=setTimeout(()=>{i(),t(r)},e);let l=n.captureStream(),d=new RTCPeerConnection({}),u=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});d.addEventListener("icecandidate",e=>u.addIceCandidate(e.candidate)),u.addEventListener("icecandidate",e=>d.addIceCandidate(e.candidate)),d.addTrack(l.getVideoTracks()[0],l);let h=await d.createOffer();await d.setLocalDescription(h),await u.setRemoteDescription(h);let p=await u.createAnswer(),f=aL.default.parse(p.sdp),m=f.media[0].rtp.findIndex(e=>"H264"===e.codec);f.media[0].rtp=[f.media[0].rtp[m]],f.media[0].fmtp=f.media[0].fmtp.filter(e=>e.payload===f.media[0].rtp[0].payload),f.media[0].rtcpFb&&(f.media[0].rtcpFb=f.media[0].rtcpFb.filter(e=>e.payload===f.media[0].rtp[0].payload)),p.sdp=aL.default.write(f),await u.setLocalDescription(p),await d.setRemoteDescription(p),s=setInterval(async()=>{r.encode&&r.decode&&(i(),t(r));let e=d.getSenders()[0],n=u.getReceivers()[0];if(!e||!n)return;let[a,o]=await Promise.all([e.getStats(),n.getStats()]);r.encode||a.forEach(e=>{"outbound-rtp"===e.type&&(e.mediaType===dA||e.kind===dA)&&e.bytesSent>0&&(r.encode=!0)}),r.decode||o.forEach(e=>{"inbound-rtp"===e.type&&(e.mediaType===dA||e.kind===dA)&&e.bytesReceived>0&&(r.decode=!0)})},100)}catch(n){i(),ZO.warn("detectH264Supported failed",n),t({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("")),e)),kL)}var RL=null;var CL=(e,t,r)=>{"http:"===location.protocol&&!BO&&(e[t]=()=>{throw new pR({code:uR.INVALID_OPERATION,message:eL.NOT_SUPPORTED_HTTP})})},DL=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(cC(e.selected)&&!e.selected)};function OL(){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 LL(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function xL(){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 NL(){return"captureStream"in HTMLCanvasElement.prototype}function PL(){return!(jD||wD||TO&&TO<63)&&!(!pL()||!NL())}function ML(){return!(TO<74||CD||NO<11||RD<46)}function UL(){return PL()||ML()}var BL=function(){if(aC(window.RTCRtpTransceiver)||!HL()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:"unified-plan"}),e.addTransceiver(lA),t=!0}catch(zP){}return null==e||e.close(),t};function FL(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function VL(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function WL(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function HL(){return!(11===NO&&!UO)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var jL=!(!HL()||bO&&TO<86);function zL(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var GL="RTCRtpSender"in window;function qL(){return GL&&"replaceTrack"in window.RTCRtpSender.prototype}function KL(){return GL&&"setParameters"in window.RTCRtpSender.prototype&&VL()}var YL="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,XL=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,ZL=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,JL="undefined"!=typeof InputDeviceInfo&&"getCapabilities"in InputDeviceInfo.prototype,QL=GL&&"createEncodedStreams"in window.RTCRtpSender.prototype&&yO()>=86,$L="RTCRtpScriptTransform"in window,ex=GL&&(QL||$L),tx=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(e=>e in window).length>0};function rx(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return aC(window.AudioDecoder)||(e.AudioDecoder=!0),aC(window.AudioEncoder)||(e.AudioEncoder=!0),aC(window.VideoDecoder)||(e.VideoDecoder=!0),aC(window.VideoEncoder)||(e.VideoEncoder=!0),aC(window.ImageDecoder)||(e.ImageDecoder=!0),e}function ix(){return"mediaSession"in navigator&&!aC(navigator.mediaSession.setActionHandler)}function nx(){return!aC(window.WebTransport)}function ax(){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 ox(){let e={browser:"".concat(VO.name,"/").concat(VO.version),os:jO(),displayResolution:OL(),isScreenShareSupported:TL(),isWebRTCSupported:tx(),isGetUserMediaSupported:LL(),isWebAudioSupported:xL(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:rx(),isMediaSessionSupported:ix(),isWebTransportSupported:nx()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var sx="checkResult";function cx(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;QO.setItem(sx+e,{ua:navigator.userAgent,checkResult:dL})}function lx(e){_L();let t=QO.getItem(sx+e);t&&t.ua===navigator.userAgent&&t.checkResult&&function(e,t){return!!lC(e)&&Object.keys(t).every(t=>t in e)}(t.checkResult.detail,dL.detail)&&(dL=t.checkResult),wL(e)}function dx(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var ux="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype;function hx(e){return{h264:1,h265:2,vp8:3,vp9:4,av1:5}[e]}var px=!1;async function fx(){var e;try{if(px||null==(e=null==navigator?void 0:navigator.mediaCapabilities)||!e.encodingInfo)return;let t=zO(),r=jD||VD?4:bO?1:RO?2:kD?3:0;if(0===t||0===r)return;px=!0;let i=["H264","VP8","VP9","AV1","H265"],[n,a]=await Promise.all([mx(i),gx(i)]);n&&Object.keys(n).forEach(e=>{let i=hx(e.toLowerCase());lL.addEnum({key:513707,value:+"".concat(i).concat(+n[e].supported).concat(+n[e].powerEfficient).concat(t).concat(r),useUV:!1})}),a&&Object.keys(a).forEach(e=>{let i=hx(e.toLowerCase());lL.addEnum({key:514713,value:+"".concat(i).concat(+a[e].supported).concat(+a[e].powerEfficient).concat(t).concat(r),useUV:!1})});let{sender:o,receiver:s}=_x();lL.addEnum({key:513708,value:+"".concat(t).concat(r).concat(+o.high),useUV:!1}),lL.addEnum({key:513709,value:+"".concat(t).concat(r).concat(+o.main),useUV:!1}),lL.addEnum({key:514714,value:+"".concat(t).concat(r).concat(+s.high),useUV:!1}),lL.addEnum({key:514715,value:+"".concat(t).concat(r).concat(+s.main),useUV:!1})}catch(t){ZO.info("detectVideoCodecCapabilities failed",t)}}async function mx(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,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,a={};try{for(let o of e){let e=await navigator.mediaCapabilities.encodingInfo({type:"webrtc",video:{contentType:"video/".concat(o),width:t,height:r,bitrate:n,framerate:i}});a[o]=e}}catch(Xk){}return a}async function gx(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,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,a={};try{for(let o of e){let e=await navigator.mediaCapabilities.decodingInfo({type:"webrtc",video:{contentType:"video/".concat(o),width:t,height:r,bitrate:n,framerate:i}});a[o]=e}}catch(Xk){}return a}function _x(){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(t){ZO.warn("get H264 profile levelId failed",t)}return e}var vx=null;function yx(){if(null!==vx)return vx;let e="undefined"!=typeof MediaStreamTrackGenerator,t="undefined"!=typeof VideoFrame;return vx=e&&t,ZO.debug("TrackGenerator support: ".concat(vx," (MediaStreamTrackGenerator=").concat(e,", VideoFrame=").concat(t,")")),vx}var Ex=null;function bx(){if(null!==Ex)return Ex;if(CO)return Ex=!1,!1;let e=!1;try{"undefined"!=typeof OffscreenCanvas&&(e=!!new OffscreenCanvas(1,1).getContext("2d"))}catch(t){}return Ex=e&&yx()&&("undefined"!=typeof VideoFrame||"function"==typeof createImageBitmap)&&vL()&&function(){try{if("undefined"==typeof ReadableStream)return!1;let e=new ReadableStream,{port1:t,port2:r}=new MessageChannel;return t.postMessage(e,[e]),t.close(),r.close(),!0}catch(e){return!1}}(),Ex}var wx=Nk(Bk(),1),Ix=Symbol("instance"),Tx=Symbol("cacheResult"),Sx=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,Dx.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},kx=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var Ax=new Map;function Rx(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,n,a)=>{let o=r.action||n;if(!r.context){let r=Ax.get(i)||[];Ax.has(i)||Ax.set(i,r),r.push({from:e,to:t,action:o})}let s=a.value;a.value=function(){let i=this;for(var n=arguments.length,a=new Array(n),c=0;c<n;c++)a[c]=arguments[c];if(r.context&&(i=Ox.get("function"==typeof r.context?r.context.call(this,...a):r.context)),i.state===t)return r.sync?i[Tx]:Promise.resolve(i[Tx]);i.state instanceof Sx&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof Sx&&i.state.abort(i):("string"!=typeof i.state||!e.includes(i.state))&&(l=new kx(i._state,"".concat(i.name," ").concat(o," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new kx(i._state,"".concat(i.name," ").concat(o," 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(l)return d(l);let u=i.state,h=new Sx(u,t,o);Dx.call(i,h);let p=e=>{var n;return i[Tx]=e,h.aborted||(Dx.call(i,t),null===(n=r.success)||void 0===n||n.call(this,i[Tx])),e},f=e=>(Dx.call(i,u,e),d(e));try{let e=s.apply(this,a);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(f):r.sync?p(e):Promise.resolve(p(e))}catch(m){return f(new kx(i._state,"".concat(i.name," ").concat(o," from ").concat(e," to ").concat(t," failed: ").concat(m),m instanceof Error?m:new Error(String(m))))}}}}var Cx="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 Dx(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(Ox.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var Ox=class e extends wx.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 n=i[Ix];n?this.name=n.name+"-"+n.count++:i[Ix]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Ax.get(e)||[],r=new Set,i=[],n=[],a=new Set,o=Object.getPrototypeOf(e);Ax.has(o)&&(o.stateDiagram.forEach(e=>r.add(e)),o.allStates.forEach(e=>a.add(e))),t.forEach(e=>{let{from:t,to:r,action:a}=e;"string"==typeof t?i.push({from:t,to:r,action:a}):t.length?t.forEach(e=>{i.push({from:e,to:r,action:a})}):n.push({to:r,action:a})}),i.forEach(e=>{let{from:t,to:i,action:n}=e;a.add(t),a.add(i),a.add(n+"ing"),r.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),r.add("".concat(n,"ing --\x3e ").concat(i," : ").concat(n," 🟢")),r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))}),n.forEach(e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),a.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:a}}),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]:{};Cx(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){Dx.call(this,e)}};Ox.STATECHANGED="stateChanged",Ox.UPDATEAFSM="updateAFSM",Ox.INIT="[*]",Ox.ON="on",Ox.OFF="off",Ox.instances=new Map,Ox.instances2=new WeakMap;var Lx="undefined"!=typeof window,xx=Lx&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1e3)},Nx=Lx&&window.cancelIdleCallback||function(e){clearTimeout(e)},Px=Lx&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),Mx=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=Ck("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=Dk(Ck({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=yC(),n=()=>{if(r=yC()-i,r>=t.delay&&(i=yC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=xx(n,{timeout:t.delay})};return t.ricID=xx(n,{timeout:t.delay})}static raf(t){let r,i=yC(),n=()=>document.hidden&&t.backgroundTask?(r=yC()-i,i=yC(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(n,t.delay-Math.floor(r%t.delay))):(r=yC()-i,r>=t.delay&&(i=yC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(n));if(t.rafID=requestAnimationFrame(n),t.backgroundTask){let e=()=>{if(document.hidden){let e=yC()-i;e>=t.delay?n():t.timeoutID=setTimeout(n,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:n,onVisibilitychange:a}=this.taskMap.get(e);return t&&clearInterval(t),r&&clearTimeout(r),i&&Px&&Px(i),n&&Nx(n),a&&document.removeEventListener("visibilitychange",a),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)}};Mk(Mx,"taskMap",new Map),Mk(Mx,"currentTaskID",1),Mk(Mx,"sharedWorker",null),Mk(Mx,"workerTasks",new Map);var Ux=Mx,Bx={LOAD_START:yA,LOADED_DATA:EA,LOADED_META_DATA:bA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",RESIZE:AA,TIME_UPDATE:"time-update",LEAVE_PICTURE_IN_PICTURE:SA,ENTER_PICTURE_IN_PICTURE:TA,USER_RESUME_IN_PIP_OR_FULL_SCREEN:"user-resume-in-pip-or-full-screen",USER_PAUSE_IN_PIP_OR_FULL_SCREEN:"user-pause-in-pip-or-full-screen",ENTER_FULL_SCREEN:"enter-full-screen",LEAVE_FULL_SCREEN:"leave-full-screen",VOLUME_CHANGE:"volume-change"},Fx={};xk(Fx,{create:()=>Wx,remove:()=>Hx});var Vx=new WeakMap;function Wx(e,t){Vx.has(e)||Vx.set(e,[]);let r=Vx.get(e),i={add:(e,n)=>("addEventListener"in t?(r.push(t.removeEventListener.bind(t,e,n)),t.addEventListener(e,n)):(r.push(t.off.bind(t,e,n)),t.on(e,n)),i)};return i}function Hx(e){let t=Vx.get(e);t&&(t.forEach(e=>e()),Vx.delete(e))}var jx=new class{constructor(){Mk(this,"_roomIdMap",new Map),Mk(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:Jk,env:nA,browserVersion:VO.name+VO.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:r,userId:i,roomId:n}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=r,this._configs.userId=i,this._roomIdMap.set(i,String(n))}logSuccessEvent(e){BO||!ZO.isAbleToUpload||this._configs.env===nA&&this.uploadEventToKibana(Dk(Ck({},e),{result:"success"}))}logFailedEvent(e){if(BO||!ZO.isAbleToUpload)return;let{eventType:t,code:r,error:i,userId:n}=e,a={roomId:this._roomIdMap.get(n||this._configs.userId),userId:n,eventType:t,result:"failed",code:r||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||uR.UNKNOWN};this._configs.env===nA&&this.uploadEventToKibana(Dk(Ck({},a),{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,n={timestamp:mR(),sdkAppId:this._configs.sdkAppId,userId:r||this._configs.userId,version:Jk,log:t};i&&(n.errorInfo=i.message,i.stack&&(n.errorInfo+="\n".concat(i.stack)));let a=YO.enable?XC(n,2002,Number(this._configs.sdkAppId)):JSON.stringify(n);this.sendRequest(FR(this._configs.sdkAppId,iA),a)}sendRequest(e,t){setTimeout(()=>aD({url:e,body:t,priority:"low"}).catch(()=>{}),2e3)}},zx=new WeakMap;var Gx=class extends Ox{constructor(e,t){super(e.id,"".concat(t,"-player")),this.options=e,this.kind=t,Mk(this,"id"),Mk(this,"element",null),Mk(this,"track"),Mk(this,"url"),Mk(this,"attr"),Mk(this,"mode"),Mk(this,"muted"),Mk(this,"_log"),Mk(this,"isPausedByUserCall",!1),Mk(this,"_pausedRetryCount"),Mk(this,"_isElementPlayingFired",!1),Mk(this,"_interval"),Mk(this,"_delayDestroyTimeoutId",0),Mk(this,"_playSuccessResolve"),Mk(this,"_isReplayByRecreateMediaStreamCalled",!1),Mk(this,"isPlayCalled",!1),Mk(this,"isInAutoPlayFailedState",!1),Mk(this,"isBindAutoPlayEvent",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=5,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))}async play(){if(!this.isPlaying)try{this.isPlayCalled=!0,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),await new Promise((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)})}catch(zP){let t=iL({key:$O.PLAY_FAILED,data:{media:this.kind,error:zP}});if(this._log.warn(zP),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new pR({code:uR.PLAY_NOT_ALLOWED,message:t})}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this.isPlayCalled=!1,this.isPausedByUserCall=!1,this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!CO?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(mA),this._interval>0&&Ux.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(){this._log.info("pause"),this.isPausedByUserCall=!0,this.doPause()}doPause(){var e;null==(e=this.element)||e.pause()}resume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPausedByUserCall=!1,this.doResume(e)}doResume(){return this._log.info("resume"),this.isPausedByUserCall||this.isPlaying?Promise.resolve():PO?this.replay():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 Wx(this.element,this.element).add(gA,e).add(mA,e).add(_A,e).add(vA,e).add(yA,e).add(EA,e).add(bA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==Fx||Fx.create(e,e).add(mA,t).add(pA,t).add(fA,t),e.readyState===mA&&this.handleTrackEvent({type:mA}),e.muted&&this.handleTrackEvent({type:pA})}}bindAutoPlayEvent(){this.isBindAutoPlayEvent||(qO.on(KO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this),this.isBindAutoPlayEvent=!0)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&Hx(e)}unbindEvents(){this.element&&Hx(this.element),this.unbindTrackEvents(),qO.off(KO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this),this.isBindAutoPlayEvent=!1}handleElementEvent(e){switch(e.type){case gA:lN()||(this.isInAutoPlayFailedState=!1),this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(gA),this._interval&&(Ux.clearTask(this._interval),this._interval=-1);break;case mA:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(mA);break;case _A:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(_A);break;case vA:if(this.element&&this.element.error){this.handlePaused(vA);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)),jx.uploadEvent({log:"stat-".concat(this.kind,"-").concat(RA,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),dO||lO?this.emit(Bx.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case EA:this.kind===dA&&this.emit(Bx.LOADED_DATA);break;case bA:this.kind===dA&&this.emit(Bx.LOADED_META_DATA);break;case yA:this.emit(Bx.LOAD_START)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then(()=>{this._log.warn("replayByRecreateMediaStream success"),jx.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),lL.addSuccessEvent({key:this.kind===lA?506700:516700})}).catch(()=>{var t;this._log.error("replayByRecreateMediaStream failed"),jx.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),lL.addFailedEvent({key:this.kind===lA?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(Bx.ERROR,e)})}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise((t,r)=>{VC(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)}),VC(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)})}async handleTrackEvent(e){let t=e.type;switch(this.options.enableLogTrackState&&this._log[t===fA?"info":"warn"]("track ".concat(t)),t){case mA:this.handleStopped(mA);break;case pA:this.handlePaused(pA);break;case fA:this.mode>0?this.handlePlaying(this.mode.toString()):this.element&&(this.element.paused&&!this.isPausedByUserCall&&(this._log.warn("track unmuted and element is paused, resume"),await this.doResume()),this.element&&!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(fA))}}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}};Mk(Gx,"PlayerEvent",Bx),Pk([function(e){let{settings:t={retries:5,timeout:2e3},onError:r,onRetrying:i,onRetryFailed:n}=e;return function(e,a,o){let s=uD({retryFunction:o.value,settings:t,onError(t){let{error:i,retry:n,reject:o,retryFuncArgs:s}=t;var c;r?r.call(this,i,()=>{var t;null!=(t=zx.get(e))&&t.has(a)?n():o(i)},o,s):null!=(c=zx.get(e))&&c.has(a)?n():o(i)},onRetrying(t,r){var n;sD(i)&&i.call(this,t,r),null!=(n=zx.get(e))&&n.has(a)&&(zx.get(e).get(a).stopRetry=r)},onRetryFailed:n});return o.value=function(){let t=zx.get(e);for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return t?t.set(a,{args:i}):zx.set(e,new Map([[a,{args:i}]])),s.apply(this,i).finally(()=>{var t;return null==(t=zx.get(e))?void 0:t.delete(a)})},o}}({settings:{retries:2,timeout:0},onError(e,t,r,i){i[0]=(i[0]||1e3)+1e3,t()}})],Gx.prototype,"doReplayByRecreateMediaStream",1),Pk([Rx([],"PLAYING",{sync:!0,success(e){this.emit(Bx.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}})],Gx.prototype,"handlePlaying",1),Pk([Rx("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(e){this.emit(Bx.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}})],Gx.prototype,"handlePaused",1),Pk([Rx([],"STOPPED",{sync:!0,success(e){this.emit(Bx.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}})],Gx.prototype,"handleStopped",1);var qx="trtc_autoplay",Kx="".concat(qx,"_mask"),Yx="".concat(qx,"_wrapper"),Xx="".concat(qx,"_header"),Zx="".concat(qx,"_content"),Jx="".concat(qx,"_action_wrapper"),Qx="".concat(qx,"_question"),$x="".concat(qx,"_collapse"),eN="".concat(qx,"_action_confirm"),tN="".concat(qx,"_detail"),rN="#2473E8",iN="dialog",nN="".concat(iN,"-show"),aN="".concat(iN,"-1"),oN="".concat(iN,"-2"),sN=!1,cN=!1,lN=()=>cN,dN="".concat(eA,"/").concat($R()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),uN="<br><a href='".concat(dN,"' target='_blank'>").concat($R()?"其他方案?":"Any other solution?","</a>"),hN="".concat($R()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(uN):"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(uN)),pN=class{constructor(){if(Mk(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),Mk(this,"_dialogNode",null),Mk(this,"_bodyPosition",""),Mk(this,"_showDetail",!1),Mk(this,"_isCollapseClicked",!1),Mk(this,"_isQuestionClicked",!1),$R()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!sN){let e=document.createElement("style");e.innerHTML=".".concat(Kx,"{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(Kx," div:not(.").concat(Jx,"){display:block !important;}.").concat(Yx,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Yx," a{color:").concat(rN,";}.").concat(Xx,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(Zx,"{margin:8px 0;}.").concat(Jx,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat($x,"{margin-right:auto;cursor:pointer}.").concat(Qx,"{height:100%;line-height:16px;cursor:pointer;}.").concat(eN,"{margin-left:8px;color:#fff;background:").concat(rN,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(eN,":hover{opacity:0.9;}.").concat($x,",.").concat(eN,",.").concat(Zx,",.").concat(Qx,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Yx,"{width:80vw;}}"),document.head.appendChild(e),sN=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(Kx,"\"><div class='").concat(Yx,"'><div class='").concat(Xx,"'>").concat(location.host,"</div><div class='").concat(Zx,"'>").concat(this.content,"</div><div class='").concat(tN,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(hN,"</div><div class='").concat(Jx,"'></div></div></div>").trim();let t=document.createElement("button");t.className=eN,t.innerText=$R()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let r=document.createElement("div");r.className=Qx,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=$x,i.innerText="".concat($R()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let n=e.content.firstChild,a=n.querySelector(".".concat(Jx));return a.appendChild(i),a.appendChild(r),a.appendChild(t),n}addDiaLog(){lN()||(cN=!0,this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(Yx)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",ZO.info("show autoplay dialog"),jx.uploadEvent({log:nN}))}deleteDialog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null,cN=!1),fN=null}onConfirm(){ZO.warn("confirm clicked, try resume stream"),qO.emit(KO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDialog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(tN));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||jx.uploadEvent({log:aN}),this._isCollapseClicked=!0}onQuestionClick(){window.open(dN,"_blank"),this._isQuestionClicked||jx.uploadEvent({log:oN}),this._isQuestionClicked=!0}},fN=null;var mN,gN=class extends Gx{constructor(e){super(e,dA),Mk(this,"stat",{}),Mk(this,"_calculateTimeout",-1),Mk(this,"viewMirror",!1),Mk(this,"objectFit","cover"),Mk(this,"container"),Mk(this,"canvas"),Mk(this,"shouldRenderAlpha",!1),Mk(this,"_preSize",{width:0,height:0}),Mk(this,"posterImg"),Mk(this,"pipWindow"),Mk(this,"enterPIPPromise"),Mk(this,"_originContainerPosition"),Mk(this,"_isResettingSrcObject",!1),Mk(this,"_wrapper",null),Mk(this,"_useWrapper",!1),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,aC(e.viewMirror)||(this.viewMirror=e.viewMirror),aC(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(){let e=document.createElement(dA);this.track&&2!==this.mode&&(e.srcObject=new MediaStream([this.track])),e.muted=!0,e.setAttribute("id","video_".concat(this.id)),e.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),e.setAttribute("autoplay","autoplay"),e.setAttribute("playsinline","playsinline"),this.element=e,TD&&(e.poster="data:,"),this._appendToWrapper(),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e=this._useWrapper?"grid-area:1/1;width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";"):"width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";");return this.viewMirror&&(e+="transform:scaleX(-1);"),e}setLiveMode(e){if(this._useWrapper!==e&&(this._useWrapper=e,this.elementToRender&&this.elementToRender.setAttribute("style",this.styleAttribute),this.container&&this.elementToRender))if(e){let e=this._getOrCreateWrapper();e.insertBefore(this.elementToRender,e.firstChild)}else this.container.appendChild(this.elementToRender),this._cleanupWrapper()}setContainer(e){if(this.container===e)return;let t=this._wrapper,r=this.container;this.container=e,this._pausedRetryCount=5,this.track&&this.elementToRender&&this._appendToWrapper(),t&&r&&r!==this.container&&t.isConnected&&0===t.children.length&&t.remove()}_getOrCreateWrapper(){if(!this.container)throw new Error("[VideoPlayer] container is required");let e=this.container.querySelector("[data-trtc-video-wrapper]");return e||(e=document.createElement("div"),e.setAttribute("data-trtc-video-wrapper","true"),e.style.cssText="display:grid;width:100%;height:100%;",this.container.appendChild(e)),this._wrapper=e,e}_appendToWrapper(e){let t=null!=e?e:this.elementToRender;if(this.container&&t)if(this._useWrapper){let e=this._getOrCreateWrapper();e.insertBefore(t,e.firstChild)}else this.container.appendChild(t)}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),this.handleFullscreenChange=this.handleFullscreenChange.bind(this),this.handleVolumeChange=this.handleVolumeChange.bind(this),e&&e.add(TA,this.handleElementEvent).add(SA,this.handleElementEvent).add(AA,this.handleElementEvent),this.element&&(this.element.addEventListener(kA,this.handleFullscreenChange),this.element.addEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.addEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.addEventListener("volumechange",this.handleVolumeChange))}handleTrackEvent(e){var t;return e.type===pA&&(null!=(t=this.stat)&&t.fps&&(this.stat.fps=0),this.isFullscreen()&&this.resetSrcObjectToReplay()),super.handleTrackEvent(e)}handleFullscreenChange(){this.isFullscreen()?(this._log.info("enter fullscreen"),this.emit(Bx.ENTER_FULL_SCREEN)):(this._log.info("leave fullscreen"),this.emit(Bx.LEAVE_FULL_SCREEN))}handleVolumeChange(){var e;(this.isPictureInPicture()||this.isFullscreen())&&this.emit(Bx.VOLUME_CHANGE,{muted:null==(e=this.element)?void 0:e.muted})}handleElementEvent(e){var t,r,i,n,a,o;if(2===this.mode)return;super.handleElementEvent(e);let s=e.type,c=this.isPictureInPicture(),l=this.isFullscreen(),d=e.isTrusted&&(c&&RO||l);if(s===gA&&d&&!this._isResettingSrcObject&&(this._log.warn("user resume in ".concat(l?"fullscreen":"pip")),this.emit(Bx.USER_RESUME_IN_PIP_OR_FULL_SCREEN)),s===_A&&(d&&(this._log.warn("user pause in ".concat(l?"fullscreen":"pip")),this.emit(Bx.USER_PAUSE_IN_PIP_OR_FULL_SCREEN)),this.container&&!this.container.isConnected&&(this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(this.container.id)),VC(500).then(()=>{var e;null!=(e=this.container)&&e.isConnected&&(this._pausedRetryCount=5,this._log.info("view container ".concat(this.container.id," is in dom, reset pausedRetryCount")))})),this._pausedRetryCount>0&&!lN()&&!this.isPausedByUserCall&&!d&&(this._log.info("[".concat(5-this._pausedRetryCount+1,"/").concat(5,"] ").concat(this.kind," player auto resume when paused")),this.doResume(),this._pausedRetryCount--),wD&&!d&&(this._interval=Ux.run("timeout",()=>{this.element&&"PAUSED"===this._state&&!this.isPausedByUserCall&&this.doResume()},{delay:3e3})),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;s===TA?this.element.style.transform=e.replace("scaleX(-1)",""):s===SA&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}s===AA&&(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==(n=this.element)?void 0:n.videoHeight)),this._preSize.height=(null==(a=this.element)?void 0:a.videoHeight)||0,this._preSize.width=(null==(o=this.element)?void 0:o.videoWidth)||0,this.emit(Bx.RESIZE,{newWidth:this._preSize.width,newHeight:this._preSize.height})),s===SA&&(this._log.warn("exit pip"),this.isPaused&&!this.isPausedByUserCall&&(this._log.warn("resume after exit pip"),this.doResume()),this.resetSrcObjectToReplay(),this.emit(Bx.LEAVE_PICTURE_IN_PICTURE)),s===TA&&this.emit(Bx.ENTER_PICTURE_IN_PICTURE)}resetSrcObjectToReplay(){TD&&SO&&this.isPlayCalled&&this.element&&this.track&&!this.isPausedByUserCall&&(this._log.warn("reset srcObject to replay for android chromium"),this._isResettingSrcObject=!0,this.element.srcObject=new MediaStream([this.track]),this.element.play().catch(e=>{this._log.warn("play failed after reset srcObject",e)}).finally(()=>{this._isResettingSrcObject=!1}))}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var r,i;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(),this._appendToWrapper(e)):this.element&&this._appendToWrapper(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||(this._log.info("setPoster",e.slice(0,10)),""===e?this.element.removeAttribute("poster"):this.element.poster=e,!t||!RO&&!kD))return r();if(""===e)return this.removePosterImg(),r();if(this.posterImg)return r();let i=document.createElement("img");i.src=e;let n=window.getComputedStyle(this.element),a=n.objectFit||this.objectFit,o=1;if(this._useWrapper){let e=parseInt(n.zIndex,10);isNaN(e)||(o=e+1)}i.style.cssText=this._useWrapper?"grid-area:1/1;z-index:".concat(o,";width:100%;height:100%;object-fit:").concat(a,";"):"position:absolute;top:0;left:0;width:100%;height:100%;object-fit:".concat(a,";"),i.onload=async()=>{try{i.decode&&await i.decode(),this.container&&!this._useWrapper&&"static"===window.getComputedStyle(this.container).position&&(this._originContainerPosition=this.container.style.position,this.container.style.position="relative"),this.posterImg=i;let e=this._useWrapper?this._wrapper:this.container;null==e||e.appendChild(i),ID()&&NO<=17&&this.elementToRender&&(this.elementToRender.style.visibility="hidden")}catch(e){this._log.warn("decode poster image error",e)}return r()},i.onerror=()=>(this._log.warn("load poster image error"),r())})}removePosterImg(){this.posterImg&&(ID()&&NO<=17&&this.elementToRender&&(this.elementToRender.style.visibility=""),this.posterImg.remove(),URL.revokeObjectURL(this.posterImg.src),!this._useWrapper&&this.container&&!aC(this._originContainerPosition)&&"relative"===this.container.style.position&&(this.container.style.position=this._originContainerPosition),delete this.posterImg)}get hasPoster(){var e;return!!this.posterImg||!(null==(e=this.element)||!e.getAttribute("poster"))}async pause(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];super.pause(),!this.isPictureInPicture()&&!this.hasPoster&&(SO||e&&(kD||RO))&&await this.setPoster(this.getVideoFrame(),!0)}resume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return super.resume(e).then(()=>{var e;(this.posterImg||null!=(e=this.element)&&e.poster)&&this.setPoster("",!0)})}doResume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPaused&&e&&this.element&&this.track&&SO&&"video"===this.track.kind&&(this.element.srcObject=new MediaStream([this.track])),super.doResume()}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this.isPictureInPicture()&&this.exitPictureInPicture().catch(e=>{}),this.isFullscreen()&&this.exitFullscreen().catch(e=>{}),this.element&&(this.element.removeEventListener(kA,this.handleFullscreenChange),this.element.removeEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.removeEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.removeEventListener("volumechange",this.handleVolumeChange)),super.stop(e),null==(t=this.canvas)||t.remove(),this.removePosterImg(),this._useWrapper&&this._cleanupWrapper()}_cleanupWrapper(){this._wrapper&&0===this._wrapper.children.length&&this._wrapper.remove(),this._wrapper=null}play(e){if(aC(null==e?void 0:e.isLiveStream)||this.setLiveMode(e.isLiveStream),this.element){if(this.elementToRender&&this.container)if(this._useWrapper){let e=this._getOrCreateWrapper();this.elementToRender.parentElement!==e&&e.insertBefore(this.elementToRender,e.firstChild)}else this.elementToRender.parentElement!==this.container&&this.container.append(this.elementToRender)}else this.initializeElement();return 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(Bx.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this._appendToWrapper()))}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(dx()&&this.element&&this._calculateTimeout<0){let e=0,t=null,r=(i,n)=>{this.stat.width=n.width,this.stat.height=n.height,t&&(this.stat.fps=Math.round((n.presentedFrames-t.presentedFrames)/(i-e)*1e3)),e=i,t=n,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(zP){this._log.warn("init stat failed",zP)}}async enterFullscreen(){let e=this.elementToRender;if(!e)throw this._log.warn("no element to render, cannot enter fullscreen"),new Error("No element available for fullscreen");if(wD&&this.isPictureInPicture()){this._log.info("exit pip before entering fullscreen");try{await this.exitPictureInPicture()}catch(Yk){this._log.warn("exit pip failed before fullscreen:",Yk)}}try{if(e.requestFullscreen)await e.requestFullscreen();else if(e.webkitRequestFullscreen)await e.webkitRequestFullscreen();else if(e.webkitEnterFullscreen)await e.webkitEnterFullscreen();else if(e.mozRequestFullScreen)await e.mozRequestFullScreen();else{if(!e.msRequestFullscreen)throw new Error("Fullscreen API not supported");await e.msRequestFullscreen()}this._log.info("entered fullscreen mode")}catch(Yk){throw this._log.error("failed to enter fullscreen:",Yk),Yk}}async exitFullscreen(){try{if(!this.isFullscreen())return;if(document.exitFullscreen)await document.exitFullscreen();else if(document.webkitExitFullscreen)await document.webkitExitFullscreen();else if(document.mozCancelFullScreen)await document.mozCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Exit fullscreen API not supported");await document.msExitFullscreen()}this._log.info("exited fullscreen mode")}catch(zP){throw this._log.error("failed to exit fullscreen:",zP),zP}}isFullscreen(){let e=this.elementToRender;return!!e&&(this.element&&this.element.webkitDisplayingFullscreen?!this.isPictureInPicture():(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)===e)}async toggleFullscreen(){this.isFullscreen()?await this.exitFullscreen():await this.enterFullscreen()}async enterPictureInPicture(){this.enterPIPPromise=this._enterPictureInPicture();try{return await this.enterPIPPromise}finally{delete this.enterPIPPromise}}async _enterPictureInPicture(){try{if(!this.element)throw new Error("No video element available for pip");if(this.canvas&&1!==this.mode)throw new Error("pip is not supported for canvas-only mode");let{element:e}=this;if(e.requestPictureInPicture){this._log.info("requestPictureInPicture");let t=await e.requestPictureInPicture();return this.pipWindow=t,this._log.info("entered pip mode"),this.elementToRender===this.canvas&&(this.canvas.remove(),this._appendToWrapper(this.element)),t}if(e.webkitSetPresentationMode)return this._log.info("webkitSetPresentationMode"),await e.webkitSetPresentationMode("picture-in-picture"),this._log.info("entered pip mode (webkit)"),{};throw new Error("pip API not supported")}catch(zP){throw this._log.error("failed to enter pip:",zP.name,zP.message),zP}}async exitPictureInPicture(){var e;try{if(!this.isPictureInPicture())return;if(delete this.pipWindow,document.pictureInPictureElement&&document.exitPictureInPicture)await document.exitPictureInPicture(),this.elementToRender===this.canvas&&(null==(e=this.element)||e.remove(),this._pausedRetryCount=5,this._appendToWrapper(this.canvas)),this._log.info("exited pip mode");else{if(!this.element||!this.element.webkitSetPresentationMode)throw new Error("Exit pip API not supported or not in PiP mode");await this.element.webkitSetPresentationMode("inline"),this._log.info("exited pip mode (webkit)")}}catch(Yk){throw this._log.error("failed to exit pip:",Yk),Yk}}isPictureInPicture(){if(!this.element)return!1;let{element:e}=this;return document.pictureInPictureElement?document.pictureInPictureElement===e:!!e.webkitPresentationMode&&"picture-in-picture"===e.webkitPresentationMode}async togglePictureInPicture(){this.isPictureInPicture()?await this.exitPictureInPicture():await this.enterPictureInPicture()}};"undefined"!=typeof AudioContext?mN=AudioContext:"undefined"!=typeof webkitAudioContext?mN=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(mN=mozAudioContext);var _N,vN=-1,yN=0,EN=-1,bN=!1,wN=0,IN=-1,TN=-1;!function e(){try{if(_N)return;(_N=new mN({sampleRate:48e3})).onstatechange=()=>{ZO.info("context state: ".concat(_N.state).concat("running"!==_N.state?" visibilityState: ".concat(document.visibilityState):"")),SN()},clearTimeout(vN)}catch(gk){ZO.error("initAudioContext failed: ".concat(gk," typeof AudioContextClass: ").concat(typeof mN)),vN=setTimeout(e,1e3)}}();var SN=()=>{"suspended"===_N.state?(yN=yC(),-1===EN&&(EN=setTimeout(()=>{"suspended"===_N.state&&(bN=!0,qO.emit("155",{isSuspended:!0}))},1500)),RN(),document.addEventListener("click",SN)):"interrupted"===_N.state?RN():(yN&&(lL.addNumber({key:507800,value:yC()-yN,split:[0,500,1e3,1500,2e3,3e3,4e3,5e3,1e4,3e4],max:6e4}),yN=0),-1!==EN&&(clearTimeout(EN),EN=-1,bN&&(bN=!1,qO.emit("155",{isSuspended:!1}))),document.removeEventListener("visibilitychange",SN),document.removeEventListener("click",SN))},kN=0,AN=-1;function RN(){return new Promise((e,t)=>{if("running"===_N.state)return e();Date.now()-kN<1e3?(clearTimeout(AN),AN=setTimeout(()=>{kN=Date.now(),_N.resume().then(e,t).finally(()=>{CN()})},1e3)):(clearTimeout(AN),kN=Date.now(),_N.resume().then(e,t).finally(()=>{CN()}))}).catch(e=>{ZO.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",SN)})}function CN(){if(!wD||-1!==TN)return;let e=()=>{yC()-wN<500||(_N&&"running"===_N.state&&_N.currentTime===IN&&(ZO.warn("context is fake running, auto resume"),_N.suspend().catch(e=>{ZO.warn("context suspend failed: ".concat(e))})),IN=_N.currentTime,wN=yC())};TN=setInterval(()=>{e()},2e3),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&e()})}document.addEventListener("click",SN);var DN=e=>_N,ON=class{constructor(e){this.name=e,Mk(this,"node"),Mk(this,"node2"),Mk(this,"pre",new Set),Mk(this,"next",new Set),Mk(this,"context"),Mk(this,"connectedNodes",new Set),Mk(this,"nextInputChannelMap",new Map),Mk(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(Yk){ZO.error(Yk)}}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(),lL.addSuccessEvent({key:502701})}catch(i){ZO.error(i),lL.addFailedEvent({key:502701,error:i})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),lL.addSuccessEvent({key:502702})}catch(zP){ZO.error(zP),lL.addFailedEvent({key:502702,error:zP})}}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}},LN=class extends ON{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,Mk(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 n=0;n<e.length;n++)r=e[n]/128*100/2,i+="L".concat(t,",").concat(r),t+=1;return i}},xN=class{constructor(){Mk(this,"source",new ON),Mk(this,"gain",new ON),Mk(this,"destination",new ON)}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(DN().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){let t=function(t){try{let e=NN.get(t);if(e)return e;let r=DN();if(t instanceof HTMLAudioElement)e=r.createMediaElementSource(t);else{if(!(t instanceof MediaStreamTrack))return t;e=r.createMediaStreamSource(new MediaStream([t]))}return NN.set(t,e),e}catch(e){if(!(kD&&e instanceof Error&&"NotSupportedError"===e.name))throw e;ZO.warn(e)}}(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}},NN=new WeakMap;var PN=class e{constructor(e){Mk(this,"_volume",0),Mk(this,"_volumeDb",0),Mk(this,"_log"),Mk(this,"_scriptProcessorNode",null),Mk(this,"_audioWorkletNode",null),Mk(this,"_interval",200);let{log:t}=e;this._log=t,qO.on(KO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(aO&&AO<=22)return this._log.warn("use script processor to avoid memory leak in electron22-"),this.initScriptProcessor();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);',r=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));e.workletReady=async function(e,t){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{await e.audioWorklet.addModule(t),ZO.info("worklet addModule success")}catch(r){throw ZO.info("worklet addModule catch error. ".concat(r.message)),r}}(e.audioContext,r).finally(()=>{URL.revokeObjectURL(r)})}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(t){this._log.error("volumeMeter init audio worklet error: ".concat(t)),jx.logFailedEvent({userId:this._log.userId,eventType:CA,error:t}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{let t=DN();this._scriptProcessorNode=t.createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let r=t.inputBuffer.getChannelData(0),i=0,n=0;for(let e=0;e<r.length;++e)i=Math.max(Math.abs(r[e]),i),n+=r[e]*r[e];this._volume=i;let a=n/r.length;this._volumeDb=Math.max(10*Math.log10(a)+100,0)/100},this._scriptProcessorNode.connect(t.destination)}catch(t){this._log.error("volumeMeter init script processor error: ".concat(t))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null,this._scriptProcessorNode.disconnect()),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null,this._audioWorkletNode.port.close(),this._audioWorkletNode.disconnect()),this._audioWorkletNode=null,this._scriptProcessorNode=null,qO.off(KO.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})}};Mk(PN,"lastMessageTime",0),Mk(PN,"audioContext",DN()),Mk(PN,"workletReady");var MN=PN,UN=class extends ON{constructor(e){super(),Mk(this,"_volumeMeter"),this._volumeMeter=new MN(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}async init(){await 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()}}},BN=Nk(Bk(),1),FN=e=>t=>t.deviceId===e,VN=class{constructor(e,t){Mk(this,"kind"),Mk(this,"type"),Mk(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&&jN(this.devices[0])||t&&(r.forEach(e=>{if(e.deviceId&&!this.devices.find(FN(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(FN(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)}},WN=class extends BN.EventEmitter{constructor(){super(),Mk(this,"audioInputs",new VN(lA,"Input")),Mk(this,"videoInputs",new VN(dA,"Input")),Mk(this,"audioOutputs",new VN(lA,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",()=>this.update()),"ondevicechange"in navigator.mediaDevices||Ux.run("interval",()=>{this.update()},{delay:1e4}))}init(){zN().then(e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)})}async update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=await zN(e);return this.audioInputs.update(t,this),this.videoInputs.update(t,this),this.audioOutputs.update(t,this),this}hasBlueTooth(){var e;if(1e3*(null==(e=DN())?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)))}},HN=$k||Qk?null:new WN;function jN(e){return e.deviceId===e.groupId&&""===e.groupId}async function zN(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(_L()||!mL())return[];let t=await navigator.mediaDevices.enumerateDevices();if(0!==e){let i={audio:!1,video:!1};if(t.forEach(e=>{jN(e)&&(e.kind===wA?i.audio=!0:e.kind===IA&&(i.video=!0))}),2===e&&(i.audio=!1),1===e&&(i.video=!1),i.audio||i.video){let e;try{e=await navigator.mediaDevices.getUserMedia(i),i.audio&&RN()}catch(r){ZO.debug("capture before getDevices failed: ",r)}t=await 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&&XN.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(r.getCapabilities=()=>e.getCapabilities()),r})}function GN(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return HN.update(e?1:0).then(e=>e.audioInputs.devices)}function qN(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return HN.update(e?2:0).then(e=>e.videoInputs.devices)}var KN=!1;async function YN(){try{KN||(KN=!0,ZO.info("speakers:".concat((await async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(wD||RO)&&(e=!1),HN.update(e?1:0).then(e=>e.audioOutputs.devices)}()).map(e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)))))}catch(gk){}}var XN=new Set;async function ZN(e){let{newDeviceId:t,oldDeviceId:r,oldGroupId:i,oldLabel:n,kind:a}=e;return t===r&&(a!==lA||t!==OA||await async function(e,t){let r=(await GN()).find(e=>e.deviceId===OA);return!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t}(i,n))}var JN,QN=class extends xN{constructor(e){super(),this.log=e,Mk(this,"volumeMeter"),Mk(this,"volumeMeterAfter3A"),Mk(this,"volumeDestination"),Mk(this,"analyser",new LN),this.volumeMeter=new UN({log:this.log}),this.volumeMeterAfter3A=new UN({log:this.log}),this.volumeDestination=new ON,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},$N=class extends Gx{constructor(e){super(e,lA),Mk(this,"_outputDeviceId"),Mk(this,"_floatVolume",1),Mk(this,"_destination"),Mk(this,"pipeline"),Mk(this,"volumeMeterMode","worklet"),Mk(this,"enableVolumeControlInIOS"),this.enableVolumeControlInIOS=e.enableVolumeControlInIOS,this.mode=0,e.url&&(this.url=e.url),this.pipeline=new QN(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"===LO||"15.3"===LO||"15.4"===LO)&&this.muted)return void this._log.info("audioElement is muted.");let t=JN||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,this.setVolume(sC(e)?e/100:this._floatVolume),t===JN&&(JN=void 0),this.options.enableTimeupdateEvent&&(this.element.ontimeupdate=()=>this.emit(Bx.TIME_UPDATE,this.currentTime)),this.bindElementEvents(),this._log.info("initializeElement")}async play(e){if(this.track||this.url){try{!this.pipeline.source.node&&this.track&&this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),this._outputDeviceId&&await this.setSinkId(this._outputDeviceId),"worklet"===this.volumeMeterMode?(this.pipeline.volumeMeter.init(),this.pipeline.volumeMeterAfter3A.init()):"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(DN().createAnalyser()),YN()}catch(Yk){throw this._log.warn("audio play error: ".concat(Yk)),xO(LO,"18.7",!0)&&this.bindAutoPlayEvent(),Yk}return super.play()}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setVolume(e){this._floatVolume=e,this.element&&(this.element.volume=e)}async setSinkId(e){var t,r;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&await(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()}},eP=class extends $N{constructor(e){super(e),Mk(this,"_sourceElement"),Mk(this,"_output",new ON),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(DN().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(Bx.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){var t;let r=e<=1&&!ID();if(this._floatVolume!==e||!(r&&(null==(t=this.element)?void 0:t.volume)===e||!r&&this.pipeline.volume===e))if(this._floatVolume=e,this.useDestination)this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e));else if(r)this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element");else{if(ID()){if(!this.enableVolumeControlInIOS)return;CN()}if(kD&&!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._destination||(this._destination=DN().createMediaStreamDestination()),this.pipeline.destination.setNode(this._destination),Hx(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play().catch(e=>{this.emit(Bx.AUTOPLAY_FAILED,e)}))}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&CO&&(JN=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},tP=class extends Ox{constructor(e){let{userId:t,sdkAppId:r,mediaType:i,room:n,PlayerClass:a=(1===i?eP:gN)}=e;var o;super(),Mk(this,"id",JO()),Mk(this,"userId",""),Mk(this,"isRemote"),Mk(this,"mediaType"),Mk(this,"room"),Mk(this,"user"),Mk(this,"_log"),Mk(this,"_inputTrack"),Mk(this,"_outputTrack"),Mk(this,"isPlayCalled"),Mk(this,"container",null),Mk(this,"player"),Mk(this,"subVideoPlayerMap"),Mk(this,"muted",!1),Mk(this,"abortCtrl"),Mk(this,"objectFit","cover"),Mk(this,"mirror"),Mk(this,"rotation"),Mk(this,"isScreen",!1),Mk(this,"manager"),Mk(this,"trackSettings"),Mk(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=i,this._log=ZO.createLogger({parent:null==n?void 0:n.getLogger(),id:"".concat(this.kind[0],"t"),userId:null==(o=n||this.room)?void 0:o.userId,remoteUserId:this instanceof XP?void 0:this.userId,sdkAppId:r,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof XP}),this.player=new a({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log,enableVolumeControlInIOS:null==n?void 0:n.enableVolumeControlInIOS}),this.player.on(Bx.PLAYER_STATE_CHANGED,e=>{if(qO.emit(KO.PLAYER_STATE_CHANGED,Ck({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&&lN()&&fN&&fN.deleteDialog()}}),this.kind===dA&&(this.player.on(Bx.LOADED_DATA,()=>{this.emitFirstVideoFrameEvent(Bx.LOADED_DATA),qO.emit(KO.VIDEO_LOADED_DATA,{track:this})}),this.player.on(Bx.LOADED_META_DATA,()=>{this.emitFirstVideoFrameEvent(Bx.LOADED_META_DATA)}),this.player.on(Bx.MEDIA_TRACK_CHANGED,e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach(t=>t.setTrack(e))}),this.player.on(Bx.RESIZE,e=>{this.emitFirstVideoFrameEvent(Bx.RESIZE),this.emit("video-size-changed",Ck({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(Bx.ERROR,this.onPlayerError.bind(this)),this.player.on(Bx.AUTOPLAY_FAILED,this.handleAutoPlayFailed,this)}get log(){return this._log||ZO}get kind(){return 1===this.mediaType?lA:dA}get isAudio(){return this.kind===lA}get strMediaType(){return 4===this.mediaType?dA:2===this.mediaType?uA:lA}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}async play(e,t){let r=dC(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!aC(t.muted)&&this.setPlayerMute(t.muted),t&&!aC(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof gN&&(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(dC(e)&&e.length>=1&&this.container&&e.includes(this.container)&&this.container.contains(this.player.elementToRender)?(e.splice(e.indexOf(this.container),1),e.unshift(this.container)):(this.container=r,this.player.setContainer(r))),dC(e)&&e.length>=1&&await this.playSubContainer(e.slice(1),t)));if(t&&!aC(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===dA)&&this.setPlayerMute(!0),t&&!aC(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof gN&&(aC(null==t?void 0:t.isLiveStream)||this.player.setLiveMode(t.isLiveStream),this.player.setObjectFit(this.objectFit),t&&!aC(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof gN&&this.player.setContainer(r)),qO.emit(KO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),await this.player.play(t),dC(e)&&e.length>1&&await this.playSubContainer(e.slice(1),t)}catch(i){throw this.handleAutoPlayFailed(i),i}}else this.log.info("play has not mediaTrack, abort")}setMirror(e,t){if(this.isScreen||this.kind!==dA||aC(e)||e===this.mirror)return;this.mirror=e;let r=this.player;t&&(r=t);let i=this.manager;if(cC(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)}}async playSubContainer(e,t){if(!this._outputTrack||this.kind===lA)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,n]of e.entries()){let e=this.subVideoPlayerMap.get(n);e?t&&(aC(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(n,new gN({id:this.userId||this.id,track:this.playerMediaTrack,container:n,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let r=[...this.subVideoPlayerMap.values()];for(let i of r)i.setViewMirror(this.player.mirror),await i.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(lD(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach(e=>{e.stop()}),this.container=null)}async resume(){var e;this.isPlayCalled&&await(null==(e=this.player)?void 0:e.resume())}close(){this._toInitState(),this.log.info("close"),this.isPlayCalled&&this.stop(!0)}_toInitState(){}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),qO.emit(e?KO.TRACK_MUTED:KO.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){Wx(e,e).add(pA,this.onTrackMuted).add(fA,this.onTrackUnmuted).add(mA,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===mA&&this.onTrackEnded()}uninstallTrackEvent(e){Hx(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){var t,r;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){if(lD(this)&&this.isAudio&&null!=(t=this.user)&&t.muteState.hasAudio&&null!=(r=this.user)&&r.muteState.audioMuted)return;return this.player.stop(lD(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))}async handleAutoPlayFailed(e){var t;this.log.warn("handleAutoPlayFailed",e);let r=()=>{this.resume().then(()=>{document.removeEventListener("click",r,!0)})};if(this.room&&this.room.enableAutoPlayDialog){if((VD||jD)&&(await VC(100),null!=(t=this.player)&&t.isPlaying))return;fN||(fN=new pN)}else document.addEventListener("click",r,!0);qO.once(KO.LOCAL_TRACK_CAPTURE_SUCCESS,e=>{let{track:t}=e;"audio"===t.kind&&lN()&&!this.player.isPlaying&&this.isRemote&&this.isAvailable&&r()}),this.emit("error",e)}getVideoFrame(){return this.player instanceof gN?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,r,i;if(this.isFirstVideoFrameEmitted)return;let n=null==(t=this.mediaTrack)?void 0:t.getSettings(),a=(null==n?void 0:n.width)||(null==(r=this.player.element)?void 0:r.videoWidth)||0,o=(null==n?void 0:n.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;e===Bx.RESIZE&&!a&&!o||e===Bx.LOADED_META_DATA&&!a&&!o||(e===Bx.LOADED_DATA&&!a&&!o&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,GC(this.rotation)&&([a,o]=[o,a]),this.emit("first-video-frame",{width:a,height:o,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"))}};Pk([Rx([],Ox.INIT,{sync:!0})],tP.prototype,"_toInitState",1);var rP=Object.prototype.hasOwnProperty;var iP=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(eC(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(rP.call(e,t))return!1;return!0}return!1},nP=uD({retryFunction:async function(e){let t=function(e){return{audio:oP(e),video:sP(e)}}(e);ZO.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],i=[],n=["label","deviceId","groupId"];if(t.audio&&(r=await GN(),ZO.info("microphones: ".concat(xC(r.map(e=>Dk(Ck({},e),{groupId:e.groupId.substring(0,8)})),{keysToInclude:n})))),t.video&&(i=await qN(),ZO.info("cameras: ".concat(xC(i,{keysToInclude:n}))),!cC(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=await navigator.mediaDevices.getUserMedia(t);return ZL&&r.getTracks().forEach(t=>{var r;let i=t.getCapabilities();ZO.info("".concat(t.kind," capabilities: ").concat(xC(i,{keysToInclude:xA}))),!aC(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&&RN(),r}catch(a){let{message:t}=a;throw"NotFoundError"===a.name&&(e.video&&i&&0===i.length&&(t=iL({key:$O.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(t=iL({key:$O.MICROPHONE_NOT_FOUND}))),new pR({code:uR.INITIALIZE_FAILED,name:a.name,message:t,constraint:a.constraint})}},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:r,reject:i,retryFuncArgs:n,retriedCount:a}=e,o=a+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name||"AbortError"===t.name?(1===o?(n[0].video&&(n[0].maxResolution=!1,(!RO||n[0].width*n[0].height<=2073600)&&n[0].frameRate&&(n[0].frameRate=n[0].frameRate>10?10:5)),n[0].retryWhenExactFailed&&n[0].useExactDeviceId&&(n[0].useExactDeviceId=!1)):2===o?n[0].useDeviceIdOnly=!0:3===o&&!n[0].useExactDeviceId&&(n[0].useTrueAsConstraint=!0),r()):i(t),n[0].microphoneId&&aP(n[0].microphoneId,!1),n[0].cameraId&&aP(n[0].cameraId,!0)},onRetrying:e=>{ZO.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{jx.logFailedEvent({eventType:DA,error:e})},onRetrySuccess:e=>{jx.logSuccessEvent({eventType:DA}),jx.uploadEvent({log:"stat-".concat(DA,"-success-").concat(e)})}});async function aP(e,t){let r=(t?await qN():await GN()).find(t=>t.deviceId===e);r&&nC(r.getCapabilities)&&ZO.warn(xC(r.getCapabilities(),{keysToInclude:xA}))}function oP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!iP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(sC(e.channelCount)&&(t.channelCount=e.channelCount),(cC(e.echoCancellation)||"remote-only"===e.echoCancellation||"all"===e.echoCancellation)&&(t.echoCancellation=e.echoCancellation),cC(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),cC(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!iP(t)||t)}function sP(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&&!iP(r)?r:(e.width&&(r.width={ideal:e.width},t&&!kD&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},t&&!kD&&(r.height.max=e.height)),kD&&tO&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!iP(r)||r)}var cP=nP,lP=(()=>{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)}})(),dP=0,uP=class{constructor(e){Mk(this,"log"),Mk(this,"isRunning",!1),Mk(this,"queue",[]);let t="fq".concat(++dP);e&&(t+="|".concat(e)),this.log=ZO.createLogger({id:t})}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 n=Ck({},e),a=new Promise((e,t)=>{n.resolve=e,n.reject=t});return n.promise=a,t?this.length<=1?this.queue.push(n):null==(i=null==(r=this.lastQueueItem)?void 0:r.promise)||i.then(n.resolve,n.reject):this.queue.push(n),this.log.debug("push ".concat(this.length),e.funcName,e.args),this.isRunning||this.callNext(),a}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length),null==e?void 0:e.funcName,null==e?void 0:e.args),e}callNext(){if(this.isRunning||0===this.length)return;let{fn:e,args:t,context:r,resolve:i,reject:n,funcName:a}=this.queue[0];this.log.debug("callNext",this.length,a,t),this.isRunning=!0,e.apply(r,t).then(i,n).finally(()=>{this.isRunning=!1,this.shift(),this.callNext()})}},hP=new WeakMap;function pP(e,t){return Gk((r,i)=>function(){let i=e;try{for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];let e=r.apply(this,a),s=yC();return pC(e)?e.then(e=>(t?lL.addSuccessEvent({key:i,cost:yC()-s}):lL.addSuccessEvent({key:i}),e)).catch(e=>{throw lL.addFailedEvent({key:i,error:e}),e}):(lL.addSuccessEvent({key:i}),e)}catch(Xk){throw lL.addFailedEvent({key:i,error:Xk}),Xk}})}function fP(){}var mP=e=>e();function gP(){this.dispose()}var _P=1,vP=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new kP(e,this,this.streamId++);return AP.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},yP=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=fP,this.error=fP,this.next=fP,this.dispose=fP,this.subscribe=fP,this.doDefer()}subscribe(e){return e instanceof vP?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(mP),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}},EP=class extends yP{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)}},bP=class extends yP{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:fP,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:fP,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:fP;if(super(),this._next=t,this._error=r,this._complete=i,this.then=fP,e instanceof vP){let n={toString:()=>"subscribe",id:0,source:e};this.defer(()=>{AP.defer(n,0)}),AP.create(n),AP.pipe(n),this.sourceId=n.id,this.subscribe(e),AP.subscribe({id:n.id,end:!0}),t==fP?this._next=e=>AP.next(n,0,e):this.next=e=>{AP.next(n,0,e),t(e)},i==fP?this._complete=()=>AP.complete(n,0):this.complete=()=>{this.dispose(),AP.complete(n,0),i()},r==fP?this._error=e=>AP.complete(n,0,e):this.error=e=>{this.dispose(),AP.complete(n,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 wP(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 IP(e,t,r){if("undefined"!=typeof __FASTRX_DEVTOOLS__){let i=Object.defineProperties(Object.setPrototypeOf(e,vP.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}});AP.create(i);for(let e=0;e<r.length;e++){let t=r[e];"function"==typeof t&&t instanceof vP&&AP.addSource(i,t)}return i}return e}function TP(e,t){return function(){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return r=>{if(r instanceof vP){let n=IP(t=>{let a=new e(t,...i);a.sourceId=n.id,a.subscribe(r)},t,arguments);return n.source=r,AP.pipe(n),n}return t=>r(new e(t,...i))}}}function SP(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var kP=class extends EP{constructor(e,t,r){super(e),this.source=t,this.id=r,this.sourceId=e.sourceId,this.defer(()=>{AP.defer(this.source,this.id)})}next(e){AP.next(this.source,this.id,e),this.sink.next(e)}complete(){AP.complete(this.source,this.id),this.sink.complete()}error(e){AP.complete(this.source,this.id,e),this.sink.error(e)}},AP={addSource(e,t){SP("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,r){SP("next",{id:e.id,streamId:t,data:r&&r.toString()})},subscribe(e,t){let{id:r,end:i}=e;SP("subscribe",{id:r,end:i,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,r){SP("complete",{id:e.id,streamId:t,err:r?r.toString():null})},defer(e,t){SP("defer",{id:e.id,streamId:t})},pipe(e){SP("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){SP("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=_P++),SP("create",{name:e.toString(),id:e.id})}},RP=class extends yP{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 CP(){return e=>{let t=new RP(e);if(e instanceof vP){let r=IP(e=>{t.add(e)},"share",arguments);return t.sourceId=r.id,r.source=e,AP.pipe(r),r}return IP(t.add.bind(t),"share",arguments)}}function DP(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return IP(e=>{let r=new EP(e),i=t.length;r.complete=()=>{0===--i&&e.complete()},t.forEach(r.bindSubscribe)},"merge",arguments)}function OP(e){let t=arguments,r=CP()(IP(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=fP,r.complete=fP,r.error=fP,r}function LP(e,t){return r=>{let i=e=>r.next(e);r.defer(()=>t(i)),e(i)}}function xP(e,t){if("on"in e&&"off"in e)return IP(LP(r=>e.on(t,r),r=>e.off(t,r)),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return IP(LP(r=>e.addListener(t,r),r=>e.removeListener(t,r)),"fromEvent",arguments);if("addEventListener"in e)return IP(LP(r=>e.addEventListener(t,r),r=>e.removeEventListener(t,r)),"fromEvent",arguments);throw"target is not a EventDispachter"}var NP=TP(class extends EP{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"),PP=TP(class extends EP{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0===--this.count&&(this.doDefer(),this.complete())}},"take"),MP=TP(class extends EP{constructor(e,t){super(e);let r=new EP(e);r.next=()=>{r.doDefer(),e.complete()},r.complete=gP,r.subscribe(t)}},"takeUntil"),UP=TP(class extends EP{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),BP=TP(class extends EP{constructor(e,t,r){super(e),this.mapper=t,this.thisArg=r}next(e){super.next(this.mapper.call(this.thisArg,e))}},"map"),FP=class extends EP{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()}},VP=class e extends EP{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()}},WP=class extends FP{},HP=class extends VP{next(e){this.subInner(e,WP),this.next=e=>{this.currentSink.dispose(),this.subInner(e,WP)}}},jP=TP(HP,"switchMap");var zP,GP=function(e){return(t,r)=>e(()=>t,r)}(TP(HP,"switchMapTo")),qP=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:fP,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:fP,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:fP;return i=>new bP(i,e,t,r)},KP=TP(class extends EP{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"),YP=((zP=YP||{})[zP.AUTO_SWITCH_NEW_DEVICE=0]="AUTO_SWITCH_NEW_DEVICE",zP[zP.WAIT_CURRENT_DEVICE=1]="WAIT_CURRENT_DEVICE",zP),XP=class extends tP{constructor(e,t,r){super({mediaType:e,PlayerClass:t,room:r}),Mk(this,"isRemote",!1),Mk(this,"deviceId"),Mk(this,"groupId",""),Mk(this,"label",""),Mk(this,"sourceTrack"),Mk(this,"enableAutoSwitchWhenRecapturing",!0),Mk(this,"_isRecapturing",!1),Mk(this,"_lastRecaptureTime",0),Mk(this,"_onMuteTimeoutId",-1),Mk(this,"_encodeCheckTimeoutId",-1),Mk(this,"recaptureMode",0),Mk(this,"profile"),Mk(this,"retryEncodeFailed")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}get isUseCustomSource(){return!(!this.mediaTrack||this.sourceTrack===this.mediaTrack)}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){e.addEventListener(pA,this.onTrackMuted),e.addEventListener(fA,this.onTrackUnmuted),e.addEventListener(mA,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===mA&&this.onTrackEnded()}uninstallTrackEvent(e){e.removeEventListener(pA,this.onTrackMuted),e.removeEventListener(fA,this.onTrackUnmuted),e.removeEventListener(mA,this.onTrackEnded)}setStateToReady(){}async capture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;let n=this.sourceTrack;try{let n,a=yC();qO.emit(KO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(n=new MediaStream,n.addTrack(e.customSource)):(t||null==(r=this.sourceTrack)||r.stop(),n=await cP(e));let o=n.getTracks()[0];return await this.setInputMediaStreamTrack(o),e.customSource||(this.sourceTrack=o,this.updateDeviceIdInUse(),this.listenDeviceChange()),qO.emit(KO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:yC()-a,profile:this.profile,room:null==(i=this.manager)?void 0:i.room}),n}catch(a){throw qO.emit(KO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:a}),this.log.error("getUserMedia error observed ".concat(a)),a}finally{t&&(null==n||n.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=SC((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}async publish(e,t){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()),await t,this._checkPublishFlag(e)}_checkPublishFlag(e){return new Promise(async(t,r)=>{var i,n,a,o,s;let c=()=>r(new pR({code:uR.API_CALL_ABORTED,message:"publish aborted"}));if(this.hasFlag||this.muted?t():((this.state===Ox.INIT||"ready"===this.state)&&c(),wP(xP(e,"local-publish-flag-changed"),NP(()=>this.hasFlag),MP(DP(xP(this,Ox.INIT),xP(this,"ready"))),qP(t,r,c))),null!=(a=null==(n=null==(i=this.room)?void 0:i.networkQuality)?void 0:n.hadRecentBadUplink)&&a.call(n,2))return t();let l=e.heartbeatCount,d=(null==(s=null==(o=this.mediaTrack)?void 0:o.stats)?void 0:s.totalFrames)||0;this._encodeCheckTimeoutId=setTimeout(async()=>{var i,n,a,o,s,c,u,h;if(null!=(a=null==(n=null==(i=this.room)?void 0:i.networkQuality)?void 0:n.hadRecentBadUplink)&&a.call(n,2)||e.heartbeatCount-l<3)return t();if(this.isPublished||this.isPublishing){let e=this.kind===lA;if(null!=(o=this.mediaTrack)&&o.stats){let e=this.mediaTrack.stats.totalFrames||0;e-d===0&&this.log.warn("capture totalFrames is 0 during encode check, totalFrames",e)}if(!this.isMediaTrackActive)return this.emit("6",this),r(new pR({message:"".concat(this.strMediaType," encode failed, track is not active"),code:e?uR.AUDIO_ENCODE_FAILED:uR.VIDEO_ENCODE_FAILED}));let i=this.stat.bytesSent>0;if(lL[i?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),!e){let e={H264:513704,H265:513705,VP8:513706}[(null==(c=null==(s=this.room)?void 0:s.videoCodec)?void 0:c.toUpperCase())||"H264"];e&&lL[i?"addSuccessEvent":"addFailedEvent"]({key:e})}if(!i){if(lL.addEnum({key:e?503701:513703,value:zO()}),jx.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(WO()||GO()),userId:this.userId}),this.log.warn(e?"encode failed":"".concat(null==(h=null==(u=this.room)?void 0:u.videoCodec)?void 0:h.toUpperCase()," encode failed")),this.retryEncodeFailed&&(this.log.warn("retry encode"),await this.retryEncodeFailed(this),this.stat.bytesSent>0||this.hasFlag||(await VC(5e3),this.stat.bytesSent>0||this.hasFlag)))return t();this.emit("6",this),r(new pR({message:"".concat(this.strMediaType," encode failed"),code:e?uR.AUDIO_ENCODE_FAILED:uR.VIDEO_ENCODE_FAILED}))}}},1e4)})}unpublish(){this.room&&this.room.localTracks.delete(this),this.log.info("unpublish"),qO.emit(KO.LOCAL_TRACK_UNPUBLISHED,{track:this})}async updateDeviceIdInUse(){if(this.sourceTrack&&XL){let{deviceId:e,groupId:t}=this.sourceTrack.getSettings(),{label:r}=this.sourceTrack;await ZN({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind})||(this.deviceId=e,this.label=r,t&&(this.groupId=t),zN().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===lA&&!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(wA);return!!XN.has(r)}(this.sourceTrack)||this.kind===dA&&!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(IA);return!!XN.has(r)}(this.sourceTrack)||this._isRecapturing||e&&tO&&RO)}onTrackMuted(){if(super.onTrackMuted(),lP(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<LA)return void setTimeout(()=>this.onTrackMuted(),LA);this._onMuteTimeoutId=setTimeout(async()=>{var e;if(null!=(e=this.sourceTrack)&&e.muted){if((wD||TD)&&"visible"!==document.visibilityState)return;this.recapture(await this.getRecoverCaptureDeviceId())}},5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}async onTrackEnded(){if(super.onTrackEnded(),this.isNeedToRecapture()&&0===this.recaptureMode){if(Date.now()-this._lastRecaptureTime<LA)return void setTimeout(()=>this.onTrackEnded(),LA);this.emit("7"),this.recapture(await this.getRecoverCaptureDeviceId())}}async recapture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];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 n={useExactDeviceId:!0};if("user"===e||"environment"===e)n.facingMode=e;else{let t;("audio"===this.kind?await GN():await qN()).find(t=>t.deviceId===e)&&(t=e),n.deviceId=t}return this.capture(n,t).then(()=>{var e;this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),qO.emit(KO.LOCAL_TRACK_RECAPTURE,{track:this}),null!=(e=this.sourceTrack)&&e.muted&&(this.log.warn("track still muted after recapture"),this.onTrackMuted())}).catch(e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),qO.emit(KO.LOCAL_TRACK_RECAPTURE,{track:this,error:e})}).finally(()=>{t&&(null==i||i.stop())})}async getRecoverCaptureDeviceId(){let e=this instanceof eM;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let r=(ZP.get(t)||0)+1;if(ZP.set(t,r),r>=3&&this.enableAutoSwitchWhenRecapturing){let i=e?(await qN()).find(e=>!ZP.has(e.deviceId)):(await GN()).find(e=>!ZP.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(),qO.emit(KO.LOCAL_TRACK_STOPPED,{track:this}),this.uninstallTrackEvent(this.sourceTrack)),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack),null==(e=this.manager)||e.removeInput(this),this._onMuteTimeoutId&&clearTimeout(this._onMuteTimeoutId)}close(){super.close(),this.stopCapture()}};Pk([Rx(Ox.INIT,"ready",{ignoreError:!0,sync:!0})],XP.prototype,"setStateToReady",1),Pk([function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,r,i){let n=i.value;return i.value=function(){let t=hP.get(this)||new uP;for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return hP.set(this,t),t.push({fn:n,args:a,context:this,funcName:r},e)},i}}()],XP.prototype,"capture",1),Pk([Rx("ready","publish",{ignoreError:!0,success(){qO.emit(KO.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 pR?e:e.cause instanceof pR?e.cause:e,n=!1;i instanceof pR&&(i.message.includes("timeout")?r="timeout":i.code===uR.API_CALL_ABORTED&&(n=!0,r="api-call")),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:r,error:i}),this.log[n?"info":"error"]("publish failed",i)}}),pP(521714,!1)],XP.prototype,"publish",1),Pk([Gk(e=>async 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)}),Rx([],"ready",{sync:!0})],XP.prototype,"unpublish",1);var ZP=new Map;qO.on(KO.SWITCH_DEVICE_SUCCESS,e=>{e.track.deviceId&&ZP.delete(e.track.deviceId)});var JP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-2,r=[],i=0;for(let a=e;a<=t;a++){let e=this.dataView.getInt8(a);switch(e){case 0:case 1:case 2:case 3:2===i&&(r.push(3),i=0),0===e?i+=1:i=0,r.push(e);break;default:i=0,r.push(e)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=n}removePreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-1,r=[],i=0;for(let a=e;a<=t;a++)switch(this.dataView.getInt8(a)){case 0:i++,r.push(this.dataView.getInt8(a));break;case 3:2!==i&&r.push(this.dataView.getInt8(a)),i=0;break;default:r.push(this.dataView.getInt8(a)),i=0}let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=n}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e+=1,255===this.dataView.getUint8(t));t+=1);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 a=6;a<this.dataView.buffer.byteLength;a+=1){let r=this.dataView.getUint8(a);if(t+=1,255!==r){e+=r;break}e+=255}let r=new ArrayBuffer(e),i=new DataView(r),n=t;for(let a=0;a<r.byteLength;a+=1)i.setInt8(a,this.dataView.getInt8(n+a));return i}get naluType(){let e=this.getStartCodeLength();return e>=this.dataView.byteLength?0:31&this.dataView.getUint8(e)}getStartCodeLength(){return this.dataView.byteLength>=4&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&0===this.dataView.getUint8(2)&&1===this.dataView.getUint8(3)?4:this.dataView.byteLength>=3&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&1===this.dataView.getUint8(2)?3:0}get isIDR(){return 5===this.naluType}get isSPS(){return 7===this.naluType}get isPPS(){return 8===this.naluType}get isSEI(){return 6===this.naluType}},QP=class{constructor(){Mk(this,"_seiMessageList",[]),Mk(this,"_smallSeiMessageList",[]),Mk(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,r=parseInt(String(t/255),10),i=t%255,n=[];n.push(0,0,0,1,6,this._seiPayloadType);for(let o=0;o<r;o++)n.push(255);n.push(i);let a=new DataView(e);return n.push(...new Uint8Array(a.buffer)),n.push(128),new JP(new DataView(new Uint8Array(n).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 n=0;n<e.byteLength;n++)switch(i.getUint8(n)){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)),n=i.reduce((e,t)=>e+t.dataView.byteLength,0),a=new ArrayBuffer(n+e.data.byteLength),o=new DataView(a),s=new DataView(e.data),c=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)o.setInt8(c++,i[e].dataView.getInt8(t));for(let r=0;r<e.data.byteLength;r++)o.setInt8(c++,s.getInt8(r));return e.data=a,i.length}return 0}},$P=class e extends XP{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,gN,null==e?void 0:e.room),Mk(this,"profile",Ck({},sA)),Mk(this,"avoidCropping",!1),Mk(this,"_scaleResolutionDownBy"),Mk(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0,framesCaptured:0}),Mk(this,"small"),Mk(this,"isNeedToSetBandwidth"),Mk(this,"muteImage"),Mk(this,"manager"),Mk(this,"_seiCodec",new QP),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=BR((null==(e=this.room)?void 0:e.sdkAppId)||0)?rA:tA;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(t)),this.setProfile(Dk(Ck({},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(XL&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e,t;return(null==(e=this._inputTrack)?void 0:e.contentHint)||(null==(t=this.outMediaTrack)?void 0:t.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)}async setMute(e){var t,r,i;if(oC(e)){if(this.muteImage===e)return;await(null==(t=this.manager)?void 0:t.deleteWatermark("mute")),await(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:e,fillVideo:!0})),this.muteImage=e,super.setMute(!1)}else this.muteImage&&(await(null==(i=this.manager)?void 0:i.deleteWatermark("mute")),this.muteImage=void 0),super.setMute(e)}async capture(e){let{deviceId:t,facingMode:r,useExactDeviceId:i=!0,customSource:n,retryWhenExactFailed:a=!0}=e,o={audio:!1,video:!0,facingMode:r||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:i,retryWhenExactFailed:a,customSource:n};if("environment"===o.facingMode){let e=await this.getDeviceIdWhenUsingBackCamera();e&&(o.cameraId=e)}return super.capture(o)}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=BR((null==(t=this.room)?void 0:t.sdkAppId)||0)?rA:tA;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(e)),super.setProfile(Dk(Ck({},this.profile),{width:1920,height:1080}))}}async applyProfile(){var e;if(!this.mediaTrack)return;this.log.info("applyProfile",this.profile);let{width:t=0,height:r=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=t*r,n=this.settings,a=n.height!==this.profile.height||n.width!==this.profile.width||n.frameRate!==this.profile.frameRate;if(a&&(16===NO&&this.deviceId?await this.recapture(this.deviceId):(await(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 a&&r&&i&&r===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:dA,videoType:hA})}}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return XL&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:zC(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)}async switchDevice(e){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(),await this.capture(t),qO.emit(KO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(Yk){throw this.log.error("switch camera failed ".concat(Yk)),this.deviceId&&this.recapture(this.deviceId),Yk}}async getDeviceIdWhenUsingBackCamera(){let e;try{if(lO&&!vO&&JL){let t=(await qN(!0)).map(e=>{var t;return Dk(Ck({},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,n,a;let{capabilities:o}=e;(null!=(t=o.width)&&t.max&&null!=(i=o.height)&&i.max?o.width.max*o.height.max:0)>(null!=(n=r.capabilities.width)&&n.max&&null!=(a=r.capabilities.height)&&a.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(Yk){this._log.warn("get max res camera failed",Yk)}return e}async 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),await(null==(t=this.manager)?void 0:t.update()),i&&await(null==(r=this.room)?void 0: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=Ck({},e);return e.width*e.height<=19200&&TD&&bO&&(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&&MO&&(i.width=r?1280:720,i.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),function(e,t){let r=e.split(".").map(e=>Number(e)),i=t.split(".").map(e=>Number(e));for(let n=0;n<Math.max(r.length,i.length);n++){let e=r[n]||0,t=i[n]||0;if(e<t)return!0;if(e>t)return!1}return!1}(LO,"14.3")&&xO(LO,"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&&(bO||kD)&&!(TD||wD||ED||vD||vO)&&e.width*e.height<=230400&&e.width/e.height===16/9&&(this._scaleResolutionDownBy=1280/e.width,i.width=1280,i.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(){HN&&!HN.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&HN.on("videoInputRemoved",this.handleCameraRemoved,this)}async handleCameraRemoved(e){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(YP[this.recaptureMode],". Current camera is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){AM(this.userId,{eventId:2003,param1:7,streamType:2});let e=await qN();e[0]?this.recapture(e[0].deviceId):t=!0}t&&HN.on("videoInputAdded",this.handleCameraAdded,this)}}async handleCameraAdded(e){1===this.recaptureMode&&e.deviceId!==this.deviceId||(HN.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 aC(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){var e;this.muteImage&&(null==(e=this.manager)||e.deleteWatermark("mute"),this.muteImage=void 0),HN.off("videoInputAdded",this.handleCameraAdded,this),HN.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}async recapture(e){try{await super.recapture(e)}catch(Yk){let r=(await qN()).find(t=>t.deviceId!==e);if(!r)throw Yk;await super.recapture(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||aC(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}setOutputMediaStreamTrack(t){var r;let i=this._outputTrack;if(!(this instanceof e&&$C(i,this.room||(null==(r=this.manager)?void 0:r.room))))return super.setOutputMediaStreamTrack(t)}};Pk([zk(function(e){this.setContentHint(e.contentHint||"motion")})],$P.prototype,"capture",1);var eM=$P,tM=[-1,-1,1,-1,-1,1,1,1],rM=[0,0,1,0,0,1,1,1],iM=class e extends Ox{constructor(e,t){if(super(),this.context=e,Mk(this,"name"),Mk(this,"sourceId",""),Mk(this,"input"),Mk(this,"output"),Mk(this,"texture"),Mk(this,"ctx2d",null),Mk(this,"fbo"),Mk(this,"width",0),Mk(this,"height",0),Mk(this,"x",0),Mk(this,"y",0),Mk(this,"program"),Mk(this,"vertexShader"),Mk(this,"fragmentShader"),Mk(this,"totalFrames",0),Mk(this,"dropFrames",0),Mk(this,"matchInputSize",!0),Mk(this,"texCoordBuffer"),Mk(this,"positionBuffer"),Mk(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),Mk(this,"cost",0),Mk(this,"_canvas",null),Mk(this,"_image"),Mk(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 yM)t.create2d&&("function"==typeof OffscreenCanvas&&16!==NO?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(rM),this.positionBuffer=this.createBuffer(tM),!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(r){this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(r.message||r)}))}}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 _M&&this.render(e)||this.context instanceof yM&&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 _M){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,n,a,o,s,c,l){let d=!(aC(o)||aC(s)||aC(c)||aC(l));return!(!this.ctx2d||!t)&&(t instanceof ImageData?(d?this.ctx2d.putImageData(t,r,i,o,s,c,l):this.ctx2d.putImageData(t,r,i),this.emit(e.RENDER,this.ctx2d.canvas)):(d?this.ctx2d.drawImage(t,o,s,c,l,r,i,n,a):this.ctx2d.drawImage(t,r,i,n,a),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:n,height:a,name:o,cost:s,dropFrames:c}=this,l=Date.now(),d=(t-this.lastInfo.totalFrames)/((l-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:r,y:i,width:n,height:a,timestamp:l,fps:d,name:o,cost:s,dropFrames:c},Ck({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}};Mk(iM,"RENDER","render"),Pk([Rx(Ox.INIT,"connected",{sync:!0})],iM.prototype,"connect",1),Pk([Rx("connected",Ox.INIT,{ignoreError:!0,sync:!0})],iM.prototype,"disconnect",1),Pk([Rx([],"closed",{sync:!0})],iM.prototype,"close",1);var nM=iM,aM=wP(function(e){return IP(t=>{let r=0,i=setInterval(()=>t.next(r++),e);return t.defer(()=>{clearInterval(i)}),"interval"},"interval",arguments)}(250),BP(()=>performance.now()),CP()),oM=class extends nM{constructor(e,t){super(e,Ck({name:"imageSource"},t)),Mk(this,"_lastImage"),Mk(this,"_totalFrames",0),Mk(this,"_autoResize",!1),Mk(this,"_canvasRendered"),Mk(this,"videoCallbackId",0),Mk(this,"waitingFirstFrame",!0),Mk(this,"shouldUpdate",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===NO&&(this._canvasRendered=OP(),wP(this._canvasRendered,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return e=>IP(function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;i<n&&!r.disposed;)r.next(t[i++]);r.disposed||r.subscribe(e)},"startWith",arguments)}(this._image),jP(e=>e instanceof HTMLCanvasElement?xP(e,"rendered"):function(){return IP(e=>e.complete(),"empty",arguments)}()),MP(xP(this,"closed")),qP(()=>{this.update()})))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){if(!this.shouldUpdate)return;let e=this.image;this.videoCallbackId&&e.cancelVideoFrameCallback(this.videoCallbackId),dx()&&!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:n}=this,{image:a}=this;if(a instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:n}=a),!i||!n)return!1;a.width=i,a.height=n}else if(a instanceof HTMLImageElement||a instanceof ImageData||a instanceof ImageBitmap){if(({width:i,height:n}=a),a!==this._lastImage)this._lastImage=a;else if(i===this.width&&n===this.height)return!0}else a instanceof HTMLCanvasElement||a instanceof OffscreenCanvas?(({width:i,height:n}=a),this._lastImage=a):"undefined"!=typeof VideoFrame&&a instanceof VideoFrame&&(({displayWidth:i,displayHeight:n}=a),null==(r=this._lastImage)||r.close(),this._lastImage=a);if(!this._autoResize)return!0;if(this.width===i&&this.height===n&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,a)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a)}this.resize(i,n)}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)}},sM=class extends oM{constructor(e,t,r){super(e,r),this._player=t,this.name="videoPlayerSource",wP(xP(this._player,Bx.PLAYER_STATE_CHANGED),MP(xP(this,"closed")),NP(e=>{let{state:t}=e;return"PLAYING"===t}),qP(()=>{this.tryVideoFrameCallback()}))}get image(){return this._player.element}},cM=class extends sM{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,r){super(e,new gN({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()}},lM=class extends nM{constructor(e,t,r){super(e,Dk(Ck({name:"textSource"},r),{create2d:!0})),Mk(this,"hasChange",!0),Mk(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 n=this.font.match(/(\d+)px/),a=(n?parseInt(n[1],10):16)*r,o=this.content.split("\n");for(let s=0;s<o.length;s++)this.ctx2d.fillText(o[s],e,t+s*a)}},dM=[1,0,0,0,1,1,0,1],uM=class extends nM{constructor(e,t,r,i){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:t}),Mk(this,"mirror",!1),Mk(this,"rotation",0),r&&(this.mirror=r),i&&(this.rotation=i),e instanceof _M)try{this.setTexBuffer(dM)}catch(Xk){e.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(Xk.message||Xk)}))}}draw2d(e,t,r,i,n){if(this.ctx2d){if(this.ctx2d.clearRect(0,0,this.width,this.height),!this.mirror&&0===this.rotation)return super.draw2d(e,t,r,i,n);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(n/i,i/n)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,n),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(n/i,i/n));let a=super.draw2d(e,t,r,i,n);return this.ctx2d.restore(),a}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){GC(this.rotation)&&([e,t]=[t,e]),super.resize(e,t)}},hM=[0,1,1,1,0,0,1,0],pM=class extends nM{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),Mk(this,"_intervalId",0),Mk(this,"_sequence",0),Mk(this,"checkGLError",!1),Mk(this,"_useTimerOnShowSubject",OP()),Mk(this,"_closedOb",xP(this,"closed")),Mk(this,"checkVisibilityChange"),Mk(this,"_workerDriven",!1),Mk(this,"_frameExtractIntervalId",0),Mk(this,"_lastLayoutHash",""),Mk(this,"_needsMainThreadExtraction",!1),Mk(this,"_pendingStartFrameRate",null),Mk(this,"_workerImageSourceIds",new Set),e instanceof yM?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(hM),wP(this._useTimerOnShowSubject,GP(xP(document,"visibilitychange")),MP(this._closedOb),qP(()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")))}))}start(e){this.context instanceof yM&&this.context.isWorkerMode?this.context.workerReady?(this._pendingStartFrameRate=null,this._startWorkerDriven(e)):(this.log.info("".concat(this.name," start() called but Worker not ready, pending frameRate=").concat(e)),this._pendingStartFrameRate=e,this.context.setOnWorkerReadyCallback(()=>{if(null!==this._pendingStartFrameRate){let e=this._pendingStartFrameRate;this._pendingStartFrameRate=null,this.log.info("".concat(this.name," Worker ready, executing pending start(").concat(e,")")),this.start(e)}})):this._startMainThreadDriven(e)}_startWorkerDriven(e){if(this._workerDriven){let t=this.context;return this.log.info("".concat(this.name," Worker-driven already active, updating fps to ").concat(e)),t.postWorkerMessage({type:"setFps",fps:e}),void this._ensureMainThreadTimer()}this.log.info("".concat(this.name," start Worker-driven render ").concat(e," fps")),Ux.clearTask(this._intervalId),this._intervalId=0,this._workerDriven=!0;let t=this.context;t.postWorkerMessage({type:"start",fps:e}),this._startFrameExtraction(e);let r=this.input;r&&r.inputs&&(this._syncLayoutToWorker(r,t),this._pushAllStaticSourceFrames(),this._resendImageSourcesToWorker(r,t))}_startFrameExtraction(e){this._stopFrameExtraction();let t=this.context,r=this.input;r&&r.inputs&&t.useWorkerRendering&&this._setupWorkerFrameExtraction(r,t),this._ensureMainThreadTimer(),!this._frameExtractIntervalId&&r&&r.inputs&&(this._syncLayoutToWorker(r,t),this.log.info("All sources transferred to Worker, main thread frame extraction timer not needed"))}_setupWorkerFrameExtraction(e,t){let r=!1,i=0;t.setStreamErrorCallback((e,t)=>{this.log.warn("Source ".concat(e," stream error, degrading to main thread extraction: ").concat(t)),this._onSourceDegradedToMainThread()});for(let n of e.inputs){if(n.layout.hidden)continue;let e=n.node.input||n.node,a=n.node.sourceId;if(e instanceof cM){let r=this._getTrackFromSourceNode(e);r&&t.addTrackStream(a,r)&&i++}else e instanceof lM||e instanceof oM&&e.image instanceof HTMLImageElement||(r=!0)}this._needsMainThreadExtraction=r,i>0?this.log.info("Worker frame extraction: ".concat(i," track source(s) transferred, needsMainThreadExtraction=").concat(r)):r||this.log.info("Worker frame extraction: all sources are static (Text/Image) or track-based, no main thread timer needed")}_getTrackFromSourceNode(e){try{let t=e._player;return(null==t?void 0:t.track)||null}catch(Yk){return null}}_onSourceDegradedToMainThread(){this._needsMainThreadExtraction=!0,this._ensureMainThreadTimer(),this.log.info("Source degraded to main thread extraction")}_stopFrameExtraction(){this._frameExtractIntervalId&&(Ux.clearTask(this._frameExtractIntervalId),this._frameExtractIntervalId=0)}addWorkerTrackStream(e,t){if(!(this._workerDriven&&this.context instanceof yM))return;let r=this.context;r.useWorkerRendering&&(r.isStreamTransferred(e)?this.log.info("addWorkerTrackStream(".concat(e,"): already transferred, skipping")):(this.log.debug("addWorkerTrackStream(".concat(e,"): track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState)),r.addTrackStream(e,t)?(this.log.info("Dynamic addWorkerTrackStream(".concat(e,"): transferred to Worker")),this._ensureMainThreadTimer()):this._onSourceDegradedToMainThread()))}removeWorkerTrackStream(e){if(!(this.context instanceof yM))return;let t=this.context;t.isStreamTransferred(e)&&(t.removeTrackStream(e),this.log.info("Dynamic removeWorkerTrackStream(".concat(e,"): pipeline removed")))}replaceWorkerTrackStream(e,t){if(!(this.context instanceof yM))return;let r=this.context;r.isStreamTransferred(e)?(this.log.debug("replaceWorkerTrackStream(".concat(e,"): replacing with newTrack.id=").concat(t.id,", newTrack.label=").concat(t.label,", newTrack.readyState=").concat(t.readyState)),r.replaceTrackStream(e,t)?this.log.info("replaceWorkerTrackStream(".concat(e,"): stream replaced successfully")):(this.log.warn("replaceWorkerTrackStream(".concat(e,"): new stream transfer failed, degrading")),this._onSourceDegradedToMainThread())):this.log.debug("replaceWorkerTrackStream(".concat(e,"): not transferred, skipping"))}syncLayoutToWorker(){if(!(this.context instanceof yM&&this.context.isWorkerMode))return;let e=this.input;!e||!e.inputs||this._syncLayoutToWorker(e,this.context)}ensureMainThreadExtraction(){if(!(this._workerDriven&&this.context instanceof yM))return;let e=this.context,t=this.input;if(!t||!t.inputs)return;let r=!1;for(let i of t.inputs){if(i.layout.hidden)continue;let t=i.node.input||i.node,n=i.node.sourceId;t instanceof cM?e.isStreamTransferred(n)||(r=!0):t instanceof lM||t instanceof oM&&t.image instanceof HTMLImageElement||(r=!0)}this._needsMainThreadExtraction=r,this._ensureMainThreadTimer()}_pushAllStaticSourceFrames(){if(!(this._workerDriven&&this.context instanceof yM))return;let e=this.context;if(!e.workerReady)return;let t=this.input;if(!t||!t.inputs)return;let r=0;for(let i of t.inputs){if(i.layout.hidden)continue;let t=i.node.input||i.node,n=i.node.sourceId,a=t instanceof lM,o=t instanceof oM&&t.image instanceof HTMLImageElement;(a||o&&!e.isWorkerMode)&&(this.pushStaticSourceFrame(n,t),r++)}r>0&&this.log.info("_pushAllStaticSourceFrames: pushed ".concat(r," static source frame(s) after Worker ready"))}_resendImageSourcesToWorker(e,t){if(!t.isWorkerMode||!t.workerReady)return;let r=0,i=0;for(let n of e.inputs){if(n.layout.hidden)continue;let e=n.node.input||n.node;if(!(e instanceof oM&&e.image instanceof HTMLImageElement))continue;let a=n.node.sourceId,o=e.image.src;if(!o)continue;if(this._workerImageSourceIds.has(a)){i++;continue}let{animated:s,mimeType:c}=eD(o);t.postWorkerMessage({type:"addImageSource",id:a,src:o,animated:s,mimeType:c}),this._workerImageSourceIds.add(a),r++}(r>0||i>0)&&this.log.info("_resendImageSourcesToWorker: re-sent ".concat(r,", skipped ").concat(i," (already tracked) ImageSource(s)"))}pushStaticSourceFrame(e,t){if(!(this._workerDriven&&this.context instanceof yM))return;let r=this.context;if(!r.workerReady)return;try{t.requestFrame(0)}catch(o){}let{image:i}=t;if(!i)return;let n=0,a=0;try{if(i instanceof HTMLImageElement){if(!i.complete||!i.naturalWidth||!i.naturalHeight)return;n=i.naturalWidth,a=i.naturalHeight}else{if(!(i instanceof HTMLCanvasElement||i instanceof OffscreenCanvas))return;({width:n,height:a}=i)}if(!n||!a)return;createImageBitmap(i).then(t=>{r.workerReady?r.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:t,width:n,height:a}]},[t]):t.close()}).catch(t=>{this.log.warn("pushStaticSourceFrame failed for source ".concat(e,": ").concat(t.message||t))})}catch(o){}}_ensureMainThreadTimer(){if(!(this._workerDriven&&this.context instanceof yM))return;let e=this.context;if(this._needsMainThreadExtraction&&!this._frameExtractIntervalId){let t=this.input;if(!t||!t.inputs||0===t.inputs.length)return void this.log.info("_ensureMainThreadTimer: no sources connected, deferring timer");this._frameExtractIntervalId=Ux.run("intervalInWorker",()=>{let t=this.input;!t||!t.inputs||(this._syncLayoutToWorker(t,e),this._extractAndSendFrames(t,e))},{fps:this.context.frameRate}),this.log.info("_ensureMainThreadTimer: started timer fps=".concat(this.context.frameRate," (needsMainThreadExtraction=").concat(this._needsMainThreadExtraction,")"))}else!this._needsMainThreadExtraction&&this._frameExtractIntervalId&&(Ux.clearTask(this._frameExtractIntervalId),this._frameExtractIntervalId=0,this.log.info("_ensureMainThreadTimer: stopped timer, no dynamic sources need main thread extraction"))}_syncLayoutToWorker(e,t){if(!t.workerReady)return;let r=e.inputs.map(e=>{var t,r,i,n;return{id:e.node.sourceId,x:null!=(t=e.layout.x)?t:e.node.x,y:null!=(r=e.layout.y)?r:e.node.y,width:null!=(i=e.layout.width)?i:e.node.width,height:null!=(n=e.layout.height)?n:e.node.height,zIndex:e.layout.zIndex,fillMode:e.layout.fillMode,rotation:e.layout.rotation,mirror:e.node instanceof uM&&e.node.mirror,hidden:!!e.layout.hidden}}),i=JSON.stringify(r);i!==this._lastLayoutHash&&(this._lastLayoutHash=i,t.postWorkerMessage({type:"updateLayout",layouts:r}))}_extractAndSendFrames(e,t){if(!t.workerReady)return;let r=[],i=[];for(let a of e.inputs){if(a.layout.hidden)continue;let e=a.node.sourceId;if(t.isStreamTransferred(e))continue;let o=a.node.input||a.node;if(o instanceof lM||o instanceof oM&&o.image instanceof HTMLImageElement)continue;try{o.requestFrame(0)}catch(n){}let{image:s}=o;if(s)try{let n=null,a=0,o=0;if(s instanceof HTMLVideoElement){if(({videoWidth:a,videoHeight:o}=s),!a||!o||s.readyState<2)continue;if("undefined"!=typeof VideoFrame)n=new VideoFrame(s,{timestamp:0});else if("undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (video): ").concat(t.message||t))});continue}}else if(s instanceof HTMLCanvasElement||s instanceof OffscreenCanvas){if(({width:a,height:o}=s),!a||!o)continue;if("undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (canvas): ").concat(t.message||t))});continue}}else if(s instanceof HTMLImageElement){if(!s.complete||!s.naturalWidth||!s.naturalHeight)continue;if(a=s.naturalWidth,o=s.naturalHeight,"undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (image): ").concat(t.message||t))});continue}}n&&a&&o&&(r.push({id:e,frame:n,width:a,height:o}),i.push(n))}catch(n){continue}}if(r.length>0){if(!t.workerReady){for(let e of r)"close"in e.frame&&"function"==typeof e.frame.close&&e.frame.close();return}t.postWorkerMessage({type:"updateFrames",frames:r},i)}}_startMainThreadDriven(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),this._workerDriven=!1,Ux.clearTask(this._intervalId),this._intervalId=Ux.run("intervalInWorker",()=>{if(e!==this.context.frameRate&&(Ux.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof _M){let e=this.context.ctx.getError();e&&this.context.destroy(new pR({code:uR.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(nM.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&&(Ux.clearTask(this._intervalId),this._intervalId=0,1===e&&(this.log.info("".concat(this.name," use requestVideoFrameCallback")),this._useTimerOnShowSubject.next())),this.requestFrame(this._sequence++))}removeInput(e){super.removeInput(e),Ux.clearTask(this._intervalId),this._cleanupWorkerDrivenState()}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}get isWorkerDriven(){return this._workerDriven}trackWorkerImageSource(e){this._workerImageSourceIds.add(e)}untrackWorkerImageSource(e){this._workerImageSourceIds.delete(e)}close(){super.close(),Ux.clearTask(this._intervalId),this._cleanupWorkerDrivenState(),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}_cleanupWorkerDrivenState(){this._pendingStartFrameRate=null,this.context instanceof yM&&this.context.setOnWorkerReadyCallback(null),this._workerDriven&&this.context instanceof yM&&(this._stopFrameExtraction(),this._cleanupAllWorkerStreams(),this.context.postWorkerMessage({type:"stop"}),this._workerDriven=!1,this._workerImageSourceIds.clear())}_cleanupAllWorkerStreams(){if(!(this.context instanceof yM))return;let e=this.context;for(let t of e.transferredStreams)e.removeTrackStream(t);this._needsMainThreadExtraction=!1,e.setStreamErrorCallback(null)}},fM=class extends pM{constructor(e,t){super(e,t),Mk(this,"_videoTrack"),Mk(this,"_muteOb"),Mk(this,"_subscription"),Mk(this,"_canvasContainer"),Mk(this,"_useTrackGenerator",!1),Mk(this,"_trackGeneratorDegradedHandler",null),Number(DO)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),e instanceof yM&&e.useTrackGenerator?(this._useTrackGenerator=!0,this._videoTrack=e.generatorTrack,this.log.info("VideoTrackDestination using TrackGenerator track, id=".concat(this._videoTrack.id,", readyState=").concat(this._videoTrack.readyState)),this._trackGeneratorDegradedHandler=()=>{this._handleTrackGeneratorDegradation()},e.on("trackGeneratorDegraded",this._trackGeneratorDegradedHandler)):([this._videoTrack]=e.canvas.captureStream().getVideoTracks(),this.log.info("VideoTrackDestination using captureStream track, id=".concat(this._videoTrack.id,", readyState=").concat(this._videoTrack.readyState))),this._muteOb=xP(this._videoTrack,"mute"),wP(xP(this._videoTrack,"ended"),MP(this._closedOb),qP(()=>{this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))}_handleTrackGeneratorDegradation(){if(!this._useTrackGenerator)return;this.log.warn("VideoTrackDestination: Worker mode degraded, switching to main thread captureStream"),this._useTrackGenerator=!1,this._trackGeneratorDegradedHandler&&this.context instanceof yM&&(this.context.off("trackGeneratorDegraded",this._trackGeneratorDegradedHandler),this._trackGeneratorDegradedHandler=null),this._stopFrameExtraction(),this._cleanupAllWorkerStreams(),this._workerDriven=!1;let[e]=this.context.canvas.captureStream().getVideoTracks();e?(this._videoTrack,this._videoTrack=e,this.log.info("VideoTrackDestination degraded to main thread captureStream track, id=".concat(e.id,", readyState=").concat(e.readyState)),this._muteOb=xP(this._videoTrack,"mute"),wP(xP(this._videoTrack,"ended"),MP(this._closedOb),qP(()=>{this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})),this._startMainThreadDriven(this.context.frameRate),this.emit("trackChanged",e)):this.log.error("VideoTrackDestination: Failed to get captureStream track during degradation")}enableCheckMute(){this._subscription=wP(this._muteOb,MP(this._closedOb),GP((e=>t=>{let r=performance.now();wP(aM,UP(t=>t-r<e),PP(1))(t)})(5e3)),NP(()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)}),qP(()=>{this.context.destroy(new pR({code:uR.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;this._trackGeneratorDegradedHandler&&this.context instanceof yM&&(this.context.off("trackGeneratorDegraded",this._trackGeneratorDegradedHandler),this._trackGeneratorDegradedHandler=null),super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},mM=class extends Ox{constructor(e){super(),Mk(this,"frameRate"),Mk(this,"_canvas"),Mk(this,"log"),Mk(this,"hasAlpha",!1),Mk(this,"name"),Mk(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 cM(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new fM(this,e)}createVideoImageSource(e,t){return new oM(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new sM(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}createTextSource(e,t){return new lM(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};Mk(mM,"_ids",0);var gM=class extends mM{constructor(){super(...arguments),Mk(this,"defaultProgam"),Mk(this,"defaultVShader"),Mk(this,"defaultFShader"),Mk(this,"ctx"),Mk(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(mM._ids++)),e&&(this._canvas2d=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",NA),!this.ctx)throw new pR({code:uR.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 pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))})}destroy(e){let t="";return e&&(t=e.message,this.error=e,lL.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}};Mk(gM,"UNAVAILABLE","unavailable"),Pk([Rx(Ox.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),lL.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),lL.addSuccessEvent({key:512700})}})],gM.prototype,"create",1),Pk([Rx("created",Ox.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(gM.UNAVAILABLE,e),this.removeAllListeners()}})],gM.prototype,"destroy",1);var _M=gM,vM=class e extends mM{constructor(){super(...arguments),Mk(this,"ctx"),Mk(this,"_useWorkerRendering",!1),Mk(this,"_renderWorker",null),Mk(this,"_workerReady",!1),Mk(this,"_workerFailed",!1),Mk(this,"_useTrackGenerator",!1),Mk(this,"_generatorTrack",null),Mk(this,"_contextLostHandler",null),Mk(this,"_contextRestoredHandler",null),Mk(this,"_transferredStreams",new Set),Mk(this,"_degradedStreams",new Set),Mk(this,"_trackProcessors",new Map),Mk(this,"_streamErrorCallback",null),Mk(this,"_pendingBackground",null),Mk(this,"_pendingBackgroundImage",null),Mk(this,"_pendingSize",null),Mk(this,"_pendingImageSourceMessages",new Map),Mk(this,"_onWorkerReadyCallback",null)}get useWorkerRendering(){return this._useWorkerRendering&&this._workerReady}get useTrackGenerator(){return this._useTrackGenerator}get generatorTrack(){return this._generatorTrack}get isWorkerMode(){return this._useWorkerRendering}get workerReady(){return this._workerReady}get renderWorker(){return this._renderWorker}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(mM._ids++),e.workerScript&&bx())try{return this._initWorkerMode(e.workerScript),void this.log.info("Worker rendering mode initialized")}catch(Yk){this.log.warn("Worker rendering mode init failed, falling back to main thread: ".concat(Yk.message)),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(mM._ids++)}this._initMainThreadMode(e)}_initWorkerMode(e){let t=new OffscreenCanvas(this._canvas.width||640,this._canvas.height||480);this._renderWorker=this._createRenderWorker(e),this._useWorkerRendering=!0;let r={type:"init",canvas:t,width:this._canvas.width||640,height:this._canvas.height||480},i=[t],n=new MediaStreamTrackGenerator({kind:"video"});this._generatorTrack=n,this._useTrackGenerator=!0;let a=n.writable;r.writable=a,i.push(a),this.log.info("TrackGenerator created, track id=".concat(n.id,", readyState=").concat(n.readyState)),this.log.info("Sending writable to Worker"),this._renderWorker.postMessage(r,i),this._renderWorker.onmessage=e=>{let{data:t}=e;switch(t.type){case"ready":if(this._workerReady=!0,this.log.info("Render Worker ready"),this._flushPendingState(),this._onWorkerReadyCallback){let e=this._onWorkerReadyCallback;this._onWorkerReadyCallback=null,e()}break;case"trackGeneratorFailed":this.log.warn("Worker reported TrackGenerator failure, failCount=".concat(t.failCount)),this._handleTrackGeneratorDegradation();break;case"error":this.log.error("Render Worker error: ".concat(t.message));break;case"streamError":this.log.warn("Worker stream error for source ".concat(t.id,": ").concat(t.message)),this._transferredStreams.delete(t.id),this._streamErrorCallback&&this._streamErrorCallback(t.id,t.message);break;case"streamStalled":this.log.warn("Worker stream stalled for source ".concat(t.id,": no frames received within ").concat(t.stallDuration,"ms, degrading to main thread extraction")),this._transferredStreams.delete(t.id),this._degradedStreams.add(t.id),this.removeTrackStream(t.id),this._streamErrorCallback&&this._streamErrorCallback(t.id,"ReadableStream stalled: no frames received within ".concat(t.stallDuration,"ms"));break;case"log":{let e=t.level,r=t.message,i=this.log[e];i?i.call(this.log,r):this.log.warn("[Worker][unknown level: ".concat(e,"] ").concat(r));break}case"destroyed":this.log.info("Render Worker destroyed");break;case"imageSourceLoaded":this.log.info("Worker imageSource loaded: id=".concat(t.id,", ").concat(t.width,"x").concat(t.height));break;case"imageSourceError":this.log.warn("Worker imageSource error: id=".concat(t.id,", ").concat(t.message))}},this._renderWorker.onerror=e=>{this.log.error("Render Worker crashed: ".concat(e.message)),this._handleWorkerCrash()},this._renderWorker.onmessageerror=()=>{this.log.error("Render Worker message error")},this.ctx=null}_initMainThreadMode(e){if(this.ctx=this._canvas.getContext("2d",{alpha:e.alpha,willReadFrequently:e.willReadFrequently}),!this.ctx)throw new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._contextLostHandler=()=>{this.log.error("2d context lost, pausing rendering")},this._contextRestoredHandler=()=>{var e;this.log.warn("2d context restored, attempting recovery");let t=null==(e=this._canvas)?void 0:e.getContext("2d",{alpha:this.hasAlpha,willReadFrequently:!1});t?(this.ctx=t,this.log.info("2d context successfully recovered")):(this.log.error("2d context recovery failed, destroying"),this.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:9,message:"2d context lost and recovery failed"})))},this._canvas.addEventListener("contextlost",this._contextLostHandler),this._canvas.addEventListener("contextrestored",this._contextRestoredHandler)}setStreamErrorCallback(e){this._streamErrorCallback=e}addTrackStream(e,t){if(!this._renderWorker||!this._workerReady)return this.log.warn("addTrackStream(".concat(e,"): Worker not ready")),!1;if(this._degradedStreams.has(e))return this.log.warn("addTrackStream(".concat(e,"): source was previously degraded, skipping Worker transfer")),!1;try{this.log.debug("addTrackStream(".concat(e,"): creating MediaStreamTrackProcessor, track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState,", track.enabled=").concat(t.enabled,", track.muted=").concat(t.muted));let r=new MediaStreamTrackProcessor({track:t}),i=r.readable;return this._renderWorker.postMessage({type:"addReadableStream",id:e,readable:i},[i]),this._transferredStreams.add(e),this._trackProcessors.set(e,r),this.log.info("addTrackStream(".concat(e,"): ReadableStream transferred to Worker")),!0}catch(r){return this.log.warn("addTrackStream(".concat(e,") failed: ").concat(r.message)),!1}}removeTrackStream(e){this._renderWorker&&this._workerReady&&this._renderWorker.postMessage({type:"removeReadableStream",id:e}),this._transferredStreams.delete(e),this._trackProcessors.delete(e),this.log.info("removeTrackStream(".concat(e,"): pipeline removed"))}replaceTrackStream(e,t){return this.log.debug("replaceTrackStream(".concat(e,"): removing old stream, then adding new track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState)),this.removeTrackStream(e),this.addTrackStream(e,t)}isStreamTransferred(e){return this._transferredStreams.has(e)}get transferredStreams(){return this._transferredStreams}_handleWorkerCrash(){this._workerFailed||(this._workerFailed=!0,this.log.warn("Worker crashed, completely exiting Worker mode, falling back to main thread rendering"),this._transferredStreams.clear(),this._trackProcessors.clear(),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(mM._ids++),this._initMainThreadMode({alpha:this.hasAlpha,willReadFrequently:!1}),this.emit("trackGeneratorDegraded"))}_handleTrackGeneratorDegradation(){this._useTrackGenerator&&(this.log.warn("TrackGenerator degradation: completely exiting Worker mode, falling back to main thread 2d rendering"),this._transferredStreams.clear(),this._trackProcessors.clear(),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(mM._ids++),this._initMainThreadMode({alpha:this.hasAlpha,willReadFrequently:!1}),this.emit("trackGeneratorDegraded"))}_cleanupWorkerMode(){if(this._useWorkerRendering&&(e._workerBlobUrlRefCount>0&&e._workerBlobUrlRefCount--,0===e._workerBlobUrlRefCount&&null!==e._workerBlobUrl&&(URL.revokeObjectURL(e._workerBlobUrl),e._workerBlobUrl=null)),this._generatorTrack)try{this._generatorTrack.stop()}catch(zP){}if(this._generatorTrack=null,this._useTrackGenerator=!1,this._renderWorker){try{this._renderWorker.postMessage({type:"destroy"})}catch(zP){}this._renderWorker=null}this._useWorkerRendering=!1,this._workerReady=!1,this._transferredStreams.clear(),this._trackProcessors.clear(),this._onWorkerReadyCallback=null,this._pendingBackgroundImage&&(this._pendingBackgroundImage.close(),this._pendingBackgroundImage=null),this._pendingImageSourceMessages.clear()}_createRenderWorker(t){if(!e._workerBlobUrl){let r=new Blob([t],{type:"application/javascript"});e._workerBlobUrl=URL.createObjectURL(r)}return e._workerBlobUrlRefCount++,new Worker(e._workerBlobUrl)}setOnWorkerReadyCallback(e){this._onWorkerReadyCallback=e}postWorkerMessage(e,t){this._renderWorker&&this._workerReady&&(t?this._renderWorker.postMessage(e,t):this._renderWorker.postMessage(e))}bufferOrPostImageSourceMessage(e){this._renderWorker&&this._workerReady?this.postWorkerMessage(e):"removeImageSource"===e.type?this._pendingImageSourceMessages.delete(e.id):this._pendingImageSourceMessages.set(e.id,e)}setSize(e,t){super.setSize(e,t),this._useWorkerRendering&&this._renderWorker&&(this._workerReady?this.postWorkerMessage({type:"resize",width:e,height:t}):this._pendingSize={width:e,height:t})}setWorkerBackground(e){this._workerReady?this.postWorkerMessage({type:"setBackground",color:e}):this._useWorkerRendering&&(this._pendingBackground=e,this._pendingBackgroundImage=null)}setWorkerBackgroundImage(e){this._workerReady?this.postWorkerMessage({type:"setBackgroundImage",bitmap:e},[e]):this._useWorkerRendering&&(this._pendingBackgroundImage&&this._pendingBackgroundImage.close(),this._pendingBackgroundImage=e,this._pendingBackground=null)}_flushPendingState(){if(null!==this._pendingBackgroundImage?(this.postWorkerMessage({type:"setBackgroundImage",bitmap:this._pendingBackgroundImage},[this._pendingBackgroundImage]),this._pendingBackgroundImage=null,this._pendingBackground=null):null!==this._pendingBackground&&(this.postWorkerMessage({type:"setBackground",color:this._pendingBackground}),this._pendingBackground=null),null!==this._pendingSize){let{width:e,height:t}=this._pendingSize;super.setSize(e,t),this.postWorkerMessage({type:"resize",width:e,height:t}),this._pendingSize=null}if(this._pendingImageSourceMessages.size>0){for(let e of this._pendingImageSourceMessages.values())this.postWorkerMessage(e);this._pendingImageSourceMessages.clear()}}destroy(e){let t="";e&&(t=e.message,this.error=e,lL.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),this._cleanupWorkerMode(),this._canvas&&this._contextLostHandler&&this._canvas.removeEventListener("contextlost",this._contextLostHandler),this._canvas&&this._contextRestoredHandler&&this._canvas.removeEventListener("contextrestored",this._contextRestoredHandler),this._contextLostHandler=null,this._contextRestoredHandler=null,delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),lL.addSuccessEvent({key:512703})}};Mk(vM,"_workerBlobUrl",null),Mk(vM,"_workerBlobUrlRefCount",0),Pk([Rx(Ox.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),lL.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d".concat(this._useWorkerRendering?" (worker mode)":"")),lL.addSuccessEvent({key:512701})}})],vM.prototype,"create",1),Pk([Rx("created",Ox.INIT,{ignoreError:!0,sync:!0})],vM.prototype,"destroy",1);var yM=vM,EM=JO();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:EM,exposeOrigin:!0,permittedOrigins:["*"]})}catch(gk){}var bM=async function(e){let t=null,r=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:e.selfBrowserSurface||"include",surfaceSwitching:"include"},r={width:RO?{max:e.width}:{ideal:e.width,max:e.width},height:RO?{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:n=!1}=e;t.audio={echoCancellation:r,noiseSuppression:i,autoGainControl:n,sampleRate:48e3}}return t}(e);ZO.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r)));let i=await navigator.mediaDevices.getDisplayMedia(r);e.systemAudio&&0===i.getAudioTracks().length&&(wO&&TO<74||RO||kD)&&ZO.warn("Your browser not support capture system audio");let n=i.getVideoTracks()[0];if(n){if(e.frameRate)try{await n.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(a){ZO.warn("screen applyConstraints failed: ".concat(a))}e.captureElement&&await async function(e,t){var r;if("CropTarget"in window&&"fromElement"in CropTarget&&nC(e.cropTo))try{if((null==(r=e.getCaptureHandle())?void 0:r.handle)!==EM)return;let i=await CropTarget.fromElement(t);await e.cropTo(i)}catch(i){ZO.warn("cropTo target failed ".concat(i))}}(n,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 aC(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);ZO.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t=await navigator.mediaDevices.getUserMedia(r),i.addTrack(t.getAudioTracks()[0])}return i};Pk([zk(function(e){this.setContentHint(e.contentHint||"detail")})],class extends eM{constructor(e){super(e,2),Mk(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),Mk(this,"objectFit","contain"),Mk(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}get isShareCurrentTab(){var e,t;try{return EM===(null==(t=null==(e=this.mediaTrack)?void 0:e.getCaptureHandle())?void 0:t.handle)}catch(r){return}}async capture(e){let{systemAudio:t=!1,autoGainControl:r,echoCancellation:i,noiseSuppression:n,audioTrack:a,videoTrack:o,captureElement:s,preferDisplaySurface:c,selfBrowserSurface:l}=e;var d;try{let e,u=yC();return o||a?(e=new MediaStream,o&&e.addTrack(o),a&&e.addTrack(a)):(e=await bM({audio:!1,systemAudio:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,autoGainControl:r,echoCancellation:i,noiseSuppression:n,captureElement:s,preferDisplaySurface:c,selfBrowserSurface:l}),this.sourceTrack=e.getVideoTracks()[0]),await this.setInputMediaStreamTrack(e.getVideoTracks()[0]),qO.emit(KO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:yC()-u,profile:this.profile,room:null==(d=this.manager)?void 0:d.room}),e}catch(u){throw this.log.error("getDisplayMedia error observed ".concat(u)),u instanceof pR?u:new pR({code:uR.INITIALIZE_FAILED,name:u.name,message:u.message})}}async switchDevice(e){throw new Error("Method not implemented.")}}.prototype,"capture",1);var wM=class e extends tP{constructor(t,r,i){super({userId:r.userId,sdkAppId:t.sdkAppId,mediaType:i,room:t}),this.room=t,this.user=r,Mk(this,"tinyId"),Mk(this,"isRemote",!0),Mk(this,"jitterBufferDelay",0),Mk(this,"availableState"),Mk(this,"remotePublishState"),Mk(this,"_triggerCheckDecodeSubject",OP(xP(this,e.STATE_SUBSCRIBE))),Mk(this,"ignoreUpdatePlayingState"),this.tinyId=r.tinyId,this.availableState=new Ox("".concat(r.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new Ox("".concat(r.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),wP(DP(xP(this,Ox.STATECHANGED),xP(this.remotePublishState,Ox.STATECHANGED)),BP(()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing)),qP(e=>{this.availableState.state!==(e?Ox.ON:Ox.OFF)&&(this.availableState.state=e?Ox.ON:Ox.OFF),(!this.isRemotePublished||!this.ignoreUpdatePlayingState)&&this.updatePlayingState(e)}));let n=wP(xP(this.player,Bx.ERROR),NP(e=>e.code===MediaError.MEDIA_ERR_DECODE)),a=wP(function(e,t){return IP(r=>{let i=0,n=setTimeout(()=>{if(r.removeDefer(a),r.next(i++),t){let e=setInterval(()=>r.next(i++),t);r.defer(()=>{clearInterval(e)})}else r.complete()},e),a=()=>clearTimeout(n);r.defer(a)},"timer",arguments)}(5e3),NP(()=>!!(!this.ignoreDecodeError&&this.isSubscribed&&this.isPlayCalled&&this.stat.bytesReceived&&this.isRemotePublished)&&(!this.player.isPlaying&&!(this.kind===lA?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1)))),o=wP(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return IP(e=>{let r=new Map;t.forEach(t=>{let i=new EP(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)}(n,a),MP(xP(this,Ox.INIT)));wP(this._triggerCheckDecodeSubject,NP(()=>!this.ignoreDecodeError),GP(o),qP(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,r,i;return null!=(i=null==(r=null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.hadRecentBadDownlink)?void 0:r.call(t,2))&&i||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===Ox.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){var r,i;let n=this.kind===lA;if(lL[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),!n){let t=(null==(r=this.room)?void 0:r.downlinkVideoCodec.toUpperCase())||"H264";lL[e?"addSuccessEvent":"addFailedEvent"]({key:sL["DECODE_".concat(t,"_RESULT")]}),e||this.log.warn("".concat(null==(i=this.room)?void 0:i.downlinkVideoCodec," decode failed"))}e||(lL.addEnum({key:n?504701:514703,value:zO()}),jx.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(WO()||GO()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===lA?"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?Ox.ON:Ox.OFF,this.emit("remote-publish-changed",this.isRemotePublished)}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};Mk(wM,"STATE_SUBSCRIBE","subscribe"),Pk([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 Gk((r,i)=>function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return new Promise((n,o)=>{let s=setTimeout(()=>{let r=new pR({code:uR.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(e,"s")});(this.log||this._log||ZO).warn(r),2===t?o(r):1===t&&n()},1e3*e);this._checkPendingPromiseSet||(this._checkPendingPromiseSet=new Set),this._checkPendingPromiseSet.add(s),r.apply(this,a).then(n,o).finally(()=>{clearTimeout(s),this._checkPendingPromiseSet&&s&&this._checkPendingPromiseSet.delete(s)})})})}(5,1)],wM.prototype,"waitHasMediaTrack",1),Pk([Rx(Ox.INIT,wM.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),qO.emit(KO.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),pP(521716,!1)],wM.prototype,"subscribe",1),Pk([Rx(wM.STATE_SUBSCRIBE,Ox.INIT,{sync:!0,success(){this.log.info("unsubscribed"),qO.emit(KO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],wM.prototype,"unsubscribe",1);var IM=wM,TM=class extends nM{constructor(e,t,r,i,n){super(e,{useDefaultProgram:!0,useFbo:!0,name:"alpha",create2d:!0,logger:t}),this.setContainer=i,Mk(this,"initStat",{alphaStitchingType:1}),Mk(this,"end",OP()),Mk(this,"minSize",320),Mk(this,"maxSize",1280),Mk(this,"draggable",!1),Mk(this,"startDragX",0),Mk(this,"startDragY",0),Mk(this,"left",0),Mk(this,"top",0),Mk(this,"baseWidth",320),Mk(this,"baseRatio"),Mk(this,"container"),this.initStat=n,this.draggable=r,this.bindDragEvents(),lL.addEnum({key:515700,value:1}),this.draggable&&lL.addEnum({key:515700,value:11})}bindDragEvents(){let e=this.context._canvas;if(e)if(this.draggable){let t=MP(this.end);wP(xP(e,"mousedown"),KP(this.startDrag.bind(this)),jP(()=>wP(xP(window,"mousemove"),MP(xP(window,"mouseup")))),t,qP(this.doDrag.bind(this))),wP(xP(e,"dblclick"),t,qP(this.resetPosition.bind(this))),wP(xP(e,"wheel"),t,qP(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,n){var a;let{ctx2d:o}=this,s=this.context._canvas;if(!o||!s)return!1;let c=super.draw2d(e,t,r,i,n),l=o.getImageData(0,0,i,n),{data:d}=l,u=!1;if(1===this.initStat.alphaStitchingType){let e=Math.floor(i/2);for(let t=0;t<n;t++)for(let r=0;r<e;r++){let n=4*(t*i+r),a=4*(t*i+(r+e)),o=d[a];d[a+3]=0;let s=o>=100;d[n+3]=s?255:0}u=super.draw2d(l,0,0,0,0,e,n),s.width=e}else if(2===this.initStat.alphaStitchingType){let e=Math.floor(n/2);for(let t=0;t<e;t++)for(let r=0;r<i;r++){let n=4*(t*i+r),a=4*((t+e)*i+r),o=d[a];d[a+3]=0;let s=o>=100;d[n+3]=s?255:0}u=super.draw2d(l,0,0,0,0,i,e),s.height=e}return null==(a=this.context.ctx)||a.clearRect(0,0,i,n),c&&u}close(){this.baseRatio=void 0,this.end.next(),this.end.complete()}};var SM=class extends IM{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),Mk(this,"mediaType",4),Mk(this,"source"),Mk(this,"shouldRenderAlpha",!1),Mk(this,"alphaNode"),Mk(this,"shouldBeDraggable",!0),Mk(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0,keyFramesDecoded:0}),Mk(this,"_keyFrameCountLogged",!1),Mk(this,"_keyFrameStartTimestamp",0),Mk(this,"_keyFrameStartCount",0),Mk(this,"_keyFrameIntervals",[]),Mk(this,"_prevKeyFrameTimestamp",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 null!=t&&t.canvasRender&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then(()=>{this.player.calculateStat(),qO.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=Zk[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 yM({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 pM(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())},n=new TM(t,this.log,this.shouldBeDraggable,i,{alphaStitchingType:e});this.source.connect(n),n.connect(r),this.alphaNode=n}else this.source.connect(r);dx()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,t),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,r=function(e){return[15,30,45,60].reduce((t,r)=>Math.abs(r-e)<Math.abs(t-e)?r:t)}(t);!sC(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),qO.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)}updateKeyFramesDecoded(e){let t=this.stat.keyFramesDecoded||0;if(this.stat.keyFramesDecoded=e,this._keyFrameCountLogged)return;let r=Date.now();if(!this._keyFrameStartTimestamp)return this._keyFrameStartTimestamp=r,this._keyFrameStartCount=e,void(this._prevKeyFrameTimestamp=r);if(this._prevKeyFrameTimestamp&&e>t){let i=e-t,n=(r-this._prevKeyFrameTimestamp)/1e3/i;this._keyFrameIntervals.push(n)}this._prevKeyFrameTimestamp=r;let i=r-this._keyFrameStartTimestamp;if(i>=16e3){let t=e-this._keyFrameStartCount,r=t>0?i/1e3/t:0,n="".concat(t," keyframes in 16s ").concat(r," [").concat(this._keyFrameIntervals.map(e=>e.toFixed(1)).join(","),"] keyFramesDecoded ").concat(e),a=r<=2.5?"debug":"info";this.log[a](n),this._keyFrameCountLogged=!0}}},kM=new Map;function AM(e,t){let r=Dk(Ck({},t),{timestamp:fR()});kM.has(e)?kM.get(e).push(r):kM.set(e,[r])}qO.on(KO.JOIN_SUCCESS,e=>{let{room:t}=e;AM(t.userId,{eventId:32788})}),qO.on(KO.LEAVE_START,e=>{let{room:t}=e;AM(t.userId,{eventId:32789})}),qO.on(KO.LOCAL_TRACK_PUBLISHED,e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),AM(t.room.userId,{eventId:e})}}),qO.on(KO.LOCAL_TRACK_UNPUBLISHED,e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),AM(t.room.userId,{eventId:e})}}),qO.on(KO.TRACK_MUTED,e=>{let{track:t}=e;t.room&&(t.kind===lA?AM(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):AM(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))}),qO.on(KO.TRACK_UNMUTED,e=>{let{track:t}=e;t.room&&(t.kind===lA?AM(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):AM(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))}),qO.on(KO.REMOTE_TRACK_SUBSCRIBED,e=>{let{track:t}=e;t.room&&(1===t.mediaType&&AM(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&AM(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&AM(t.room.userId,{eventId:32803,remoteUserId:t.userId}))}),qO.on(KO.REMOTE_TRACK_UNSUBSCRIBED,e=>{let{track:t}=e;t.room&&(1===t.mediaType&&AM(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&AM(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&AM(t.room.userId,{eventId:32804,remoteUserId:t.userId}))}),qO.on(KO.SWITCH_DEVICE_SUCCESS,e=>{let{track:t}=e;t.room&&AM(t.room.userId,{eventId:t.kind===dA?32780:32781})}),qO.on(KO.LOCAL_TRACK_REPLACED,e=>{let{track:t}=e;t.room&&AM(t.room.userId,{eventId:t.kind===dA?32782:32783})}),qO.on(KO.SIGNAL_CONNECTION_STATE_CHANGED,e=>{let t,{room:r,prevState:i,state:n}=e;switch(n){case"CONNECTED":t="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":t=32794}t&&AM(r.userId,{eventId:t})}),qO.on(KO.PEER_CONNECTION_STATE_CHANGED,e=>{let t,{room:r,prevState:i,state:n,remoteUserId:a}=e,o=!!a;switch(n){case"CONNECTED":t="RECONNECTING"===i?o?32801:32798:o?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(t=o?32802:32799);break;case"RECONNECTING":t=o?32800:32797}t&&AM(r.userId,{eventId:t,remoteUserId:a})}),qO.on(KO.VIDEO_CODEC_IMPLEMENTATION_CHANGED,e=>{let{implementation:t,userId:r,remoteUserId:i,codec:n,isHWCodec:a,prevImplementation:o,streamType:s}=e,c=a?1:0;o||(c=a?3:2);let l={H264:0,H265:1,VP8:2}[n.toUpperCase()],d={eventId:4004,param1:c,param2:l,streamType:s||2};i&&(d.remoteUserId=i,d.eventId=4005),AM(r,d),lL.addEnum({key:i?514701:513701,value:c}),lL.addEnum({key:i?514700:513700,value:l})}),qO.on(KO.LOCAL_TRACK_RECAPTURE,e=>{let{track:t,error:r}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===lA?(e.streamType=1,r&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,r&&(e.param1=8)),AM(t.userId,e)}}),Nk(Bk(),1),Nk(Bk(),1);var RM="trtc_debug_dialog",CM="".concat(RM,"_activated"),DM="".concat(RM,"_switch"),OM="".concat(RM,"_mask"),LM="".concat(RM,"_panel"),xM="".concat(RM,"_tabber"),NM="".concat(RM,"_tab"),PM="".concat(RM,"_topbar"),MM="".concat(RM,"_toptab"),UM="".concat(RM,"_content"),BM="".concat(RM,"_has_topbar"),FM="".concat(UM,"_log"),VM="".concat(UM,"_network"),WM="".concat(RM,"_dump"),HM="".concat(VM,"_title"),jM="".concat(VM,"_basic"),zM="".concat(VM,"_local"),GM="".concat(VM,"_remote"),qM="".concat(WM,"_title"),KM="".concat(WM,"_local"),YM="".concat(WM,"_remote"),XM="".concat(YM,"_hook"),ZM="".concat(RM,"_banner"),JM="".concat(ZM,"_item"),QM="".concat(RM,"_toolbar"),$M="".concat(RM,"_tool"),eU="".concat(RM,"_item"),tU="".concat(eU,"_debug"),rU="".concat(eU,"_info"),iU="".concat(eU,"_warn"),nU="".concat(eU,"_error"),aU="".concat(RM,"_back_top"),oU="".concat(RM,"_go_bottom"),sU="".concat(WM,"_local_audio"),cU="".concat(WM,"_local_video_main"),lU="".concat(WM,"_local_video_aux"),dU="".concat(RM,"_tooltip"),uU="".concat(jM,"_network_info"),hU="".concat(jM,"_room_info"),pU="".concat(FM,"_controller"),fU="success",mU="warning",gU="failed",_U=0,vU=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(RM,'" class="').concat(RM,'"><div class="').concat(DM,'">Debug#').concat(++_U,'</div><div class="').concat(OM,'"></div><div class="').concat(LM,'"><div class="').concat(xM,'"><a class="').concat(NM," ").concat(CM,'" data-tab="log">').concat(FA,'</a><a class="').concat(NM,'" data-tab="network">').concat(VA,'</a><a class="').concat(NM,'" data-tab="dump">').concat(WA,'</a></div><div class="').concat(pU,'"><div data-type="back_top">').concat(ZA,'</div><div data-type="go_bottom">').concat(XA,'</div><div data-type="clear_log">').concat(JA,'</div></div><div class="').concat(PM,'"><a class="').concat(MM," ").concat(CM,'" data-type="all">All</a><a class="').concat(MM,'" data-type="debug">Debug</a><a class="').concat(MM,'" data-type="info">Info</a><a class="').concat(MM,'" data-type="warn">Warn</a><a class="').concat(MM,'" data-type="error">Error</a></div><div class="').concat(UM," ").concat(BM,'"><div class="').concat(FM,'"></div><div class="').concat(VM,'"><div class="').concat(HM,'">').concat(tR,'</div><div class="').concat(jM,'"><div class="').concat(hU,'"></div><div class="').concat(uU,'">').concat(eR,'</div></div><div class="').concat(HM,'">').concat(QA,'</div><div class="').concat(zM,'">').concat(eR,'</div><div class="').concat(HM,'">').concat($A,'</div><div class="').concat(GM,'">').concat(eR,'</div></div><div class="').concat(WM,'"><div class="').concat(qM,'">').concat(QA,'</div><div class="').concat(KM,'"><div id="').concat(sU,'"><span>').concat(nR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(HA,'</button><button class="dump-opus">').concat(jA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div><div id="').concat(cU,'"><span>').concat(iR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(WA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div><div id="').concat(lU,'"><span>').concat(aR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(WA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div></div><div class="').concat(qM,'">').concat($A,'</div><div class="').concat(YM,'"><div class="').concat(XM,"\">userId:<input id=\"dump-remote-video-hook-userid\" value='*' />duration:<input id=\"dump-remote-video-hook-duration\" min='1' value='0' 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(ZM,'"></div><div class="').concat(QM,'"><a id="trtc_upload" class="').concat($M,'">').concat(qA,'</a><a id="trtc_export" class="').concat($M,'">').concat(KA,'</a><a id="trtc_hide" class="').concat($M,'">').concat(YA,"</a></div></div></div>"),null==(e=this.shadowRoot)||e.appendChild(t.content.firstChild)}addStyle(){var e;let t=document.createElement("style");t.textContent="#".concat(RM,"{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(RM," a,.").concat(DM,"{cursor:pointer;}.").concat(RM,"{color:black;}.").concat(DM,"{display:block;position:fixed;right:50px;bottom:").concat(150+50*_U,"px;border-radius:5px;background-color:#07c160;color:#fff;padding:5px 10px;z-index:10000;}.").concat(OM,"{display:none;position:fixed;left:0;top:0;right:0;bottom:0;z-index:10001;background-color:rgb(0,0,0,0.6);}.").concat(LM,"{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(LM,"{left:0;}}.").concat(xM,"{display:flex;height:2em;border-bottom:1px solid var(--DD-BORDER);}.").concat(NM,"{padding:0 20px;border-right:1px solid rgba(0,0,0,0.1);line-height:2em;color:black;}.").concat(NM,".").concat(CM,"{background-color:var(--DD-BG-2);}.").concat(NM,".disabled{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(PM,"{height:2em;display:flex;flex-direction:row;}.").concat(MM,"{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(MM,".").concat(CM,"{border-bottom:1px solid #1485ee;background-color:var(--DD-BG-2);}.").concat(UM,"{background-color:#fff;position:absolute;left:0;right:0;top:2em;bottom:8em;overflow-y:scroll;overflow-x:hidden;}.").concat(UM,".").concat(BM,"{top:4em;bottom:10em}.").concat(VM,"{display:none;}.").concat(WM,"{display:none;}.").concat(HM,",.").concat(qM,"{line-height:2em;text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat(jM,",.").concat(zM,",.").concat(GM,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(KM,",.").concat(YM,"{display:flex;flex-direction:column;padding:0.5em 0;justify-content:center;align-items:center;}.").concat(KM," div input{margin:0 10px;height:1.5em;width:4em;}.").concat(KM," div {padding:10px 0;border-radius:5px;}.").concat(KM," div button,.").concat(YM," div button {cursor:pointer;height:1.8em;border-radius:5px;margin-right:5px;}.").concat(KM," div button[disabled],.").concat(YM," div button[disabled]{cursor:not-allowed;}.").concat(YM," select {height:1.8em;margin:0 10px;}.").concat(YM," div input{margin:0 10px;height:1.5em;width:4em;}.").concat(XM," {line-height:3em;padding:0.5em;}.").concat(HM,"{text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat(jM,",.").concat(zM,",.").concat(GM,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(eU,"{border-bottom:1px solid var(--DD-BG-0);padding:5px 10px;overflow-wrap: break-word;}.").concat(nU,"{color:var(--DD-ERROR);background-color:var(--DD-ERROR-BG);}.").concat(iU,"{color:var(--DD-WARN);background-color:var(--DD-WARN-BG);}div .").concat(rU,"{color:var(--DD-INFO);}.").concat(tU,"{color:var(--DD-DEBUG);}.").concat(ZM,"{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(JM,"{border-bottom:1px solid var(--DD-BORDER);padding:5px 10px;overflow-wrap: break-word;}.").concat(QM,"{position:absolute;line-height:2em;display:flex;flex-direction:row;left:0;right:0;bottom:0;}.").concat($M,"{flex:1;color:black;text-align:center;background-color:#ededed;border-right:1px solid var(--DD-BORDER);}#").concat(RM," .").concat(aU,",#").concat(RM," .").concat(oU,"{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(oU,"{bottom:9em;}.").concat(aU,"{bottom:11.5em;}#").concat(RM," .").concat($M,".disable{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(dU," {position:relative;display:inline-block;}.").concat(dU," .tooltiptext{visibility:hidden;width:180px;background-color:black;color:#fff;text-align:center;padding:5px 0;border-radius:6px;position:absolute;}.").concat(dU," .tooltip-top {bottom:125%;left:50%;margin-left:-90px;}.").concat(dU,":hover .tooltiptext{visibility:visible;}.").concat(pU,"{position:absolute;left:0;right:0;bottom:8em;height:2em;display:flex;align-items:center;}.").concat(pU," 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",vU);var yU=class{constructor(e,t){Mk(this,"_dialogNode",null),Mk(this,"_switchNode",null),Mk(this,"_maskNode",null),Mk(this,"_panelNode",null),Mk(this,"_logContentNode",null),Mk(this,"_networkContentNode",null),Mk(this,"_dumpContentNode",null),Mk(this,"_tabNodes",[]),Mk(this,"_toptabNodes",[]),Mk(this,"_hasMove",!1),Mk(this,"_showDialog",!1),Mk(this,"_isMobile",!1),Mk(this,"_showLogType","all"),Mk(this,"prevBytesSent",0),Mk(this,"prevBytesReceived",0),Mk(this,"_core"),Mk(this,"_log"),Mk(this,"_logList",[]),Mk(this,"isUploading",!1),Mk(this,"publishMap",new Map),Mk(this,"dumpLocalVideoMap",{}),Mk(this,"dumpRemoteVideoMap",{}),Mk(this,"dumpLocalAudioMap",{}),Mk(this,"dumpRemoteAudioMap",{}),Mk(this,"eventMap",new Map),Mk(this,"switchPos",{x:0,y:0,startX:0,startY:0,endX:0,endY:0,isTouchEnd:!1}),Mk(this,"handleLeaveSuccess",e=>{let{room:t}=e;var r,i;if(!this.hitTest(t))return;let n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(YM));for(let a of this.publishMap.values())null==n||n.removeChild(a);this.publishMap.clear()}),Mk(this,"handleJoinSuccess",e=>{let{room:t}=e;var r,i;if(!this.hitTest(t))return;(null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(hU))).innerHTML="sdkAppId: ".concat(t.sdkAppId,"<br/>roomId: ").concat(t.roomId,"<br/>userId: ").concat(t.userId,"<br/>")}),Mk(this,"handleRemoteVideoAvailable",e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"publish")}),Mk(this,"handleRemoteVideoUnavailable",e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"unpublish")}),Mk(this,"handleRemoteAudioAvailable",e=>{this.renderDumpTab(e.userId,"remote","audio","publish")}),Mk(this,"handleRemoteAudioUnavailable",e=>{this.renderDumpTab(e.userId,"remote","audio","unpublish")}),Mk(this,"renderDumpTab",(e,t,r,i)=>{var n,a,o;let s={main:"video",auxiliary:"screen",audio:"audio"},c=(e,t)=>{var r,i,n;let a=document.createElement("div");a.innerText="".concat(e," - ").concat(s[t]," - ").concat(rR,"(s):");let o=document.createElement("input");o.type="number",o.min="0",o.value="10",o.id="dump_remote_".concat(t,"_").concat(e);let c,l=document.createElement("button");l.innerText=GA,l.disabled=!0,"audio"===t&&(c=document.createElement("button"),c.innerText=jA,c.style.marginLeft="5px");let d,u,h=document.createElement("button");if(h.innerText="audio"===t?HA:WA,h.onclick=()=>{let r,i,n=Number(o.value);if("audio"===t)({download:r,onDumpEnd:i}=this.dumpAudio("remote",n,e));else{if(!this.isSupportDumpVideo())return;({download:r,onDumpEnd:i}=this.dumpVideo(t,"remote",n,e))}r&&(this.inactiveButton(h,zA),c&&this.inactiveButton(c),n>0?setTimeout(()=>{null==r||r(),this.activeButton(h,WA),c&&this.activeButton(c,jA)},1e3*n):(this.activeButton(l),l.onclick=()=>{l.onclick=null,null==r||r(),null==i||i(),this.activeButton(h,WA),c&&this.activeButton(c,jA),this.inactiveButton(l)}))},c&&(c.onclick=()=>{let t=Number(o.value),{download:r,onDumpEnd:i}=this.dumpAudioFromPipeline("remote",t,e);r&&(this.inactiveButton(c,zA),this.inactiveButton(h),t>0?setTimeout(()=>{null==r||r(),this.activeButton(c,jA),this.activeButton(h,WA)},1e3*t):(this.activeButton(l),l.onclick=()=>{l.onclick=null,null==r||r(),null==i||i(),this.activeButton(c,jA),this.activeButton(h,WA),this.inactiveButton(l)}))}),"audio"!==t&&(d=document.createElement("button"),d.innerText="Dump w/ Audio",d.style.marginLeft="5px",d.onclick=()=>{if(!this.isSupportDumpVideo())return;let r=Number(o.value),i=this.dumpVideo(t,"remote",r,e),n=this.dumpAudioFromPipeline("remote",r,e);if(!i.download&&!n.download)return;let a=async()=>{var r,a,o,s;let c=new lR.default,l=this.dumpRemoteVideoMap["".concat(e,"-").concat(t)];if(l&&l.data.length>0){let r,i="h264",n=this.getVideoCodec(e);if("vp8"===n){let n=this._core.room.remotePublishedUserMap.get(e),a="main"===t?null==n?void 0:n.remoteVideoTrack:null==n?void 0:n.remoteAuxiliaryTrack;this.addInfoToBanner(mU,"package vp8 into ivf format"),r=this.convertVP8ToIVF(l.data,a),i="ivf"}else r=new Blob(l.data),i=n||"h264";let a="remote-".concat(e,"_").concat(t,"_").concat(this.formatStartDumpTime(l.startTimestamp),".").concat(i);c.file(a,r)}let d=this.dumpRemoteAudioMap["".concat(e)];if(d&&d.data.length>0){let t,i=(null==(a=null==(r=this._core.room.userManager)?void 0:r.getPublishedUser(e))?void 0:a.audioCodec)||"opus",n=i;"opus"===i?(this.addInfoToBanner(mU,"package opus to ogg"),t=this.convertOpusToOgg(d.data),n="ogg"):t=new Blob(d.data);let o="remote-".concat(e,"_audio_").concat(this.formatStartDumpTime(d.startTimestamp),".").concat(n);c.file(o,t)}let u=await c.generateAsync({type:"blob"}),h=URL.createObjectURL(u),p=document.createElement("a");p.href=h,p.download="dump_".concat(e,"_").concat(this.formatStartDumpTime(Date.now()),".zip"),p.style.display="none",document.body.appendChild(p),p.click(),URL.revokeObjectURL(h),document.body.removeChild(p),null==(o=i.onDumpEnd)||o.call(i),null==(s=n.onDumpEnd)||s.call(n),this.addInfoToBanner(fU,"Dump success, file name is: ".concat(p.download))};this.inactiveButton(d,zA),this.inactiveButton(h),r>0?setTimeout(()=>{a(),this.activeButton(d,"Dump w/ Audio"),this.activeButton(h,WA)},1e3*r):(this.activeButton(l),l.onclick=()=>{l.onclick=null,a(),this.activeButton(d,"Dump w/ Audio"),this.activeButton(h,WA),this.inactiveButton(l)})}),"audio"!==t){u=document.createElement("button"),u.innerText="Preview",u.style.whiteSpace="Pre";let r=document.createElement("video");document.body.appendChild(r),r.id="".concat(RM,"_preview_remote_").concat(t,"_").concat(e),r.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 ",u.onclick=async()=>{var i;if(r.style.display="none"===r.style.display?"":"none",u&&(u.innerText="none"===r.style.display?"Preview":" Hide "),!r.srcObject){let n=this._core.room.remotePublishedUserMap.get(e);if(n){let e=null==(i=n["main"===t?"remoteVideoTrack":"remoteAuxiliaryTrack"])?void 0:i.mediaTrack;e?(r.srcObject=new MediaStream([e]),await r.play()):this.addInfoToBanner(gU,"failed to preview, remote video track is not available")}}}}a.appendChild(o),a.appendChild(h),c&&a.appendChild(c),d&&a.appendChild(d),a.appendChild(l),u&&a.appendChild(u),a.style.cssText="padding:10px;";let p=document.createElement("div");return p.style.cssText="width:100%;display:flex;justify-content:center;border-top: 1px solid var(--DD-BORDER);",p.appendChild(a),null==(n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(YM)))||n.appendChild(p),p};if("remote"===t)if("publish"===i){let i=c(e,r);this.publishMap.set("".concat(e,"-").concat(t,"-").concat(r),i)}else{let i=this.publishMap.get("".concat(e,"-").concat(t,"-").concat(r));if(!i)return;null==(o=null==(a=null==(n=this._dialogNode)?void 0:n.shadowRoot)?void 0:a.querySelector(".".concat(YM)))||o.removeChild(i);let s=document.querySelector("#".concat(RM,"_preview_remote_").concat(r,"_").concat(e));s&&document.body.removeChild(s),this.publishMap.delete("".concat(e,"-").concat(t,"-").concat(r))}}),Mk(this,"handleStatistics",e=>{var t,r,i,n,a,o;let s=(e.bytesSent-this.prevBytesSent)/2,c=(e.bytesReceived-this.prevBytesReceived)/2;this.prevBytesSent=e.bytesSent,this.prevBytesReceived=e.bytesReceived,(null==(r=null==(t=this._dialogNode)?void 0:t.shadowRoot)?void 0:r.querySelector(".".concat(uU))).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==(n=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:n.querySelector(".".concat(zM)),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(eR):d;let u=null==(o=null==(a=this._dialogNode)?void 0:a.shadowRoot)?void 0:o.querySelector(".".concat(GM)),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(eR):h}),Mk(this,"pad",e=>e<10?"0".concat(e):"".concat(e)),this._core=e,this._log=t,this.initCustomElements(),this.synchronizeLog(),this.installEvents(),this.addVideoProcessor(),this.addAudioProcessor(),window["__trtc_instance_".concat(_U,"__")]=this._core.trtc}initCustomElements(){this._isMobile=(()=>{let e=window.navigator&&window.navigator.userAgent||"",t=/iPad/i.test(e)||/iPhone/i.test(e),r=/Android/i.test(e);return t||r})();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(DM)),this._addEventListener(this._switchNode,"click",this.onSwitchClick.bind(this));let r=getComputedStyle(this._switchNode);this.switchPos.x=parseInt(r.right,10)||50,this.switchPos.y=parseInt(r.bottom,10)||100+50*_U,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(OM)),this._addEventListener(this._maskNode,"click",this.onMaskClick.bind(this)),this._panelNode=t.querySelector(".".concat(LM)),t.querySelector(".".concat(pU)).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(FM)),this._networkContentNode=t.querySelector(".".concat(VM)),this._dumpContentNode=t.querySelector(".".concat(WM)),this._tabNodes=Array.from(t.querySelector(".".concat(xM)).children),this._tabNodes.forEach(e=>{this._addEventListener(e,"click",this.onTabClick.bind(this))}),this._toptabNodes=Array.from(t.querySelector(".".concat(PM)).children),this._toptabNodes.forEach(e=>{this._addEventListener(e,"click",this.onToptabClick.bind(this))});let i=t.querySelector("#trtc_upload");this._addEventListener(i,"click",this.onUploadClick.bind(this));let n=t.querySelector("#trtc_export");this._addEventListener(n,"click",this.onExportClick.bind(this));let a=t.querySelector("#trtc_hide");this._addEventListener(a,"click",this.onHideClick.bind(this));let o=t.querySelector("#".concat(cU," .dump")),s=t.querySelector("#".concat(cU," .end-dump")),c=Number(t.querySelector("#".concat(cU," input")).value);this._addEventListener(o,"click",this.getDumpButtonClickHandler.bind(this,o,s,c,"main","local"));let l=t.querySelector("#".concat(lU," .dump")),d=t.querySelector("#".concat(lU," .end-dump")),u=Number(t.querySelector("#".concat(lU," input")).value);this._addEventListener(l,"click",this.getDumpButtonClickHandler.bind(this,l,d,u,"auxiliary","local"));let h=t.querySelector("#".concat(sU," .dump")),p=t.querySelector("#".concat(sU," .dump-opus")),f=t.querySelector("#".concat(sU," .end-dump"));this._addEventListener(h,"click",()=>{let e=Number(t.querySelector("#".concat(sU," input")).value),{download:r,onDumpEnd:i}=this.dumpAudio("local",e);r?(this.inactiveButton(h,zA),this.inactiveButton(p),e>0?setTimeout(()=>{r(),this.activeButton(h,HA),this.activeButton(p,jA)},1e3*e):(this.activeButton(f),f.onclick=()=>{f.onclick=null,r(),null==i||i(),this.activeButton(h,HA),this.activeButton(p,jA),this.inactiveButton(f)})):this.addInfoToBanner(gU,"Failed to dump, please check if the current user has started the audio")}),this._addEventListener(p,"click",()=>{let e=Number(t.querySelector("#".concat(sU," input")).value),{download:r,onDumpEnd:i}=this.dumpAudioFromPipeline("local",e);r?(this.inactiveButton(p,zA),this.inactiveButton(h),e>0?setTimeout(()=>{r(),this.activeButton(p,jA),this.activeButton(h,HA)},1e3*e):(this.activeButton(f),f.onclick=()=>{f.onclick=null,r(),null==i||i(),this.activeButton(p,jA),this.activeButton(h,HA),this.inactiveButton(f)})):this.addInfoToBanner(gU,"Failed to dump opus, please check if the current user has started the audio")});let m=t.querySelector("#dump-remote-video-hook-userid"),g=t.querySelector("#dump-remote-video-hook-duration"),_=t.querySelector("#dump-remote-video-hook-mediaType"),v=t.querySelector("#dump-remote-video-hook-button");v.onclick=()=>{let e=Number(g.value);if(e<1)return void this.addInfoToBanner(gU,"duration at least 1s");let t=m.value;if(!t)return void this.addInfoToBanner(gU,"please input user id");"*"===t&&this.inactiveButton(v);let r,i,n=_.value,a="remote_".concat(t,"_").concat("sub"===n?"auxiliary":n),o=a=>{if((a.userId===t||"*"===t)&&a.streamType===n){if(this.addInfoToBanner(fU,"[".concat(a.userId,"_").concat(n,"] starting to dump video, duration: ").concat(e,"s")),({download:r,onDumpEnd:i}=this.dumpVideo("sub"===a.streamType?"auxiliary":a.streamType,"remote",e,a.userId)),!r)return;setTimeout(()=>{null==r||r(),null==i||i(),"*"!==t&&this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,o)},1e3*e)}};this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,o),this.addInfoToBanner(fU,"[".concat(a,"] 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(gU,"Current browser does not support dumping video"),!1)}_addEventListener(e,t,r,i){e&&(e.addEventListener(t,r,i),this.eventMap.set(e,{type:t,listener:r}))}_removeEventListener(){this.eventMap.forEach((e,t)=>{let{type:r,listener:i}=e;t&&t.removeEventListener(r,i)}),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.removeVideoProcessor(),this.removeAudioProcessor(),this._dialogNode&&(document.body.removeChild(this._dialogNode),this._dialogNode=null)}updateLog(e){var t;this._logList.push(e);let r=document.createElement("div");switch(r.classList.add(eU),e.level){case 4:r.classList.add(nU);break;case 2:r.classList.add(rU);break;case 3:r.classList.add(iU);break;case 1:r.classList.add(tU)}r.textContent=e.log,"all"!==this._showLogType&&!r.classList.contains("".concat(eU,"_").concat(this._showLogType))&&(r.style.display="none"),null==(t=this._logContentNode)||t.appendChild(r),this.addHelper(r)}getDumpButtonClickHandler(e,t,r,i,n){if(!this.isSupportDumpVideo())return;let{download:a,onDumpEnd:o}=this.dumpVideo(i,n,r);if(a)return this.addInfoToBanner(fU,"[".concat(n,"_").concat(i,"] starting to dump...")),this.inactiveButton(e,zA),void(r>0?setTimeout(()=>{a(),this.activeButton(e,WA)},1e3*r):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==o||o(),a(),this.activeButton(e,WA),this.inactiveButton(t)}));this.addInfoToBanner(fU,"[".concat(n,"_").concat(i,"] waiting to dump..."));let s=a=>{let{track:o}=a;if(o.room===this._core.room&&o.streamType===i){this.addInfoToBanner(fU,"[".concat(n,"_").concat(i,"] starting to dump")),"local"===n&&this._core.innerEmitter.off("104",s);let{download:a,onDumpEnd:o}=this.dumpVideo(i,n,r);if(!a)return;r>0?setTimeout(()=>{a(),this.activeButton(e,WA)},1e3*r):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==o||o(),a(),this.activeButton(e,WA),this.inactiveButton(t)})}};s.bind(this),"local"===n&&this._core.innerEmitter.on("104",s),this.inactiveButton(e,zA)}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,r,i,n,a,o,s;let c=e.target;null==(t=this._tabNodes)||t.forEach(e=>{e.classList.remove(CM)}),c.classList.add(CM);let l=c.getAttribute("data-tab");"log"===l?(null==(n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(UM)))||n.classList.add(BM),this._logContentNode.style.display="block",this._networkContentNode.style.display="none",this._dumpContentNode.style.display="none",this.logContentGoBottom()):(null==(s=null==(o=null==(a=this._dialogNode)?void 0:a.shadowRoot)?void 0:o.querySelector(".".concat(UM)))||s.classList.remove(BM),"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,r;let i=e.target;null==(t=this._toptabNodes)||t.forEach(e=>{e.classList.remove(CM)}),i.classList.add(CM),this._showLogType=i.getAttribute("data-type");let n=null==(r=this._logContentNode)?void 0:r.querySelectorAll(".".concat(eU)),a="".concat(eU,"_").concat(this._showLogType);n.forEach(e=>{e.classList.contains(a)||"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"}),r=document.createElement("a"),i=URL.createObjectURL(t);r.href=i;let n="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");r.download=n,r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(i),document.body.removeChild(r),this.addInfoToBanner(fU,"Export success: The log file name is ".concat(n)),this._core.kvStatManager.addSuccessEvent({key:592703})}addInfoToBanner(e,t){var r,i;let n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(ZM)),a=document.createElement("div");a.classList.add(JM);let o=e===fU?"🟩":e===mU?"🟧":"🟥";a.innerText="".concat(o," [").concat(this.getCurrentTime(),"] ").concat(t),n.appendChild(a),n.scrollTop=n.scrollHeight}async onUploadClick(){var e,t;if(this.isUploading)return;this.isUploading=!0;let r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector("#trtc_upload");r.innerText="Uploading...",null==r||r.classList.add(".disable");let i=this._logList.reduce((e,t)=>"".concat(e+t.log,"\n"),""),n=new Blob([i],{type:"text/plain"}),a=new FormData;a.append("file",n,"trtc.log"),a.append("sdkAppId","".concat(this._core.room.sdkAppId||"EmptySdkAppId")),a.append("userId","".concat(this._core.room.userId||"EmptyUserId")),fetch("https://service.trtc.qcloud.com/api/uploadLogFile",{method:"POST",body:a}).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(gU,"Upload Failed: Please use local export"),this._log.info("Upload Failed: Please use local export"),this._core.kvStatManager.addFailedEvent({key:592704})}).finally(()=>{r.innerText=qA,null==r||r.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,r;null==(r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(UM)))||r.scrollTo(0,0)}onGoBottomClick(){this.logContentGoBottom()}onClearLogClick(){this._logList=[],this._logContentNode&&(this._logContentNode.innerHTML="")}logContentGoBottom(){var e,t;let r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(UM));null==r||r.scrollTo(0,null==r?void 0:r.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),r=this.switchPos.y-(e.pageY-this.switchPos.startY);[t,r]=this.getSafeAreaXY(t,r),this._switchNode.style.right="".concat(t,"px"),this._switchNode.style.bottom="".concat(r,"px"),this.switchPos.endX=t,this.switchPos.endY=r}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,r=e.touches[0].pageY-this.switchPos.startY,i=Math.floor(this.switchPos.x-t),n=Math.floor(this.switchPos.y-r);[i,n]=this.getSafeAreaXY(i,n),this._switchNode.style.right="".concat(i,"px"),this._switchNode.style.bottom="".concat(n,"px"),this.switchPos.endX=i,this.switchPos.endY=n,this.switchPos.isTouchEnd=!0,e.cancelable&&e.preventDefault()}getSafeAreaXY(e,t){let r=Math.max(document.documentElement.offsetWidth,window.innerWidth),i=Math.max(document.documentElement.offsetHeight,window.innerHeight);return e+this._switchNode.offsetWidth>r&&(e=r-this._switchNode.offsetWidth),t+this._switchNode.offsetHeight>i&&(t=i-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",r=this.dumpLocalVideoMap[t];r&&(r.data.push(e.data),r.duration>0&&Date.now()-r.startTimestamp>1e3*r.duration&&r.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,r=cR,i=e.innerText;i=i.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 r=e.match(t);return null==r||r.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"),r.forEach(t=>{if(e.innerText.includes(t)){let r="";r="function"==typeof oR[t].tips?oR[t].tips(e.innerText):oR[t].tips,i=i.replace(new RegExp("".concat((e=>e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(">","&gt;").replace(">","&lt;"))(t)),"gi"),'<span class="'.concat(dU,'" style="background:').concat(oR[t].color||"#e1dfdf","; color: ").concat(oR[t].textColor||"#000",'">').concat(t,'\n <span class="tooltiptext tooltip-top">').concat(r,"</span>\n </span>"))}}),e.innerHTML=i}getCurrentTime(){let e=new Date,t=this.pad(e.getHours()),r=this.pad(e.getMinutes()),i=this.pad(e.getSeconds());return"".concat(t,":").concat(r,":").concat(i)}dumpAudioFromPipeline(e,t,r){this.addInfoToBanner(mU,"dump audio from pipeline");let i=Date.now(),n=this.formatStartDumpTime(i),a=[],o="".concat(e,"_").concat(r);if("local"===e)this._core.trtc._localAudioTrack;else if(r){let e=this._core.room.remotePublishedUserMap.get(r);e&&e.remoteAudioTrack}let s;if("local"===e){if(!this.hasLocalTrack("main","audio"))return{};s=()=>{delete this.dumpLocalAudioMap.main},this.dumpLocalAudioMap.main={startTimestamp:i,data:a,duration:t,onDumpEnd:s}}if("remote"===e&&r){if(s=()=>{delete this.dumpRemoteAudioMap["".concat(r)]},this.dumpRemoteAudioMap["".concat(r)])return this.addInfoToBanner(mU,"[".concat(o,"] dump already exists.")),{};this.dumpRemoteAudioMap["".concat(r)]={startTimestamp:i,data:a,duration:t,onDumpEnd:s}}return{download:()=>{var t,i;if(0===a.length)return void this.addInfoToBanner(gU,"[".concat(o,"] dump failed. Reason: data is empty"));let s,c=("local"===e?null==(t=this._core.room.singlePC)?void 0:t.audioCodec:null==(i=this._core.room.userManager)?void 0:i.getPublishedUser(r).audioCodec)||"opus",l=c;"opus"===c?(this.addInfoToBanner(mU,"[".concat(o,"] package opus to ogg")),s=this.convertOpusToOgg(a),l="ogg"):s=new Blob(a);let d=URL.createObjectURL(s),u=document.createElement("a"),h="local"===e?"local_".concat(n,".").concat(l):"remote-".concat(r,"_").concat(n,".").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(fU,"[".concat(o,"] dump success. File name is: ").concat(h))},onDumpEnd:s}}dumpVideo(e,t,r,i){let n,a=Date.now(),o=this.formatStartDumpTime(a),s=[],c="".concat(t,"_").concat(i,"_").concat(e);if("local"===t)n="main"===e?this._core.trtc._localVideoTrack:this._core.trtc._localScreenTrack;else if(i){let t=this._core.room.remotePublishedUserMap.get(i);t&&(n="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:a,data:s,duration:r,onDumpEnd:l}}if("remote"===t&&i){if(l=()=>{delete this.dumpRemoteVideoMap["".concat(i,"-").concat(e)]},this.dumpRemoteVideoMap["".concat(i,"-").concat(e)])return this.addInfoToBanner(mU,"[".concat(c,"] dump already exists.")),{};this.dumpRemoteVideoMap["".concat(i,"-").concat(e)]={startTimestamp:a,data:s,duration:r,onDumpEnd:l}}return{download:()=>{var r,a;if(0===s.length)return void this.addInfoToBanner(gU,"[".concat(c,"] dump failed. Reason: data is empty"));let l,d;"main"===e?l="video":"auxiliary"===e&&(l="screen"),"vp8"===this.getVideoCodec(i||"")?(this.addInfoToBanner(mU,"[".concat(c,"] package vp8 into ivf format")),d=this.convertVP8ToIVF(s,n)):d=new Blob(s);let u=URL.createObjectURL(d),h=document.createElement("a"),p="local"===t?"local_".concat(l,"_").concat(o,".").concat((null==(r=this._core.room.singlePC)?void 0:r.videoCodec)||"h264"):"remote-".concat(i,"_").concat(l,"_").concat(o,".").concat((null==(a=this._core.room.userManager)?void 0:a.getPublishedUser(i).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(fU,"[".concat(c,"] dump success. File name is: ").concat(p))},onDumpEnd:l}}convertVP8ToIVF(e,t){var r,i,n;function a(e,t,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}let o=e.reduce((e,t)=>e+12+t.byteLength,32),s=new ArrayBuffer(o),c=new DataView(s),l=new Uint8Array(s),d=0;a(c,d,"DKIF"),d+=4,c.setUint16(d,0,!0),d+=2,c.setUint16(d,32,!0),d+=2,a(c,d,"VP80"),d+=4,c.setUint16(d,(null==(r=null==t?void 0:t._inputTrack)?void 0:r.getSettings().width)||0,!0),d+=2,c.setUint16(d,(null==(i=null==t?void 0:t._inputTrack)?void 0:i.getSettings().height)||0,!0),d+=2;let u=(t instanceof SM?null==t?void 0:t.decodeFPS:null==(n=null==t?void 0:t.mediaTrack)?void 0:n.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 r=e.byteLength,i=Math.floor(1e6*t/u);c.setUint32(d,r,!0),d+=4,c.setFloat64(d,i,!0),d+=8,l.set(new Uint8Array(e),d),d+=r}),new Blob([s],{type:"application/octet-stream"})}getVideoCodec(e){var t,r;return""===e?null==(t=this._core.room.singlePC)?void 0:t.videoCodec:null==(r=this._core.room.remotePublishedUserMap.get(e))?void 0:r.videoCodec}hasLocalTrack(e,t){for(let r of this._core.room.localTracks)if(r.streamType===e&&r.kind===t)return!0;return!1}dumpAudio(e,t,r){var i,n,a;let o,s,c=null,l=[],d=[],u=[],h=[],p=[],f=[],m=[],g=new AbortController,_=Date.now(),v=this.formatStartDumpTime(_),y=this._core.room.audioManager._localAudioPipline,E=this._core.room.audioManager._localScreenAudioPipeline,b=e=>{let{room:t,data:r,type:i}=e;if(this.hitTest(t)){if("dump"===i){if(h[0]=h[0]?h[0].concat(r.captureInput):r.captureInput,h[1]=h[1]?h[1].concat(r.playInput):r.playInput,o){let e=r.startTime-o,t=r.endTime-r.startTime;if(e>30||t>30){let i=function(e){if("number"!=typeof e||e<0)return"0毫秒";let t=[],r=Math.floor(e/6e4),i=e%6e4;r>0&&t.push("".concat(r,"分"));let n=Math.floor(i/1e3);return i%=1e3,(n>0||t.length)&&t.push("".concat(n,"秒")),(i>0||!t.length)&&t.push("".concat(i,"毫秒")),t.join("")},n=r.startTime-s,a=o-s;m.push("".concat(r.startTime,"\t").concat(i(n),"~").concat(i(a),"\t").concat(e,"\t").concat(t))}o=r.startTime}else o=r.startTime,s=r.startTime;f.push(r.startTime)}"dump-screen-audio"===i&&(p[0]=p[0]?p[0].concat(r.captureInput):r.captureInput,p[1]=p[1]?p[1].concat(r.playInput):r.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!=y&&y.source.node&&(l.push(y.source.node),d.push("local_audio_raw_capture-".concat(e,"-").concat(y.source.node.channelCount))),(null!=(i=null==y?void 0:y.aec)&&i.node||null!=E&&E.aec.node)&&(this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!0}),this._core.innerEmitter.on("265",b),null!=(n=null==y?void 0:y.aec)&&n.node&&(l.push(y.aec.node),d.push("local_audio_audioProcessor_processed-".concat(e,"-").concat(y.aec.node.channelCount))),null!=E&&E.aec.node&&(l.push(E.aec.node),d.push("screen_audio_audioProcessor_processed-".concat(e,"-").concat(E.aec.node.channelCount)))),null!=y&&y.denoiser.node&&(l.push(y.denoiser.node),d.push("local_audio_denoiser_processed-".concat(e,"-").concat(y.denoiser.node.channelCount))),this._core.room.audioManager.mixWeight>1&&null!=y&&y.stream){let t=this._core.room.audioManager.audioContext.createMediaStreamSource(y.stream);t.channelCount=1,l.push(t),d.push("local_audio_destination-".concat(e,"-").concat(t.channelCount))}}else if("remote"===e&&void 0!==r){let e=null==(a=this._core.room.remotePublishedUserMap.get(r))?void 0:a.remoteAudioTrack;if(null==e||!e.mediaTrack)return{};let t=this._core.createAudioNode(e.mediaTrack);l.push(t),d.push("remote_".concat(r))}let w=async()=>{var t,r,i,n,a;let o=new lR.default;for(let e=0;e<d.length;e++)o.file("".concat(d[e],".pcm"),new Blob(u[e]));if(null!=(t=null==h?void 0:h[0])&&t.length&&o.file("audioProcessor_input_capture.pcm",new Blob(h[0])),null!=(r=null==h?void 0:h[1])&&r.length&&o.file("audioProcessor_input_playback.pcm",new Blob(h[1])),null!=(i=null==p?void 0:p[0])&&i.length&&o.file("audioProcessor_screen_audio_input_capture.pcm",new Blob(p[0])),null!=(n=null==p?void 0:p[1])&&n.length&&o.file("audioProcessor_screen_audio_input_playback.pcm",new Blob(p[1])),null!=f&&f.length){let e=f.reduce((e,t)=>"".concat(e,"\n").concat(t));o.file("audioProcessor_handle_timestamp.txt",new Blob([e]))}if(null!=m&&m.length){let e=m.reduce((e,t)=>"".concat(e,"\n").concat(t));o.file("audioProcessor_big_gap_data.txt",new Blob([e]))}let s=await o.generateAsync({type:"blob"}),l=URL.createObjectURL(s),_=document.createElement("a");_.href=l,_.download="".concat(e,"-audio-").concat(v,".zip"),_.style.display="none",document.body.appendChild(_),_.click(),URL.revokeObjectURL(l),_.remove(),this.addInfoToBanner(fU,"Dump success, file name is: ".concat(e,"-").concat(v,".zip")),this._core.innerEmitter.off("265",b),(null!=(a=null==y?void 0:y.aec)&&a.node||null!=E&&E.aec.node)&&this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!1}),c&&clearTimeout(c),g.abort("download")};return t>0&&(c=Number(setTimeout(()=>{g.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]]})}}),g).catch(()=>w)),{download:w,onDumpEnd:()=>{g.abort("timeout")}}}formatStartDumpTime(e){let t=new Date(e),r=t.getFullYear(),i=this.pad(t.getMonth()+1),n=this.pad(t.getDate()),a=this.pad(t.getHours()),o=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(r,"-").concat(i,"-").concat(n,"T").concat(a,"-").concat(o,"-").concat(s).concat(u).concat(this.pad(l),"-").concat(this.pad(d))}convertOpusToOgg(e){let t=Math.floor(4294967295*Math.random()),r=0,i=0,n=[],a=this.createOpusHead(48e3,2);n.push(this.createOggPage(2,0,t,r++,[a]));let o=this.createOpusTags();n.push(this.createOggPage(0,0,t,r++,[o]));let s=[],c=0;return e.forEach((a,o)=>{let l=this.getOpusPacketDuration(a);s.push(a),c+=a.byteLength,i+=l;let d=o===e.length-1;if(c>6e4||s.length>=50||d){let e=d?4:0;n.push(this.createOggPage(e,i,t,r++,s)),s=[],c=0}}),new Blob(n,{type:"audio/ogg"})}createOpusHead(e,t){let r=new ArrayBuffer(19),i=new DataView(r);return this.writeString(i,0,"OpusHead"),i.setUint8(8,1),i.setUint8(9,t),i.setUint16(10,0,!0),i.setUint32(12,e,!0),i.setUint16(16,0,!0),i.setUint8(18,0),r}createOpusTags(){let e="TRTC Debugger",t=new ArrayBuffer(29),r=new DataView(t);return this.writeString(r,0,"OpusTags"),r.setUint32(8,13,!0),this.writeString(r,12,e),r.setUint32(25,0,!0),t}createOggPage(e,t,r,i,n){let a=0;n.forEach(e=>{let t=e.byteLength;for(;t>=255;)a++,t-=255;a++});let o=27+a,s=n.reduce((e,t)=>e+t.byteLength,0),c=new ArrayBuffer(o+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,r,!0),l.setUint32(18,i,!0),l.setUint32(22,0,!0),l.setUint8(26,a);let u=27;n.forEach(e=>{let t=e.byteLength;for(;t>=255;)d[u++]=255,t-=255;d[u++]=t});let h=o;n.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,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}getOpusPacketDuration(e){if(0===e.byteLength)return 0;let t=new Uint8Array(e),r=t[0],i=r>>3&31,n=3&r,a=1;if(1===n||2===n)a=2;else if(3===n){if(e.byteLength<2)return 0;a=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][i]||960)*a}crc32(e){let t=new Uint32Array(256);for(let i=0;i<256;i++){let e=i<<24;for(let t=0;t<8;t++)2147483648&e?e=e<<1^79764919:e<<=1;t[i]=e>>>0}let r=0;for(let i=0;i<e.length;i++){r=(r<<8^t[255&(r>>>24^e[i])])>>>0}return r}addVideoProcessor(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):PA,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):MA,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):UA,type:2}),this._core.room.audioManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeAudio.bind(this):BA,type:2})}removeAudioProcessor(){this._core.room.audioManager.removeEncodeProcessor({type:2}),this._core.room.audioManager.removeDecodeProcessor({type:2})}encodeVideo(e){let{frame:t,mediaType:r}=e;return PA({frame:t,onDump:()=>{if(!r)return;let e=2===r?"sub":"main",i=this.dumpLocalVideoMap[e];i&&(i.data.push(t.data.slice(0)),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}})}decodeVideo(e){let{frame:t,track:r}=e;return MA({frame:t,onDump:()=>{if(!r)return;let e=this.dumpRemoteVideoMap["".concat(r.userId,"-").concat(r.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 UA({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:r}=e;return BA({frame:t,onDump:()=>{if(!r)return;let e=this.dumpRemoteAudioMap[r.userId];e&&(e.data.push(t.data.slice(0)),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}})}};
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).TRTCDebugDialog=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={},n=function(e){try{return!!e()}catch(t){return!0}},a=!n(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}),o=!n(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}),s=o,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 f,m,g=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},_=o,v=Function.prototype,y=v.call,E=_&&v.bind.bind(y,y),b=_?E:function(e){return function(){return y.apply(e,arguments)}},w=b,I=w({}.toString),T=w("".slice),S=function(e){return T(I(e),8,-1)},k=n,A=S,R=Object,C=b("".split),D=k(function(){return!R("z").propertyIsEnumerable(0)})?function(e){return"String"===A(e)?C(e,""):R(e)}:R,O=function(e){return null==e},L=O,x=TypeError,N=function(e){if(L(e))throw new x("Can't call method on "+e);return e},P=D,M=N,U=function(e){return P(M(e))},B="object"==typeof document&&document.all,F=void 0===B&&void 0!==B?function(e){return"function"==typeof e||e===B}:function(e){return"function"==typeof e},V=F,W=function(e){return"object"==typeof e?null!==e:V(e)},H=r,j=F,z=function(e,t){return arguments.length<2?(r=H[e],j(r)?r:void 0):H[e]&&H[e][t];var r},G=b({}.isPrototypeOf),q=r.navigator,K=q&&q.userAgent,Y=K?String(K):"",X=r,Z=Y,J=X.process,Q=X.Deno,$=J&&J.versions||Q&&Q.version,ee=$&&$.v8;ee&&(m=(f=ee.split("."))[0]>0&&f[0]<4?1:+(f[0]+f[1])),!m&&Z&&(!(f=Z.match(/Edge\/(\d+)/))||f[1]>=74)&&(f=Z.match(/Chrome\/(\d+)/))&&(m=+f[1]);var te=m,re=te,ie=n,ne=r.String,ae=!!Object.getOwnPropertySymbols&&!ie(function(){var e=Symbol("symbol detection");return!ne(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41}),oe=ae&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=z,ce=F,le=G,de=Object,ue=oe?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"}},fe=F,me=pe,ge=TypeError,_e=function(e){if(fe(e))return e;throw new ge(me(e)+" is not a function")},ve=_e,ye=O,Ee=function(e,t){var r=e[t];return ye(r)?void 0:ve(r)},be=l,we=F,Ie=W,Te=TypeError,Se={exports:{}},ke=r,Ae=Object.defineProperty,Re=function(e,t){try{Ae(ke,e,{value:t,configurable:!0,writable:!0})}catch(r){ke[e]=t}return t},Ce=r,De=Re,Oe="__core-js_shared__",Le=Se.exports=Ce[Oe]||De(Oe,{});(Le.versions||(Le.versions=[])).push({version:"3.49.0",mode:"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE",source:"https://github.com/zloirock/core-js"});var xe=Se.exports,Ne=xe,Pe=function(e,t){return Ne[e]||(Ne[e]=t||{})},Me=N,Ue=Object,Be=function(e){return Ue(Me(e))},Fe=Be,Ve=b({}.hasOwnProperty),We=Object.hasOwn||function(e,t){return Ve(Fe(e),t)},He=b,je=0,ze=Math.random(),Ge=He(1.1.toString),qe=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ge(++je+ze,36)},Ke=Pe,Ye=We,Xe=qe,Ze=ae,Je=oe,Qe=r.Symbol,$e=Ke("wks"),et=Je?Qe.for||Qe:Qe&&Qe.withoutSetter||Xe,tt=function(e){return Ye($e,e)||($e[e]=Ze&&Ye(Qe,e)?Qe[e]:et("Symbol."+e)),$e[e]},rt=l,it=W,nt=ue,at=Ee,ot=function(e,t){var r,i;if("string"===t&&we(r=e.toString)&&!Ie(i=be(r,e)))return i;if(we(r=e.valueOf)&&!Ie(i=be(r,e)))return i;if("string"!==t&&we(r=e.toString)&&!Ie(i=be(r,e)))return i;throw new Te("Can't convert object to primitive value")},st=TypeError,ct=tt("toPrimitive"),lt=function(e,t){if(!it(e)||nt(e))return e;var r,i=at(e,ct);if(i){if(void 0===t&&(t="default"),r=rt(i,e,t),!it(r)||nt(r))return r;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),ot(e,t)},dt=lt,ut=ue,ht=function(e){var t=dt(e,"string");return ut(t)?t:t+""},pt=W,ft=r.document,mt=pt(ft)&&pt(ft.createElement),gt=function(e){return mt?ft.createElement(e):{}},_t=gt,vt=!a&&!n(function(){return 7!==Object.defineProperty(_t("div"),"a",{get:function(){return 7}}).a}),yt=a,Et=l,bt=d,wt=g,It=U,Tt=ht,St=We,kt=vt,At=Object.getOwnPropertyDescriptor;i.f=yt?At:function(e,t){if(e=It(e),t=Tt(t),kt)try{return At(e,t)}catch(r){}if(St(e,t))return wt(!Et(bt.f,e,t),e[t])};var Rt={},Ct=a&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype}),Dt=W,Ot=String,Lt=TypeError,xt=function(e){if(Dt(e))return e;throw new Lt(Ot(e)+" is not an object")},Nt=a,Pt=vt,Mt=Ct,Ut=xt,Bt=ht,Ft=TypeError,Vt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,Ht="enumerable",jt="configurable",zt="writable";Rt.f=Nt?Mt?function(e,t,r){if(Ut(e),t=Bt(t),Ut(r),"function"==typeof e&&"prototype"===t&&"value"in r&&zt in r&&!r[zt]){var i=Wt(e,t);i&&i[zt]&&(e[t]=r.value,r={configurable:jt in r?r[jt]:i[jt],enumerable:Ht in r?r[Ht]:i[Ht],writable:!1})}return Vt(e,t,r)}:Vt:function(e,t,r){if(Ut(e),t=Bt(t),Ut(r),Pt)try{return Vt(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 Gt=Rt,qt=g,Kt=a?function(e,t,r){return Gt.f(e,t,qt(1,r))}:function(e,t,r){return e[t]=r,e},Yt={exports:{}},Xt=a,Zt=We,Jt=Function.prototype,Qt=Xt&&Object.getOwnPropertyDescriptor,$t=Zt(Jt,"name"),er={EXISTS:$t,PROPER:$t&&"something"===function(){}.name,CONFIGURABLE:$t&&(!Xt||Xt&&Qt(Jt,"name").configurable)},tr=F,rr=xe,ir=b(Function.toString);tr(rr.inspectSource)||(rr.inspectSource=function(e){return ir(e)});var nr,ar,or,sr=rr.inspectSource,cr=F,lr=r.WeakMap,dr=cr(lr)&&/native code/.test(String(lr)),ur=qe,hr=Pe("keys"),pr=function(e){return hr[e]||(hr[e]=ur(e))},fr={},mr=dr,gr=r,_r=W,vr=Kt,yr=We,Er=xe,br=pr,wr=fr,Ir="Object already initialized",Tr=gr.TypeError,Sr=gr.WeakMap;if(mr||Er.state){var kr=Er.state||(Er.state=new Sr);kr.get=kr.get,kr.has=kr.has,kr.set=kr.set,nr=function(e,t){if(kr.has(e))throw new Tr(Ir);return t.facade=e,kr.set(e,t),t},ar=function(e){return kr.get(e)||{}},or=function(e){return kr.has(e)}}else{var Ar=br("state");wr[Ar]=!0,nr=function(e,t){if(yr(e,Ar))throw new Tr(Ir);return t.facade=e,vr(e,Ar,t),t},ar=function(e){return yr(e,Ar)?e[Ar]:{}},or=function(e){return yr(e,Ar)}}var Rr={set:nr,get:ar,has:or,enforce:function(e){return or(e)?ar(e):nr(e,{})},getterFor:function(e){return function(t){var r;if(!_r(t)||(r=ar(t)).type!==e)throw new Tr("Incompatible receiver, "+e+" required");return r}}},Cr=b,Dr=n,Or=F,Lr=We,xr=a,Nr=er.CONFIGURABLE,Pr=sr,Mr=Rr.enforce,Ur=Rr.get,Br=String,Fr=Object.defineProperty,Vr=Cr("".slice),Wr=Cr("".replace),Hr=Cr([].join),jr=xr&&!Dr(function(){return 8!==Fr(function(){},"length",{value:8}).length}),zr=String(String).split("String"),Gr=Yt.exports=function(e,t,r){"Symbol("===Vr(Br(t),0,7)&&(t="["+Wr(Br(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Lr(e,"name")||Nr&&e.name!==t)&&(xr?Fr(e,"name",{value:t,configurable:!0}):e.name=t),jr&&r&&Lr(r,"arity")&&e.length!==r.arity&&Fr(e,"length",{value:r.arity});try{r&&Lr(r,"constructor")&&r.constructor?xr&&Fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(n){}var i=Mr(e);return Lr(i,"source")||(i.source=Hr(zr,"string"==typeof t?t:"")),e};Function.prototype.toString=Gr(function(){return Or(this)&&Ur(this).source||Pr(this)},"toString");var qr=Yt.exports,Kr=F,Yr=Rt,Xr=qr,Zr=Re,Jr=function(e,t,r,i){i||(i={});var n=i.enumerable,a=void 0!==i.name?i.name:t;if(Kr(r)&&Xr(r,a,i),i.global)n?e[t]=r:Zr(t,r);else{try{i.unsafe?e[t]&&(n=!0):delete e[t]}catch(o){}n?e[t]=r:Yr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},Qr={},$r=Math.ceil,ei=Math.floor,ti=Math.trunc||function(e){var t=+e;return(t>0?ei:$r)(t)},ri=function(e){var t=+e;return t!=t||0===t?0:ti(t)},ii=ri,ni=Math.max,ai=Math.min,oi=function(e,t){var r=ii(e);return r<0?ni(r+t,0):ai(r,t)},si=ri,ci=Math.min,li=function(e){var t=si(e);return t>0?ci(t,9007199254740991):0},di=li,ui=function(e){return di(e.length)},hi=U,pi=oi,fi=ui,mi=function(e){return function(t,r,i){var n=hi(t),a=fi(n);if(0===a)return!e&&-1;var o,s=pi(i,a);if(e&&r!=r){for(;a>s;)if((o=n[s++])!=o)return!0}else for(;a>s;s++)if((e||s in n)&&n[s]===r)return e||s||0;return!e&&-1}},gi={includes:mi(!0),indexOf:mi(!1)},_i=We,vi=U,yi=gi.indexOf,Ei=fr,bi=b([].push),wi=function(e,t){var r,i=vi(e),n=0,a=[];for(r in i)!_i(Ei,r)&&_i(i,r)&&bi(a,r);for(;t.length>n;)_i(i,r=t[n++])&&(~yi(a,r)||bi(a,r));return a},Ii=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ti=wi,Si=Ii.concat("length","prototype");Qr.f=Object.getOwnPropertyNames||function(e){return Ti(e,Si)};var ki={};ki.f=Object.getOwnPropertySymbols;var Ai=z,Ri=Qr,Ci=ki,Di=xt,Oi=b([].concat),Li=Ai("Reflect","ownKeys")||function(e){var t=Ri.f(Di(e)),r=Ci.f;return r?Oi(t,r(e)):t},xi=We,Ni=Li,Pi=i,Mi=Rt,Ui=function(e,t,r){for(var i=Ni(t),n=Mi.f,a=Pi.f,o=0;o<i.length;o++){var s=i[o];xi(e,s)||r&&xi(r,s)||n(e,s,a(t,s))}},Bi=n,Fi=F,Vi=/#|\.prototype\./,Wi=function(e,t){var r=ji[Hi(e)];return r===Gi||r!==zi&&(Fi(t)?Bi(t):!!t)},Hi=Wi.normalize=function(e){return String(e).replace(Vi,".").toLowerCase()},ji=Wi.data={},zi=Wi.NATIVE="N",Gi=Wi.POLYFILL="P",qi=Wi,Ki=r,Yi=i.f,Xi=Kt,Zi=Jr,Ji=Re,Qi=Ui,$i=qi,en=function(e,t){var r,i,n,a,o,s=e.target,c=e.global,l=e.stat;if(r=c?Ki:l?Ki[s]||Ji(s,{}):Ki[s]&&Ki[s].prototype)for(i in t){if(a=t[i],n=e.dontCallGetSet?(o=Yi(r,i))&&o.value:r[i],!$i(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==n){if(typeof a==typeof n)continue;Qi(a,n)}(e.sham||n&&n.sham)&&Xi(a,"sham",!0),Zi(r,i,a,e)}},tn={};tn[tt("toStringTag")]="z";var rn="[object z]"===String(tn),nn=F,an=S,on=tt("toStringTag"),sn=Object,cn="Arguments"===an(function(){return arguments}()),ln=rn?an: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=sn(e),on))?r:cn?an(t):"Object"===(i=an(t))&&nn(t.callee)?"Arguments":i},dn=ln,un=String,hn=function(e){if("Symbol"===dn(e))throw new TypeError("Cannot convert a Symbol value to a string");return un(e)},pn=qr,fn=Rt,mn=function(e,t,r){return r.get&&pn(r.get,t,{getter:!0}),r.set&&pn(r.set,t,{setter:!0}),fn.f(e,t,r)},gn=en,_n=a,vn=l,yn=b,En=We,bn=F,wn=G,In=hn,Tn=mn,Sn=Ui,kn=r.Symbol,An=kn&&kn.prototype;if(_n&&bn(kn)&&(!("description"in An)||void 0!==kn().description)){var Rn={},Cn=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:In(arguments[0]),t=wn(An,this)?new kn(e):void 0===e?kn():kn(e);return""===e&&(Rn[t]=!0),t};Sn(Cn,kn);var Dn=Cn.for;Cn.for={for:function(e){var t=In(e),r=vn(Dn,this,t);return""===t&&(Rn[r]=!0),r}}.for,Cn.prototype=An,An.constructor=Cn;var On="Symbol(description detection)"===String(kn("description detection")),Ln=yn(An.valueOf),xn=yn(An.toString),Nn=/^Symbol\((.*)\)[^)]+$/,Pn=yn("".replace),Mn=yn("".slice);Tn(An,"description",{configurable:!0,get:function(){var e=Ln(this);if(En(Rn,e))return"";var t=xn(e),r=On?Mn(t,7,-1):Pn(t,Nn,"$1");return""===r?void 0:r}}),gn({global:!0,constructor:!0,forced:!0},{Symbol:Cn})}var Un={},Bn=wi,Fn=Ii,Vn=Object.keys||function(e){return Bn(e,Fn)},Wn=a,Hn=Ct,jn=Rt,zn=xt,Gn=U,qn=Vn;Un.f=Wn&&!Hn?Object.defineProperties:function(e,t){zn(e);for(var r,i=Gn(t),n=qn(t),a=n.length,o=0;a>o;)jn.f(e,r=n[o++],i[r]);return e};var Kn,Yn=z("document","documentElement"),Xn=xt,Zn=Un,Jn=Ii,Qn=fr,$n=Yn,ea=gt,ta="prototype",ra="script",ia=pr("IE_PROTO"),na=function(){},aa=function(e){return"<"+ra+">"+e+"</"+ra+">"},oa=function(e){e.write(aa("")),e.close();var t=e.parentWindow.Object;return e=null,t},sa=function(){try{Kn=new ActiveXObject("htmlfile")}catch(n){}var e,t,r;sa="undefined"!=typeof document?document.domain&&Kn?oa(Kn):(t=ea("iframe"),r="java"+ra+":",t.style.display="none",$n.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(aa("document.F=Object")),e.close(),e.F):oa(Kn);for(var i=Jn.length;i--;)delete sa[ta][Jn[i]];return sa()};Qn[ia]=!0;var ca=Object.create||function(e,t){var r;return null!==e?(na[ta]=Xn(e),r=new na,na[ta]=null,r[ia]=e):r=sa(),void 0===t?r:Zn.f(r,t)},la=tt,da=ca,ua=Rt.f,ha=la("unscopables"),pa=Array.prototype;void 0===pa[ha]&&ua(pa,ha,{configurable:!0,value:da(null)});var fa=function(e){pa[ha][e]=!0},ma=en,ga=gi.includes,_a=n,va=fa,ya=_a(function(){return!Array(1).includes()}),Ea=_a(function(){return[,1].includes(void 0,1)});ma({target:"Array",proto:!0,forced:ya||Ea},{includes:function(e){return ga(this,e,arguments.length>1?arguments[1]:void 0)}}),va("includes");var ba,wa,Ia,Ta={},Sa=!n(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}),ka=We,Aa=F,Ra=Be,Ca=Sa,Da=pr("IE_PROTO"),Oa=Object,La=Oa.prototype,xa=Ca?Oa.getPrototypeOf:function(e){var t=Ra(e);if(ka(t,Da))return t[Da];var r=t.constructor;return Aa(r)&&t instanceof r?r.prototype:t instanceof Oa?La:null},Na=n,Pa=F,Ma=W,Ua=xa,Ba=Jr,Fa=tt("iterator"),Va=!1;[].keys&&("next"in(Ia=[].keys())?(wa=Ua(Ua(Ia)))!==Object.prototype&&(ba=wa):Va=!0);var Wa=!Ma(ba)||Na(function(){var e={};return ba[Fa].call(e)!==e});Wa&&(ba={}),Pa(ba[Fa])||Ba(ba,Fa,function(){return this});var Ha={IteratorPrototype:ba,BUGGY_SAFARI_ITERATORS:Va},ja=Rt.f,za=We,Ga=tt("toStringTag"),qa=function(e,t,r){e&&!r&&(e=e.prototype),e&&!za(e,Ga)&&ja(e,Ga,{configurable:!0,value:t})},Ka=Ha.IteratorPrototype,Ya=ca,Xa=g,Za=qa,Ja=Ta,Qa=function(){return this},$a=function(e,t,r,i){var n=t+" Iterator";return e.prototype=Ya(Ka,{next:Xa(+!i,r)}),Za(e,n,!1),Ja[n]=Qa,e},eo=b,to=_e,ro=W,io=function(e){return ro(e)||null===e},no=String,ao=TypeError,oo=function(e,t,r){try{return eo(to(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},so=W,co=N,lo=function(e){if(io(e))return e;throw new ao("Can't set "+no(e)+" as a prototype")},uo=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=oo(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return co(r),lo(i),so(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0),ho=en,po=l,fo=F,mo=$a,go=xa,_o=uo,vo=qa,yo=Kt,Eo=Jr,bo=Ta,wo=er.PROPER,Io=er.CONFIGURABLE,To=Ha.IteratorPrototype,So=Ha.BUGGY_SAFARI_ITERATORS,ko=tt("iterator"),Ao="keys",Ro="values",Co="entries",Do=function(){return this},Oo=function(e,t,r,i,n,a,o){mo(r,t,i);var s,c,l,d=function(e){if(e===n&&m)return m;if(!So&&e&&e in p)return p[e];switch(e){case Ao:case Ro:case Co:return function(){return new r(this,e)}}return function(){return new r(this)}},u=t+" Iterator",h=!1,p=e.prototype,f=p[ko]||p["@@iterator"]||n&&p[n],m=!So&&f||d(n),g="Array"===t&&p.entries||f;if(g&&(s=go(g.call(new e)))!==Object.prototype&&s.next&&(go(s)!==To&&(_o?_o(s,To):fo(s[ko])||Eo(s,ko,Do)),vo(s,u,!0)),wo&&n===Ro&&f&&f.name!==Ro&&(Io?yo(p,"name",Ro):(h=!0,m=function(){return po(f,this)})),n)if(c={values:d(Ro),keys:a?m:d(Ao),entries:d(Co)},o)for(l in c)(So||h||!(l in p))&&Eo(p,l,c[l]);else ho({target:t,proto:!0,forced:So||h},c);return p[ko]!==m&&Eo(p,ko,m,{name:n}),bo[t]=m,c},Lo=function(e,t){return{value:e,done:t}},xo=U,No=fa,Po=Ta,Mo=Rr,Uo=Rt.f,Bo=Oo,Fo=Lo,Vo=a,Wo="Array Iterator",Ho=Mo.set,jo=Mo.getterFor(Wo),zo=Bo(Array,"Array",function(e,t){Ho(this,{type:Wo,target:xo(e),index:0,kind:t})},function(){var e=jo(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Fo(void 0,!0);switch(e.kind){case"keys":return Fo(r,!1);case"values":return Fo(t[r],!1)}return Fo([r,t[r]],!1)},"values"),Go=Po.Arguments=Po.Array;if(No("keys"),No("values"),No("entries"),Vo&&"values"!==Go.name)try{Uo(Go,"name",{value:"values"})}catch(TU){}var qo=_e,Ko=Be,Yo=D,Xo=ui,Zo=TypeError,Jo="Reduce of empty array with no initial value",Qo=function(e){return function(t,r,i,n){var a=Ko(t),o=Yo(a),s=Xo(a);if(qo(r),0===s&&i<2)throw new Zo(Jo);var c=e?s-1:0,l=e?-1:1;if(i<2)for(;;){if(c in o){n=o[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw new Zo(Jo)}for(;e?c>=0:s>c;c+=l)c in o&&(n=r(n,o[c],c,a));return n}},$o={left:Qo(!1),right:Qo(!0)},es=n,ts=function(e,t){var r=[][e];return!!r&&es(function(){r.call(null,t||function(){return 1},1)})},rs=r,is=Y,ns=S,as=function(e){return is.slice(0,e.length)===e},os=as("Bun/")?"BUN":as("Cloudflare-Workers")?"CLOUDFLARE":as("Deno/")?"DENO":as("Node.js/")?"NODE":rs.Bun&&"string"==typeof Bun.version?"BUN":rs.Deno&&"object"==typeof Deno.version?"DENO":"process"===ns(rs.process)?"NODE":rs.window&&rs.document?"BROWSER":"REST",ss="NODE"===os,cs=$o.left;en({target:"Array",proto:!0,forced:!ss&&te>79&&te<83||!ts("reduce")},{reduce:function(e){var t=arguments.length;return cs(this,e,t,t>1?arguments[1]:void 0)}});var ls=$o.right;en({target:"Array",proto:!0,forced:!ss&&te>79&&te<83||!ts("reduceRight")},{reduceRight:function(e){return ls(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ds=S,us=Array.isArray||function(e){return"Array"===ds(e)},hs=en,ps=us,fs=b([].reverse),ms=[1,2];hs({target:"Array",proto:!0,forced:String(ms)===String(ms.reverse())},{reverse:function(){return ps(this)&&(this.length=this.length),fs(this)}});var gs="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,_s=Jr,vs=function(e,t,r){for(var i in t)_s(e,i,t[i],r);return e},ys=G,Es=TypeError,bs=function(e,t){if(ys(t,e))return e;throw new Es("Incorrect invocation")},ws=ri,Is=li,Ts=RangeError,Ss=function(e){if(void 0===e)return 0;var t=ws(e),r=Is(t);if(t!==r)throw new Ts("Wrong length or index");return r},ks=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},As=4503599627370496,Rs=ks,Cs=function(e){return e+As-As},Ds=Math.abs,Os=function(e,t,r,i){var n=+e,a=Ds(n),o=Rs(n);if(a<i)return o*Cs(a/i/t)*i*t;var s=(1+t/2220446049250313e-31)*a,c=s-(s-a);return c>r||c!=c?Infinity*o:o*c},Ls=Math.fround||function(e){return Os(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},xs=Array,Ns=Math.abs,Ps=Math.pow,Ms=Math.floor,Us=Math.log,Bs=Math.LN2,Fs={pack:function(e,t,r){var i,n,a,o=xs(r),s=8*r-t-1,c=(1<<s)-1,l=c>>1,d=23===t?Ps(2,-24)-Ps(2,-77):0,u=e<0||0===e&&1/e<0?1:0,h=0;for((e=Ns(e))!=e||Infinity===e?(n=e!=e?1:0,i=c):(i=Ms(Us(e)/Bs),e*(a=Ps(2,-i))<1&&(i--,a*=2),(e+=i+l>=1?d/a:d*Ps(2,1-l))*a>=2&&(i++,a/=2),i+l>=c?(n=0,i=c):i+l>=1?(n=(e*a-1)*Ps(2,t),i+=l):(n=e*Ps(2,l-1)*Ps(2,t),i=0));t>=8;)o[h++]=255&n,n/=256,t-=8;for(i=i<<t|n,s+=t;s>0;)o[h++]=255&i,i/=256,s-=8;return o[h-1]|=128*u,o},unpack:function(e,t){var r,i=e.length,n=8*i-t-1,a=(1<<n)-1,o=a>>1,s=n-7,c=i-1,l=e[c--],d=127&l;for(l>>=7;s>0;)d=256*d+e[c--],s-=8;for(r=d&(1<<-s)-1,d>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===d)d=1-o;else{if(d===a)return r?NaN:l?-Infinity:Infinity;r+=Ps(2,t),d-=o}return(l?-1:1)*r*Ps(2,d-t)}},Vs=Be,Ws=oi,Hs=ui,js=function(e){for(var t=Vs(this),r=Hs(t),i=arguments.length,n=Ws(i>1?arguments[1]:void 0,r),a=i>2?arguments[2]:void 0,o=void 0===a?r:Ws(a,r);o>n;)t[n++]=e;return t},zs=b([].slice),Gs=F,qs=W,Ks=uo,Ys=function(e,t,r){var i,n;return Ks&&Gs(i=t.constructor)&&i!==r&&qs(n=i.prototype)&&n!==r.prototype&&Ks(e,n),e},Xs=r,Zs=b,Js=a,Qs=gs,$s=Kt,ec=mn,tc=vs,rc=n,ic=bs,nc=ri,ac=Ss,oc=Ls,sc=Fs,cc=xa,lc=uo,dc=js,uc=zs,hc=Ys,pc=Ui,fc=qa,mc=Rr,gc=er.PROPER,_c=er.CONFIGURABLE,vc="ArrayBuffer",yc="DataView",Ec="prototype",bc="Wrong index",wc=mc.getterFor(vc),Ic=mc.getterFor(yc),Tc=mc.set,Sc=Xs[vc],kc=Sc,Ac=kc&&kc[Ec],Rc=Xs[yc],Cc=Rc&&Rc[Ec],Dc=Object.prototype,Oc=Xs.Array,Lc=Xs.RangeError,xc=Zs(dc),Nc=Zs([].reverse),Pc=sc.pack,Mc=sc.unpack,Uc=function(e){return[255&e]},Bc=function(e){return[255&e,e>>8&255]},Fc=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},Vc=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Wc=function(e){return Pc(oc(e),23,4)},Hc=function(e){return Pc(e,52,8)},jc=function(e,t,r){ec(e[Ec],t,{configurable:!0,get:function(){return r(this)[t]}})},zc=function(e,t,r,i){var n=Ic(e),a=ac(r),o=!!i;if(a+t>n.byteLength)throw new Lc(bc);var s=n.bytes,c=a+n.byteOffset,l=uc(s,c,c+t);return o?l:Nc(l)},Gc=function(e,t,r,i,n,a){var o=Ic(e),s=ac(r),c=i(+n),l=!!a;if(s+t>o.byteLength)throw new Lc(bc);for(var d=o.bytes,u=s+o.byteOffset,h=0;h<t;h++)d[u+h]=c[l?h:t-h-1]};if(Qs){var qc=gc&&Sc.name!==vc;rc(function(){Sc(1)})&&rc(function(){new Sc(-1)})&&!rc(function(){return new Sc,new Sc(1.5),new Sc(NaN),1!==Sc.length||qc&&!_c})?qc&&_c&&$s(Sc,"name",vc):((kc=function(e){return ic(this,Ac),hc(new Sc(ac(e)),this,kc)})[Ec]=Ac,Ac.constructor=kc,pc(kc,Sc)),lc&&cc(Cc)!==Dc&&lc(Cc,Dc);var Kc=new Rc(new kc(2)),Yc=Zs(Cc.setInt8);Kc.setInt8(0,2147483648),Kc.setInt8(1,2147483649),!Kc.getInt8(0)&&Kc.getInt8(1)||tc(Cc,{setInt8:function(e,t){Yc(this,e,t<<24>>24)},setUint8:function(e,t){Yc(this,e,t<<24>>24)}},{unsafe:!0})}else Ac=(kc=function(e){ic(this,Ac);var t=ac(e);Tc(this,{type:vc,bytes:xc(Oc(t),0),byteLength:t}),Js||(this.byteLength=t,this.detached=!1)})[Ec],Cc=(Rc=function(e,t,r){ic(this,Cc),ic(e,Ac);var i=wc(e),n=i.byteLength,a=nc(t);if(a<0||a>n)throw new Lc("Wrong offset");if(a+(r=void 0===r?n-a:ac(r))>n)throw new Lc("Wrong length");Tc(this,{type:yc,buffer:e,byteLength:r,byteOffset:a,bytes:i.bytes}),Js||(this.buffer=e,this.byteLength=r,this.byteOffset=a)})[Ec],Js&&(jc(kc,"byteLength",wc),jc(Rc,"buffer",Ic),jc(Rc,"byteLength",Ic),jc(Rc,"byteOffset",Ic)),tc(Cc,{getInt8:function(e){return zc(this,1,e)[0]<<24>>24},getUint8:function(e){return zc(this,1,e)[0]},getInt16:function(e){var t=zc(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=zc(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return Vc(zc(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return Vc(zc(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return Mc(zc(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return Mc(zc(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){Gc(this,1,e,Uc,t)},setUint8:function(e,t){Gc(this,1,e,Uc,t)},setInt16:function(e,t){Gc(this,2,e,Bc,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){Gc(this,2,e,Bc,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){Gc(this,4,e,Fc,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){Gc(this,4,e,Fc,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){Gc(this,4,e,Wc,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){Gc(this,8,e,Hc,t,arguments.length>2&&arguments[2])}});fc(kc,vc),fc(Rc,yc);var Xc={ArrayBuffer:kc,DataView:Rc},Zc=z,Jc=mn,Qc=a,$c=tt("species"),el=function(e){var t=Zc(e);Qc&&t&&!t[$c]&&Jc(t,$c,{configurable:!0,get:function(){return this}})},tl=el,rl="ArrayBuffer",il=Xc[rl];en({global:!0,constructor:!0,forced:r[rl]!==il},{ArrayBuffer:il}),tl(rl);var nl=S,al=b,ol=function(e){if("Function"===nl(e))return al(e)},sl=en,cl=ol,ll=n,dl=xt,ul=oi,hl=li,pl=Xc.ArrayBuffer,fl=Xc.DataView,ml=fl.prototype,gl=cl(pl.prototype.slice),_l=cl(ml.getUint8),vl=cl(ml.setUint8);sl({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:ll(function(){return!new pl(2).slice(1,void 0).byteLength})},{slice:function(e,t){if(gl&&void 0===t)return gl(dl(this),e);for(var r=dl(this).byteLength,i=ul(e,r),n=ul(void 0===t?r:t,r),a=new pl(hl(n-i)),o=new fl(this),s=new fl(a),c=0;i<n;)vl(s,c++,_l(o,i++));return a}});var yl=r,El=b,bl=n,wl=F,Il=ln,Tl=sr,Sl=function(){},kl=z("Reflect","construct"),Al=/^\s*(?:class|function)\b/,Rl=El(Al.exec),Cl=!Al.test(Sl),Dl=function(e){if(!wl(e))return!1;try{return kl(Sl,[],e),!0}catch(TU){return!1}},Ol=function(e){if(!wl(e))return!1;switch(Il(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Cl||!!Rl(Al,Tl(e))}catch(TU){return!0}};Ol.sham=!0;var Ll,xl,Nl,Pl,Ml=!kl||bl(function(){var e;return Dl(Dl.call)||!Dl(Object)||!Dl(function(){e=!0})||e})?Ol:Dl,Ul=Ml,Bl=pe,Fl=TypeError,Vl=function(e){if(Ul(e))return e;throw new Fl(Bl(e)+" is not a constructor")},Wl=xt,Hl=Vl,jl=O,zl=tt("species"),Gl=function(e,t){var r,i=Wl(e).constructor;return void 0===i||jl(r=Wl(i)[zl])?t:Hl(r)},ql=o,Kl=Function.prototype,Yl=Kl.apply,Xl=Kl.call,Zl="object"==typeof Reflect&&Reflect.apply||(ql?Xl.bind(Yl):function(){return Xl.apply(Yl,arguments)}),Jl=_e,Ql=o,$l=ol(ol.bind),ed=function(e,t){return Jl(e),void 0===t?e:Ql?$l(e,t):function(){return e.apply(t,arguments)}},td=TypeError,rd=function(e,t){if(e<t)throw new td("Not enough arguments");return e},id=Y,nd=/ipad|iphone|ipod/i.test(id)&&/applewebkit/i.test(id),ad=r,od=Zl,sd=ed,cd=F,ld=We,dd=n,ud=Yn,hd=zs,pd=gt,fd=rd,md=nd,gd=ss,_d=ad.setImmediate,vd=ad.clearImmediate,yd=ad.process,Ed=ad.Dispatch,bd=ad.Function,wd=ad.MessageChannel,Id=ad.String,Td=0,Sd={},kd="onreadystatechange";dd(function(){Ll=ad.location});var Ad=function(e){if(ld(Sd,e)){var t=Sd[e];delete Sd[e],t()}},Rd=function(e){return function(){Ad(e)}},Cd=function(e){Ad(e.data)},Dd=function(e){ad.postMessage(Id(e),Ll.protocol+"//"+Ll.host)};_d&&vd||(_d=function(e){fd(arguments.length,1);var t=cd(e)?e:bd(e),r=hd(arguments,1);return Sd[++Td]=function(){od(t,void 0,r)},xl(Td),Td},vd=function(e){delete Sd[e]},gd?xl=function(e){yd.nextTick(Rd(e))}:Ed&&Ed.now?xl=function(e){Ed.now(Rd(e))}:wd&&!md?(Pl=(Nl=new wd).port2,Nl.port1.onmessage=Cd,xl=sd(Pl.postMessage,Pl)):ad.addEventListener&&cd(ad.postMessage)&&!ad.importScripts&&Ll&&"file:"!==Ll.protocol&&!dd(Dd)?(xl=Dd,ad.addEventListener("message",Cd,!1)):xl=kd in pd("script")?function(e){ud.appendChild(pd("script"))[kd]=function(){ud.removeChild(this),Ad(e)}}:function(e){setTimeout(Rd(e),0)});var Od={set:_d,clear:vd},Ld=r,xd=a,Nd=Object.getOwnPropertyDescriptor,Pd=function(e){if(!xd)return Ld[e];var t=Nd(Ld,e);return t&&t.value},Md=function(){this.head=null,this.tail=null};Md.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 Ud,Bd,Fd,Vd,Wd,Hd=Md,jd=/ipad|iphone|ipod/i.test(Y)&&"undefined"!=typeof Pebble,zd=/web0s(?!.*chrome)/i.test(Y),Gd=r,qd=Pd,Kd=ed,Yd=Od.set,Xd=Hd,Zd=nd,Jd=jd,Qd=zd,$d=ss,eu=Gd.MutationObserver||Gd.WebKitMutationObserver,tu=Gd.document,ru=Gd.process,iu=Gd.Promise,nu=qd("queueMicrotask");if(!nu){var au=new Xd,ou=function(){var e,t;for($d&&(e=ru.domain)&&e.exit();t=au.get();)try{t()}catch(TU){throw au.head&&Ud(),TU}e&&e.enter()};Zd||$d||Qd||!eu||!tu?!Jd&&iu&&iu.resolve?((Vd=iu.resolve(void 0)).constructor=iu,Wd=Kd(Vd.then,Vd),Ud=function(){Wd(ou)}):$d?Ud=function(){ru.nextTick(ou)}:(Yd=Kd(Yd,Gd),Ud=function(){Yd(ou)}):(Bd=!0,Fd=tu.createTextNode(""),new eu(ou).observe(Fd,{characterData:!0}),Ud=function(){Fd.data=Bd=!Bd}),nu=function(e){au.head||Ud(),au.add(e)}}var su=nu,cu=function(e){try{return{error:!1,value:e()}}catch(TU){return{error:!0,value:TU}}},lu=r.Promise,du=r,uu=lu,hu=F,pu=qi,fu=sr,mu=tt,gu=os,_u=te;uu&&uu.prototype;var vu=mu("species"),yu=!1,Eu=hu(du.PromiseRejectionEvent),bu=pu("Promise",function(){var e=fu(uu),t=e!==String(uu);if(!t&&66===_u)return!0;if(!_u||_u<51||!/native code/.test(e)){var r=new uu(function(e){e(1)}),i=function(e){e(function(){},function(){})};if((r.constructor={})[vu]=i,!(yu=r.then(function(){})instanceof i))return!0}return!(t||"BROWSER"!==gu&&"DENO"!==gu||Eu)}),wu={CONSTRUCTOR:bu,REJECTION_EVENT:Eu,SUBCLASSING:yu},Iu={},Tu=_e,Su=TypeError,ku=function(e){var t,r;this.promise=new e(function(e,i){if(void 0!==t||void 0!==r)throw new Su("Bad Promise constructor");t=e,r=i}),this.resolve=Tu(t),this.reject=Tu(r)};Iu.f=function(e){return new ku(e)};var Au,Ru,Cu,Du,Ou=en,Lu=ss,xu=r,Nu=yl,Pu=l,Mu=Jr,Uu=uo,Bu=qa,Fu=el,Vu=_e,Wu=F,Hu=W,ju=bs,zu=Gl,Gu=Od.set,qu=su,Ku=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(TU){}},Yu=cu,Xu=Hd,Zu=Rr,Ju=lu,Qu=Iu,$u="Promise",eh=wu.CONSTRUCTOR,th=wu.REJECTION_EVENT,rh=wu.SUBCLASSING,ih=Zu.getterFor($u),nh=Zu.set,ah=Ju&&Ju.prototype,oh=Ju,sh=ah,ch=xu.TypeError,lh=xu.document,dh=xu.process,uh=Qu.f,hh=uh,ph=!!(lh&&lh.createEvent&&xu.dispatchEvent),fh="unhandledrejection",mh=function(e){var t;return!(!Hu(e)||!Wu(t=e.then))&&t},gh=function(e,t){var r,i,n,a=t.value,o=1===t.state,s=o?e.ok:e.fail,c=e.resolve,l=e.reject,d=e.domain;try{s?(o||(2===t.rejection&&bh(t),t.rejection=1),!0===s?r=a:(d&&d.enter(),r=s(a),d&&(d.exit(),n=!0)),r===e.promise?l(new ch("Promise-chain cycle")):(i=mh(r))?Pu(i,r,c,l):c(r)):l(a)}catch(TU){d&&!n&&d.exit(),l(TU)}},_h=function(e,t){e.notified||(e.notified=!0,qu(function(){for(var r,i=e.reactions;r=i.get();)gh(r,e);e.notified=!1,t&&!e.rejection&&yh(e)}))},vh=function(e,t,r){var i,n;ph?((i=lh.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),xu.dispatchEvent(i)):i={promise:t,reason:r},!th&&(n=xu["on"+e])?n(i):e===fh&&Ku("Unhandled promise rejection",r)},yh=function(e){Pu(Gu,xu,function(){var t,r=e.facade,i=e.value;if(Eh(e)&&(t=Yu(function(){Lu?dh.emit("unhandledRejection",i,r):vh(fh,r,i)}),e.rejection=Lu||Eh(e)?2:1,t.error))throw t.value})},Eh=function(e){return 1!==e.rejection&&!e.parent},bh=function(e){Pu(Gu,xu,function(){var t=e.facade;Lu?dh.emit("rejectionHandled",t):vh("rejectionhandled",t,e.value)})},wh=function(e,t,r){return function(i){e(t,i,r)}},Ih=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,_h(e,!0))},Th=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new ch("Promise can't be resolved itself");var i=mh(t);i?qu(function(){var r={done:!1};try{Pu(i,t,wh(Th,r,e),wh(Ih,r,e))}catch(TU){Ih(r,TU,e)}}):(e.value=t,e.state=1,_h(e,!1))}catch(TU){Ih({done:!1},TU,e)}}};if(eh&&(sh=(oh=function(e){ju(this,sh),Vu(e),Pu(Au,this);var t=ih(this);try{e(wh(Th,t),wh(Ih,t))}catch(TU){Ih(t,TU)}}).prototype,(Au=function(e){nh(this,{type:$u,done:!1,notified:!1,parent:!1,reactions:new Xu,rejection:!1,state:0,value:null})}).prototype=Mu(sh,"then",function(e,t){var r=ih(this),i=uh(zu(this,oh));return r.parent=!0,i.ok=!Wu(e)||e,i.fail=Wu(t)&&t,i.domain=Lu?dh.domain:void 0,0===r.state?r.reactions.add(i):qu(function(){gh(i,r)}),i.promise}),Ru=function(){var e=new Au,t=ih(e);this.promise=e,this.resolve=wh(Th,t),this.reject=wh(Ih,t)},Qu.f=uh=function(e){return e===oh||e===Cu?new Ru(e):hh(e)},Wu(Ju)&&ah!==Object.prototype)){Du=ah.then,rh||Mu(ah,"then",function(e,t){var r=this;return new oh(function(e,t){Pu(Du,r,e,t)}).then(e,t)},{unsafe:!0});try{delete ah.constructor}catch(TU){}Uu&&Uu(ah,sh)}Ou({global:!0,constructor:!0,wrap:!0,forced:eh},{Promise:oh}),Cu=Nu.Promise,Bu(oh,$u,!1),Fu($u);var Sh=Ta,kh=tt("iterator"),Ah=Array.prototype,Rh=function(e){return void 0!==e&&(Sh.Array===e||Ah[kh]===e)},Ch=ln,Dh=Ee,Oh=O,Lh=Ta,xh=tt("iterator"),Nh=function(e){if(!Oh(e))return Dh(e,xh)||Dh(e,"@@iterator")||Lh[Ch(e)]},Ph=l,Mh=_e,Uh=xt,Bh=pe,Fh=Nh,Vh=TypeError,Wh=function(e,t){var r=arguments.length<2?Fh(e):t;if(Mh(r))return Uh(Ph(r,e));throw new Vh(Bh(e)+" is not iterable")},Hh=l,jh=xt,zh=Ee,Gh=function(e,t,r){var i,n;jh(e);try{if(!(i=zh(e,"return"))){if("throw"===t)throw r;return r}i=Hh(i,e)}catch(TU){n=!0,i=TU}if("throw"===t)throw r;if(n)throw i;return jh(i),r},qh=ed,Kh=l,Yh=xt,Xh=pe,Zh=Rh,Jh=ui,Qh=G,$h=Wh,ep=Nh,tp=Gh,rp=TypeError,ip=function(e,t){this.stopped=e,this.result=t},np=ip.prototype,ap=function(e,t,r){var i,n,a,o,s,c,l,d=r&&r.that,u=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),f=!(!r||!r.INTERRUPTED),m=qh(t,d),g=function(e){var t=i;return i=void 0,t&&tp(t,"normal"),new ip(!0,e)},_=function(e){return u?(Yh(e),f?m(e[0],e[1],g):m(e[0],e[1])):f?m(e,g):m(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(n=ep(e)))throw new rp(Xh(e)+" is not iterable");if(Zh(n)){for(a=0,o=Jh(e);o>a;a++)if((s=_(e[a]))&&Qh(np,s))return s;return new ip(!1)}i=$h(e,n)}for(c=h?e.next:i.next;!(l=Kh(c,i)).done;){var v=l.value;try{s=_(v)}catch(TU){if(!i)throw TU;tp(i,"throw",TU)}if("object"==typeof s&&s&&Qh(np,s))return s}return new ip(!1)},op=tt("iterator"),sp=!1;try{var cp=0,lp={next:function(){return{done:!!cp++}},return:function(){sp=!0}};lp[op]=function(){return this},Array.from(lp,function(){throw 2})}catch(TU){}var dp=function(e,t){try{if(!t&&!sp)return!1}catch(TU){return!1}var r=!1;try{var i={};i[op]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(TU){}return r},up=lu,hp=wu.CONSTRUCTOR||!dp(function(e){up.all(e).then(void 0,function(){})}),pp=l,fp=_e,mp=Iu,gp=cu,_p=ap;en({target:"Promise",stat:!0,forced:hp},{all:function(e){var t=this,r=mp.f(t),i=r.resolve,n=r.reject,a=gp(function(){var r=fp(t.resolve),a=[],o=0,s=1;_p(e,function(e){var c=o++,l=!1;s++,pp(r,t,e).then(function(e){l||(l=!0,a[c]=e,--s||i(a))},n)}),--s||i(a)});return a.error&&n(a.value),r.promise}});var vp=en,yp=wu.CONSTRUCTOR,Ep=lu,bp=z,wp=F,Ip=Jr,Tp=Ep&&Ep.prototype;if(vp({target:"Promise",proto:!0,forced:yp,real:!0},{catch:function(e){return this.then(void 0,e)}}),wp(Ep)){var Sp=bp("Promise").prototype.catch;Tp.catch!==Sp&&Ip(Tp,"catch",Sp,{unsafe:!0})}var kp=l,Ap=_e,Rp=Iu,Cp=cu,Dp=ap;en({target:"Promise",stat:!0,forced:hp},{race:function(e){var t=this,r=Rp.f(t),i=r.reject,n=Cp(function(){var n=Ap(t.resolve);Dp(e,function(e){kp(n,t,e).then(r.resolve,i)})});return n.error&&i(n.value),r.promise}});var Op=Iu;en({target:"Promise",stat:!0,forced:wu.CONSTRUCTOR},{reject:function(e){var t=Op.f(this);return(0,t.reject)(e),t.promise}});var Lp=xt,xp=W,Np=Iu,Pp=function(e,t){if(Lp(e),xp(t)&&t.constructor===e)return t;var r=Np.f(e);return(0,r.resolve)(t),r.promise},Mp=en,Up=wu.CONSTRUCTOR,Bp=Pp;z("Promise"),Mp({target:"Promise",stat:!0,forced:Up},{resolve:function(e){return Bp(this,e)}});var Fp=en,Vp=lu,Wp=n,Hp=z,jp=F,zp=Gl,Gp=Pp,qp=Jr,Kp=Vp&&Vp.prototype;if(Fp({target:"Promise",proto:!0,real:!0,forced:!!Vp&&Wp(function(){Kp.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=zp(this,Hp("Promise")),r=jp(e);return this.then(r?function(r){return Gp(t,e()).then(function(){return r})}:e,r?function(r){return Gp(t,e()).then(function(){throw r})}:e)}}),jp(Vp)){var Yp=Hp("Promise").prototype.finally;Kp.finally!==Yp&&qp(Kp,"finally",Yp,{unsafe:!0})}var Xp=W,Zp=S,Jp=tt("match"),Qp=function(e){var t;return Xp(e)&&(void 0!==(t=e[Jp])?!!t:"RegExp"===Zp(e))},$p=n,ef=r.RegExp,tf=!$p(function(){var e=!0;try{ef(".","d")}catch(TU){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",n=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},a={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var o in e&&(a.hasIndices="d"),a)n(o,a[o]);return Object.getOwnPropertyDescriptor(ef.prototype,"flags").get.call(t)!==i||r!==i}),rf={correct:tf},nf=xt,af=function(){var e=nf(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},of=l,sf=We,cf=G,lf=rf,df=af,uf=RegExp.prototype,hf=lf.correct?function(e){return e.flags}:function(e){return lf.correct||!cf(uf,e)||sf(e,"flags")?e.flags:of(df,e)},pf=n,ff=r.RegExp,mf=pf(function(){var e=ff("a","y");return e.lastIndex=2,null!==e.exec("abcd")}),gf=mf||pf(function(){return!ff("a","y").sticky}),_f={BROKEN_CARET:mf||pf(function(){var e=ff("^r","gy");return e.lastIndex=2,null!==e.exec("str")}),MISSED_STICKY:gf,UNSUPPORTED_Y:mf},vf=Rt.f,yf=n,Ef=r.RegExp,bf=yf(function(){var e=Ef(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)}),wf=n,If=r.RegExp,Tf=wf(function(){var e=If("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")}),Sf=a,kf=r,Af=b,Rf=qi,Cf=Ys,Df=Kt,Of=ca,Lf=Qr.f,xf=G,Nf=Qp,Pf=hn,Mf=hf,Uf=_f,Bf=function(e,t,r){r in e||vf(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},Ff=Jr,Vf=n,Wf=We,Hf=Rr.enforce,jf=el,zf=bf,Gf=Tf,qf=tt("match"),Kf=kf.RegExp,Yf=Kf.prototype,Xf=kf.SyntaxError,Zf=Af(Yf.exec),Jf=Af("".charAt),Qf=Af("".replace),$f=Af("".indexOf),em=Af("".slice),tm=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,rm=/a/g,im=/a/g,nm=new Kf(rm)!==rm,am=Uf.MISSED_STICKY,om=Uf.UNSUPPORTED_Y,sm=Sf&&(!nm||am||zf||Gf||Vf(function(){return im[qf]=!1,Kf(rm)!==rm||Kf(im)===im||"/a/i"!==String(Kf(rm,"i"))}));if(Rf("RegExp",sm)){for(var cm=function(e,t){var r,i,n,a,o,s,c=xf(Yf,this),l=Nf(e),d=void 0===t,u=[],h=e;if(!c&&l&&d&&e.constructor===cm)return e;if((l||xf(Yf,e))&&(e=e.source,d&&(t=Mf(h))),e=void 0===e?"":Pf(e),t=void 0===t?"":Pf(t),h=e,zf&&"dotAll"in rm&&(i=!!t&&$f(t,"s")>-1)&&(t=Qf(t,/s/g,"")),r=t,am&&"sticky"in rm&&(n=!!t&&$f(t,"y")>-1)&&om&&(t=Qf(t,/y/g,"")),Gf&&(a=function(e){for(var t,r=e.length,i=0,n="",a=[],o=Of(null),s=!1,c=!1,l=0,d="";i<r;i++){if("\\"===(t=Jf(e,i))){if(t+=Jf(e,++i),!c&&"\\"===Jf(t,1)){n+="\\x5c";continue}}else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:n+=t,Zf(tm,em(e,i+1))?(i+=2,c=!0,l++):"?"!==Jf(e,i+1)&&l++;continue;case">"===t&&c:if(""===d||Wf(o,d))throw new Xf("Invalid capture group name");o[d]=!0,a[a.length]=[d,l],c=!1,d="";continue}c?d+=t:n+=t}for(var u=0;u<a.length;u++)for(var h="\\k<"+a[u][0]+">",p="\\"+a[u][1];$f(n,h)>-1;)n=Qf(n,h,p);return[n,a]}(e),e=a[0],u=a[1]),o=Cf(Kf(e,t),c?this:Yf,cm),(i||n||u.length)&&(s=Hf(o),i&&(s.dotAll=!0,s.raw=cm(function(e){for(var t,r=e.length,i=0,n="",a=!1;i<r;i++)"\\"!==(t=Jf(e,i))?a||"."!==t?("["===t?a=!0:"]"===t&&(a=!1),n+=t):n+="[\\s\\S]":n+=t+Jf(e,++i);return n}(e),r)),n&&(s.sticky=!0),u.length&&(s.groups=u)),e!==h)try{Df(o,"source",""===h?"(?:)":h)}catch(TU){}return o},lm=Lf(Kf),dm=0;lm.length>dm;)Bf(cm,Kf,lm[dm++]);Yf.constructor=cm,cm.prototype=Yf,Ff(kf,"RegExp",cm,{constructor:!0})}jf("RegExp");var um=l,hm=b,pm=hn,fm=af,mm=_f,gm=ca,_m=Rr.get,vm=bf,ym=Tf,Em=Pe("native-string-replace",String.prototype.replace),bm=RegExp.prototype.exec,wm=bm,Im=hm("".charAt),Tm=hm("".indexOf),Sm=hm("".replace),km=hm("".slice),Am=function(){var e=/a/,t=/b*/g;return um(bm,e,"a"),um(bm,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),Rm=mm.BROKEN_CARET,Cm=void 0!==/()??/.exec("")[1],Dm=function(e,t){for(var r=e.groups=gm(null),i=0;i<t.length;i++){var n=t[i];r[n[0]]=e[n[1]]}};(Am||Cm||Rm||vm||ym)&&(wm=function(e){var t,r,i,n=this,a=_m(n),o=pm(e),s=a.raw;if(s)return s.lastIndex=n.lastIndex,t=um(wm,s,o),n.lastIndex=s.lastIndex,t&&a.groups&&Dm(t,a.groups),t;var c=a.groups,l=Rm&&n.sticky,d=um(fm,n),u=n.source,h=0,p=o;if(l){d=Sm(d,"y",""),-1===Tm(d,"g")&&(d+="g"),p=km(o,n.lastIndex);var f=n.lastIndex>0&&Im(o,n.lastIndex-1);n.lastIndex>0&&(!n.multiline||n.multiline&&"\n"!==f&&"\r"!==f&&"\u2028"!==f&&"\u2029"!==f)&&(u="(?: (?:"+u+"))",p=" "+p,h++),r=new RegExp("^(?:"+u+")",d)}Cm&&(r=new RegExp("^"+u+"$(?!\\s)",d)),Am&&(i=n.lastIndex);var m=um(bm,l?r:n,p);return l?m?(m.input=o,m[0]=km(m[0],h),m.index=n.lastIndex,n.lastIndex+=m[0].length):n.lastIndex=0:Am&&m&&(n.lastIndex=n.global?m.index+m[0].length:i),Cm&&m&&m.length>1&&um(Em,m[0],r,function(){for(var e=1;e<arguments.length-2;e++)void 0===arguments[e]&&(m[e]=void 0)}),m&&c&&Dm(m,c),m});var Om=wm;en({target:"RegExp",proto:!0,forced:/./.exec!==Om},{exec:Om});var Lm=mn,xm=rf,Nm=af;a&&!xm.correct&&(Lm(RegExp.prototype,"flags",{configurable:!0,get:Nm}),xm.correct=!0);var Pm=ri,Mm=hn,Um=N,Bm=RangeError,Fm=Math.floor,Vm=b,Wm=li,Hm=hn,jm=N,zm=Vm(function(e){var t=Mm(Um(this)),r="",i=Pm(e);if(i<0||Infinity===i)throw new Bm("Wrong number of repetitions");for(;i>0;(i=Fm(i/2))&&(t+=t))i%2&&(r+=t);return r}),Gm=Vm("".slice),qm=Math.ceil,Km=function(e){return function(t,r,i){var n=Hm(jm(t)),a=Wm(r),o=n.length;if(a<=o)return n;var s,c,l=void 0===i?" ":Hm(i);return""===l?n:((c=zm(l,qm((s=a-o)/l.length))).length>s&&(c=Gm(c,0,s)),e?n+c:c+n)}},Ym={start:Km(!1),end:Km(!0)},Xm=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Y),Zm=Ym.start;en({target:"String",proto:!0,forced:Xm},{padStart:function(e){return Zm(this,e,arguments.length>1?arguments[1]:void 0)}});var Jm=l,Qm=Jr,$m=Om,eg=n,tg=tt,rg=Kt,ig=tg("species"),ng=RegExp.prototype,ag=b,og=ri,sg=hn,cg=N,lg=ag("".charAt),dg=ag("".charCodeAt),ug=ag("".slice),hg=function(e){return function(t,r){var i,n,a=sg(cg(t)),o=og(r),s=a.length;return o<0||o>=s?e?"":void 0:(i=dg(a,o))<55296||i>56319||o+1===s||(n=dg(a,o+1))<56320||n>57343?e?lg(a,o):i:e?ug(a,o,o+2):n-56320+(i-55296<<10)+65536}},pg={codeAt:hg(!1),charAt:hg(!0)},fg=pg.charAt,mg=b,gg=Be,_g=Math.floor,vg=mg("".charAt),yg=mg("".replace),Eg=mg("".slice),bg=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,wg=/\$([$&'`]|\d{1,2})/g,Ig=function(e,t,r,i,n,a){var o=r+e.length,s=i.length,c=wg;return void 0!==n&&(n=gg(n),c=bg),yg(a,c,function(a,c){var l;switch(vg(c,0)){case"$":return"$";case"&":return e;case"`":return Eg(t,0,r);case"'":return Eg(t,o);case"<":l=n[Eg(c,1,-1)];break;default:var d=+c;if(0===d)return a;if(d>s){var u=_g(d/10);return 0===u?a:u<=s?void 0===i[u-1]?vg(c,1):i[u-1]+vg(c,1):a}l=i[d-1]}return void 0===l?"":l})},Tg=l,Sg=xt,kg=F,Ag=S,Rg=Om,Cg=TypeError,Dg=Zl,Og=l,Lg=b,xg=function(e,t,r,i){var n=tg(e),a=!eg(function(){var t={};return t[n]=function(){return 7},7!==""[e](t)}),o=a&&!eg(function(){var t=!1,r=/a/;if("split"===e){var i={};i[ig]=function(){return r},(r={constructor:i,flags:""})[n]=/./[n]}return r.exec=function(){return t=!0,null},r[n](""),!t});if(!a||!o||r){var s=/./[n],c=t(n,""[e],function(e,t,r,i,n){var o=t.exec;return o===$m||o===ng.exec?a&&!n?{done:!0,value:Jm(s,t,r,i)}:{done:!0,value:Jm(e,r,t,i)}:{done:!1}});Qm(String.prototype,e,c[0]),Qm(ng,n,c[1])}i&&rg(ng[n],"sham",!0)},Ng=n,Pg=xt,Mg=F,Ug=W,Bg=ri,Fg=li,Vg=hn,Wg=N,Hg=function(e,t,r){return t+(r&&fg(e,t).length||1)},jg=Ee,zg=Ig,Gg=hf,qg=function(e,t){var r=e.exec;if(kg(r)){var i=Tg(r,e,t);return null!==i&&Sg(i),i}if("RegExp"===Ag(e))return Tg(Rg,e,t);throw new Cg("RegExp#exec called on incompatible receiver")},Kg=tt("replace"),Yg=Math.max,Xg=Math.min,Zg=Lg([].concat),Jg=Lg([].push),Qg=Lg("".indexOf),$g=Lg("".slice),e_=function(e){return void 0===e?e:String(e)},t_="$0"==="a".replace(/./,"$0"),r_=!!/./[Kg]&&""===/./[Kg]("a","$0");xg("replace",function(e,t,r){var i=r_?"$":"$0";return[function(e,r){var i=Wg(this),n=Ug(e)?jg(e,Kg):void 0;return n?Og(n,e,i,r):Og(t,Vg(i),e,r)},function(e,n){var a=Pg(this),o=Vg(e),s=Mg(n);s||(n=Vg(n));var c=Vg(Gg(a));if("string"==typeof n&&!~Qg(n,i)&&!~Qg(n,"$<")&&!~Qg(c,"y")){var l=r(t,a,o,n);if(l.done)return l.value}var d,u=!!~Qg(c,"g");u&&(d=!!~Qg(c,"u")||!!~Qg(c,"v"),a.lastIndex=0);for(var h,p=[];null!==(h=qg(a,o))&&(Jg(p,h),u);){""===Vg(h[0])&&(a.lastIndex=Hg(o,Fg(a.lastIndex),d))}for(var f="",m=0,g=0;g<p.length;g++){for(var _,v=Vg((h=p[g])[0]),y=Yg(Xg(Bg(h.index),o.length),0),E=[],b=1;b<h.length;b++)Jg(E,e_(h[b]));var w=h.groups;if(s){var I=Zg([v],E,y,o);void 0!==w&&Jg(I,w),_=Vg(Dg(n,void 0,I))}else _=zg(v,o,y,E,w,n);y>=m&&(f+=$g(o,m,y)+_,m=y+v.length)}return f+$g(o,m)}]},!!Ng(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")})||!t_||r_);var i_="\t\n\v\f\r                 \u2028\u2029\ufeff",n_=N,a_=hn,o_=i_,s_=b("".replace),c_=RegExp("^["+o_+"]+"),l_=RegExp("(^|[^"+o_+"])["+o_+"]+$"),d_=function(e){return function(t){var r=a_(n_(t));return 1&e&&(r=s_(r,c_,"")),2&e&&(r=s_(r,l_,"$1")),r}},u_={start:d_(1),end:d_(2),trim:d_(3)},h_=er.PROPER,p_=n,f_=i_,m_=u_.trim;en({target:"String",proto:!0,forced:function(e){return p_(function(){return!!f_[e]()||"​…᠎"!=="​…᠎"[e]()||h_&&f_[e].name!==e})}("trim")},{trim:function(){return m_(this)}});var g_,__,v_,y_={exports:{}},E_=gs,b_=a,w_=r,I_=F,T_=W,S_=We,k_=ln,A_=pe,R_=Kt,C_=Jr,D_=mn,O_=G,L_=xa,x_=uo,N_=tt,P_=qe,M_=Rr.enforce,U_=Rr.get,B_=w_.Int8Array,F_=B_&&B_.prototype,V_=w_.Uint8ClampedArray,W_=V_&&V_.prototype,H_=B_&&L_(B_),j_=F_&&L_(F_),z_=Object.prototype,G_=w_.TypeError,q_=N_("toStringTag"),K_=P_("TYPED_ARRAY_TAG"),Y_="TypedArrayConstructor",X_=E_&&!!x_&&"Opera"!==k_(w_.opera),Z_=!1,J_={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Q_={BigInt64Array:8,BigUint64Array:8},$_=function(e){var t=L_(e);if(T_(t)){var r=U_(t);return r&&S_(r,Y_)?r[Y_]:$_(t)}},ev=function(e){if(!T_(e))return!1;var t=k_(e);return S_(J_,t)||S_(Q_,t)};for(g_ in J_)(v_=(__=w_[g_])&&__.prototype)?M_(v_)[Y_]=__:X_=!1;for(g_ in Q_)(v_=(__=w_[g_])&&__.prototype)&&(M_(v_)[Y_]=__);if((!X_||!I_(H_)||H_===Function.prototype)&&(H_=function(){throw new G_("Incorrect invocation")},X_))for(g_ in J_)w_[g_]&&x_(w_[g_],H_);if((!X_||!j_||j_===z_)&&(j_=H_.prototype,X_))for(g_ in J_)w_[g_]&&x_(w_[g_].prototype,j_);if(X_&&L_(W_)!==j_&&x_(W_,j_),b_&&!S_(j_,q_))for(g_ in Z_=!0,D_(j_,q_,{configurable:!0,get:function(){return T_(this)?this[K_]:void 0}}),J_)w_[g_]&&R_(w_[g_].prototype,K_,g_);var tv={NATIVE_ARRAY_BUFFER_VIEWS:X_,TYPED_ARRAY_TAG:Z_&&K_,aTypedArray:function(e){if(ev(e))return e;throw new G_("Target is not a typed array")},aTypedArrayConstructor:function(e){if(I_(e)&&(!x_||O_(H_,e)))return e;throw new G_(A_(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(b_){if(r)for(var n in J_){var a=w_[n];if(a&&S_(a.prototype,e))try{delete a.prototype[e]}catch(TU){try{a.prototype[e]=t}catch(o){}}}j_[e]&&!r||C_(j_,e,r?t:X_&&F_[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,n;if(b_){if(x_){if(r)for(i in J_)if((n=w_[i])&&S_(n,e))try{delete n[e]}catch(TU){}if(H_[e]&&!r)return;try{return C_(H_,e,r?t:X_&&H_[e]||t)}catch(TU){}}for(i in J_)!(n=w_[i])||n[e]&&!r||C_(n,e,t)}},getTypedArrayConstructor:$_,isView:function(e){if(!T_(e))return!1;var t=k_(e);return"DataView"===t||S_(J_,t)||S_(Q_,t)},isTypedArray:ev,TypedArray:H_,TypedArrayPrototype:j_},rv=r,iv=n,nv=dp,av=tv.NATIVE_ARRAY_BUFFER_VIEWS,ov=rv.ArrayBuffer,sv=rv.Int8Array,cv=!av||!iv(function(){sv(1)})||!iv(function(){new sv(-1)})||!nv(function(e){new sv,new sv(null),new sv(1.5),new sv(e)},!0)||iv(function(){return 1!==new sv(new ov(2),1,void 0).length}),lv=W,dv=Math.floor,uv=Number.isInteger||function(e){return!lv(e)&&isFinite(e)&&dv(e)===e},hv=ri,pv=RangeError,fv=function(e){var t=hv(e);if(t<0)throw new pv("The argument can't be less than 0");return t},mv=RangeError,gv=function(e,t){var r=fv(e);if(r%t)throw new mv("Wrong offset");return r},_v=Math.floor,vv=ln,yv=lt,Ev=TypeError,bv=function(e){var t=yv(e,"number");if("number"==typeof t)throw new Ev("Can't convert number to bigint");return BigInt(t)},wv=ed,Iv=l,Tv=_e,Sv=Vl,kv=Be,Av=ui,Rv=Wh,Cv=Nh,Dv=Rh,Ov=function(e){var t=vv(e);return"BigInt64Array"===t||"BigUint64Array"===t},Lv=tv.aTypedArrayConstructor,xv=bv,Nv=function(e){var t=Sv(this),r=arguments.length,i=r>1?arguments[1]:void 0,n=void 0!==i;n&&Tv(i);var a,o,s,c,l,d,u,h,p=kv(e),f=Cv(p);if(f&&!Dv(f))for(h=(u=Rv(p,f)).next,p=[];!(d=Iv(h,u)).done;)p.push(d.value);for(n&&r>2&&(i=wv(i,arguments[2])),o=Av(p),s=new(Lv(t))(o),c=Ov(s),a=0;o>a;a++)l=n?i(p[a],a):p[a],s[a]=c?xv(l):+l;return s},Pv=us,Mv=Ml,Uv=W,Bv=tt("species"),Fv=Array,Vv=function(e){var t;return Pv(e)&&(t=e.constructor,(Mv(t)&&(t===Fv||Pv(t.prototype))||Uv(t)&&null===(t=t[Bv]))&&(t=void 0)),void 0===t?Fv:t},Wv=a,Hv=Rt,jv=g,zv=function(e,t,r){Wv?Hv.f(e,t,jv(0,r)):e[t]=r},Gv=ed,qv=D,Kv=Be,Yv=ui,Xv=function(e,t){return new(Vv(e))(0===t?0:t)},Zv=zv,Jv=function(e){var t=1===e,r=2===e,i=3===e,n=4===e,a=6===e,o=7===e,s=5===e||a;return function(c,l,d){for(var u,h,p=Kv(c),f=qv(p),m=Yv(f),g=Gv(l,d),_=0,v=0,y=t?Xv(c,m):r||o?Xv(c,0):void 0;m>_;_++)if((s||_ in f)&&(h=g(u=f[_],_,p),e))if(t)Zv(y,_,h);else if(h)switch(e){case 3:return!0;case 5:return u;case 6:return _;case 2:Zv(y,v++,u)}else switch(e){case 4:return!1;case 7:Zv(y,v++,u)}return a?-1:i||n?n:y}},Qv={forEach:Jv(0),map:Jv(1),filter:Jv(2),some:Jv(3),every:Jv(4),find:Jv(5),findIndex:Jv(6),filterReject:Jv(7)},$v=ui,ey=en,ty=r,ry=l,iy=a,ny=cv,ay=tv,oy=Xc,sy=bs,cy=g,ly=Kt,dy=uv,uy=Ss,hy=gv,py=function(e){var t=+e;if(t!=t||t<=0)return 0;if(t>=255)return 255;var r=_v(t);return r+.5<t?r+1:t<r+.5||r%2==0?r:r+1},fy=ht,my=We,gy=ln,_y=W,vy=ue,yy=ca,Ey=G,by=uo,wy=Qr.f,Iy=Nv,Ty=Qv.forEach,Sy=el,ky=mn,Ay=Rt,Ry=i,Cy=function(e,t,r){for(var i=0,n=arguments.length>2?r:$v(t),a=new e(n);n>i;)a[i]=t[i++];return a},Dy=Ys,Oy=Rr.get,Ly=Rr.set,xy=Rr.enforce,Ny=Ay.f,Py=Ry.f,My=ty.RangeError,Uy=oy.ArrayBuffer,By=Uy.prototype,Fy=oy.DataView,Vy=ay.NATIVE_ARRAY_BUFFER_VIEWS,Wy=ay.TYPED_ARRAY_TAG,Hy=ay.TypedArray,jy=ay.TypedArrayPrototype,zy=ay.isTypedArray,Gy="BYTES_PER_ELEMENT",qy="Wrong length",Ky=function(e,t){ky(e,t,{configurable:!0,get:function(){return Oy(this)[t]}})},Yy=function(e){var t;return Ey(By,e)||"ArrayBuffer"===(t=gy(e))||"SharedArrayBuffer"===t},Xy=function(e,t){return zy(e)&&!vy(t)&&t in e&&dy(+t)&&t>=0},Zy=function(e,t){return t=fy(t),Xy(e,t)?cy(2,e[t]):Py(e,t)},Jy=function(e,t,r){return t=fy(t),!(Xy(e,t)&&_y(r)&&my(r,"value"))||my(r,"get")||my(r,"set")||r.configurable||my(r,"writable")&&!r.writable||my(r,"enumerable")&&!r.enumerable?Ny(e,t,r):(e[t]=r.value,e)};iy?(Vy||(Ry.f=Zy,Ay.f=Jy,Ky(jy,"buffer"),Ky(jy,"byteOffset"),Ky(jy,"byteLength"),Ky(jy,"length")),ey({target:"Object",stat:!0,forced:!Vy},{getOwnPropertyDescriptor:Zy,defineProperty:Jy}),y_.exports=function(e,t,r){var i=e.match(/\d+/)[0]/8,n=e+(r?"Clamped":"")+"Array",a="get"+e,o="set"+e,s=ty[n],c=s,l=c&&c.prototype,d={},u=function(e,t){Ny(e,t,{get:function(){return function(e,t){var r=Oy(e);return r.view[a](t*i+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,n){var a=Oy(e);a.view[o](t*i+a.byteOffset,r?py(n):n,!0)}(this,t,e)},enumerable:!0})};Vy?ny&&(c=t(function(e,t,r,n){return sy(e,l),Dy(_y(t)?Yy(t)?void 0!==n?new s(t,hy(r,i),n):void 0!==r?new s(t,hy(r,i)):new s(t):zy(t)?Cy(c,t):ry(Iy,c,t):new s(uy(t)),e,c)}),by&&by(c,Hy),Ty(wy(s),function(e){e in c||ly(c,e,s[e])}),c.prototype=l):(c=t(function(e,t,r,n){sy(e,l);var a,o,s,d=0,h=0;if(_y(t)){if(!Yy(t))return zy(t)?Cy(c,t):ry(Iy,c,t);a=t,h=hy(r,i);var p=t.byteLength;if(void 0===n){if(p%i)throw new My(qy);if((o=p-h)<0)throw new My(qy)}else if((o=uy(n)*i)+h>p)throw new My(qy);s=o/i}else s=uy(t),a=new Uy(o=s*i);for(Ly(e,{buffer:a,byteOffset:h,byteLength:o,length:s,view:new Fy(a)});d<s;)u(e,d++)}),by&&by(c,Hy),l=c.prototype=yy(jy)),l.constructor!==c&&ly(l,"constructor",c),xy(l).TypedArrayConstructor=c,Wy&&ly(l,Wy,n);var h=c!==s;d[n]=c,ey({global:!0,constructor:!0,forced:h,sham:!Vy},d),Gy in c||ly(c,Gy,i),Gy in l||ly(l,Gy,i),Sy(n)}):y_.exports=function(){};var Qy=y_.exports;Qy("Float32",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Int32",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint8",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint16",function(e){return function(t,r,i){return e(this,t,r,i)}}),Qy("Uint32",function(e){return function(t,r,i){return e(this,t,r,i)}});var $y=js,eE=bv,tE=ln,rE=l,iE=n,nE=tv.aTypedArray,aE=tv.exportTypedArrayMethod,oE=b("".slice);aE("fill",function(e){var t=arguments.length;nE(this);var r="Big"===oE(tE(this),0,3)?eE(e):+e;return rE($y,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},iE(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})),(0,tv.exportTypedArrayStaticMethod)("from",Nv,cv);var sE=r,cE=l,lE=tv,dE=ui,uE=gv,hE=Be,pE=n,fE=sE.RangeError,mE=sE.Int8Array,gE=mE&&mE.prototype,_E=gE&&gE.set,vE=lE.aTypedArray,yE=lE.exportTypedArrayMethod,EE=!pE(function(){var e=new Uint8ClampedArray(2);return cE(_E,e,{length:1,0:3},1),3!==e[1]}),bE=EE&&lE.NATIVE_ARRAY_BUFFER_VIEWS&&pE(function(){var e=new mE(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]});yE("set",function(e){vE(this);var t=uE(arguments.length>1?arguments[1]:void 0,1),r=hE(e);if(EE)return cE(_E,this,r,t);var i=this.length,n=dE(r),a=0;if(n+t>i)throw new fE("Wrong length");for(;a<n;)this[t+a]=r[a++]},!EE||bE);var wE=zs,IE=Math.floor,TE=function(e,t){var r=e.length;if(r<8)for(var i,n,a=1;a<r;){for(n=a,i=e[a];n&&t(e[n-1],i)>0;)e[n]=e[--n];n!==a++&&(e[n]=i)}else for(var o=IE(r/2),s=TE(wE(e,0,o),t),c=TE(wE(e,o),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},SE=TE,kE=Y.match(/firefox\/(\d+)/i),AE=!!kE&&+kE[1],RE=/MSIE|Trident/.test(Y),CE=Y.match(/AppleWebKit\/(\d+)\./),DE=!!CE&&+CE[1],OE=ol,LE=n,xE=_e,NE=SE,PE=AE,ME=RE,UE=te,BE=DE,FE=tv.aTypedArray,VE=tv.exportTypedArrayMethod,WE=r.Uint16Array,HE=WE&&OE(WE.prototype.sort),jE=!(!HE||LE(function(){HE(new WE(2),null)})&&LE(function(){HE(new WE(2),{})})),zE=!!HE&&!LE(function(){if(UE)return UE<74;if(PE)return PE<67;if(ME)return!0;if(BE)return BE<602;var e,t,r=new WE(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(HE(r,function(e,t){return(e/4|0)-(t/4|0)}),e=0;e<516;e++)if(r[e]!==i[e])return!0});VE("sort",function(e){return void 0!==e&&xE(e),zE?HE(this,e):NE(FE(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?t!=t?0:-1:t!=t?1:0===t&&0===r?1/t>0?1/r>0?0:1:1/r>0?-1:0:t>r?1:t<r?-1:0}}(e))},!zE||jE);var GE=en,qE=l,KE=b,YE=N,XE=F,ZE=W,JE=Qp,QE=hn,$E=Ee,eb=hf,tb=Ig,rb=tt("replace"),ib=TypeError,nb=KE("".indexOf);KE("".replace);var ab=KE("".slice),ob=Math.max;GE({target:"String",proto:!0},{replaceAll:function(e,t){var r,i,n,a,o,s,c,l,d,u=YE(this),h=0,p="";if(ZE(e)){if(JE(e)&&(r=QE(YE(eb(e))),!~nb(r,"g")))throw new ib("`.replaceAll` does not allow non-global regexes");if(i=$E(e,rb))return qE(i,e,u,t)}for(n=QE(u),a=QE(e),(o=XE(t))||(t=QE(t)),s=a.length,c=ob(1,s),l=nb(n,a);-1!==l;)d=o?QE(t(a,l,n)):tb(a,n,l,[],void 0,t),p+=ab(n,h,l)+d,h=l+s,l=l+c>n.length?-1:nb(n,a,l+c);return h<n.length&&(p+=ab(n,h)),p}});var sb={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},cb=gt("span").classList,lb=cb&&cb.constructor&&cb.constructor.prototype,db=lb===Object.prototype?void 0:lb,ub=Qv.forEach,hb=ts("forEach")?[].forEach:function(e){return ub(this,e,arguments.length>1?arguments[1]:void 0)},pb=r,fb=sb,mb=db,gb=hb,_b=Kt,vb=function(e){if(e&&e.forEach!==gb)try{_b(e,"forEach",gb)}catch(TU){e.forEach=gb}};for(var yb in fb)fb[yb]&&vb(pb[yb]&&pb[yb].prototype);vb(mb);var Eb=r,bb=sb,wb=db,Ib=zo,Tb=Kt,Sb=qa,kb=tt("iterator"),Ab=Ib.values,Rb=function(e,t){if(e){if(e[kb]!==Ab)try{Tb(e,kb,Ab)}catch(TU){e[kb]=Ab}if(Sb(e,t,!0),bb[t])for(var r in Ib)if(e[r]!==Ib[r])try{Tb(e,r,Ib[r])}catch(TU){e[r]=Ib[r]}}};for(var Cb in bb)Rb(Eb[Cb]&&Eb[Cb].prototype,Cb);Rb(wb,"DOMTokenList");var Db=Od.clear;en({global:!0,bind:!0,enumerable:!0,forced:r.clearImmediate!==Db},{clearImmediate:Db});var Ob=r,Lb=Zl,xb=F,Nb=os,Pb=Y,Mb=zs,Ub=rd,Bb=Ob.Function,Fb=/MSIE .\./.test(Pb)||"BUN"===Nb&&function(){var e=Ob.Bun.version.split(".");return e.length<3||"0"===e[0]&&(e[1]<3||"3"===e[1]&&"0"===e[2])}(),Vb=en,Wb=r,Hb=Od.set,jb=function(e,t){var r=t?2:1;return Fb?function(i,n){var a=Ub(arguments.length,1)>r,o=xb(i)?i:Bb(i),s=a?Mb(arguments,r):[],c=a?function(){Lb(o,this,s)}:o;return t?e(c,n):e(c)}:e},zb=Wb.setImmediate?jb(Hb,!1):Hb;Vb({global:!0,bind:!0,enumerable:!0,forced:Wb.setImmediate!==zb},{setImmediate:zb});var Gb=pg.charAt,qb=hn,Kb=Rr,Yb=Oo,Xb=Lo,Zb="String Iterator",Jb=Kb.set,Qb=Kb.getterFor(Zb);Yb(String,"String",function(e){Jb(this,{type:Zb,string:qb(e),index:0})},function(){var e,t=Qb(this),r=t.string,i=t.index;return i>=r.length?Xb(void 0,!0):(e=Gb(r,i),t.index+=e.length,Xb(e,!1))});var $b=n,ew=a,tw=tt("iterator"),rw=!$b(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&&!ew||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[tw]||"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}),iw=a,nw=b,aw=l,ow=n,sw=Vn,cw=ki,lw=d,dw=Be,uw=D,hw=Object.assign,pw=Object.defineProperty,fw=nw([].concat),mw=!hw||ow(function(){if(iw&&1!==hw({b:1},hw(pw({},"a",{enumerable:!0,get:function(){pw(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!==hw({},e)[r]||sw(hw({},t)).join("")!==i})?function(e,t){for(var r=dw(e),i=arguments.length,n=1,a=cw.f,o=lw.f;i>n;)for(var s,c=uw(arguments[n++]),l=a?fw(sw(c),a(c)):sw(c),d=l.length,u=0;d>u;)s=l[u++],iw&&!aw(o,c,s)||(r[s]=c[s]);return r}:hw,gw=xt,_w=Gh,vw=a,yw=us,Ew=TypeError,bw=Object.getOwnPropertyDescriptor,ww=vw&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(TU){return TU instanceof TypeError}}(),Iw=ed,Tw=l,Sw=Be,kw=function(e,t,r,i){try{return i?t(gw(r)[0],r[1]):t(r)}catch(TU){_w(e,"throw",TU)}},Aw=Rh,Rw=Ml,Cw=ui,Dw=zv,Ow=ww?function(e,t){if(yw(e)&&!bw(e,"length").writable)throw new Ew("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t},Lw=Wh,xw=Nh,Nw=Gh,Pw=Array,Mw=b,Uw=2147483647,Bw=/[^\0-\u007E]/,Fw=/[.\u3002\uFF0E\uFF61]/g,Vw="Overflow: input needs wider integers to process",Ww=RangeError,Hw=Mw(Fw.exec),jw=Math.floor,zw=String.fromCharCode,Gw=Mw("".charCodeAt),qw=Mw([].join),Kw=Mw([].push),Yw=Mw("".replace),Xw=Mw("".split),Zw=Mw("".toLowerCase),Jw=function(e){return e+22+75*(e<26)},Qw=function(e,t,r){var i=0;for(e=r?jw(e/700):e>>1,e+=jw(e/t);e>455;)e=jw(e/35),i+=36;return jw(i+36*e/(e+38))},$w=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var n=Gw(e,r++);if(n>=55296&&n<=56319&&r<i){var a=Gw(e,r++);56320==(64512&a)?Kw(t,((1023&n)<<10)+(1023&a)+65536):(Kw(t,n),r--)}else Kw(t,n)}return t}(e);var r,i,n=e.length,a=128,o=0,s=72;for(r=0;r<e.length;r++)(i=e[r])<128&&Kw(t,zw(i));var c=t.length,l=c;for(c&&Kw(t,"-");l<n;){var d=Uw;for(r=0;r<e.length;r++)(i=e[r])>=a&&i<d&&(d=i);var u=l+1;if(d-a>jw((Uw-o)/u))throw new Ww(Vw);for(o+=(d-a)*u,a=d,r=0;r<e.length;r++){if((i=e[r])<a&&++o>Uw)throw new Ww(Vw);if(i===a){for(var h=o,p=36;;){var f=p<=s?1:p>=s+26?26:p-s;if(h<f)break;var m=h-f,g=36-f;Kw(t,zw(Jw(f+m%g))),h=jw(m/g),p+=36}Kw(t,zw(Jw(h))),s=Qw(o,u,l===c),o=0,l++}}o++,a++}return qw(t,"")},eI=en,tI=b,rI=oi,iI=RangeError,nI=String.fromCharCode,aI=String.fromCodePoint,oI=tI([].join);eI({target:"String",stat:!0,arity:1,forced:!!aI&&1!==aI.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,n=0;i>n;){if(rI(t=+arguments[n],1114111)!==t)throw new iI(t+" is not a valid code point");r[n++]=t<65536?nI(t):nI(55296+((t-=65536)>>10),t%1024+56320)}return oI(r,"")}});var sI=en,cI=r,lI=Pd,dI=z,uI=l,hI=b,pI=a,fI=rw,mI=Jr,gI=mn,_I=vs,vI=qa,yI=$a,EI=Rr,bI=bs,wI=F,II=We,TI=ed,SI=ln,kI=xt,AI=W,RI=hn,CI=ca,DI=g,OI=Wh,LI=Nh,xI=Lo,NI=rd,PI=SE,MI=tt("iterator"),UI="URLSearchParams",BI=UI+"Iterator",FI=EI.set,VI=EI.getterFor(UI),WI=EI.getterFor(BI),HI=lI("fetch"),jI=lI("Request"),zI=lI("Headers"),GI=jI&&jI.prototype,qI=zI&&zI.prototype,KI=cI.TypeError,YI=cI.encodeURIComponent,XI=String.fromCharCode,ZI=dI("String","fromCodePoint"),JI=parseInt,QI=hI("".charAt),$I=hI([].join),eT=hI([].push),tT=hI("".replace),rT=hI([].shift),iT=hI([].splice),nT=hI("".split),aT=hI("".slice),oT=hI(/./.exec),sT=/\+/g,cT=/^[0-9a-f]+$/i,lT=function(e,t){var r=aT(e,t,t+2);return oT(cT,r)?JI(r,16):NaN},dT=function(e){for(var t=0,r=128;r>0&&0!==(e&r);r>>=1)t++;return t},uT=function(e){var t=null,r=e.length;switch(r){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 null===t||t>1114111||t>=55296&&t<=57343||t<(r>3?65536:r>2?2048:r>1?128:0)?null:t},hT=function(e){for(var t=(e=tT(e,sT," ")).length,r="",i=0;i<t;){var n=QI(e,i);if("%"===n){if("%"===QI(e,i+1)||i+3>t){r+="%",i++;continue}var a=lT(e,i+1);if(a!=a){r+=n,i++;continue}i+=2;var o=dT(a);if(0===o)n=XI(a);else{if(1===o||o>4){r+="�",i++;continue}for(var s=[a],c=1;c<o&&!(++i+3>t||"%"!==QI(e,i));){var l=lT(e,i+1);if(l!=l||l>191||l<128)break;if(1===c){if(224===a&&l<160)break;if(237===a&&l>159)break;if(240===a&&l<144)break;if(244===a&&l>143)break}eT(s,l),i+=2,c++}if(s.length!==o){r+="�";continue}var d=uT(s);if(null===d){for(var u=0;u<o;u++)r+="�";i++;continue}n=ZI(d)}}r+=n,i++}return r},pT=/[!'()~]|%20/g,fT={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},mT=function(e){return fT[e]},gT=function(e){return tT(YI(e),pT,mT)},_T=yI(function(e,t){FI(this,{type:BI,target:VI(e).entries,index:0,kind:t})},UI,function(){var e=WI(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,xI(void 0,!0);var i=t[r];switch(e.kind){case"keys":return xI(i.key,!1);case"values":return xI(i.value,!1)}return xI([i.key,i.value],!1)},!0),vT=function(e){this.entries=[],this.url=null,void 0!==e&&(AI(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===QI(e,0)?aT(e,1):e:RI(e)))};vT.prototype={type:UI,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,a,o,s,c=this.entries,l=LI(e);if(l)for(r=(t=OI(e,l)).next;!(i=uI(r,t)).done;){if(a=(n=OI(kI(i.value))).next,(o=uI(a,n)).done||(s=uI(a,n)).done||!uI(a,n).done)throw new KI("Expected sequence with length 2");eT(c,{key:RI(o.value),value:RI(s.value)})}else for(var d in e)II(e,d)&&eT(c,{key:d,value:RI(e[d])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,n=nT(e,"&"),a=0;a<n.length;)(t=n[a++]).length&&(r=nT(t,"="),eT(i,{key:hT(rT(r)),value:hT($I(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],eT(r,gT(e.key)+"="+gT(e.value));return $I(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var yT=function(){bI(this,ET);var e=FI(this,new vT(arguments.length>0?arguments[0]:void 0));pI||(this.size=e.entries.length)},ET=yT.prototype;if(_I(ET,{append:function(e,t){var r=VI(this);NI(arguments.length,2),eT(r.entries,{key:RI(e),value:RI(t)}),pI||this.size++,r.updateURL()},delete:function(e){for(var t=VI(this),r=NI(arguments.length,1),i=t.entries,n=RI(e),a=r<2?void 0:arguments[1],o=void 0===a?a:RI(a),s=0;s<i.length;){var c=i[s];c.key!==n||void 0!==o&&c.value!==o?s++:iT(i,s,1)}pI||(this.size=i.length),t.updateURL()},get:function(e){var t=VI(this).entries;NI(arguments.length,1);for(var r=RI(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){var t=VI(this).entries;NI(arguments.length,1);for(var r=RI(e),i=[],n=0;n<t.length;n++)t[n].key===r&&eT(i,t[n].value);return i},has:function(e){for(var t=VI(this).entries,r=NI(arguments.length,1),i=RI(e),n=r<2?void 0:arguments[1],a=void 0===n?n:RI(n),o=0;o<t.length;){var s=t[o++];if(s.key===i&&(void 0===a||s.value===a))return!0}return!1},set:function(e,t){var r=VI(this);NI(arguments.length,2);for(var i,n=r.entries,a=!1,o=RI(e),s=RI(t),c=0;c<n.length;c++)(i=n[c]).key===o&&(a?iT(n,c--,1):(a=!0,i.value=s));a||eT(n,{key:o,value:s}),pI||(this.size=n.length),r.updateURL()},sort:function(){var e=VI(this);PI(e.entries,function(e,t){return e.key>t.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,r=VI(this).entries,i=TI(e,arguments.length>1?arguments[1]:void 0),n=0;n<r.length;)i((t=r[n++]).value,t.key,this)},keys:function(){return new _T(this,"keys")},values:function(){return new _T(this,"values")},entries:function(){return new _T(this,"entries")}},{enumerable:!0}),mI(ET,MI,ET.entries,{name:"entries"}),mI(ET,"toString",function(){return VI(this).serialize()},{enumerable:!0}),pI&&gI(ET,"size",{get:function(){return VI(this).entries.length},configurable:!0,enumerable:!0}),vI(yT,UI),sI({global:!0,constructor:!0,forced:!fI},{URLSearchParams:yT}),!fI&&wI(zI)){var bT=hI(qI.has),wT=hI(qI.set),IT=function(e){if(AI(e)){var t,r=e.body;if(SI(r)===UI)return t=e.headers?new zI(e.headers):new zI,bT(t,"content-type")||wT(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),CI(e,{body:DI(0,RI(r)),headers:DI(0,t)})}return e};if(wI(HI)&&sI({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return HI(e,arguments.length>1?IT(arguments[1]):{})}}),wI(jI)){var TT=function(e){return bI(this,GI),new jI(e,arguments.length>1?IT(arguments[1]):{})};GI.constructor=TT,TT.prototype=GI,sI({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:TT})}}var ST,kT=en,AT=a,RT=rw,CT=r,DT=ed,OT=b,LT=Jr,xT=mn,NT=bs,PT=We,MT=mw,UT=function(e){var t=Rw(this),r=arguments.length,i=r>1?arguments[1]:void 0,n=void 0!==i;n&&(i=Iw(i,r>2?arguments[2]:void 0));var a,o,s,c,l,d,u=Sw(e),h=xw(u),p=0;if(!h||this===Pw&&Aw(h))for(a=Cw(u),o=t?new this(a):Pw(a);a>p;p++)d=n?i(u[p],p):u[p],Dw(o,p,d);else for(o=t?new this:[],l=(c=Lw(u,h)).next;!(s=Tw(l,c)).done;p++){d=n?kw(c,i,[s.value,p],!0):s.value;try{Dw(o,p,d)}catch(TU){Nw(c,"throw",TU)}}return Ow(o,p),o},BT=zs,FT=pg.codeAt,VT=function(e){var t,r,i=[],n=Xw(Yw(Zw(e),Fw,"."),".");for(t=0;t<n.length;t++)r=n[t],Kw(i,Hw(Bw,r)?"xn--"+$w(r):r);return qw(i,".")},WT=hn,HT=qa,jT=rd,zT={URLSearchParams:yT,getState:VI},GT=Rr,qT=GT.set,KT=GT.getterFor("URL"),YT=zT.URLSearchParams,XT=zT.getState,ZT=CT.URL,JT=CT.TypeError,QT=CT.encodeURIComponent,$T=CT.parseInt,eS=Math.floor,tS=Math.pow,rS=OT("".charAt),iS=OT(/./.exec),nS=OT([].join),aS=OT(1.1.toString),oS=OT([].pop),sS=OT([].push),cS=OT("".replace),lS=OT([].shift),dS=OT("".split),uS=OT("".slice),hS=OT("".toLowerCase),pS=OT([].unshift),fS="Invalid scheme",mS="Invalid host",gS="Invalid port",_S=/[a-z]/i,vS=/[\d+\-.a-z]/i,yS=/\d/,ES=/^0x/i,bS=/^[0-7]+$/,wS=/^\d+$/,IS=/^[\da-f]+$/i,TS=/[\0\t\n\r #%/:<>?@[\\\]^|]/,SS=/[\0\t\n\r #/:<>?@[\\\]^|]/,kS=/^[\u0000-\u0020]+/,AS=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,RS=/[\t\n\r]/g,CS=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)pS(t,e%256),e=eS(e/256);return nS(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,n=0,a=0;a<8;a++)0!==e[a]?(n>r&&(t=i,r=n),i=null,n=0):(null===i&&(i=a),++n);return n>r?i:t}(e),r=0;r<8;r++)n&&0===e[r]||(n&&(n=!1),i===r?(t+=r?":":"::",n=!0):(t+=aS(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},DS={},OS=MT({},DS,{" ":1,'"':1,"#":1,"<":1,">":1}),LS=MT({},OS,{"'":1}),xS=MT({},DS,{" ":1,'"':1,"<":1,">":1,"`":1}),NS=MT({},xS,{"#":1,"?":1,"{":1,"}":1,"^":1}),PS=MT({},NS,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),MS=function(e,t){var r=FT(e,0);return r>=32&&r<127&&!PT(t,e)?e:"'"===e&&PT(t,e)?"%27":QT(e)},US={ftp:21,file:null,http:80,https:443,ws:80,wss:443},BS=function(e,t){var r;return 2===e.length&&iS(_S,rS(e,0))&&(":"===(r=rS(e,1))||!t&&"|"===r)},FS=function(e){var t;return e.length>1&&BS(uS(e,0,2))&&(2===e.length||"/"===(t=rS(e,2))||"\\"===t||"?"===t||"#"===t)},VS=function(e){return"."===e||"%2e"===hS(e)},WS=function(e){return".."===(e=hS(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},HS={},jS={},zS={},GS={},qS={},KS={},YS={},XS={},ZS={},JS={},QS={},$S={},ek={},tk={},rk={},ik={},nk={},ak={},ok={},sk={},ck={},lk=function(e,t,r){var i,n,a,o=WT(e);if(t){if(n=this.parse(o))throw new JT(n);this.searchParams=null}else{if(void 0!==r&&(i=new lk(r,!0)),n=this.parse(o,null,i))throw new JT(n);(a=XT(new YT)).bindURL(this),this.searchParams=a}};lk.prototype={type:"URL",parse:function(e,t,r){var i,n,a,o,s=this,c=t||HS,l=0,d="",u=!1,h=!1,p=!1;for(e=WT(e),t||(s.scheme="",s.username="",s.password="",s.host=null,s.port=null,s.path=[],s.query=null,s.fragment=null,s.cannotBeABaseURL=!1,e=cS(e,kS,""),e=cS(e,AS,"$1")),e=cS(e,RS,""),i=UT(e);l<=i.length;){switch(n=i[l],c){case HS:if(!n||!iS(_S,n)){if(t)return fS;c=zS;continue}d+=hS(n),c=jS;break;case jS:if(n&&iS(vS,n))d+=hS(n);else{if(":"!==n){if(t)return fS;d="",c=zS,l=0;continue}if(t&&(s.isSpecial()!==PT(US,d)||"file"===d&&(s.includesCredentials()||null!==s.port)||"file"===s.scheme&&""===s.host))return;if(s.scheme=d,t)return void(s.isSpecial()&&US[s.scheme]===s.port&&(s.port=null));d="","file"===s.scheme?c=tk:s.isSpecial()&&r&&r.scheme===s.scheme?c=GS:s.isSpecial()?c=XS:"/"===i[l+1]?(c=qS,l++):(s.cannotBeABaseURL=!0,sS(s.path,""),c=ok)}break;case zS:if(!r||r.cannotBeABaseURL&&"#"!==n)return fS;if(r.cannotBeABaseURL&&"#"===n){s.scheme=r.scheme,s.path=BT(r.path),s.query=r.query,s.fragment="",s.cannotBeABaseURL=!0,c=ck;break}c="file"===r.scheme?tk:KS;continue;case GS:if("/"!==n||"/"!==i[l+1]){c=KS;continue}c=ZS,l++;break;case qS:if("/"===n){c=JS;break}c=ak;continue;case KS:if(s.scheme=r.scheme,n===ST)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query=r.query;else if("/"===n||"\\"===n&&s.isSpecial())c=YS;else if("?"===n)s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query="",c=sk;else{if("#"!==n){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.path.length&&s.path.length--,c=ak;continue}s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,s.path=BT(r.path),s.query=r.query,s.fragment="",c=ck}break;case YS:if(!s.isSpecial()||"/"!==n&&"\\"!==n){if("/"!==n){s.username=r.username,s.password=r.password,s.host=r.host,s.port=r.port,c=ak;continue}c=JS}else c=ZS;break;case XS:if(c=ZS,"/"!==n||"/"!==i[l+1])continue;l++;break;case ZS:if("/"!==n&&"\\"!==n){c=JS;continue}break;case JS:if("@"===n){u&&(d="%40"+d),u=!0,a=UT(d);for(var f=0;f<a.length;f++){var m=a[f];if(":"!==m||p){var g=MS(m,PS);p?s.password+=g:s.username+=g}else p=!0}d=""}else if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()){if(u&&""===d)return"Invalid authority";l-=UT(d).length+1,d="",c=QS}else d+=n;break;case QS:case $S:if(t&&"file"===s.scheme){c=ik;continue}if(":"!==n||h){if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()){if(s.isSpecial()&&""===d)return mS;if(t&&""===d&&(s.includesCredentials()||null!==s.port))return;if(o=s.parseHost(d))return o;if(d="",c=nk,t)return;continue}"["===n?h=!0:"]"===n&&(h=!1),d+=n}else{if(""===d)return mS;if(t===$S)return;if(o=s.parseHost(d))return o;d="",c=ek}break;case ek:if(!iS(yS,n)){if(n===ST||"/"===n||"?"===n||"#"===n||"\\"===n&&s.isSpecial()||t){if(""!==d){var _=$T(d,10);if(_>65535)return gS;s.port=s.isSpecial()&&_===US[s.scheme]?null:_,d=""}if(t)return;c=nk;continue}return gS}d+=n;break;case tk:if(s.scheme="file",s.host="","/"===n||"\\"===n)c=rk;else{if(!r||"file"!==r.scheme){c=ak;continue}switch(n){case ST:s.host=r.host,s.path=BT(r.path),s.query=r.query;break;case"?":s.host=r.host,s.path=BT(r.path),s.query="",c=sk;break;case"#":s.host=r.host,s.path=BT(r.path),s.query=r.query,s.fragment="",c=ck;break;default:s.host=r.host,FS(nS(BT(i,l),""))||(s.path=BT(r.path),s.shortenPath()),c=ak;continue}}break;case rk:if("/"===n||"\\"===n){c=ik;break}r&&"file"===r.scheme&&(s.host=r.host,!FS(nS(BT(i,l),""))&&BS(r.path[0],!0)&&sS(s.path,r.path[0])),c=ak;continue;case ik:if(n===ST||"/"===n||"\\"===n||"?"===n||"#"===n){if(!t&&BS(d))c=ak;else if(""===d){if(s.host="",t)return;c=nk}else{if(o=s.parseHost(d))return o;if("localhost"===s.host&&(s.host=""),t)return;d="",c=nk}continue}d+=n;break;case nk:if(s.isSpecial()){if(c=ak,"/"!==n&&"\\"!==n)continue}else if(t||"?"!==n)if(t||"#"!==n){if(n!==ST&&(c=ak,"/"!==n))continue}else s.fragment="",c=ck;else s.query="",c=sk;break;case ak:if(n===ST||"/"===n||"\\"===n&&s.isSpecial()||!t&&("?"===n||"#"===n)){if(WS(d)?(s.shortenPath(),"/"===n||"\\"===n&&s.isSpecial()||sS(s.path,"")):VS(d)?"/"===n||"\\"===n&&s.isSpecial()||sS(s.path,""):("file"===s.scheme&&!s.path.length&&BS(d)&&(null!==s.host&&""!==s.host&&(s.host=""),d=rS(d,0)+":"),sS(s.path,d)),d="","file"===s.scheme&&(n===ST||"?"===n||"#"===n))for(;s.path.length>1&&""===s.path[0];)lS(s.path);"?"===n?(s.query="",c=sk):"#"===n&&(s.fragment="",c=ck)}else d+=MS(n,NS);break;case ok:"?"===n?(s.query="",c=sk):"#"===n?(s.fragment="",c=ck):n!==ST&&(s.path[0]+=MS(n,DS));break;case sk:t||"#"!==n?n!==ST&&(s.query+=MS(n,s.isSpecial()?LS:OS)):(s.fragment="",c=ck);break;case ck:n!==ST&&(s.fragment+=MS(n,xS))}l++}},parseHost:function(e){var t,r,i;if("["===rS(e,0)){if("]"!==rS(e,e.length-1))return mS;if(t=function(e){var t,r,i,n,a,o,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=r=0;r<4&&iS(IS,h());)t=16*t+$T(h(),16),u++,r++;if("."===h()){if(0===r)return;if(u-=r,l>6)return;for(i=0;h();){if(n=null,i>0){if(!("."===h()&&i<4))return;u++}if(!iS(yS,h()))return;for(;iS(yS,h());){if(a=$T(h(),10),null===n)n=a;else{if(0===n)return;n=10*n+a}if(n>255)return;u++}c[l]=256*c[l]+n,2!==++i&&4!==i||l++}if(4!==i)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(o=l-d,l=7;0!==l&&o>0;)s=c[l],c[l--]=c[d+o-1],c[d+--o]=s;else if(8!==l)return;return c}(uS(e,1,-1)),!t)return mS;this.host=t}else if(this.isSpecial()){if(e=VT(e),iS(TS,e))return mS;if(function(e){var t,r,i=dS(e,".");if(""===i[i.length-1]){if(1===i.length)return!1;i.length--}return t=i[i.length-1],!!iS(wS,t)||!!iS(ES,t)&&(""===(r=uS(t,2))||!!iS(IS,r))}(e)){if(t=function(e){var t,r,i,n,a,o,s,c=dS(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return null;for(r=[],i=0;i<t;i++){if(""===(n=c[i]))return null;if(a=10,n.length>1&&"0"===rS(n,0)&&(a=iS(ES,n)?16:8,n=uS(n,8===a?1:2)),""===n)o=0;else{if(!iS(10===a?wS:8===a?bS:IS,n))return null;o=$T(n,a)}sS(r,o)}for(i=0;i<t;i++)if(o=r[i],i===t-1){if(o>=tS(256,5-t))return null}else if(o>255)return null;for(s=oS(r),i=0;i<r.length;i++)s+=r[i]*tS(256,3-i);return s}(e),null===t)return mS;this.host=t}else this.host=e}else{if(iS(SS,e))return mS;for(t="",r=UT(e),i=0;i<r.length;i++)t+=MS(r[i],DS);this.host=t}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return PT(US,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&BS(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,n=e.host,a=e.port,o=e.path,s=e.query,c=e.fragment,l=t+":";return null!==n?(l+="//",e.includesCredentials()&&(l+=r+(i?":"+i:"")+"@"),l+=CS(n),null!==a&&(l+=":"+a)):"file"===t&&(l+="//"),null===n&&!e.cannotBeABaseURL&&o.length>1&&""===o[0]&&(l+="/."),l+=e.cannotBeABaseURL?o[0]:o.length?"/"+nS(o,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw new JT(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new dk(this.path[0]).origin}catch(TU){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+CS(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(WT(e)+":",HS)},getUsername:function(){return this.username},setUsername:function(e){var t=UT(WT(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=MS(t[r],PS)}},getPassword:function(){return this.password},setPassword:function(e){var t=UT(WT(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=MS(t[r],PS)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?CS(e):CS(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,QS)},getHostname:function(){var e=this.host;return null===e?"":CS(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,$S)},getPort:function(){var e=this.port;return null===e?"":WT(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=WT(e))?this.port=null:this.parse(e,ek))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+nS(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,nk))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=WT(e))?this.query=null:("?"===rS(e,0)&&(e=uS(e,1)),this.query="",this.parse(e,sk)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=WT(e))?("#"===rS(e,0)&&(e=uS(e,1)),this.fragment="",this.parse(e,ck)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var dk=function(e){var t=NT(this,uk),r=jT(arguments.length,1)>1?arguments[1]:void 0,i=qT(t,new lk(e,!1,r));AT||(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())},uk=dk.prototype,hk=function(e,t){return{get:function(){return KT(this)[e]()},set:t&&function(e){return KT(this)[t](e)},configurable:!0,enumerable:!0}};if(AT&&(xT(uk,"href",hk("serialize","setHref")),xT(uk,"origin",hk("getOrigin")),xT(uk,"protocol",hk("getProtocol","setProtocol")),xT(uk,"username",hk("getUsername","setUsername")),xT(uk,"password",hk("getPassword","setPassword")),xT(uk,"host",hk("getHost","setHost")),xT(uk,"hostname",hk("getHostname","setHostname")),xT(uk,"port",hk("getPort","setPort")),xT(uk,"pathname",hk("getPathname","setPathname")),xT(uk,"search",hk("getSearch","setSearch")),xT(uk,"searchParams",hk("getSearchParams")),xT(uk,"hash",hk("getHash","setHash"))),LT(uk,"toJSON",function(){return KT(this).serialize()},{enumerable:!0}),LT(uk,"toString",function(){return KT(this).serialize()},{enumerable:!0}),ZT){var pk=ZT.createObjectURL,fk=ZT.revokeObjectURL;pk&&LT(dk,"createObjectURL",DT(pk,ZT)),fk&&LT(dk,"revokeObjectURL",DT(fk,ZT))}HT(dk,"URL"),kT({global:!0,constructor:!0,forced:!RT,sham:!AT},{URL:dk});var mk=l;en({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return mk(URL.prototype.toString,this)}});var gk,_k,vk=Object.create,yk=Object.defineProperty,Ek=Object.defineProperties,bk=Object.getOwnPropertyDescriptor,wk=Object.getOwnPropertyDescriptors,Ik=Object.getOwnPropertyNames,Tk=Object.getOwnPropertySymbols,Sk=Object.getPrototypeOf,kk=Object.prototype.hasOwnProperty,Ak=Object.prototype.propertyIsEnumerable,Rk=(e,t,r)=>t in e?yk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ck=(e,t)=>{for(var r in t||(t={}))kk.call(t,r)&&Rk(e,r,t[r]);if(Tk)for(var r of Tk(t))Ak.call(t,r)&&Rk(e,r,t[r]);return e},Dk=(e,t)=>Ek(e,wk(t)),Ok=(gk=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(gk,{get:(e,t)=>("undefined"!=typeof require?require:e)[t]}):gk),Lk=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),xk=(e,t)=>{for(var r in t)yk(e,r,{get:t[r],enumerable:!0})},Nk=(e,t,r)=>(r=null!=e?vk(Sk(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of Ik(t))!kk.call(e,n)&&n!==r&&yk(e,n,{get:()=>t[n],enumerable:!(i=bk(t,n))||i.enumerable});return e})(!t&&e&&e.__esModule?r:yk(r,"default",{value:e,enumerable:!0}),e)),Pk=(e,t,r,i)=>{for(var n,a=i>1?void 0:i?bk(t,r):t,o=e.length-1;o>=0;o--)(n=e[o])&&(a=(i?n(t,r,a):n(a))||a);return i&&a&&yk(t,r,a),a},Mk=(e,t,r)=>Rk(e,"symbol"!=typeof t?t+"":t,r),Uk=Lk((e,t)=>{!function(r){"object"==typeof e&&void 0!==t?t.exports=r():"function"==typeof define&&define.amd?define([],r):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).JSZip=r()}(function(){return function e(t,r,i){function n(o,s){if(!r[o]){if(!t[o]){var c="function"==typeof Ok&&Ok;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var d=r[o]={exports:{}};t[o][0].call(d.exports,function(e){return n(t[o][1][e]||e)},d,d.exports,e,t,r,i)}return r[o].exports}for(var a="function"==typeof Ok&&Ok,o=0;o<i.length;o++)n(i[o]);return n}({1:[function(e,t,r){var i=e("./utils"),n=e("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";r.encode=function(e){for(var t,r,n,o,s,c,l,d=[],u=0,h=e.length,p=h,f="string"!==i.getTypeOf(e);u<e.length;)p=h-u,n=f?(t=e[u++],r=u<h?e[u++]:0,u<h?e[u++]:0):(t=e.charCodeAt(u++),r=u<h?e.charCodeAt(u++):0,u<h?e.charCodeAt(u++):0),o=t>>2,s=(3&t)<<4|r>>4,c=1<p?(15&r)<<2|n>>6:64,l=2<p?63&n:64,d.push(a.charAt(o)+a.charAt(s)+a.charAt(c)+a.charAt(l));return d.join("")},r.decode=function(e){var t,r,i,o,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)===a.charAt(64)&&p--,e.charAt(e.length-2)===a.charAt(64)&&p--,p%1!=0)throw new Error("Invalid base64 input, bad content length.");for(h=n.uint8array?new Uint8Array(0|p):new Array(0|p);l<e.length;)t=a.indexOf(e.charAt(l++))<<2|(o=a.indexOf(e.charAt(l++)))>>4,r=(15&o)<<4|(s=a.indexOf(e.charAt(l++)))>>2,i=(3&s)<<6|(c=a.indexOf(e.charAt(l++))),h[d++]=t,64!==s&&(h[d++]=r),64!==c&&(h[d++]=i);return h}},{"./support":30,"./utils":32}],2:[function(e,t,r){var i=e("./external"),n=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),o=e("./stream/DataLengthProbe");function s(e,t,r,i,n){this.compressedSize=e,this.uncompressedSize=t,this.crc32=r,this.compression=i,this.compressedContent=n}s.prototype={getContentWorker:function(){var e=new n(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o("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 n(i.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,r){return e.pipe(new a).pipe(new o("uncompressedSize")).pipe(t.compressWorker(r)).pipe(new o("compressedSize")).withStreamInfo("compression",t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,r){var i=e("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,r){var i=e("./utils"),n=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t){return void 0!==e&&e.length?"string"!==i.getTypeOf(e)?function(e,t,r){var i=n,a=0+r;e^=-1;for(var o=0;o<a;o++)e=e>>>8^i[255&(e^t[o])];return-1^e}(0|t,e,e.length):function(e,t,r){var i=n,a=0+r;e^=-1;for(var o=0;o<a;o++)e=e>>>8^i[255&(e^t.charCodeAt(o))];return-1^e}(0|t,e,e.length):0}},{"./utils":32}],5:[function(e,t,r){r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(e,t,r){var i;i="undefined"!=typeof Promise?Promise:e("lie"),t.exports={Promise:i}},{lie:37}],7:[function(e,t,r){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=e("pako"),a=e("./utils"),o=e("./stream/GenericWorker"),s=i?"uint8array":"array";function c(e,t){o.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}r.magic="\b\0",a.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(s,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},r.compressWorker=function(e){return new c("Deflate",e)},r.uncompressWorker=function(){return new c("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,r){function i(e,t){var r,i="";for(r=0;r<t;r++)i+=String.fromCharCode(255&e),e>>>=8;return i}function n(e,t,r,n,o,d){var u,h,p=e.file,f=e.compression,m=d!==s.utf8encode,g=a.transformTo("string",d(p.name)),_=a.transformTo("string",s.utf8encode(p.name)),v=p.comment,y=a.transformTo("string",d(v)),E=a.transformTo("string",s.utf8encode(v)),b=_.length!==p.name.length,w=E.length!==v.length,I="",T="",S="",k=p.dir,A=p.date,R={crc32:0,compressedSize:0,uncompressedSize:0};t&&!r||(R.crc32=e.crc32,R.compressedSize=e.compressedSize,R.uncompressedSize=e.uncompressedSize);var C=0;t&&(C|=8),m||!b&&!w||(C|=2048);var D,O,L,x=0,N=0;k&&(x|=16),"UNIX"===o?(N=798,x|=(D=p.unixPermissions,O=k,L=D,D||(L=O?16893:33204),(65535&L)<<16)):(N=20,x|=function(e){return 63&(e||0)}(p.dosPermissions)),u=A.getUTCHours(),u<<=6,u|=A.getUTCMinutes(),u<<=5,u|=A.getUTCSeconds()/2,h=A.getUTCFullYear()-1980,h<<=4,h|=A.getUTCMonth()+1,h<<=5,h|=A.getUTCDate(),b&&(T=i(1,1)+i(c(g),4)+_,I+="up"+i(T.length,2)+T),w&&(S=i(1,1)+i(c(y),4)+E,I+="uc"+i(S.length,2)+S);var P="";return P+="\n\0",P+=i(C,2),P+=f.magic,P+=i(u,2),P+=i(h,2),P+=i(R.crc32,4),P+=i(R.compressedSize,4),P+=i(R.uncompressedSize,4),P+=i(g.length,2),P+=i(I.length,2),{fileRecord:l.LOCAL_FILE_HEADER+P+g+I,dirRecord:l.CENTRAL_FILE_HEADER+i(N,2)+P+i(y.length,2)+"\0\0\0\0"+i(x,4)+i(n,4)+g+I+y}}var a=e("../utils"),o=e("../stream/GenericWorker"),s=e("../utf8"),c=e("../crc32"),l=e("../signature");function d(e,t,r,i){o.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=r,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(d,o),d.prototype.push=function(e){var t=e.meta.percent||0,r=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:r?(t+100*(r-i-1))/r: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 r=n(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(e){this.accumulate=!1;var t,r=this.streamFiles&&!e.file.dir,a=n(e,r,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(a.dirRecord),r)this.push({data:(t=e,l.DATA_DESCRIPTOR+i(t.crc32,4)+i(t.compressedSize,4)+i(t.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:a.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 r,n,o,s,c,d,u=this.bytesWritten-e,h=(r=this.dirRecords.length,n=u,o=e,s=this.zipComment,c=this.encodeFileName,d=a.transformTo("string",c(s)),l.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(r,2)+i(r,2)+i(n,4)+i(o,4)+i(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!!o.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(!o.prototype.error.call(this,e))return!1;for(var r=0;r<t.length;r++)try{t[r].error(e)}catch(i){}return!0},d.prototype.lock=function(){o.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,r){var i=e("../compressions"),n=e("./ZipFileWorker");r.generateWorker=function(e,t,r){var a=new n(t.streamFiles,r,t.platform,t.encodeFileName),o=0;try{e.forEach(function(e,r){o++;var n=function(e,t){var r=e||t,n=i[r];if(!n)throw new Error(r+" is not a valid compression method !");return n}(r.options.compression,t.compression),s=r.options.compressionOptions||t.compressionOptions||{},c=r.dir,l=r.date;r._compressWorker(n,s).withStreamInfo("file",{name:e,dir:c,date:l,comment:r.comment||"",unixPermissions:r.unixPermissions,dosPermissions:r.dosPermissions}).pipe(a)}),a.entriesCount=o}catch(s){a.error(s)}return a}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,t,r){function i(){if(!(this instanceof i))return new i;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 i;for(var t in this)"function"!=typeof this[t]&&(e[t]=this[t]);return e}}(i.prototype=e("./object")).loadAsync=e("./load"),i.support=e("./support"),i.defaults=e("./defaults"),i.version="3.10.1",i.loadAsync=function(e,t){return(new i).loadAsync(e,t)},i.external=e("./external"),t.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,t,r){var i=e("./utils"),n=e("./external"),a=e("./utf8"),o=e("./zipEntries"),s=e("./stream/Crc32Probe"),c=e("./nodejsUtils");function l(e){return new n.Promise(function(t,r){var i=e.decompressed.getContentWorker().pipe(new s);i.on("error",function(e){r(e)}).on("end",function(){i.streamInfo.crc32!==e.decompressed.crc32?r(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}t.exports=function(e,t){var r=this;return t=i.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),c.isNode&&c.isStream(e)?n.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(e){var r=new o(t);return r.load(e),r}).then(function(e){var r=[n.Promise.resolve(e)],i=e.files;if(t.checkCRC32)for(var a=0;a<i.length;a++)r.push(l(i[a]));return n.Promise.all(r)}).then(function(e){for(var n=e.shift(),a=n.files,o=0;o<a.length;o++){var s=a[o],c=s.fileNameStr,l=i.resolve(s.fileNameStr);r.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||(r.file(l).unsafeOriginalName=c)}return n.zipComment.length&&(r.comment=n.zipComment),r})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,t,r){var i=e("../utils"),n=e("../stream/GenericWorker");function a(e,t){n.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}i.inherits(a,n),a.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()})},a.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},t.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,t,r){var i=e("readable-stream").Readable;function n(e,t,r){i.call(this,t),this._helper=e;var n=this;e.on("data",function(e,t){n.push(e)||n._helper.pause(),r&&r(t)}).on("error",function(e){n.emit("error",e)}).on("end",function(){n.push(null)})}e("../utils").inherits(n,i),n.prototype._read=function(){this._helper.resume()},t.exports=n},{"../utils":32,"readable-stream":16}],14:[function(e,t,r){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,r){function i(e,t,r){var i,n=a.getTypeOf(t),s=a.extend(r||{},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=m(e)),s.createFolders&&(i=f(e))&&g.call(this,i,!0);var u="string"===n&&!1===s.binary&&!1===s.base64;r&&void 0!==r.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",n="string");var _;_=t instanceof l||t instanceof o?t:h.isNode&&h.isStream(t)?new p(e,t):a.prepareContent(e,t,s.binary,s.optimizedBinaryString,s.base64);var v=new d(e,_,s);this.files[e]=v}var n=e("./utf8"),a=e("./utils"),o=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"),f=function(e){"/"===e.slice(-1)&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return 0<t?e.substring(0,t):""},m=function(e){return"/"!==e.slice(-1)&&(e+="/"),e},g=function(e,t){return t=void 0!==t?t:c.createFolders,e=m(e),this.files[e]||i.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function _(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,r,i;for(t in this.files)i=this.files[t],(r=t.slice(this.root.length,t.length))&&t.slice(0,this.root.length)===this.root&&e(r,i)},filter:function(e){var t=[];return this.forEach(function(r,i){e(r,i)&&t.push(i)}),t},file:function(e,t,r){if(1!==arguments.length)return e=this.root+e,i.call(this,e,t,r),this;if(_(e)){var n=e;return this.filter(function(e,t){return!t.dir&&n.test(e)})}var a=this.files[this.root+e];return a&&!a.dir?a:null},folder:function(e){if(!e)return this;if(_(e))return this.filter(function(t,r){return r.dir&&e.test(t)});var t=this.root+e,r=g.call(this,t),i=this.clone();return i.root=r.name,i},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 r=this.filter(function(t,r){return r.name.slice(0,e.length)===e}),i=0;i<r.length;i++)delete this.files[r[i].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,r={};try{if((r=a.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=r.type.toLowerCase(),r.compression=r.compression.toUpperCase(),"binarystring"===r.type&&(r.type="string"),!r.type)throw new Error("No output type specified.");a.checkSupport(r.type),"darwin"!==r.platform&&"freebsd"!==r.platform&&"linux"!==r.platform&&"sunos"!==r.platform||(r.platform="UNIX"),"win32"===r.platform&&(r.platform="DOS");var i=r.comment||this.comment||"";t=u.generateWorker(this,r,i)}catch(c){(t=new o("error")).error(c)}return new s(t,r.type||"string",r.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,r){t.exports=e("stream")},{stream:void 0}],17:[function(e,t,r){var i=e("./DataReader");function n(e){i.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=255&e[t]}e("../utils").inherits(n,i),n.prototype.byteAt=function(e){return this.data[this.zero+e]},n.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2),n=e.charCodeAt(3),a=this.length-4;0<=a;--a)if(this.data[a]===t&&this.data[a+1]===r&&this.data[a+2]===i&&this.data[a+3]===n)return a-this.zero;return-1},n.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2),n=e.charCodeAt(3),a=this.readData(4);return t===a[0]&&r===a[1]&&i===a[2]&&n===a[3]},n.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=n},{"../utils":32,"./DataReader":18}],18:[function(e,t,r){var i=e("../utils");function n(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}n.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,r=0;for(this.checkOffset(e),t=this.index+e-1;t>=this.index;t--)r=(r<<8)+this.byteAt(t);return this.index+=e,r},readString:function(e){return i.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=n},{"../utils":32}],19:[function(e,t,r){var i=e("./Uint8ArrayReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.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=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,r){var i=e("./DataReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},n.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},n.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},n.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=n},{"../utils":32,"./DataReader":18}],21:[function(e,t,r){var i=e("./ArrayReader");function n(e){i.call(this,e)}e("../utils").inherits(n,i),n.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=n},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,r){var i=e("../utils"),n=e("../support"),a=e("./ArrayReader"),o=e("./StringReader"),s=e("./NodeBufferReader"),c=e("./Uint8ArrayReader");t.exports=function(e){var t=i.getTypeOf(e);return i.checkSupport(t),"string"!==t||n.uint8array?"nodebuffer"===t?new s(e):n.uint8array?new c(i.transformTo("uint8array",e)):new a(i.transformTo("array",e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,r){r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(e,t,r){var i=e("./GenericWorker"),n=e("../utils");function a(e){i.call(this,"ConvertWorker to "+e),this.destType=e}n.inherits(a,i),a.prototype.processChunk=function(e){this.push({data:n.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,r){var i=e("./GenericWorker"),n=e("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,i),a.prototype.processChunk=function(e){this.streamInfo.crc32=n(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,r){var i=e("../utils"),n=e("./GenericWorker");function a(e){n.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}i.inherits(a,n),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}n.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,r){var i=e("../utils"),n=e("./GenericWorker");function a(e){n.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=i.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}i.inherits(a,n),a.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.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=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,r){function i(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}i.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(e){this.emit("error",e)}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 r=0;r<this._listeners[e].length;r++)this._listeners[e][r].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=i},{}],29:[function(e,t,r){var i=e("../utils"),n=e("./ConvertWorker"),a=e("./GenericWorker"),o=e("../base64"),s=e("../support"),c=e("../external"),l=null;if(s.nodestream)try{l=e("../nodejs/NodejsStreamOutputAdapter")}catch(u){}function d(e,t,r){var o=t;switch(t){case"blob":case"arraybuffer":o="uint8array";break;case"base64":o="string"}try{this._internalType=o,this._outputType=t,this._mimeType=r,i.checkSupport(o),this._worker=e.pipe(new n(o)),e.lock()}catch(s){this._worker=new a("error"),this._worker.error(s)}}d.prototype={accumulate:function(e){return function(e,t){return new c.Promise(function(r,n){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on("data",function(e,r){a.push(e),t&&t(r)}).on("error",function(e){a=[],n(e)}).on("end",function(){try{var e=function(e,t,r){switch(e){case"blob":return i.newBlob(i.transformTo("arraybuffer",t),r);case"base64":return o.encode(t);default:return i.transformTo(e,t)}}(c,function(e,t){var r,i=0,n=null,a=0;for(r=0;r<t.length;r++)a+=t[r].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(n=new Uint8Array(a),r=0;r<t.length;r++)n.set(t[r],i),i+=t[r].length;return n;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}(s,a),l);r(e)}catch(t){n(t)}a=[]}).resume()})}(this,e)},on:function(e,t){var r=this;return"data"===e?this._worker.on(e,function(e){t.call(r,e.data,e.meta)}):this._worker.on(e,function(){i.delay(t,arguments,r)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(i.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,r){if(r.base64=!0,r.array=!0,r.string=!0,r.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,r.nodebuffer="undefined"!=typeof Buffer,r.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)r.blob=!1;else{var i=new ArrayBuffer(0);try{r.blob=0===new Blob([i],{type:"application/zip"}).size}catch(a){try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(i),r.blob=0===n.getBlob("application/zip").size}catch(Xk){r.blob=!1}}}try{r.nodestream=!!e("readable-stream").Readable}catch(a){r.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,r){for(var i=e("./utils"),n=e("./support"),a=e("./nodejsUtils"),o=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(){o.call(this,"utf-8 decode"),this.leftOver=null}function d(){o.call(this,"utf-8 encode")}s[254]=s[254]=1,r.utf8encode=function(e){return n.nodebuffer?a.newBufferFrom(e,"utf-8"):function(e){var t,r,i,a,o,s=e.length,c=0;for(a=0;a<s;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(i=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(i-56320),a++),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=n.uint8array?new Uint8Array(c):new Array(c),a=o=0;o<c;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(i=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(i-56320),a++),r<128?t[o++]=r:(r<2048?t[o++]=192|r>>>6:(r<65536?t[o++]=224|r>>>12:(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63),t[o++]=128|r>>>6&63),t[o++]=128|63&r);return t}(e)},r.utf8decode=function(e){return n.nodebuffer?i.transformTo("nodebuffer",e).toString("utf-8"):function(e){var t,r,n,a,o=e.length,c=new Array(2*o);for(t=r=0;t<o;)if((n=e[t++])<128)c[r++]=n;else if(4<(a=s[n]))c[r++]=65533,t+=a-1;else{for(n&=2===a?31:3===a?15:7;1<a&&t<o;)n=n<<6|63&e[t++],a--;1<a?c[r++]=65533:n<65536?c[r++]=n:(n-=65536,c[r++]=55296|n>>10&1023,c[r++]=56320|1023&n)}return c.length!==r&&(c.subarray?c=c.subarray(0,r):c.length=r),i.applyFromCharCode(c)}(e=i.transformTo(n.uint8array?"uint8array":"array",e))},i.inherits(l,o),l.prototype.processChunk=function(e){var t=i.transformTo(n.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+s[e[r]]>t?r:t}(t),c=t;o!==t.length&&(n.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:r.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:r.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},r.Utf8DecodeWorker=l,i.inherits(d,o),d.prototype.processChunk=function(e){this.push({data:r.utf8encode(e.data),meta:e.meta})},r.Utf8EncodeWorker=d},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,r){var i=e("./support"),n=e("./base64"),a=e("./nodejsUtils"),o=e("./external");function s(e){return e}function c(e,t){for(var r=0;r<e.length;++r)t[r]=255&e.charCodeAt(r);return t}e("setimmediate"),r.newBlob=function(e,t){r.checkSupport("blob");try{return new Blob([e],{type:t})}catch(n){try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return i.append(e),i.getBlob(t)}catch(a){throw new Error("Bug : can't construct the Blob.")}}};var l={stringifyByChunk:function(e,t,r){var i=[],n=0,a=e.length;if(a<=r)return String.fromCharCode.apply(null,e);for(;n<a;)"array"===t||"nodebuffer"===t?i.push(String.fromCharCode.apply(null,e.slice(n,Math.min(n+r,a)))):i.push(String.fromCharCode.apply(null,e.subarray(n,Math.min(n+r,a)))),n+=r;return i.join("")},stringifyByChar:function(e){for(var t="",r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(e){return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch(e){return!1}}()}};function d(e){var t=65536,i=r.getTypeOf(e),n=!0;if("uint8array"===i?n=l.applyCanBeUsed.uint8array:"nodebuffer"===i&&(n=l.applyCanBeUsed.nodebuffer),n)for(;1<t;)try{return l.stringifyByChunk(e,i,t)}catch(a){t=Math.floor(t/2)}return l.stringifyByChar(e)}function u(e,t){for(var r=0;r<e.length;r++)t[r]=e[r];return t}r.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,a.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 a.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 a.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 a.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},r.transformTo=function(e,t){if(t=t||"",!e)return t;r.checkSupport(e);var i=r.getTypeOf(t);return h[i][e](t)},r.resolve=function(e){for(var t=e.split("/"),r=[],i=0;i<t.length;i++){var n=t[i];"."===n||""===n&&0!==i&&i!==t.length-1||(".."===n?r.pop():r.push(n))}return r.join("/")},r.getTypeOf=function(e){return"string"==typeof e?"string":"[object Array]"===Object.prototype.toString.call(e)?"array":i.nodebuffer&&a.isBuffer(e)?"nodebuffer":i.uint8array&&e instanceof Uint8Array?"uint8array":i.arraybuffer&&e instanceof ArrayBuffer?"arraybuffer":void 0},r.checkSupport=function(e){if(!i[e.toLowerCase()])throw new Error(e+" is not supported by this platform")},r.MAX_VALUE_16BITS=65535,r.MAX_VALUE_32BITS=-1,r.pretty=function(e){var t,r,i="";for(r=0;r<(e||"").length;r++)i+="\\x"+((t=e.charCodeAt(r))<16?"0":"")+t.toString(16).toUpperCase();return i},r.delay=function(e,t,r){setImmediate(function(){e.apply(r||null,t||[])})},r.inherits=function(e,t){function r(){}r.prototype=t.prototype,e.prototype=new r},r.extend=function(){var e,t,r={};for(e=0;e<arguments.length;e++)for(t in arguments[e])Object.prototype.hasOwnProperty.call(arguments[e],t)&&void 0===r[t]&&(r[t]=arguments[e][t]);return r},r.prepareContent=function(e,t,a,s,l){return o.Promise.resolve(t).then(function(e){return i.blob&&(e instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(e)))&&"undefined"!=typeof FileReader?new o.Promise(function(t,r){var i=new FileReader;i.onload=function(e){t(e.target.result)},i.onerror=function(e){r(e.target.error)},i.readAsArrayBuffer(e)}):e}).then(function(t){var d,u=r.getTypeOf(t);return u?("arraybuffer"===u?t=r.transformTo("uint8array",t):"string"===u&&(l?t=n.decode(t):a&&!0!==s&&(t=c(d=t,i.uint8array?new Uint8Array(d.length):new Array(d.length)))),t):o.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,r){var i=e("./reader/readerFor"),n=e("./utils"),a=e("./signature"),o=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 ("+n.pretty(t)+", expected "+n.pretty(e)+")")}},isSignature:function(e,t){var r=this.reader.index;this.reader.setIndex(e);var i=this.reader.readString(4)===t;return this.reader.setIndex(r),i},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",r=n.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(r)},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,r,i=this.zip64EndOfCentralSize-44;0<i;)e=this.reader.readInt(2),t=this.reader.readInt(4),r=this.reader.readData(t),this.zip64ExtensibleData[e]={id:e,length:t,value:r}},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(a.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(e=new o({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(a.CENTRAL_DIRECTORY_END);if(e<0)throw this.isSignature(0,a.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(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(e=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.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(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var r=this.centralDirOffset+this.centralDirSize;this.zip64&&(r+=20,r+=12+this.zip64EndOfCentralSize);var i=t-r;if(0<i)this.isSignature(t,a.CENTRAL_FILE_HEADER)||(this.reader.zero=i);else if(i<0)throw new Error("Corrupted zip: missing "+Math.abs(i)+" bytes.")},prepareReader:function(e){this.reader=i(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,r){var i=e("./reader/readerFor"),n=e("./utils"),a=e("./compressedObject"),o=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,r;if(e.skip(22),this.fileNameLength=e.readInt(2),r=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(r),-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 "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new a(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=i(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,r,i,n=e.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});e.index+4<n;)t=e.readInt(2),r=e.readInt(2),i=e.readData(r),this.extraFields[t]={id:t,length:r,value:i};e.setIndex(n)},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 r=n.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var i=this.findExtraFieldUnicodeComment();if(null!==i)this.fileCommentStr=i;else{var a=n.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(a)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=i(e.value);return 1!==t.readInt(1)||o(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=i(e.value);return 1!==t.readInt(1)||o(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,r){function i(e,t,r){this.name=e,this.dir=r.dir,this.date=r.date,this.comment=r.comment,this.unixPermissions=r.unixPermissions,this.dosPermissions=r.dosPermissions,this._data=t,this._dataBinary=r.binary,this.options={compression:r.compression,compressionOptions:r.compressionOptions}}var n=e("./stream/StreamHelper"),a=e("./stream/DataWorker"),o=e("./utf8"),s=e("./compressedObject"),c=e("./stream/GenericWorker");i.prototype={internalStream:function(e){var t=null,r="string";try{if(!e)throw new Error("No output type specified.");var i="string"===(r=e.toLowerCase())||"text"===r;"binarystring"!==r&&"text"!==r||(r="string"),t=this._decompressWorker();var a=!this._dataBinary;a&&!i&&(t=t.pipe(new o.Utf8EncodeWorker)),!a&&i&&(t=t.pipe(new o.Utf8DecodeWorker))}catch(s){(t=new c("error")).error(s)}return new n(t,r,"")},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 r=this._decompressWorker();return this._dataBinary||(r=r.pipe(new o.Utf8EncodeWorker)),s.createWorkerFrom(r,e,t)},_decompressWorker:function(){return this._data instanceof s?this._data.getContentWorker():this._data instanceof c?this._data:new a(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++)i.prototype[l[u]]=d;t.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,t,r){(function(e){var r,i,n=e.MutationObserver||e.WebKitMutationObserver;if(n){var a=0,o=new n(d),s=e.document.createTextNode("");o.observe(s,{characterData:!0}),r=function(){s.data=a=++a%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="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,r=function(){c.port2.postMessage(0)}}var l=[];function d(){var e,t;i=!0;for(var r=l.length;r;){for(t=l,l=[],e=-1;++e<r;)t[e]();r=l.length}i=!1}t.exports=function(e){1!==l.push(e)||i||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],37:[function(e,t,r){var i=e("immediate");function n(){}var a={},o=["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!==n&&p(this,e)}function d(e,t,r){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof r&&(this.onRejected=r,this.callRejected=this.otherCallRejected)}function u(e,t,r){i(function(){var i;try{i=t(r)}catch(cL){return a.reject(e,cL)}i===e?a.reject(e,new TypeError("Cannot resolve promise with itself")):a.resolve(e,i)})}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 r=!1;function i(t){r||(r=!0,a.reject(e,t))}function n(t){r||(r=!0,a.resolve(e,t))}var o=f(function(){t(n,i)});"error"===o.status&&i(o.value)}function f(e,t){var r={};try{r.value=e(t),r.status="success"}catch(i){r.status="error",r.value=i}return r}(t.exports=l).prototype.finally=function(e){if("function"!=typeof e)return this;var t=this.constructor;return this.then(function(r){return t.resolve(e()).then(function(){return r})},function(r){return t.resolve(e()).then(function(){throw r})})},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===o)return this;var r=new this.constructor(n);return this.state!==c?u(r,this.state===s?e:t,this.outcome):this.queue.push(new d(r,e,t)),r},d.prototype.callFulfilled=function(e){a.resolve(this.promise,e)},d.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},d.prototype.callRejected=function(e){a.reject(this.promise,e)},d.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},a.resolve=function(e,t){var r=f(h,t);if("error"===r.status)return a.reject(e,r.value);var i=r.value;if(i)p(e,i);else{e.state=s,e.outcome=t;for(var n=-1,o=e.queue.length;++n<o;)e.queue[n].callFulfilled(t)}return e},a.reject=function(e,t){e.state=o,e.outcome=t;for(var r=-1,i=e.queue.length;++r<i;)e.queue[r].callRejected(t);return e},l.resolve=function(e){return e instanceof this?e:a.resolve(new this(n),e)},l.reject=function(e){var t=new this(n);return a.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 r=e.length,i=!1;if(!r)return this.resolve([]);for(var o=new Array(r),s=0,c=-1,l=new this(n);++c<r;)d(e[c],c);return l;function d(e,n){t.resolve(e).then(function(e){o[n]=e,++s!==r||i||(i=!0,a.resolve(l,o))},function(e){i||(i=!0,a.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,r=e.length,i=!1;if(!r)return this.resolve([]);for(var o=-1,s=new this(n);++o<r;)t=e[o],this.resolve(t).then(function(e){i||(i=!0,a.resolve(s,e))},function(e){i||(i=!0,a.reject(s,e))});return s}},{immediate:36}],38:[function(e,t,r){var i={};(0,e("./lib/utils/common").assign)(i,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),t.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,t,r){var i=e("./zlib/deflate"),n=e("./utils/common"),a=e("./utils/strings"),o=e("./zlib/messages"),s=e("./zlib/zstream"),c=Object.prototype.toString;function l(e){if(!(this instanceof l))return new l(e);this.options=n.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 r=i.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(0!==r)throw new Error(o[r]);if(t.header&&i.deflateSetHeader(this.strm,t.header),t.dictionary){var d;if(d="string"==typeof t.dictionary?a.string2buf(t.dictionary):"[object ArrayBuffer]"===c.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,0!==(r=i.deflateSetDictionary(this.strm,d)))throw new Error(o[r]);this._dict_set=!0}}function d(e,t){var r=new l(t);if(r.push(e,!0),r.err)throw r.msg||o[r.err];return r.result}l.prototype.push=function(e,t){var r,o,s=this.strm,l=this.options.chunkSize;if(this.ended)return!1;o=t===~~t?t:!0===t?4:0,"string"==typeof e?s.input=a.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 n.Buf8(l),s.next_out=0,s.avail_out=l),1!==(r=i.deflate(s,o))&&0!==r)return this.onEnd(r),!(this.ended=!0);0!==s.avail_out&&(0!==s.avail_in||4!==o&&2!==o)||("string"===this.options.to?this.onData(a.buf2binstring(n.shrinkBuf(s.output,s.next_out))):this.onData(n.shrinkBuf(s.output,s.next_out)))}while((0<s.avail_in||0===s.avail_out)&&1!==r);return 4===o?(r=i.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,0===r):2!==o||(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=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Deflate=l,r.deflate=d,r.deflateRaw=function(e,t){return(t=t||{}).raw=!0,d(e,t)},r.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,r){var i=e("./zlib/inflate"),n=e("./utils/common"),a=e("./utils/strings"),o=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=n.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 r=i.inflateInit2(this.strm,t.windowBits);if(r!==o.Z_OK)throw new Error(s[r]);this.header=new l,i.inflateGetHeader(this.strm,this.header)}function h(e,t){var r=new u(t);if(r.push(e,!0),r.err)throw r.msg||s[r.err];return r.result}u.prototype.push=function(e,t){var r,s,c,l,u,h,p=this.strm,f=this.options.chunkSize,m=this.options.dictionary,g=!1;if(this.ended)return!1;s=t===~~t?t:!0===t?o.Z_FINISH:o.Z_NO_FLUSH,"string"==typeof e?p.input=a.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 n.Buf8(f),p.next_out=0,p.avail_out=f),(r=i.inflate(p,o.Z_NO_FLUSH))===o.Z_NEED_DICT&&m&&(h="string"==typeof m?a.string2buf(m):"[object ArrayBuffer]"===d.call(m)?new Uint8Array(m):m,r=i.inflateSetDictionary(this.strm,h)),r===o.Z_BUF_ERROR&&!0===g&&(r=o.Z_OK,g=!1),r!==o.Z_STREAM_END&&r!==o.Z_OK)return this.onEnd(r),!(this.ended=!0);p.next_out&&(0!==p.avail_out&&r!==o.Z_STREAM_END&&(0!==p.avail_in||s!==o.Z_FINISH&&s!==o.Z_SYNC_FLUSH)||("string"===this.options.to?(c=a.utf8border(p.output,p.next_out),l=p.next_out-c,u=a.buf2string(p.output,c),p.next_out=l,p.avail_out=f-l,l&&n.arraySet(p.output,p.output,c,l,0),this.onData(u)):this.onData(n.shrinkBuf(p.output,p.next_out)))),0===p.avail_in&&0===p.avail_out&&(g=!0)}while((0<p.avail_in||0===p.avail_out)&&r!==o.Z_STREAM_END);return r===o.Z_STREAM_END&&(s=o.Z_FINISH),s===o.Z_FINISH?(r=i.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===o.Z_OK):s!==o.Z_SYNC_FLUSH||(this.onEnd(o.Z_OK),!(p.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===o.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},r.Inflate=u,r.inflate=h,r.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},r.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,r){var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;r.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var r=t.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}}return e},r.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,r,i,n){if(t.subarray&&e.subarray)e.set(t.subarray(r,r+i),n);else for(var a=0;a<i;a++)e[n+a]=t[r+a]},flattenChunks:function(e){var t,r,i,n,a,o;for(t=i=0,r=e.length;t<r;t++)i+=e[t].length;for(o=new Uint8Array(i),t=n=0,r=e.length;t<r;t++)a=e[t],o.set(a,n),n+=a.length;return o}},a={arraySet:function(e,t,r,i,n){for(var a=0;a<i;a++)e[n+a]=t[r+a]},flattenChunks:function(e){return[].concat.apply([],e)}};r.setTyped=function(e){e?(r.Buf8=Uint8Array,r.Buf16=Uint16Array,r.Buf32=Int32Array,r.assign(r,n)):(r.Buf8=Array,r.Buf16=Array,r.Buf32=Array,r.assign(r,a))},r.setTyped(i)},{}],42:[function(e,t,r){var i=e("./common"),n=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch(l){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(l){a=!1}for(var o=new i.Buf8(256),s=0;s<256;s++)o[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&&a||!e.subarray&&n))return String.fromCharCode.apply(null,i.shrinkBuf(e,t));for(var r="",o=0;o<t;o++)r+=String.fromCharCode(e[o]);return r}o[254]=o[254]=1,r.string2buf=function(e){var t,r,n,a,o,s=e.length,c=0;for(a=0;a<s;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),c+=r<128?1:r<2048?2:r<65536?3:4;for(t=new i.Buf8(c),a=o=0;o<c;a++)55296==(64512&(r=e.charCodeAt(a)))&&a+1<s&&56320==(64512&(n=e.charCodeAt(a+1)))&&(r=65536+(r-55296<<10)+(n-56320),a++),r<128?t[o++]=r:(r<2048?t[o++]=192|r>>>6:(r<65536?t[o++]=224|r>>>12:(t[o++]=240|r>>>18,t[o++]=128|r>>>12&63),t[o++]=128|r>>>6&63),t[o++]=128|63&r);return t},r.buf2binstring=function(e){return c(e,e.length)},r.binstring2buf=function(e){for(var t=new i.Buf8(e.length),r=0,n=t.length;r<n;r++)t[r]=e.charCodeAt(r);return t},r.buf2string=function(e,t){var r,i,n,a,s=t||e.length,l=new Array(2*s);for(r=i=0;r<s;)if((n=e[r++])<128)l[i++]=n;else if(4<(a=o[n]))l[i++]=65533,r+=a-1;else{for(n&=2===a?31:3===a?15:7;1<a&&r<s;)n=n<<6|63&e[r++],a--;1<a?l[i++]=65533:n<65536?l[i++]=n:(n-=65536,l[i++]=55296|n>>10&1023,l[i++]=56320|1023&n)}return c(l,i)},r.utf8border=function(e,t){var r;for((t=t||e.length)>e.length&&(t=e.length),r=t-1;0<=r&&128==(192&e[r]);)r--;return r<0||0===r?t:r+o[e[r]]>t?r:t}},{"./common":41}],43:[function(e,t,r){t.exports=function(e,t,r,i){for(var n=65535&e,a=e>>>16&65535,o=0;0!==r;){for(r-=o=2e3<r?2e3:r;a=a+(n=n+t[i++]|0)|0,--o;);n%=65521,a%=65521}return n|a<<16}},{}],44:[function(e,t,r){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,r){var i=function(){for(var e,t=[],r=0;r<256;r++){e=r;for(var i=0;i<8;i++)e=1&e?3988292384^e>>>1:e>>>1;t[r]=e}return t}();t.exports=function(e,t,r,n){var a=i,o=n+r;e^=-1;for(var s=n;s<o;s++)e=e>>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,r){var i,n=e("../utils/common"),a=e("./trees"),o=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 f(e){return(e<<1)-(4<e?9:0)}function m(e){for(var t=e.length;0<=--t;)e[t]=0}function g(e){var t=e.state,r=t.pending;r>e.avail_out&&(r=e.avail_out),0!==r&&(n.arraySet(e.output,t.pending_buf,t.pending_out,r,e.next_out),e.next_out+=r,t.pending_out+=r,e.total_out+=r,e.avail_out-=r,t.pending-=r,0===t.pending&&(t.pending_out=0))}function _(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,g(e.strm)}function v(e,t){e.pending_buf[e.pending++]=t}function y(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function E(e,t){var r,i,n=e.max_chain_length,a=e.strstart,o=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,f=e.strstart+d,m=l[a+o-1],g=l[a+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(l[(r=t)+o]===g&&l[r+o-1]===m&&l[r]===l[a]&&l[++r]===l[a+1]){a+=2,r++;do{}while(l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&l[++a]===l[++r]&&a<f);if(i=d-(f-a),a=f-d,o<i){if(e.match_start=t,s<=(o=i))break;m=l[a+o-1],g=l[a+o]}}}while((t=p[t&h])>c&&0!=--n);return o<=e.lookahead?o:e.lookahead}function b(e){var t,r,i,a,c,l,d,h,p,f,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-u)){for(n.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=r=e.hash_size;i=e.head[--t],e.head[t]=m<=i?i-m:0,--r;);for(t=r=m;i=e.prev[--t],e.prev[t]=m<=i?i-m:0,--r;);a+=m}if(0===e.strm.avail_in)break;if(l=e.strm,d=e.window,h=e.strstart+e.lookahead,f=void 0,(p=a)<(f=l.avail_in)&&(f=p),r=0===f?0:(l.avail_in-=f,n.arraySet(d,l.input,l.next_in,f,h),1===l.state.wrap?l.adler=o(l.adler,d,f,h):2===l.state.wrap&&(l.adler=s(l.adler,d,f,h)),l.next_in+=f,l.total_in+=f,f),e.lookahead+=r,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 w(e,t){for(var r,i;;){if(e.lookahead<u){if(b(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==r&&e.strstart-r<=e.w_size-u&&(e.match_length=E(e,r)),e.match_length>=3)if(i=a._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,r=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 i=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function I(e,t){for(var r,i,n;;){if(e.lookahead<u){if(b(e),e.lookahead<u&&0===t)return 1;if(0===e.lookahead)break}if(r=0,e.lookahead>=3&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==r&&e.prev_length<e.max_lazy_match&&e.strstart-r<=e.w_size-u&&(e.match_length=E(e,r),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(n=e.strstart+e.lookahead-3,i=a._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<=n&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+3-1])&e.hash_mask,r=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!=--e.prev_length;);if(e.match_available=0,e.match_length=2,e.strstart++,i&&(_(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if((i=a._tr_tally(e,0,e.window[e.strstart-1]))&&_(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&&(i=a._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}function T(e,t,r,i,n){this.good_length=e,this.max_lazy=t,this.nice_length=r,this.max_chain=i,this.func=n}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 n.Buf16(1146),this.dyn_dtree=new n.Buf16(122),this.bl_tree=new n.Buf16(78),m(this.dyn_ltree),m(this.dyn_dtree),m(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(16),this.heap=new n.Buf16(573),m(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(573),m(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 k(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,a._tr_init(t),0):p(e,l)}function A(e){var t,r=k(e);return 0===r&&((t=e.state).window_size=2*t.w_size,m(t.head),t.max_lazy_match=i[t.level].max_lazy,t.good_match=i[t.level].good_length,t.nice_match=i[t.level].nice_length,t.max_chain_length=i[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0),r}function R(e,t,r,i,a,o){if(!e)return l;var s=1;if(-1===t&&(t=6),i<0?(s=0,i=-i):15<i&&(s=2,i-=16),a<1||9<a||8!==r||i<8||15<i||t<0||9<t||o<0||4<o)return p(e,l);8===i&&(i=9);var c=new S;return(e.state=c).strm=e,c.wrap=s,c.gzhead=null,c.w_bits=i,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.hash_bits=a+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 n.Buf8(2*c.w_size),c.head=new n.Buf16(c.hash_size),c.prev=new n.Buf16(c.w_size),c.lit_bufsize=1<<a+6,c.pending_buf_size=4*c.lit_bufsize,c.pending_buf=new n.Buf8(c.pending_buf_size),c.d_buf=1*c.lit_bufsize,c.l_buf=3*c.lit_bufsize,c.level=t,c.strategy=o,c.method=r,A(e)}i=[new T(0,0,0,0,function(e,t){var r=65535;for(r>e.pending_buf_size-5&&(r=e.pending_buf_size-5);;){if(e.lookahead<=1){if(b(e),0===e.lookahead&&0===t)return 1;if(0===e.lookahead)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+r;if((0===e.strstart||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,_(e,!1),0===e.strm.avail_out)||e.strstart-e.block_start>=e.w_size-u&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):(e.strstart>e.block_start&&(_(e,!1),e.strm.avail_out),1)}),new T(4,4,8,4,w),new T(4,5,16,8,w),new T(4,6,32,32,w),new T(4,4,16,16,I),new T(8,16,32,32,I),new T(8,16,128,128,I),new T(8,32,128,256,I),new T(32,128,258,1024,I),new T(32,258,258,4096,I)],r.deflateInit=function(e,t){return R(e,t,8,15,8,0)},r.deflateInit2=R,r.deflateReset=A,r.deflateResetKeep=k,r.deflateSetHeader=function(e,t){return e&&e.state?2!==e.state.wrap?l:(e.state.gzhead=t,0):l},r.deflate=function(e,t){var r,n,o,c;if(!e||!e.state||5<t||t<0)return e?p(e,l):l;if(n=e.state,!e.output||!e.input&&0!==e.avail_in||666===n.status&&4!==t)return p(e,0===e.avail_out?-5:l);if(n.strm=e,r=n.last_flush,n.last_flush=t,42===n.status)if(2===n.wrap)e.adler=0,v(n,31),v(n,139),v(n,8),n.gzhead?(v(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),v(n,255&n.gzhead.time),v(n,n.gzhead.time>>8&255),v(n,n.gzhead.time>>16&255),v(n,n.gzhead.time>>24&255),v(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),v(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(v(n,255&n.gzhead.extra.length),v(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=s(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69):(v(n,0),v(n,0),v(n,0),v(n,0),v(n,0),v(n,9===n.level?2:2<=n.strategy||n.level<2?4:0),v(n,3),n.status=h);else{var u=8+(n.w_bits-8<<4)<<8;u|=(2<=n.strategy||n.level<2?0:n.level<6?1:6===n.level?2:3)<<6,0!==n.strstart&&(u|=32),u+=31-u%31,n.status=h,y(n,u),0!==n.strstart&&(y(n,e.adler>>>16),y(n,65535&e.adler)),e.adler=1}if(69===n.status)if(n.gzhead.extra){for(o=n.pending;n.gzindex<(65535&n.gzhead.extra.length)&&(n.pending!==n.pending_buf_size||(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending!==n.pending_buf_size));)v(n,255&n.gzhead.extra[n.gzindex]),n.gzindex++;n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),n.gzindex===n.gzhead.extra.length&&(n.gzindex=0,n.status=73)}else n.status=73;if(73===n.status)if(n.gzhead.name){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,v(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.gzindex=0,n.status=91)}else n.status=91;if(91===n.status)if(n.gzhead.comment){o=n.pending;do{if(n.pending===n.pending_buf_size&&(n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),g(e),o=n.pending,n.pending===n.pending_buf_size)){c=1;break}c=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,v(n,c)}while(0!==c);n.gzhead.hcrc&&n.pending>o&&(e.adler=s(e.adler,n.pending_buf,n.pending-o,o)),0===c&&(n.status=103)}else n.status=103;if(103===n.status&&(n.gzhead.hcrc?(n.pending+2>n.pending_buf_size&&g(e),n.pending+2<=n.pending_buf_size&&(v(n,255&e.adler),v(n,e.adler>>8&255),e.adler=0,n.status=h)):n.status=h),0!==n.pending){if(g(e),0===e.avail_out)return n.last_flush=-1,0}else if(0===e.avail_in&&f(t)<=f(r)&&4!==t)return p(e,-5);if(666===n.status&&0!==e.avail_in)return p(e,-5);if(0!==e.avail_in||0!==n.lookahead||0!==t&&666!==n.status){var E=2===n.strategy?function(e,t){for(var r;;){if(0===e.lookahead&&(b(e),0===e.lookahead)){if(0===t)return 1;break}if(e.match_length=0,r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(n,t):3===n.strategy?function(e,t){for(var r,i,n,o,s=e.window;;){if(e.lookahead<=d){if(b(e),e.lookahead<=d&&0===t)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&0<e.strstart&&(i=s[n=e.strstart-1])===s[++n]&&i===s[++n]&&i===s[++n]){o=e.strstart+d;do{}while(i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&i===s[++n]&&n<o);e.match_length=d-(o-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(r=a._tr_tally(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(r=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),r&&(_(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,4===t?(_(e,!0),0===e.strm.avail_out?3:4):e.last_lit&&(_(e,!1),0===e.strm.avail_out)?1:2}(n,t):i[n.level].func(n,t);if(3!==E&&4!==E||(n.status=666),1===E||3===E)return 0===e.avail_out&&(n.last_flush=-1),0;if(2===E&&(1===t?a._tr_align(n):5!==t&&(a._tr_stored_block(n,0,0,!1),3===t&&(m(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),g(e),0===e.avail_out))return n.last_flush=-1,0}return 4!==t?0:n.wrap<=0?1:(2===n.wrap?(v(n,255&e.adler),v(n,e.adler>>8&255),v(n,e.adler>>16&255),v(n,e.adler>>24&255),v(n,255&e.total_in),v(n,e.total_in>>8&255),v(n,e.total_in>>16&255),v(n,e.total_in>>24&255)):(y(n,e.adler>>>16),y(n,65535&e.adler)),g(e),0<n.wrap&&(n.wrap=-n.wrap),0!==n.pending?0:1)},r.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},r.deflateSetDictionary=function(e,t){var r,i,a,s,c,d,u,h,p=t.length;if(!e||!e.state||2===(s=(r=e.state).wrap)||1===s&&42!==r.status||r.lookahead)return l;for(1===s&&(e.adler=o(e.adler,t,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(m(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new n.Buf8(r.w_size),n.arraySet(h,t,p-r.w_size,r.w_size,0),t=h,p=r.w_size),c=e.avail_in,d=e.next_in,u=e.input,e.avail_in=p,e.next_in=0,e.input=t,b(r);r.lookahead>=3;){for(i=r.strstart,a=r.lookahead-2;r.ins_h=(r.ins_h<<r.hash_shift^r.window[i+3-1])&r.hash_mask,r.prev[i&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=i,i++,--a;);r.strstart=i,r.lookahead=2,b(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=d,e.input=u,e.avail_in=c,r.wrap=s,0},r.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,t,r){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,r){t.exports=function(e,t){var r,i,n,a,o,s,c,l,d,u,h,p,f,m,g,_,v,y,E,b,w,I,T,S,k;r=e.state,i=e.next_in,S=e.input,n=i+(e.avail_in-5),a=e.next_out,k=e.output,o=a-(t-e.avail_out),s=a+(e.avail_out-257),c=r.dmax,l=r.wsize,d=r.whave,u=r.wnext,h=r.window,p=r.hold,f=r.bits,m=r.lencode,g=r.distcode,_=(1<<r.lenbits)-1,v=(1<<r.distbits)-1;e:do{f<15&&(p+=S[i++]<<f,f+=8,p+=S[i++]<<f,f+=8),y=m[p&_];t:for(;;){if(p>>>=E=y>>>24,f-=E,0==(E=y>>>16&255))k[a++]=65535&y;else{if(!(16&E)){if(!(64&E)){y=m[(65535&y)+(p&(1<<E)-1)];continue t}if(32&E){r.mode=12;break e}e.msg="invalid literal/length code",r.mode=30;break e}b=65535&y,(E&=15)&&(f<E&&(p+=S[i++]<<f,f+=8),b+=p&(1<<E)-1,p>>>=E,f-=E),f<15&&(p+=S[i++]<<f,f+=8,p+=S[i++]<<f,f+=8),y=g[p&v];r:for(;;){if(p>>>=E=y>>>24,f-=E,!(16&(E=y>>>16&255))){if(!(64&E)){y=g[(65535&y)+(p&(1<<E)-1)];continue r}e.msg="invalid distance code",r.mode=30;break e}if(w=65535&y,f<(E&=15)&&(p+=S[i++]<<f,(f+=8)<E&&(p+=S[i++]<<f,f+=8)),c<(w+=p&(1<<E)-1)){e.msg="invalid distance too far back",r.mode=30;break e}if(p>>>=E,f-=E,(E=a-o)<w){if(d<(E=w-E)&&r.sane){e.msg="invalid distance too far back",r.mode=30;break e}if(T=h,(I=0)===u){if(I+=l-E,E<b){for(b-=E;k[a++]=h[I++],--E;);I=a-w,T=k}}else if(u<E){if(I+=l+u-E,(E-=u)<b){for(b-=E;k[a++]=h[I++],--E;);if(I=0,u<b){for(b-=E=u;k[a++]=h[I++],--E;);I=a-w,T=k}}}else if(I+=u-E,E<b){for(b-=E;k[a++]=h[I++],--E;);I=a-w,T=k}for(;2<b;)k[a++]=T[I++],k[a++]=T[I++],k[a++]=T[I++],b-=3;b&&(k[a++]=T[I++],1<b&&(k[a++]=T[I++]))}else{for(I=a-w;k[a++]=k[I++],k[a++]=k[I++],k[a++]=k[I++],2<(b-=3););b&&(k[a++]=k[I++],1<b&&(k[a++]=k[I++]))}break}}break}}while(i<n&&a<s);i-=b=f>>3,p&=(1<<(f-=b<<3))-1,e.next_in=i,e.next_out=a,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=a<s?s-a+257:257-(a-s),r.hold=p,r.bits=f}},{}],49:[function(e,t,r){var i=e("../utils/common"),n=e("./adler32"),a=e("./crc32"),o=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 i.Buf16(320),this.work=new i.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 i.Buf32(852),t.distcode=t.distdyn=new i.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 r,i;return e&&e.state?(i=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?c:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=r,i.wbits=t,h(e))):c}function f(e,t){var r,i;return e?(i=new d,(e.state=i).window=null,0!==(r=p(e,t))&&(e.state=null),r):c}var m,g,_=!0;function v(e){if(_){var t;for(m=new i.Buf32(512),g=new i.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,m,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;s(2,e.lens,0,32,g,0,e.work,{bits:5}),_=!1}e.lencode=m,e.lenbits=9,e.distcode=g,e.distbits=5}function y(e,t,r,n){var a,o=e.state;return null===o.window&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new i.Buf8(o.wsize)),n>=o.wsize?(i.arraySet(o.window,t,r-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(n<(a=o.wsize-o.wnext)&&(a=n),i.arraySet(o.window,t,r-n,a,o.wnext),(n-=a)?(i.arraySet(o.window,t,r-n,n,0),o.wnext=n,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=a))),0}r.inflateReset=h,r.inflateReset2=p,r.inflateResetKeep=u,r.inflateInit=function(e){return f(e,15)},r.inflateInit2=f,r.inflate=function(e,t){var r,d,u,h,p,f,m,g,_,E,b,w,I,T,S,k,A,R,C,D,O,L,x,N,P=0,M=new i.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===(r=e.state).mode&&(r.mode=13),p=e.next_out,u=e.output,m=e.avail_out,h=e.next_in,d=e.input,f=e.avail_in,g=r.hold,_=r.bits,E=f,b=m,L=0;e:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(2&r.wrap&&35615===g){M[r.check=0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0),_=g=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&g)<<8)+(g>>8))%31){e.msg="incorrect header check",r.mode=30;break}if(8!=(15&g)){e.msg="unknown compression method",r.mode=30;break}if(_-=4,O=8+(15&(g>>>=4)),0===r.wbits)r.wbits=O;else if(O>r.wbits){e.msg="invalid window size",r.mode=30;break}r.dmax=1<<O,e.adler=r.check=1,r.mode=512&g?10:12,_=g=0;break;case 2:for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(r.flags=g,8!=(255&r.flags)){e.msg="unknown compression method",r.mode=30;break}if(57344&r.flags){e.msg="unknown header flags set",r.mode=30;break}r.head&&(r.head.text=g>>8&1),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0,r.mode=3;case 3:for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.head&&(r.head.time=g),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,M[2]=g>>>16&255,M[3]=g>>>24&255,r.check=a(r.check,M,4,0)),_=g=0,r.mode=4;case 4:for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.head&&(r.head.xflags=255&g,r.head.os=g>>8),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0,r.mode=5;case 5:if(1024&r.flags){for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.length=g,r.head&&(r.head.extra_len=g),512&r.flags&&(M[0]=255&g,M[1]=g>>>8&255,r.check=a(r.check,M,2,0)),_=g=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(f<(w=r.length)&&(w=f),w&&(r.head&&(O=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),i.arraySet(r.head.extra,d,h,w,O)),512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,r.length-=w),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===f)break e;for(w=0;O=d[h+w++],r.head&&O&&r.length<65536&&(r.head.name+=String.fromCharCode(O)),O&&w<f;);if(512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,O)break e}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===f)break e;for(w=0;O=d[h+w++],r.head&&O&&r.length<65536&&(r.head.comment+=String.fromCharCode(O)),O&&w<f;);if(512&r.flags&&(r.check=a(r.check,d,w,h)),f-=w,h+=w,O)break e}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;_<16;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g!==(65535&r.check)){e.msg="header crc mismatch",r.mode=30;break}_=g=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}e.adler=r.check=l(g),_=g=0,r.mode=11;case 11:if(0===r.havedict)return e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,2;e.adler=r.check=1,r.mode=12;case 12:if(5===t||6===t)break e;case 13:if(r.last){g>>>=7&_,_-=7&_,r.mode=27;break}for(;_<3;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}switch(r.last=1&g,_-=1,3&(g>>>=1)){case 0:r.mode=14;break;case 1:if(v(r),r.mode=20,6!==t)break;g>>>=2,_-=2;break e;case 2:r.mode=17;break;case 3:e.msg="invalid block type",r.mode=30}g>>>=2,_-=2;break;case 14:for(g>>>=7&_,_-=7&_;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if((65535&g)!=(g>>>16^65535)){e.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&g,_=g=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(w=r.length){if(f<w&&(w=f),m<w&&(w=m),0===w)break e;i.arraySet(u,d,h,w,p),f-=w,h+=w,m-=w,p+=w,r.length-=w;break}r.mode=12;break;case 17:for(;_<14;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(r.nlen=257+(31&g),g>>>=5,_-=5,r.ndist=1+(31&g),g>>>=5,_-=5,r.ncode=4+(15&g),g>>>=4,_-=4,286<r.nlen||30<r.ndist){e.msg="too many length or distance symbols",r.mode=30;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;_<3;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.lens[U[r.have++]]=7&g,g>>>=3,_-=3}for(;r.have<19;)r.lens[U[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,x={bits:r.lenbits},L=s(0,r.lens,0,19,r.lencode,0,r.work,x),r.lenbits=x.bits,L){e.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;k=(P=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(A<16)g>>>=S,_-=S,r.lens[r.have++]=A;else{if(16===A){for(N=S+2;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g>>>=S,_-=S,0===r.have){e.msg="invalid bit length repeat",r.mode=30;break}O=r.lens[r.have-1],w=3+(3&g),g>>>=2,_-=2}else if(17===A){for(N=S+3;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}_-=S,O=0,w=3+(7&(g>>>=S)),g>>>=3,_-=3}else{for(N=S+7;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}_-=S,O=0,w=11+(127&(g>>>=S)),g>>>=7,_-=7}if(r.have+w>r.nlen+r.ndist){e.msg="invalid bit length repeat",r.mode=30;break}for(;w--;)r.lens[r.have++]=O}}if(30===r.mode)break;if(0===r.lens[256]){e.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,x={bits:r.lenbits},L=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,x),r.lenbits=x.bits,L){e.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,x={bits:r.distbits},L=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,x),r.distbits=x.bits,L){e.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=f&&258<=m){e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,o(e,b),p=e.next_out,u=e.output,m=e.avail_out,h=e.next_in,d=e.input,f=e.avail_in,g=r.hold,_=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;k=(P=r.lencode[g&(1<<r.lenbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(k&&!(240&k)){for(R=S,C=k,D=A;k=(P=r.lencode[D+((g&(1<<R+C)-1)>>R)])>>>16&255,A=65535&P,!(R+(S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}g>>>=R,_-=R,r.back+=R}if(g>>>=S,_-=S,r.back+=S,r.length=A,0===k){r.mode=26;break}if(32&k){r.back=-1,r.mode=12;break}if(64&k){e.msg="invalid literal/length code",r.mode=30;break}r.extra=15&k,r.mode=22;case 22:if(r.extra){for(N=r.extra;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.length+=g&(1<<r.extra)-1,g>>>=r.extra,_-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;k=(P=r.distcode[g&(1<<r.distbits)-1])>>>16&255,A=65535&P,!((S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(!(240&k)){for(R=S,C=k,D=A;k=(P=r.distcode[D+((g&(1<<R+C)-1)>>R)])>>>16&255,A=65535&P,!(R+(S=P>>>24)<=_);){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}g>>>=R,_-=R,r.back+=R}if(g>>>=S,_-=S,r.back+=S,64&k){e.msg="invalid distance code",r.mode=30;break}r.offset=A,r.extra=15&k,r.mode=24;case 24:if(r.extra){for(N=r.extra;_<N;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}r.offset+=g&(1<<r.extra)-1,g>>>=r.extra,_-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===m)break e;if(w=b-m,r.offset>w){if((w=r.offset-w)>r.whave&&r.sane){e.msg="invalid distance too far back",r.mode=30;break}I=w>r.wnext?(w-=r.wnext,r.wsize-w):r.wnext-w,w>r.length&&(w=r.length),T=r.window}else T=u,I=p-r.offset,w=r.length;for(m<w&&(w=m),m-=w,r.length-=w;u[p++]=T[I++],--w;);0===r.length&&(r.mode=21);break;case 26:if(0===m)break e;u[p++]=r.length,m--,r.mode=21;break;case 27:if(r.wrap){for(;_<32;){if(0===f)break e;f--,g|=d[h++]<<_,_+=8}if(b-=m,e.total_out+=b,r.total+=b,b&&(e.adler=r.check=r.flags?a(r.check,u,b,p-b):n(r.check,u,b,p-b)),b=m,(r.flags?g:l(g))!==r.check){e.msg="incorrect data check",r.mode=30;break}_=g=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;_<32;){if(0===f)break e;f--,g+=d[h++]<<_,_+=8}if(g!==(4294967295&r.total)){e.msg="incorrect length check",r.mode=30;break}_=g=0}r.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;default:return c}return e.next_out=p,e.avail_out=m,e.next_in=h,e.avail_in=f,r.hold=g,r.bits=_,(r.wsize||b!==e.avail_out&&r.mode<30&&(r.mode<27||4!==t))&&y(e,e.output,e.next_out,b-e.avail_out)?(r.mode=31,-4):(E-=e.avail_in,b-=e.avail_out,e.total_in+=E,e.total_out+=b,r.total+=b,r.wrap&&b&&(e.adler=r.check=r.flags?a(r.check,u,b,e.next_out-b):n(r.check,u,b,e.next_out-b)),e.data_type=r.bits+(r.last?64:0)+(12===r.mode?128:0)+(20===r.mode||15===r.mode?256:0),(0==E&&0===b||4===t)&&0===L&&(L=-5),L)},r.inflateEnd=function(e){if(!e||!e.state)return c;var t=e.state;return t.window&&(t.window=null),e.state=null,0},r.inflateGetHeader=function(e,t){var r;return e&&e.state&&2&(r=e.state).wrap?((r.head=t).done=!1,0):c},r.inflateSetDictionary=function(e,t){var r,i=t.length;return e&&e.state?0!==(r=e.state).wrap&&11!==r.mode?c:11===r.mode&&n(1,t,i,0)!==r.check?-3:y(e,t,i,i)?(r.mode=31,-4):(r.havedict=1,0):c},r.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,t,r){var i=e("../utils/common"),n=[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],a=[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],o=[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,r,c,l,d,u,h){var p,f,m,g,_,v,y,E,b,w=h.bits,I=0,T=0,S=0,k=0,A=0,R=0,C=0,D=0,O=0,L=0,x=null,N=0,P=new i.Buf16(16),M=new i.Buf16(16),U=null,B=0;for(I=0;I<=15;I++)P[I]=0;for(T=0;T<c;T++)P[t[r+T]]++;for(A=w,k=15;1<=k&&0===P[k];k--);if(k<A&&(A=k),0===k)return l[d++]=20971520,l[d++]=20971520,h.bits=1,0;for(S=1;S<k&&0===P[S];S++);for(A<S&&(A=S),I=D=1;I<=15;I++)if(D<<=1,(D-=P[I])<0)return-1;if(0<D&&(0===e||1!==k))return-1;for(M[1]=0,I=1;I<15;I++)M[I+1]=M[I]+P[I];for(T=0;T<c;T++)0!==t[r+T]&&(u[M[t[r+T]]++]=T);if(v=0===e?(x=U=u,19):1===e?(x=n,N-=257,U=a,B-=257,256):(x=o,U=s,-1),I=S,_=d,C=T=L=0,m=-1,g=(O=1<<(R=A))-1,1===e&&852<O||2===e&&592<O)return 1;for(;;){for(y=I-C,b=u[T]<v?(E=0,u[T]):u[T]>v?(E=U[B+u[T]],x[N+u[T]]):(E=96,0),p=1<<I-C,S=f=1<<R;l[_+(L>>C)+(f-=p)]=y<<24|E<<16|b,0!==f;);for(p=1<<I-1;L&p;)p>>=1;if(0!==p?(L&=p-1,L+=p):L=0,T++,0==--P[I]){if(I===k)break;I=t[r+u[T]]}if(A<I&&(L&g)!==m){for(0===C&&(C=A),_+=S,D=1<<(R=I-C);R+C<k&&!((D-=P[R+C])<=0);)R++,D<<=1;if(O+=1<<R,1===e&&852<O||2===e&&592<O)return 1;l[m=L&g]=A<<24|R<<16|_-d}}return 0!==L&&(l[_+L]=I-C<<24|64<<16),h.bits=A,0}},{"../utils/common":41}],51:[function(e,t,r){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,r){var i=e("../utils/common");function n(e){for(var t=e.length;0<=--t;)e[t]=0}var a=256,o=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);n(p);var f=new Array(60);n(f);var m=new Array(512);n(m);var g=new Array(256);n(g);var _=new Array(29);n(_);var v,y,E,b=new Array(s);function w(e,t,r,i,n){this.static_tree=e,this.extra_bits=t,this.extra_base=r,this.elems=i,this.max_length=n,this.has_stree=e&&e.length}function I(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function T(e){return e<256?m[e]:m[256+(e>>>7)]}function S(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function k(e,t,r){e.bi_valid>16-r?(e.bi_buf|=t<<e.bi_valid&65535,S(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=r-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=r)}function A(e,t,r){k(e,r[2*t],r[2*t+1])}function R(e,t){for(var r=0;r|=1&e,e>>>=1,r<<=1,0<--t;);return r>>>1}function C(e,t,r){var i,n,a=new Array(16),o=0;for(i=1;i<=c;i++)a[i]=o=o+r[i-1]<<1;for(n=0;n<=t;n++){var s=e[2*n+1];0!==s&&(e[2*n]=R(a[s]++,s))}}function D(e){var t;for(t=0;t<o;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 O(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 L(e,t,r,i){var n=2*t,a=2*r;return e[n]<e[a]||e[n]===e[a]&&i[t]<=i[r]}function x(e,t,r){for(var i=e.heap[r],n=r<<1;n<=e.heap_len&&(n<e.heap_len&&L(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!L(t,i,e.heap[n],e.depth));)e.heap[r]=e.heap[n],r=n,n<<=1;e.heap[r]=i}function N(e,t,r){var i,n,o,s,c=0;if(0!==e.last_lit)for(;i=e.pending_buf[e.d_buf+2*c]<<8|e.pending_buf[e.d_buf+2*c+1],n=e.pending_buf[e.l_buf+c],c++,0===i?A(e,n,t):(A(e,(o=g[n])+a+1,t),0!==(s=l[o])&&k(e,n-=_[o],s),A(e,o=T(--i),r),0!==(s=d[o])&&k(e,i-=b[o],s)),c<e.last_lit;);A(e,256,t)}function P(e,t){var r,i,n,a=t.dyn_tree,o=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,r=0;r<l;r++)0!==a[2*r]?(e.heap[++e.heap_len]=d=r,e.depth[r]=0):a[2*r+1]=0;for(;e.heap_len<2;)a[2*(n=e.heap[++e.heap_len]=d<2?++d:0)]=1,e.depth[n]=0,e.opt_len--,s&&(e.static_len-=o[2*n+1]);for(t.max_code=d,r=e.heap_len>>1;1<=r;r--)x(e,a,r);for(n=l;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],x(e,a,1),i=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=i,a[2*n]=a[2*r]+a[2*i],e.depth[n]=(e.depth[r]>=e.depth[i]?e.depth[r]:e.depth[i])+1,a[2*r+1]=a[2*i+1]=n,e.heap[1]=n++,x(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,i,n,a,o,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,f=t.stat_desc.extra_base,m=t.stat_desc.max_length,g=0;for(a=0;a<=c;a++)e.bl_count[a]=0;for(l[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)m<(a=l[2*l[2*(i=e.heap[r])+1]+1]+1)&&(a=m,g++),l[2*i+1]=a,d<i||(e.bl_count[a]++,o=0,f<=i&&(o=p[i-f]),s=l[2*i],e.opt_len+=s*(a+o),h&&(e.static_len+=s*(u[2*i+1]+o)));if(0!==g){do{for(a=m-1;0===e.bl_count[a];)a--;e.bl_count[a]--,e.bl_count[a+1]+=2,e.bl_count[m]--,g-=2}while(0<g);for(a=m;0!==a;a--)for(i=e.bl_count[a];0!==i;)d<(n=e.heap[--r])||(l[2*n+1]!==a&&(e.opt_len+=(a-l[2*n+1])*l[2*n],l[2*n+1]=a),i--)}}(e,t),C(a,d,e.bl_count)}function M(e,t,r){var i,n,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),t[2*(r+1)+1]=65535,i=0;i<=r;i++)n=o,o=t[2*(i+1)+1],++s<c&&n===o||(s<l?e.bl_tree[2*n]+=s:0!==n?(n!==a&&e.bl_tree[2*n]++,e.bl_tree[32]++):s<=10?e.bl_tree[34]++:e.bl_tree[36]++,a=n,l=(s=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4))}function U(e,t,r){var i,n,a=-1,o=t[1],s=0,c=7,l=4;for(0===o&&(c=138,l=3),i=0;i<=r;i++)if(n=o,o=t[2*(i+1)+1],!(++s<c&&n===o)){if(s<l)for(;A(e,n,e.bl_tree),0!=--s;);else 0!==n?(n!==a&&(A(e,n,e.bl_tree),s--),A(e,16,e.bl_tree),k(e,s-3,2)):s<=10?(A(e,17,e.bl_tree),k(e,s-3,3)):(A(e,18,e.bl_tree),k(e,s-11,7));a=n,l=(s=0)===o?(c=138,3):n===o?(c=6,3):(c=7,4)}}n(b);var B=!1;function F(e,t,r,n){var a,o,s;k(e,0+(n?1:0),3),o=t,s=r,O(a=e),S(a,s),S(a,~s),i.arraySet(a.pending_buf,a.window,o,s,a.pending),a.pending+=s}r._tr_init=function(e){B||(function(){var e,t,r,i,n,a=new Array(16);for(i=r=0;i<28;i++)for(_[i]=r,e=0;e<1<<l[i];e++)g[r++]=i;for(g[r-1]=i,i=n=0;i<16;i++)for(b[i]=n,e=0;e<1<<d[i];e++)m[n++]=i;for(n>>=7;i<s;i++)for(b[i]=n<<7,e=0;e<1<<d[i]-7;e++)m[256+n++]=i;for(t=0;t<=c;t++)a[t]=0;for(e=0;e<=143;)p[2*e+1]=8,e++,a[8]++;for(;e<=255;)p[2*e+1]=9,e++,a[9]++;for(;e<=279;)p[2*e+1]=7,e++,a[7]++;for(;e<=287;)p[2*e+1]=8,e++,a[8]++;for(C(p,287,a),e=0;e<s;e++)f[2*e+1]=5,f[2*e]=R(e,5);v=new w(p,l,257,o,c),y=new w(f,d,0,s,c),E=new w(new Array(0),u,0,19,7)}(),B=!0),e.l_desc=new I(e.dyn_ltree,v),e.d_desc=new I(e.dyn_dtree,y),e.bl_desc=new I(e.bl_tree,E),e.bi_buf=0,e.bi_valid=0,D(e)},r._tr_stored_block=F,r._tr_flush_block=function(e,t,r,i){var n,o,s=0;0<e.level?(2===e.strm.data_type&&(e.strm.data_type=function(e){var t,r=4093624447;for(t=0;t<=31;t++,r>>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<a;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(M(e,e.dyn_ltree,e.l_desc.max_code),M(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),n=e.opt_len+3+7>>>3,(o=e.static_len+3+7>>>3)<=n&&(n=o)):n=o=r+5,r+4<=n&&-1!==t?F(e,t,r,i):4===e.strategy||o===n?(k(e,2+(i?1:0),3),N(e,p,f)):(k(e,4+(i?1:0),3),function(e,t,r,i){var n;for(k(e,t-257,5),k(e,r-1,5),k(e,i-4,4),n=0;n<i;n++)k(e,e.bl_tree[2*h[n]+1],3);U(e,e.dyn_ltree,t-1),U(e,e.dyn_dtree,r-1)}(e,e.l_desc.max_code+1,e.d_desc.max_code+1,s+1),N(e,e.dyn_ltree,e.dyn_dtree)),D(e),i&&O(e)},r._tr_tally=function(e,t,r){return e.pending_buf[e.d_buf+2*e.last_lit]=t>>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(g[r]+a+1)]++,e.dyn_dtree[2*T(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){var t;k(e,2,3),A(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,r){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,r){(function(e){!function(e){if(!e.setImmediate){var t,r,i,n,a=1,o={},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,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?(n="setImmediate$"+Math.random()+"$",e.addEventListener?e.addEventListener("message",h,!1):e.attachEvent("onmessage",h),function(t){e.postMessage(n+t,"*")}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){u(e.data)},function(e){i.port2.postMessage(e)}):c&&"onreadystatechange"in c.createElement("script")?(r=c.documentElement,function(e){var t=c.createElement("script");t.onreadystatechange=function(){u(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(u,0,e)},l.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var r=new Array(arguments.length-1),i=0;i<r.length;i++)r[i]=arguments[i+1];var n={callback:e,args:r};return o[a]=n,t(a),a++},l.clearImmediate=d}function d(e){delete o[e]}function u(e){if(s)setTimeout(u,0,e);else{var t=o[e];if(t){s=!0;try{!function(e){var t=e.callback,r=e.args;switch(r.length){case 0:t();break;case 1:t(r[0]);break;case 2:t(r[0],r[1]);break;case 3:t(r[0],r[1],r[2]);break;default:t.apply(void 0,r)}}(t)}finally{d(e),s=!1}}}}function h(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(n)&&u(+t.data.slice(n.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)})}),Bk=Lk((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,r,n,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new a(r,n||e,o),c=i?i+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function c(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.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 n=0,a=r.length,o=new Array(a);n<a;n++)o[n]=r[n].fn;return o},c.prototype.listenerCount=function(e){var t=i?i+e:e,r=this._events[t];return r?r.fn?1:r.length:0},c.prototype.emit=function(e,t,r,n,a,o){var s=i?i+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,r),!0;case 4:return d.fn.call(d.context,t,r,n),!0;case 5:return d.fn.call(d.context,t,r,n,a),!0;case 6:return d.fn.call(d.context,t,r,n,a,o),!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,r);break;case 4:d[l].fn.call(d[l].context,t,r,n);break;default:if(!c)for(h=1,c=new Array(u-1);h<u;h++)c[h-1]=arguments[h];d[l].fn.apply(d[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,n){var a=i?i+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!n||o.once)&&(!r||o.context===r)&&s(this,a);else{for(var c=0,l=[],d=o.length;c<d;c++)(o[c].fn!==t||n&&!o[c].once||r&&o[c].context!==r)&&l.push(o[c]);l.length?this._events[a]=1===l.length?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new n,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)}),Fk=Lk((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")})})}),Vk=Lk(e=>{var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,i){var n=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:n&&!r[e.name]&&(r[e.name]={});var a=e.push?{}:n?r[e.name]:r;(function(e,r,i,n){if(n&&!i)r[n]=t(e[1]);else for(var a=0;a<i.length;a+=1)null!=e[a+1]&&(r[i[a]]=t(e[a+1]))})(i.match(e.reg),a,e.names,e.name),e.push&&r[e.push].push(a)},i=Fk(),n=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},a=[],o=t;return e.split(/(\r\n|\r|\n)/).filter(n).forEach(function(e){var t=e[0],n=e.slice(2);"m"===t&&(a.push({rtp:[],fmtp:[]}),o=a[a.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(n))return r(c,o,n)}}),t.media=a,t};var a=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(a,{})},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),n=0;n<i.length;n+=3)r.push({component:i[n],ip:i[n+1],port:i[n+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map(function(e){return e.substring(1,e.length-1).split(",").reduce(a,{})})},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}})})}}),Wk=Lk((e,t)=>{var r=Fk(),i=/%[sdv%]/g,n=function(e){var t=1,r=arguments,n=r.length;return e.replace(i,function(e){if(t>=n)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}})},a=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 a=0;a<t.names.length;a+=1){var o=t.names[a];t.name?i.push(r[t.name][o]):i.push(r[t.names[a]])}else i.push(r[t.name]);return n.apply(null,i)},o=["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||o,n=t.innerOrder||s,c=[];return i.forEach(function(t){r[t].forEach(function(r){r.name in e&&null!=e[r.name]?c.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){c.push(a(t,r,e))})})}),e.media.forEach(function(e){c.push(a("m",r.m[0],e)),n.forEach(function(t){r[t].forEach(function(r){r.name in e&&null!=e[r.name]?c.push(a(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach(function(e){c.push(a(t,r,e))})})})}),c.join("\r\n")+"\r\n"}}),Hk=Lk(e=>{var t=Vk(),r=Wk(),i=Fk();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}),jk=((_k=jk||{}).ROOM_DESTROY="1",_k.JOIN_START="21",_k.JOIN_SCHEDULE_SUCCESS="22",_k.JOIN_SIGNAL_CONNECTION_START="23",_k.JOIN_SIGNAL_CONNECTION_END="24",_k.JOIN_SEND_CMD="25",_k.JOIN_RECEIVED_CMD_RES="26",_k.JOIN_SUCCESS="27",_k.JOIN_FAILED="28",_k.WHIP_REQUEST_COST="29",_k.WHIP_PULL_RESULT="30",_k.LEAVE_START="51",_k.LEAVE_SEND_CMD="52",_k.LEAVE_SUCCESS="53",_k.PUBLISH_START="61",_k.SEND_FIRST_VIDEO_FRAME="62",_k.PUBLISH_FAILED="63",_k.SUBSCRIBE_START="81",_k.SUBSCRIBE_SUCCESS="82",_k.SUBSCRIBE_FAILED="84",_k.UNSUBSCRIBE_SUCCESS="83",_k.LOCAL_TRACK_CAPTURE_START="101",_k.LOCAL_TRACK_CAPTURE_SUCCESS="102",_k.LOCAL_TRACK_CAPTURE_FAILED="103",_k.LOCAL_TRACK_PUBLISHED="104",_k.LOCAL_TRACK_UNPUBLISHED="105",_k.LOCAL_TRACK_REPLACED="106",_k.SWITCH_DEVICE_SUCCESS="107",_k.TRACK_MUTED="108",_k.TRACK_UNMUTED="109",_k.REMOTE_TRACK_SUBSCRIBED="110",_k.REMOTE_TRACK_UNSUBSCRIBED="111",_k.LOCAL_TRACK_RECAPTURE="112",_k.LOCAL_AUDIO_STARTED="113",_k.LOCAL_AUDIO_STOPPED="114",_k.REMOTE_AUDIO_STARTED="115",_k.REMOTE_AUDIO_STOPPED="116",_k.LOCAL_TRACK_STOPPED="117",_k.LOCAL_VIDEO_TRACK_PREPROCESSED="118",_k.PLAY_TRACK_START="151",_k.PLAYER_STATE_CHANGED="152",_k.VIDEO_LOADED_DATA="153",_k.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",_k.AUDIO_CONTEXT_LONG_SUSPENDED="155",_k.REMOTE_VIDEO_PLAY_START="156",_k.REMOTE_VIDEO_PLAY_FINISH="157",_k.SIGNAL_CONNECTION_STATE_CHANGED="201",_k.PEER_CONNECTION_STATE_CHANGED="202",_k.SINGLE_CONNECTION_STAT="203",_k.SPC_RECONNECTED="204",_k.HEARTBEAT_REPORT="251",_k.RECEIVED_PUBLISHED_USER_LIST="252",_k.REMOTE_PUBLISH_STATE_CHANGED="253",_k.AUDIO_LEVEL_INTERVAL="260",_k.NETWORK_QUALITY="261",_k.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",_k.QUALITY_LIMITATION_CHANGED="263",_k.LOG="264",_k.AUDIO_PROCESSOR_DEBUG="265",_k.SSO_SWITCH="266",_k.SEI_MESSAGE="267",_k.USER_PAUSE_IN_PIP="268",_k.USER_RESUME_IN_PIP="269",_k.ENTER_PICTURE_IN_PICTURE="270",_k.LEAVE_PICTURE_IN_PICTURE="271",_k.SWITCH_ROOM_START="401",_k.SWITCH_ROOM_SUCCESS="407",_k.SWITCH_ROOM_FAILED="408",_k);function zk(e){return Gk((t,r)=>async function(){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];let a=await t.apply(this,i);return await e.call(this,...i),a})}function Gk(e){return function(t,r,i){return i.value=e(i.value,r),i}}var qk=new WeakMap;function Kk(e,t){return Gk((r,i)=>function(){for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];let o=qk.get(this);o||(o=new Map,qk.set(this,o));let s=t(...n),c=o.get(s);if(!c||c<=0){r.apply(this,n);let t=setTimeout(()=>{var e;null==(e=qk.get(this))||e.delete(s)},e);o.set(s,t)}else{clearTimeout(c);let t=window.setTimeout(()=>{var e;r.apply(this,n),null==(e=qk.get(this))||e.delete(s)},e);o.set(s,t)}})}var Yk,Xk,Zk=((Yk=Zk||{})[Yk.none=0]="none",Yk[Yk.horizontal=1]="horizontal",Yk[Yk.vertical=2]="vertical",Yk),Jk="5.0.0",Qk="undefined"!=typeof importScripts,$k="undefined"!=typeof registerProcessor,eA="https://".concat("web.sdk.qcloud.com","/trtc/webrtc/doc"),tA="https://cloud.tencent.com/document/product/647/85386",rA="https://trtc.io/document/56025",iA="jssdk_log",nA="qcloud",aA=((Xk=aA||{})[Xk.TRACE=0]="TRACE",Xk[Xk.DEBUG=1]="DEBUG",Xk[Xk.INFO=2]="INFO",Xk[Xk.WARN=3]="WARN",Xk[Xk.ERROR=4]="ERROR",Xk[Xk.NONE=5]="NONE",Xk),oA={unknown:0,wifi:1,"4g":2,"3g":3,"2g":4,wired:5,"5g":6},sA={width:640,height:480,frameRate:15,bitrate:500},cA="canvas",lA="audio",dA="video",uA="screen",hA="big",pA="mute",fA="unmute",mA="ended",gA="playing",_A="pause",vA="error",yA="loadstart",EA="loadeddata",bA="loadedmetadata",wA="audioinput",IA="videoinput",TA="enterpictureinpicture",SA="leavepictureinpicture",kA="fullscreenchange",AA="resize",RA="player-error",CA="load-worklet",DA="getUserMedia-retry",OA="default",LA=2e3,xA=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],NA={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"};function PA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function MA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function UA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function BA(e){let{frame:t,onDump:r}=e;return null==r||r(),t}var FA="Log",VA="Network",WA="Dump",HA="Dump (PCM)",jA="Dump (Opus)",zA="Dumping",GA="End",qA="Upload Log",KA="Export Log",YA="Hide",XA="goBottom",ZA="backTop",JA="Clear Log",QA="Uplink",$A="Downlink",eR="No Data",tR="Basic",rR="Duration",iR="Video",nR="Audio",aR="Screen",oR={"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=>{oR["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}});var sR,cR=Object.keys(oR),lR=Nk(Uk()),dR=((sR=dR||{})[sR.INVALID_PARAMETER=4096]="INVALID_PARAMETER",sR[sR.INVALID_OPERATION=4097]="INVALID_OPERATION",sR[sR.NOT_SUPPORTED=4098]="NOT_SUPPORTED",sR[sR.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",sR[sR.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",sR[sR.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",sR[sR.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",sR[sR.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",sR[sR.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",sR[sR.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",sR[sR.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",sR[sR.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",sR[sR.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",sR[sR.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",sR[sR.CLIENT_BANNED=16448]="CLIENT_BANNED",sR[sR.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",sR[sR.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",sR[sR.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",sR[sR.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",sR[sR.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",sR[sR.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",sR[sR.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",sR[sR.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",sR[sR.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",sR[sR.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",sR[sR.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",sR[sR.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",sR[sR.API_CALL_ABORTED=16461]="API_CALL_ABORTED",sR[sR.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",sR[sR.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",sR[sR.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",sR[sR.VIDEO_ENCODE_FAILED=16465]="VIDEO_ENCODE_FAILED",sR[sR.AUDIO_ENCODE_FAILED=16466]="AUDIO_ENCODE_FAILED",sR[sR.WHIP_REQUEST_FAILED=16467]="WHIP_REQUEST_FAILED",sR[sR.UNKNOWN=65535]="UNKNOWN",sR),uR=dR,hR=class extends Error{constructor(e){let{name:t="RtcError",message:r,code:i=uR.UNKNOWN,extraCode:n=0,constraint:a}=e,o="<".concat(function(e){for(let t in uR)if(uR[t]===e)return t;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(r).concat(a?" constraint: ".concat(a):"").concat(null!=r&&r.includes(o)?"":" ".concat(o));super(s),Mk(this,"code"),Mk(this,"extraCode"),Mk(this,"message"),Mk(this,"originMessage"),Mk(this,"name"),Mk(this,"constraint"),this.code=i,this.extraCode=n,this.name=t,this.message=s,this.constraint=a,this.originMessage=r}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},pR=hR,fR=function(){return Date.now()+0},mR=function(){let e=new Date;return e.setTime(fR()),e.toLocaleString()};xk({},{REPORT_TYPE:()=>ZC,buildSSOPackage:()=>JC,bytes2ms:()=>ZR,calculateScaleResolutionDownNumber:()=>qC,concatArrayBuffers:()=>QC,convertObjectNumberToInt:()=>WC,copyProperties:()=>XR,deepClone:()=>OC,deepCloneBasic:()=>XC,deepMerge:()=>DC,delay:()=>HC,detectImageType:()=>rD,fibonacci:()=>iC,formatedTime:()=>NC,getConstructorName:()=>_C,getContainerFromElement:()=>xC,getEnv:()=>BR,getFirst16Bits:()=>eD,getInternalVersion:()=>IC,getLast16Bits:()=>$C,getLoggerUrl:()=>WR,getMediaStreamTrackInfo:()=>GC,getMuteStateFromFlag:()=>AC,getNetworkType:()=>jR,getNumNetworkType:()=>YR,getReconnectionTimeout:()=>nC,getStringByteLength:()=>UC,getTestSignalDomain:()=>FR,getTurnServer:()=>RC,getUint32Version:()=>VC,getValueType:()=>aC,getVersionFromInternalVersion:()=>TC,getViewListFromView:()=>LC,glog:()=>eC,ipv4ToUint32:()=>CC,isArray:()=>hC,isAudioWorkletSupported:()=>vC,isBoolean:()=>dC,isConstructor:()=>gC,isEmpty:()=>kC,isFunction:()=>oC,isLangChinese:()=>tC,isMediaStreamTrack:()=>pC,isNumber:()=>lC,isObject:()=>uC,isOverseaSdkAppId:()=>VR,isPlainObject:()=>rC,isPortrait:()=>BC,isPromise:()=>mC,isRemoteTrack:()=>fC,isRotate90Or270:()=>KC,isSameSubnet:()=>UR,isSetSinkIdSupported:()=>yC,isString:()=>cC,isUndefined:()=>sC,isValidIP:()=>MR,isVideoMixerOutputTrack:()=>tD,loadImage:()=>FC,loadVideo:()=>YC,ms2bytes:()=>QR,ms2samples:()=>$R,normalizeUrl:()=>zC,performanceNow:()=>bC,promiseAny:()=>EC,samples2ms:()=>JR,setNetworkTypeFromWebRTC:()=>KR,stringify:()=>PC,stringifyIncludeValue:()=>MC,throttlePromise:()=>jC});var gR=function(e,t,r,i){return new(r||(r=Promise))(function(n,a){function o(e){try{c(i.next(e))}catch(t){a(t)}}function s(e){try{c(i.throw(e))}catch(t){a(t)}}function c(e){e.done?n(e.value):function(e){return e instanceof r?e:new r(function(t){t(e)})}(e.value).then(o,s)}c((i=i.apply(e,t||[])).next())})},_R=Symbol(32),vR=Symbol(16),yR=Symbol(8),ER=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 gR(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(_R)}readU16(){return this.read(vR)}readU8(){return this.read(yR)}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===_R){if(i(4))return;e=t[0]<<24|t[1]<<16|t[2]<<8|t[3]}else if(this.need===vR){if(i(2))return;e=t[0]<<8|t[1]}else if(this.need===yR){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}};ER.U32=_R,ER.U16=vR,ER.U8=yR;var bR=128;function wR(e){let t=new ER;for(;e>=128;)t.malloc(1)[0]=255&e|bR,e>>>=7;return t.malloc(1)[0]=255&e,t.buffer||new Uint8Array(0)}function IR(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=new ER,i=t<<3;switch(typeof e){case"boolean":let n=r.malloc(2);n[0]=i,n[1]=e?1:0;break;case"number":r.malloc(1)[0]=i,r.write(wR(e));break;case"string":r.malloc(1)[0]=2|i;let a=(new TextEncoder).encode(e);r.write(wR(a.length));let o=r.malloc(a.length);for(let e=0;e<a.length;e++)o[e]=a[e];break;case"object":let s=new ER;if(Array.isArray(e))for(let t=0;t<e.length;t++){let r=IR(e[t],t+1);r&&s.write(r)}else{let t=1;for(let r in e){let i=IR(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(wR(s.buffer.length)),r.write(s.buffer)))}return r.buffer||new Uint8Array(0)}var TR=class{constructor(){Mk(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 SR(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 kR(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function AR(e,t){return e[t]}function RR(e,t,r){return(new TextDecoder).decode(function(e,t,r){return e.slice(t,t+r)}(e,t,r))}var CR=0,DR=2654435769,OR=16,LR=2,xR=7;function NR(e,t){let r=new TR,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,CR);CR=CR+1&2147483647,r.writeInt32(0),r.writeInt32(i.version),r.writeByte(i.encryption);let n=(new TextEncoder).encode(i.d2);r.writeInt32(n.length+4),n&&r.writeBytes(n),r.writeByte(i.uinType);let a=(new TextEncoder).encode(i.uin);r.writeInt32(a.length+4),a.length&&r.writeBytes(a);let o=new TR;o.writeInt32(0),o.writeInt32(i.reqHead.seqNumber),o.writeInt32(i.reqHead.appId),o.writeByte(i.reqHead.appId>>>24&255),o.writeByte(i.reqHead.appId>>>16&255),o.writeByte(i.reqHead.appId>>>8&255),o.writeByte(255&i.reqHead.appId);for(let v=4;v<16;v++)o.writeByte(0);let s=(new TextEncoder).encode(i.reqHead.a2);o.writeInt32(s.length+4),s.length&&o.writeBytes(s);let c=(new TextEncoder).encode(i.reqHead.serviceCmd);o.writeInt32(c.length+4),c.length&&o.writeBytes(c);let l=(new TextEncoder).encode(i.reqHead.cookie);o.writeInt32(l.length+4),l.length&&o.writeBytes(l);let d=(new TextEncoder).encode(i.reqHead.imei);o.writeInt32(d.length+4),d.length&&o.writeBytes(d);let u=(new TextEncoder).encode(i.reqHead.ksid);o.writeInt32(u.length+4),u.length&&o.writeBytes(u);let h=(new TextEncoder).encode(i.reqHead.clientVersionInfo);o.writeInt16(h.length+2),h.length&&o.writeBytes(h);let p=o.length;o.data[0]=p>>>24&255,o.data[1]=p>>>16&255,o.data[2]=p>>>8&255,o.data[3]=255&p,cC(e)&&(e=(new TextEncoder).encode(e)),o.writeInt32(e.length+4),e.length&&o.writeBytes(e);let f=new Uint8Array(o.data),m=null;1===i.encryption?m=(new TextEncoder).encode(i.uin):2===i.encryption&&(m=new Uint8Array(16)),m&&(f=function(e,t){let r=e.length,i=(r+1+LR+xR)%8;i&&(i=8-i);let n=r+1+LR+xR+i,a=new Uint8Array(n),o=0,s=new Uint8Array(8),c=new Uint8Array(8),l=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<LR;)if(d<8&&(s[d]=255&Math.floor(256*Math.random()),d+=1,h+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}let u=0;for(;u<r;)if(d<8&&(s[d]=e[u],d+=1,u+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}for(let h=0;h<xR;)if(d<8&&(s[d]=0,d+=1,h+=1),8===d){PR(s,t,c,l,a,o),o+=8,d=0;for(let e=0;e<8;e++)l[e]=a[o-8+e]}return a}(f,m)),r.writeBytes(f);let g=new Uint8Array(r.data),_=g.length;return g[0]=_>>>24&255,g[1]=_>>>16&255,g[2]=_>>>8&255,g[3]=255&_,g}function PR(e,t,r,i,n,a){for(let o=0;o<8;o++)e[o]^=i[o];!function(e,t,r,i){let n=kR(e,0),a=kR(e,4),o=[];for(let c=0;c<4;c++)o[c]=kR(t,4*c);let s=0;for(let c=0;c<OR;c++)s+=DR,s>>>=0,n+=(a<<4)+o[0]^a+s^(a>>>5)+o[1],n>>>=0,a+=(n<<4)+o[2]^n+s^(n>>>5)+o[3],a>>>=0;SR(r,n,i),SR(r,a,i+4)}(e,t,n,a);for(let o=0;o<8;o++)n[a+o]^=r[o];for(let o=0;o<8;o++)r[o]=e[o]}function MR(e){return!!e&&!!(/^\d{1,3}(\.\d{1,3}){3}$/.test(e)||e.includes(":")&&/^[0-9a-fA-F:]+$/.test(e))}function UR(e,t){if(!MR(e)||!MR(t))return e===t;let r=e=>e.includes(":");if(r(e)!==r(t))return e===t;if(r(e)){return e.split(":").slice(0,3).join(":")===t.split(":").slice(0,3).join(":")}return e.split(".").slice(0,3).join(".")===t.split(".").slice(0,3).join(".")}var BR=function(){return new URLSearchParams(location.search).get("trtc_env")||""},FR=function(e){return e.includes(".")?e:"".concat(e).concat(".rtc.qq.com")},VR=e=>Number(e)<14e8,WR=function(e,t){let r;r=VR(e)?"https://apisgp.my-imcloud.com":"https://yun.tim.qq.com";let i=Math.floor(Math.random()*2**31);return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},HR="unknown";function jR(){!function(){var e;GR||(GR=!0,null==(e=navigator.connection)||e.addEventListener("typechange",zR))}();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(),n=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===n&&(n="2g"),i?qR(i,n):HR}function zR(){eL.warn("netType changed",jR())}var GR=!1;function qR(e,t){if(oA[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function KR(e){HR=qR(e)}function YR(){return oA[jR()]}function XR(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 ZR(e){return JR(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function JR(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function QR(e){return 4*$R(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function $R(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var eC="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},tC=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},rC=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 iC(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:iC(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function nC(e){return e>8?3e4:1e3*iC(e)}function aC(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var oC=e=>"function"==typeof e,sC=e=>void 0===e,cC=e=>"string"==typeof e,lC=e=>"number"==typeof e,dC=e=>"boolean"==typeof e,uC=e=>"object"===aC(e),hC=e=>"array"===aC(e),pC=e=>aC(e)==="MediaStreamTrack".toLowerCase(),fC=e=>e.isRemote,mC=e=>"promise"===aC(e),gC=e=>oC(e)&&e.prototype.constructor===e,_C=e=>gC(e)?e.prototype.constructor.name:"",vC="undefined"!=typeof AudioWorkletNode,yC="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype;function EC(e){return new Promise((t,r)=>{let i=[];e.forEach(n=>{n.then(t).catch(t=>{i.push(t),i.length===e.length&&r(i)})})})}function bC(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var wC=e=>+e<10?"0".concat(e):e,IC=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let r=t.split("."),i=wC(r[1])+wC(r[2]);return r[1]-15>0&&(r[1]="15"),r[2]-15>0&&(r[2]="15"),"".concat(r.join("."),".").concat(i)},TC=e=>{let t=e.split(".");if(4!==t.length)return e;let r=t[0],i=t[3];if(i.length<4)return e;let n=parseInt(i.substring(0,i.length-2),10),a=parseInt(i.substring(i.length-2),10);return"".concat(r,".").concat(n,".").concat(a)},SC=Object.prototype.hasOwnProperty;function kC(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(rC(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(SC.call(e,t))return!1;return!0}return!1}function AC(e,t){return{userId:t,hasAudio:!!(8&e),hasVideo:!!(1&e),hasAuxiliary:!!(4&e),hasSmall:!!(2&e),audioMuted:!!(64&e),videoMuted:!!(16&e),audioAvailable:!(!(8&e)||64&e),videoAvailable:!(!(1&e)||16&e),hasDatachannel:!!(256&e)}}function RC(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!sC(e.username)&&!sC(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",sC(e.credentialType)||(t.credentialType=e.credentialType)),t}function CC(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!cC(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 DC=function(e,t,r,i){if(!uC(e)||!uC(t))return 0;let n,a=0,o=Object.keys(t);for(let s=0,c=o.length;s<c;s++)if(n=o[s],!(sC(t[n])||r&&r.includes(n)))if(uC(e[n])&&uC(t[n]))a+=DC(e[n],t[n],r,i);else{if(i&&i.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=OC(t[n]),a+=1)}return a};function OC(e){if(hC(e)){let t=[];return e.forEach((e,r)=>{t[r]=OC(e)}),t}if(uC(e)){let t={};return Object.keys(e).forEach(r=>{t[r]=OC(e[r])}),t}return e}var LC=e=>{let t=[];if(hC(e))t=[...e];else if(cC(e)){let r=document.getElementById(e);r&&t.push(r)}else e&&t.push(e);return t},xC=e=>cC(e)?document.getElementById(e):e,NC=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),r=e.getFullYear(),i=e.getMonth()+1,n=e.getDate(),a=t(e.getHours()),o=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(r,"/").concat(i,"/").concat(n," ").concat(a,":").concat(o,":").concat(s)})(new Date);function PC(e,t){let{keysToInclude:r,keysToExclude:i}=t;try{if(hC(e))return"[".concat(e.map(e=>PC(e,{keysToInclude:r,keysToExclude:i})).join(","),"]");if(!rC(e)||!hC(r)&&!hC(i))return JSON.stringify(e);let t={},n=new Set(r),a=new Set(i);return Object.keys(e).forEach(o=>{(0===a.size&&n.has(o)||0===n.size&&!a.has(o))&&(t[o]=rC(e[o])||hC(e[o])?JSON.parse(PC(e[o],{keysToExclude:i,keysToInclude:r})):e[o])}),JSON.stringify(t)}catch(Yk){return"{}"}}function MC(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)}),PC(e,{keysToInclude:r})}function UC(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var BC=()=>{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},FC=async e=>new Promise((t,r)=>{let i;if(cC(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 pR({code:uR.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}),VC=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},WC=e=>(Object.keys(e).forEach(t=>{lC(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(rC(e[t])||hC(e[t]))&&WC(e[t])}),e);function HC(e,t){return new Promise(r=>{let i=setTimeout(r,e);t&&t(i)})}function jC(e,t){let r=null;return function(){for(var i=arguments.length,n=new Array(i),a=0;a<i;a++)n[a]=arguments[a];return r||(r=e.apply(t||this,n),r.finally(()=>r=null),r)}}function zC(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function GC(e){var t;try{let{width:r,height:i,frameRate:n,sampleRate:a,sampleSize:o,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),c=e.kind===lA?"".concat(a,"x").concat(o,"@").concat(s):"".concat(r,"x").concat(i,"@").concat(n),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(YP){return""}}function qC(e,t){return e.width*e.height===t.width*t.height?1:BC()&&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 KC(e){return 90===e||270===e}async function YC(e){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 XC(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]=XC(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]=XC(e[i],t)}),r}return e}var ZC=(e=>(e[e.END_REPORT=2001]="END_REPORT",e[e.LOG=2002]="LOG",e[e.KEY_METRIC_REPORT=2003]="KEY_METRIC_REPORT",e))(ZC||{});function JC(e,t,r,i){try{let n=function(e,t,r,i){let n={data:e,random:Math.floor(2147483648*Math.random()),sdkAppId:r};return sC(i)||(n=Dk(Ck({},n),{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(n)}}}(e,t,r,i);return NR(IR(n),r)}catch(n){return JSON.stringify(e)}}function QC(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 $C(e){return(65535&e)>>>0}function eD(e){return(4294901760&e)>>>0}function tD(e,t){return eL.debug("isVideoMixerOutputTrack",e,t,e===(null==t?void 0:t.videoMixerOutputTrack)),!(!e||null==t||!t.isUsingVideoMixerInternalTrack)&&!(!t.videoMixerOutputTrack||e!==t.videoMixerOutputTrack)}function rD(e){var t;if(!e)return{animated:!1};if(e.startsWith("data:")){let t=e.match(/^data:(image\/[^;,]+)/);if(t){let e=t[1].toLowerCase();return{animated:"image/gif"===e||"image/apng"===e,mimeType:e}}return{animated:!1}}if(e.startsWith("blob:"))return{animated:!1};try{let r=null==(t=new URL(e,"https://placeholder.invalid").pathname.split(".").pop())?void 0:t.toLowerCase();if("gif"===r)return{animated:!0,mimeType:"image/gif"};if("apng"===r)return{animated:!0,mimeType:"image/apng"}}catch(YP){}return{animated:!1}}function iD(e){let t=function(e){try{let t={},r=0;t.totalLength=kR(e,r),r+=4,t.version=kR(e,r),r+=4,t.encryption=AR(e,r),r+=1,t.uinType=AR(e,r),r+=1,t.uinLength=kR(e,r),r+=4,t.uin=t.uinLength>4?RR(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),n=new Uint8Array(e.slice(0,8)),a=nD(n,t),o=7&a[0],s=e.length-1-o-LR-xR,c=new Uint8Array(s),l=0,d=i,u=e.slice(0,8);r=8;let h=1;h+=o;for(let f=1;f<=LR;)if(h<8)h++,f++;else if(8===h){let i=aD(e,r,d,u,a,t);d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}let p=s;for(;p>0;)if(h<8)c[l++]=a[h]^d[h],h++,p--;else if(8===h){let i=aD(e,r,d,u,a,t);d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}for(let f=1;f<=xR;)if(h<8)a[h],d[h],h++,f++;else if(8===h){if(r>=e.length)break;let i=aD(e,r,d,u,a,t);if(!i.success)break;d=i.ivPreCrypt,u=i.ivCurCrypt,a=i.debiBuf,r=i.bufPos,h=0}return c}(i,new Uint8Array(16).fill(0)),t.decrypted=!0,r=0}else e=i,r=0;return t.rspHeadLength=kR(e,r),r+=4,t.seqNo=kR(e,r),r+=4,t.retCode=kR(e,r),r+=4,t.retStrLength=kR(e,r),r+=4,t.retStr=t.retStrLength?RR(e,r,t.retStrLength-4):"",r+=t.retStrLength-4,t.serviceCmdLength=kR(e,r),r+=4,t.serviceCmd=t.serviceCmdLength?RR(e,r,t.serviceCmdLength-4):"",r+=t.serviceCmdLength-4,t.cookieLength=kR(e,r),r+=4,t.cookie=t.cookieLength?RR(e,r,t.cookieLength-4):"",r+=t.cookieLength-4,t.flag=kR(e,r),r+=4,t.busiBuffLength=kR(e,r),r+=4,t.busiBuff=t.busiBuffLength?RR(e,r,t.busiBuffLength-4):"",r+=t.busiBuffLength-4,t}catch(t){}}(e);return null==t?void 0:t.busiBuff}function nD(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 n=DR*OR>>>0;for(let a=0;a<OR;a++)i-=(r<<4)+t[2]^r+n^(r>>>5)+t[3],i>>>=0,r-=(i<<4)+t[0]^i+n^(i>>>5)+t[1],r>>>=0,n-=DR,n>>>=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 aD(e,t,r,i,n,a){if(t+8>e.length)return{success:!1};let o=new Uint8Array(i),s=e.slice(t,t+8),c=new Uint8Array(8);for(let l=0;l<8;l++)c[l]=n[l]^s[l];return{success:!0,ivPreCrypt:o,ivCurCrypt:s,debiBuf:nD(c,a),bufPos:t+8}}var oD="undefined"!=typeof TextDecoder?new TextDecoder:void 0;function sD(e){let{url:t,body:r,method:i="POST",timeout:n,priority:a}=e;return new Promise((e,o)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:a}).then(e=>e.clone().json().then(e=>({data:e}),()=>e.arrayBuffer().then(e=>({data:iD(new Uint8Array(e))||(oD?oD.decode(e):e)})))).then(e,o);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(t){e({data:s.response})}else o({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=n||5e3,s.open(i,t,!0),s.send(r)})}var cD=Object.prototype.hasOwnProperty,lD=e=>"function"==typeof e,dD=e=>void 0===e,uD=e=>e.isRemote;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(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(cD.call(e,t))return!1;return!0}return!1}var pD=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:n,onRetryFailed:a,onRetrySuccess:o,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}=r,h=0,p=-1,f=0,m=async(e,r)=>{let l=s||this;try{let r=await t.apply(l,c);h>0&&o&&o.call(this,h),h=0,e(r)}catch(g){let t=()=>{clearTimeout(p),h=0,f=2,r(g)},o=()=>{2!==f&&h<(lD(d)?d():d)?(h++,f=1,lD(n)&&n.call(this,h,t),p=window.setTimeout(()=>{p=-1,m(e,r)},lD(u)?u(h):u)):(t(),lD(a)&&a.call(this,g))};lD(i)?i.call(this,{error:g,retry:o,reject:r,retryFuncArgs:c,retriedCount:h}):o()}};return new Promise(m)}},fD=class e{constructor(e){Mk(this,"_parentPath"),Mk(this,"userId"),Mk(this,"remoteUserId"),Mk(this,"id"),Mk(this,"sdkAppId"),Mk(this,"type"),Mk(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:dD(t.userId)?this.userId:t.userId,sdkAppId:dD(t.sdkAppId)?this.sdkAppId:t.sdkAppId,type:dD(t.type)?this.type:t.type,isLocal:dD(t.isLocal)?this.isLocal:t.isLocal,remoteUserId:dD(t.remoteUserId)?this.remoteUserId:t.remoteUserId});return r.bindParent(this),r}bindParent(e){let t=e.getFullId();this._parentPath!==t&&(this._parentPath=t,this.userId=e.userId||this.userId,this.sdkAppId=e.sdkAppId||this.sdkAppId,this.debug("bindParent: ".concat(e.id)))}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):"","]")),eL.log(e,t,dD(this.userId)||hD(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)}},mD="undefined"==typeof navigator?"":navigator.userAgent,gD=e=>new RegExp(e,"i").test(mD),_D=e=>{if(gD(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=mD.match(t);if(r&&r[1])return r[1]}return""},vD=e=>{if(gD(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=mD.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},yD=/AppleWebKit\/([\d.]+)/i.exec(mD);yD&&parseFloat(yD[1]);var ED=gD("iPad"),bD="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&gD("Macintosh"),wD=gD("iPhone")&&!ED,ID=gD("iPod"),TD=wD||ED||ID||bD,SD=()=>{try{return TD&&navigator.maxTouchPoints>1&&navigator.vendor.includes("Apple")}catch(gk){return TD}},kD=gD("Android"),AD=function(){if(kD){let e=mD.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}();kD&&gD("webkit");var RD=gD("Firefox"),CD=_D("Firefox"),DD=vD("Firefox"),OD=gD("Edge"),LD=_D("Edge"),xD=gD("Edg"),ND=_D("Edg"),PD=vD("Edg"),MD=gD("SogouMobileBrowser"),UD=_D("SogouMobileBrowser"),BD=gD("MetaSr\\s"),FD=_D("MetaSr\\s"),VD=gD("TBS"),WD=_D("TBS"),HD=gD("XWEB"),jD=_D("XWEB");gD("MSIE\\s8\\.0");var zD=gD("MSIE\\/\\d+");!function(){if(zD){let e=/MSIE\s(\d+)\.\d/.exec(mD),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(mD)&&/rv:11.0/.test(mD)&&(t=11),t}}();var GD=gD("(micromessenger|webbrowser)"),qD=_D("MicroMessenger"),KD=!VD&&gD("MQQBrowser")&&gD("COVC"),YD=!VD&&gD("MQQBrowser")&&!gD("COVC"),XD=YD||KD?_D("MQQBrowser"):"",ZD=!VD&&gD(" QQBrowser"),JD=_D(" QQBrowser"),QD=!VD&&gD("QQBrowserLite"),$D=_D("QQBrowserLite"),eO=!VD&&gD("MQBHD"),tO=_D("MQBHD"),rO=gD("Windows"),iO=!TD&&gD("MAC OS X"),nO=!kD&&gD("Linux"),aO=gD("CrOS");gD("MicroMessenger");var oO=gD("UCBrowser"),sO=gD("Electron"),cO=gD("MiuiBrowser"),lO=_D("MiuiBrowser"),dO=gD("HuaweiBrowser"),uO=gD("Huawei")||gD("HUAWEI"),hO=gD("Honor")||gD("HONOR"),pO=_D("HuaweiBrowser"),fO=gD("SamsungBrowser"),mO=_D("SamsungBrowser"),gO=gD("HeyTapBrowser"),_O=_D("HeyTapBrowser"),vO=gD("VivoBrowser"),yO=_D("VivoBrowser"),EO=gD("OpenHarmony");_D("OpenHarmony");var bO=()=>vD("Chrome"),wO=gD("CriOS"),IO=gD("Chrome"),TO=!OD&&!BD&&!MD&&!VD&&!HD&&!xD&&!ZD&&!cO&&!dO&&!fO&&!gO&&!vO&&IO,SO=gD("HeadlessChrome"),kO=bO(),AO=IO&&kO>=128&&kO<=143,RO=_D("Chrome"),CO=vD("Electron"),DO=!IO&&!YD&&!KD&&!QD&&!eO&&gD("Safari"),OO=DO||TD,LO=_D("Version"),xO=/Android.*(wv|.0.0.0)/.test(mD),NO=(()=>{if(bD)return LO;if(TD){let e=mD.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function PO(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=e.split(".").map(e=>Number(e)),n=t.split(".").map(e=>Number(e));for(let a=0;a<Math.max(i.length,n.length);a++){let e=i[a]||0,t=n[a]||0;if(e>t)return!0;if(e<t)return!1}return r}var MO=Number(NO.split(".")[0]),UO="15.1"===NO,BO=(()=>{let e=Number(NO.split(".")[0]);return 14===e||13===e})(),FO=wO&&"11.1.1"===LO,VO="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),WO=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(t){e=!1}return e}})(),HO=function(){let e=new Map([[RD,["Firefox",CD]],[xD,["Edg",ND]],[TO,["Chrome",RO]],[wO,["ChiOS",_D("CriOS")]],[DO&&!wO,["Safari",LO]],[VD,["TBS",WD]],[HD,["XWEB",jD]],[GD&&wD,["WeChat",qD]],[ZD,["QQ(Win)",JD]],[YD,["QQ(Mobile)",XD]],[KD,["QQ(Mobile X5)",XD]],[QD,["QQ(Mac)",$D]],[eO,["QQ(iPad)",tO]],[cO,["MI",lO]],[dO,["HW",pO]],[fO,["Samsung",mO]],[gO,["OPPO",_O]],[vO,["VIVO",yO]],[OD,["EDGE",LD]],[MD,["SogouMobile",UD]],[BD,["Sogou",FD]]]),t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}();var jO="";function zO(){try{if(jO)return jO;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 jO="".concat(e," ").concat(i)}return""}catch(gk){return""}}function GO(){return function(){let e=/;\s*([^;)]+)\s+Build\//,t=mD.match(e);return null!=t&&t[1]?t[1].trim():null}()||""}var qO=new Map([[kD,"Android"],[TD,"iOS"],[rO,"Windows"],[iO,"MacOS"],[nO,"Linux"],[aO,"ChromeOS"]]),KO=function(){return qO.get(!0)?qO.get(!0):"unknown"};function YO(){return rO?1:kD?2:iO?3:TD?4:nO?5:aO?6:EO?7:0}var XO=()=>{let e=KO();return TD?e+="/".concat(NO):kD&&(e+="/".concat(AD)),e+="/".concat(HO.name,"/").concat(DO&&!wO?HO.version:HO.version.split(".")[0]),e},ZO=new(Nk(Bk(),1).default),JO=jk,QO=new class{constructor(){Mk(this,"enable",!1),Mk(this,"ssoFailCount",0),ZO.on("22",e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.sso&&ZO.emit("266",{enable:!0})}),ZO.on("266",e=>{let{enable:t}=e;this.enable=t})}handleUploadFailed(){this.ssoFailCount++,this.ssoFailCount>3&&ZO.emit("266",{enable:!1})}},$O=class e{constructor(){Mk(this,"_isEnableUploadLog",!0),Mk(this,"_localJoinedUser",new Map),Mk(this,"_queue",[]),Mk(this,"_timeoutId",-1),Mk(this,"_logLevel",1),Mk(this,"_logLevelToUpload",2),!Qk&&!$k&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){ZO.on(JO.JOIN_SCHEDULE_SUCCESS,e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&aA[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)}),ZO.on(JO.JOIN_START,e=>{let{params:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()}),ZO.on(JO.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:n}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:n,logs:[r]})});else if(cC(r.userId)&&lC(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}async upload(){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:n}=t[e],a={timestamp:mR(),sdkAppId:String(i),userId:r,version:Jk,log:n.map(e=>e.log).join("\n")},o=JSON.stringify(a),s=QO.enable?JC(a,2002,i):o;await this.uploadLogWithRetry(s,i,s instanceof Uint8Array,o),n.forEach(e=>e.uploaded=!0)}}catch(i){}let r=t.filter(e=>!e.uploaded);r.length>0&&(this._queue=r.concat(this._queue))}uploadLogWithRetry(e,t,r,i){return pD({retryFunction:()=>sD({url:WR(t,iA),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(fR()),"[".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(aA[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){sC(aA[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(cC(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(YP){return""}}addLogToQueue(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],i=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0,a={log:t.reduce((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim(),""),level:e,userId:i,sdkAppId:n,forAllJoinedClients:r};ZO.emit(JO.LOG,{log:a}),this._isEnableUploadLog&&e>=this._logLevelToUpload&&this._queue.push(a)}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;var o;if(r.unshift(this.getPrefix(t)),this.addLogToQueue(t,r,i,n,a),t<this._logLevel)return;let s=(null==(o=aA[t])?void 0:o.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 fD){let t=e,{parent:r}=t,i=((e,t)=>{var r={};for(var i in e)kk.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&Tk)for(var i of Tk(e))t.indexOf(i)<0&&Ak.call(e,i)&&(r[i]=e[i]);return r})(t,["parent"]),n=new fD(i);return n.bindParent(r),n}return new fD(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;aA[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};Mk($O,"PRINT_LOG_TAG",!(TD||kD||SO));var eL=new $O,tL=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)})},rL=new class{constructor(){Mk(this,"_prefix","TRTC"),Mk(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){WO()&&(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(t){return!1}return!1}).forEach(e=>localStorage.removeItem(e)))}doFlush(){if(WO())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(e){eL.warn(e)}}getItem(e){if(!WO())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(YP){eL.warn(YP)}}setItem(e,t){if(WO())try{let r={expiresIn:Date.now()+6048e5,value:t};this._queue.set(this.getRealKey(e),r)}catch(Yk){eL.warn(Yk)}}deleteItem(e){if(!WO())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(YP){return eL.warn(YP),!1}}clear(){if(WO())try{localStorage.clear()}catch(e){eL.warn(e)}}};xk({},{HTTPS_API:()=>xL,IS_GET_CAPABILITIES_FROM_INPUTDEVICE_SUPPORTED:()=>tx,IS_GET_CAPABILITIES_SUPPORTED:()=>ex,IS_GET_SETTINGS_SUPPORTED:()=>$L,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>QL,IS_INSERTABLE_STREAM_SUPPORTED:()=>rx,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>mx,IS_RTC_RTP_SENDER_SUPPORTED:()=>XL,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>ix,IS_SEI_SUPPORTED:()=>nx,IS_SPC_SUPPORTED:()=>KL,basis:()=>dx,capabilityCheck:()=>px,checkSystemRequirementsInternal:()=>kL,decodeSupportStatus:()=>SL,detectH264SupportedByFakeStreaming:()=>OL,detectVideoCodecCapabilities:()=>vx,detectVideoDecoderCapabilities:()=>Ex,detectVideoEncoderCapabilities:()=>yx,encodeSupportStatus:()=>TL,getBrowserInfo:()=>gL,getDisplayResolution:()=>PL,getH264ProfileLevelIds:()=>bx,isAddTransceiverSupported:()=>qL,isBrowserSupported:()=>_L,isCanvasCaptureStreamAPISupported:()=>BL,isCanvasSmallStreamSupported:()=>FL,isGetReceiversSupported:()=>jL,isGetSendersSupported:()=>zL,isGetTransceiversSupported:()=>GL,isGetUserMediaSupported:()=>ML,isMediaDevicesSupported:()=>yL,isMediaSessionSupported:()=>sx,isMediaStreamTrackGeneratorSupported:()=>IL,isMediaStreamTrackProcessorSupported:()=>wL,isOffscreenCanvasWorkerSupported:()=>Sx,isReplaceTrackSupported:()=>ZL,isRequestVideoFrameCallbackSupported:()=>fx,isSIMDSupported:()=>lx,isScaleResolutionDownBySupported:()=>VL,isScreenCaptureApiAvailable:()=>RL,isSelectedCandidatePair:()=>NL,isSetParametersSupported:()=>JL,isSetSinkIdSupported:()=>CL,isSmallStreamSupported:()=>WL,isStopTransceiverSupported:()=>YL,isTRTCSupported:()=>AL,isTrackGeneratorOutputSupported:()=>Ix,isUnifiedPlanDefault:()=>HL,isUsedInHttpProtocol:()=>bL,isWebAudioSupported:()=>UL,isWebCodecSupported:()=>ox,isWebCodecsSupported:()=>vL,isWebRTCSupported:()=>ax,isWebTransportSupported:()=>cx});var iL={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",SWITCH_PLAYBACK_QUALITY_TIMEOUT:"SWITCH_PLAYBACK_QUALITY_TIMEOUT"},nL={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:n}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(n,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:n}=e,a="".concat(t||r.name),o="";return o=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(a,"' must be type of ").concat(o," when calling ").concat(i,"(), received type: ").concat(aC(n),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:n}=e;return"'".concat(t||r.name,"' cannot be '").concat(n,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:n}=e,a="".concat(t||r.name),o="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(a,"' must be instanceof ").concat(o," when calling ").concat(i,"(), received type: ").concat(aC(n),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:n}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(n,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,fnName:i,value:n}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(n,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,fnName:i,value:n}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(n,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code: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:n}=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:n}=e;return"api ".concat(r," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(n," 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,"()"),SWITCH_PLAYBACK_QUALITY_TIMEOUT:e=>"switchPlaybackQuality timeout: waiting for first frame of user ".concat(e.userId,".")},aL=(e,t)=>t?"".concat(eA,"/").concat(e,"/").concat(t):"".concat(eA,"/").concat(e,"/index.html"),oL=()=>{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("trtc_error_assistance");if(e){e=JSON.parse(e);let t=document.createElement("script");t.type="text/javascript",t.text=e.message,document.body.appendChild(t);let 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 sL(e){let{key:t,data:r,link:i,addDocLink:n=!0}=e,a="",o="",s="";oC(nL[t])?a=nL[t](r):cC(nL[t])&&(a=nL[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=oL();i?s="".concat(i.className,".html#").concat(i.fnName):l&&l[t]&&(oC(l[t])?s=l[t](r):cC(l[t])&&(s=l[t]));let d=a;return tC()&&(c&&c[t]&&(oC(c[t])?o=c[t](r):cC(c[t])&&(o=c[t])),o&&(d=n?"".concat(o,"\n请查看文档: ").concat(aL("zh-cn",s),"\n\n"):"".concat(o,"\n\n"),d+=a)),n&&(d+=" \nRefer to: ".concat(aL("en",s),"\n")),d}var cL,lL=Nk(Hk(),1),dL=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Mk(this,"countMap",new Map),Mk(this,"distributionMap",new Map),Mk(this,"version"),Mk(this,"log",eL.createLogger({id:"kv"})),e&&(ZO.on("102",e=>{let{track:t,cost:r}=e;this.addSuccessEvent({key:t.kind===lA?501700:511700,cost:r})}),ZO.on("103",e=>{let{track:t,error:r}=e;this.addFailedEvent({key:t.kind===lA?501700:511700,error:r})}),ZO.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:VC(this.version||Jk),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 n;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 a=(null==(n=this.distributionMap)?void 0:n.get(t))||new Map;a.set(r,(a.get(r)||0)+1),this.distributionMap.set(t,a)}addNumber(e){let{key:t,value:r,split:i=100,useUV:n=!1,max:a=5e3}=e;var o;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(n&&this.countMap.has(t))return;r>a&&(r=a),this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map,c=0;if(lC(i))c=Math.floor(r/i);else for(let l=i.length-1;l>0;l--)if(r>i[l]){c=l;break}s.set(c,(s.get(c)||0)+1),this.distributionMap.set(t,s)}addSuccessEvent(e){let{key:t,cost:r,timeKey:i,split:n}=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:n}):i||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:r}=e;if(!t)return;let i=uR.UNKNOWN;r&&(lC(r)?i=r:(!sC(r.extraCode)||!sC(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})}},uL=((cL=uL||{})[cL.DECODER_TYPE=514700]="DECODER_TYPE",cL[cL.DECODER_HW_SW=514701]="DECODER_HW_SW",cL[cL.DECODE_RESULT=514702]="DECODE_RESULT",cL[cL.DECODE_FAILED_OS=514703]="DECODE_FAILED_OS",cL[cL.DOWNGRADE_RESULT=514704]="DOWNGRADE_RESULT",cL[cL.DOWNGRADE_WEBCODECS_VIDEO=514705]="DOWNGRADE_WEBCODECS_VIDEO",cL[cL.DOWNGRADE_WEBCODECS_2D=514706]="DOWNGRADE_WEBCODECS_2D",cL[cL.DOWNGRADE_WASM_WEGBL=514707]="DOWNGRADE_WASM_WEGBL",cL[cL.DOWNGRADE_WASM_VIDEO=514708]="DOWNGRADE_WASM_VIDEO",cL[cL.DOWNGRADE_WASM_2D=514709]="DOWNGRADE_WASM_2D",cL[cL.DECODE_H264_RESULT=514710]="DECODE_H264_RESULT",cL[cL.DECODE_H265_RESULT=514711]="DECODE_H265_RESULT",cL[cL.DECODE_VP8_RESULT=514712]="DECODE_VP8_RESULT",cL[cL.DECODE_CAPABILITIES=514713]="DECODE_CAPABILITIES",cL[cL.H264_PROFILE_LEVEL_ID_HIGH=514714]="H264_PROFILE_LEVEL_ID_HIGH",cL[cL.H264_PROFILE_LEVEL_ID_MAIN=514715]="H264_PROFILE_LEVEL_ID_MAIN",cL[cL.RENDER_FREEZE_RATE=514850]="RENDER_FREEZE_RATE",cL[cL.DATA_FREEZE_RATE=514851]="DATA_FREEZE_RATE",cL[cL.VIDEO_CONSUME_RENDER_RATE=514852]="VIDEO_CONSUME_RENDER_RATE",cL),hL=new dL(!0);new dL(!1);var pL=hL,fL={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}},mL=new Map([[RD,["Firefox",CD]],[xD,["Edg",ND]],[TO,["Chrome",RO]],[DO,["Safari",LO]],[VD,["TBS",WD]],[HD,["XWEB",jD]],[GD&&wD,["WeChat",qD]],[ZD,["QQ(Win)",JD]],[YD,["QQ(Mobile)",XD]],[KD,["QQ(Mobile X5)",XD]],[QD,["QQ(Mac)",$D]],[eO,["QQ(iPad)",tO]],[cO,["MI",lO]],[dO,["HW",pO]],[fO,["Samsung",mO]],[gO,["OPPO",_O]],[vO,["VIVO",yO]],[OD,["EDGE",LD]],[MD,["SogouMobile",UD]],[BD,["Sogou",FD]]]);function gL(){let e=mL.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var _L=function(){return!(oO||OD||xD&&PD<80||RD&&DD<56)},vL=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder"].every(e=>e in window)},yL=function(){if(!navigator.mediaDevices)return bL()||eL.error(nL.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter(e=>e in navigator.mediaDevices).length===e.length},EL=!1;function bL(){return"http:"===location.protocol&&!VO&&(EL||eL.error(sL({key:iL.NOT_SUPPORTED_HTTP})),EL=!0,!0)}var wL=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},IL=function(){return!(null==window||!window.MediaStreamTrackGenerator)},TL=async function(){var e,t,r;if(fL.detail.isH264EncodeSupported&&fL.detail.isVp8EncodeSupported)return{isH264EncodeSupported:fL.detail.isH264EncodeSupported,isVp8EncodeSupported:fL.detail.isVp8EncodeSupported,isH265EncodeSupported:fL.detail.isH265EncodeSupported};let i,n=!1,a=!1,o=!1;try{let s=new RTCPeerConnection,c=document.createElement(cA);c.getContext("2d");let l=c.captureStream(0);return s.addTrack(l.getVideoTracks()[0],l),i=await s.createOffer(),n=-1!==(null==(e=i.sdp)?void 0:e.toLowerCase().indexOf("h264")),a=-1!==(null==(t=i.sdp)?void 0:t.toLowerCase().indexOf("vp8")),o=-1!==(null==(r=i.sdp)?void 0:r.toLowerCase().indexOf("h265")),s.close(),{isH264EncodeSupported:n,isVp8EncodeSupported:a,isH265EncodeSupported:o}}catch(s){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH265EncodeSupported:!1}}},SL=async function(){var e;if(fL.detail.isH264DecodeSupported&&fL.detail.isVp8DecodeSupported)return{isH264DecodeSupported:fL.detail.isH264DecodeSupported,isVp8DecodeSupported:fL.detail.isVp8DecodeSupported,isH265DecodeSupported:fL.detail.isH265DecodeSupported};let t,r=!1,i=!1;try{let n=new RTCPeerConnection;qL()?(n.addTransceiver(dA,{direction:"recvonly"}),t=await n.createOffer()):t=await n.createOffer({offerToReceiveVideo:!0}),-1!==t.sdp.toLowerCase().indexOf("h264")&&!(xO&&kO<79)&&(r=!0),-1!==t.sdp.toLowerCase().indexOf("vp8")&&(i=!0);let a=-1!==(null==(e=t.sdp)?void 0:e.toLowerCase().indexOf("h265"));return n.close(),{isH264DecodeSupported:r,isVp8DecodeSupported:i,isH265DecodeSupported:a}}catch(n){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1,isH265DecodeSupported:!1}}};var kL=jC(async e=>{let t=Date.now(),r=ax(),i=yL(),n=vL();if(fL.detail.isWebRTCSupported=r,fL.detail.isMediaDevicesSupported=i,fL.detail.isWebCodecsSupported=n,fL.detail.isScreenShareSupported=RL(),fL.detail.isSmallStreamSupported=WL(),37===e)return Object.assign(fL.detail,await async function(){return LL||(LL=new Promise(async e=>{let t={isH264EncodeSupported:!1,isH264DecodeSupported:!1,isVp8EncodeSupported:!1,isVp8DecodeSupported:!1};if(!vL())return void e(t);let r=null,i=null,n=null,a=()=>{n&&clearTimeout(n),r=null,i=null};try{r=document.createElement("canvas"),i=r.getContext("2d"),r.width=320,r.height=240;let o=0,s=()=>{!i||!r||(i.fillStyle="hsl(".concat(o%360,", 50%, 50%)"),i.fillRect(0,0,r.width,r.height),i.fillStyle="white",i.font="20px Arial",i.fillText("Frame ".concat(o),10,30),o++)};n=setTimeout(()=>{a(),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"}}];(await Promise.all(c.map(async e=>{let t,i={type:e.type,encodeSupported:!1,decodeSupported:!1};try{t=await new Promise(async(t,n)=>{try{let a=new VideoEncoder({output:e=>{t(e),i.encodeSupported=!0},error:n});a.configure(e.encodeConfig),s();let o=new VideoFrame(r,{timestamp:0});a.encode(o,{keyFrame:!0}),o.close(),await a.flush(),a.close()}catch(a){n(a)}})}catch(p){return eL.warn("".concat(e.type," encoder error:"),p),i}try{await new Promise(async(r,n)=>{try{let a=new VideoDecoder({output:e=>{i.decodeSupported=!0,r(0),e.close()},error:n});a.configure(e.decodeConfig),a.decode(t),await a.flush(),a.close()}catch(a){n(a)}})}catch(p){eL.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)}),a(),e(t)}catch(o){a(),eL.warn("detectWebCodecsSupported failed:",o),e(t)}}),LL)}()),fL.detail.isBrowserSupported=n,fL.result=i&&n,fL.result||eL.error("".concat(navigator.userAgent," ").concat(MC(fL.detail,!1))),hx(e),pL.addNumber({key:523800,value:Date.now()-t}),fL;if(fL.result&&fL.detail.isH264EncodeSupported&&fL.detail.isVp8EncodeSupported&&fL.detail.isH265EncodeSupported&&fL.detail.isH264DecodeSupported&&fL.detail.isVp8DecodeSupported&&fL.detail.isH265DecodeSupported)return fL;let a=_L(),{encode:o,decode:s}=await async function(){let[e,t]=await Promise.all([TL(),SL()]);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}=o,{h264:d}=s,{h265:u}=o,{vp8:h,h265:p}=s;if(!c||!l){let e=await TL();eL.warn("detect encode again h264:".concat(c," vp8:").concat(l," result: ").concat(JSON.stringify(e))),c=e.isH264EncodeSupported,l=e.isVp8EncodeSupported}if(c&&d&&kD&&IO&&!HD&&!VD&&(!gO||115!==kO)){let{encode:e,decode:t}=await OL();c=e,d=t}return fL.result=a&&r&&i&&(c||l)&&(d||h),fL.detail.isBrowserSupported=a,fL.detail.isWebRTCSupported=r,fL.detail.isH264EncodeSupported=c,fL.detail.isVp8EncodeSupported=l,fL.detail.isH265EncodeSupported=u,fL.detail.isH264DecodeSupported=d,fL.detail.isVp8DecodeSupported=h,fL.detail.isH265DecodeSupported=p,fL.result||eL.error("".concat(navigator.userAgent," ").concat(MC(fL.detail,!1))),hx(),pL.addNumber({key:523800,value:Date.now()-t}),fL}),AL=function(){return fL.result},RL=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},CL="undefined"!=typeof HTMLMediaElement&&"setSinkId"in HTMLMediaElement.prototype,DL=null;async function OL(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;return DL||(DL=new Promise(async t=>{let r={encode:!1,decode:!1},i=()=>{};try{let n=document.createElement("canvas"),a=n.getContext("2d");n.width=640,n.height=480;let o=setInterval(()=>{a.fillText("test",Math.floor(640*Math.random()),Math.floor(480*Math.random()))},66),s=-1,c=-1;i=()=>{clearInterval(s),clearInterval(o),clearTimeout(c),d.close(),u.close(),l.getTracks().forEach(e=>e.stop())},c=setTimeout(()=>{i(),t(r)},e);let l=n.captureStream(),d=new RTCPeerConnection({}),u=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});d.addEventListener("icecandidate",e=>u.addIceCandidate(e.candidate)),u.addEventListener("icecandidate",e=>d.addIceCandidate(e.candidate)),d.addTrack(l.getVideoTracks()[0],l);let h=await d.createOffer();await d.setLocalDescription(h),await u.setRemoteDescription(h);let p=await u.createAnswer(),f=lL.default.parse(p.sdp),m=f.media[0].rtp.findIndex(e=>"H264"===e.codec);f.media[0].rtp=[f.media[0].rtp[m]],f.media[0].fmtp=f.media[0].fmtp.filter(e=>e.payload===f.media[0].rtp[0].payload),f.media[0].rtcpFb&&(f.media[0].rtcpFb=f.media[0].rtcpFb.filter(e=>e.payload===f.media[0].rtp[0].payload)),p.sdp=lL.default.write(f),await u.setLocalDescription(p),await d.setRemoteDescription(p),s=setInterval(async()=>{r.encode&&r.decode&&(i(),t(r));let e=d.getSenders()[0],n=u.getReceivers()[0];if(!e||!n)return;let[a,o]=await Promise.all([e.getStats(),n.getStats()]);r.encode||a.forEach(e=>{"outbound-rtp"===e.type&&(e.mediaType===dA||e.kind===dA)&&e.bytesSent>0&&(r.encode=!0)}),r.decode||o.forEach(e=>{"inbound-rtp"===e.type&&(e.mediaType===dA||e.kind===dA)&&e.bytesReceived>0&&(r.decode=!0)})},100)}catch(n){i(),eL.warn("detectH264Supported failed",n),t({encode:!0,decode:!0})}}).then(e=>(e.encode||(e.decode=!0),(!e.encode||!e.decode)&&eL.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat("")),e)),DL)}var LL=null;var xL=(e,t,r)=>{"http:"===location.protocol&&!VO&&(e[t]=()=>{throw new pR({code:uR.INVALID_OPERATION,message:nL.NOT_SUPPORTED_HTTP})})},NL=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(dC(e.selected)&&!e.selected)};function PL(){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 ML(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function UL(){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 BL(){return"captureStream"in HTMLCanvasElement.prototype}function FL(){return!(GD||TD||kO&&kO<63)&&!(!_L()||!BL())}function VL(){return!(kO<74||OD||MO<11||DD<46)}function WL(){return FL()||VL()}var HL=function(){if(sC(window.RTCRtpTransceiver)||!qL()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:"unified-plan"}),e.addTransceiver(lA),t=!0}catch(YP){}return null==e||e.close(),t};function jL(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function zL(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function GL(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function qL(){return!(11===MO&&!FO)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var KL=!(!qL()||IO&&kO<86);function YL(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var XL="RTCRtpSender"in window;function ZL(){return XL&&"replaceTrack"in window.RTCRtpSender.prototype}function JL(){return XL&&"setParameters"in window.RTCRtpSender.prototype&&zL()}var QL="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,$L=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,ex=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,tx="undefined"!=typeof InputDeviceInfo&&"getCapabilities"in InputDeviceInfo.prototype,rx=XL&&"createEncodedStreams"in window.RTCRtpSender.prototype&&bO()>=86,ix="RTCRtpScriptTransform"in window,nx=XL&&(rx||ix),ax=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter(e=>e in window).length>0};function ox(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return sC(window.AudioDecoder)||(e.AudioDecoder=!0),sC(window.AudioEncoder)||(e.AudioEncoder=!0),sC(window.VideoDecoder)||(e.VideoDecoder=!0),sC(window.VideoEncoder)||(e.VideoEncoder=!0),sC(window.ImageDecoder)||(e.ImageDecoder=!0),e}function sx(){return"mediaSession"in navigator&&!sC(navigator.mediaSession.setActionHandler)}function cx(){return!sC(window.WebTransport)}function lx(){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 dx(){let e={browser:"".concat(HO.name,"/").concat(HO.version),os:KO(),displayResolution:PL(),isScreenShareSupported:RL(),isWebRTCSupported:ax(),isGetUserMediaSupported:ML(),isWebAudioSupported:UL(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:ox(),isMediaSessionSupported:sx(),isWebTransportSupported:cx()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var ux="checkResult";function hx(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30;rL.setItem(ux+e,{ua:navigator.userAgent,checkResult:fL})}function px(e){bL();let t=rL.getItem(ux+e);t&&t.ua===navigator.userAgent&&t.checkResult&&function(e,t){return!!uC(e)&&Object.keys(t).every(t=>t in e)}(t.checkResult.detail,fL.detail)&&(fL=t.checkResult),kL(e)}function fx(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var mx="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype;function gx(e){return{h264:1,h265:2,vp8:3,vp9:4,av1:5}[e]}var _x=!1;async function vx(){var e;try{if(_x||null==(e=null==navigator?void 0:navigator.mediaCapabilities)||!e.encodingInfo)return;let t=YO(),r=GD||HD?4:IO?1:DO?2:RD?3:0;if(0===t||0===r)return;_x=!0;let i=["H264","VP8","VP9","AV1","H265"],[n,a]=await Promise.all([yx(i),Ex(i)]);n&&Object.keys(n).forEach(e=>{let i=gx(e.toLowerCase());pL.addEnum({key:513707,value:+"".concat(i).concat(+n[e].supported).concat(+n[e].powerEfficient).concat(t).concat(r),useUV:!1})}),a&&Object.keys(a).forEach(e=>{let i=gx(e.toLowerCase());pL.addEnum({key:514713,value:+"".concat(i).concat(+a[e].supported).concat(+a[e].powerEfficient).concat(t).concat(r),useUV:!1})});let{sender:o,receiver:s}=bx();pL.addEnum({key:513708,value:+"".concat(t).concat(r).concat(+o.high),useUV:!1}),pL.addEnum({key:513709,value:+"".concat(t).concat(r).concat(+o.main),useUV:!1}),pL.addEnum({key:514714,value:+"".concat(t).concat(r).concat(+s.high),useUV:!1}),pL.addEnum({key:514715,value:+"".concat(t).concat(r).concat(+s.main),useUV:!1})}catch(t){eL.info("detectVideoCodecCapabilities failed",t)}}async function yx(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,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,a={};try{for(let o of e){let e=await navigator.mediaCapabilities.encodingInfo({type:"webrtc",video:{contentType:"video/".concat(o),width:t,height:r,bitrate:n,framerate:i}});a[o]=e}}catch(Xk){}return a}async function Ex(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,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3,a={};try{for(let o of e){let e=await navigator.mediaCapabilities.decodingInfo({type:"webrtc",video:{contentType:"video/".concat(o),width:t,height:r,bitrate:n,framerate:i}});a[o]=e}}catch(Xk){}return a}function bx(){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(t){eL.warn("get H264 profile levelId failed",t)}return e}var wx=null;function Ix(){if(null!==wx)return wx;let e="undefined"!=typeof MediaStreamTrackGenerator,t="undefined"!=typeof VideoFrame;return wx=e&&t,eL.debug("TrackGenerator support: ".concat(wx," (MediaStreamTrackGenerator=").concat(e,", VideoFrame=").concat(t,")")),wx}var Tx=null;function Sx(){if(null!==Tx)return Tx;if(OO)return Tx=!1,!1;let e=!1;try{"undefined"!=typeof OffscreenCanvas&&(e=!!new OffscreenCanvas(1,1).getContext("2d"))}catch(t){}return Tx=e&&Ix()&&("undefined"!=typeof VideoFrame||"function"==typeof createImageBitmap)&&wL()&&function(){try{if("undefined"==typeof ReadableStream)return!1;let e=new ReadableStream,{port1:t,port2:r}=new MessageChannel;return t.postMessage(e,[e]),t.close(),r.close(),!0}catch(e){return!1}}(),Tx}var kx=Nk(Bk(),1),Ax=Symbol("instance"),Rx=Symbol("cacheResult"),Cx=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,Nx.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},Dx=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var Ox=new Map;function Lx(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,n,a)=>{let o=r.action||n;if(!r.context){let r=Ox.get(i)||[];Ox.has(i)||Ox.set(i,r),r.push({from:e,to:t,action:o})}let s=a.value;a.value=function(){let i=this;for(var n=arguments.length,a=new Array(n),c=0;c<n;c++)a[c]=arguments[c];if(r.context&&(i=Px.get("function"==typeof r.context?r.context.call(this,...a):r.context)),i.state===t)return r.sync?i[Rx]:Promise.resolve(i[Rx]);i.state instanceof Cx&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof Cx&&i.state.abort(i):("string"!=typeof i.state||!e.includes(i.state))&&(l=new Dx(i._state,"".concat(i.name," ").concat(o," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new Dx(i._state,"".concat(i.name," ").concat(o," 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(l)return d(l);let u=i.state,h=new Cx(u,t,o);Nx.call(i,h);let p=e=>{var n;return i[Rx]=e,h.aborted||(Nx.call(i,t),null===(n=r.success)||void 0===n||n.call(this,i[Rx])),e},f=e=>(Nx.call(i,u,e),d(e));try{let e=s.apply(this,a);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(f):r.sync?p(e):Promise.resolve(p(e))}catch(m){return f(new Dx(i._state,"".concat(i.name," ").concat(o," from ").concat(e," to ").concat(t," failed: ").concat(m),m instanceof Error?m:new Error(String(m))))}}}}var xx="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 Nx(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(Px.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var Px=class e extends kx.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 n=i[Ax];n?this.name=n.name+"-"+n.count++:i[Ax]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=Ox.get(e)||[],r=new Set,i=[],n=[],a=new Set,o=Object.getPrototypeOf(e);Ox.has(o)&&(o.stateDiagram.forEach(e=>r.add(e)),o.allStates.forEach(e=>a.add(e))),t.forEach(e=>{let{from:t,to:r,action:a}=e;"string"==typeof t?i.push({from:t,to:r,action:a}):t.length?t.forEach(e=>{i.push({from:e,to:r,action:a})}):n.push({to:r,action:a})}),i.forEach(e=>{let{from:t,to:i,action:n}=e;a.add(t),a.add(i),a.add(n+"ing"),r.add("".concat(t," --\x3e ").concat(n,"ing : ").concat(n)),r.add("".concat(n,"ing --\x3e ").concat(i," : ").concat(n," 🟢")),r.add("".concat(n,"ing --\x3e ").concat(t," : ").concat(n," 🔴"))}),n.forEach(e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),a.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:a}}),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]:{};xx(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){Nx.call(this,e)}};Px.STATECHANGED="stateChanged",Px.UPDATEAFSM="updateAFSM",Px.INIT="[*]",Px.ON="on",Px.OFF="off",Px.instances=new Map,Px.instances2=new WeakMap;var Mx="undefined"!=typeof window,Ux=Mx&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout(()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})},1e3)},Bx=Mx&&window.cancelIdleCallback||function(e){clearTimeout(e)},Fx=Mx&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),Vx=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=Ck("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=Dk(Ck({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=bC(),n=()=>{if(r=bC()-i,r>=t.delay&&(i=bC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=Ux(n,{timeout:t.delay})};return t.ricID=Ux(n,{timeout:t.delay})}static raf(t){let r,i=bC(),n=()=>document.hidden&&t.backgroundTask?(r=bC()-i,i=bC(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(n,t.delay-Math.floor(r%t.delay))):(r=bC()-i,r>=t.delay&&(i=bC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(n));if(t.rafID=requestAnimationFrame(n),t.backgroundTask){let e=()=>{if(document.hidden){let e=bC()-i;e>=t.delay?n():t.timeoutID=setTimeout(n,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:n,onVisibilitychange:a}=this.taskMap.get(e);return t&&clearInterval(t),r&&clearTimeout(r),i&&Fx&&Fx(i),n&&Bx(n),a&&document.removeEventListener("visibilitychange",a),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)}};Mk(Vx,"taskMap",new Map),Mk(Vx,"currentTaskID",1),Mk(Vx,"sharedWorker",null),Mk(Vx,"workerTasks",new Map);var Wx=Vx,Hx={LOAD_START:yA,LOADED_DATA:EA,LOADED_META_DATA:bA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",RESIZE:AA,TIME_UPDATE:"time-update",LEAVE_PICTURE_IN_PICTURE:SA,ENTER_PICTURE_IN_PICTURE:TA,USER_RESUME_IN_PIP_OR_FULL_SCREEN:"user-resume-in-pip-or-full-screen",USER_PAUSE_IN_PIP_OR_FULL_SCREEN:"user-pause-in-pip-or-full-screen",ENTER_FULL_SCREEN:"enter-full-screen",LEAVE_FULL_SCREEN:"leave-full-screen",VOLUME_CHANGE:"volume-change"},jx={};xk(jx,{create:()=>Gx,remove:()=>qx});var zx=new WeakMap;function Gx(e,t){zx.has(e)||zx.set(e,[]);let r=zx.get(e),i={add:(e,n)=>("addEventListener"in t?(r.push(t.removeEventListener.bind(t,e,n)),t.addEventListener(e,n)):(r.push(t.off.bind(t,e,n)),t.on(e,n)),i)};return i}function qx(e){let t=zx.get(e);t&&(t.forEach(e=>e()),zx.delete(e))}var Kx=new class{constructor(){Mk(this,"_roomIdMap",new Map),Mk(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:Jk,env:nA,browserVersion:HO.name+HO.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:r,userId:i,roomId:n}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=r,this._configs.userId=i,this._roomIdMap.set(i,String(n))}logSuccessEvent(e){VO||!eL.isAbleToUpload||this._configs.env===nA&&this.uploadEventToKibana(Dk(Ck({},e),{result:"success"}))}logFailedEvent(e){if(VO||!eL.isAbleToUpload)return;let{eventType:t,code:r,error:i,userId:n}=e,a={roomId:this._roomIdMap.get(n||this._configs.userId),userId:n,eventType:t,result:"failed",code:r||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||uR.UNKNOWN};this._configs.env===nA&&this.uploadEventToKibana(Dk(Ck({},a),{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,n={timestamp:mR(),sdkAppId:this._configs.sdkAppId,userId:r||this._configs.userId,version:Jk,log:t};i&&(n.errorInfo=i.message,i.stack&&(n.errorInfo+="\n".concat(i.stack)));let a=QO.enable?JC(n,2002,Number(this._configs.sdkAppId)):JSON.stringify(n);this.sendRequest(WR(this._configs.sdkAppId,iA),a)}sendRequest(e,t){setTimeout(()=>sD({url:e,body:t,priority:"low"}).catch(()=>{}),2e3)}},Yx=new WeakMap;var Xx=class extends Px{constructor(e,t){super(e.id,"".concat(t,"-player")),this.options=e,this.kind=t,Mk(this,"id"),Mk(this,"element",null),Mk(this,"track"),Mk(this,"url"),Mk(this,"attr"),Mk(this,"mode"),Mk(this,"muted"),Mk(this,"_log"),Mk(this,"isPausedByUserCall",!1),Mk(this,"_pausedRetryCount"),Mk(this,"_isElementPlayingFired",!1),Mk(this,"_interval"),Mk(this,"_delayDestroyTimeoutId",0),Mk(this,"_playSuccessResolve"),Mk(this,"_isReplayByRecreateMediaStreamCalled",!1),Mk(this,"isPlayCalled",!1),Mk(this,"isInAutoPlayFailedState",!1),Mk(this,"isBindAutoPlayEvent",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=5,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))}async play(){if(!this.isPlaying)try{this.isPlayCalled=!0,this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),await new Promise((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)})}catch(YP){let t=sL({key:iL.PLAY_FAILED,data:{media:this.kind,error:YP}});if(this._log.warn(YP),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new pR({code:uR.PLAY_NOT_ALLOWED,message:t})}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this.isPlayCalled=!1,this.isPausedByUserCall=!1,this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!OO?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(mA),this._interval>0&&Wx.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(){this._log.info("pause"),this.isPausedByUserCall=!0,this.doPause()}doPause(){var e;null==(e=this.element)||e.pause()}resume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPausedByUserCall=!1,this.doResume(e)}doResume(){return this._log.info("resume"),this.isPausedByUserCall||this.isPlaying?Promise.resolve():UO?this.replay():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 Gx(this.element,this.element).add(gA,e).add(mA,e).add(_A,e).add(vA,e).add(yA,e).add(EA,e).add(bA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==jx||jx.create(e,e).add(mA,t).add(pA,t).add(fA,t),e.readyState===mA&&this.handleTrackEvent({type:mA}),e.muted&&this.handleTrackEvent({type:pA})}}bindAutoPlayEvent(){this.isBindAutoPlayEvent||(ZO.on(JO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this),this.isBindAutoPlayEvent=!0)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&qx(e)}unbindEvents(){this.element&&qx(this.element),this.unbindTrackEvents(),ZO.off(JO.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this),this.isBindAutoPlayEvent=!1}handleElementEvent(e){switch(e.type){case gA:pN()||(this.isInAutoPlayFailedState=!1),this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(gA),this._interval&&(Wx.clearTask(this._interval),this._interval=-1);break;case mA:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(mA);break;case _A:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(_A);break;case vA:if(this.element&&this.element.error){this.handlePaused(vA);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)),Kx.uploadEvent({log:"stat-".concat(this.kind,"-").concat(RA,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),hO||uO?this.emit(Hx.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case EA:this.kind===dA&&this.emit(Hx.LOADED_DATA);break;case bA:this.kind===dA&&this.emit(Hx.LOADED_META_DATA);break;case yA:this.emit(Hx.LOAD_START)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then(()=>{this._log.warn("replayByRecreateMediaStream success"),Kx.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),pL.addSuccessEvent({key:this.kind===lA?506700:516700})}).catch(()=>{var t;this._log.error("replayByRecreateMediaStream failed"),Kx.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),pL.addFailedEvent({key:this.kind===lA?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(Hx.ERROR,e)})}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise((t,r)=>{HC(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)}),HC(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)})}async handleTrackEvent(e){let t=e.type;switch(this.options.enableLogTrackState&&this._log[t===fA?"info":"warn"]("track ".concat(t)),t){case mA:this.handleStopped(mA);break;case pA:this.handlePaused(pA);break;case fA:this.mode>0?this.handlePlaying(this.mode.toString()):this.element&&(this.element.paused&&!this.isPausedByUserCall&&(this._log.warn("track unmuted and element is paused, resume"),await this.doResume()),this.element&&!this.element.paused&&this._isElementPlayingFired&&this.handlePlaying(fA))}}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}};Mk(Xx,"PlayerEvent",Hx),Pk([function(e){let{settings:t={retries:5,timeout:2e3},onError:r,onRetrying:i,onRetryFailed:n}=e;return function(e,a,o){let s=pD({retryFunction:o.value,settings:t,onError(t){let{error:i,retry:n,reject:o,retryFuncArgs:s}=t;var c;r?r.call(this,i,()=>{var t;null!=(t=Yx.get(e))&&t.has(a)?n():o(i)},o,s):null!=(c=Yx.get(e))&&c.has(a)?n():o(i)},onRetrying(t,r){var n;lD(i)&&i.call(this,t,r),null!=(n=Yx.get(e))&&n.has(a)&&(Yx.get(e).get(a).stopRetry=r)},onRetryFailed:n});return o.value=function(){let t=Yx.get(e);for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return t?t.set(a,{args:i}):Yx.set(e,new Map([[a,{args:i}]])),s.apply(this,i).finally(()=>{var t;return null==(t=Yx.get(e))?void 0:t.delete(a)})},o}}({settings:{retries:2,timeout:0},onError(e,t,r,i){i[0]=(i[0]||1e3)+1e3,t()}})],Xx.prototype,"doReplayByRecreateMediaStream",1),Pk([Lx([],"PLAYING",{sync:!0,success(e){this.emit(Hx.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}})],Xx.prototype,"handlePlaying",1),Pk([Lx("PLAYING","PAUSED",{ignoreError:!0,sync:!0,success(e){this.emit(Hx.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}})],Xx.prototype,"handlePaused",1),Pk([Lx([],"STOPPED",{sync:!0,success(e){this.emit(Hx.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}})],Xx.prototype,"handleStopped",1);var Zx="trtc_autoplay",Jx="".concat(Zx,"_mask"),Qx="".concat(Zx,"_wrapper"),$x="".concat(Zx,"_header"),eN="".concat(Zx,"_content"),tN="".concat(Zx,"_action_wrapper"),rN="".concat(Zx,"_question"),iN="".concat(Zx,"_collapse"),nN="".concat(Zx,"_action_confirm"),aN="".concat(Zx,"_detail"),oN="#2473E8",sN="dialog",cN="".concat(sN,"-show"),lN="".concat(sN,"-1"),dN="".concat(sN,"-2"),uN=!1,hN=!1,pN=()=>hN,fN="".concat(eA,"/").concat(tC()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),mN="<br><a href='".concat(fN,"' target='_blank'>").concat(tC()?"其他方案?":"Any other solution?","</a>"),gN="".concat(tC()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(mN):"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(mN)),_N=class{constructor(){if(Mk(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),Mk(this,"_dialogNode",null),Mk(this,"_bodyPosition",""),Mk(this,"_showDetail",!1),Mk(this,"_isCollapseClicked",!1),Mk(this,"_isQuestionClicked",!1),tC()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!uN){let e=document.createElement("style");e.innerHTML=".".concat(Jx,"{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(Jx," div:not(.").concat(tN,"){display:block !important;}.").concat(Qx,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(Qx," a{color:").concat(oN,";}.").concat($x,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(eN,"{margin:8px 0;}.").concat(tN,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(iN,"{margin-right:auto;cursor:pointer}.").concat(rN,"{height:100%;line-height:16px;cursor:pointer;}.").concat(nN,"{margin-left:8px;color:#fff;background:").concat(oN,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(nN,":hover{opacity:0.9;}.").concat(iN,",.").concat(nN,",.").concat(eN,",.").concat(rN,"{font-size:14px;}@media screen and (max-width:750px){.").concat(Qx,"{width:80vw;}}"),document.head.appendChild(e),uN=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(Jx,"\"><div class='").concat(Qx,"'><div class='").concat($x,"'>").concat(location.host,"</div><div class='").concat(eN,"'>").concat(this.content,"</div><div class='").concat(aN,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(gN,"</div><div class='").concat(tN,"'></div></div></div>").trim();let t=document.createElement("button");t.className=nN,t.innerText=tC()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let r=document.createElement("div");r.className=rN,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=iN,i.innerText="".concat(tC()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let n=e.content.firstChild,a=n.querySelector(".".concat(tN));return a.appendChild(i),a.appendChild(r),a.appendChild(t),n}addDiaLog(){pN()||(hN=!0,this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(Qx)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",eL.info("show autoplay dialog"),Kx.uploadEvent({log:cN}))}deleteDialog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null,hN=!1),vN=null}onConfirm(){eL.warn("confirm clicked, try resume stream"),ZO.emit(JO.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDialog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(aN));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||Kx.uploadEvent({log:lN}),this._isCollapseClicked=!0}onQuestionClick(){window.open(fN,"_blank"),this._isQuestionClicked||Kx.uploadEvent({log:dN}),this._isQuestionClicked=!0}},vN=null;var yN,EN=class extends Xx{constructor(e){super(e,dA),Mk(this,"stat",{}),Mk(this,"_calculateTimeout",-1),Mk(this,"viewMirror",!1),Mk(this,"objectFit","cover"),Mk(this,"container"),Mk(this,"canvas"),Mk(this,"shouldRenderAlpha",!1),Mk(this,"_preSize",{width:0,height:0}),Mk(this,"posterImg"),Mk(this,"pipWindow"),Mk(this,"enterPIPPromise"),Mk(this,"_originContainerPosition"),Mk(this,"_isResettingSrcObject",!1),Mk(this,"_wrapper",null),Mk(this,"_useWrapper",!1),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,sC(e.viewMirror)||(this.viewMirror=e.viewMirror),sC(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(){let e=document.createElement(dA);this.track&&2!==this.mode&&(e.srcObject=new MediaStream([this.track])),e.muted=!0,e.setAttribute("id","video_".concat(this.id)),e.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),e.setAttribute("autoplay","autoplay"),e.setAttribute("playsinline","playsinline"),this.element=e,kD&&(e.poster="data:,"),this._appendToWrapper(),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e=this._useWrapper?"grid-area:1/1;width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";"):"width:100%;height:100%;object-fit:".concat(this.objectFit,";").concat(this.shouldRenderAlpha?"":"background-color:black",";");return this.viewMirror&&(e+="transform:scaleX(-1);"),e}setLiveMode(e){if(this._useWrapper!==e&&(this._useWrapper=e,this.elementToRender&&this.elementToRender.setAttribute("style",this.styleAttribute),this.container&&this.elementToRender))if(e){let e=this._getOrCreateWrapper();e.insertBefore(this.elementToRender,e.firstChild)}else this.container.appendChild(this.elementToRender),this._cleanupWrapper()}setContainer(e){if(this.container===e)return;let t=this._wrapper,r=this.container;this.container=e,this._pausedRetryCount=5,this.track&&this.elementToRender&&this._appendToWrapper(),t&&r&&r!==this.container&&t.isConnected&&0===t.children.length&&t.remove()}_getOrCreateWrapper(){if(!this.container)throw new Error("[VideoPlayer] container is required");let e=this.container.querySelector("[data-trtc-video-wrapper]");return e||(e=document.createElement("div"),e.setAttribute("data-trtc-video-wrapper","true"),e.style.cssText="display:grid;width:100%;height:100%;",this.container.appendChild(e)),this._wrapper=e,e}_appendToWrapper(e){let t=null!=e?e:this.elementToRender;if(this.container&&t)if(this._useWrapper){let e=this._getOrCreateWrapper();e.insertBefore(t,e.firstChild)}else this.container.appendChild(t)}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),this.handleFullscreenChange=this.handleFullscreenChange.bind(this),this.handleVolumeChange=this.handleVolumeChange.bind(this),e&&e.add(TA,this.handleElementEvent).add(SA,this.handleElementEvent).add(AA,this.handleElementEvent),this.element&&(this.element.addEventListener(kA,this.handleFullscreenChange),this.element.addEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.addEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.addEventListener("volumechange",this.handleVolumeChange))}handleTrackEvent(e){var t;return e.type===pA&&(null!=(t=this.stat)&&t.fps&&(this.stat.fps=0),this.isFullscreen()&&this.resetSrcObjectToReplay()),super.handleTrackEvent(e)}handleFullscreenChange(){this.isFullscreen()?(this._log.info("enter fullscreen"),this.emit(Hx.ENTER_FULL_SCREEN)):(this._log.info("leave fullscreen"),this.emit(Hx.LEAVE_FULL_SCREEN))}handleVolumeChange(){var e;(this.isPictureInPicture()||this.isFullscreen())&&this.emit(Hx.VOLUME_CHANGE,{muted:null==(e=this.element)?void 0:e.muted})}handleElementEvent(e){var t,r,i,n,a,o;if(2===this.mode)return;super.handleElementEvent(e);let s=e.type,c=this.isPictureInPicture(),l=this.isFullscreen(),d=e.isTrusted&&(c&&DO||l);if(s===gA&&d&&!this._isResettingSrcObject&&(this._log.warn("user resume in ".concat(l?"fullscreen":"pip")),this.emit(Hx.USER_RESUME_IN_PIP_OR_FULL_SCREEN)),s===_A&&(d&&(this._log.warn("user pause in ".concat(l?"fullscreen":"pip")),this.emit(Hx.USER_PAUSE_IN_PIP_OR_FULL_SCREEN)),this.container&&!this.container.isConnected&&(this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(this.container.id)),HC(500).then(()=>{var e;null!=(e=this.container)&&e.isConnected&&(this._pausedRetryCount=5,this._log.info("view container ".concat(this.container.id," is in dom, reset pausedRetryCount")))})),this._pausedRetryCount>0&&!pN()&&!this.isPausedByUserCall&&!d&&(this._log.info("[".concat(5-this._pausedRetryCount+1,"/").concat(5,"] ").concat(this.kind," player auto resume when paused")),this.doResume(),this._pausedRetryCount--),TD&&!d&&(this._interval=Wx.run("timeout",()=>{this.element&&"PAUSED"===this._state&&!this.isPausedByUserCall&&this.doResume()},{delay:3e3})),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;s===TA?this.element.style.transform=e.replace("scaleX(-1)",""):s===SA&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}s===AA&&(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==(n=this.element)?void 0:n.videoHeight)),this._preSize.height=(null==(a=this.element)?void 0:a.videoHeight)||0,this._preSize.width=(null==(o=this.element)?void 0:o.videoWidth)||0,this.emit(Hx.RESIZE,{newWidth:this._preSize.width,newHeight:this._preSize.height})),s===SA&&(this._log.warn("exit pip"),this.isPaused&&!this.isPausedByUserCall&&(this._log.warn("resume after exit pip"),this.doResume()),this.resetSrcObjectToReplay(),this.emit(Hx.LEAVE_PICTURE_IN_PICTURE)),s===TA&&this.emit(Hx.ENTER_PICTURE_IN_PICTURE)}resetSrcObjectToReplay(){kD&&AO&&this.isPlayCalled&&this.element&&this.track&&!this.isPausedByUserCall&&(this._log.warn("reset srcObject to replay for android chromium"),this._isResettingSrcObject=!0,this.element.srcObject=new MediaStream([this.track]),this.element.play().catch(e=>{this._log.warn("play failed after reset srcObject",e)}).finally(()=>{this._isResettingSrcObject=!1}))}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var r,i;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(),this._appendToWrapper(e)):this.element&&this._appendToWrapper(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||(this._log.info("setPoster",e.slice(0,10)),""===e?this.element.removeAttribute("poster"):this.element.poster=e,!t||!DO&&!RD))return r();if(""===e)return this.removePosterImg(),r();if(this.posterImg)return r();let i=document.createElement("img");i.src=e;let n=window.getComputedStyle(this.element),a=n.objectFit||this.objectFit,o=1;if(this._useWrapper){let e=parseInt(n.zIndex,10);isNaN(e)||(o=e+1)}i.style.cssText=this._useWrapper?"grid-area:1/1;z-index:".concat(o,";width:100%;height:100%;object-fit:").concat(a,";"):"position:absolute;top:0;left:0;width:100%;height:100%;object-fit:".concat(a,";"),i.onload=async()=>{try{i.decode&&await i.decode(),this.container&&!this._useWrapper&&"static"===window.getComputedStyle(this.container).position&&(this._originContainerPosition=this.container.style.position,this.container.style.position="relative"),this.posterImg=i;let e=this._useWrapper?this._wrapper:this.container;null==e||e.appendChild(i),SD()&&MO<=17&&this.elementToRender&&(this.elementToRender.style.visibility="hidden")}catch(e){this._log.warn("decode poster image error",e)}return r()},i.onerror=()=>(this._log.warn("load poster image error"),r())})}removePosterImg(){this.posterImg&&(SD()&&MO<=17&&this.elementToRender&&(this.elementToRender.style.visibility=""),this.posterImg.remove(),URL.revokeObjectURL(this.posterImg.src),!this._useWrapper&&this.container&&!sC(this._originContainerPosition)&&"relative"===this.container.style.position&&(this.container.style.position=this._originContainerPosition),delete this.posterImg)}get hasPoster(){var e;return!!this.posterImg||!(null==(e=this.element)||!e.getAttribute("poster"))}async pause(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];super.pause(),!this.isPictureInPicture()&&!this.hasPoster&&(AO||e&&(RD||DO))&&await this.setPoster(this.getVideoFrame(),!0)}resume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return super.resume(e).then(()=>{var e;(this.posterImg||null!=(e=this.element)&&e.poster)&&this.setPoster("",!0)})}doResume(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isPaused&&e&&this.element&&this.track&&AO&&"video"===this.track.kind&&(this.element.srcObject=new MediaStream([this.track])),super.doResume()}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;this.isPictureInPicture()&&this.exitPictureInPicture().catch(e=>{}),this.isFullscreen()&&this.exitFullscreen().catch(e=>{}),this.element&&(this.element.removeEventListener(kA,this.handleFullscreenChange),this.element.removeEventListener("webkitbeginfullscreen",this.handleFullscreenChange),this.element.removeEventListener("webkitendfullscreen",this.handleFullscreenChange),this.element.removeEventListener("volumechange",this.handleVolumeChange)),super.stop(e),null==(t=this.canvas)||t.remove(),this.removePosterImg(),this._useWrapper&&this._cleanupWrapper()}_cleanupWrapper(){this._wrapper&&0===this._wrapper.children.length&&this._wrapper.remove(),this._wrapper=null}play(e){if(sC(null==e?void 0:e.isLiveStream)||this.setLiveMode(e.isLiveStream),this.element){if(this.elementToRender&&this.container)if(this._useWrapper){let e=this._getOrCreateWrapper();this.elementToRender.parentElement!==e&&e.insertBefore(this.elementToRender,e.firstChild)}else this.elementToRender.parentElement!==this.container&&this.container.append(this.elementToRender)}else this.initializeElement();return 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(Hx.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this._appendToWrapper()))}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(fx()&&this.element&&this._calculateTimeout<0){let e=0,t=null,r=(i,n)=>{this.stat.width=n.width,this.stat.height=n.height,t&&(this.stat.fps=Math.round((n.presentedFrames-t.presentedFrames)/(i-e)*1e3)),e=i,t=n,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(YP){this._log.warn("init stat failed",YP)}}async enterFullscreen(){let e=this.elementToRender;if(!e)throw this._log.warn("no element to render, cannot enter fullscreen"),new Error("No element available for fullscreen");if(TD&&this.isPictureInPicture()){this._log.info("exit pip before entering fullscreen");try{await this.exitPictureInPicture()}catch(Yk){this._log.warn("exit pip failed before fullscreen:",Yk)}}try{if(e.requestFullscreen)await e.requestFullscreen();else if(e.webkitRequestFullscreen)await e.webkitRequestFullscreen();else if(e.webkitEnterFullscreen)await e.webkitEnterFullscreen();else if(e.mozRequestFullScreen)await e.mozRequestFullScreen();else{if(!e.msRequestFullscreen)throw new Error("Fullscreen API not supported");await e.msRequestFullscreen()}this._log.info("entered fullscreen mode")}catch(Yk){throw this._log.error("failed to enter fullscreen:",Yk),Yk}}async exitFullscreen(){try{if(!this.isFullscreen())return;if(document.exitFullscreen)await document.exitFullscreen();else if(document.webkitExitFullscreen)await document.webkitExitFullscreen();else if(document.mozCancelFullScreen)await document.mozCancelFullScreen();else{if(!document.msExitFullscreen)throw new Error("Exit fullscreen API not supported");await document.msExitFullscreen()}this._log.info("exited fullscreen mode")}catch(YP){throw this._log.error("failed to exit fullscreen:",YP),YP}}isFullscreen(){let e=this.elementToRender;return!!e&&(this.element&&this.element.webkitDisplayingFullscreen?!this.isPictureInPicture():(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)===e)}async toggleFullscreen(){this.isFullscreen()?await this.exitFullscreen():await this.enterFullscreen()}async enterPictureInPicture(){this.enterPIPPromise=this._enterPictureInPicture();try{return await this.enterPIPPromise}finally{delete this.enterPIPPromise}}async _enterPictureInPicture(){try{if(!this.element)throw new Error("No video element available for pip");if(this.canvas&&1!==this.mode)throw new Error("pip is not supported for canvas-only mode");let{element:e}=this;if(e.requestPictureInPicture){this._log.info("requestPictureInPicture");let t=await e.requestPictureInPicture();return this.pipWindow=t,this._log.info("entered pip mode"),this.elementToRender===this.canvas&&(this.canvas.remove(),this._appendToWrapper(this.element)),t}if(e.webkitSetPresentationMode)return this._log.info("webkitSetPresentationMode"),await e.webkitSetPresentationMode("picture-in-picture"),this._log.info("entered pip mode (webkit)"),{};throw new Error("pip API not supported")}catch(YP){throw this._log.error("failed to enter pip:",YP.name,YP.message),YP}}async exitPictureInPicture(){var e;try{if(!this.isPictureInPicture())return;if(delete this.pipWindow,document.pictureInPictureElement&&document.exitPictureInPicture)await document.exitPictureInPicture(),this.elementToRender===this.canvas&&(null==(e=this.element)||e.remove(),this._pausedRetryCount=5,this._appendToWrapper(this.canvas)),this._log.info("exited pip mode");else{if(!this.element||!this.element.webkitSetPresentationMode)throw new Error("Exit pip API not supported or not in PiP mode");await this.element.webkitSetPresentationMode("inline"),this._log.info("exited pip mode (webkit)")}}catch(Yk){throw this._log.error("failed to exit pip:",Yk),Yk}}isPictureInPicture(){if(!this.element)return!1;let{element:e}=this;return document.pictureInPictureElement?document.pictureInPictureElement===e:!!e.webkitPresentationMode&&"picture-in-picture"===e.webkitPresentationMode}async togglePictureInPicture(){this.isPictureInPicture()?await this.exitPictureInPicture():await this.enterPictureInPicture()}};"undefined"!=typeof AudioContext?yN=AudioContext:"undefined"!=typeof webkitAudioContext?yN=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(yN=mozAudioContext);var bN,wN=-1,IN=0,TN=-1,SN=!1,kN=0,AN=-1,RN=-1;!function e(){try{if(bN)return;(bN=new yN({sampleRate:48e3})).onstatechange=()=>{eL.info("context state: ".concat(bN.state).concat("running"!==bN.state?" visibilityState: ".concat(document.visibilityState):"")),CN()},clearTimeout(wN)}catch(gk){eL.error("initAudioContext failed: ".concat(gk," typeof AudioContextClass: ").concat(typeof yN)),wN=setTimeout(e,1e3)}}();var CN=()=>{"suspended"===bN.state?(IN=bC(),-1===TN&&(TN=setTimeout(()=>{"suspended"===bN.state&&(SN=!0,ZO.emit("155",{isSuspended:!0}))},1500)),LN(),document.addEventListener("click",CN)):"interrupted"===bN.state?LN():(IN&&(pL.addNumber({key:507800,value:bC()-IN,split:[0,500,1e3,1500,2e3,3e3,4e3,5e3,1e4,3e4],max:6e4}),IN=0),-1!==TN&&(clearTimeout(TN),TN=-1,SN&&(SN=!1,ZO.emit("155",{isSuspended:!1}))),document.removeEventListener("visibilitychange",CN),document.removeEventListener("click",CN))},DN=0,ON=-1;function LN(){return new Promise((e,t)=>{if("running"===bN.state)return e();Date.now()-DN<1e3?(clearTimeout(ON),ON=setTimeout(()=>{DN=Date.now(),bN.resume().then(e,t).finally(()=>{xN()})},1e3)):(clearTimeout(ON),DN=Date.now(),bN.resume().then(e,t).finally(()=>{xN()}))}).catch(e=>{eL.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",CN)})}function xN(){if(!TD||-1!==RN)return;let e=()=>{bC()-kN<500||(bN&&"running"===bN.state&&bN.currentTime===AN&&(eL.warn("context is fake running, auto resume"),bN.suspend().catch(e=>{eL.warn("context suspend failed: ".concat(e))})),AN=bN.currentTime,kN=bC())};RN=setInterval(()=>{e()},2e3),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&e()})}document.addEventListener("click",CN);var NN=e=>bN,PN=class{constructor(e){this.name=e,Mk(this,"node"),Mk(this,"node2"),Mk(this,"pre",new Set),Mk(this,"next",new Set),Mk(this,"context"),Mk(this,"connectedNodes",new Set),Mk(this,"nextInputChannelMap",new Map),Mk(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(Yk){eL.error(Yk)}}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(),pL.addSuccessEvent({key:502701})}catch(i){eL.error(i),pL.addFailedEvent({key:502701,error:i})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),pL.addSuccessEvent({key:502702})}catch(YP){eL.error(YP),pL.addFailedEvent({key:502702,error:YP})}}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}},MN=class extends PN{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,Mk(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 n=0;n<e.length;n++)r=e[n]/128*100/2,i+="L".concat(t,",").concat(r),t+=1;return i}},UN=class{constructor(){Mk(this,"source",new PN),Mk(this,"gain",new PN),Mk(this,"destination",new PN)}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(NN().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){let t=function(t){try{let e=BN.get(t);if(e)return e;let r=NN();if(t instanceof HTMLAudioElement)e=r.createMediaElementSource(t);else{if(!(t instanceof MediaStreamTrack))return t;e=r.createMediaStreamSource(new MediaStream([t]))}return BN.set(t,e),e}catch(e){if(!(RD&&e instanceof Error&&"NotSupportedError"===e.name))throw e;eL.warn(e)}}(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}},BN=new WeakMap;var FN=class e{constructor(e){Mk(this,"_volume",0),Mk(this,"_volumeDb",0),Mk(this,"_log"),Mk(this,"_scriptProcessorNode",null),Mk(this,"_audioWorkletNode",null),Mk(this,"_interval",200);let{log:t}=e;this._log=t,ZO.on(JO.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(sO&&CO<=22)return this._log.warn("use script processor to avoid memory leak in electron22-"),this.initScriptProcessor();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);',r=URL.createObjectURL(new Blob([t],{type:"application/javascript"}));e.workletReady=async function(e,t){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{await e.audioWorklet.addModule(t),eL.info("worklet addModule success")}catch(r){throw eL.info("worklet addModule catch error. ".concat(r.message)),r}}(e.audioContext,r).finally(()=>{URL.revokeObjectURL(r)})}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(t){this._log.error("volumeMeter init audio worklet error: ".concat(t)),Kx.logFailedEvent({userId:this._log.userId,eventType:CA,error:t}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{let t=NN();this._scriptProcessorNode=t.createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let r=t.inputBuffer.getChannelData(0),i=0,n=0;for(let e=0;e<r.length;++e)i=Math.max(Math.abs(r[e]),i),n+=r[e]*r[e];this._volume=i;let a=n/r.length;this._volumeDb=Math.max(10*Math.log10(a)+100,0)/100},this._scriptProcessorNode.connect(t.destination)}catch(t){this._log.error("volumeMeter init script processor error: ".concat(t))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null,this._scriptProcessorNode.disconnect()),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null,this._audioWorkletNode.port.close(),this._audioWorkletNode.disconnect()),this._audioWorkletNode=null,this._scriptProcessorNode=null,ZO.off(JO.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})}};Mk(FN,"lastMessageTime",0),Mk(FN,"audioContext",NN()),Mk(FN,"workletReady");var VN=FN,WN=class extends PN{constructor(e){super(),Mk(this,"_volumeMeter"),this._volumeMeter=new VN(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}async init(){await 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()}}},HN=Nk(Bk(),1),jN=e=>t=>t.deviceId===e,zN=class{constructor(e,t){Mk(this,"kind"),Mk(this,"type"),Mk(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&&KN(this.devices[0])||t&&(r.forEach(e=>{if(e.deviceId&&!this.devices.find(jN(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Added");eL.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}}),this.devices.forEach(e=>{if(e.deviceId&&!r.find(jN(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Removed");eL.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices=r}hasDevice(e){return!!this.devices.find(t=>t.deviceId===e)}},GN=class extends HN.EventEmitter{constructor(){super(),Mk(this,"audioInputs",new zN(lA,"Input")),Mk(this,"videoInputs",new zN(dA,"Input")),Mk(this,"audioOutputs",new zN(lA,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",()=>this.update()),"ondevicechange"in navigator.mediaDevices||Wx.run("interval",()=>{this.update()},{delay:1e4}))}init(){YN().then(e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)})}async update(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=await YN(e);return this.audioInputs.update(t,this),this.videoInputs.update(t,this),this.audioOutputs.update(t,this),this}hasBlueTooth(){var e;if(1e3*(null==(e=NN())?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)))}},qN=$k||Qk?null:new GN;function KN(e){return e.deviceId===e.groupId&&""===e.groupId}async function YN(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(bL()||!yL())return[];let t=await navigator.mediaDevices.enumerateDevices();if(0!==e){let i={audio:!1,video:!1};if(t.forEach(e=>{KN(e)&&(e.kind===wA?i.audio=!0:e.kind===IA&&(i.video=!0))}),2===e&&(i.audio=!1),1===e&&(i.video=!1),i.audio||i.video){let e;try{e=await navigator.mediaDevices.getUserMedia(i),i.audio&&LN()}catch(r){eL.debug("capture before getDevices failed: ",r)}t=await 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&&$N.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(r.getCapabilities=()=>e.getCapabilities()),r})}function XN(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return qN.update(e?1:0).then(e=>e.audioInputs.devices)}function ZN(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return qN.update(e?2:0).then(e=>e.videoInputs.devices)}var JN=!1;async function QN(){try{JN||(JN=!0,eL.info("speakers:".concat((await async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(TD||DO)&&(e=!1),qN.update(e?1:0).then(e=>e.audioOutputs.devices)}()).map(e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label)))))}catch(gk){}}var $N=new Set;async function eP(e){let{newDeviceId:t,oldDeviceId:r,oldGroupId:i,oldLabel:n,kind:a}=e;return t===r&&(a!==lA||t!==OA||await async function(e,t){let r=(await XN()).find(e=>e.deviceId===OA);return!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t}(i,n))}var tP,rP=class extends UN{constructor(e){super(),this.log=e,Mk(this,"volumeMeter"),Mk(this,"volumeMeterAfter3A"),Mk(this,"volumeDestination"),Mk(this,"analyser",new MN),this.volumeMeter=new WN({log:this.log}),this.volumeMeterAfter3A=new WN({log:this.log}),this.volumeDestination=new PN,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},iP=class extends Xx{constructor(e){super(e,lA),Mk(this,"_outputDeviceId"),Mk(this,"_floatVolume",1),Mk(this,"_destination"),Mk(this,"pipeline"),Mk(this,"volumeMeterMode","worklet"),Mk(this,"enableVolumeControlInIOS"),this.enableVolumeControlInIOS=e.enableVolumeControlInIOS,this.mode=0,e.url&&(this.url=e.url),this.pipeline=new rP(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"===NO||"15.3"===NO||"15.4"===NO)&&this.muted)return void this._log.info("audioElement is muted.");let t=tP||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,this.setVolume(lC(e)?e/100:this._floatVolume),t===tP&&(tP=void 0),this.options.enableTimeupdateEvent&&(this.element.ontimeupdate=()=>this.emit(Hx.TIME_UPDATE,this.currentTime)),this.bindElementEvents(),this._log.info("initializeElement")}async play(e){if(this.track||this.url){try{!this.pipeline.source.node&&this.track&&this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==e?void 0:e.volume),this._outputDeviceId&&await this.setSinkId(this._outputDeviceId),"worklet"===this.volumeMeterMode?(this.pipeline.volumeMeter.init(),this.pipeline.volumeMeterAfter3A.init()):"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(NN().createAnalyser()),QN()}catch(Yk){throw this._log.warn("audio play error: ".concat(Yk)),PO(NO,"18.7",!0)&&this.bindAutoPlayEvent(),Yk}return super.play()}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setVolume(e){this._floatVolume=e,this.element&&(this.element.volume=e)}async setSinkId(e){var t,r;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&await(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()}},nP=class extends iP{constructor(e){super(e),Mk(this,"_sourceElement"),Mk(this,"_output",new PN),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(NN().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(Hx.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){var t;let r=e<=1&&!SD();if(this._floatVolume!==e||!(r&&(null==(t=this.element)?void 0:t.volume)===e||!r&&this.pipeline.volume===e))if(this._floatVolume=e,this.useDestination)this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e));else if(r)this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element");else{if(SD()){if(!this.enableVolumeControlInIOS)return;xN()}if(RD&&!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._destination||(this._destination=NN().createMediaStreamDestination()),this.pipeline.destination.setNode(this._destination),qx(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play().catch(e=>{this.emit(Hx.AUTOPLAY_FAILED,e)}))}}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&OO&&(tP=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},aP=class extends Px{constructor(e){let{userId:t,sdkAppId:r,mediaType:i,room:n,PlayerClass:a=(1===i?nP:EN)}=e;var o;super(),Mk(this,"id",tL()),Mk(this,"userId",""),Mk(this,"isRemote"),Mk(this,"mediaType"),Mk(this,"room"),Mk(this,"user"),Mk(this,"_log"),Mk(this,"_inputTrack"),Mk(this,"_outputTrack"),Mk(this,"isPlayCalled"),Mk(this,"container",null),Mk(this,"player"),Mk(this,"subVideoPlayerMap"),Mk(this,"muted",!1),Mk(this,"abortCtrl"),Mk(this,"objectFit","cover"),Mk(this,"mirror"),Mk(this,"rotation"),Mk(this,"isScreen",!1),Mk(this,"manager"),Mk(this,"trackSettings"),Mk(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=i,this._log=eL.createLogger({parent:null==n?void 0:n.getLogger(),id:"".concat(this.kind[0],"t"),userId:null==(o=n||this.room)?void 0:o.userId,remoteUserId:this instanceof $P?void 0:this.userId,sdkAppId:r,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof $P}),this.player=new a({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log,enableVolumeControlInIOS:null==n?void 0:n.enableVolumeControlInIOS}),this.player.on(Hx.PLAYER_STATE_CHANGED,e=>{if(ZO.emit(JO.PLAYER_STATE_CHANGED,Ck({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&&pN()&&vN&&vN.deleteDialog()}}),this.kind===dA&&(this.player.on(Hx.LOADED_DATA,()=>{this.emitFirstVideoFrameEvent(Hx.LOADED_DATA),ZO.emit(JO.VIDEO_LOADED_DATA,{track:this})}),this.player.on(Hx.LOADED_META_DATA,()=>{this.emitFirstVideoFrameEvent(Hx.LOADED_META_DATA)}),this.player.on(Hx.MEDIA_TRACK_CHANGED,e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach(t=>t.setTrack(e))}),this.player.on(Hx.RESIZE,e=>{this.emitFirstVideoFrameEvent(Hx.RESIZE),this.emit("video-size-changed",Ck({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(Hx.ERROR,this.onPlayerError.bind(this)),this.player.on(Hx.AUTOPLAY_FAILED,this.handleAutoPlayFailed,this)}get log(){return this._log||eL}get kind(){return 1===this.mediaType?lA:dA}get isAudio(){return this.kind===lA}get strMediaType(){return 4===this.mediaType?dA:2===this.mediaType?uA:lA}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}async play(e,t){let r=hC(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!sC(t.muted)&&this.setPlayerMute(t.muted),t&&!sC(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof EN&&(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(hC(e)&&e.length>=1&&this.container&&e.includes(this.container)&&this.container.contains(this.player.elementToRender)?(e.splice(e.indexOf(this.container),1),e.unshift(this.container)):(this.container=r,this.player.setContainer(r))),hC(e)&&e.length>=1&&await this.playSubContainer(e.slice(1),t)));if(t&&!sC(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===dA)&&this.setPlayerMute(!0),t&&!sC(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof EN&&(sC(null==t?void 0:t.isLiveStream)||this.player.setLiveMode(t.isLiveStream),this.player.setObjectFit(this.objectFit),t&&!sC(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof EN&&this.player.setContainer(r)),ZO.emit(JO.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),await this.player.play(t),hC(e)&&e.length>1&&await this.playSubContainer(e.slice(1),t)}catch(i){throw this.handleAutoPlayFailed(i),i}}else this.log.info("play has not mediaTrack, abort")}setMirror(e,t){if(this.isScreen||this.kind!==dA||sC(e)||e===this.mirror)return;this.mirror=e;let r=this.player;t&&(r=t);let i=this.manager;if(dC(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)}}async playSubContainer(e,t){if(!this._outputTrack||this.kind===lA)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,n]of e.entries()){let e=this.subVideoPlayerMap.get(n);e?t&&(sC(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(n,new EN({id:this.userId||this.id,track:this.playerMediaTrack,container:n,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let r=[...this.subVideoPlayerMap.values()];for(let i of r)i.setViewMirror(this.player.mirror),await i.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(uD(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach(e=>{e.stop()}),this.container=null)}async resume(){var e;this.isPlayCalled&&await(null==(e=this.player)?void 0:e.resume())}close(){this._toInitState(),this.log.info("close"),this.isPlayCalled&&this.stop(!0)}_toInitState(){}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),ZO.emit(e?JO.TRACK_MUTED:JO.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){Gx(e,e).add(pA,this.onTrackMuted).add(fA,this.onTrackUnmuted).add(mA,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===mA&&this.onTrackEnded()}uninstallTrackEvent(e){qx(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){var t,r;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){if(uD(this)&&this.isAudio&&null!=(t=this.user)&&t.muteState.hasAudio&&null!=(r=this.user)&&r.muteState.audioMuted)return;return this.player.stop(uD(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))}async handleAutoPlayFailed(e){var t;this.log.warn("handleAutoPlayFailed",e);let r=()=>{this.resume().then(()=>{document.removeEventListener("click",r,!0)})};if(this.room&&this.room.enableAutoPlayDialog){if((HD||GD)&&(await HC(100),null!=(t=this.player)&&t.isPlaying))return;vN||(vN=new _N)}else document.addEventListener("click",r,!0);ZO.once(JO.LOCAL_TRACK_CAPTURE_SUCCESS,e=>{let{track:t}=e;"audio"===t.kind&&pN()&&!this.player.isPlaying&&this.isRemote&&this.isAvailable&&r()}),this.emit("error",e)}getVideoFrame(){return this.player instanceof EN?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,r,i;if(this.isFirstVideoFrameEmitted)return;let n=null==(t=this.mediaTrack)?void 0:t.getSettings(),a=(null==n?void 0:n.width)||(null==(r=this.player.element)?void 0:r.videoWidth)||0,o=(null==n?void 0:n.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;e===Hx.RESIZE&&!a&&!o||e===Hx.LOADED_META_DATA&&!a&&!o||(e===Hx.LOADED_DATA&&!a&&!o&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,KC(this.rotation)&&([a,o]=[o,a]),this.emit("first-video-frame",{width:a,height:o,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"))}};Pk([Lx([],Px.INIT,{sync:!0})],aP.prototype,"_toInitState",1);var oP=Object.prototype.hasOwnProperty;var sP=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(rC(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(oP.call(e,t))return!1;return!0}return!1},cP=pD({retryFunction:async function(e){let t=function(e){return{audio:dP(e),video:uP(e)}}(e);eL.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],i=[],n=["label","deviceId","groupId"];if(t.audio&&(r=await XN(),eL.info("microphones: ".concat(PC(r.map(e=>Dk(Ck({},e),{groupId:e.groupId.substring(0,8)})),{keysToInclude:n})))),t.video&&(i=await ZN(),eL.info("cameras: ".concat(PC(i,{keysToInclude:n}))),!dC(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,eL.info("exclude infrared camera: ".concat(JSON.stringify(t))))}try{let r=await navigator.mediaDevices.getUserMedia(t);return ex&&r.getTracks().forEach(t=>{var r;let i=t.getCapabilities();eL.info("".concat(t.kind," capabilities: ").concat(PC(i,{keysToInclude:xA}))),!sC(e.echoCancellation)&&-1===(null==(r=i.echoCancellation)?void 0:r.indexOf(e.echoCancellation))&&eL.warn("Invalid argument for 'echoCancellation'. Expected one of [".concat(JSON.stringify(i.echoCancellation),"], but received '").concat(e.echoCancellation,"'"))}),t.audio&&LN(),r}catch(a){let{message:t}=a;throw"NotFoundError"===a.name&&(e.video&&i&&0===i.length&&(t=sL({key:iL.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(t=sL({key:iL.MICROPHONE_NOT_FOUND}))),new pR({code:uR.INITIALIZE_FAILED,name:a.name,message:t,constraint:a.constraint})}},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:r,reject:i,retryFuncArgs:n,retriedCount:a}=e,o=a+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name||"AbortError"===t.name?(1===o?(n[0].video&&(n[0].maxResolution=!1,(!DO||n[0].width*n[0].height<=2073600)&&n[0].frameRate&&(n[0].frameRate=n[0].frameRate>10?10:5)),n[0].retryWhenExactFailed&&n[0].useExactDeviceId&&(n[0].useExactDeviceId=!1)):2===o?n[0].useDeviceIdOnly=!0:3===o&&!n[0].useExactDeviceId&&(n[0].useTrueAsConstraint=!0),r()):i(t),n[0].microphoneId&&lP(n[0].microphoneId,!1),n[0].cameraId&&lP(n[0].cameraId,!0)},onRetrying:e=>{eL.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{Kx.logFailedEvent({eventType:DA,error:e})},onRetrySuccess:e=>{Kx.logSuccessEvent({eventType:DA}),Kx.uploadEvent({log:"stat-".concat(DA,"-success-").concat(e)})}});async function lP(e,t){let r=(t?await ZN():await XN()).find(t=>t.deviceId===e);r&&oC(r.getCapabilities)&&eL.warn(PC(r.getCapabilities(),{keysToInclude:xA}))}function dP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!sP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(lC(e.channelCount)&&(t.channelCount=e.channelCount),(dC(e.echoCancellation)||"remote-only"===e.echoCancellation||"all"===e.echoCancellation)&&(t.echoCancellation=e.echoCancellation),dC(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),dC(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!sP(t)||t)}function uP(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&&!sP(r)?r:(e.width&&(r.width={ideal:e.width},t&&!RD&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},t&&!RD&&(r.height.max=e.height)),RD&&iO&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!sP(r)||r)}var hP=cP,pP=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&eL.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",()=>{eL.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState}),e=!0)}})(),fP=0,mP=class{constructor(e){Mk(this,"log"),Mk(this,"isRunning",!1),Mk(this,"queue",[]);let t="fq".concat(++fP);e&&(t+="|".concat(e)),this.log=eL.createLogger({id:t})}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 n=Ck({},e),a=new Promise((e,t)=>{n.resolve=e,n.reject=t});return n.promise=a,t?this.length<=1?this.queue.push(n):null==(i=null==(r=this.lastQueueItem)?void 0:r.promise)||i.then(n.resolve,n.reject):this.queue.push(n),this.log.debug("push ".concat(this.length),e.funcName,e.args),this.isRunning||this.callNext(),a}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length),null==e?void 0:e.funcName,null==e?void 0:e.args),e}callNext(){if(this.isRunning||0===this.length)return;let{fn:e,args:t,context:r,resolve:i,reject:n,funcName:a}=this.queue[0];this.log.debug("callNext",this.length,a,t),this.isRunning=!0,e.apply(r,t).then(i,n).finally(()=>{this.isRunning=!1,this.shift(),this.callNext()})}},gP=new WeakMap;function _P(e,t){return Gk((r,i)=>function(){let i=e;try{for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];let e=r.apply(this,a),s=bC();return mC(e)?e.then(e=>(t?pL.addSuccessEvent({key:i,cost:bC()-s}):pL.addSuccessEvent({key:i}),e)).catch(e=>{throw pL.addFailedEvent({key:i,error:e}),e}):(pL.addSuccessEvent({key:i}),e)}catch(Xk){throw pL.addFailedEvent({key:i,error:Xk}),Xk}})}function vP(){}var yP=e=>e();function EP(){this.dispose()}var bP=1,wP=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new DP(e,this,this.streamId++);return OP.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},IP=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=vP,this.error=vP,this.next=vP,this.dispose=vP,this.subscribe=vP,this.doDefer()}subscribe(e){return e instanceof wP?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(yP),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}},TP=class extends IP{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)}},SP=class extends IP{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vP,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vP,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:vP;if(super(),this._next=t,this._error=r,this._complete=i,this.then=vP,e instanceof wP){let n={toString:()=>"subscribe",id:0,source:e};this.defer(()=>{OP.defer(n,0)}),OP.create(n),OP.pipe(n),this.sourceId=n.id,this.subscribe(e),OP.subscribe({id:n.id,end:!0}),t==vP?this._next=e=>OP.next(n,0,e):this.next=e=>{OP.next(n,0,e),t(e)},i==vP?this._complete=()=>OP.complete(n,0):this.complete=()=>{this.dispose(),OP.complete(n,0),i()},r==vP?this._error=e=>OP.complete(n,0,e):this.error=e=>{this.dispose(),OP.complete(n,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 kP(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 AP(e,t,r){if("undefined"!=typeof __FASTRX_DEVTOOLS__){let i=Object.defineProperties(Object.setPrototypeOf(e,wP.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}});OP.create(i);for(let e=0;e<r.length;e++){let t=r[e];"function"==typeof t&&t instanceof wP&&OP.addSource(i,t)}return i}return e}function RP(e,t){return function(){for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return r=>{if(r instanceof wP){let n=AP(t=>{let a=new e(t,...i);a.sourceId=n.id,a.subscribe(r)},t,arguments);return n.source=r,OP.pipe(n),n}return t=>r(new e(t,...i))}}}function CP(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var DP=class extends TP{constructor(e,t,r){super(e),this.source=t,this.id=r,this.sourceId=e.sourceId,this.defer(()=>{OP.defer(this.source,this.id)})}next(e){OP.next(this.source,this.id,e),this.sink.next(e)}complete(){OP.complete(this.source,this.id),this.sink.complete()}error(e){OP.complete(this.source,this.id,e),this.sink.error(e)}},OP={addSource(e,t){CP("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,r){CP("next",{id:e.id,streamId:t,data:r&&r.toString()})},subscribe(e,t){let{id:r,end:i}=e;CP("subscribe",{id:r,end:i,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,r){CP("complete",{id:e.id,streamId:t,err:r?r.toString():null})},defer(e,t){CP("defer",{id:e.id,streamId:t})},pipe(e){CP("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){CP("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=bP++),CP("create",{name:e.toString(),id:e.id})}},LP=class extends IP{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 xP(){return e=>{let t=new LP(e);if(e instanceof wP){let r=AP(e=>{t.add(e)},"share",arguments);return t.sourceId=r.id,r.source=e,OP.pipe(r),r}return AP(t.add.bind(t),"share",arguments)}}function NP(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return AP(e=>{let r=new TP(e),i=t.length;r.complete=()=>{0===--i&&e.complete()},t.forEach(r.bindSubscribe)},"merge",arguments)}function PP(e){let t=arguments,r=xP()(AP(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=vP,r.complete=vP,r.error=vP,r}function MP(e,t){return r=>{let i=e=>r.next(e);r.defer(()=>t(i)),e(i)}}function UP(e,t){if("on"in e&&"off"in e)return AP(MP(r=>e.on(t,r),r=>e.off(t,r)),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return AP(MP(r=>e.addListener(t,r),r=>e.removeListener(t,r)),"fromEvent",arguments);if("addEventListener"in e)return AP(MP(r=>e.addEventListener(t,r),r=>e.removeEventListener(t,r)),"fromEvent",arguments);throw"target is not a EventDispachter"}var BP=RP(class extends TP{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"),FP=RP(class extends TP{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0===--this.count&&(this.doDefer(),this.complete())}},"take"),VP=RP(class extends TP{constructor(e,t){super(e);let r=new TP(e);r.next=()=>{r.doDefer(),e.complete()},r.complete=EP,r.subscribe(t)}},"takeUntil"),WP=RP(class extends TP{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),HP=RP(class extends TP{constructor(e,t,r){super(e),this.mapper=t,this.thisArg=r}next(e){super.next(this.mapper.call(this.thisArg,e))}},"map"),jP=class extends TP{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()}},zP=class e extends TP{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()}},GP=class extends jP{},qP=class extends zP{next(e){this.subInner(e,GP),this.next=e=>{this.currentSink.dispose(),this.subInner(e,GP)}}},KP=RP(qP,"switchMap");var YP,XP=function(e){return(t,r)=>e(()=>t,r)}(RP(qP,"switchMapTo")),ZP=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:vP,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:vP,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:vP;return i=>new SP(i,e,t,r)},JP=RP(class extends TP{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"),QP=((YP=QP||{})[YP.AUTO_SWITCH_NEW_DEVICE=0]="AUTO_SWITCH_NEW_DEVICE",YP[YP.WAIT_CURRENT_DEVICE=1]="WAIT_CURRENT_DEVICE",YP),$P=class extends aP{constructor(e,t,r){super({mediaType:e,PlayerClass:t,room:r}),Mk(this,"isRemote",!1),Mk(this,"deviceId"),Mk(this,"groupId",""),Mk(this,"label",""),Mk(this,"sourceTrack"),Mk(this,"enableAutoSwitchWhenRecapturing",!0),Mk(this,"_isRecapturing",!1),Mk(this,"_lastRecaptureTime",0),Mk(this,"_onMuteTimeoutId",-1),Mk(this,"_encodeCheckTimeoutId",-1),Mk(this,"recaptureMode",0),Mk(this,"profile"),Mk(this,"retryEncodeFailed")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}get isUseCustomSource(){return!(!this.mediaTrack||this.sourceTrack===this.mediaTrack)}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){e.addEventListener(pA,this.onTrackMuted),e.addEventListener(fA,this.onTrackUnmuted),e.addEventListener(mA,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===mA&&this.onTrackEnded()}uninstallTrackEvent(e){e.removeEventListener(pA,this.onTrackMuted),e.removeEventListener(fA,this.onTrackUnmuted),e.removeEventListener(mA,this.onTrackEnded)}setStateToReady(){}async capture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;let n=this.sourceTrack;try{let n,a=bC();ZO.emit(JO.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(n=new MediaStream,n.addTrack(e.customSource)):(t||null==(r=this.sourceTrack)||r.stop(),n=await hP(e));let o=n.getTracks()[0];return await this.setInputMediaStreamTrack(o),e.customSource||(this.sourceTrack=o,this.updateDeviceIdInUse(),this.listenDeviceChange()),ZO.emit(JO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:bC()-a,profile:this.profile,room:null==(i=this.manager)?void 0:i.room}),n}catch(a){throw ZO.emit(JO.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:a}),this.log.error("getUserMedia error observed ".concat(a)),a}finally{t&&(null==n||n.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=AC((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}async publish(e,t){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()),await t,this._checkPublishFlag(e)}_checkPublishFlag(e){return new Promise(async(t,r)=>{var i,n,a,o,s;let c=()=>r(new pR({code:uR.API_CALL_ABORTED,message:"publish aborted"}));if(this.hasFlag||this.muted?t():((this.state===Px.INIT||"ready"===this.state)&&c(),kP(UP(e,"local-publish-flag-changed"),BP(()=>this.hasFlag),VP(NP(UP(this,Px.INIT),UP(this,"ready"))),ZP(t,r,c))),null!=(a=null==(n=null==(i=this.room)?void 0:i.networkQuality)?void 0:n.hadRecentBadUplink)&&a.call(n,2))return t();let l=e.heartbeatCount,d=(null==(s=null==(o=this.mediaTrack)?void 0:o.stats)?void 0:s.totalFrames)||0;this._encodeCheckTimeoutId=setTimeout(async()=>{var i,n,a,o,s,c,u,h;if(null!=(a=null==(n=null==(i=this.room)?void 0:i.networkQuality)?void 0:n.hadRecentBadUplink)&&a.call(n,2)||e.heartbeatCount-l<3)return t();if(this.isPublished||this.isPublishing){let e=this.kind===lA;if(null!=(o=this.mediaTrack)&&o.stats){let e=this.mediaTrack.stats.totalFrames||0;e-d===0&&this.log.warn("capture totalFrames is 0 during encode check, totalFrames",e)}if(!this.isMediaTrackActive)return this.emit("6",this),r(new pR({message:"".concat(this.strMediaType," encode failed, track is not active"),code:e?uR.AUDIO_ENCODE_FAILED:uR.VIDEO_ENCODE_FAILED}));let i=this.stat.bytesSent>0;if(pL[i?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),!e){let e={H264:513704,H265:513705,VP8:513706}[(null==(c=null==(s=this.room)?void 0:s.videoCodec)?void 0:c.toUpperCase())||"H264"];e&&pL[i?"addSuccessEvent":"addFailedEvent"]({key:e})}if(!i){if(pL.addEnum({key:e?503701:513703,value:YO()}),Kx.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(GO()||XO()),userId:this.userId}),this.log.warn(e?"encode failed":"".concat(null==(h=null==(u=this.room)?void 0:u.videoCodec)?void 0:h.toUpperCase()," encode failed")),this.retryEncodeFailed&&(this.log.warn("retry encode"),await this.retryEncodeFailed(this),this.stat.bytesSent>0||this.hasFlag||(await HC(5e3),this.stat.bytesSent>0||this.hasFlag)))return t();this.emit("6",this),r(new pR({message:"".concat(this.strMediaType," encode failed"),code:e?uR.AUDIO_ENCODE_FAILED:uR.VIDEO_ENCODE_FAILED}))}}},1e4)})}unpublish(){this.room&&this.room.localTracks.delete(this),this.log.info("unpublish"),ZO.emit(JO.LOCAL_TRACK_UNPUBLISHED,{track:this})}async updateDeviceIdInUse(){if(this.sourceTrack&&$L){let{deviceId:e,groupId:t}=this.sourceTrack.getSettings(),{label:r}=this.sourceTrack;await eP({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind})||(this.deviceId=e,this.label=r,t&&(this.groupId=t),YN().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===lA&&!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(wA);return!!$N.has(r)}(this.sourceTrack)||this.kind===dA&&!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(IA);return!!$N.has(r)}(this.sourceTrack)||this._isRecapturing||e&&iO&&DO)}onTrackMuted(){if(super.onTrackMuted(),pP(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<LA)return void setTimeout(()=>this.onTrackMuted(),LA);this._onMuteTimeoutId=setTimeout(async()=>{var e;if(null!=(e=this.sourceTrack)&&e.muted){if((TD||kD)&&"visible"!==document.visibilityState)return;this.recapture(await this.getRecoverCaptureDeviceId())}},5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}async onTrackEnded(){if(super.onTrackEnded(),this.isNeedToRecapture()&&0===this.recaptureMode){if(Date.now()-this._lastRecaptureTime<LA)return void setTimeout(()=>this.onTrackEnded(),LA);this.emit("7"),this.recapture(await this.getRecoverCaptureDeviceId())}}async recapture(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];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 n={useExactDeviceId:!0};if("user"===e||"environment"===e)n.facingMode=e;else{let t;("audio"===this.kind?await XN():await ZN()).find(t=>t.deviceId===e)&&(t=e),n.deviceId=t}return this.capture(n,t).then(()=>{var e;this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),ZO.emit(JO.LOCAL_TRACK_RECAPTURE,{track:this}),null!=(e=this.sourceTrack)&&e.muted&&(this.log.warn("track still muted after recapture"),this.onTrackMuted())}).catch(e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),ZO.emit(JO.LOCAL_TRACK_RECAPTURE,{track:this,error:e})}).finally(()=>{t&&(null==i||i.stop())})}async getRecoverCaptureDeviceId(){let e=this instanceof nM;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let r=(eM.get(t)||0)+1;if(eM.set(t,r),r>=3&&this.enableAutoSwitchWhenRecapturing){let i=e?(await ZN()).find(e=>!eM.has(e.deviceId)):(await XN()).find(e=>!eM.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(),ZO.emit(JO.LOCAL_TRACK_STOPPED,{track:this}),this.uninstallTrackEvent(this.sourceTrack)),this._inputTrack&&this.uninstallTrackEvent(this._inputTrack),null==(e=this.manager)||e.removeInput(this),this._onMuteTimeoutId&&clearTimeout(this._onMuteTimeoutId)}close(){super.close(),this.stopCapture()}};Pk([Lx(Px.INIT,"ready",{ignoreError:!0,sync:!0})],$P.prototype,"setStateToReady",1),Pk([function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,r,i){let n=i.value;return i.value=function(){let t=gP.get(this)||new mP;for(var i=arguments.length,a=new Array(i),o=0;o<i;o++)a[o]=arguments[o];return gP.set(this,t),t.push({fn:n,args:a,context:this,funcName:r},e)},i}}()],$P.prototype,"capture",1),Pk([Lx("ready","publish",{ignoreError:!0,success(){ZO.emit(JO.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 pR?e:e.cause instanceof pR?e.cause:e,n=!1;i instanceof pR&&(i.message.includes("timeout")?r="timeout":i.code===uR.API_CALL_ABORTED&&(n=!0,r="api-call")),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:r,error:i}),this.log[n?"info":"error"]("publish failed",i)}}),_P(521714,!1)],$P.prototype,"publish",1),Pk([Gk(e=>async 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)}),Lx([],"ready",{sync:!0})],$P.prototype,"unpublish",1);var eM=new Map;ZO.on(JO.SWITCH_DEVICE_SUCCESS,e=>{e.track.deviceId&&eM.delete(e.track.deviceId)});var tM=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-2,r=[],i=0;for(let a=e;a<=t;a++){let e=this.dataView.getInt8(a);switch(e){case 0:case 1:case 2:case 3:2===i&&(r.push(3),i=0),0===e?i+=1:i=0,r.push(e);break;default:i=0,r.push(e)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=n}removePreventionByte(){let{seiPayloadStartIndex:e}=this,t=this.dataView.byteLength-1,r=[],i=0;for(let a=e;a<=t;a++)switch(this.dataView.getInt8(a)){case 0:i++,r.push(this.dataView.getInt8(a));break;case 3:2!==i&&r.push(this.dataView.getInt8(a)),i=0;break;default:r.push(this.dataView.getInt8(a)),i=0}let n=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=n}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e+=1,255===this.dataView.getUint8(t));t+=1);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 a=6;a<this.dataView.buffer.byteLength;a+=1){let r=this.dataView.getUint8(a);if(t+=1,255!==r){e+=r;break}e+=255}let r=new ArrayBuffer(e),i=new DataView(r),n=t;for(let a=0;a<r.byteLength;a+=1)i.setInt8(a,this.dataView.getInt8(n+a));return i}get naluType(){let e=this.getStartCodeLength();return e>=this.dataView.byteLength?0:31&this.dataView.getUint8(e)}getStartCodeLength(){return this.dataView.byteLength>=4&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&0===this.dataView.getUint8(2)&&1===this.dataView.getUint8(3)?4:this.dataView.byteLength>=3&&0===this.dataView.getUint8(0)&&0===this.dataView.getUint8(1)&&1===this.dataView.getUint8(2)?3:0}get isIDR(){return 5===this.naluType}get isSPS(){return 7===this.naluType}get isPPS(){return 8===this.naluType}get isSEI(){return 6===this.naluType}},rM=class{constructor(){Mk(this,"_seiMessageList",[]),Mk(this,"_smallSeiMessageList",[]),Mk(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,r=parseInt(String(t/255),10),i=t%255,n=[];n.push(0,0,0,1,6,this._seiPayloadType);for(let o=0;o<r;o++)n.push(255);n.push(i);let a=new DataView(e);return n.push(...new Uint8Array(a.buffer)),n.push(128),new tM(new DataView(new Uint8Array(n).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 n=0;n<e.byteLength;n++)switch(i.getUint8(n)){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)),n=i.reduce((e,t)=>e+t.dataView.byteLength,0),a=new ArrayBuffer(n+e.data.byteLength),o=new DataView(a),s=new DataView(e.data),c=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)o.setInt8(c++,i[e].dataView.getInt8(t));for(let r=0;r<e.data.byteLength;r++)o.setInt8(c++,s.getInt8(r));return e.data=a,i.length}return 0}},iM=class e extends $P{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,EN,null==e?void 0:e.room),Mk(this,"profile",Ck({},sA)),Mk(this,"avoidCropping",!1),Mk(this,"_scaleResolutionDownBy"),Mk(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0,framesCaptured:0}),Mk(this,"small"),Mk(this,"isNeedToSetBandwidth"),Mk(this,"muteImage"),Mk(this,"manager"),Mk(this,"_seiCodec",new rM),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=VR((null==(e=this.room)?void 0:e.sdkAppId)||0)?rA:tA;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(t)),this.setProfile(Dk(Ck({},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($L&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e,t;return(null==(e=this._inputTrack)?void 0:e.contentHint)||(null==(t=this.outMediaTrack)?void 0:t.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)}async setMute(e){var t,r,i;if(cC(e)){if(this.muteImage===e)return;await(null==(t=this.manager)?void 0:t.deleteWatermark("mute")),await(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:e,fillVideo:!0})),this.muteImage=e,super.setMute(!1)}else this.muteImage&&(await(null==(i=this.manager)?void 0:i.deleteWatermark("mute")),this.muteImage=void 0),super.setMute(e)}async capture(e){let{deviceId:t,facingMode:r,useExactDeviceId:i=!0,customSource:n,retryWhenExactFailed:a=!0}=e,o={audio:!1,video:!0,facingMode:r||this.facingMode,cameraId:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,useExactDeviceId:i,retryWhenExactFailed:a,customSource:n};if("environment"===o.facingMode){let e=await this.getDeviceIdWhenUsingBackCamera();e&&(o.cameraId=e)}return super.capture(o)}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=VR((null==(t=this.room)?void 0:t.sdkAppId)||0)?rA:tA;this.log.warn("Resolution is reset to 1080p, need to upgrade ability here ".concat(e)),super.setProfile(Dk(Ck({},this.profile),{width:1920,height:1080}))}}async applyProfile(){var e;if(!this.mediaTrack)return;this.log.info("applyProfile",this.profile);let{width:t=0,height:r=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=t*r,n=this.settings,a=n.height!==this.profile.height||n.width!==this.profile.width||n.frameRate!==this.profile.frameRate;if(a&&(16===MO&&this.deviceId?await this.recapture(this.deviceId):(await(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 a&&r&&i&&r===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:dA,videoType:hA})}}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return $L&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:qC(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)}async switchDevice(e){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(),await this.capture(t),ZO.emit(JO.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(Yk){throw this.log.error("switch camera failed ".concat(Yk)),this.deviceId&&this.recapture(this.deviceId),Yk}}async getDeviceIdWhenUsingBackCamera(){let e;try{if(uO&&!EO&&tx){let t=(await ZN(!0)).map(e=>{var t;return Dk(Ck({},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,n,a;let{capabilities:o}=e;(null!=(t=o.width)&&t.max&&null!=(i=o.height)&&i.max?o.width.max*o.height.max:0)>(null!=(n=r.capabilities.width)&&n.max&&null!=(a=r.capabilities.height)&&a.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(Yk){this._log.warn("get max res camera failed",Yk)}return e}async 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),await(null==(t=this.manager)?void 0:t.update()),i&&await(null==(r=this.room)?void 0: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=Ck({},e);return e.width*e.height<=19200&&kD&&IO&&(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&&BO&&(i.width=r?1280:720,i.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),function(e,t){let r=e.split(".").map(e=>Number(e)),i=t.split(".").map(e=>Number(e));for(let n=0;n<Math.max(r.length,i.length);n++){let e=r[n]||0,t=i[n]||0;if(e<t)return!0;if(e>t)return!1}return!1}(NO,"14.3")&&PO(NO,"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&&(IO||RD)&&!(kD||TD||wD||ED||EO)&&e.width*e.height<=230400&&e.width/e.height===16/9&&(this._scaleResolutionDownBy=1280/e.width,i.width=1280,i.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(){qN&&!qN.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&qN.on("videoInputRemoved",this.handleCameraRemoved,this)}async handleCameraRemoved(e){if(e.deviceId===this.deviceId){let t=1===this.recaptureMode;if(this.log.warn("RecaptureMode: ".concat(QP[this.recaptureMode],". Current camera is lost: ").concat(JSON.stringify(e))),0===this.recaptureMode){OM(this.userId,{eventId:2003,param1:7,streamType:2});let e=await ZN();e[0]?this.recapture(e[0].deviceId):t=!0}t&&qN.on("videoInputAdded",this.handleCameraAdded,this)}}async handleCameraAdded(e){1===this.recaptureMode&&e.deviceId!==this.deviceId||(qN.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 sC(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){var e;this.muteImage&&(null==(e=this.manager)||e.deleteWatermark("mute"),this.muteImage=void 0),qN.off("videoInputAdded",this.handleCameraAdded,this),qN.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}async recapture(e){try{await super.recapture(e)}catch(Yk){let r=(await ZN()).find(t=>t.deviceId!==e);if(!r)throw Yk;await super.recapture(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||sC(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}setOutputMediaStreamTrack(t){var r;let i=this._outputTrack;if(!(this instanceof e&&tD(i,this.room||(null==(r=this.manager)?void 0:r.room))))return super.setOutputMediaStreamTrack(t)}};Pk([zk(function(e){this.setContentHint(e.contentHint||"motion")})],iM.prototype,"capture",1);var nM=iM,aM=[-1,-1,1,-1,-1,1,1,1],oM=[0,0,1,0,0,1,1,1],sM=class e extends Px{constructor(e,t){if(super(),this.context=e,Mk(this,"name"),Mk(this,"sourceId",""),Mk(this,"input"),Mk(this,"output"),Mk(this,"texture"),Mk(this,"ctx2d",null),Mk(this,"fbo"),Mk(this,"width",0),Mk(this,"height",0),Mk(this,"x",0),Mk(this,"y",0),Mk(this,"program"),Mk(this,"vertexShader"),Mk(this,"fragmentShader"),Mk(this,"totalFrames",0),Mk(this,"dropFrames",0),Mk(this,"matchInputSize",!0),Mk(this,"texCoordBuffer"),Mk(this,"positionBuffer"),Mk(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),Mk(this,"cost",0),Mk(this,"_canvas",null),Mk(this,"_image"),Mk(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 IM)t.create2d&&("function"==typeof OffscreenCanvas&&16!==MO?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(oM),this.positionBuffer=this.createBuffer(aM),!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(r){this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(r.message||r)}))}}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 bM&&this.render(e)||this.context instanceof IM&&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 bM){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,n,a,o,s,c,l){let d=!(sC(o)||sC(s)||sC(c)||sC(l));return!(!this.ctx2d||!t)&&(t instanceof ImageData?(d?this.ctx2d.putImageData(t,r,i,o,s,c,l):this.ctx2d.putImageData(t,r,i),this.emit(e.RENDER,this.ctx2d.canvas)):(d?this.ctx2d.drawImage(t,o,s,c,l,r,i,n,a):this.ctx2d.drawImage(t,r,i,n,a),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:n,height:a,name:o,cost:s,dropFrames:c}=this,l=Date.now(),d=(t-this.lastInfo.totalFrames)/((l-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:r,y:i,width:n,height:a,timestamp:l,fps:d,name:o,cost:s,dropFrames:c},Ck({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}};Mk(sM,"RENDER","render"),Pk([Lx(Px.INIT,"connected",{sync:!0})],sM.prototype,"connect",1),Pk([Lx("connected",Px.INIT,{ignoreError:!0,sync:!0})],sM.prototype,"disconnect",1),Pk([Lx([],"closed",{sync:!0})],sM.prototype,"close",1);var cM=sM,lM=kP(function(e){return AP(t=>{let r=0,i=setInterval(()=>t.next(r++),e);return t.defer(()=>{clearInterval(i)}),"interval"},"interval",arguments)}(250),HP(()=>performance.now()),xP()),dM=class extends cM{constructor(e,t){super(e,Ck({name:"imageSource"},t)),Mk(this,"_lastImage"),Mk(this,"_totalFrames",0),Mk(this,"_autoResize",!1),Mk(this,"_canvasRendered"),Mk(this,"videoCallbackId",0),Mk(this,"waitingFirstFrame",!0),Mk(this,"shouldUpdate",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===MO&&(this._canvasRendered=PP(),kP(this._canvasRendered,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return e=>AP(function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;i<n&&!r.disposed;)r.next(t[i++]);r.disposed||r.subscribe(e)},"startWith",arguments)}(this._image),KP(e=>e instanceof HTMLCanvasElement?UP(e,"rendered"):function(){return AP(e=>e.complete(),"empty",arguments)}()),VP(UP(this,"closed")),ZP(()=>{this.update()})))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){if(!this.shouldUpdate)return;let e=this.image;this.videoCallbackId&&e.cancelVideoFrameCallback(this.videoCallbackId),fx()&&!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:n}=this,{image:a}=this;if(a instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:n}=a),!i||!n)return!1;a.width=i,a.height=n}else if(a instanceof HTMLImageElement||a instanceof ImageData||a instanceof ImageBitmap){if(({width:i,height:n}=a),a!==this._lastImage)this._lastImage=a;else if(i===this.width&&n===this.height)return!0}else a instanceof HTMLCanvasElement||a instanceof OffscreenCanvas?(({width:i,height:n}=a),this._lastImage=a):"undefined"!=typeof VideoFrame&&a instanceof VideoFrame&&(({displayWidth:i,displayHeight:n}=a),null==(r=this._lastImage)||r.close(),this._lastImage=a);if(!this._autoResize)return!0;if(this.width===i&&this.height===n&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,a)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a)}this.resize(i,n)}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)}},uM=class extends dM{constructor(e,t,r){super(e,r),this._player=t,this.name="videoPlayerSource",kP(UP(this._player,Hx.PLAYER_STATE_CHANGED),VP(UP(this,"closed")),BP(e=>{let{state:t}=e;return"PLAYING"===t}),ZP(()=>{this.tryVideoFrameCallback()}))}get image(){return this._player.element}},hM=class extends uM{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,r){super(e,new EN({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()}},pM=class extends cM{constructor(e,t,r){super(e,Dk(Ck({name:"textSource"},r),{create2d:!0})),Mk(this,"hasChange",!0),Mk(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 n=this.font.match(/(\d+)px/),a=(n?parseInt(n[1],10):16)*r,o=this.content.split("\n");for(let s=0;s<o.length;s++)this.ctx2d.fillText(o[s],e,t+s*a)}},fM=[1,0,0,0,1,1,0,1],mM=class extends cM{constructor(e,t,r,i){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:t}),Mk(this,"mirror",!1),Mk(this,"rotation",0),r&&(this.mirror=r),i&&(this.rotation=i),e instanceof bM)try{this.setTexBuffer(fM)}catch(Xk){e.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(Xk.message||Xk)}))}}draw2d(e,t,r,i,n){if(this.ctx2d){if(this.ctx2d.clearRect(0,0,this.width,this.height),!this.mirror&&0===this.rotation)return super.draw2d(e,t,r,i,n);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(n/i,i/n)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,n),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(n/i,i/n));let a=super.draw2d(e,t,r,i,n);return this.ctx2d.restore(),a}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){KC(this.rotation)&&([e,t]=[t,e]),super.resize(e,t)}},gM=[0,1,1,1,0,0,1,0],_M=class extends cM{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),Mk(this,"_intervalId",0),Mk(this,"_sequence",0),Mk(this,"checkGLError",!1),Mk(this,"_useTimerOnShowSubject",PP()),Mk(this,"_closedOb",UP(this,"closed")),Mk(this,"checkVisibilityChange"),Mk(this,"_workerDriven",!1),Mk(this,"_frameExtractIntervalId",0),Mk(this,"_lastLayoutHash",""),Mk(this,"_needsMainThreadExtraction",!1),Mk(this,"_pendingStartFrameRate",null),Mk(this,"_workerImageSourceIds",new Set),e instanceof IM?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(gM),kP(this._useTimerOnShowSubject,XP(UP(document,"visibilitychange")),VP(this._closedOb),ZP(()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")))}))}start(e){this.context instanceof IM&&this.context.isWorkerMode?this.context.workerReady?(this._pendingStartFrameRate=null,this._startWorkerDriven(e)):(this.log.info("".concat(this.name," start() called but Worker not ready, pending frameRate=").concat(e)),this._pendingStartFrameRate=e,this.context.setOnWorkerReadyCallback(()=>{if(null!==this._pendingStartFrameRate){let e=this._pendingStartFrameRate;this._pendingStartFrameRate=null,this.log.info("".concat(this.name," Worker ready, executing pending start(").concat(e,")")),this.start(e)}})):this._startMainThreadDriven(e)}_startWorkerDriven(e){if(this._workerDriven){let t=this.context;return this.log.info("".concat(this.name," Worker-driven already active, updating fps to ").concat(e)),t.postWorkerMessage({type:"setFps",fps:e}),void this._ensureMainThreadTimer()}this.log.info("".concat(this.name," start Worker-driven render ").concat(e," fps")),Wx.clearTask(this._intervalId),this._intervalId=0,this._workerDriven=!0;let t=this.context;t.postWorkerMessage({type:"start",fps:e}),this._startFrameExtraction(e);let r=this.input;r&&r.inputs&&(this._syncLayoutToWorker(r,t),this._pushAllStaticSourceFrames(),this._resendImageSourcesToWorker(r,t))}_startFrameExtraction(e){this._stopFrameExtraction();let t=this.context,r=this.input;r&&r.inputs&&t.useWorkerRendering&&this._setupWorkerFrameExtraction(r,t),this._ensureMainThreadTimer(),!this._frameExtractIntervalId&&r&&r.inputs&&(this._syncLayoutToWorker(r,t),this.log.info("All sources transferred to Worker, main thread frame extraction timer not needed"))}_setupWorkerFrameExtraction(e,t){let r=!1,i=0;t.setStreamErrorCallback((e,t)=>{this.log.warn("Source ".concat(e," stream error, degrading to main thread extraction: ").concat(t)),this._onSourceDegradedToMainThread()});for(let n of e.inputs){if(n.layout.hidden)continue;let e=n.node.input||n.node,a=n.node.sourceId;if(e instanceof hM){let r=this._getTrackFromSourceNode(e);r&&t.addTrackStream(a,r)&&i++}else e instanceof pM||e instanceof dM&&e.image instanceof HTMLImageElement||(r=!0)}this._needsMainThreadExtraction=r,i>0?this.log.info("Worker frame extraction: ".concat(i," track source(s) transferred, needsMainThreadExtraction=").concat(r)):r||this.log.info("Worker frame extraction: all sources are static (Text/Image) or track-based, no main thread timer needed")}_getTrackFromSourceNode(e){try{let t=e._player;return(null==t?void 0:t.track)||null}catch(Yk){return null}}_onSourceDegradedToMainThread(){this._needsMainThreadExtraction=!0,this._ensureMainThreadTimer(),this.log.info("Source degraded to main thread extraction")}_stopFrameExtraction(){this._frameExtractIntervalId&&(Wx.clearTask(this._frameExtractIntervalId),this._frameExtractIntervalId=0)}addWorkerTrackStream(e,t){if(!(this._workerDriven&&this.context instanceof IM))return;let r=this.context;r.useWorkerRendering&&(r.isStreamTransferred(e)?this.log.info("addWorkerTrackStream(".concat(e,"): already transferred, skipping")):(this.log.debug("addWorkerTrackStream(".concat(e,"): track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState)),r.addTrackStream(e,t)?(this.log.info("Dynamic addWorkerTrackStream(".concat(e,"): transferred to Worker")),this._ensureMainThreadTimer()):this._onSourceDegradedToMainThread()))}removeWorkerTrackStream(e){if(!(this.context instanceof IM))return;let t=this.context;t.isStreamTransferred(e)&&(t.removeTrackStream(e),this.log.info("Dynamic removeWorkerTrackStream(".concat(e,"): pipeline removed")))}replaceWorkerTrackStream(e,t){if(!(this.context instanceof IM))return;let r=this.context;r.isStreamTransferred(e)?(this.log.debug("replaceWorkerTrackStream(".concat(e,"): replacing with newTrack.id=").concat(t.id,", newTrack.label=").concat(t.label,", newTrack.readyState=").concat(t.readyState)),r.replaceTrackStream(e,t)?this.log.info("replaceWorkerTrackStream(".concat(e,"): stream replaced successfully")):(this.log.warn("replaceWorkerTrackStream(".concat(e,"): new stream transfer failed, degrading")),this._onSourceDegradedToMainThread())):this.log.debug("replaceWorkerTrackStream(".concat(e,"): not transferred, skipping"))}syncLayoutToWorker(){if(!(this.context instanceof IM&&this.context.isWorkerMode))return;let e=this.input;!e||!e.inputs||this._syncLayoutToWorker(e,this.context)}ensureMainThreadExtraction(){if(!(this._workerDriven&&this.context instanceof IM))return;let e=this.context,t=this.input;if(!t||!t.inputs)return;let r=!1;for(let i of t.inputs){if(i.layout.hidden)continue;let t=i.node.input||i.node,n=i.node.sourceId;t instanceof hM?e.isStreamTransferred(n)||(r=!0):t instanceof pM||t instanceof dM&&t.image instanceof HTMLImageElement||(r=!0)}this._needsMainThreadExtraction=r,this._ensureMainThreadTimer()}_pushAllStaticSourceFrames(){if(!(this._workerDriven&&this.context instanceof IM))return;let e=this.context;if(!e.workerReady)return;let t=this.input;if(!t||!t.inputs)return;let r=0;for(let i of t.inputs){if(i.layout.hidden)continue;let t=i.node.input||i.node,n=i.node.sourceId,a=t instanceof pM,o=t instanceof dM&&t.image instanceof HTMLImageElement;(a||o&&!e.isWorkerMode)&&(this.pushStaticSourceFrame(n,t),r++)}r>0&&this.log.info("_pushAllStaticSourceFrames: pushed ".concat(r," static source frame(s) after Worker ready"))}_resendImageSourcesToWorker(e,t){if(!t.isWorkerMode||!t.workerReady)return;let r=0,i=0;for(let n of e.inputs){if(n.layout.hidden)continue;let e=n.node.input||n.node;if(!(e instanceof dM&&e.image instanceof HTMLImageElement))continue;let a=n.node.sourceId,o=e.image.src;if(!o)continue;if(this._workerImageSourceIds.has(a)){i++;continue}let{animated:s,mimeType:c}=rD(o);t.postWorkerMessage({type:"addImageSource",id:a,src:o,animated:s,mimeType:c}),this._workerImageSourceIds.add(a),r++}(r>0||i>0)&&this.log.info("_resendImageSourcesToWorker: re-sent ".concat(r,", skipped ").concat(i," (already tracked) ImageSource(s)"))}pushStaticSourceFrame(e,t){if(!(this._workerDriven&&this.context instanceof IM))return;let r=this.context;if(!r.workerReady)return;try{t.requestFrame(0)}catch(o){}let{image:i}=t;if(!i)return;let n=0,a=0;try{if(i instanceof HTMLImageElement){if(!i.complete||!i.naturalWidth||!i.naturalHeight)return;n=i.naturalWidth,a=i.naturalHeight}else{if(!(i instanceof HTMLCanvasElement||i instanceof OffscreenCanvas))return;({width:n,height:a}=i)}if(!n||!a)return;createImageBitmap(i).then(t=>{r.workerReady?r.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:t,width:n,height:a}]},[t]):t.close()}).catch(t=>{this.log.warn("pushStaticSourceFrame failed for source ".concat(e,": ").concat(t.message||t))})}catch(o){}}_ensureMainThreadTimer(){if(!(this._workerDriven&&this.context instanceof IM))return;let e=this.context;if(this._needsMainThreadExtraction&&!this._frameExtractIntervalId){let t=this.input;if(!t||!t.inputs||0===t.inputs.length)return void this.log.info("_ensureMainThreadTimer: no sources connected, deferring timer");this._frameExtractIntervalId=Wx.run("intervalInWorker",()=>{let t=this.input;!t||!t.inputs||(this._syncLayoutToWorker(t,e),this._extractAndSendFrames(t,e))},{fps:this.context.frameRate}),this.log.info("_ensureMainThreadTimer: started timer fps=".concat(this.context.frameRate," (needsMainThreadExtraction=").concat(this._needsMainThreadExtraction,")"))}else!this._needsMainThreadExtraction&&this._frameExtractIntervalId&&(Wx.clearTask(this._frameExtractIntervalId),this._frameExtractIntervalId=0,this.log.info("_ensureMainThreadTimer: stopped timer, no dynamic sources need main thread extraction"))}_syncLayoutToWorker(e,t){if(!t.workerReady)return;let r=e.inputs.map(e=>{var t,r,i,n;return{id:e.node.sourceId,x:null!=(t=e.layout.x)?t:e.node.x,y:null!=(r=e.layout.y)?r:e.node.y,width:null!=(i=e.layout.width)?i:e.node.width,height:null!=(n=e.layout.height)?n:e.node.height,zIndex:e.layout.zIndex,fillMode:e.layout.fillMode,rotation:e.layout.rotation,mirror:e.node instanceof mM&&e.node.mirror,hidden:!!e.layout.hidden}}),i=JSON.stringify(r);i!==this._lastLayoutHash&&(this._lastLayoutHash=i,t.postWorkerMessage({type:"updateLayout",layouts:r}))}_extractAndSendFrames(e,t){if(!t.workerReady)return;let r=[],i=[];for(let a of e.inputs){if(a.layout.hidden)continue;let e=a.node.sourceId;if(t.isStreamTransferred(e))continue;let o=a.node.input||a.node;if(o instanceof pM||o instanceof dM&&o.image instanceof HTMLImageElement)continue;try{o.requestFrame(0)}catch(n){}let{image:s}=o;if(s)try{let n=null,a=0,o=0;if(s instanceof HTMLVideoElement){if(({videoWidth:a,videoHeight:o}=s),!a||!o||s.readyState<2)continue;if("undefined"!=typeof VideoFrame)n=new VideoFrame(s,{timestamp:0});else if("undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (video): ").concat(t.message||t))});continue}}else if(s instanceof HTMLCanvasElement||s instanceof OffscreenCanvas){if(({width:a,height:o}=s),!a||!o)continue;if("undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (canvas): ").concat(t.message||t))});continue}}else if(s instanceof HTMLImageElement){if(!s.complete||!s.naturalWidth||!s.naturalHeight)continue;if(a=s.naturalWidth,o=s.naturalHeight,"undefined"!=typeof createImageBitmap){createImageBitmap(s).then(r=>{t.workerReady?t.postWorkerMessage({type:"updateFrames",frames:[{id:e,frame:r,width:a,height:o}]},[r]):r.close()}).catch(t=>{this.log.warn("createImageBitmap failed for source ".concat(e," (image): ").concat(t.message||t))});continue}}n&&a&&o&&(r.push({id:e,frame:n,width:a,height:o}),i.push(n))}catch(n){continue}}if(r.length>0){if(!t.workerReady){for(let e of r)"close"in e.frame&&"function"==typeof e.frame.close&&e.frame.close();return}t.postWorkerMessage({type:"updateFrames",frames:r},i)}}_startMainThreadDriven(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),this._workerDriven=!1,Wx.clearTask(this._intervalId),this._intervalId=Wx.run("intervalInWorker",()=>{if(e!==this.context.frameRate&&(Wx.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof bM){let e=this.context.ctx.getError();e&&this.context.destroy(new pR({code:uR.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(cM.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&&(Wx.clearTask(this._intervalId),this._intervalId=0,1===e&&(this.log.info("".concat(this.name," use requestVideoFrameCallback")),this._useTimerOnShowSubject.next())),this.requestFrame(this._sequence++))}removeInput(e){super.removeInput(e),Wx.clearTask(this._intervalId),this._cleanupWorkerDrivenState()}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}get isWorkerDriven(){return this._workerDriven}trackWorkerImageSource(e){this._workerImageSourceIds.add(e)}untrackWorkerImageSource(e){this._workerImageSourceIds.delete(e)}close(){super.close(),Wx.clearTask(this._intervalId),this._cleanupWorkerDrivenState(),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}_cleanupWorkerDrivenState(){this._pendingStartFrameRate=null,this.context instanceof IM&&this.context.setOnWorkerReadyCallback(null),this._workerDriven&&this.context instanceof IM&&(this._stopFrameExtraction(),this._cleanupAllWorkerStreams(),this.context.postWorkerMessage({type:"stop"}),this._workerDriven=!1,this._workerImageSourceIds.clear())}_cleanupAllWorkerStreams(){if(!(this.context instanceof IM))return;let e=this.context;for(let t of e.transferredStreams)e.removeTrackStream(t);this._needsMainThreadExtraction=!1,e.setStreamErrorCallback(null)}},vM=class extends _M{constructor(e,t){super(e,t),Mk(this,"_videoTrack"),Mk(this,"_muteOb"),Mk(this,"_subscription"),Mk(this,"_canvasContainer"),Mk(this,"_useTrackGenerator",!1),Mk(this,"_trackGeneratorDegradedHandler",null),Number(LO)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),e instanceof IM&&e.useTrackGenerator?(this._useTrackGenerator=!0,this._videoTrack=e.generatorTrack,this.log.info("VideoTrackDestination using TrackGenerator track, id=".concat(this._videoTrack.id,", readyState=").concat(this._videoTrack.readyState)),this._trackGeneratorDegradedHandler=()=>{this._handleTrackGeneratorDegradation()},e.on("trackGeneratorDegraded",this._trackGeneratorDegradedHandler)):([this._videoTrack]=e.canvas.captureStream().getVideoTracks(),this.log.info("VideoTrackDestination using captureStream track, id=".concat(this._videoTrack.id,", readyState=").concat(this._videoTrack.readyState))),this._muteOb=UP(this._videoTrack,"mute"),kP(UP(this._videoTrack,"ended"),VP(this._closedOb),ZP(()=>{this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))}))}_handleTrackGeneratorDegradation(){if(!this._useTrackGenerator)return;this.log.warn("VideoTrackDestination: Worker mode degraded, switching to main thread captureStream"),this._useTrackGenerator=!1,this._trackGeneratorDegradedHandler&&this.context instanceof IM&&(this.context.off("trackGeneratorDegraded",this._trackGeneratorDegradedHandler),this._trackGeneratorDegradedHandler=null),this._stopFrameExtraction(),this._cleanupAllWorkerStreams(),this._workerDriven=!1;let[e]=this.context.canvas.captureStream().getVideoTracks();e?(this._videoTrack,this._videoTrack=e,this.log.info("VideoTrackDestination degraded to main thread captureStream track, id=".concat(e.id,", readyState=").concat(e.readyState)),this._muteOb=UP(this._videoTrack,"mute"),kP(UP(this._videoTrack,"ended"),VP(this._closedOb),ZP(()=>{this.context.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})),this._startMainThreadDriven(this.context.frameRate),this.emit("trackChanged",e)):this.log.error("VideoTrackDestination: Failed to get captureStream track during degradation")}enableCheckMute(){this._subscription=kP(this._muteOb,VP(this._closedOb),XP((e=>t=>{let r=performance.now();kP(lM,WP(t=>t-r<e),FP(1))(t)})(5e3)),BP(()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)}),ZP(()=>{this.context.destroy(new pR({code:uR.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;this._trackGeneratorDegradedHandler&&this.context instanceof IM&&(this.context.off("trackGeneratorDegraded",this._trackGeneratorDegradedHandler),this._trackGeneratorDegradedHandler=null),super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},yM=class extends Px{constructor(e){super(),Mk(this,"frameRate"),Mk(this,"_canvas"),Mk(this,"log"),Mk(this,"hasAlpha",!1),Mk(this,"name"),Mk(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 hM(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new vM(this,e)}createVideoImageSource(e,t){return new dM(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new uM(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}createTextSource(e,t){return new pM(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};Mk(yM,"_ids",0);var EM=class extends yM{constructor(){super(...arguments),Mk(this,"defaultProgam"),Mk(this,"defaultVShader"),Mk(this,"defaultFShader"),Mk(this,"ctx"),Mk(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(yM._ids++)),e&&(this._canvas2d=document.createElement("canvas")),this.ctx=this._canvas.getContext("webgl2",NA),!this.ctx)throw new pR({code:uR.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 pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))})}destroy(e){let t="";return e&&(t=e.message,this.error=e,pL.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}};Mk(EM,"UNAVAILABLE","unavailable"),Pk([Lx(Px.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),pL.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),pL.addSuccessEvent({key:512700})}})],EM.prototype,"create",1),Pk([Lx("created",Px.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(EM.UNAVAILABLE,e),this.removeAllListeners()}})],EM.prototype,"destroy",1);var bM=EM,wM=class e extends yM{constructor(){super(...arguments),Mk(this,"ctx"),Mk(this,"_useWorkerRendering",!1),Mk(this,"_renderWorker",null),Mk(this,"_workerReady",!1),Mk(this,"_workerFailed",!1),Mk(this,"_useTrackGenerator",!1),Mk(this,"_generatorTrack",null),Mk(this,"_contextLostHandler",null),Mk(this,"_contextRestoredHandler",null),Mk(this,"_transferredStreams",new Set),Mk(this,"_degradedStreams",new Set),Mk(this,"_trackProcessors",new Map),Mk(this,"_streamErrorCallback",null),Mk(this,"_pendingBackground",null),Mk(this,"_pendingBackgroundImage",null),Mk(this,"_pendingSize",null),Mk(this,"_pendingImageSourceMessages",new Map),Mk(this,"_onWorkerReadyCallback",null)}get useWorkerRendering(){return this._useWorkerRendering&&this._workerReady}get useTrackGenerator(){return this._useTrackGenerator}get generatorTrack(){return this._generatorTrack}get isWorkerMode(){return this._useWorkerRendering}get workerReady(){return this._workerReady}get renderWorker(){return this._renderWorker}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(yM._ids++),e.workerScript&&Sx())try{return this._initWorkerMode(e.workerScript),void this.log.info("Worker rendering mode initialized")}catch(Yk){this.log.warn("Worker rendering mode init failed, falling back to main thread: ".concat(Yk.message)),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(yM._ids++)}this._initMainThreadMode(e)}_initWorkerMode(e){let t=new OffscreenCanvas(this._canvas.width||640,this._canvas.height||480);this._renderWorker=this._createRenderWorker(e),this._useWorkerRendering=!0;let r={type:"init",canvas:t,width:this._canvas.width||640,height:this._canvas.height||480},i=[t],n=new MediaStreamTrackGenerator({kind:"video"});this._generatorTrack=n,this._useTrackGenerator=!0;let a=n.writable;r.writable=a,i.push(a),this.log.info("TrackGenerator created, track id=".concat(n.id,", readyState=").concat(n.readyState)),this.log.info("Sending writable to Worker"),this._renderWorker.postMessage(r,i),this._renderWorker.onmessage=e=>{let{data:t}=e;switch(t.type){case"ready":if(this._workerReady=!0,this.log.info("Render Worker ready"),this._flushPendingState(),this._onWorkerReadyCallback){let e=this._onWorkerReadyCallback;this._onWorkerReadyCallback=null,e()}break;case"trackGeneratorFailed":this.log.warn("Worker reported TrackGenerator failure, failCount=".concat(t.failCount)),this._handleTrackGeneratorDegradation();break;case"error":this.log.error("Render Worker error: ".concat(t.message));break;case"streamError":this.log.warn("Worker stream error for source ".concat(t.id,": ").concat(t.message)),this._transferredStreams.delete(t.id),this._streamErrorCallback&&this._streamErrorCallback(t.id,t.message);break;case"streamStalled":this.log.warn("Worker stream stalled for source ".concat(t.id,": no frames received within ").concat(t.stallDuration,"ms, degrading to main thread extraction")),this._transferredStreams.delete(t.id),this._degradedStreams.add(t.id),this.removeTrackStream(t.id),this._streamErrorCallback&&this._streamErrorCallback(t.id,"ReadableStream stalled: no frames received within ".concat(t.stallDuration,"ms"));break;case"log":{let e=t.level,r=t.message,i=this.log[e];i?i.call(this.log,r):this.log.warn("[Worker][unknown level: ".concat(e,"] ").concat(r));break}case"destroyed":this.log.info("Render Worker destroyed");break;case"imageSourceLoaded":this.log.info("Worker imageSource loaded: id=".concat(t.id,", ").concat(t.width,"x").concat(t.height));break;case"imageSourceError":this.log.warn("Worker imageSource error: id=".concat(t.id,", ").concat(t.message))}},this._renderWorker.onerror=e=>{this.log.error("Render Worker crashed: ".concat(e.message)),this._handleWorkerCrash()},this._renderWorker.onmessageerror=()=>{this.log.error("Render Worker message error")},this.ctx=null}_initMainThreadMode(e){if(this.ctx=this._canvas.getContext("2d",{alpha:e.alpha,willReadFrequently:e.willReadFrequently}),!this.ctx)throw new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._contextLostHandler=()=>{this.log.error("2d context lost, pausing rendering")},this._contextRestoredHandler=()=>{var e;this.log.warn("2d context restored, attempting recovery");let t=null==(e=this._canvas)?void 0:e.getContext("2d",{alpha:this.hasAlpha,willReadFrequently:!1});t?(this.ctx=t,this.log.info("2d context successfully recovered")):(this.log.error("2d context recovery failed, destroying"),this.destroy(new pR({code:uR.VIDEO_MANAGER_ERROR,extraCode:9,message:"2d context lost and recovery failed"})))},this._canvas.addEventListener("contextlost",this._contextLostHandler),this._canvas.addEventListener("contextrestored",this._contextRestoredHandler)}setStreamErrorCallback(e){this._streamErrorCallback=e}addTrackStream(e,t){if(!this._renderWorker||!this._workerReady)return this.log.warn("addTrackStream(".concat(e,"): Worker not ready")),!1;if(this._degradedStreams.has(e))return this.log.warn("addTrackStream(".concat(e,"): source was previously degraded, skipping Worker transfer")),!1;try{this.log.debug("addTrackStream(".concat(e,"): creating MediaStreamTrackProcessor, track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState,", track.enabled=").concat(t.enabled,", track.muted=").concat(t.muted));let r=new MediaStreamTrackProcessor({track:t}),i=r.readable;return this._renderWorker.postMessage({type:"addReadableStream",id:e,readable:i},[i]),this._transferredStreams.add(e),this._trackProcessors.set(e,r),this.log.info("addTrackStream(".concat(e,"): ReadableStream transferred to Worker")),!0}catch(r){return this.log.warn("addTrackStream(".concat(e,") failed: ").concat(r.message)),!1}}removeTrackStream(e){this._renderWorker&&this._workerReady&&this._renderWorker.postMessage({type:"removeReadableStream",id:e}),this._transferredStreams.delete(e),this._trackProcessors.delete(e),this.log.info("removeTrackStream(".concat(e,"): pipeline removed"))}replaceTrackStream(e,t){return this.log.debug("replaceTrackStream(".concat(e,"): removing old stream, then adding new track.id=").concat(t.id,", track.label=").concat(t.label,", track.readyState=").concat(t.readyState)),this.removeTrackStream(e),this.addTrackStream(e,t)}isStreamTransferred(e){return this._transferredStreams.has(e)}get transferredStreams(){return this._transferredStreams}_handleWorkerCrash(){this._workerFailed||(this._workerFailed=!0,this.log.warn("Worker crashed, completely exiting Worker mode, falling back to main thread rendering"),this._transferredStreams.clear(),this._trackProcessors.clear(),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(yM._ids++),this._initMainThreadMode({alpha:this.hasAlpha,willReadFrequently:!1}),this.emit("trackGeneratorDegraded"))}_handleTrackGeneratorDegradation(){this._useTrackGenerator&&(this.log.warn("TrackGenerator degradation: completely exiting Worker mode, falling back to main thread 2d rendering"),this._transferredStreams.clear(),this._trackProcessors.clear(),this._cleanupWorkerMode(),this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(yM._ids++),this._initMainThreadMode({alpha:this.hasAlpha,willReadFrequently:!1}),this.emit("trackGeneratorDegraded"))}_cleanupWorkerMode(){if(this._useWorkerRendering&&(e._workerBlobUrlRefCount>0&&e._workerBlobUrlRefCount--,0===e._workerBlobUrlRefCount&&null!==e._workerBlobUrl&&(URL.revokeObjectURL(e._workerBlobUrl),e._workerBlobUrl=null)),this._generatorTrack)try{this._generatorTrack.stop()}catch(YP){}if(this._generatorTrack=null,this._useTrackGenerator=!1,this._renderWorker){try{this._renderWorker.postMessage({type:"destroy"})}catch(YP){}this._renderWorker=null}this._useWorkerRendering=!1,this._workerReady=!1,this._transferredStreams.clear(),this._trackProcessors.clear(),this._onWorkerReadyCallback=null,this._pendingBackgroundImage&&(this._pendingBackgroundImage.close(),this._pendingBackgroundImage=null),this._pendingImageSourceMessages.clear()}_createRenderWorker(t){if(!e._workerBlobUrl){let r=new Blob([t],{type:"application/javascript"});e._workerBlobUrl=URL.createObjectURL(r)}return e._workerBlobUrlRefCount++,new Worker(e._workerBlobUrl)}setOnWorkerReadyCallback(e){this._onWorkerReadyCallback=e}postWorkerMessage(e,t){this._renderWorker&&this._workerReady&&(t?this._renderWorker.postMessage(e,t):this._renderWorker.postMessage(e))}bufferOrPostImageSourceMessage(e){this._renderWorker&&this._workerReady?this.postWorkerMessage(e):"removeImageSource"===e.type?this._pendingImageSourceMessages.delete(e.id):this._pendingImageSourceMessages.set(e.id,e)}setSize(e,t){super.setSize(e,t),this._useWorkerRendering&&this._renderWorker&&(this._workerReady?this.postWorkerMessage({type:"resize",width:e,height:t}):this._pendingSize={width:e,height:t})}setWorkerBackground(e){this._workerReady?this.postWorkerMessage({type:"setBackground",color:e}):this._useWorkerRendering&&(this._pendingBackground=e,this._pendingBackgroundImage=null)}setWorkerBackgroundImage(e){this._workerReady?this.postWorkerMessage({type:"setBackgroundImage",bitmap:e},[e]):this._useWorkerRendering&&(this._pendingBackgroundImage&&this._pendingBackgroundImage.close(),this._pendingBackgroundImage=e,this._pendingBackground=null)}_flushPendingState(){if(null!==this._pendingBackgroundImage?(this.postWorkerMessage({type:"setBackgroundImage",bitmap:this._pendingBackgroundImage},[this._pendingBackgroundImage]),this._pendingBackgroundImage=null,this._pendingBackground=null):null!==this._pendingBackground&&(this.postWorkerMessage({type:"setBackground",color:this._pendingBackground}),this._pendingBackground=null),null!==this._pendingSize){let{width:e,height:t}=this._pendingSize;super.setSize(e,t),this.postWorkerMessage({type:"resize",width:e,height:t}),this._pendingSize=null}if(this._pendingImageSourceMessages.size>0){for(let e of this._pendingImageSourceMessages.values())this.postWorkerMessage(e);this._pendingImageSourceMessages.clear()}}destroy(e){let t="";e&&(t=e.message,this.error=e,pL.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),this._cleanupWorkerMode(),this._canvas&&this._contextLostHandler&&this._canvas.removeEventListener("contextlost",this._contextLostHandler),this._canvas&&this._contextRestoredHandler&&this._canvas.removeEventListener("contextrestored",this._contextRestoredHandler),this._contextLostHandler=null,this._contextRestoredHandler=null,delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),pL.addSuccessEvent({key:512703})}};Mk(wM,"_workerBlobUrl",null),Mk(wM,"_workerBlobUrlRefCount",0),Pk([Lx(Px.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),pL.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d".concat(this._useWorkerRendering?" (worker mode)":"")),pL.addSuccessEvent({key:512701})}})],wM.prototype,"create",1),Pk([Lx("created",Px.INIT,{ignoreError:!0,sync:!0})],wM.prototype,"destroy",1);var IM=wM,TM=tL();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:TM,exposeOrigin:!0,permittedOrigins:["*"]})}catch(gk){}var SM=async function(e){let t=null,r=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:e.selfBrowserSurface||"include",surfaceSwitching:"include"},r={width:DO?{max:e.width}:{ideal:e.width,max:e.width},height:DO?{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:n=!1}=e;t.audio={echoCancellation:r,noiseSuppression:i,autoGainControl:n,sampleRate:48e3}}return t}(e);eL.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r)));let i=await navigator.mediaDevices.getDisplayMedia(r);e.systemAudio&&0===i.getAudioTracks().length&&(TO&&kO<74||DO||RD)&&eL.warn("Your browser not support capture system audio");let n=i.getVideoTracks()[0];if(n){if(e.frameRate)try{await n.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(a){eL.warn("screen applyConstraints failed: ".concat(a))}e.captureElement&&await async function(e,t){var r;if("CropTarget"in window&&"fromElement"in CropTarget&&oC(e.cropTo))try{if((null==(r=e.getCaptureHandle())?void 0:r.handle)!==TM)return;let i=await CropTarget.fromElement(t);await e.cropTo(i)}catch(i){eL.warn("cropTo target failed ".concat(i))}}(n,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 sC(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);eL.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t=await navigator.mediaDevices.getUserMedia(r),i.addTrack(t.getAudioTracks()[0])}return i};Pk([zk(function(e){this.setContentHint(e.contentHint||"detail")})],class extends nM{constructor(e){super(e,2),Mk(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),Mk(this,"objectFit","contain"),Mk(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}get isShareCurrentTab(){var e,t;try{return TM===(null==(t=null==(e=this.mediaTrack)?void 0:e.getCaptureHandle())?void 0:t.handle)}catch(r){return}}async capture(e){let{systemAudio:t=!1,autoGainControl:r,echoCancellation:i,noiseSuppression:n,audioTrack:a,videoTrack:o,captureElement:s,preferDisplaySurface:c,selfBrowserSurface:l}=e;var d;try{let e,u=bC();return o||a?(e=new MediaStream,o&&e.addTrack(o),a&&e.addTrack(a)):(e=await SM({audio:!1,systemAudio:t,width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate,autoGainControl:r,echoCancellation:i,noiseSuppression:n,captureElement:s,preferDisplaySurface:c,selfBrowserSurface:l}),this.sourceTrack=e.getVideoTracks()[0]),await this.setInputMediaStreamTrack(e.getVideoTracks()[0]),ZO.emit(JO.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:bC()-u,profile:this.profile,room:null==(d=this.manager)?void 0:d.room}),e}catch(u){throw this.log.error("getDisplayMedia error observed ".concat(u)),u instanceof pR?u:new pR({code:uR.INITIALIZE_FAILED,name:u.name,message:u.message})}}async switchDevice(e){throw new Error("Method not implemented.")}}.prototype,"capture",1);var kM=class e extends aP{constructor(t,r,i){super({userId:r.userId,sdkAppId:t.sdkAppId,mediaType:i,room:t}),this.room=t,this.user=r,Mk(this,"tinyId"),Mk(this,"isRemote",!0),Mk(this,"jitterBufferDelay",0),Mk(this,"availableState"),Mk(this,"remotePublishState"),Mk(this,"_triggerCheckDecodeSubject",PP(UP(this,e.STATE_SUBSCRIBE))),Mk(this,"ignoreUpdatePlayingState"),this.tinyId=r.tinyId,this.availableState=new Px("".concat(r.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new Px("".concat(r.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),kP(NP(UP(this,Px.STATECHANGED),UP(this.remotePublishState,Px.STATECHANGED)),HP(()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing)),ZP(e=>{this.availableState.state!==(e?Px.ON:Px.OFF)&&(this.availableState.state=e?Px.ON:Px.OFF),(!this.isRemotePublished||!this.ignoreUpdatePlayingState)&&this.updatePlayingState(e)}));let n=kP(UP(this.player,Hx.ERROR),BP(e=>e.code===MediaError.MEDIA_ERR_DECODE)),a=kP(function(e,t){return AP(r=>{let i=0,n=setTimeout(()=>{if(r.removeDefer(a),r.next(i++),t){let e=setInterval(()=>r.next(i++),t);r.defer(()=>{clearInterval(e)})}else r.complete()},e),a=()=>clearTimeout(n);r.defer(a)},"timer",arguments)}(5e3),BP(()=>!!(!this.ignoreDecodeError&&this.isSubscribed&&this.isPlayCalled&&this.stat.bytesReceived&&this.isRemotePublished)&&(!this.player.isPlaying&&!(this.kind===lA?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1)))),o=kP(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return AP(e=>{let r=new Map;t.forEach(t=>{let i=new TP(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)}(n,a),VP(UP(this,Px.INIT)));kP(this._triggerCheckDecodeSubject,BP(()=>!this.ignoreDecodeError),XP(o),ZP(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,r,i;return null!=(i=null==(r=null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.hadRecentBadDownlink)?void 0:r.call(t,2))&&i||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===Px.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){var r,i;let n=this.kind===lA;if(pL[e?"addSuccessEvent":"addFailedEvent"]({key:n?504700:514702}),!n){let t=(null==(r=this.room)?void 0:r.downlinkVideoCodec.toUpperCase())||"H264";pL[e?"addSuccessEvent":"addFailedEvent"]({key:uL["DECODE_".concat(t,"_RESULT")]}),e||this.log.warn("".concat(null==(i=this.room)?void 0:i.downlinkVideoCodec," decode failed"))}e||(pL.addEnum({key:n?504701:514703,value:YO()}),Kx.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(GO()||XO(),"-").concat(zO()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===lA?"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?Px.ON:Px.OFF,this.emit("remote-publish-changed",this.isRemotePublished)}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};Mk(kM,"STATE_SUBSCRIBE","subscribe"),Pk([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 Gk((r,i)=>function(){for(var n=arguments.length,a=new Array(n),o=0;o<n;o++)a[o]=arguments[o];return new Promise((n,o)=>{let s=setTimeout(()=>{let r=new pR({code:uR.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(e,"s")});(this.log||this._log||eL).warn(r),2===t?o(r):1===t&&n()},1e3*e);this._checkPendingPromiseSet||(this._checkPendingPromiseSet=new Set),this._checkPendingPromiseSet.add(s),r.apply(this,a).then(n,o).finally(()=>{clearTimeout(s),this._checkPendingPromiseSet&&s&&this._checkPendingPromiseSet.delete(s)})})})}(5,1)],kM.prototype,"waitHasMediaTrack",1),Pk([Lx(Px.INIT,kM.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),ZO.emit(JO.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),_P(521716,!1)],kM.prototype,"subscribe",1),Pk([Lx(kM.STATE_SUBSCRIBE,Px.INIT,{sync:!0,success(){this.log.info("unsubscribed"),ZO.emit(JO.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],kM.prototype,"unsubscribe",1);var AM=kM,RM=class extends cM{constructor(e,t,r,i,n){super(e,{useDefaultProgram:!0,useFbo:!0,name:"alpha",create2d:!0,logger:t}),this.setContainer=i,Mk(this,"initStat",{alphaStitchingType:1}),Mk(this,"end",PP()),Mk(this,"minSize",320),Mk(this,"maxSize",1280),Mk(this,"draggable",!1),Mk(this,"startDragX",0),Mk(this,"startDragY",0),Mk(this,"left",0),Mk(this,"top",0),Mk(this,"baseWidth",320),Mk(this,"baseRatio"),Mk(this,"container"),this.initStat=n,this.draggable=r,this.bindDragEvents(),pL.addEnum({key:515700,value:1}),this.draggable&&pL.addEnum({key:515700,value:11})}bindDragEvents(){let e=this.context._canvas;if(e)if(this.draggable){let t=VP(this.end);kP(UP(e,"mousedown"),JP(this.startDrag.bind(this)),KP(()=>kP(UP(window,"mousemove"),VP(UP(window,"mouseup")))),t,ZP(this.doDrag.bind(this))),kP(UP(e,"dblclick"),t,ZP(this.resetPosition.bind(this))),kP(UP(e,"wheel"),t,ZP(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,n){var a;let{ctx2d:o}=this,s=this.context._canvas;if(!o||!s)return!1;let c=super.draw2d(e,t,r,i,n),l=o.getImageData(0,0,i,n),{data:d}=l,u=!1;if(1===this.initStat.alphaStitchingType){let e=Math.floor(i/2);for(let t=0;t<n;t++)for(let r=0;r<e;r++){let n=4*(t*i+r),a=4*(t*i+(r+e)),o=d[a];d[a+3]=0;let s=o>=100;d[n+3]=s?255:0}u=super.draw2d(l,0,0,0,0,e,n),s.width=e}else if(2===this.initStat.alphaStitchingType){let e=Math.floor(n/2);for(let t=0;t<e;t++)for(let r=0;r<i;r++){let n=4*(t*i+r),a=4*((t+e)*i+r),o=d[a];d[a+3]=0;let s=o>=100;d[n+3]=s?255:0}u=super.draw2d(l,0,0,0,0,i,e),s.height=e}return null==(a=this.context.ctx)||a.clearRect(0,0,i,n),c&&u}close(){this.baseRatio=void 0,this.end.next(),this.end.complete()}};var CM=class extends AM{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),Mk(this,"mediaType",4),Mk(this,"source"),Mk(this,"shouldRenderAlpha",!1),Mk(this,"alphaNode"),Mk(this,"shouldBeDraggable",!0),Mk(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0,keyFramesDecoded:0}),Mk(this,"_keyFrameCountLogged",!1),Mk(this,"_keyFrameStartTimestamp",0),Mk(this,"_keyFrameStartCount",0),Mk(this,"_keyFrameIntervals",[]),Mk(this,"_prevKeyFrameTimestamp",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 null!=t&&t.canvasRender&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then(()=>{this.player.calculateStat(),ZO.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=Zk[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 IM({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 _M(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())},n=new RM(t,this.log,this.shouldBeDraggable,i,{alphaStitchingType:e});this.source.connect(n),n.connect(r),this.alphaNode=n}else this.source.connect(r);fx()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,t),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,r=function(e){return[15,30,45,60].reduce((t,r)=>Math.abs(r-e)<Math.abs(t-e)?r:t)}(t);!lC(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),ZO.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)}updateKeyFramesDecoded(e){let t=this.stat.keyFramesDecoded||0;if(this.stat.keyFramesDecoded=e,this._keyFrameCountLogged)return;let r=Date.now();if(!this._keyFrameStartTimestamp)return this._keyFrameStartTimestamp=r,this._keyFrameStartCount=e,void(this._prevKeyFrameTimestamp=r);if(this._prevKeyFrameTimestamp&&e>t){let i=e-t,n=(r-this._prevKeyFrameTimestamp)/1e3/i;this._keyFrameIntervals.push(n)}this._prevKeyFrameTimestamp=r;let i=r-this._keyFrameStartTimestamp;if(i>=16e3){let t=e-this._keyFrameStartCount,r=t>0?i/1e3/t:0,n="".concat(t," keyframes in 16s ").concat(r," [").concat(this._keyFrameIntervals.map(e=>e.toFixed(1)).join(","),"] keyFramesDecoded ").concat(e),a=r<=2.5?"debug":"info";this.log[a](n),this._keyFrameCountLogged=!0}}},DM=new Map;function OM(e,t){let r=Dk(Ck({},t),{timestamp:fR()});DM.has(e)?DM.get(e).push(r):DM.set(e,[r])}ZO.on(JO.JOIN_SUCCESS,e=>{let{room:t}=e;OM(t.userId,{eventId:32788})}),ZO.on(JO.LEAVE_START,e=>{let{room:t}=e;OM(t.userId,{eventId:32789})}),ZO.on(JO.LOCAL_TRACK_PUBLISHED,e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),OM(t.room.userId,{eventId:e})}}),ZO.on(JO.LOCAL_TRACK_UNPUBLISHED,e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),OM(t.room.userId,{eventId:e})}}),ZO.on(JO.TRACK_MUTED,e=>{let{track:t}=e;t.room&&(t.kind===lA?OM(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):OM(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))}),ZO.on(JO.TRACK_UNMUTED,e=>{let{track:t}=e;t.room&&(t.kind===lA?OM(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):OM(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))}),ZO.on(JO.REMOTE_TRACK_SUBSCRIBED,e=>{let{track:t}=e;t.room&&(1===t.mediaType&&OM(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&OM(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&OM(t.room.userId,{eventId:32803,remoteUserId:t.userId}))}),ZO.on(JO.REMOTE_TRACK_UNSUBSCRIBED,e=>{let{track:t}=e;t.room&&(1===t.mediaType&&OM(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&OM(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&OM(t.room.userId,{eventId:32804,remoteUserId:t.userId}))}),ZO.on(JO.SWITCH_DEVICE_SUCCESS,e=>{let{track:t}=e;t.room&&OM(t.room.userId,{eventId:t.kind===dA?32780:32781})}),ZO.on(JO.LOCAL_TRACK_REPLACED,e=>{let{track:t}=e;t.room&&OM(t.room.userId,{eventId:t.kind===dA?32782:32783})}),ZO.on(JO.SIGNAL_CONNECTION_STATE_CHANGED,e=>{let t,{room:r,prevState:i,state:n}=e;switch(n){case"CONNECTED":t="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":t=32794}t&&OM(r.userId,{eventId:t})}),ZO.on(JO.PEER_CONNECTION_STATE_CHANGED,e=>{let t,{room:r,prevState:i,state:n,remoteUserId:a}=e,o=!!a;switch(n){case"CONNECTED":t="RECONNECTING"===i?o?32801:32798:o?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(t=o?32802:32799);break;case"RECONNECTING":t=o?32800:32797}t&&OM(r.userId,{eventId:t,remoteUserId:a})}),ZO.on(JO.VIDEO_CODEC_IMPLEMENTATION_CHANGED,e=>{let{implementation:t,userId:r,remoteUserId:i,codec:n,isHWCodec:a,prevImplementation:o,streamType:s}=e,c=a?1:0;o||(c=a?3:2);let l={H264:0,H265:1,VP8:2}[n.toUpperCase()],d={eventId:4004,param1:c,param2:l,streamType:s||2};i&&(d.remoteUserId=i,d.eventId=4005),OM(r,d),pL.addEnum({key:i?514701:513701,value:c}),pL.addEnum({key:i?514700:513700,value:l})}),ZO.on(JO.LOCAL_TRACK_RECAPTURE,e=>{let{track:t,error:r}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===lA?(e.streamType=1,r&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,r&&(e.param1=8)),OM(t.userId,e)}}),Nk(Bk(),1),Nk(Bk(),1);var LM="trtc_debug_dialog",xM="".concat(LM,"_activated"),NM="".concat(LM,"_switch"),PM="".concat(LM,"_mask"),MM="".concat(LM,"_panel"),UM="".concat(LM,"_tabber"),BM="".concat(LM,"_tab"),FM="".concat(LM,"_topbar"),VM="".concat(LM,"_toptab"),WM="".concat(LM,"_content"),HM="".concat(LM,"_has_topbar"),jM="".concat(WM,"_log"),zM="".concat(WM,"_network"),GM="".concat(LM,"_dump"),qM="".concat(zM,"_title"),KM="".concat(zM,"_basic"),YM="".concat(zM,"_local"),XM="".concat(zM,"_remote"),ZM="".concat(GM,"_title"),JM="".concat(GM,"_local"),QM="".concat(GM,"_remote"),$M="".concat(QM,"_hook"),eU="".concat(LM,"_banner"),tU="".concat(eU,"_item"),rU="".concat(LM,"_toolbar"),iU="".concat(LM,"_tool"),nU="".concat(LM,"_item"),aU="".concat(nU,"_debug"),oU="".concat(nU,"_info"),sU="".concat(nU,"_warn"),cU="".concat(nU,"_error"),lU="".concat(LM,"_back_top"),dU="".concat(LM,"_go_bottom"),uU="".concat(GM,"_local_audio"),hU="".concat(GM,"_local_video_main"),pU="".concat(GM,"_local_video_aux"),fU="".concat(LM,"_tooltip"),mU="".concat(KM,"_network_info"),gU="".concat(KM,"_room_info"),_U="".concat(jM,"_controller"),vU="success",yU="warning",EU="failed",bU=0,wU=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(LM,'" class="').concat(LM,'"><div class="').concat(NM,'">Debug#').concat(++bU,'</div><div class="').concat(PM,'"></div><div class="').concat(MM,'"><div class="').concat(UM,'"><a class="').concat(BM," ").concat(xM,'" data-tab="log">').concat(FA,'</a><a class="').concat(BM,'" data-tab="network">').concat(VA,'</a><a class="').concat(BM,'" data-tab="dump">').concat(WA,'</a></div><div class="').concat(_U,'"><div data-type="back_top">').concat(ZA,'</div><div data-type="go_bottom">').concat(XA,'</div><div data-type="clear_log">').concat(JA,'</div></div><div class="').concat(FM,'"><a class="').concat(VM," ").concat(xM,'" data-type="all">All</a><a class="').concat(VM,'" data-type="debug">Debug</a><a class="').concat(VM,'" data-type="info">Info</a><a class="').concat(VM,'" data-type="warn">Warn</a><a class="').concat(VM,'" data-type="error">Error</a></div><div class="').concat(WM," ").concat(HM,'"><div class="').concat(jM,'"></div><div class="').concat(zM,'"><div class="').concat(qM,'">').concat(tR,'</div><div class="').concat(KM,'"><div class="').concat(gU,'"></div><div class="').concat(mU,'">').concat(eR,'</div></div><div class="').concat(qM,'">').concat(QA,'</div><div class="').concat(YM,'">').concat(eR,'</div><div class="').concat(qM,'">').concat($A,'</div><div class="').concat(XM,'">').concat(eR,'</div></div><div class="').concat(GM,'"><div class="').concat(ZM,'">').concat(QA,'</div><div class="').concat(JM,'"><div id="').concat(uU,'"><span>').concat(nR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(HA,'</button><button class="dump-opus">').concat(jA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div><div id="').concat(hU,'"><span>').concat(iR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(WA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div><div id="').concat(pU,'"><span>').concat(aR," - ").concat(rR,'(s):</span><input type="number" min=0 value=0></input><button class="dump">').concat(WA,'</button><button class="end-dump" disabled>').concat(GA,'</button></div></div><div class="').concat(ZM,'">').concat($A,'</div><div class="').concat(QM,'"><div class="').concat($M,"\">userId:<input id=\"dump-remote-video-hook-userid\" value='*' />duration:<input id=\"dump-remote-video-hook-duration\" min='1' value='0' 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(eU,'"></div><div class="').concat(rU,'"><a id="trtc_upload" class="').concat(iU,'">').concat(qA,'</a><a id="trtc_export" class="').concat(iU,'">').concat(KA,'</a><a id="trtc_hide" class="').concat(iU,'">').concat(YA,"</a></div></div></div>"),null==(e=this.shadowRoot)||e.appendChild(t.content.firstChild)}addStyle(){var e;let t=document.createElement("style");t.textContent="#".concat(LM,"{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(LM," a,.").concat(NM,"{cursor:pointer;}.").concat(LM,"{color:black;}.").concat(NM,"{display:block;position:fixed;right:50px;bottom:").concat(150+50*bU,"px;border-radius:5px;background-color:#07c160;color:#fff;padding:5px 10px;z-index:10000;}.").concat(PM,"{display:none;position:fixed;left:0;top:0;right:0;bottom:0;z-index:10001;background-color:rgb(0,0,0,0.6);}.").concat(MM,"{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(MM,"{left:0;}}.").concat(UM,"{display:flex;height:2em;border-bottom:1px solid var(--DD-BORDER);}.").concat(BM,"{padding:0 20px;border-right:1px solid rgba(0,0,0,0.1);line-height:2em;color:black;}.").concat(BM,".").concat(xM,"{background-color:var(--DD-BG-2);}.").concat(BM,".disabled{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(FM,"{height:2em;display:flex;flex-direction:row;}.").concat(VM,"{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(VM,".").concat(xM,"{border-bottom:1px solid #1485ee;background-color:var(--DD-BG-2);}.").concat(WM,"{background-color:#fff;position:absolute;left:0;right:0;top:2em;bottom:8em;overflow-y:scroll;overflow-x:hidden;}.").concat(WM,".").concat(HM,"{top:4em;bottom:10em}.").concat(zM,"{display:none;}.").concat(GM,"{display:none;}.").concat(qM,",.").concat(ZM,"{line-height:2em;text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat(KM,",.").concat(YM,",.").concat(XM,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(JM,",.").concat(QM,"{display:flex;flex-direction:column;padding:0.5em 0;justify-content:center;align-items:center;}.").concat(JM," div input{margin:0 10px;height:1.5em;width:4em;}.").concat(JM," div {padding:10px 0;border-radius:5px;}.").concat(JM," div button,.").concat(QM," div button {cursor:pointer;height:1.8em;border-radius:5px;margin-right:5px;}.").concat(JM," div button[disabled],.").concat(QM," div button[disabled]{cursor:not-allowed;}.").concat(QM," select {height:1.8em;margin:0 10px;}.").concat(QM," div input{margin:0 10px;height:1.5em;width:4em;}.").concat($M," {line-height:3em;padding:0.5em;}.").concat(qM,"{text-align:center;background-color:var(--DD-BG-0);border-bottom:1px solid var(--DD-BORDER);}.").concat(KM,",.").concat(YM,",.").concat(XM,"{text-align:center;border-bottom:1px solid var(--DD-BORDER);}.").concat(nU,"{border-bottom:1px solid var(--DD-BG-0);padding:5px 10px;overflow-wrap: break-word;}.").concat(cU,"{color:var(--DD-ERROR);background-color:var(--DD-ERROR-BG);}.").concat(sU,"{color:var(--DD-WARN);background-color:var(--DD-WARN-BG);}div .").concat(oU,"{color:var(--DD-INFO);}.").concat(aU,"{color:var(--DD-DEBUG);}.").concat(eU,"{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(tU,"{border-bottom:1px solid var(--DD-BORDER);padding:5px 10px;overflow-wrap: break-word;}.").concat(rU,"{position:absolute;line-height:2em;display:flex;flex-direction:row;left:0;right:0;bottom:0;}.").concat(iU,"{flex:1;color:black;text-align:center;background-color:#ededed;border-right:1px solid var(--DD-BORDER);}#").concat(LM," .").concat(lU,",#").concat(LM," .").concat(dU,"{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(dU,"{bottom:9em;}.").concat(lU,"{bottom:11.5em;}#").concat(LM," .").concat(iU,".disable{cursor:not-allowed;background-color:#ededed;color:#999;}.").concat(fU," {position:relative;display:inline-block;}.").concat(fU," .tooltiptext{visibility:hidden;width:180px;background-color:black;color:#fff;text-align:center;padding:5px 0;border-radius:6px;position:absolute;}.").concat(fU," .tooltip-top {bottom:125%;left:50%;margin-left:-90px;}.").concat(fU,":hover .tooltiptext{visibility:visible;}.").concat(_U,"{position:absolute;left:0;right:0;bottom:8em;height:2em;display:flex;align-items:center;}.").concat(_U," 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",wU);var IU=class{constructor(e,t){Mk(this,"_dialogNode",null),Mk(this,"_switchNode",null),Mk(this,"_maskNode",null),Mk(this,"_panelNode",null),Mk(this,"_logContentNode",null),Mk(this,"_networkContentNode",null),Mk(this,"_dumpContentNode",null),Mk(this,"_tabNodes",[]),Mk(this,"_toptabNodes",[]),Mk(this,"_hasMove",!1),Mk(this,"_showDialog",!1),Mk(this,"_isMobile",!1),Mk(this,"_showLogType","all"),Mk(this,"prevBytesSent",0),Mk(this,"prevBytesReceived",0),Mk(this,"_core"),Mk(this,"_log"),Mk(this,"_logList",[]),Mk(this,"isUploading",!1),Mk(this,"publishMap",new Map),Mk(this,"dumpLocalVideoMap",{}),Mk(this,"dumpRemoteVideoMap",{}),Mk(this,"dumpLocalAudioMap",{}),Mk(this,"dumpRemoteAudioMap",{}),Mk(this,"eventMap",new Map),Mk(this,"switchPos",{x:0,y:0,startX:0,startY:0,endX:0,endY:0,isTouchEnd:!1}),Mk(this,"handleLeaveSuccess",e=>{let{room:t}=e;var r,i;if(!this.hitTest(t))return;let n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(QM));for(let a of this.publishMap.values())null==n||n.removeChild(a);this.publishMap.clear()}),Mk(this,"handleJoinSuccess",e=>{let{room:t}=e;var r,i;if(!this.hitTest(t))return;(null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(gU))).innerHTML="sdkAppId: ".concat(t.sdkAppId,"<br/>roomId: ").concat(t.roomId,"<br/>userId: ").concat(t.userId,"<br/>")}),Mk(this,"handleRemoteVideoAvailable",e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"publish")}),Mk(this,"handleRemoteVideoUnavailable",e=>{let t="sub"===e.streamType?"auxiliary":"main";this.renderDumpTab(e.userId,"remote",t,"unpublish")}),Mk(this,"handleRemoteAudioAvailable",e=>{this.renderDumpTab(e.userId,"remote","audio","publish")}),Mk(this,"handleRemoteAudioUnavailable",e=>{this.renderDumpTab(e.userId,"remote","audio","unpublish")}),Mk(this,"renderDumpTab",(e,t,r,i)=>{var n,a,o;let s={main:"video",auxiliary:"screen",audio:"audio"},c=(e,t)=>{var r,i,n;let a=document.createElement("div");a.innerText="".concat(e," - ").concat(s[t]," - ").concat(rR,"(s):");let o=document.createElement("input");o.type="number",o.min="0",o.value="10",o.id="dump_remote_".concat(t,"_").concat(e);let c,l=document.createElement("button");l.innerText=GA,l.disabled=!0,"audio"===t&&(c=document.createElement("button"),c.innerText=jA,c.style.marginLeft="5px");let d,u,h=document.createElement("button");if(h.innerText="audio"===t?HA:WA,h.onclick=()=>{let r,i,n=Number(o.value);if("audio"===t)({download:r,onDumpEnd:i}=this.dumpAudio("remote",n,e));else{if(!this.isSupportDumpVideo())return;({download:r,onDumpEnd:i}=this.dumpVideo(t,"remote",n,e))}r&&(this.inactiveButton(h,zA),c&&this.inactiveButton(c),n>0?setTimeout(()=>{null==r||r(),this.activeButton(h,WA),c&&this.activeButton(c,jA)},1e3*n):(this.activeButton(l),l.onclick=()=>{l.onclick=null,null==r||r(),null==i||i(),this.activeButton(h,WA),c&&this.activeButton(c,jA),this.inactiveButton(l)}))},c&&(c.onclick=()=>{let t=Number(o.value),{download:r,onDumpEnd:i}=this.dumpAudioFromPipeline("remote",t,e);r&&(this.inactiveButton(c,zA),this.inactiveButton(h),t>0?setTimeout(()=>{null==r||r(),this.activeButton(c,jA),this.activeButton(h,WA)},1e3*t):(this.activeButton(l),l.onclick=()=>{l.onclick=null,null==r||r(),null==i||i(),this.activeButton(c,jA),this.activeButton(h,WA),this.inactiveButton(l)}))}),"audio"!==t&&(d=document.createElement("button"),d.innerText="Dump w/ Audio",d.style.marginLeft="5px",d.onclick=()=>{if(!this.isSupportDumpVideo())return;let r=Number(o.value),i=this.dumpVideo(t,"remote",r,e),n=this.dumpAudioFromPipeline("remote",r,e);if(!i.download&&!n.download)return;let a=async()=>{var r,a,o,s;let c=new lR.default,l=this.dumpRemoteVideoMap["".concat(e,"-").concat(t)];if(l&&l.data.length>0){let r,i="h264",n=this.getVideoCodec(e);if("vp8"===n){let n=this._core.room.remotePublishedUserMap.get(e),a="main"===t?null==n?void 0:n.remoteVideoTrack:null==n?void 0:n.remoteAuxiliaryTrack;this.addInfoToBanner(yU,"package vp8 into ivf format"),r=this.convertVP8ToIVF(l.data,a),i="ivf"}else r=new Blob(l.data),i=n||"h264";let a="remote-".concat(e,"_").concat(t,"_").concat(this.formatStartDumpTime(l.startTimestamp),".").concat(i);c.file(a,r)}let d=this.dumpRemoteAudioMap["".concat(e)];if(d&&d.data.length>0){let t,i=(null==(a=null==(r=this._core.room.userManager)?void 0:r.getPublishedUser(e))?void 0:a.audioCodec)||"opus",n=i;"opus"===i?(this.addInfoToBanner(yU,"package opus to ogg"),t=this.convertOpusToOgg(d.data),n="ogg"):t=new Blob(d.data);let o="remote-".concat(e,"_audio_").concat(this.formatStartDumpTime(d.startTimestamp),".").concat(n);c.file(o,t)}let u=await c.generateAsync({type:"blob"}),h=URL.createObjectURL(u),p=document.createElement("a");p.href=h,p.download="dump_".concat(e,"_").concat(this.formatStartDumpTime(Date.now()),".zip"),p.style.display="none",document.body.appendChild(p),p.click(),URL.revokeObjectURL(h),document.body.removeChild(p),null==(o=i.onDumpEnd)||o.call(i),null==(s=n.onDumpEnd)||s.call(n),this.addInfoToBanner(vU,"Dump success, file name is: ".concat(p.download))};this.inactiveButton(d,zA),this.inactiveButton(h),r>0?setTimeout(()=>{a(),this.activeButton(d,"Dump w/ Audio"),this.activeButton(h,WA)},1e3*r):(this.activeButton(l),l.onclick=()=>{l.onclick=null,a(),this.activeButton(d,"Dump w/ Audio"),this.activeButton(h,WA),this.inactiveButton(l)})}),"audio"!==t){u=document.createElement("button"),u.innerText="Preview",u.style.whiteSpace="Pre";let r=document.createElement("video");document.body.appendChild(r),r.id="".concat(LM,"_preview_remote_").concat(t,"_").concat(e),r.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 ",u.onclick=async()=>{var i;if(r.style.display="none"===r.style.display?"":"none",u&&(u.innerText="none"===r.style.display?"Preview":" Hide "),!r.srcObject){let n=this._core.room.remotePublishedUserMap.get(e);if(n){let e=null==(i=n["main"===t?"remoteVideoTrack":"remoteAuxiliaryTrack"])?void 0:i.mediaTrack;e?(r.srcObject=new MediaStream([e]),await r.play()):this.addInfoToBanner(EU,"failed to preview, remote video track is not available")}}}}a.appendChild(o),a.appendChild(h),c&&a.appendChild(c),d&&a.appendChild(d),a.appendChild(l),u&&a.appendChild(u),a.style.cssText="padding:10px;";let p=document.createElement("div");return p.style.cssText="width:100%;display:flex;justify-content:center;border-top: 1px solid var(--DD-BORDER);",p.appendChild(a),null==(n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(QM)))||n.appendChild(p),p};if("remote"===t)if("publish"===i){let i=c(e,r);this.publishMap.set("".concat(e,"-").concat(t,"-").concat(r),i)}else{let i=this.publishMap.get("".concat(e,"-").concat(t,"-").concat(r));if(!i)return;null==(o=null==(a=null==(n=this._dialogNode)?void 0:n.shadowRoot)?void 0:a.querySelector(".".concat(QM)))||o.removeChild(i);let s=document.querySelector("#".concat(LM,"_preview_remote_").concat(r,"_").concat(e));s&&document.body.removeChild(s),this.publishMap.delete("".concat(e,"-").concat(t,"-").concat(r))}}),Mk(this,"handleStatistics",e=>{var t,r,i,n,a,o;let s=(e.bytesSent-this.prevBytesSent)/2,c=(e.bytesReceived-this.prevBytesReceived)/2;this.prevBytesSent=e.bytesSent,this.prevBytesReceived=e.bytesReceived,(null==(r=null==(t=this._dialogNode)?void 0:t.shadowRoot)?void 0:r.querySelector(".".concat(mU))).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==(n=null==(i=this._dialogNode)?void 0:i.shadowRoot)?void 0:n.querySelector(".".concat(YM)),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(eR):d;let u=null==(o=null==(a=this._dialogNode)?void 0:a.shadowRoot)?void 0:o.querySelector(".".concat(XM)),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(eR):h}),Mk(this,"pad",e=>e<10?"0".concat(e):"".concat(e)),this._core=e,this._log=t,this.initCustomElements(),this.synchronizeLog(),this.installEvents(),this.addVideoProcessor(),this.addAudioProcessor(),window["__trtc_instance_".concat(bU,"__")]=this._core.trtc}initCustomElements(){this._isMobile=(()=>{let e=window.navigator&&window.navigator.userAgent||"",t=/iPad/i.test(e)||/iPhone/i.test(e),r=/Android/i.test(e);return t||r})();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(NM)),this._addEventListener(this._switchNode,"click",this.onSwitchClick.bind(this));let r=getComputedStyle(this._switchNode);this.switchPos.x=parseInt(r.right,10)||50,this.switchPos.y=parseInt(r.bottom,10)||100+50*bU,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(PM)),this._addEventListener(this._maskNode,"click",this.onMaskClick.bind(this)),this._panelNode=t.querySelector(".".concat(MM)),t.querySelector(".".concat(_U)).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(jM)),this._networkContentNode=t.querySelector(".".concat(zM)),this._dumpContentNode=t.querySelector(".".concat(GM)),this._tabNodes=Array.from(t.querySelector(".".concat(UM)).children),this._tabNodes.forEach(e=>{this._addEventListener(e,"click",this.onTabClick.bind(this))}),this._toptabNodes=Array.from(t.querySelector(".".concat(FM)).children),this._toptabNodes.forEach(e=>{this._addEventListener(e,"click",this.onToptabClick.bind(this))});let i=t.querySelector("#trtc_upload");this._addEventListener(i,"click",this.onUploadClick.bind(this));let n=t.querySelector("#trtc_export");this._addEventListener(n,"click",this.onExportClick.bind(this));let a=t.querySelector("#trtc_hide");this._addEventListener(a,"click",this.onHideClick.bind(this));let o=t.querySelector("#".concat(hU," .dump")),s=t.querySelector("#".concat(hU," .end-dump")),c=Number(t.querySelector("#".concat(hU," input")).value);this._addEventListener(o,"click",this.getDumpButtonClickHandler.bind(this,o,s,c,"main","local"));let l=t.querySelector("#".concat(pU," .dump")),d=t.querySelector("#".concat(pU," .end-dump")),u=Number(t.querySelector("#".concat(pU," input")).value);this._addEventListener(l,"click",this.getDumpButtonClickHandler.bind(this,l,d,u,"auxiliary","local"));let h=t.querySelector("#".concat(uU," .dump")),p=t.querySelector("#".concat(uU," .dump-opus")),f=t.querySelector("#".concat(uU," .end-dump"));this._addEventListener(h,"click",()=>{let e=Number(t.querySelector("#".concat(uU," input")).value),{download:r,onDumpEnd:i}=this.dumpAudio("local",e);r?(this.inactiveButton(h,zA),this.inactiveButton(p),e>0?setTimeout(()=>{r(),this.activeButton(h,HA),this.activeButton(p,jA)},1e3*e):(this.activeButton(f),f.onclick=()=>{f.onclick=null,r(),null==i||i(),this.activeButton(h,HA),this.activeButton(p,jA),this.inactiveButton(f)})):this.addInfoToBanner(EU,"Failed to dump, please check if the current user has started the audio")}),this._addEventListener(p,"click",()=>{let e=Number(t.querySelector("#".concat(uU," input")).value),{download:r,onDumpEnd:i}=this.dumpAudioFromPipeline("local",e);r?(this.inactiveButton(p,zA),this.inactiveButton(h),e>0?setTimeout(()=>{r(),this.activeButton(p,jA),this.activeButton(h,HA)},1e3*e):(this.activeButton(f),f.onclick=()=>{f.onclick=null,r(),null==i||i(),this.activeButton(p,jA),this.activeButton(h,HA),this.inactiveButton(f)})):this.addInfoToBanner(EU,"Failed to dump opus, please check if the current user has started the audio")});let m=t.querySelector("#dump-remote-video-hook-userid"),g=t.querySelector("#dump-remote-video-hook-duration"),_=t.querySelector("#dump-remote-video-hook-mediaType"),v=t.querySelector("#dump-remote-video-hook-button");v.onclick=()=>{let e=Number(g.value);if(e<1)return void this.addInfoToBanner(EU,"duration at least 1s");let t=m.value;if(!t)return void this.addInfoToBanner(EU,"please input user id");"*"===t&&this.inactiveButton(v);let r,i,n=_.value,a="remote_".concat(t,"_").concat("sub"===n?"auxiliary":n),o=a=>{if((a.userId===t||"*"===t)&&a.streamType===n){if(this.addInfoToBanner(vU,"[".concat(a.userId,"_").concat(n,"] starting to dump video, duration: ").concat(e,"s")),({download:r,onDumpEnd:i}=this.dumpVideo("sub"===a.streamType?"auxiliary":a.streamType,"remote",e,a.userId)),!r)return;setTimeout(()=>{null==r||r(),null==i||i(),"*"!==t&&this._core.trtc.off(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,o)},1e3*e)}};this._core.trtc.on(this._core.TRTC.EVENT.REMOTE_VIDEO_AVAILABLE,o),this.addInfoToBanner(vU,"[".concat(a,"] 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(EU,"Current browser does not support dumping video"),!1)}_addEventListener(e,t,r,i){e&&(e.addEventListener(t,r,i),this.eventMap.set(e,{type:t,listener:r}))}_removeEventListener(){this.eventMap.forEach((e,t)=>{let{type:r,listener:i}=e;t&&t.removeEventListener(r,i)}),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.removeVideoProcessor(),this.removeAudioProcessor(),this._dialogNode&&(document.body.removeChild(this._dialogNode),this._dialogNode=null)}updateLog(e){var t;this._logList.push(e);let r=document.createElement("div");switch(r.classList.add(nU),e.level){case 4:r.classList.add(cU);break;case 2:r.classList.add(oU);break;case 3:r.classList.add(sU);break;case 1:r.classList.add(aU)}r.textContent=e.log,"all"!==this._showLogType&&!r.classList.contains("".concat(nU,"_").concat(this._showLogType))&&(r.style.display="none"),null==(t=this._logContentNode)||t.appendChild(r),this.addHelper(r)}getDumpButtonClickHandler(e,t,r,i,n){if(!this.isSupportDumpVideo())return;let{download:a,onDumpEnd:o}=this.dumpVideo(i,n,r);if(a)return this.addInfoToBanner(vU,"[".concat(n,"_").concat(i,"] starting to dump...")),this.inactiveButton(e,zA),void(r>0?setTimeout(()=>{a(),this.activeButton(e,WA)},1e3*r):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==o||o(),a(),this.activeButton(e,WA),this.inactiveButton(t)}));this.addInfoToBanner(vU,"[".concat(n,"_").concat(i,"] waiting to dump..."));let s=a=>{let{track:o}=a;if(o.room===this._core.room&&o.streamType===i){this.addInfoToBanner(vU,"[".concat(n,"_").concat(i,"] starting to dump")),"local"===n&&this._core.innerEmitter.off("104",s);let{download:a,onDumpEnd:o}=this.dumpVideo(i,n,r);if(!a)return;r>0?setTimeout(()=>{a(),this.activeButton(e,WA)},1e3*r):(this.activeButton(t),t.onclick=()=>{t.onclick=null,null==o||o(),a(),this.activeButton(e,WA),this.inactiveButton(t)})}};s.bind(this),"local"===n&&this._core.innerEmitter.on("104",s),this.inactiveButton(e,zA)}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,r,i,n,a,o,s;let c=e.target;null==(t=this._tabNodes)||t.forEach(e=>{e.classList.remove(xM)}),c.classList.add(xM);let l=c.getAttribute("data-tab");"log"===l?(null==(n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(WM)))||n.classList.add(HM),this._logContentNode.style.display="block",this._networkContentNode.style.display="none",this._dumpContentNode.style.display="none",this.logContentGoBottom()):(null==(s=null==(o=null==(a=this._dialogNode)?void 0:a.shadowRoot)?void 0:o.querySelector(".".concat(WM)))||s.classList.remove(HM),"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,r;let i=e.target;null==(t=this._toptabNodes)||t.forEach(e=>{e.classList.remove(xM)}),i.classList.add(xM),this._showLogType=i.getAttribute("data-type");let n=null==(r=this._logContentNode)?void 0:r.querySelectorAll(".".concat(nU)),a="".concat(nU,"_").concat(this._showLogType);n.forEach(e=>{e.classList.contains(a)||"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"}),r=document.createElement("a"),i=URL.createObjectURL(t);r.href=i;let n="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");r.download=n,r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(i),document.body.removeChild(r),this.addInfoToBanner(vU,"Export success: The log file name is ".concat(n)),this._core.kvStatManager.addSuccessEvent({key:592703})}addInfoToBanner(e,t){var r,i;let n=null==(i=null==(r=this._dialogNode)?void 0:r.shadowRoot)?void 0:i.querySelector(".".concat(eU)),a=document.createElement("div");a.classList.add(tU);let o=e===vU?"🟩":e===yU?"🟧":"🟥";a.innerText="".concat(o," [").concat(this.getCurrentTime(),"] ").concat(t),n.appendChild(a),n.scrollTop=n.scrollHeight}async onUploadClick(){var e,t;if(this.isUploading)return;this.isUploading=!0;let r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector("#trtc_upload");r.innerText="Uploading...",null==r||r.classList.add(".disable");let i=this._logList.reduce((e,t)=>"".concat(e+t.log,"\n"),""),n=new Blob([i],{type:"text/plain"}),a=new FormData;a.append("file",n,"trtc.log"),a.append("sdkAppId","".concat(this._core.room.sdkAppId||"EmptySdkAppId")),a.append("userId","".concat(this._core.room.userId||"EmptyUserId")),fetch("https://service.trtc.qcloud.com/api/uploadLogFile",{method:"POST",body:a}).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(EU,"Upload Failed: Please use local export"),this._log.info("Upload Failed: Please use local export"),this._core.kvStatManager.addFailedEvent({key:592704})}).finally(()=>{r.innerText=qA,null==r||r.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,r;null==(r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(WM)))||r.scrollTo(0,0)}onGoBottomClick(){this.logContentGoBottom()}onClearLogClick(){this._logList=[],this._logContentNode&&(this._logContentNode.innerHTML="")}logContentGoBottom(){var e,t;let r=null==(t=null==(e=this._dialogNode)?void 0:e.shadowRoot)?void 0:t.querySelector(".".concat(WM));null==r||r.scrollTo(0,null==r?void 0:r.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),r=this.switchPos.y-(e.pageY-this.switchPos.startY);[t,r]=this.getSafeAreaXY(t,r),this._switchNode.style.right="".concat(t,"px"),this._switchNode.style.bottom="".concat(r,"px"),this.switchPos.endX=t,this.switchPos.endY=r}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,r=e.touches[0].pageY-this.switchPos.startY,i=Math.floor(this.switchPos.x-t),n=Math.floor(this.switchPos.y-r);[i,n]=this.getSafeAreaXY(i,n),this._switchNode.style.right="".concat(i,"px"),this._switchNode.style.bottom="".concat(n,"px"),this.switchPos.endX=i,this.switchPos.endY=n,this.switchPos.isTouchEnd=!0,e.cancelable&&e.preventDefault()}getSafeAreaXY(e,t){let r=Math.max(document.documentElement.offsetWidth,window.innerWidth),i=Math.max(document.documentElement.offsetHeight,window.innerHeight);return e+this._switchNode.offsetWidth>r&&(e=r-this._switchNode.offsetWidth),t+this._switchNode.offsetHeight>i&&(t=i-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",r=this.dumpLocalVideoMap[t];r&&(r.data.push(e.data),r.duration>0&&Date.now()-r.startTimestamp>1e3*r.duration&&r.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,r=cR,i=e.innerText;i=i.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 r=e.match(t);return null==r||r.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"),r.forEach(t=>{if(e.innerText.includes(t)){let r="";r="function"==typeof oR[t].tips?oR[t].tips(e.innerText):oR[t].tips,i=i.replace(new RegExp("".concat((e=>e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d").replace(">","&gt;").replace(">","&lt;"))(t)),"gi"),'<span class="'.concat(fU,'" style="background:').concat(oR[t].color||"#e1dfdf","; color: ").concat(oR[t].textColor||"#000",'">').concat(t,'\n <span class="tooltiptext tooltip-top">').concat(r,"</span>\n </span>"))}}),e.innerHTML=i}getCurrentTime(){let e=new Date,t=this.pad(e.getHours()),r=this.pad(e.getMinutes()),i=this.pad(e.getSeconds());return"".concat(t,":").concat(r,":").concat(i)}dumpAudioFromPipeline(e,t,r){this.addInfoToBanner(yU,"dump audio from pipeline");let i=Date.now(),n=this.formatStartDumpTime(i),a=[],o="".concat(e,"_").concat(r);if("local"===e)this._core.trtc._localAudioTrack;else if(r){let e=this._core.room.remotePublishedUserMap.get(r);e&&e.remoteAudioTrack}let s;if("local"===e){if(!this.hasLocalTrack("main","audio"))return{};s=()=>{delete this.dumpLocalAudioMap.main},this.dumpLocalAudioMap.main={startTimestamp:i,data:a,duration:t,onDumpEnd:s}}if("remote"===e&&r){if(s=()=>{delete this.dumpRemoteAudioMap["".concat(r)]},this.dumpRemoteAudioMap["".concat(r)])return this.addInfoToBanner(yU,"[".concat(o,"] dump already exists.")),{};this.dumpRemoteAudioMap["".concat(r)]={startTimestamp:i,data:a,duration:t,onDumpEnd:s}}return{download:()=>{var t,i;if(0===a.length)return void this.addInfoToBanner(EU,"[".concat(o,"] dump failed. Reason: data is empty"));let s,c=("local"===e?null==(t=this._core.room.singlePC)?void 0:t.audioCodec:null==(i=this._core.room.userManager)?void 0:i.getPublishedUser(r).audioCodec)||"opus",l=c;"opus"===c?(this.addInfoToBanner(yU,"[".concat(o,"] package opus to ogg")),s=this.convertOpusToOgg(a),l="ogg"):s=new Blob(a);let d=URL.createObjectURL(s),u=document.createElement("a"),h="local"===e?"local_".concat(n,".").concat(l):"remote-".concat(r,"_").concat(n,".").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(vU,"[".concat(o,"] dump success. File name is: ").concat(h))},onDumpEnd:s}}dumpVideo(e,t,r,i){let n,a=Date.now(),o=this.formatStartDumpTime(a),s=[],c="".concat(t,"_").concat(i,"_").concat(e);if("local"===t)n="main"===e?this._core.trtc._localVideoTrack:this._core.trtc._localScreenTrack;else if(i){let t=this._core.room.remotePublishedUserMap.get(i);t&&(n="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:a,data:s,duration:r,onDumpEnd:l}}if("remote"===t&&i){if(l=()=>{delete this.dumpRemoteVideoMap["".concat(i,"-").concat(e)]},this.dumpRemoteVideoMap["".concat(i,"-").concat(e)])return this.addInfoToBanner(yU,"[".concat(c,"] dump already exists.")),{};this.dumpRemoteVideoMap["".concat(i,"-").concat(e)]={startTimestamp:a,data:s,duration:r,onDumpEnd:l}}return{download:()=>{var r,a;if(0===s.length)return void this.addInfoToBanner(EU,"[".concat(c,"] dump failed. Reason: data is empty"));let l,d;"main"===e?l="video":"auxiliary"===e&&(l="screen"),"vp8"===this.getVideoCodec(i||"")?(this.addInfoToBanner(yU,"[".concat(c,"] package vp8 into ivf format")),d=this.convertVP8ToIVF(s,n)):d=new Blob(s);let u=URL.createObjectURL(d),h=document.createElement("a"),p="local"===t?"local_".concat(l,"_").concat(o,".").concat((null==(r=this._core.room.singlePC)?void 0:r.videoCodec)||"h264"):"remote-".concat(i,"_").concat(l,"_").concat(o,".").concat((null==(a=this._core.room.userManager)?void 0:a.getPublishedUser(i).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(vU,"[".concat(c,"] dump success. File name is: ").concat(p))},onDumpEnd:l}}convertVP8ToIVF(e,t){var r,i,n;function a(e,t,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}let o=e.reduce((e,t)=>e+12+t.byteLength,32),s=new ArrayBuffer(o),c=new DataView(s),l=new Uint8Array(s),d=0;a(c,d,"DKIF"),d+=4,c.setUint16(d,0,!0),d+=2,c.setUint16(d,32,!0),d+=2,a(c,d,"VP80"),d+=4,c.setUint16(d,(null==(r=null==t?void 0:t._inputTrack)?void 0:r.getSettings().width)||0,!0),d+=2,c.setUint16(d,(null==(i=null==t?void 0:t._inputTrack)?void 0:i.getSettings().height)||0,!0),d+=2;let u=(t instanceof CM?null==t?void 0:t.decodeFPS:null==(n=null==t?void 0:t.mediaTrack)?void 0:n.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 r=e.byteLength,i=Math.floor(1e6*t/u);c.setUint32(d,r,!0),d+=4,c.setFloat64(d,i,!0),d+=8,l.set(new Uint8Array(e),d),d+=r}),new Blob([s],{type:"application/octet-stream"})}getVideoCodec(e){var t,r;return""===e?null==(t=this._core.room.singlePC)?void 0:t.videoCodec:null==(r=this._core.room.remotePublishedUserMap.get(e))?void 0:r.videoCodec}hasLocalTrack(e,t){for(let r of this._core.room.localTracks)if(r.streamType===e&&r.kind===t)return!0;return!1}dumpAudio(e,t,r){var i,n,a;let o,s,c=null,l=[],d=[],u=[],h=[],p=[],f=[],m=[],g=new AbortController,_=Date.now(),v=this.formatStartDumpTime(_),y=this._core.room.audioManager._localAudioPipline,E=this._core.room.audioManager._localScreenAudioPipeline,b=e=>{let{room:t,data:r,type:i}=e;if(this.hitTest(t)){if("dump"===i){if(h[0]=h[0]?h[0].concat(r.captureInput):r.captureInput,h[1]=h[1]?h[1].concat(r.playInput):r.playInput,o){let e=r.startTime-o,t=r.endTime-r.startTime;if(e>30||t>30){let i=function(e){if("number"!=typeof e||e<0)return"0毫秒";let t=[],r=Math.floor(e/6e4),i=e%6e4;r>0&&t.push("".concat(r,"分"));let n=Math.floor(i/1e3);return i%=1e3,(n>0||t.length)&&t.push("".concat(n,"秒")),(i>0||!t.length)&&t.push("".concat(i,"毫秒")),t.join("")},n=r.startTime-s,a=o-s;m.push("".concat(r.startTime,"\t").concat(i(n),"~").concat(i(a),"\t").concat(e,"\t").concat(t))}o=r.startTime}else o=r.startTime,s=r.startTime;f.push(r.startTime)}"dump-screen-audio"===i&&(p[0]=p[0]?p[0].concat(r.captureInput):r.captureInput,p[1]=p[1]?p[1].concat(r.playInput):r.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!=y&&y.source.node&&(l.push(y.source.node),d.push("local_audio_raw_capture-".concat(e,"-").concat(y.source.node.channelCount))),(null!=(i=null==y?void 0:y.aec)&&i.node||null!=E&&E.aec.node)&&(this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!0}),this._core.innerEmitter.on("265",b),null!=(n=null==y?void 0:y.aec)&&n.node&&(l.push(y.aec.node),d.push("local_audio_audioProcessor_processed-".concat(e,"-").concat(y.aec.node.channelCount))),null!=E&&E.aec.node&&(l.push(E.aec.node),d.push("screen_audio_audioProcessor_processed-".concat(e,"-").concat(E.aec.node.channelCount)))),null!=y&&y.denoiser.node&&(l.push(y.denoiser.node),d.push("local_audio_denoiser_processed-".concat(e,"-").concat(y.denoiser.node.channelCount))),this._core.room.audioManager.mixWeight>1&&null!=y&&y.stream){let t=this._core.room.audioManager.audioContext.createMediaStreamSource(y.stream);t.channelCount=1,l.push(t),d.push("local_audio_destination-".concat(e,"-").concat(t.channelCount))}}else if("remote"===e&&void 0!==r){let e=null==(a=this._core.room.remotePublishedUserMap.get(r))?void 0:a.remoteAudioTrack;if(null==e||!e.mediaTrack)return{};let t=this._core.createAudioNode(e.mediaTrack);l.push(t),d.push("remote_".concat(r))}let w=async()=>{var t,r,i,n,a;let o=new lR.default;for(let e=0;e<d.length;e++)o.file("".concat(d[e],".pcm"),new Blob(u[e]));if(null!=(t=null==h?void 0:h[0])&&t.length&&o.file("audioProcessor_input_capture.pcm",new Blob(h[0])),null!=(r=null==h?void 0:h[1])&&r.length&&o.file("audioProcessor_input_playback.pcm",new Blob(h[1])),null!=(i=null==p?void 0:p[0])&&i.length&&o.file("audioProcessor_screen_audio_input_capture.pcm",new Blob(p[0])),null!=(n=null==p?void 0:p[1])&&n.length&&o.file("audioProcessor_screen_audio_input_playback.pcm",new Blob(p[1])),null!=f&&f.length){let e=f.reduce((e,t)=>"".concat(e,"\n").concat(t));o.file("audioProcessor_handle_timestamp.txt",new Blob([e]))}if(null!=m&&m.length){let e=m.reduce((e,t)=>"".concat(e,"\n").concat(t));o.file("audioProcessor_big_gap_data.txt",new Blob([e]))}let s=await o.generateAsync({type:"blob"}),l=URL.createObjectURL(s),_=document.createElement("a");_.href=l,_.download="".concat(e,"-audio-").concat(v,".zip"),_.style.display="none",document.body.appendChild(_),_.click(),URL.revokeObjectURL(l),_.remove(),this.addInfoToBanner(vU,"Dump success, file name is: ".concat(e,"-").concat(v,".zip")),this._core.innerEmitter.off("265",b),(null!=(a=null==y?void 0:y.aec)&&a.node||null!=E&&E.aec.node)&&this._core.trtc.updatePlugin("AudioProcessor",{enableDump:!1}),c&&clearTimeout(c),g.abort("download")};return t>0&&(c=Number(setTimeout(()=>{g.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]]})}}),g).catch(()=>w)),{download:w,onDumpEnd:()=>{g.abort("timeout")}}}formatStartDumpTime(e){let t=new Date(e),r=t.getFullYear(),i=this.pad(t.getMonth()+1),n=this.pad(t.getDate()),a=this.pad(t.getHours()),o=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(r,"-").concat(i,"-").concat(n,"T").concat(a,"-").concat(o,"-").concat(s).concat(u).concat(this.pad(l),"-").concat(this.pad(d))}convertOpusToOgg(e){let t=Math.floor(4294967295*Math.random()),r=0,i=0,n=[],a=this.createOpusHead(48e3,2);n.push(this.createOggPage(2,0,t,r++,[a]));let o=this.createOpusTags();n.push(this.createOggPage(0,0,t,r++,[o]));let s=[],c=0;return e.forEach((a,o)=>{let l=this.getOpusPacketDuration(a);s.push(a),c+=a.byteLength,i+=l;let d=o===e.length-1;if(c>6e4||s.length>=50||d){let e=d?4:0;n.push(this.createOggPage(e,i,t,r++,s)),s=[],c=0}}),new Blob(n,{type:"audio/ogg"})}createOpusHead(e,t){let r=new ArrayBuffer(19),i=new DataView(r);return this.writeString(i,0,"OpusHead"),i.setUint8(8,1),i.setUint8(9,t),i.setUint16(10,0,!0),i.setUint32(12,e,!0),i.setUint16(16,0,!0),i.setUint8(18,0),r}createOpusTags(){let e="TRTC Debugger",t=new ArrayBuffer(29),r=new DataView(t);return this.writeString(r,0,"OpusTags"),r.setUint32(8,13,!0),this.writeString(r,12,e),r.setUint32(25,0,!0),t}createOggPage(e,t,r,i,n){let a=0;n.forEach(e=>{let t=e.byteLength;for(;t>=255;)a++,t-=255;a++});let o=27+a,s=n.reduce((e,t)=>e+t.byteLength,0),c=new ArrayBuffer(o+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,r,!0),l.setUint32(18,i,!0),l.setUint32(22,0,!0),l.setUint8(26,a);let u=27;n.forEach(e=>{let t=e.byteLength;for(;t>=255;)d[u++]=255,t-=255;d[u++]=t});let h=o;n.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,r){for(let i=0;i<r.length;i++)e.setUint8(t+i,r.charCodeAt(i))}getOpusPacketDuration(e){if(0===e.byteLength)return 0;let t=new Uint8Array(e),r=t[0],i=r>>3&31,n=3&r,a=1;if(1===n||2===n)a=2;else if(3===n){if(e.byteLength<2)return 0;a=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][i]||960)*a}crc32(e){let t=new Uint32Array(256);for(let i=0;i<256;i++){let e=i<<24;for(let t=0;t<8;t++)2147483648&e?e=e<<1^79764919:e<<=1;t[i]=e>>>0}let r=0;for(let i=0;i<e.length;i++){r=(r<<8^t[255&(r>>>24^e[i])])>>>0}return r}addVideoProcessor(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):PA,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):MA,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):UA,type:2}),this._core.room.audioManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeAudio.bind(this):BA,type:2})}removeAudioProcessor(){this._core.room.audioManager.removeEncodeProcessor({type:2}),this._core.room.audioManager.removeDecodeProcessor({type:2})}encodeVideo(e){let{frame:t,mediaType:r}=e;return PA({frame:t,onDump:()=>{if(!r)return;let e=2===r?"sub":"main",i=this.dumpLocalVideoMap[e];i&&(i.data.push(t.data.slice(0)),i.duration>0&&Date.now()-i.startTimestamp>1e3*i.duration&&i.onDumpEnd())}})}decodeVideo(e){let{frame:t,track:r}=e;return MA({frame:t,onDump:()=>{if(!r)return;let e=this.dumpRemoteVideoMap["".concat(r.userId,"-").concat(r.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 UA({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:r}=e;return BA({frame:t,onDump:()=>{if(!r)return;let e=this.dumpRemoteAudioMap[r.userId];e&&(e.data.push(t.data.slice(0)),e.duration>0&&Date.now()-e.startTimestamp>1e3*e.duration&&e.onDumpEnd())}})}};
2
2
  /*! Bundled license information:
3
3
 
4
4
  jszip/dist/jszip.min.js:
@@ -14,4 +14,4 @@
14
14
  https://github.com/nodeca/pako/blob/main/LICENSE
15
15
  *)
16
16
  */
17
- return Pk([Kk(300,()=>"export")],yU.prototype,"onExportClick",1),Pk([Kk(300,()=>"upload")],yU.prototype,"onUploadClick",1),yU});
17
+ return Pk([Kk(300,()=>"export")],IU.prototype,"onExportClick",1),Pk([Kk(300,()=>"upload")],IU.prototype,"onUploadClick",1),IU});