trtc-sdk-v5 5.10.2-wasm.2 → 5.10.2-wasm.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/face_detection/blaze_face_short_range.tflite +0 -0
- package/assets/face_detection/vision_wasm_internal.gz +0 -0
- package/assets/face_detection/vision_wasm_internal.js +20 -0
- package/assets/face_detection/vision_wasm_nosimd_internal.gz +0 -0
- package/assets/face_detection/vision_wasm_nosimd_internal.js +20 -0
- package/assets/worker.js +8 -8
- package/index.d.ts +84 -23
- package/package.json +1 -1
- package/plugins/cdn-streaming/package.json +1 -1
- package/plugins/cross-room/package.json +1 -1
- package/plugins/custom-encryption/package.json +1 -1
- package/plugins/device-detector/package.json +1 -1
- package/plugins/small-stream-auto-switcher/package.json +9 -0
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.d.ts +19 -0
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.esm.js +1 -0
- package/plugins/small-stream-auto-switcher/small-stream-auto-switcher.umd.js +1 -0
- package/plugins/video-decoder/package.json +1 -1
- package/plugins/video-decoder/video-decoder.esm.js +1 -1
- package/plugins/video-decoder/video-decoder.umd.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.esm.js +1 -1
- package/plugins/video-effect/basic-beauty/basic-beauty.umd.js +1 -1
- package/plugins/video-effect/basic-beauty/package.json +1 -1
- package/plugins/video-effect/beauty/package.json +1 -1
- package/plugins/video-effect/video-mixer/package.json +29 -0
- package/plugins/video-effect/video-mixer/video-mixer.esm.d.ts +24 -0
- package/plugins/video-effect/video-mixer/video-mixer.esm.js +1 -0
- package/plugins/video-effect/video-mixer/video-mixer.umd.js +1 -0
- package/plugins/video-effect/virtual-background/package.json +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.esm.js +1 -1
- package/plugins/video-effect/virtual-background/virtual-background.umd.js +1 -1
- package/plugins/video-effect/watermark/package.json +1 -1
- package/plugins/video-effect/watermark/watermark.esm.js +1 -1
- package/plugins/video-effect/watermark/watermark.umd.js +1 -1
- package/plugins/voice-changer/package.json +1 -1
- package/trtc.esm.js +60 -60
- package/trtc.js +1 -1
package/trtc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e){return e&&e.Math===Math&&e},r=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof e&&e)||t("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i={},o=function(e){try{return!!e()}catch(t){return!0}},n=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,c=Function.prototype.call,l=s?c.bind(c):function(){return c.apply(c,arguments)},u={},d={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,p=h&&!d.call({1:2},1);u.f=p?function(e){var t=h(this,e);return!!t&&t.enumerable}:d;var m,f,_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},g=a,E=Function.prototype,v=E.call,y=g&&E.bind.bind(v,v),T=g?y:function(e){return function(){return v.apply(e,arguments)}},I=T,A=I({}.toString),S=I("".slice),R=function(e){return S(A(e),8,-1)},b=o,w=R,D=Object,C=T("".split),N=b((function(){return!D("z").propertyIsEnumerable(0)}))?function(e){return"String"===w(e)?C(e,""):D(e)}:D,k=function(e){return null==e},O=k,M=TypeError,L=function(e){if(O(e))throw new M("Can't call method on "+e);return e},P=N,x=L,U=function(e){return P(x(e))},V="object"==typeof document&&document.all,F=void 0===V&&void 0!==V?function(e){return"function"==typeof e||e===V}:function(e){return"function"==typeof e},B=F,H=function(e){return"object"==typeof e?null!==e:B(e)},j=r,G=F,W=function(e,t){return arguments.length<2?(r=j[e],G(r)?r:void 0):j[e]&&j[e][t];var r},K=T({}.isPrototypeOf),z=r.navigator,q=z&&z.userAgent,J=q?String(q):"",Y=r,X=J,$=Y.process,Q=Y.Deno,Z=$&&$.versions||Q&&Q.version,ee=Z&&Z.v8;ee&&(f=(m=ee.split("."))[0]>0&&m[0]<4?1:+(m[0]+m[1])),!f&&X&&(!(m=X.match(/Edge\/(\d+)/))||m[1]>=74)&&(m=X.match(/Chrome\/(\d+)/))&&(f=+m[1]);var te=f,re=te,ie=o,oe=r.String,ne=!!Object.getOwnPropertySymbols&&!ie((function(){var e=Symbol("symbol detection");return!oe(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41})),ae=ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=W,ce=F,le=K,ue=Object,de=ae?function(e){return"symbol"==typeof e}:function(e){var t=se("Symbol");return ce(t)&&le(t.prototype,ue(e))},he=String,pe=function(e){try{return he(e)}catch(t){return"Object"}},me=F,fe=pe,_e=TypeError,ge=function(e){if(me(e))return e;throw new _e(fe(e)+" is not a function")},Ee=ge,ve=k,ye=function(e,t){var r=e[t];return ve(r)?void 0:Ee(r)},Te=l,Ie=F,Ae=H,Se=TypeError,Re={exports:{}},be=r,we=Object.defineProperty,De=function(e,t){try{we(be,e,{value:t,configurable:!0,writable:!0})}catch(r){be[e]=t}return t},Ce=r,Ne=De,ke="__core-js_shared__",Oe=Re.exports=Ce[ke]||Ne(ke,{});(Oe.versions||(Oe.versions=[])).push({version:"3.40.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Me=Re.exports,Le=Me,Pe=function(e,t){return Le[e]||(Le[e]=t||{})},xe=L,Ue=Object,Ve=function(e){return Ue(xe(e))},Fe=Ve,Be=T({}.hasOwnProperty),He=Object.hasOwn||function(e,t){return Be(Fe(e),t)},je=T,Ge=0,We=Math.random(),Ke=je(1..toString),ze=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ke(++Ge+We,36)},qe=Pe,Je=He,Ye=ze,Xe=ne,$e=ae,Qe=r.Symbol,Ze=qe("wks"),et=$e?Qe.for||Qe:Qe&&Qe.withoutSetter||Ye,tt=function(e){return Je(Ze,e)||(Ze[e]=Xe&&Je(Qe,e)?Qe[e]:et("Symbol."+e)),Ze[e]},rt=l,it=H,ot=de,nt=ye,at=function(e,t){var r,i;if("string"===t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;if(Ie(r=e.valueOf)&&!Ae(i=Te(r,e)))return i;if("string"!==t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;throw new Se("Can't convert object to primitive value")},st=TypeError,ct=tt("toPrimitive"),lt=function(e,t){if(!it(e)||ot(e))return e;var r,i=nt(e,ct);if(i){if(void 0===t&&(t="default"),r=rt(i,e,t),!it(r)||ot(r))return r;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),at(e,t)},ut=lt,dt=de,ht=function(e){var t=ut(e,"string");return dt(t)?t:t+""},pt=H,mt=r.document,ft=pt(mt)&&pt(mt.createElement),_t=function(e){return ft?mt.createElement(e):{}},gt=_t,Et=!n&&!o((function(){return 7!==Object.defineProperty(gt("div"),"a",{get:function(){return 7}}).a})),vt=n,yt=l,Tt=u,It=_,At=U,St=ht,Rt=He,bt=Et,wt=Object.getOwnPropertyDescriptor;i.f=vt?wt:function(e,t){if(e=At(e),t=St(t),bt)try{return wt(e,t)}catch(r){}if(Rt(e,t))return It(!yt(Tt.f,e,t),e[t])};var Dt={},Ct=n&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Nt=H,kt=String,Ot=TypeError,Mt=function(e){if(Nt(e))return e;throw new Ot(kt(e)+" is not an object")},Lt=n,Pt=Et,xt=Ct,Ut=Mt,Vt=ht,Ft=TypeError,Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,jt="enumerable",Gt="configurable",Wt="writable";Dt.f=Lt?xt?function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Wt in r&&!r[Wt]){var i=Ht(e,t);i&&i[Wt]&&(e[t]=r.value,r={configurable:Gt in r?r[Gt]:i[Gt],enumerable:jt in r?r[jt]:i[jt],writable:!1})}return Bt(e,t,r)}:Bt:function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),Pt)try{return Bt(e,t,r)}catch(i){}if("get"in r||"set"in r)throw new Ft("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Kt=Dt,zt=_,qt=n?function(e,t,r){return Kt.f(e,t,zt(1,r))}:function(e,t,r){return e[t]=r,e},Jt={exports:{}},Yt=n,Xt=He,$t=Function.prototype,Qt=Yt&&Object.getOwnPropertyDescriptor,Zt=Xt($t,"name"),er={EXISTS:Zt,PROPER:Zt&&"something"===function(){}.name,CONFIGURABLE:Zt&&(!Yt||Yt&&Qt($t,"name").configurable)},tr=F,rr=Me,ir=T(Function.toString);tr(rr.inspectSource)||(rr.inspectSource=function(e){return ir(e)});var or,nr,ar,sr=rr.inspectSource,cr=F,lr=r.WeakMap,ur=cr(lr)&&/native code/.test(String(lr)),dr=ze,hr=Pe("keys"),pr=function(e){return hr[e]||(hr[e]=dr(e))},mr={},fr=ur,_r=r,gr=H,Er=qt,vr=He,yr=Me,Tr=pr,Ir=mr,Ar="Object already initialized",Sr=_r.TypeError,Rr=_r.WeakMap;if(fr||yr.state){var br=yr.state||(yr.state=new Rr);br.get=br.get,br.has=br.has,br.set=br.set,or=function(e,t){if(br.has(e))throw new Sr(Ar);return t.facade=e,br.set(e,t),t},nr=function(e){return br.get(e)||{}},ar=function(e){return br.has(e)}}else{var wr=Tr("state");Ir[wr]=!0,or=function(e,t){if(vr(e,wr))throw new Sr(Ar);return t.facade=e,Er(e,wr,t),t},nr=function(e){return vr(e,wr)?e[wr]:{}},ar=function(e){return vr(e,wr)}}var Dr={set:or,get:nr,has:ar,enforce:function(e){return ar(e)?nr(e):or(e,{})},getterFor:function(e){return function(t){var r;if(!gr(t)||(r=nr(t)).type!==e)throw new Sr("Incompatible receiver, "+e+" required");return r}}},Cr=T,Nr=o,kr=F,Or=He,Mr=n,Lr=er.CONFIGURABLE,Pr=sr,xr=Dr.enforce,Ur=Dr.get,Vr=String,Fr=Object.defineProperty,Br=Cr("".slice),Hr=Cr("".replace),jr=Cr([].join),Gr=Mr&&!Nr((function(){return 8!==Fr((function(){}),"length",{value:8}).length})),Wr=String(String).split("String"),Kr=Jt.exports=function(e,t,r){"Symbol("===Br(Vr(t),0,7)&&(t="["+Hr(Vr(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Or(e,"name")||Lr&&e.name!==t)&&(Mr?Fr(e,"name",{value:t,configurable:!0}):e.name=t),Gr&&r&&Or(r,"arity")&&e.length!==r.arity&&Fr(e,"length",{value:r.arity});try{r&&Or(r,"constructor")&&r.constructor?Mr&&Fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var i=xr(e);return Or(i,"source")||(i.source=jr(Wr,"string"==typeof t?t:"")),e};Function.prototype.toString=Kr((function(){return kr(this)&&Ur(this).source||Pr(this)}),"toString");var zr=Jt.exports,qr=F,Jr=Dt,Yr=zr,Xr=De,$r=function(e,t,r,i){i||(i={});var o=i.enumerable,n=void 0!==i.name?i.name:t;if(qr(r)&&Yr(r,n,i),i.global)o?e[t]=r:Xr(t,r);else{try{i.unsafe?e[t]&&(o=!0):delete e[t]}catch(a){}o?e[t]=r:Jr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},Qr={},Zr=Math.ceil,ei=Math.floor,ti=Math.trunc||function(e){var t=+e;return(t>0?ei:Zr)(t)},ri=ti,ii=function(e){var t=+e;return t!=t||0===t?0:ri(t)},oi=ii,ni=Math.max,ai=Math.min,si=function(e,t){var r=oi(e);return r<0?ni(r+t,0):ai(r,t)},ci=ii,li=Math.min,ui=function(e){var t=ci(e);return t>0?li(t,9007199254740991):0},di=ui,hi=function(e){return di(e.length)},pi=U,mi=si,fi=hi,_i=function(e){return function(t,r,i){var o=pi(t),n=fi(o);if(0===n)return!e&&-1;var a,s=mi(i,n);if(e&&r!=r){for(;n>s;)if((a=o[s++])!=a)return!0}else for(;n>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},gi={includes:_i(!0),indexOf:_i(!1)},Ei=He,vi=U,yi=gi.indexOf,Ti=mr,Ii=T([].push),Ai=function(e,t){var r,i=vi(e),o=0,n=[];for(r in i)!Ei(Ti,r)&&Ei(i,r)&&Ii(n,r);for(;t.length>o;)Ei(i,r=t[o++])&&(~yi(n,r)||Ii(n,r));return n},Si=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ri=Ai,bi=Si.concat("length","prototype");Qr.f=Object.getOwnPropertyNames||function(e){return Ri(e,bi)};var wi={};wi.f=Object.getOwnPropertySymbols;var Di=W,Ci=Qr,Ni=wi,ki=Mt,Oi=T([].concat),Mi=Di("Reflect","ownKeys")||function(e){var t=Ci.f(ki(e)),r=Ni.f;return r?Oi(t,r(e)):t},Li=He,Pi=Mi,xi=i,Ui=Dt,Vi=function(e,t,r){for(var i=Pi(t),o=Ui.f,n=xi.f,a=0;a<i.length;a++){var s=i[a];Li(e,s)||r&&Li(r,s)||o(e,s,n(t,s))}},Fi=o,Bi=F,Hi=/#|\.prototype\./,ji=function(e,t){var r=Wi[Gi(e)];return r===zi||r!==Ki&&(Bi(t)?Fi(t):!!t)},Gi=ji.normalize=function(e){return String(e).replace(Hi,".").toLowerCase()},Wi=ji.data={},Ki=ji.NATIVE="N",zi=ji.POLYFILL="P",qi=ji,Ji=r,Yi=i.f,Xi=qt,$i=$r,Qi=De,Zi=Vi,eo=qi,to=function(e,t){var r,i,o,n,a,s=e.target,c=e.global,l=e.stat;if(r=c?Ji:l?Ji[s]||Qi(s,{}):Ji[s]&&Ji[s].prototype)for(i in t){if(n=t[i],o=e.dontCallGetSet?(a=Yi(r,i))&&a.value:r[i],!eo(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==o){if(typeof n==typeof o)continue;Zi(n,o)}(e.sham||o&&o.sham)&&Xi(n,"sham",!0),$i(r,i,n,e)}},ro={};ro[tt("toStringTag")]="z";var io="[object z]"===String(ro),oo=F,no=R,ao=tt("toStringTag"),so=Object,co="Arguments"===no(function(){return arguments}()),lo=io?no:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=so(e),ao))?r:co?no(t):"Object"===(i=no(t))&&oo(t.callee)?"Arguments":i},uo=lo,ho=String,po=function(e){if("Symbol"===uo(e))throw new TypeError("Cannot convert a Symbol value to a string");return ho(e)},mo=zr,fo=Dt,_o=function(e,t,r){return r.get&&mo(r.get,t,{getter:!0}),r.set&&mo(r.set,t,{setter:!0}),fo.f(e,t,r)},go=to,Eo=n,vo=T,yo=He,To=F,Io=K,Ao=po,So=_o,Ro=Vi,bo=r.Symbol,wo=bo&&bo.prototype;if(Eo&&To(bo)&&(!("description"in wo)||void 0!==bo().description)){var Do={},Co=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Ao(arguments[0]),t=Io(wo,this)?new bo(e):void 0===e?bo():bo(e);return""===e&&(Do[t]=!0),t};Ro(Co,bo),Co.prototype=wo,wo.constructor=Co;var No="Symbol(description detection)"===String(bo("description detection")),ko=vo(wo.valueOf),Oo=vo(wo.toString),Mo=/^Symbol\((.*)\)[^)]+$/,Lo=vo("".replace),Po=vo("".slice);So(wo,"description",{configurable:!0,get:function(){var e=ko(this);if(yo(Do,e))return"";var t=Oo(e),r=No?Po(t,7,-1):Lo(t,Mo,"$1");return""===r?void 0:r}}),go({global:!0,constructor:!0,forced:!0},{Symbol:Co})}var xo=r,Uo={},Vo=tt;Uo.f=Vo;var Fo=xo,Bo=He,Ho=Uo,jo=Dt.f,Go=function(e){var t=Fo.Symbol||(Fo.Symbol={});Bo(t,e)||jo(t,e,{value:Ho.f(e)})};Go("asyncIterator");var Wo=R,Ko=Array.isArray||function(e){return"Array"===Wo(e)},zo=TypeError,qo=R,Jo=T,Yo=function(e){if("Function"===qo(e))return Jo(e)},Xo=ge,$o=a,Qo=Yo(Yo.bind),Zo=function(e,t){return Xo(e),void 0===t?e:$o?Qo(e,t):function(){return e.apply(t,arguments)}},en=Ko,tn=hi,rn=function(e){if(e>9007199254740991)throw zo("Maximum allowed index exceeded");return e},on=Zo,nn=function(e,t,r,i,o,n,a,s){for(var c,l,u=o,d=0,h=!!a&&on(a,s);d<i;)d in r&&(c=h?h(r[d],d,t):r[d],n>0&&en(c)?(l=tn(c),u=nn(e,t,c,l,u,n-1)-1):(rn(u+1),e[u]=c),u++),d++;return u},an=nn,sn=T,cn=o,ln=F,un=lo,dn=sr,hn=function(){},pn=W("Reflect","construct"),mn=/^\s*(?:class|function)\b/,fn=sn(mn.exec),_n=!mn.test(hn),gn=function(e){if(!ln(e))return!1;try{return pn(hn,[],e),!0}catch(t){return!1}},En=function(e){if(!ln(e))return!1;switch(un(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _n||!!fn(mn,dn(e))}catch(t){return!0}};En.sham=!0;var vn=!pn||cn((function(){var e;return gn(gn.call)||!gn(Object)||!gn((function(){e=!0}))||e}))?En:gn,yn=Ko,Tn=vn,In=H,An=tt("species"),Sn=Array,Rn=function(e){var t;return yn(e)&&(t=e.constructor,(Tn(t)&&(t===Sn||yn(t.prototype))||In(t)&&null===(t=t[An]))&&(t=void 0)),void 0===t?Sn:t},bn=function(e,t){return new(Rn(e))(0===t?0:t)},wn=an,Dn=Ve,Cn=hi,Nn=ii,kn=bn;to({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Dn(this),r=Cn(t),i=kn(t,0);return i.length=wn(i,t,t,r,0,void 0===e?1:Nn(e)),i}});var On={},Mn=Ai,Ln=Si,Pn=Object.keys||function(e){return Mn(e,Ln)},xn=n,Un=Ct,Vn=Dt,Fn=Mt,Bn=U,Hn=Pn;On.f=xn&&!Un?Object.defineProperties:function(e,t){Fn(e);for(var r,i=Bn(t),o=Hn(t),n=o.length,a=0;n>a;)Vn.f(e,r=o[a++],i[r]);return e};var jn,Gn=W("document","documentElement"),Wn=Mt,Kn=On,zn=Si,qn=mr,Jn=Gn,Yn=_t,Xn="prototype",$n="script",Qn=pr("IE_PROTO"),Zn=function(){},ea=function(e){return"<"+$n+">"+e+"</"+$n+">"},ta=function(e){e.write(ea("")),e.close();var t=e.parentWindow.Object;return e=null,t},ra=function(){try{jn=new ActiveXObject("htmlfile")}catch(o){}var e,t,r;ra="undefined"!=typeof document?document.domain&&jn?ta(jn):(t=Yn("iframe"),r="java"+$n+":",t.style.display="none",Jn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(ea("document.F=Object")),e.close(),e.F):ta(jn);for(var i=zn.length;i--;)delete ra[Xn][zn[i]];return ra()};qn[Qn]=!0;var ia=Object.create||function(e,t){var r;return null!==e?(Zn[Xn]=Wn(e),r=new Zn,Zn[Xn]=null,r[Qn]=e):r=ra(),void 0===t?r:Kn.f(r,t)},oa=tt,na=ia,aa=Dt.f,sa=oa("unscopables"),ca=Array.prototype;void 0===ca[sa]&&aa(ca,sa,{configurable:!0,value:na(null)});var la=function(e){ca[sa][e]=!0},ua=gi.includes,da=la;to({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return ua(this,e,arguments.length>1?arguments[1]:void 0)}}),da("includes");var ha,pa,ma,fa={},_a=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),ga=He,Ea=F,va=Ve,ya=_a,Ta=pr("IE_PROTO"),Ia=Object,Aa=Ia.prototype,Sa=ya?Ia.getPrototypeOf:function(e){var t=va(e);if(ga(t,Ta))return t[Ta];var r=t.constructor;return Ea(r)&&t instanceof r?r.prototype:t instanceof Ia?Aa:null},Ra=o,ba=F,wa=H,Da=Sa,Ca=$r,Na=tt("iterator"),ka=!1;[].keys&&("next"in(ma=[].keys())?(pa=Da(Da(ma)))!==Object.prototype&&(ha=pa):ka=!0);var Oa=!wa(ha)||Ra((function(){var e={};return ha[Na].call(e)!==e}));Oa&&(ha={}),ba(ha[Na])||Ca(ha,Na,(function(){return this}));var Ma={IteratorPrototype:ha,BUGGY_SAFARI_ITERATORS:ka},La=Dt.f,Pa=He,xa=tt("toStringTag"),Ua=function(e,t,r){e&&!r&&(e=e.prototype),e&&!Pa(e,xa)&&La(e,xa,{configurable:!0,value:t})},Va=Ma.IteratorPrototype,Fa=ia,Ba=_,Ha=Ua,ja=fa,Ga=function(){return this},Wa=function(e,t,r,i){var o=t+" Iterator";return e.prototype=Fa(Va,{next:Ba(+!i,r)}),Ha(e,o,!1),ja[o]=Ga,e},Ka=T,za=ge,qa=H,Ja=function(e){return qa(e)||null===e},Ya=String,Xa=TypeError,$a=function(e,t,r){try{return Ka(za(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},Qa=H,Za=L,es=function(e){if(Ja(e))return e;throw new Xa("Can't set "+Ya(e)+" as a prototype")},ts=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=$a(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return Za(r),es(i),Qa(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0),rs=to,is=l,os=F,ns=Wa,as=Sa,ss=ts,cs=Ua,ls=qt,us=$r,ds=fa,hs=er.PROPER,ps=er.CONFIGURABLE,ms=Ma.IteratorPrototype,fs=Ma.BUGGY_SAFARI_ITERATORS,_s=tt("iterator"),gs="keys",Es="values",vs="entries",ys=function(){return this},Ts=function(e,t,r,i,o,n,a){ns(r,t,i);var s,c,l,u=function(e){if(e===o&&f)return f;if(!fs&&e&&e in p)return p[e];switch(e){case gs:case Es:case vs:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",h=!1,p=e.prototype,m=p[_s]||p["@@iterator"]||o&&p[o],f=!fs&&m||u(o),_="Array"===t&&p.entries||m;if(_&&(s=as(_.call(new e)))!==Object.prototype&&s.next&&(as(s)!==ms&&(ss?ss(s,ms):os(s[_s])||us(s,_s,ys)),cs(s,d,!0)),hs&&o===Es&&m&&m.name!==Es&&(ps?ls(p,"name",Es):(h=!0,f=function(){return is(m,this)})),o)if(c={values:u(Es),keys:n?f:u(gs),entries:u(vs)},a)for(l in c)(fs||h||!(l in p))&&us(p,l,c[l]);else rs({target:t,proto:!0,forced:fs||h},c);return p[_s]!==f&&us(p,_s,f,{name:o}),ds[t]=f,c},Is=function(e,t){return{value:e,done:t}},As=U,Ss=la,Rs=fa,bs=Dr,ws=Dt.f,Ds=Ts,Cs=Is,Ns=n,ks="Array Iterator",Os=bs.set,Ms=bs.getterFor(ks),Ls=Ds(Array,"Array",(function(e,t){Os(this,{type:ks,target:As(e),index:0,kind:t})}),(function(){var e=Ms(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Cs(void 0,!0);switch(e.kind){case"keys":return Cs(r,!1);case"values":return Cs(t[r],!1)}return Cs([r,t[r]],!1)}),"values"),Ps=Rs.Arguments=Rs.Array;if(Ss("keys"),Ss("values"),Ss("entries"),Ns&&"values"!==Ps.name)try{ws(Ps,"name",{value:"values"})}catch(Uj){}var xs=ge,Us=Ve,Vs=N,Fs=hi,Bs=TypeError,Hs="Reduce of empty array with no initial value",js=function(e){return function(t,r,i,o){var n=Us(t),a=Vs(n),s=Fs(n);if(xs(r),0===s&&i<2)throw new Bs(Hs);var c=e?s-1:0,l=e?-1:1;if(i<2)for(;;){if(c in a){o=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw new Bs(Hs)}for(;e?c>=0:s>c;c+=l)c in a&&(o=r(o,a[c],c,n));return o}},Gs={left:js(!1),right:js(!0)},Ws=o,Ks=function(e,t){var r=[][e];return!!r&&Ws((function(){r.call(null,t||function(){return 1},1)}))},zs=r,qs=J,Js=R,Ys=function(e){return qs.slice(0,e.length)===e},Xs=Ys("Bun/")?"BUN":Ys("Cloudflare-Workers")?"CLOUDFLARE":Ys("Deno/")?"DENO":Ys("Node.js/")?"NODE":zs.Bun&&"string"==typeof Bun.version?"BUN":zs.Deno&&"object"==typeof Deno.version?"DENO":"process"===Js(zs.process)?"NODE":zs.window&&zs.document?"BROWSER":"REST",$s="NODE"===Xs,Qs=Gs.left;to({target:"Array",proto:!0,forced:!$s&&te>79&&te<83||!Ks("reduce")},{reduce:function(e){var t=arguments.length;return Qs(this,e,t,t>1?arguments[1]:void 0)}});var Zs=Gs.right;to({target:"Array",proto:!0,forced:!$s&&te>79&&te<83||!Ks("reduceRight")},{reduceRight:function(e){return Zs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ec=to,tc=Ko,rc=T([].reverse),ic=[1,2];ec({target:"Array",proto:!0,forced:String(ic)===String(ic.reverse())},{reverse:function(){return tc(this)&&(this.length=this.length),rc(this)}});var oc=pe,nc=TypeError,ac=T([].slice),sc=ac,cc=Math.floor,lc=function(e,t){var r=e.length;if(r<8)for(var i,o,n=1;n<r;){for(o=n,i=e[n];o&&t(e[o-1],i)>0;)e[o]=e[--o];o!==n++&&(e[o]=i)}else for(var a=cc(r/2),s=lc(sc(e,0,a),t),c=lc(sc(e,a),t),l=s.length,u=c.length,d=0,h=0;d<l||h<u;)e[d+h]=d<l&&h<u?t(s[d],c[h])<=0?s[d++]:c[h++]:d<l?s[d++]:c[h++];return e},uc=lc,dc=J.match(/firefox\/(\d+)/i),hc=!!dc&&+dc[1],pc=/MSIE|Trident/.test(J),mc=J.match(/AppleWebKit\/(\d+)\./),fc=!!mc&&+mc[1],_c=to,gc=T,Ec=ge,vc=Ve,yc=hi,Tc=function(e,t){if(!delete e[t])throw new nc("Cannot delete property "+oc(t)+" of "+oc(e))},Ic=po,Ac=o,Sc=uc,Rc=Ks,bc=hc,wc=pc,Dc=te,Cc=fc,Nc=[],kc=gc(Nc.sort),Oc=gc(Nc.push),Mc=Ac((function(){Nc.sort(void 0)})),Lc=Ac((function(){Nc.sort(null)})),Pc=Rc("sort"),xc=!Ac((function(){if(Dc)return Dc<70;if(!(bc&&bc>3)){if(wc)return!0;if(Cc)return Cc<603;var e,t,r,i,o="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)Nc.push({k:t+i,v:r})}for(Nc.sort((function(e,t){return t.v-e.v})),i=0;i<Nc.length;i++)t=Nc[i].k.charAt(0),o.charAt(o.length-1)!==t&&(o+=t);return"DGBEFHACIJK"!==o}}));_c({target:"Array",proto:!0,forced:Mc||!Lc||!Pc||!xc},{sort:function(e){void 0!==e&&Ec(e);var t=vc(this);if(xc)return void 0===e?kc(t):kc(t,e);var r,i,o=[],n=yc(t);for(i=0;i<n;i++)i in t&&Oc(o,t[i]);for(Sc(o,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Ic(t)>Ic(r)?1:-1}}(e)),r=yc(o),i=0;i<r;)t[i]=o[i++];for(;i<n;)Tc(t,i++);return t}}),la("flat");var Uc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Vc=$r,Fc=function(e,t,r){for(var i in t)Vc(e,i,t[i],r);return e},Bc=K,Hc=TypeError,jc=function(e,t){if(Bc(t,e))return e;throw new Hc("Incorrect invocation")},Gc=ii,Wc=ui,Kc=RangeError,zc=function(e){if(void 0===e)return 0;var t=Gc(e),r=Wc(t);if(t!==r)throw new Kc("Wrong length or index");return r},qc=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},Jc=4503599627370496,Yc=qc,Xc=function(e){return e+Jc-Jc},$c=Math.abs,Qc=function(e,t,r,i){var o=+e,n=$c(o),a=Yc(o);if(n<i)return a*Xc(n/i/t)*i*t;var s=(1+t/2220446049250313e-31)*n,c=s-(s-n);return c>r||c!=c?Infinity*a:a*c},Zc=Math.fround||function(e){return Qc(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},el=Array,tl=Math.abs,rl=Math.pow,il=Math.floor,ol=Math.log,nl=Math.LN2,al={pack:function(e,t,r){var i,o,n,a=el(r),s=8*r-t-1,c=(1<<s)-1,l=c>>1,u=23===t?rl(2,-24)-rl(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=tl(e))!=e||Infinity===e?(o=e!=e?1:0,i=c):(i=il(ol(e)/nl),e*(n=rl(2,-i))<1&&(i--,n*=2),(e+=i+l>=1?u/n:u*rl(2,1-l))*n>=2&&(i++,n/=2),i+l>=c?(o=0,i=c):i+l>=1?(o=(e*n-1)*rl(2,t),i+=l):(o=e*rl(2,l-1)*rl(2,t),i=0));t>=8;)a[h++]=255&o,o/=256,t-=8;for(i=i<<t|o,s+=t;s>0;)a[h++]=255&i,i/=256,s-=8;return a[h-1]|=128*d,a},unpack:function(e,t){var r,i=e.length,o=8*i-t-1,n=(1<<o)-1,a=n>>1,s=o-7,c=i-1,l=e[c--],u=127&l;for(l>>=7;s>0;)u=256*u+e[c--],s-=8;for(r=u&(1<<-s)-1,u>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===u)u=1-a;else{if(u===n)return r?NaN:l?-Infinity:Infinity;r+=rl(2,t),u-=a}return(l?-1:1)*r*rl(2,u-t)}},sl=Ve,cl=si,ll=hi,ul=function(e){for(var t=sl(this),r=ll(t),i=arguments.length,o=cl(i>1?arguments[1]:void 0,r),n=i>2?arguments[2]:void 0,a=void 0===n?r:cl(n,r);a>o;)t[o++]=e;return t},dl=F,hl=H,pl=ts,ml=function(e,t,r){var i,o;return pl&&dl(i=t.constructor)&&i!==r&&hl(o=i.prototype)&&o!==r.prototype&&pl(e,o),e},fl=r,_l=T,gl=n,El=Uc,vl=qt,yl=_o,Tl=Fc,Il=o,Al=jc,Sl=ii,Rl=ui,bl=zc,wl=Zc,Dl=al,Cl=Sa,Nl=ts,kl=ul,Ol=ac,Ml=ml,Ll=Vi,Pl=Ua,xl=Dr,Ul=er.PROPER,Vl=er.CONFIGURABLE,Fl="ArrayBuffer",Bl="DataView",Hl="prototype",jl="Wrong index",Gl=xl.getterFor(Fl),Wl=xl.getterFor(Bl),Kl=xl.set,zl=fl[Fl],ql=zl,Jl=ql&&ql[Hl],Yl=fl[Bl],Xl=Yl&&Yl[Hl],$l=Object.prototype,Ql=fl.Array,Zl=fl.RangeError,eu=_l(kl),tu=_l([].reverse),ru=Dl.pack,iu=Dl.unpack,ou=function(e){return[255&e]},nu=function(e){return[255&e,e>>8&255]},au=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},su=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},cu=function(e){return ru(wl(e),23,4)},lu=function(e){return ru(e,52,8)},uu=function(e,t,r){yl(e[Hl],t,{configurable:!0,get:function(){return r(this)[t]}})},du=function(e,t,r,i){var o=Wl(e),n=bl(r),a=!!i;if(n+t>o.byteLength)throw new Zl(jl);var s=o.bytes,c=n+o.byteOffset,l=Ol(s,c,c+t);return a?l:tu(l)},hu=function(e,t,r,i,o,n){var a=Wl(e),s=bl(r),c=i(+o),l=!!n;if(s+t>a.byteLength)throw new Zl(jl);for(var u=a.bytes,d=s+a.byteOffset,h=0;h<t;h++)u[d+h]=c[l?h:t-h-1]};if(El){var pu=Ul&&zl.name!==Fl;Il((function(){zl(1)}))&&Il((function(){new zl(-1)}))&&!Il((function(){return new zl,new zl(1.5),new zl(NaN),1!==zl.length||pu&&!Vl}))?pu&&Vl&&vl(zl,"name",Fl):((ql=function(e){return Al(this,Jl),Ml(new zl(bl(e)),this,ql)})[Hl]=Jl,Jl.constructor=ql,Ll(ql,zl)),Nl&&Cl(Xl)!==$l&&Nl(Xl,$l);var mu=new Yl(new ql(2)),fu=_l(Xl.setInt8);mu.setInt8(0,2147483648),mu.setInt8(1,2147483649),!mu.getInt8(0)&&mu.getInt8(1)||Tl(Xl,{setInt8:function(e,t){fu(this,e,t<<24>>24)},setUint8:function(e,t){fu(this,e,t<<24>>24)}},{unsafe:!0})}else Jl=(ql=function(e){Al(this,Jl);var t=bl(e);Kl(this,{type:Fl,bytes:eu(Ql(t),0),byteLength:t}),gl||(this.byteLength=t,this.detached=!1)})[Hl],Xl=(Yl=function(e,t,r){Al(this,Xl),Al(e,Jl);var i=Gl(e),o=i.byteLength,n=Sl(t);if(n<0||n>o)throw new Zl("Wrong offset");if(n+(r=void 0===r?o-n:Rl(r))>o)throw new Zl("Wrong length");Kl(this,{type:Bl,buffer:e,byteLength:r,byteOffset:n,bytes:i.bytes}),gl||(this.buffer=e,this.byteLength=r,this.byteOffset=n)})[Hl],gl&&(uu(ql,"byteLength",Gl),uu(Yl,"buffer",Wl),uu(Yl,"byteLength",Wl),uu(Yl,"byteOffset",Wl)),Tl(Xl,{getInt8:function(e){return du(this,1,e)[0]<<24>>24},getUint8:function(e){return du(this,1,e)[0]},getInt16:function(e){var t=du(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=du(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return su(du(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return su(du(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return iu(du(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return iu(du(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){hu(this,1,e,ou,t)},setUint8:function(e,t){hu(this,1,e,ou,t)},setInt16:function(e,t){hu(this,2,e,nu,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){hu(this,2,e,nu,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){hu(this,4,e,au,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){hu(this,4,e,au,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){hu(this,4,e,cu,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){hu(this,8,e,lu,t,arguments.length>2&&arguments[2])}});Pl(ql,Fl),Pl(Yl,Bl);var _u={ArrayBuffer:ql,DataView:Yl},gu=W,Eu=_o,vu=n,yu=tt("species"),Tu=function(e){var t=gu(e);vu&&t&&!t[yu]&&Eu(t,yu,{configurable:!0,get:function(){return this}})},Iu=Tu,Au="ArrayBuffer",Su=_u[Au];to({global:!0,constructor:!0,forced:r[Au]!==Su},{ArrayBuffer:Su}),Iu(Au);var Ru=to,bu=Yo,wu=o,Du=Mt,Cu=si,Nu=ui,ku=_u.ArrayBuffer,Ou=_u.DataView,Mu=Ou.prototype,Lu=bu(ku.prototype.slice),Pu=bu(Mu.getUint8),xu=bu(Mu.setUint8);Ru({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wu((function(){return!new ku(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Lu&&void 0===t)return Lu(Du(this),e);for(var r=Du(this).byteLength,i=Cu(e,r),o=Cu(void 0===t?r:t,r),n=new ku(Nu(o-i)),a=new Ou(this),s=new Ou(n),c=0;i<o;)xu(s,c++,Pu(a,i++));return n}});var Uu,Vu,Fu,Bu,Hu=vn,ju=pe,Gu=TypeError,Wu=function(e){if(Hu(e))return e;throw new Gu(ju(e)+" is not a constructor")},Ku=Mt,zu=Wu,qu=k,Ju=tt("species"),Yu=function(e,t){var r,i=Ku(e).constructor;return void 0===i||qu(r=Ku(i)[Ju])?t:zu(r)},Xu=a,$u=Function.prototype,Qu=$u.apply,Zu=$u.call,ed="object"==typeof Reflect&&Reflect.apply||(Xu?Zu.bind(Qu):function(){return Zu.apply(Qu,arguments)}),td=TypeError,rd=function(e,t){if(e<t)throw new td("Not enough arguments");return e},id=/(?:ipad|iphone|ipod).*applewebkit/i.test(J),od=r,nd=ed,ad=Zo,sd=F,cd=He,ld=o,ud=Gn,dd=ac,hd=_t,pd=rd,md=id,fd=$s,_d=od.setImmediate,gd=od.clearImmediate,Ed=od.process,vd=od.Dispatch,yd=od.Function,Td=od.MessageChannel,Id=od.String,Ad=0,Sd={},Rd="onreadystatechange";ld((function(){Uu=od.location}));var bd=function(e){if(cd(Sd,e)){var t=Sd[e];delete Sd[e],t()}},wd=function(e){return function(){bd(e)}},Dd=function(e){bd(e.data)},Cd=function(e){od.postMessage(Id(e),Uu.protocol+"//"+Uu.host)};_d&&gd||(_d=function(e){pd(arguments.length,1);var t=sd(e)?e:yd(e),r=dd(arguments,1);return Sd[++Ad]=function(){nd(t,void 0,r)},Vu(Ad),Ad},gd=function(e){delete Sd[e]},fd?Vu=function(e){Ed.nextTick(wd(e))}:vd&&vd.now?Vu=function(e){vd.now(wd(e))}:Td&&!md?(Bu=(Fu=new Td).port2,Fu.port1.onmessage=Dd,Vu=ad(Bu.postMessage,Bu)):od.addEventListener&&sd(od.postMessage)&&!od.importScripts&&Uu&&"file:"!==Uu.protocol&&!ld(Cd)?(Vu=Cd,od.addEventListener("message",Dd,!1)):Vu=Rd in hd("script")?function(e){ud.appendChild(hd("script"))[Rd]=function(){ud.removeChild(this),bd(e)}}:function(e){setTimeout(wd(e),0)});var Nd={set:_d,clear:gd},kd=r,Od=n,Md=Object.getOwnPropertyDescriptor,Ld=function(e){if(!Od)return kd[e];var t=Md(kd,e);return t&&t.value},Pd=function(){this.head=null,this.tail=null};Pd.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 xd,Ud,Vd,Fd,Bd,Hd=Pd,jd=/ipad|iphone|ipod/i.test(J)&&"undefined"!=typeof Pebble,Gd=/web0s(?!.*chrome)/i.test(J),Wd=r,Kd=Ld,zd=Zo,qd=Nd.set,Jd=Hd,Yd=id,Xd=jd,$d=Gd,Qd=$s,Zd=Wd.MutationObserver||Wd.WebKitMutationObserver,eh=Wd.document,th=Wd.process,rh=Wd.Promise,ih=Kd("queueMicrotask");if(!ih){var oh=new Jd,nh=function(){var e,t;for(Qd&&(e=th.domain)&&e.exit();t=oh.get();)try{t()}catch(Uj){throw oh.head&&xd(),Uj}e&&e.enter()};Yd||Qd||$d||!Zd||!eh?!Xd&&rh&&rh.resolve?((Fd=rh.resolve(void 0)).constructor=rh,Bd=zd(Fd.then,Fd),xd=function(){Bd(nh)}):Qd?xd=function(){th.nextTick(nh)}:(qd=zd(qd,Wd),xd=function(){qd(nh)}):(Ud=!0,Vd=eh.createTextNode(""),new Zd(nh).observe(Vd,{characterData:!0}),xd=function(){Vd.data=Ud=!Ud}),ih=function(e){oh.head||xd(),oh.add(e)}}var ah=ih,sh=function(e){try{return{error:!1,value:e()}}catch(Uj){return{error:!0,value:Uj}}},ch=r.Promise,lh=r,uh=ch,dh=F,hh=qi,ph=sr,mh=tt,fh=Xs,_h=te;uh&&uh.prototype;var gh=mh("species"),Eh=!1,vh=dh(lh.PromiseRejectionEvent),yh=hh("Promise",(function(){var e=ph(uh),t=e!==String(uh);if(!t&&66===_h)return!0;if(!_h||_h<51||!/native code/.test(e)){var r=new uh((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[gh]=i,!(Eh=r.then((function(){}))instanceof i))return!0}return!(t||"BROWSER"!==fh&&"DENO"!==fh||vh)})),Th={CONSTRUCTOR:yh,REJECTION_EVENT:vh,SUBCLASSING:Eh},Ih={},Ah=ge,Sh=TypeError,Rh=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw new Sh("Bad Promise constructor");t=e,r=i})),this.resolve=Ah(t),this.reject=Ah(r)};Ih.f=function(e){return new Rh(e)};var bh,wh,Dh,Ch=to,Nh=$s,kh=r,Oh=l,Mh=$r,Lh=ts,Ph=Ua,xh=Tu,Uh=ge,Vh=F,Fh=H,Bh=jc,Hh=Yu,jh=Nd.set,Gh=ah,Wh=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(Uj){}},Kh=sh,zh=Hd,qh=Dr,Jh=ch,Yh=Ih,Xh="Promise",$h=Th.CONSTRUCTOR,Qh=Th.REJECTION_EVENT,Zh=Th.SUBCLASSING,ep=qh.getterFor(Xh),tp=qh.set,rp=Jh&&Jh.prototype,ip=Jh,op=rp,np=kh.TypeError,ap=kh.document,sp=kh.process,cp=Yh.f,lp=cp,up=!!(ap&&ap.createEvent&&kh.dispatchEvent),dp="unhandledrejection",hp=function(e){var t;return!(!Fh(e)||!Vh(t=e.then))&&t},pp=function(e,t){var r,i,o,n=t.value,a=1===t.state,s=a?e.ok:e.fail,c=e.resolve,l=e.reject,u=e.domain;try{s?(a||(2===t.rejection&&Ep(t),t.rejection=1),!0===s?r=n:(u&&u.enter(),r=s(n),u&&(u.exit(),o=!0)),r===e.promise?l(new np("Promise-chain cycle")):(i=hp(r))?Oh(i,r,c,l):c(r)):l(n)}catch(Uj){u&&!o&&u.exit(),l(Uj)}},mp=function(e,t){e.notified||(e.notified=!0,Gh((function(){for(var r,i=e.reactions;r=i.get();)pp(r,e);e.notified=!1,t&&!e.rejection&&_p(e)})))},fp=function(e,t,r){var i,o;up?((i=ap.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),kh.dispatchEvent(i)):i={promise:t,reason:r},!Qh&&(o=kh["on"+e])?o(i):e===dp&&Wh("Unhandled promise rejection",r)},_p=function(e){Oh(jh,kh,(function(){var t,r=e.facade,i=e.value;if(gp(e)&&(t=Kh((function(){Nh?sp.emit("unhandledRejection",i,r):fp(dp,r,i)})),e.rejection=Nh||gp(e)?2:1,t.error))throw t.value}))},gp=function(e){return 1!==e.rejection&&!e.parent},Ep=function(e){Oh(jh,kh,(function(){var t=e.facade;Nh?sp.emit("rejectionHandled",t):fp("rejectionhandled",t,e.value)}))},vp=function(e,t,r){return function(i){e(t,i,r)}},yp=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,mp(e,!0))},Tp=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new np("Promise can't be resolved itself");var i=hp(t);i?Gh((function(){var r={done:!1};try{Oh(i,t,vp(Tp,r,e),vp(yp,r,e))}catch(Uj){yp(r,Uj,e)}})):(e.value=t,e.state=1,mp(e,!1))}catch(Uj){yp({done:!1},Uj,e)}}};if($h&&(op=(ip=function(e){Bh(this,op),Uh(e),Oh(bh,this);var t=ep(this);try{e(vp(Tp,t),vp(yp,t))}catch(Uj){yp(t,Uj)}}).prototype,(bh=function(e){tp(this,{type:Xh,done:!1,notified:!1,parent:!1,reactions:new zh,rejection:!1,state:0,value:null})}).prototype=Mh(op,"then",(function(e,t){var r=ep(this),i=cp(Hh(this,ip));return r.parent=!0,i.ok=!Vh(e)||e,i.fail=Vh(t)&&t,i.domain=Nh?sp.domain:void 0,0===r.state?r.reactions.add(i):Gh((function(){pp(i,r)})),i.promise})),wh=function(){var e=new bh,t=ep(e);this.promise=e,this.resolve=vp(Tp,t),this.reject=vp(yp,t)},Yh.f=cp=function(e){return e===ip||undefined===e?new wh(e):lp(e)},Vh(Jh)&&rp!==Object.prototype)){Dh=rp.then,Zh||Mh(rp,"then",(function(e,t){var r=this;return new ip((function(e,t){Oh(Dh,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete rp.constructor}catch(Uj){}Lh&&Lh(rp,op)}Ch({global:!0,constructor:!0,wrap:!0,forced:$h},{Promise:ip}),Ph(ip,Xh,!1),xh(Xh);var Ip=fa,Ap=tt("iterator"),Sp=Array.prototype,Rp=function(e){return void 0!==e&&(Ip.Array===e||Sp[Ap]===e)},bp=lo,wp=ye,Dp=k,Cp=fa,Np=tt("iterator"),kp=function(e){if(!Dp(e))return wp(e,Np)||wp(e,"@@iterator")||Cp[bp(e)]},Op=l,Mp=ge,Lp=Mt,Pp=pe,xp=kp,Up=TypeError,Vp=function(e,t){var r=arguments.length<2?xp(e):t;if(Mp(r))return Lp(Op(r,e));throw new Up(Pp(e)+" is not iterable")},Fp=l,Bp=Mt,Hp=ye,jp=function(e,t,r){var i,o;Bp(e);try{if(!(i=Hp(e,"return"))){if("throw"===t)throw r;return r}i=Fp(i,e)}catch(Uj){o=!0,i=Uj}if("throw"===t)throw r;if(o)throw i;return Bp(i),r},Gp=Zo,Wp=l,Kp=Mt,zp=pe,qp=Rp,Jp=hi,Yp=K,Xp=Vp,$p=kp,Qp=jp,Zp=TypeError,em=function(e,t){this.stopped=e,this.result=t},tm=em.prototype,rm=function(e,t,r){var i,o,n,a,s,c,l,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),m=!(!r||!r.INTERRUPTED),f=Gp(t,u),_=function(e){return i&&Qp(i,"normal",e),new em(!0,e)},g=function(e){return d?(Kp(e),m?f(e[0],e[1],_):f(e[0],e[1])):m?f(e,_):f(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(o=$p(e)))throw new Zp(zp(e)+" is not iterable");if(qp(o)){for(n=0,a=Jp(e);a>n;n++)if((s=g(e[n]))&&Yp(tm,s))return s;return new em(!1)}i=Xp(e,o)}for(c=h?e.next:i.next;!(l=Wp(c,i)).done;){try{s=g(l.value)}catch(Uj){Qp(i,"throw",Uj)}if("object"==typeof s&&s&&Yp(tm,s))return s}return new em(!1)},im=tt("iterator"),om=!1;try{var nm=0,am={next:function(){return{done:!!nm++}},return:function(){om=!0}};am[im]=function(){return this},Array.from(am,(function(){throw 2}))}catch(Uj){}var sm=function(e,t){try{if(!t&&!om)return!1}catch(Uj){return!1}var r=!1;try{var i={};i[im]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(Uj){}return r},cm=ch,lm=Th.CONSTRUCTOR||!sm((function(e){cm.all(e).then(void 0,(function(){}))})),um=l,dm=ge,hm=Ih,pm=sh,mm=rm;to({target:"Promise",stat:!0,forced:lm},{all:function(e){var t=this,r=hm.f(t),i=r.resolve,o=r.reject,n=pm((function(){var r=dm(t.resolve),n=[],a=0,s=1;mm(e,(function(e){var c=a++,l=!1;s++,um(r,t,e).then((function(e){l||(l=!0,n[c]=e,--s||i(n))}),o)})),--s||i(n)}));return n.error&&o(n.value),r.promise}});var fm=to,_m=Th.CONSTRUCTOR,gm=ch,Em=W,vm=F,ym=$r,Tm=gm&&gm.prototype;if(fm({target:"Promise",proto:!0,forced:_m,real:!0},{catch:function(e){return this.then(void 0,e)}}),vm(gm)){var Im=Em("Promise").prototype.catch;Tm.catch!==Im&&ym(Tm,"catch",Im,{unsafe:!0})}var Am=l,Sm=ge,Rm=Ih,bm=sh,wm=rm;to({target:"Promise",stat:!0,forced:lm},{race:function(e){var t=this,r=Rm.f(t),i=r.reject,o=bm((function(){var o=Sm(t.resolve);wm(e,(function(e){Am(o,t,e).then(r.resolve,i)}))}));return o.error&&i(o.value),r.promise}});var Dm=Ih;to({target:"Promise",stat:!0,forced:Th.CONSTRUCTOR},{reject:function(e){var t=Dm.f(this);return(0,t.reject)(e),t.promise}});var Cm=Mt,Nm=H,km=Ih,Om=function(e,t){if(Cm(e),Nm(t)&&t.constructor===e)return t;var r=km.f(e);return(0,r.resolve)(t),r.promise},Mm=to,Lm=Th.CONSTRUCTOR,Pm=Om;W("Promise"),Mm({target:"Promise",stat:!0,forced:Lm},{resolve:function(e){return Pm(this,e)}});var xm=to,Um=ch,Vm=o,Fm=W,Bm=F,Hm=Yu,jm=Om,Gm=$r,Wm=Um&&Um.prototype;if(xm({target:"Promise",proto:!0,real:!0,forced:!!Um&&Vm((function(){Wm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hm(this,Fm("Promise")),r=Bm(e);return this.then(r?function(r){return jm(t,e()).then((function(){return r}))}:e,r?function(r){return jm(t,e()).then((function(){throw r}))}:e)}}),Bm(Um)){var Km=Fm("Promise").prototype.finally;Wm.finally!==Km&&Gm(Wm,"finally",Km,{unsafe:!0})}var zm=H,qm=R,Jm=tt("match"),Ym=function(e){var t;return zm(e)&&(void 0!==(t=e[Jm])?!!t:"RegExp"===qm(e))},Xm=Mt,$m=function(){var e=Xm(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Qm=l,Zm=He,ef=K,tf=$m,rf=RegExp.prototype,of=function(e){var t=e.flags;return void 0!==t||"flags"in rf||Zm(e,"flags")||!ef(rf,e)?t:Qm(tf,e)},nf=o,af=r.RegExp,sf=nf((function(){var e=af("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),cf=sf||nf((function(){return!af("a","y").sticky})),lf={BROKEN_CARET:sf||nf((function(){var e=af("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),MISSED_STICKY:cf,UNSUPPORTED_Y:sf},uf=Dt.f,df=o,hf=r.RegExp,pf=df((function(){var e=hf(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),mf=o,ff=r.RegExp,_f=mf((function(){var e=ff("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),gf=n,Ef=r,vf=T,yf=qi,Tf=ml,If=qt,Af=ia,Sf=Qr.f,Rf=K,bf=Ym,wf=po,Df=of,Cf=lf,Nf=function(e,t,r){r in e||uf(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},kf=$r,Of=o,Mf=He,Lf=Dr.enforce,Pf=Tu,xf=pf,Uf=_f,Vf=tt("match"),Ff=Ef.RegExp,Bf=Ff.prototype,Hf=Ef.SyntaxError,jf=vf(Bf.exec),Gf=vf("".charAt),Wf=vf("".replace),Kf=vf("".indexOf),zf=vf("".slice),qf=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Jf=/a/g,Yf=/a/g,Xf=new Ff(Jf)!==Jf,$f=Cf.MISSED_STICKY,Qf=Cf.UNSUPPORTED_Y,Zf=gf&&(!Xf||$f||xf||Uf||Of((function(){return Yf[Vf]=!1,Ff(Jf)!==Jf||Ff(Yf)===Yf||"/a/i"!==String(Ff(Jf,"i"))})));if(yf("RegExp",Zf)){for(var e_=function(e,t){var r,i,o,n,a,s,c=Rf(Bf,this),l=bf(e),u=void 0===t,d=[],h=e;if(!c&&l&&u&&e.constructor===e_)return e;if((l||Rf(Bf,e))&&(e=e.source,u&&(t=Df(h))),e=void 0===e?"":wf(e),t=void 0===t?"":wf(t),h=e,xf&&"dotAll"in Jf&&(i=!!t&&Kf(t,"s")>-1)&&(t=Wf(t,/s/g,"")),r=t,$f&&"sticky"in Jf&&(o=!!t&&Kf(t,"y")>-1)&&Qf&&(t=Wf(t,/y/g,"")),Uf&&(n=function(e){for(var t,r=e.length,i=0,o="",n=[],a=Af(null),s=!1,c=!1,l=0,u="";i<=r;i++){if("\\"===(t=Gf(e,i)))t+=Gf(e,++i);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(o+=t,"?:"===zf(e,i+1,i+3))continue;jf(qf,zf(e,i+1))&&(i+=2,c=!0),l++;continue;case">"===t&&c:if(""===u||Mf(a,u))throw new Hf("Invalid capture group name");a[u]=!0,n[n.length]=[u,l],c=!1,u="";continue}c?u+=t:o+=t}return[o,n]}(e),e=n[0],d=n[1]),a=Tf(Ff(e,t),c?this:Bf,e_),(i||o||d.length)&&(s=Lf(a),i&&(s.dotAll=!0,s.raw=e_(function(e){for(var t,r=e.length,i=0,o="",n=!1;i<=r;i++)"\\"!==(t=Gf(e,i))?n||"."!==t?("["===t?n=!0:"]"===t&&(n=!1),o+=t):o+="[\\s\\S]":o+=t+Gf(e,++i);return o}(e),r)),o&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{If(a,"source",""===h?"(?:)":h)}catch(Uj){}return a},t_=Sf(Ff),r_=0;t_.length>r_;)Nf(e_,Ff,t_[r_++]);Bf.constructor=e_,e_.prototype=Bf,kf(Ef,"RegExp",e_,{constructor:!0})}Pf("RegExp");var i_=l,o_=T,n_=po,a_=$m,s_=lf,c_=ia,l_=Dr.get,u_=pf,d_=_f,h_=Pe("native-string-replace",String.prototype.replace),p_=RegExp.prototype.exec,m_=p_,f_=o_("".charAt),__=o_("".indexOf),g_=o_("".replace),E_=o_("".slice),v_=function(){var e=/a/,t=/b*/g;return i_(p_,e,"a"),i_(p_,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),y_=s_.BROKEN_CARET,T_=void 0!==/()??/.exec("")[1];(v_||T_||y_||u_||d_)&&(m_=function(e){var t,r,i,o,n,a,s,c=this,l=l_(c),u=n_(e),d=l.raw;if(d)return d.lastIndex=c.lastIndex,t=i_(m_,d,u),c.lastIndex=d.lastIndex,t;var h=l.groups,p=y_&&c.sticky,m=i_(a_,c),f=c.source,_=0,g=u;if(p&&(m=g_(m,"y",""),-1===__(m,"g")&&(m+="g"),g=E_(u,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==f_(u,c.lastIndex-1))&&(f="(?: "+f+")",g=" "+g,_++),r=new RegExp("^(?:"+f+")",m)),T_&&(r=new RegExp("^"+f+"$(?!\\s)",m)),v_&&(i=c.lastIndex),o=i_(p_,p?r:c,g),p?o?(o.input=E_(o.input,_),o[0]=E_(o[0],_),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:v_&&o&&(c.lastIndex=c.global?o.index+o[0].length:i),T_&&o&&o.length>1&&i_(h_,o[0],r,(function(){for(n=1;n<arguments.length-2;n++)void 0===arguments[n]&&(o[n]=void 0)})),o&&h)for(o.groups=a=c_(null),n=0;n<h.length;n++)a[(s=h[n])[0]]=o[s[1]];return o});var I_=m_;to({target:"RegExp",proto:!0,forced:/./.exec!==I_},{exec:I_});var A_=n,S_=_o,R_=$m,b_=o,w_=r.RegExp,D_=w_.prototype,C_=A_&&b_((function(){var e=!0;try{w_(".","d")}catch(Uj){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",o=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(n.hasIndices="d"),n)o(a,n[a]);return Object.getOwnPropertyDescriptor(D_,"flags").get.call(t)!==i||r!==i}));C_&&S_(D_,"flags",{configurable:!0,get:R_});var N_=ii,k_=po,O_=L,M_=RangeError,L_=T,P_=ui,x_=po,U_=function(e){var t=k_(O_(this)),r="",i=N_(e);if(i<0||Infinity===i)throw new M_("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r},V_=L,F_=L_(U_),B_=L_("".slice),H_=Math.ceil,j_=function(e){return function(t,r,i){var o,n,a=x_(V_(t)),s=P_(r),c=a.length,l=void 0===i?" ":x_(i);return s<=c||""===l?a:((n=F_(l,H_((o=s-c)/l.length))).length>o&&(n=B_(n,0,o)),e?a+n:n+a)}},G_={start:j_(!1),end:j_(!0)},W_=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(J),K_=G_.start;to({target:"String",proto:!0,forced:W_},{padStart:function(e){return K_(this,e,arguments.length>1?arguments[1]:void 0)}});var z_=l,q_=$r,J_=I_,Y_=o,X_=tt,$_=qt,Q_=X_("species"),Z_=RegExp.prototype,eg=T,tg=ii,rg=po,ig=L,og=eg("".charAt),ng=eg("".charCodeAt),ag=eg("".slice),sg=function(e){return function(t,r){var i,o,n=rg(ig(t)),a=tg(r),s=n.length;return a<0||a>=s?e?"":void 0:(i=ng(n,a))<55296||i>56319||a+1===s||(o=ng(n,a+1))<56320||o>57343?e?og(n,a):i:e?ag(n,a,a+2):o-56320+(i-55296<<10)+65536}},cg={codeAt:sg(!1),charAt:sg(!0)},lg=cg.charAt,ug=T,dg=Ve,hg=Math.floor,pg=ug("".charAt),mg=ug("".replace),fg=ug("".slice),_g=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,gg=/\$([$&'`]|\d{1,2})/g,Eg=function(e,t,r,i,o,n){var a=r+e.length,s=i.length,c=gg;return void 0!==o&&(o=dg(o),c=_g),mg(n,c,(function(n,c){var l;switch(pg(c,0)){case"$":return"$";case"&":return e;case"`":return fg(t,0,r);case"'":return fg(t,a);case"<":l=o[fg(c,1,-1)];break;default:var u=+c;if(0===u)return n;if(u>s){var d=hg(u/10);return 0===d?n:d<=s?void 0===i[d-1]?pg(c,1):i[d-1]+pg(c,1):n}l=i[u-1]}return void 0===l?"":l}))},vg=l,yg=Mt,Tg=F,Ig=R,Ag=I_,Sg=TypeError,Rg=ed,bg=l,wg=T,Dg=function(e,t,r,i){var o=X_(e),n=!Y_((function(){var t={};return t[o]=function(){return 7},7!==""[e](t)})),a=n&&!Y_((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Q_]=function(){return r},r.flags="",r[o]=/./[o]),r.exec=function(){return t=!0,null},r[o](""),!t}));if(!n||!a||r){var s=/./[o],c=t(o,""[e],(function(e,t,r,i,o){var a=t.exec;return a===J_||a===Z_.exec?n&&!o?{done:!0,value:z_(s,t,r,i)}:{done:!0,value:z_(e,r,t,i)}:{done:!1}}));q_(String.prototype,e,c[0]),q_(Z_,o,c[1])}i&&$_(Z_[o],"sham",!0)},Cg=o,Ng=Mt,kg=F,Og=k,Mg=ii,Lg=ui,Pg=po,xg=L,Ug=function(e,t,r){return t+(r?lg(e,t).length:1)},Vg=ye,Fg=Eg,Bg=function(e,t){var r=e.exec;if(Tg(r)){var i=vg(r,e,t);return null!==i&&yg(i),i}if("RegExp"===Ig(e))return vg(Ag,e,t);throw new Sg("RegExp#exec called on incompatible receiver")},Hg=tt("replace"),jg=Math.max,Gg=Math.min,Wg=wg([].concat),Kg=wg([].push),zg=wg("".indexOf),qg=wg("".slice),Jg=function(e){return void 0===e?e:String(e)},Yg="$0"==="a".replace(/./,"$0"),Xg=!!/./[Hg]&&""===/./[Hg]("a","$0");Dg("replace",(function(e,t,r){var i=Xg?"$":"$0";return[function(e,r){var i=xg(this),o=Og(e)?void 0:Vg(e,Hg);return o?bg(o,e,i,r):bg(t,Pg(i),e,r)},function(e,o){var n=Ng(this),a=Pg(e);if("string"==typeof o&&-1===zg(o,i)&&-1===zg(o,"$<")){var s=r(t,n,a,o);if(s.done)return s.value}var c=kg(o);c||(o=Pg(o));var l,u=n.global;u&&(l=n.unicode,n.lastIndex=0);for(var d,h=[];null!==(d=Bg(n,a))&&(Kg(h,d),u);){""===Pg(d[0])&&(n.lastIndex=Ug(a,Lg(n.lastIndex),l))}for(var p="",m=0,f=0;f<h.length;f++){for(var _,g=Pg((d=h[f])[0]),E=jg(Gg(Mg(d.index),a.length),0),v=[],y=1;y<d.length;y++)Kg(v,Jg(d[y]));var T=d.groups;if(c){var I=Wg([g],v,E,a);void 0!==T&&Kg(I,T),_=Pg(Rg(o,void 0,I))}else _=Fg(g,a,E,v,T,o);E>=m&&(p+=qg(a,m,E)+_,m=E+g.length)}return p+qg(a,m)}]}),!!Cg((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!Yg||Xg);var $g="\t\n\v\f\r \u2028\u2029\ufeff",Qg=L,Zg=po,eE=$g,tE=T("".replace),rE=RegExp("^["+eE+"]+"),iE=RegExp("(^|[^"+eE+"])["+eE+"]+$"),oE=function(e){return function(t){var r=Zg(Qg(t));return 1&e&&(r=tE(r,rE,"")),2&e&&(r=tE(r,iE,"$1")),r}},nE={start:oE(1),end:oE(2),trim:oE(3)},aE=er.PROPER,sE=o,cE=$g,lE=nE.trim;to({target:"String",proto:!0,forced:function(e){return sE((function(){return!!cE[e]()||"
"!=="
"[e]()||aE&&cE[e].name!==e}))}("trim")},{trim:function(){return lE(this)}});var uE,dE,hE,pE={exports:{}},mE=Uc,fE=n,_E=r,gE=F,EE=H,vE=He,yE=lo,TE=pe,IE=qt,AE=$r,SE=_o,RE=K,bE=Sa,wE=ts,DE=tt,CE=ze,NE=Dr.enforce,kE=Dr.get,OE=_E.Int8Array,ME=OE&&OE.prototype,LE=_E.Uint8ClampedArray,PE=LE&&LE.prototype,xE=OE&&bE(OE),UE=ME&&bE(ME),VE=Object.prototype,FE=_E.TypeError,BE=DE("toStringTag"),HE=CE("TYPED_ARRAY_TAG"),jE="TypedArrayConstructor",GE=mE&&!!wE&&"Opera"!==yE(_E.opera),WE=!1,KE={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},zE={BigInt64Array:8,BigUint64Array:8},qE=function(e){var t=bE(e);if(EE(t)){var r=kE(t);return r&&vE(r,jE)?r[jE]:qE(t)}},JE=function(e){if(!EE(e))return!1;var t=yE(e);return vE(KE,t)||vE(zE,t)};for(uE in KE)(hE=(dE=_E[uE])&&dE.prototype)?NE(hE)[jE]=dE:GE=!1;for(uE in zE)(hE=(dE=_E[uE])&&dE.prototype)&&(NE(hE)[jE]=dE);if((!GE||!gE(xE)||xE===Function.prototype)&&(xE=function(){throw new FE("Incorrect invocation")},GE))for(uE in KE)_E[uE]&&wE(_E[uE],xE);if((!GE||!UE||UE===VE)&&(UE=xE.prototype,GE))for(uE in KE)_E[uE]&&wE(_E[uE].prototype,UE);if(GE&&bE(PE)!==UE&&wE(PE,UE),fE&&!vE(UE,BE))for(uE in WE=!0,SE(UE,BE,{configurable:!0,get:function(){return EE(this)?this[HE]:void 0}}),KE)_E[uE]&&IE(_E[uE],HE,uE);var YE={NATIVE_ARRAY_BUFFER_VIEWS:GE,TYPED_ARRAY_TAG:WE&&HE,aTypedArray:function(e){if(JE(e))return e;throw new FE("Target is not a typed array")},aTypedArrayConstructor:function(e){if(gE(e)&&(!wE||RE(xE,e)))return e;throw new FE(TE(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(fE){if(r)for(var o in KE){var n=_E[o];if(n&&vE(n.prototype,e))try{delete n.prototype[e]}catch(Uj){try{n.prototype[e]=t}catch(a){}}}UE[e]&&!r||AE(UE,e,r?t:GE&&ME[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,o;if(fE){if(wE){if(r)for(i in KE)if((o=_E[i])&&vE(o,e))try{delete o[e]}catch(Uj){}if(xE[e]&&!r)return;try{return AE(xE,e,r?t:GE&&xE[e]||t)}catch(Uj){}}for(i in KE)!(o=_E[i])||o[e]&&!r||AE(o,e,t)}},getTypedArrayConstructor:qE,isView:function(e){if(!EE(e))return!1;var t=yE(e);return"DataView"===t||vE(KE,t)||vE(zE,t)},isTypedArray:JE,TypedArray:xE,TypedArrayPrototype:UE},XE=r,$E=o,QE=sm,ZE=YE.NATIVE_ARRAY_BUFFER_VIEWS,ev=XE.ArrayBuffer,tv=XE.Int8Array,rv=!ZE||!$E((function(){tv(1)}))||!$E((function(){new tv(-1)}))||!QE((function(e){new tv,new tv(null),new tv(1.5),new tv(e)}),!0)||$E((function(){return 1!==new tv(new ev(2),1,void 0).length})),iv=H,ov=Math.floor,nv=Number.isInteger||function(e){return!iv(e)&&isFinite(e)&&ov(e)===e},av=ii,sv=RangeError,cv=function(e){var t=av(e);if(t<0)throw new sv("The argument can't be less than 0");return t},lv=RangeError,uv=function(e,t){var r=cv(e);if(r%t)throw new lv("Wrong offset");return r},dv=Math.round,hv=lo,pv=lt,mv=TypeError,fv=function(e){var t=pv(e,"number");if("number"==typeof t)throw new mv("Can't convert number to bigint");return BigInt(t)},_v=Zo,gv=l,Ev=Wu,vv=Ve,yv=hi,Tv=Vp,Iv=kp,Av=Rp,Sv=function(e){var t=hv(e);return"BigInt64Array"===t||"BigUint64Array"===t},Rv=YE.aTypedArrayConstructor,bv=fv,wv=Zo,Dv=N,Cv=Ve,Nv=hi,kv=bn,Ov=T([].push),Mv=function(e){var t=1===e,r=2===e,i=3===e,o=4===e,n=6===e,a=7===e,s=5===e||n;return function(c,l,u,d){for(var h,p,m=Cv(c),f=Dv(m),_=Nv(f),g=wv(l,u),E=0,v=d||kv,y=t?v(c,_):r||a?v(c,0):void 0;_>E;E++)if((s||E in f)&&(p=g(h=f[E],E,m),e))if(t)y[E]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:Ov(y,h)}else switch(e){case 4:return!1;case 7:Ov(y,h)}return n?-1:i||o?o:y}},Lv={forEach:Mv(0),map:Mv(1),filter:Mv(2),some:Mv(3),every:Mv(4),find:Mv(5),findIndex:Mv(6),filterReject:Mv(7)},Pv=hi,xv=to,Uv=r,Vv=l,Fv=n,Bv=rv,Hv=YE,jv=_u,Gv=jc,Wv=_,Kv=qt,zv=nv,qv=ui,Jv=zc,Yv=uv,Xv=function(e){var t=dv(e);return t<0?0:t>255?255:255&t},$v=ht,Qv=He,Zv=lo,ey=H,ty=de,ry=ia,iy=K,oy=ts,ny=Qr.f,ay=function(e){var t,r,i,o,n,a,s,c,l=Ev(this),u=vv(e),d=arguments.length,h=d>1?arguments[1]:void 0,p=void 0!==h,m=Iv(u);if(m&&!Av(m))for(c=(s=Tv(u,m)).next,u=[];!(a=gv(c,s)).done;)u.push(a.value);for(p&&d>2&&(h=_v(h,arguments[2])),r=yv(u),i=new(Rv(l))(r),o=Sv(i),t=0;r>t;t++)n=p?h(u[t],t):u[t],i[t]=o?bv(n):+n;return i},sy=Lv.forEach,cy=Tu,ly=_o,uy=Dt,dy=i,hy=function(e,t,r){for(var i=0,o=arguments.length>2?r:Pv(t),n=new e(o);o>i;)n[i]=t[i++];return n},py=ml,my=Dr.get,fy=Dr.set,_y=Dr.enforce,gy=uy.f,Ey=dy.f,vy=Uv.RangeError,yy=jv.ArrayBuffer,Ty=yy.prototype,Iy=jv.DataView,Ay=Hv.NATIVE_ARRAY_BUFFER_VIEWS,Sy=Hv.TYPED_ARRAY_TAG,Ry=Hv.TypedArray,by=Hv.TypedArrayPrototype,wy=Hv.isTypedArray,Dy="BYTES_PER_ELEMENT",Cy="Wrong length",Ny=function(e,t){ly(e,t,{configurable:!0,get:function(){return my(this)[t]}})},ky=function(e){var t;return iy(Ty,e)||"ArrayBuffer"===(t=Zv(e))||"SharedArrayBuffer"===t},Oy=function(e,t){return wy(e)&&!ty(t)&&t in e&&zv(+t)&&t>=0},My=function(e,t){return t=$v(t),Oy(e,t)?Wv(2,e[t]):Ey(e,t)},Ly=function(e,t,r){return t=$v(t),!(Oy(e,t)&&ey(r)&&Qv(r,"value"))||Qv(r,"get")||Qv(r,"set")||r.configurable||Qv(r,"writable")&&!r.writable||Qv(r,"enumerable")&&!r.enumerable?gy(e,t,r):(e[t]=r.value,e)};Fv?(Ay||(dy.f=My,uy.f=Ly,Ny(by,"buffer"),Ny(by,"byteOffset"),Ny(by,"byteLength"),Ny(by,"length")),xv({target:"Object",stat:!0,forced:!Ay},{getOwnPropertyDescriptor:My,defineProperty:Ly}),pE.exports=function(e,t,r){var i=e.match(/\d+/)[0]/8,o=e+(r?"Clamped":"")+"Array",n="get"+e,a="set"+e,s=Uv[o],c=s,l=c&&c.prototype,u={},d=function(e,t){gy(e,t,{get:function(){return function(e,t){var r=my(e);return r.view[n](t*i+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,o){var n=my(e);n.view[a](t*i+n.byteOffset,r?Xv(o):o,!0)}(this,t,e)},enumerable:!0})};Ay?Bv&&(c=t((function(e,t,r,o){return Gv(e,l),py(ey(t)?ky(t)?void 0!==o?new s(t,Yv(r,i),o):void 0!==r?new s(t,Yv(r,i)):new s(t):wy(t)?hy(c,t):Vv(ay,c,t):new s(Jv(t)),e,c)})),oy&&oy(c,Ry),sy(ny(s),(function(e){e in c||Kv(c,e,s[e])})),c.prototype=l):(c=t((function(e,t,r,o){Gv(e,l);var n,a,s,u=0,h=0;if(ey(t)){if(!ky(t))return wy(t)?hy(c,t):Vv(ay,c,t);n=t,h=Yv(r,i);var p=t.byteLength;if(void 0===o){if(p%i)throw new vy(Cy);if((a=p-h)<0)throw new vy(Cy)}else if((a=qv(o)*i)+h>p)throw new vy(Cy);s=a/i}else s=Jv(t),n=new yy(a=s*i);for(fy(e,{buffer:n,byteOffset:h,byteLength:a,length:s,view:new Iy(n)});u<s;)d(e,u++)})),oy&&oy(c,Ry),l=c.prototype=ry(by)),l.constructor!==c&&Kv(l,"constructor",c),_y(l).TypedArrayConstructor=c,Sy&&Kv(l,Sy,o);var h=c!==s;u[o]=c,xv({global:!0,constructor:!0,forced:h,sham:!Ay},u),Dy in c||Kv(c,Dy,i),Dy in l||Kv(l,Dy,i),cy(o)}):pE.exports=function(){};var Py=pE.exports;Py("Float32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Float64",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Int8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Int16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Int32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}}),!0),Py("Uint16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Py("Uint32",(function(e){return function(t,r,i){return e(this,t,r,i)}}));var xy=ul,Uy=fv,Vy=lo,Fy=l,By=o,Hy=YE.aTypedArray,jy=YE.exportTypedArrayMethod,Gy=T("".slice);jy("fill",(function(e){var t=arguments.length;Hy(this);var r="Big"===Gy(Vy(this),0,3)?Uy(e):+e;return Fy(xy,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),By((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var Wy=r,Ky=l,zy=YE,qy=hi,Jy=uv,Yy=Ve,Xy=o,$y=Wy.RangeError,Qy=Wy.Int8Array,Zy=Qy&&Qy.prototype,eT=Zy&&Zy.set,tT=zy.aTypedArray,rT=zy.exportTypedArrayMethod,iT=!Xy((function(){var e=new Uint8ClampedArray(2);return Ky(eT,e,{length:1,0:3},1),3!==e[1]})),oT=iT&&zy.NATIVE_ARRAY_BUFFER_VIEWS&&Xy((function(){var e=new Qy(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));rT("set",(function(e){tT(this);var t=Jy(arguments.length>1?arguments[1]:void 0,1),r=Yy(e);if(iT)return Ky(eT,this,r,t);var i=this.length,o=qy(r),n=0;if(o+t>i)throw new $y("Wrong length");for(;n<o;)this[t+n]=r[n++]}),!iT||oT);var nT=Yo,aT=o,sT=ge,cT=uc,lT=hc,uT=pc,dT=te,hT=fc,pT=YE.aTypedArray,mT=YE.exportTypedArrayMethod,fT=r.Uint16Array,_T=fT&&nT(fT.prototype.sort),gT=!(!_T||aT((function(){_T(new fT(2),null)}))&&aT((function(){_T(new fT(2),{})}))),ET=!!_T&&!aT((function(){if(dT)return dT<74;if(lT)return lT<67;if(uT)return!0;if(hT)return hT<602;var e,t,r=new fT(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(_T(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==i[e])return!0}));mT("sort",(function(e){return void 0!==e&&sT(e),ET?_T(this,e):cT(pT(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))}),!ET||gT);var vT=to,yT=l,TT=T,IT=L,AT=F,ST=k,RT=Ym,bT=po,wT=ye,DT=of,CT=Eg,NT=tt("replace"),kT=TypeError,OT=TT("".indexOf);TT("".replace);var MT=TT("".slice),LT=Math.max;vT({target:"String",proto:!0},{replaceAll:function(e,t){var r,i,o,n,a,s,c,l,u,d=IT(this),h=0,p="";if(!ST(e)){if(RT(e)&&(r=bT(IT(DT(e))),!~OT(r,"g")))throw new kT("`.replaceAll` does not allow non-global regexes");if(i=wT(e,NT))return yT(i,e,d,t)}for(o=bT(d),n=bT(e),(a=AT(t))||(t=bT(t)),s=n.length,c=LT(1,s),l=OT(o,n);-1!==l;)u=a?bT(t(n,l,o)):CT(n,o,l,[],void 0,t),p+=MT(o,h,l)+u,h=l+s,l=l+c>o.length?-1:OT(o,n,l+c);return h<o.length&&(p+=MT(o,h)),p}});var PT={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},xT=_t("span").classList,UT=xT&&xT.constructor&&xT.constructor.prototype,VT=UT===Object.prototype?void 0:UT,FT=Lv.forEach,BT=Ks("forEach")?[].forEach:function(e){return FT(this,e,arguments.length>1?arguments[1]:void 0)},HT=r,jT=PT,GT=VT,WT=BT,KT=qt,zT=function(e){if(e&&e.forEach!==WT)try{KT(e,"forEach",WT)}catch(Uj){e.forEach=WT}};for(var qT in jT)jT[qT]&&zT(HT[qT]&&HT[qT].prototype);zT(GT);var JT=r,YT=PT,XT=VT,$T=Ls,QT=qt,ZT=Ua,eI=tt("iterator"),tI=$T.values,rI=function(e,t){if(e){if(e[eI]!==tI)try{QT(e,eI,tI)}catch(Uj){e[eI]=tI}if(ZT(e,t,!0),YT[t])for(var r in $T)if(e[r]!==$T[r])try{QT(e,r,$T[r])}catch(Uj){e[r]=$T[r]}}};for(var iI in YT)rI(JT[iI]&&JT[iI].prototype,iI);rI(XT,"DOMTokenList");var oI=cg.charAt,nI=po,aI=Dr,sI=Ts,cI=Is,lI="String Iterator",uI=aI.set,dI=aI.getterFor(lI);sI(String,"String",(function(e){uI(this,{type:lI,string:nI(e),index:0})}),(function(){var e,t=dI(this),r=t.string,i=t.index;return i>=r.length?cI(void 0,!0):(e=oI(r,i),t.index+=e.length,cI(e,!1))}));var hI=o,pI=n,mI=tt("iterator"),fI=!hI((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&&!pI||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[mI]||"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})),_I=n,gI=T,EI=l,vI=o,yI=Pn,TI=wi,II=u,AI=Ve,SI=N,RI=Object.assign,bI=Object.defineProperty,wI=gI([].concat),DI=!RI||vI((function(){if(_I&&1!==RI({b:1},RI(bI({},"a",{enumerable:!0,get:function(){bI(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!==RI({},e)[r]||yI(RI({},t)).join("")!==i}))?function(e,t){for(var r=AI(e),i=arguments.length,o=1,n=TI.f,a=II.f;i>o;)for(var s,c=SI(arguments[o++]),l=n?wI(yI(c),n(c)):yI(c),u=l.length,d=0;u>d;)s=l[d++],_I&&!EI(a,c,s)||(r[s]=c[s]);return r}:RI,CI=Mt,NI=jp,kI=n,OI=Dt,MI=_,LI=Zo,PI=l,xI=Ve,UI=function(e,t,r,i){try{return i?t(CI(r)[0],r[1]):t(r)}catch(Uj){NI(e,"throw",Uj)}},VI=Rp,FI=vn,BI=hi,HI=function(e,t,r){kI?OI.f(e,t,MI(0,r)):e[t]=r},jI=Vp,GI=kp,WI=Array,KI=T,zI=2147483647,qI=/[^\0-\u007E]/,JI=/[.\u3002\uFF0E\uFF61]/g,YI="Overflow: input needs wider integers to process",XI=RangeError,$I=KI(JI.exec),QI=Math.floor,ZI=String.fromCharCode,eA=KI("".charCodeAt),tA=KI([].join),rA=KI([].push),iA=KI("".replace),oA=KI("".split),nA=KI("".toLowerCase),aA=function(e){return e+22+75*(e<26)},sA=function(e,t,r){var i=0;for(e=r?QI(e/700):e>>1,e+=QI(e/t);e>455;)e=QI(e/35),i+=36;return QI(i+36*e/(e+38))},cA=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var o=eA(e,r++);if(o>=55296&&o<=56319&&r<i){var n=eA(e,r++);56320==(64512&n)?rA(t,((1023&o)<<10)+(1023&n)+65536):(rA(t,o),r--)}else rA(t,o)}return t}(e);var r,i,o=e.length,n=128,a=0,s=72;for(r=0;r<e.length;r++)(i=e[r])<128&&rA(t,ZI(i));var c=t.length,l=c;for(c&&rA(t,"-");l<o;){var u=zI;for(r=0;r<e.length;r++)(i=e[r])>=n&&i<u&&(u=i);var d=l+1;if(u-n>QI((zI-a)/d))throw new XI(YI);for(a+=(u-n)*d,n=u,r=0;r<e.length;r++){if((i=e[r])<n&&++a>zI)throw new XI(YI);if(i===n){for(var h=a,p=36;;){var m=p<=s?1:p>=s+26?26:p-s;if(h<m)break;var f=h-m,_=36-m;rA(t,ZI(aA(m+f%_))),h=QI(f/_),p+=36}rA(t,ZI(aA(h))),s=sA(a,d,l===c),a=0,l++}}a++,n++}return tA(t,"")},lA=to,uA=T,dA=si,hA=RangeError,pA=String.fromCharCode,mA=String.fromCodePoint,fA=uA([].join);lA({target:"String",stat:!0,arity:1,forced:!!mA&&1!==mA.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,o=0;i>o;){if(t=+arguments[o++],dA(t,1114111)!==t)throw new hA(t+" is not a valid code point");r[o]=t<65536?pA(t):pA(55296+((t-=65536)>>10),t%1024+56320)}return fA(r,"")}});var _A=to,gA=r,EA=Ld,vA=W,yA=l,TA=T,IA=n,AA=fI,SA=$r,RA=_o,bA=Fc,wA=Ua,DA=Wa,CA=Dr,NA=jc,kA=F,OA=He,MA=Zo,LA=lo,PA=Mt,xA=H,UA=po,VA=ia,FA=_,BA=Vp,HA=kp,jA=Is,GA=rd,WA=uc,KA=tt("iterator"),zA="URLSearchParams",qA=zA+"Iterator",JA=CA.set,YA=CA.getterFor(zA),XA=CA.getterFor(qA),$A=EA("fetch"),QA=EA("Request"),ZA=EA("Headers"),eS=QA&&QA.prototype,tS=ZA&&ZA.prototype,rS=gA.TypeError,iS=gA.encodeURIComponent,oS=String.fromCharCode,nS=vA("String","fromCodePoint"),aS=parseInt,sS=TA("".charAt),cS=TA([].join),lS=TA([].push),uS=TA("".replace),dS=TA([].shift),hS=TA([].splice),pS=TA("".split),mS=TA("".slice),fS=TA(/./.exec),_S=/\+/g,gS=/^[0-9a-f]+$/i,ES=function(e,t){var r=mS(e,t,t+2);return fS(gS,r)?aS(r,16):NaN},vS=function(e){for(var t=0,r=128;r>0&&e&r;r>>=1)t++;return t},yS=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},TS=function(e){for(var t=(e=uS(e,_S," ")).length,r="",i=0;i<t;){var o=sS(e,i);if("%"===o){if("%"===sS(e,i+1)||i+3>t){r+="%",i++;continue}var n=ES(e,i+1);if(n!=n){r+=o,i++;continue}i+=2;var a=vS(n);if(0===a)o=oS(n);else{if(1===a||a>4){r+="�",i++;continue}for(var s=[n],c=1;c<a&&!(++i+3>t||"%"!==sS(e,i));){var l=ES(e,i+1);if(l!=l){i+=3;break}if(l>191||l<128)break;lS(s,l),i+=2,c++}if(s.length!==a){r+="�";continue}var u=yS(s);null===u?r+="�":o=nS(u)}}r+=o,i++}return r},IS=/[!'()~]|%20/g,AS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},SS=function(e){return AS[e]},RS=function(e){return uS(iS(e),IS,SS)},bS=DA((function(e,t){JA(this,{type:qA,target:YA(e).entries,index:0,kind:t})}),zA,(function(){var e=XA(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,jA(void 0,!0);var i=t[r];switch(e.kind){case"keys":return jA(i.key,!1);case"values":return jA(i.value,!1)}return jA([i.key,i.value],!1)}),!0),wS=function(e){this.entries=[],this.url=null,void 0!==e&&(xA(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===sS(e,0)?mS(e,1):e:UA(e)))};wS.prototype={type:zA,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,o,n,a,s,c=this.entries,l=HA(e);if(l)for(r=(t=BA(e,l)).next;!(i=yA(r,t)).done;){if(n=(o=BA(PA(i.value))).next,(a=yA(n,o)).done||(s=yA(n,o)).done||!yA(n,o).done)throw new rS("Expected sequence with length 2");lS(c,{key:UA(a.value),value:UA(s.value)})}else for(var u in e)OA(e,u)&&lS(c,{key:u,value:UA(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,o=pS(e,"&"),n=0;n<o.length;)(t=o[n++]).length&&(r=pS(t,"="),lS(i,{key:TS(dS(r)),value:TS(cS(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],lS(r,RS(e.key)+"="+RS(e.value));return cS(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var DS=function(){NA(this,CS);var e=JA(this,new wS(arguments.length>0?arguments[0]:void 0));IA||(this.size=e.entries.length)},CS=DS.prototype;if(bA(CS,{append:function(e,t){var r=YA(this);GA(arguments.length,2),lS(r.entries,{key:UA(e),value:UA(t)}),IA||this.length++,r.updateURL()},delete:function(e){for(var t=YA(this),r=GA(arguments.length,1),i=t.entries,o=UA(e),n=r<2?void 0:arguments[1],a=void 0===n?n:UA(n),s=0;s<i.length;){var c=i[s];if(c.key!==o||void 0!==a&&c.value!==a)s++;else if(hS(i,s,1),void 0!==a)break}IA||(this.size=i.length),t.updateURL()},get:function(e){var t=YA(this).entries;GA(arguments.length,1);for(var r=UA(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){var t=YA(this).entries;GA(arguments.length,1);for(var r=UA(e),i=[],o=0;o<t.length;o++)t[o].key===r&&lS(i,t[o].value);return i},has:function(e){for(var t=YA(this).entries,r=GA(arguments.length,1),i=UA(e),o=r<2?void 0:arguments[1],n=void 0===o?o:UA(o),a=0;a<t.length;){var s=t[a++];if(s.key===i&&(void 0===n||s.value===n))return!0}return!1},set:function(e,t){var r=YA(this);GA(arguments.length,1);for(var i,o=r.entries,n=!1,a=UA(e),s=UA(t),c=0;c<o.length;c++)(i=o[c]).key===a&&(n?hS(o,c--,1):(n=!0,i.value=s));n||lS(o,{key:a,value:s}),IA||(this.size=o.length),r.updateURL()},sort:function(){var e=YA(this);WA(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=YA(this).entries,i=MA(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)i((t=r[o++]).value,t.key,this)},keys:function(){return new bS(this,"keys")},values:function(){return new bS(this,"values")},entries:function(){return new bS(this,"entries")}},{enumerable:!0}),SA(CS,KA,CS.entries,{name:"entries"}),SA(CS,"toString",(function(){return YA(this).serialize()}),{enumerable:!0}),IA&&RA(CS,"size",{get:function(){return YA(this).entries.length},configurable:!0,enumerable:!0}),wA(DS,zA),_A({global:!0,constructor:!0,forced:!AA},{URLSearchParams:DS}),!AA&&kA(ZA)){var NS=TA(tS.has),kS=TA(tS.set),OS=function(e){if(xA(e)){var t,r=e.body;if(LA(r)===zA)return t=e.headers?new ZA(e.headers):new ZA,NS(t,"content-type")||kS(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),VA(e,{body:FA(0,UA(r)),headers:FA(0,t)})}return e};if(kA($A)&&_A({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return $A(e,arguments.length>1?OS(arguments[1]):{})}}),kA(QA)){var MS=function(e){return NA(this,eS),new QA(e,arguments.length>1?OS(arguments[1]):{})};eS.constructor=MS,MS.prototype=eS,_A({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:MS})}}var LS,PS=to,xS=n,US=fI,VS=r,FS=Zo,BS=T,HS=$r,jS=_o,GS=jc,WS=He,KS=DI,zS=function(e){var t=xI(e),r=FI(this),i=arguments.length,o=i>1?arguments[1]:void 0,n=void 0!==o;n&&(o=LI(o,i>2?arguments[2]:void 0));var a,s,c,l,u,d,h=GI(t),p=0;if(!h||this===WI&&VI(h))for(a=BI(t),s=r?new this(a):WI(a);a>p;p++)d=n?o(t[p],p):t[p],HI(s,p,d);else for(s=r?new this:[],u=(l=jI(t,h)).next;!(c=PI(u,l)).done;p++)d=n?UI(l,o,[c.value,p],!0):c.value,HI(s,p,d);return s.length=p,s},qS=ac,JS=cg.codeAt,YS=function(e){var t,r,i=[],o=oA(iA(nA(e),JI,"."),".");for(t=0;t<o.length;t++)r=o[t],rA(i,$I(qI,r)?"xn--"+cA(r):r);return tA(i,".")},XS=po,$S=Ua,QS=rd,ZS={URLSearchParams:DS,getState:YA},eR=Dr,tR=eR.set,rR=eR.getterFor("URL"),iR=ZS.URLSearchParams,oR=ZS.getState,nR=VS.URL,aR=VS.TypeError,sR=VS.parseInt,cR=Math.floor,lR=Math.pow,uR=BS("".charAt),dR=BS(/./.exec),hR=BS([].join),pR=BS(1..toString),mR=BS([].pop),fR=BS([].push),_R=BS("".replace),gR=BS([].shift),ER=BS("".split),vR=BS("".slice),yR=BS("".toLowerCase),TR=BS([].unshift),IR="Invalid scheme",AR="Invalid host",SR="Invalid port",RR=/[a-z]/i,bR=/[\d+-.a-z]/i,wR=/\d/,DR=/^0x/i,CR=/^[0-7]+$/,NR=/^\d+$/,kR=/^[\da-f]+$/i,OR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,MR=/[\0\t\n\r #/:<>?@[\\\]^|]/,LR=/^[\u0000-\u0020]+/,PR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,xR=/[\t\n\r]/g,UR=function(e){var t,r,i,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)TR(t,e%256),e=cR(e/256);return hR(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,o=0,n=0;n<8;n++)0!==e[n]?(o>r&&(t=i,r=o),i=null,o=0):(null===i&&(i=n),++o);return o>r?i:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),i===r?(t+=r?":":"::",o=!0):(t+=pR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},VR={},FR=KS({},VR,{" ":1,'"':1,"<":1,">":1,"`":1}),BR=KS({},FR,{"#":1,"?":1,"{":1,"}":1}),HR=KS({},BR,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),jR=function(e,t){var r=JS(e,0);return r>32&&r<127&&!WS(t,e)?e:encodeURIComponent(e)},GR={ftp:21,file:null,http:80,https:443,ws:80,wss:443},WR=function(e,t){var r;return 2===e.length&&dR(RR,uR(e,0))&&(":"===(r=uR(e,1))||!t&&"|"===r)},KR=function(e){var t;return e.length>1&&WR(vR(e,0,2))&&(2===e.length||"/"===(t=uR(e,2))||"\\"===t||"?"===t||"#"===t)},zR=function(e){return"."===e||"%2e"===yR(e)},qR={},JR={},YR={},XR={},$R={},QR={},ZR={},eb={},tb={},rb={},ib={},ob={},nb={},ab={},sb={},cb={},lb={},ub={},db={},hb={},pb={},mb=function(e,t,r){var i,o,n,a=XS(e);if(t){if(o=this.parse(a))throw new aR(o);this.searchParams=null}else{if(void 0!==r&&(i=new mb(r,!0)),o=this.parse(a,null,i))throw new aR(o);(n=oR(new iR)).bindURL(this),this.searchParams=n}};mb.prototype={type:"URL",parse:function(e,t,r){var i,o,n,a,s,c=this,l=t||qR,u=0,d="",h=!1,p=!1,m=!1;for(e=XS(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=_R(e,LR,""),e=_R(e,PR,"$1")),e=_R(e,xR,""),i=zS(e);u<=i.length;){switch(o=i[u],l){case qR:if(!o||!dR(RR,o)){if(t)return IR;l=YR;continue}d+=yR(o),l=JR;break;case JR:if(o&&(dR(bR,o)||"+"===o||"-"===o||"."===o))d+=yR(o);else{if(":"!==o){if(t)return IR;d="",l=YR,u=0;continue}if(t&&(c.isSpecial()!==WS(GR,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&GR[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?l=ab:c.isSpecial()&&r&&r.scheme===c.scheme?l=XR:c.isSpecial()?l=eb:"/"===i[u+1]?(l=$R,u++):(c.cannotBeABaseURL=!0,fR(c.path,""),l=db)}break;case YR:if(!r||r.cannotBeABaseURL&&"#"!==o)return IR;if(r.cannotBeABaseURL&&"#"===o){c.scheme=r.scheme,c.path=qS(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,l=pb;break}l="file"===r.scheme?ab:QR;continue;case XR:if("/"!==o||"/"!==i[u+1]){l=QR;continue}l=tb,u++;break;case $R:if("/"===o){l=rb;break}l=ub;continue;case QR:if(c.scheme=r.scheme,o===LS)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=qS(r.path),c.query=r.query;else if("/"===o||"\\"===o&&c.isSpecial())l=ZR;else if("?"===o)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=qS(r.path),c.query="",l=hb;else{if("#"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=qS(r.path),c.path.length--,l=ub;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=qS(r.path),c.query=r.query,c.fragment="",l=pb}break;case ZR:if(!c.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,l=ub;continue}l=rb}else l=tb;break;case eb:if(l=tb,"/"!==o||"/"!==uR(d,u+1))continue;u++;break;case tb:if("/"!==o&&"\\"!==o){l=rb;continue}break;case rb:if("@"===o){h&&(d="%40"+d),h=!0,n=zS(d);for(var f=0;f<n.length;f++){var _=n[f];if(":"!==_||m){var g=jR(_,HR);m?c.password+=g:c.username+=g}else m=!0}d=""}else if(o===LS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(h&&""===d)return"Invalid authority";u-=zS(d).length+1,d="",l=ib}else d+=o;break;case ib:case ob:if(t&&"file"===c.scheme){l=cb;continue}if(":"!==o||p){if(o===LS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(c.isSpecial()&&""===d)return AR;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",l=lb,t)return;continue}"["===o?p=!0:"]"===o&&(p=!1),d+=o}else{if(""===d)return AR;if(a=c.parseHost(d))return a;if(d="",l=nb,t===ob)return}break;case nb:if(!dR(wR,o)){if(o===LS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()||t){if(""!==d){var E=sR(d,10);if(E>65535)return SR;c.port=c.isSpecial()&&E===GR[c.scheme]?null:E,d=""}if(t)return;l=lb;continue}return SR}d+=o;break;case ab:if(c.scheme="file","/"===o||"\\"===o)l=sb;else{if(!r||"file"!==r.scheme){l=ub;continue}switch(o){case LS:c.host=r.host,c.path=qS(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=qS(r.path),c.query="",l=hb;break;case"#":c.host=r.host,c.path=qS(r.path),c.query=r.query,c.fragment="",l=pb;break;default:KR(hR(qS(i,u),""))||(c.host=r.host,c.path=qS(r.path),c.shortenPath()),l=ub;continue}}break;case sb:if("/"===o||"\\"===o){l=cb;break}r&&"file"===r.scheme&&!KR(hR(qS(i,u),""))&&(WR(r.path[0],!0)?fR(c.path,r.path[0]):c.host=r.host),l=ub;continue;case cb:if(o===LS||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&WR(d))l=ub;else if(""===d){if(c.host="",t)return;l=lb}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",l=lb}continue}d+=o;break;case lb:if(c.isSpecial()){if(l=ub,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==LS&&(l=ub,"/"!==o))continue}else c.fragment="",l=pb;else c.query="",l=hb;break;case ub:if(o===LS||"/"===o||"\\"===o&&c.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(s=yR(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===o||"\\"===o&&c.isSpecial()||fR(c.path,"")):zR(d)?"/"===o||"\\"===o&&c.isSpecial()||fR(c.path,""):("file"===c.scheme&&!c.path.length&&WR(d)&&(c.host&&(c.host=""),d=uR(d,0)+":"),fR(c.path,d)),d="","file"===c.scheme&&(o===LS||"?"===o||"#"===o))for(;c.path.length>1&&""===c.path[0];)gR(c.path);"?"===o?(c.query="",l=hb):"#"===o&&(c.fragment="",l=pb)}else d+=jR(o,BR);break;case db:"?"===o?(c.query="",l=hb):"#"===o?(c.fragment="",l=pb):o!==LS&&(c.path[0]+=jR(o,VR));break;case hb:t||"#"!==o?o!==LS&&("'"===o&&c.isSpecial()?c.query+="%27":c.query+="#"===o?"%23":jR(o,VR)):(c.fragment="",l=pb);break;case pb:o!==LS&&(c.fragment+=jR(o,FR))}u++}},parseHost:function(e){var t,r,i;if("["===uR(e,0)){if("]"!==uR(e,e.length-1))return AR;if(t=function(e){var t,r,i,o,n,a,s,c=[0,0,0,0,0,0,0,0],l=0,u=null,d=0,h=function(){return uR(e,d)};if(":"===h()){if(":"!==uR(e,1))return;d+=2,u=++l}for(;h();){if(8===l)return;if(":"!==h()){for(t=r=0;r<4&&dR(kR,h());)t=16*t+sR(h(),16),d++,r++;if("."===h()){if(0===r)return;if(d-=r,l>6)return;for(i=0;h();){if(o=null,i>0){if(!("."===h()&&i<4))return;d++}if(!dR(wR,h()))return;for(;dR(wR,h());){if(n=sR(h(),10),null===o)o=n;else{if(0===o)return;o=10*o+n}if(o>255)return;d++}c[l]=256*c[l]+o,2!=++i&&4!==i||l++}if(4!==i)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[l++]=t}else{if(null!==u)return;d++,u=++l}}if(null!==u)for(a=l-u,l=7;0!==l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!==l)return;return c}(vR(e,1,-1)),!t)return AR;this.host=t}else if(this.isSpecial()){if(e=YS(e),dR(OR,e))return AR;if(t=function(e){var t,r,i,o,n,a,s,c=ER(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],i=0;i<t;i++){if(""===(o=c[i]))return e;if(n=10,o.length>1&&"0"===uR(o,0)&&(n=dR(DR,o)?16:8,o=vR(o,8===n?1:2)),""===o)a=0;else{if(!dR(10===n?NR:8===n?CR:kR,o))return e;a=sR(o,n)}fR(r,a)}for(i=0;i<t;i++)if(a=r[i],i===t-1){if(a>=lR(256,5-t))return null}else if(a>255)return null;for(s=mR(r),i=0;i<r.length;i++)s+=r[i]*lR(256,3-i);return s}(e),null===t)return AR;this.host=t}else{if(dR(MR,e))return AR;for(t="",r=zS(e),i=0;i<r.length;i++)t+=jR(r[i],VR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return WS(GR,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&WR(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,o=e.host,n=e.port,a=e.path,s=e.query,c=e.fragment,l=t+":";return null!==o?(l+="//",e.includesCredentials()&&(l+=r+(i?":"+i:"")+"@"),l+=UR(o),null!==n&&(l+=":"+n)):"file"===t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+hR(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw new aR(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new fb(e.path[0]).origin}catch(Uj){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+UR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(XS(e)+":",qR)},getUsername:function(){return this.username},setUsername:function(e){var t=zS(XS(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=jR(t[r],HR)}},getPassword:function(){return this.password},setPassword:function(e){var t=zS(XS(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=jR(t[r],HR)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?UR(e):UR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,ib)},getHostname:function(){var e=this.host;return null===e?"":UR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,ob)},getPort:function(){var e=this.port;return null===e?"":XS(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=XS(e))?this.port=null:this.parse(e,nb))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+hR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,lb))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=XS(e))?this.query=null:("?"===uR(e,0)&&(e=vR(e,1)),this.query="",this.parse(e,hb)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=XS(e))?("#"===uR(e,0)&&(e=vR(e,1)),this.fragment="",this.parse(e,pb)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var fb=function(e){var t=GS(this,_b),r=QS(arguments.length,1)>1?arguments[1]:void 0,i=tR(t,new mb(e,!1,r));xS||(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())},_b=fb.prototype,gb=function(e,t){return{get:function(){return rR(this)[e]()},set:t&&function(e){return rR(this)[t](e)},configurable:!0,enumerable:!0}};if(xS&&(jS(_b,"href",gb("serialize","setHref")),jS(_b,"origin",gb("getOrigin")),jS(_b,"protocol",gb("getProtocol","setProtocol")),jS(_b,"username",gb("getUsername","setUsername")),jS(_b,"password",gb("getPassword","setPassword")),jS(_b,"host",gb("getHost","setHost")),jS(_b,"hostname",gb("getHostname","setHostname")),jS(_b,"port",gb("getPort","setPort")),jS(_b,"pathname",gb("getPathname","setPathname")),jS(_b,"search",gb("getSearch","setSearch")),jS(_b,"searchParams",gb("getSearchParams")),jS(_b,"hash",gb("getHash","setHash"))),HS(_b,"toJSON",(function(){return rR(this).serialize()}),{enumerable:!0}),HS(_b,"toString",(function(){return rR(this).serialize()}),{enumerable:!0}),nR){var Eb=nR.createObjectURL,vb=nR.revokeObjectURL;Eb&&HS(fb,"createObjectURL",FS(Eb,nR)),vb&&HS(fb,"revokeObjectURL",FS(vb,nR))}$S(fb,"URL"),PS({global:!0,constructor:!0,forced:!US,sham:!xS},{URL:fb});var yb=l;to({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return yb(URL.prototype.toString,this)}});var Tb,Ib=Object.create,Ab=Object.defineProperty,Sb=Object.defineProperties,Rb=Object.getOwnPropertyDescriptor,bb=Object.getOwnPropertyDescriptors,wb=Object.getOwnPropertyNames,Db=Object.getOwnPropertySymbols,Cb=Object.getPrototypeOf,Nb=Object.prototype.hasOwnProperty,kb=Object.prototype.propertyIsEnumerable,Ob=Reflect.get,Mb=Math.pow,Lb=(e,t,r)=>t in e?Ab(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pb=(e,t)=>{for(var r in t||(t={}))Nb.call(t,r)&&Lb(e,r,t[r]);if(Db)for(var r of Db(t))kb.call(t,r)&&Lb(e,r,t[r]);return e},xb=(e,t)=>Sb(e,bb(t)),Ub=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Vb=(e,t)=>{for(var r in t)Ab(e,r,{get:t[r],enumerable:!0})},Fb=(e,t,r)=>(r=null!=e?Ib(Cb(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of wb(t))!Nb.call(e,o)&&o!==r&&Ab(e,o,{get:()=>t[o],enumerable:!(i=Rb(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:Ab(r,"default",{value:e,enumerable:!0}),e)),Bb=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?Rb(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&Ab(t,r,n),n},Hb=(e,t,r)=>Lb(e,"symbol"!=typeof t?t+"":t,r),jb=(e,t,r)=>Ob(Cb(e),r,t),Gb=(e,t,r)=>new Promise(((i,o)=>{var n=e=>{try{s(r.next(e))}catch($k){o($k)}},a=e=>{try{s(r.throw(e))}catch($k){o($k)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(n,a);s((r=r.apply(e,t)).next())})),Wb=Ub(((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),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 o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},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 o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},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,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,n),!0;case 6:return u.fn.call(u.context,t,r,o,n,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn===t&&(!o||a.once)&&(!r||a.context===r)&&s(this,n);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),Kb=Ub(((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")}))}))})),zb=Ub((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,i){var o=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:o&&!r[e.name]&&(r[e.name]={});var n=e.push?{}:o?r[e.name]:r;(function(e,r,i,o){if(o&&!i)r[o]=t(e[1]);else for(var n=0;n<i.length;n+=1)null!=e[n+1]&&(r[i[n]]=t(e[n+1]))})(i.match(e.reg),n,e.names,e.name),e.push&&r[e.push].push(n)},i=Kb(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},n=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(o).forEach((function(e){var t=e[0],o=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),a=n[n.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(o))return r(c,a,o)}})),t.media=n,t};var n=function(e,r){var i=r.split(/=(.+)/,2);return 2===i.length?e[i[0]]=t(i[1]):1===i.length&&r.length>1&&(e[i[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(n,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],i=e.split(" ").map(t),o=0;o<i.length;o+=3)r.push({component:i[o],ip:i[o+1],port:i[o+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(n,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,i=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),i=!0),{scid:r,paused:i}}))}))}})),qb=Ub(((e,t)=>{var r=Kb(),i=/%[sdv%]/g,o=function(e){var t=1,r=arguments,o=r.length;return e.replace(i,(function(e){if(t>=o)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},n=function(e,t,r){var i=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var a=t.names[n];t.name?i.push(r[t.name][a]):i.push(r[t.names[n]])}else i.push(r[t.name]);return o.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var i=t.outerOrder||a,o=t.innerOrder||s,c=[];return i.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?c.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){c.push(n(t,r,e))}))}))})),e.media.forEach((function(e){c.push(n("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?c.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){c.push(n(t,r,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),Jb=Ub((e=>{var t=zb(),r=qb(),i=Kb();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})),Yb=((Tb=Yb||{})[Tb.INVALID_PARAMETER=4096]="INVALID_PARAMETER",Tb[Tb.INVALID_OPERATION=4097]="INVALID_OPERATION",Tb[Tb.NOT_SUPPORTED=4098]="NOT_SUPPORTED",Tb[Tb.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",Tb[Tb.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",Tb[Tb.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",Tb[Tb.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",Tb[Tb.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",Tb[Tb.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",Tb[Tb.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",Tb[Tb.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",Tb[Tb.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",Tb[Tb.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",Tb[Tb.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",Tb[Tb.CLIENT_BANNED=16448]="CLIENT_BANNED",Tb[Tb.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",Tb[Tb.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",Tb[Tb.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",Tb[Tb.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",Tb[Tb.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",Tb[Tb.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",Tb[Tb.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",Tb[Tb.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",Tb[Tb.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",Tb[Tb.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",Tb[Tb.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",Tb[Tb.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",Tb[Tb.API_CALL_ABORTED=16461]="API_CALL_ABORTED",Tb[Tb.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",Tb[Tb.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",Tb[Tb.UNKNOWN=65535]="UNKNOWN",Tb),Xb=Yb,$b=class extends Error{constructor(e){let{name:t="RtcError",message:r,code:i=Xb.UNKNOWN,extraCode:o=0,constraint:n}=e,a="<".concat(function(e){for(let t in Xb)if(Xb[t]===e)return t;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(r).concat(n?" constraint: ".concat(n):"").concat(null!=r&&r.includes(a)?"":" ".concat(a));super(s),Hb(this,"code"),Hb(this,"extraCode"),Hb(this,"message"),Hb(this,"originMessage"),Hb(this,"name"),Hb(this,"constraint"),this.code=i,this.extraCode=o,this.name=t,this.message=s,this.constraint=n,this.originMessage=r}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},Qb=$b;(new Date).getTime();var Zb=function(){return(new Date).getTime()+0},ew=function(){let e=new Date;return e.setTime(Zb()),e.toLocaleString()},tw=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)},rw={};Vb(rw,{bytes2ms:()=>KD,convertObjectNumberToInt:()=>LC,copyProperties:()=>WD,deepClone:()=>SC,deepMerge:()=>AC,delay:()=>PC,fibonacci:()=>QD,formatedTime:()=>wC,getConstructorName:()=>hC,getContainerFromElement:()=>bC,getEnv:()=>xD,getInternalVersion:()=>gC,getLoggerUrl:()=>VD,getMediaStreamTrackInfo:()=>VC,getMuteStateFromFlag:()=>yC,getNetworkType:()=>BD,getNumNetworkType:()=>GD,getReconnectionTimeout:()=>ZD,getStringByteLength:()=>NC,getTurnServer:()=>TC,getUint32Version:()=>MC,getValueType:()=>eC,getViewListFromView:()=>RC,glog:()=>YD,ipv4ToUint32:()=>IC,isArray:()=>sC,isAudioWorkletSupported:()=>pC,isBoolean:()=>nC,isConstructor:()=>dC,isEmpty:()=>vC,isFunction:()=>tC,isLangChinese:()=>XD,isMediaStreamTrack:()=>cC,isNumber:()=>oC,isObject:()=>aC,isOverseaSdkAppId:()=>UD,isPlainObject:()=>$D,isPortrait:()=>kC,isPromise:()=>uC,isRemoteTrack:()=>lC,isString:()=>iC,isUndefined:()=>rC,loadImage:()=>OC,ms2bytes:()=>qD,ms2samples:()=>JD,normalizeUrl:()=>UC,performanceNow:()=>fC,promiseAny:()=>mC,samples2ms:()=>zD,setNetworkType:()=>jD,stringify:()=>DC,stringifyIncludeValue:()=>CC,throttlePromise:()=>xC});var iw={};Vb(iw,{AUDIO_MUTE_BIT:()=>jw,AUDIO_STAT_BIT:()=>Hw,AUX_STAT_BIT:()=>Bw,AUX_STREAM_MSID:()=>qw,BACKEND_ENV:()=>xw,BASE_DOC_URL:()=>Ew,BASE_HOST:()=>mw,CAPABILITIES_KEYS:()=>LD,CLASS_NAME:()=>RD,CLOUD_CONSOLE_URL:()=>gw,CROSS_ROOM_BIT:()=>Kw,DATA_FREEZE_TIMING:()=>ED,DEFAULT_ASSETS_URL:()=>vw,DOC_URL:()=>yw,DTLS_STATE_UNKNOWN:()=>iD,ENV_NAME:()=>Rw,EXCHANGE_SDP_TIMEOUT:()=>pD,IS_WORKER:()=>lw,IS_WORKLET:()=>uw,KIBANA_EVENT:()=>uD,LOCAL_STREAM_PUBLISH_STATE:()=>gD,LOGGER_CMD_TYPE:()=>Sw,LOGGER_DOMAIN:()=>Tw,LOGGER_DOMAIN_OVERSEA:()=>Iw,LOG_LEVEL:()=>bw,LOG_LEVEL_NAME:()=>ND,MAIN_STREAM_MSID:()=>zw,MAX_RTT:()=>PD,MICROPHONE_COMMUNICATIONS:()=>CD,MICROPHONE_DEFAULT:()=>wD,MUTE_ALL_BIT:()=>Ww,NAME:()=>Lw,NETWORK_TYPE:()=>Cw,NOT_SUPPORTED_H264:()=>_D,PAUSED_RETRY_COUNT:()=>bD,PEERCONNECTION_CONNECTING_TIMEOUT:()=>ID,PEER_CONNECTION_STATE:()=>oD,PEER_LEAVE_REASON:()=>kD,RECOVER_CAPTURE_INTERVAL:()=>MD,REMOTE_STREAM_TYPE_AUX:()=>Yw,REMOTE_STREAM_TYPE_MAIN:()=>Jw,RENDER_FREEZE_TIMING:()=>vD,SCHEDULE_DOMAIN:()=>AD,SCHEDULE_TIMEOUT:()=>SD,SDP_SEMANTICS_PLAN_B:()=>fD,SDP_SEMANTICS_UNIFIED_PLAN:()=>mD,SECOND_HOST:()=>fw,SIGNAL_PING_PONG_INTERVAL:()=>Dw,SIGNAL_PING_TIMEOUT:()=>ww,SIGNAL_RECONNECTION_COUNT:()=>lD,SMALL_STAT_BIT:()=>Fw,SPEAKER_DEFAULT:()=>DD,STORAGE_EXPIRES_TIME:()=>Nw,STREAM_TYPE_BIG:()=>yD,STREAM_TYPE_SMALL:()=>TD,SUBSCRIBE_SMALL_RETRY_COUNT:()=>OD,SYNC_USER_LIST_INTERVAL:()=>dD,Scene:()=>Uw,THIRD_HOST:()=>_w,TRANSPORT_DIRECTION:()=>Pw,TRTC_ERROR_ASSISTANCE:()=>Aw,TRTC_QUALITY_BAD:()=>eD,TRTC_QUALITY_DISCONNECTED:()=>rD,TRTC_QUALITY_EXCELLENT:()=>$w,TRTC_QUALITY_GOOD:()=>Qw,TRTC_QUALITY_POOR:()=>Zw,TRTC_QUALITY_UNKNOWN:()=>Xw,TRTC_QUALITY_VERY_BAD:()=>tD,UPDATE_OFFER_TIMEOUT:()=>hD,VIDEO_MUTE_BIT:()=>Gw,VIDEO_STAT_BIT:()=>Vw,audioProfileMap:()=>kw,getRetryCount:()=>sD,getScriptDir:()=>dw,innerVersion:()=>ow,loggerProxy:()=>hw,screenProfileMap:()=>Mw,setLoggerProxy:()=>pw,setRetryCount:()=>aD,setVersion:()=>aw,version:()=>nw,videoProfileMap:()=>Ow});var ow="4.15.00.1600",nw="5.0.0";function aw(e){nw=e;let[t,r,i]=e.split(".").map((e=>parseInt(e,10)));ow="".concat(t,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var sw,cw,lw="undefined"!=typeof importScripts,uw="undefined"!=typeof registerProcessor,dw=()=>{let e=lw?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},hw="",pw=e=>hw=e,mw="web.sdk.qcloud.com",fw="web.sdk.tencent.cn",_w="web.sdk.cloud.tencent.cn",gw="https://console.cloud.tencent.com/trtc",Ew="https://".concat(mw,"/trtc/webrtc/v5/doc"),vw="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",yw="".concat(Ew,"/zh-cn/"),Tw="https://yun.tim.qq.com",Iw="https://apisgp.my-imcloud.com",Aw="trtc_error_assistance",Sw={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},Rw={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},bw=((cw=bw||{})[cw.TRACE=0]="TRACE",cw[cw.DEBUG=1]="DEBUG",cw[cw.INFO=2]="INFO",cw[cw.WARN=3]="WARN",cw[cw.ERROR=4]="ERROR",cw[cw.NONE=5]="NONE",cw),ww=18e3,Dw=2e3,Cw={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},Nw=6048e5,kw={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},Ow={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Mw={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},Lw={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},Pw={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},xw={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},Uw=((sw=Uw||{}).LIVE="live",sw.RTC="rtc",sw),Vw=1,Fw=2,Bw=4,Hw=8,jw=64,Gw=16,Ww=112,Kw=128,zw="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",qw="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",Jw=Lw.MAIN,Yw=Lw.AUXILIARY,Xw=0,$w=1,Qw=2,Zw=3,eD=4,tD=5,rD=6,iD="unknown",oD={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},nD=1/0;function aD(e){nD=e}function sD(){return nD}var cD,lD=30,uD={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},dD=1e4,hD=1e4,pD=1e4,mD="unified-plan",fD="plan-b",_D=1028,gD=((cD=gD||{})[cD.UNPUBLISH=-1]="UNPUBLISH",cD[cD.PUBLISHING=0]="PUBLISHING",cD[cD.PUBLISHED=1]="PUBLISHED",cD),ED=500,vD=1e3,yD=Lw.BIG,TD=Lw.SMALL,ID=1e4,AD={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},SD=2e3,RD={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},bD=5,wD="default",DD=wD,CD="communications",ND=Object.keys(bw),kD=["normal leave","timeout leave","kick","role change"],OD=10,MD=2e3,LD=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],PD=1e4,xD=function(){return new URLSearchParams(location.search).get("trtc_env")||""},UD=e=>Number(e)<14e8,VD=function(e,t){let r;r=hw||(UD(e)?Iw:Tw);let i=Math.floor(Math.random()*Mb(2,31));return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},FD="unknown";function BD(){if("unknown"!==FD)return FD;let{userAgent:e,connection:t}=navigator,r=(e.match(/NetType\/\S+/)||[])[0]||"";r=r.toLowerCase().replace("nettype/",""),"3gnet"===r&&(r="3g");let i=t&&t.type&&t.type.toLowerCase(),o=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===o&&(o="2g"),i&&(FD=HD(i,o)),FD}function HD(e,t){if(Cw[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function jD(e){FD=HD(e)}function GD(){return Cw[BD()]}function WD(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 KD(e){return zD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function zD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function qD(e){return 4*JD(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function JD(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var YD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},XD=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},$D=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 QD(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:QD(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function ZD(e){return e>8?3e4:1e3*QD(e)}function eC(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var tC=e=>"function"==typeof e,rC=e=>void 0===e,iC=e=>"string"==typeof e,oC=e=>"number"==typeof e,nC=e=>"boolean"==typeof e,aC=e=>"object"===eC(e),sC=e=>"array"===eC(e),cC=e=>eC(e)==="MediaStreamTrack".toLowerCase(),lC=e=>e.isRemote,uC=e=>"promise"===eC(e),dC=e=>tC(e)&&e.prototype.constructor===e,hC=e=>dC(e)?e.prototype.constructor.name:"",pC="undefined"!=typeof AudioWorkletNode;function mC(e){return new Promise(((t,r)=>{let i=[];e.forEach((o=>{o.then(t).catch((t=>{i.push(t),i.length===e.length&&r(i)}))}))}))}function fC(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var _C=e=>+e<10?"0".concat(e):e,gC=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let r=t.split("."),i=_C(r[1])+_C(r[2]);return r[1]-15>0&&(r[1]="15"),r[2]-15>0&&(r[2]="15"),"".concat(r.join("."),".").concat(i)},EC=Object.prototype.hasOwnProperty;function vC(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($D(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(EC.call(e,t))return!1;return!0}return!1}function yC(e,t){return{userId:t,hasAudio:!!(e&Hw),hasVideo:!!(e&Vw),hasAuxiliary:!!(e&Bw),hasSmall:!!(e&Fw),audioMuted:!!(e&jw),videoMuted:!!(e&Gw),audioAvailable:!(!(e&Hw)||e&jw),videoAvailable:!(!(e&Vw)||e&Gw)}}function TC(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!rC(e.username)&&!rC(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",rC(e.credentialType)||(t.credentialType=e.credentialType)),t}function IC(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!iC(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 AC=function(e,t,r,i){if(!aC(e)||!aC(t))return 0;let o,n=0,a=Object.keys(t);for(let s=0,c=a.length;s<c;s++)if(o=a[s],!(rC(t[o])||r&&r.includes(o)))if(aC(e[o])&&aC(t[o]))n+=AC(e[o],t[o],r,i);else{if(i&&i.includes(t[o]))continue;e[o]!==t[o]&&(e[o]=SC(t[o]),n+=1)}return n};function SC(e){if(sC(e)){let t=[];return e.forEach(((e,r)=>{t[r]=SC(e)})),t}if(aC(e)){let t={};return Object.keys(e).forEach((r=>{t[r]=SC(e[r])})),t}return e}var RC=e=>{let t=[];if(sC(e))t=[...e];else if(iC(e)){let r=document.getElementById(e);r&&t.push(r)}else e&&t.push(e);return t},bC=e=>iC(e)?document.getElementById(e):e,wC=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),n=t(e.getHours()),a=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(r,"/").concat(i,"/").concat(o," ").concat(n,":").concat(a,":").concat(s)})(new Date);function DC(e,t){let{keysToInclude:r,keysToExclude:i}=t;try{if(sC(e))return"[".concat(e.map((e=>DC(e,{keysToInclude:r,keysToExclude:i}))).join(","),"]");if(!$D(e)||!sC(r)&&!sC(i))return JSON.stringify(e);let t={},o=new Set(r),n=new Set(i);return Object.keys(e).forEach((a=>{(0===n.size&&o.has(a)||0===o.size&&!n.has(a))&&(t[a]=$D(e[a])||sC(e[a])?JSON.parse(DC(e[a],{keysToExclude:i,keysToInclude:r})):e[a])})),JSON.stringify(t)}catch(cD){return"{}"}}function CC(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)})),DC(e,{keysToInclude:r})}function NC(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var kC=()=>{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},OC=e=>Gb(void 0,null,(function*(){return new Promise(((t,r)=>{let i;if(iC(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 Qb({code:Xb.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}))})),MC=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},LC=e=>(Object.keys(e).forEach((t=>{oC(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):($D(e[t])||sC(e[t]))&&LC(e[t])})),e);function PC(e,t){return new Promise((r=>{let i=setTimeout(r,e);t&&t(i)}))}function xC(e,t){let r=null;return function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return r||(r=e.apply(t||this,o),r.finally((()=>r=null)),r)}}function UC(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function VC(e){var t;try{let{width:r,height:i,frameRate:o,sampleRate:n,sampleSize:a,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),c=e.kind===Lw.AUDIO?"".concat(n,"x").concat(a,"@").concat(s):"".concat(r,"x").concat(i,"@").concat(o),l=e.stats?" stats: ".concat(JSON.stringify(e.stats).replaceAll('"',"")):"";return"".concat(e.id," ").concat(e.readyState," muted:").concat(e.muted," ").concat(e.kind," ").concat(e.label," ").concat(c).concat(l)}catch(sw){return""}}function FC(e){let{url:t,body:r,method:i="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:n}).then((e=>e.text())).then((t=>{try{e({data:JSON.parse(t)})}catch($k){e({data:t})}}),a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(t){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,t,!0),s.send(r)}))}function BC(e){return Gb(this,null,(function*(){let t=fC(),r=JSON.stringify(e);try{if(!CompressionStream||r.length<=2800)return r;let e=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),i=yield(yield(yield new Response(e)).blob()).arrayBuffer();return Kk.debug("compressJSON ".concat(r.length," -> ").concat(i.byteLength," ").concat(fC()-t,"ms")),i}catch(cD){return r}}))}var HC=Object.prototype.hasOwnProperty,jC=e=>"function"==typeof e,GC=e=>e.isRemote;function WC(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(HC.call(e,t))return!1;return!0}return!1}var KC=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:u=5,timeout:d=1e3}=r,h=0,p=-1,m=0,f=(e,r)=>Gb(this,null,(function*(){let l=s||this;try{let r=yield t.apply(l,c);h>0&&a&&a.call(this,h),h=0,e(r)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,r(_)},a=()=>{2!==m&&h<(jC(u)?u():u)?(h++,m=1,jC(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,r)}),jC(d)?d(h):d)):(t(),jC(n)&&n.call(this,_))};jC(i)?i.call(this,{error:_,retry:a,reject:r,retryFuncArgs:c,retriedCount:h}):a()}}));return new Promise(f)}},zC=class{constructor(e){Hb(this,"userId"),Hb(this,"remoteUserId"),Hb(this,"id"),Hb(this,"sdkAppId"),Hb(this,"type"),Hb(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal="boolean"!=typeof e.isLocal||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let r=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(r?"|".concat(r):"","]")),Kk.log(e,t,void 0===this.userId||WC(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)}},qC={};Vb(qC,{ANDROID_VERSION:()=>aN,CHROME_MAJOR_VERSION:()=>uk,CHROME_VERSION:()=>dk,EDGE_VERSION:()=>pN,EDG_MAJOR_VERSION:()=>_N,EDG_VERSION:()=>fN,FIREFOX_MAJOR_VERSION:()=>dN,FIREFOX_VERSION:()=>uN,HUAWEI_VERSION:()=>$N,IE_VERSION:()=>wN,IOS_MAIN_VERSION:()=>Ek,IOS_VERSION:()=>_k,IPADQQB_VERSION:()=>VN,IS_ANDROID:()=>nN,IS_ANDROID_WEBVIEW:()=>fk,IS_ANY_SAFARI:()=>pk,IS_CHROME:()=>ck,IS_CHROME_OS:()=>jN,IS_CHROMIUM_BASE:()=>sk,IS_DESKTOP_IOS_CHROME:()=>Ak,IS_EDG:()=>mN,IS_EDGE:()=>hN,IS_ELECTRON:()=>KN,IS_FIREFOX:()=>lN,IS_HEADLESS_CHROME:()=>lk,IS_HONOR:()=>XN,IS_HUAWEI:()=>YN,IS_HUAWEIBROWSER:()=>JN,IS_IE:()=>bN,IS_IE8:()=>RN,IS_IOS:()=>oN,IS_IOS_13_OR_14:()=>Tk,IS_IOS_15_1:()=>yk,IS_IOS_CHROME:()=>Ik,IS_IPAD:()=>eN,IS_IPADQQB:()=>UN,IS_IPAD_PRO:()=>tN,IS_IPHONE:()=>rN,IS_IPOD:()=>iN,IS_LINUX:()=>HN,IS_LOCAL:()=>Sk,IS_MAC:()=>BN,IS_MACQQB:()=>PN,IS_MIBROWSER:()=>zN,IS_MQQB:()=>kN,IS_NATIVE_ANDROID:()=>cN,IS_OLD_ANDROID:()=>sN,IS_OPENHARMONY:()=>ok,IS_OPPOBROWSER:()=>ek,IS_SAFARI:()=>hk,IS_SAFARI_15_1:()=>vk,IS_SAMSUNGBROWSER:()=>QN,IS_SOGOU:()=>vN,IS_SOGOUM:()=>gN,IS_TBS:()=>TN,IS_UCBROWSER:()=>WN,IS_VIVOBROWSER:()=>rk,IS_WECHAT:()=>DN,IS_WIN:()=>FN,IS_WQQB:()=>MN,IS_WX:()=>GN,IS_X5MQQB:()=>NN,IS_XWEB:()=>AN,MACQQB_VERSION:()=>xN,MI_VERSION:()=>qN,MQQB_VERSION:()=>ON,OPENHARMONY_VERSION:()=>nk,OPPO_VERSION:()=>tk,SAFARI_VERSION:()=>mk,SAMSUNG_VERSION:()=>ZN,SOGOUM_VERSION:()=>EN,SOGOU_VERSION:()=>yN,TBS_VERSION:()=>IN,UA_DATA_STRING:()=>Nk,USER_AGENT:()=>JC,VIVO_VERSION:()=>ik,WECHAT_VERSION:()=>CN,WQQB_VERSION:()=>LN,XWEB_VERSION:()=>SN,browserInfo:()=>bk,getBrowserInfo:()=>wk,getChromeMajorVersion:()=>ak,getDeviceModel:()=>Mk,getGPUInfo:()=>Ok,getOSName:()=>Pk,getOSNumber:()=>xk,getOSString:()=>Uk,getOSType:()=>Fk,getTerminalType:()=>Vk,getUserAgentData:()=>kk,isLocalStorageEnabled:()=>Rk,isMobile:()=>Ck,isVersionSmallerThan:()=>gk});var JC="undefined"==typeof navigator?"":navigator.userAgent,YC=e=>new RegExp(e,"i").test(JC),XC=e=>{if(YC(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=JC.match(t);if(r&&r[1])return r[1]}return""},$C=e=>{if(YC(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=JC.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},QC=/AppleWebKit\/([\d.]+)/i.exec(JC),ZC=QC?parseFloat(QC[1]):NaN,eN=YC("iPad"),tN="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&YC("Macintosh"),rN=YC("iPhone")&&!eN,iN=YC("iPod"),oN=rN||eN||iN||tN,nN=YC("Android"),aN=function(){if(nN){let e=JC.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}(),sN=nN&&YC("webkit")&&aN<2.3,cN=nN&&aN<5&&ZC<537,lN=YC("Firefox"),uN=XC("Firefox"),dN=$C("Firefox"),hN=YC("Edge"),pN=XC("Edge"),mN=YC("Edg"),fN=XC("Edg"),_N=$C("Edg"),gN=YC("SogouMobileBrowser"),EN=XC("SogouMobileBrowser"),vN=YC("MetaSr\\s"),yN=XC("MetaSr\\s"),TN=YC("TBS"),IN=XC("TBS"),AN=YC("XWEB"),SN=XC("XWEB"),RN=YC("MSIE\\s8\\.0"),bN=YC("MSIE\\/\\d+"),wN=function(){if(bN){let e=/MSIE\s(\d+)\.\d/.exec(JC),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(JC)&&/rv:11.0/.test(JC)&&(t=11),t}return NaN}(),DN=YC("(micromessenger|webbrowser)"),CN=XC("MicroMessenger"),NN=!TN&&YC("MQQBrowser")&&YC("COVC"),kN=!TN&&YC("MQQBrowser")&&!YC("COVC"),ON=kN||NN?XC("MQQBrowser"):"",MN=!TN&&YC(" QQBrowser"),LN=XC(" QQBrowser"),PN=!TN&&YC("QQBrowserLite"),xN=XC("QQBrowserLite"),UN=!TN&&YC("MQBHD"),VN=XC("MQBHD"),FN=YC("Windows"),BN=!oN&&YC("MAC OS X"),HN=!nN&&YC("Linux"),jN=YC("CrOS"),GN=YC("MicroMessenger"),WN=YC("UCBrowser"),KN=YC("Electron"),zN=YC("MiuiBrowser"),qN=XC("MiuiBrowser"),JN=YC("HuaweiBrowser"),YN=YC("Huawei")||YC("HUAWEI"),XN=YC("Honor")||YC("HONOR"),$N=XC("HuaweiBrowser"),QN=YC("SamsungBrowser"),ZN=XC("SamsungBrowser"),ek=YC("HeyTapBrowser"),tk=XC("HeyTapBrowser"),rk=YC("VivoBrowser"),ik=XC("VivoBrowser"),ok=YC("OpenHarmony"),nk=XC("OpenHarmony"),ak=()=>$C("Chrome"),sk=YC("Chrome"),ck=!hN&&!vN&&!gN&&!TN&&!AN&&!mN&&!MN&&!zN&&!JN&&!QN&&!ek&&!rk&&sk,lk=YC("HeadlessChrome"),uk=ak(),dk=XC("Chrome"),hk=!sk&&!kN&&!NN&&!PN&&!UN&&YC("Safari"),pk=hk||oN,mk=XC("Version"),fk=/Android.*(wv|.0.0.0)/.test(JC),_k=(()=>{if(tN)return mk;if(oN){let e=JC.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function gk(e,t){let r=e.split(".").map((e=>Number(e))),i=t.split(".").map((e=>Number(e)));for(let o=0;o<Math.max(r.length,i.length);o++){let e=r[o]||0,t=i[o]||0;if(e<t)return!0;if(e>t)return!1}return!1}var Ek=Number(_k.split(".")[0]),vk="15.1"===mk,yk="15.1"===_k,Tk=(()=>{let e=Number(_k.split(".")[0]);return 14===e||13===e})(),Ik=YC("CriOS"),Ak=Ik&&"11.1.1"===mk,Sk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Rk=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(Zk){e=!1}return e}})(),bk=wk();function wk(){let e=new Map([[lN,["Firefox",uN]],[mN,["Edg",fN]],[ck,["Chrome",dk]],[hk,["Safari",mk]],[TN,["TBS",IN]],[AN,["XWEB",SN]],[DN&&rN,["WeChat",CN]],[MN,["QQ(Win)",LN]],[kN,["QQ(Mobile)",ON]],[NN,["QQ(Mobile X5)",ON]],[PN,["QQ(Mac)",xN]],[UN,["QQ(iPad)",VN]],[zN,["MI",qN]],[JN,["HW",$N]],[QN,["Samsung",ZN]],[ek,["OPPO",tk]],[rk,["VIVO",ik]],[hN,["EDGE",pN]],[gN,["SogouMobile",EN]],[vN,["Sogou",yN]]]),t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}var Dk=null;function Ck(){return Dk&&"boolean"==typeof Dk.mobile?Dk.mobile:nN||oN||rN||eN||ok}var Nk="";function kk(){return Gb(this,null,(function*(){if(Dk)return Dk;if(!navigator.userAgentData||"function"!=typeof navigator.userAgentData.getHighEntropyValues)return null;try{return(Dk=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]))&&!Nk&&(Nk="UAData: ".concat(Dk.platform,"/").concat(Dk.platformVersion),Dk.architecture&&Dk.bitness&&(Nk+=" ".concat(Dk.architecture,"/").concat(Dk.bitness)),Dk.mobile&&(Nk+=" mobile"),Dk.model&&(Nk+=" model: ".concat(Dk.model.replace(/\s+/g,"/"))),Dk.fullVersionList&&(Nk+=" ".concat(Dk.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(",")))),Dk}catch(CF){return null}}))}function Ok(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return"";let r=t.getExtension("WEBGL_debug_renderer_info");if(r){let e=t.getParameter(r.UNMASKED_VENDOR_WEBGL),i=t.getParameter(r.UNMASKED_RENDERER_WEBGL);return"".concat(e," ").concat(i)}return""}catch(CF){return""}}function Mk(){return(null==Dk?void 0:Dk.model)||""}var Lk=new Map([[nN,"Android"],[oN,"iOS"],[FN,"Windows"],[BN,"MacOS"],[HN,"Linux"],[jN,"ChromeOS"]]),Pk=function(){return Lk.get(!0)?Lk.get(!0):Dk?Dk.platform:"unknown"};function xk(){return FN?1:nN?2:BN?3:oN?4:HN?5:jN?6:0}var Uk=()=>{let e=Pk();return e+="/".concat(bk.name,"/").concat(hk?bk.version:bk.version.split(".")[0]),null!=Dk&&Dk.platformVersion&&(e+="/".concat(Dk.platformVersion)),null!=Dk&&Dk.architecture&&(e+="/".concat(Dk.architecture)),e};function Vk(){return nN?4:rN?2:eN?3:BN?12:FN?5:HN?13:ok?22:1}function Fk(){return nN?"Android":rN?"iPhone":eN?"iPad":BN?"Mac":FN?"Windows":HN?"Linux":"unknown"}var Bk,Hk=new(Fb(Wb(),1).default),jk=((Bk=jk||{}).ROOM_DESTROY="1",Bk.JOIN_START="21",Bk.JOIN_SCHEDULE_SUCCESS="22",Bk.JOIN_SIGNAL_CONNECTION_START="23",Bk.JOIN_SIGNAL_CONNECTION_END="24",Bk.JOIN_SEND_CMD="25",Bk.JOIN_RECEIVED_CMD_RES="26",Bk.JOIN_SUCCESS="27",Bk.JOIN_FAILED="28",Bk.LEAVE_START="51",Bk.LEAVE_SEND_CMD="52",Bk.LEAVE_SUCCESS="53",Bk.PUBLISH_START="61",Bk.SEND_FIRST_VIDEO_FRAME="62",Bk.PUBLISH_FAILED="63",Bk.SUBSCRIBE_START="81",Bk.SUBSCRIBE_SUCCESS="82",Bk.SUBSCRIBE_FAILED="84",Bk.UNSUBSCRIBE_SUCCESS="83",Bk.LOCAL_TRACK_CAPTURE_START="101",Bk.LOCAL_TRACK_CAPTURE_SUCCESS="102",Bk.LOCAL_TRACK_CAPTURE_FAILED="103",Bk.LOCAL_TRACK_PUBLISHED="104",Bk.LOCAL_TRACK_UNPUBLISHED="105",Bk.LOCAL_TRACK_REPLACED="106",Bk.SWITCH_DEVICE_SUCCESS="107",Bk.TRACK_MUTED="108",Bk.TRACK_UNMUTED="109",Bk.REMOTE_TRACK_SUBSCRIBED="110",Bk.REMOTE_TRACK_UNSUBSCRIBED="111",Bk.LOCAL_TRACK_RECAPTURE="112",Bk.LOCAL_AUDIO_STARTED="113",Bk.LOCAL_AUDIO_STOPPED="114",Bk.REMOTE_AUDIO_STARTED="115",Bk.REMOTE_AUDIO_STOPPED="116",Bk.PLAY_TRACK_START="151",Bk.PLAYER_STATE_CHANGED="152",Bk.VIDEO_LOADED_DATA="153",Bk.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",Bk.SIGNAL_CONNECTION_STATE_CHANGED="201",Bk.PEER_CONNECTION_STATE_CHANGED="202",Bk.SINGLE_CONNECTION_STAT="203",Bk.SPC_RECONNECTED="204",Bk.HEARTBEAT_REPORT="251",Bk.RECEIVED_PUBLISHED_USER_LIST="252",Bk.REMOTE_PUBLISH_STATE_CHANGED="253",Bk.AUDIO_LEVEL_INTERVAL="260",Bk.NETWORK_QUALITY="261",Bk.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",Bk.QUALITY_LIMITATION_CHANGED="263",Bk.LOG="264",Bk),Gk=jk,Wk=class e{constructor(){Hb(this,"_isEnableUploadLog",!0),Hb(this,"_localJoinedUser",new Map),Hb(this,"_queue",[]),Hb(this,"_timeoutId",-1),Hb(this,"_logLevel",1),Hb(this,"_logLevelToUpload",2),!lw&&!uw&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){Hk.on(Gk.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&bw[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),Hk.on(Gk.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),Hk.once(Gk.JOIN_FAILED,(()=>{this.startUpload()})),Hk.on(Gk.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:i,sdkAppId:o}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:o,logs:[r]})}));else if(iC(r.userId)&&oC(r.sdkAppId)){let{userId:t,sdkAppId:i}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:i,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return Gb(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:r,sdkAppId:i,logs:o}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:ew(),sdkAppId:String(i),userId:r,version:nw,log:o.map((e=>e.log)).join("\n")}),i),o.forEach((e=>e.uploaded=!0))}}catch(eO){}let r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}))}uploadLogWithRetry(e,t){return KC({retryFunction:()=>FC({url:VD(t,Sw.LOG),body:e,timeout:5e3,priority:"low"}),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(Zb()),"[".concat(tw(t),"] <").concat(bw[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){rC(bw[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(iC(e))return e;try{return e instanceof Error?e.toString():JSON.stringify(e)}catch(sw){return""}}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;r.unshift(this.getPrefix(t));let s={log:r.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:t,userId:o,sdkAppId:n,forAllJoinedClients:i};if(Hk.emit(Gk.LOG,{log:s}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(s),t<this._logLevel)return;let c=(null==(a=bw[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[c]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...r):console[c](...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){return new zC(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;bw[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};Hb(Wk,"PRINT_LOG_TAG",!(oN||nN||lk));var Kk=new Wk,zk=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)}))},qk=new class{constructor(){Hb(this,"_prefix","TRTC"),Hb(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){Rk()&&(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(eO){return!1}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(Rk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(Zk){Kk.warn(Zk)}}getItem(e){if(!Rk())return null;try{let t=localStorage.getItem(this.getRealKey(e));if(!t)return null;let r=JSON.parse(t);return r&&r.expiresIn>=Date.now()?r.value:null}catch(sw){Kk.warn(sw)}}setItem(e,t){if(Rk())try{let r={expiresIn:Date.now()+Nw,value:t};this._queue.set(this.getRealKey(e),r)}catch(cD){Kk.warn(cD)}}deleteItem(e){if(!Rk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(sw){return Kk.warn(sw),!1}}clear(){if(Rk())try{localStorage.clear()}catch(Zk){Kk.warn(Zk)}}},Jk={};Vb(Jk,{HTTPS_API:()=>RM,IS_GET_CAPABILITIES_SUPPORTED:()=>WM,IS_GET_SETTINGS_SUPPORTED:()=>GM,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>jM,IS_INSERTABLE_STREAM_SUPPORTED:()=>KM,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>iL,IS_RTC_RTP_SENDER_SUPPORTED:()=>FM,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>zM,IS_SEI_SUPPORTED:()=>qM,IS_SPC_SUPPORTED:()=>UM,basis:()=>ZM,capabilityCheck:()=>tL,checkSystemRequirementsInternal:()=>TM,decodeSupportStatus:()=>yM,encodeSupportStatus:()=>vM,getBrowserInfo:()=>hM,getDisplayResolution:()=>wM,isAddTransceiverSupported:()=>xM,isBrowserSupported:()=>pM,isGetReceiversSupported:()=>MM,isGetSendersSupported:()=>LM,isGetTransceiversSupported:()=>PM,isGetUserMediaSupported:()=>DM,isMediaDevicesSupported:()=>fM,isMediaSessionSupported:()=>XM,isMediaStreamTrackProcessorSupported:()=>EM,isReplaceTrackSupported:()=>BM,isRequestVideoFrameCallbackSupported:()=>rL,isSIMDSupported:()=>QM,isScreenCaptureApiAvailable:()=>AM,isSelectedCandidatePair:()=>bM,isSetParametersSupported:()=>HM,isSmallStreamAPISupported:()=>NM,isSmallStreamSupported:()=>kM,isStopTransceiverSupported:()=>VM,isTRTCSupported:()=>IM,isUnifiedPlanDefault:()=>OM,isUsedInHttpProtocol:()=>gM,isWebAudioSupported:()=>CM,isWebCodecSupported:()=>YM,isWebCodecsSupported:()=>mM,isWebRTCSupported:()=>JM,isWebTransportSupported:()=>$M});var Yk={};Vb(Yk,{AUDIO_LEVEL_SCALE:()=>FO,AudioCodecPipelineType:()=>WO,AudioDecoderDowngradeState:()=>yO,AudioPlayerMode:()=>xO,AudioType:()=>bO,BASIC_TYPE:()=>HO,BannedReason:()=>UO,CONNECTION_CLOSED_REASON:()=>sO,ClientEvent:()=>cO,CodecType:()=>KO,ConnectionEvent:()=>aO,ConnectionState:()=>vO,DECODE_FAILED_ERROR_CODE:()=>zO,FacingMode:()=>LO,LeaveReason:()=>VO,LocalTrackEvent:()=>uO,MULTI_VIDEO_DATA_TYPE:()=>NO,MediaType:()=>SO,MediaTypeLabel:()=>RO,MonitorEventId:()=>kO,MutedFlag:()=>fO,NetworkQualityValue:()=>OO,PlayerState:()=>dO,ReceiveMode:()=>MO,RemoteStreamType:()=>CO,RemoteTrackEvent:()=>mO,RoomEvent:()=>hO,SceneNumber:()=>_O,StreamEvent:()=>lO,StreamType:()=>DO,SubscribeMediaType:()=>BO,TIMER_TYPE:()=>JO,TRACK_ACTION:()=>AO,TRACK_KIND:()=>IO,TrackEvent:()=>pO,UserRole:()=>EO,UserRoleNumber:()=>gO,VideoCodec:()=>jO,VideoCodecPipelineType:()=>GO,VideoContentHint:()=>qO,VideoDecoderDowngradeState:()=>TO,VideoPlayerMode:()=>PO,VideoType:()=>wO});var Xk,$k,Qk,Zk,eO,tO,rO,iO,oO,nO,aO=((nO=aO||{}).TRACK_ADDED="track-added",nO.TRACK_UPDATED="track-updated",nO.TRACK_SUBSCRIBED="track-subscribed",nO.STREAM_ADDED="stream-added",nO.STREAM_REMOVED="stream-removed",nO.STREAM_UPDATED="stream-updated",nO.STREAM_PUBLISHED="stream-published",nO.STREAM_SUBSCRIBED="stream-subscribed",nO.STREAM_UNSUBSCRIBED="stream-unsubscribed",nO.STATE_CHANGED="state-changed",nO.ERROR="error",nO.CONNECTION_STATE_CHANGED="connection-state-changed",nO.FIREWALL_RESTRICTION="firewall-restriction",nO.SEI_MESSAGE="sei-message",nO.CLOSED="closed",nO),sO=(e=>(e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e))(sO||{}),cO=((oO=cO||{}).STREAM_ADDED="stream-added",oO.STREAM_REMOVED="stream-removed",oO.STREAM_UPDATED="stream-updated",oO.STREAM_SUBSCRIBED="stream-subscribed",oO.CONNECTION_STATE_CHANGED="connection-state-changed",oO.PEER_JOIN="peer-join",oO.PEER_LEAVE="peer-leave",oO.MUTE_AUDIO="mute-audio",oO.MUTE_VIDEO="mute-video",oO.UNMUTE_AUDIO="unmute-audio",oO.UNMUTE_VIDEO="unmute-video",oO.CLIENT_BANNED="client-banned",oO.NETWORK_QUALITY="network-quality",oO.AUDIO_VOLUME="audio-volume",oO.SEI_MESSAGE="sei-message",oO.ERROR="error",oO),lO=((iO=lO||{}).PLAYER_STATE_CHANGED="player-state-changed",iO.SCREEN_SHARING_STOPPED="screen-sharing-stopped",iO.CONNECTION_STATE_CHANGED="connection-state-changed",iO.DEVICE_AUTO_RECOVERED="device-auto-recovered",iO.ERROR="error",iO),uO=(e=>(e.DEVICE_AUTO_RECOVERED="1",e.DEVICE_RECOVER_FAILED="5",e.DEVICE_CHANGED="2",e.ERROR="3",e.PUBLISH_STATE_CHANGED="4",e.ENCODE_FAILED="6",e))(uO||{}),dO=(e=>(e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e))(dO||{}),hO=((rO=hO||{}).PEER_JOIN="peer-join",rO.PEER_LEAVE="peer-leave",rO.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",rO.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",rO.BANNED="banned",rO.NETWORK_QUALITY="network-quality",rO.AUDIO_VOLUME="audio-volume",rO.SEI_MESSAGE="sei-message",rO.ERROR="error",rO.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",rO.REMOTE_PUBLISHED="remote-published",rO.REMOTE_UNPUBLISHED="remote-unpublished",rO.FIREWALL_RESTRICTION="firewall-restriction",rO.HEARTBEAT_REPORT="heartbeat-report",rO.CUSTOM_MESSAGE="custom-message",rO.LAYER_DATA="layerData",rO.FIRST_VIDEO_FRAME="first-video-frame",rO.DUMP="dump",rO.AUDIO_FRAME="audio-frame",rO),pO=((tO=pO||{}).PLAYER_STATE_CHANGED="player-state-changed",tO.MUTE="mute",tO.UNMUTE="unmute",tO.ERROR="error",tO.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",tO.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",tO.FIRST_VIDEO_FRAME="first-video-frame",tO),mO=(e=>(e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e))(mO||{}),fO=(e=>(e[e.VIDEO=1]="VIDEO",e[e.SMALL=2]="SMALL",e[e.AUX=4]="AUX",e[e.AUDIO=8]="AUDIO",e[e.VIDEO_MUTE=16]="VIDEO_MUTE",e[e.AUX_MUTE=32]="AUX_MUTE",e[e.AUDIO_MUTE=64]="AUDIO_MUTE",e))(fO||{}),_O=(e=>(e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e))(_O||{}),gO=(e=>(e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e))(gO||{}),EO=(e=>(e.ANCHOR="anchor",e.AUDIENCE="audience",e))(EO||{}),vO=(e=>(e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e))(vO||{}),yO=((eO=yO||{}).INITIALIZED="INITIALIZED",eO.STARTING="STARTING",eO.STARTED="STARTED",eO.FAILED="FAILED",eO),TO=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(TO||{}),IO=(e=>(e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e))(IO||{}),AO=(e=>(e.ADD="add",e.REMOVE="remove",e))(AO||{}),SO=(e=>(e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e))(SO||{}),RO={1:"audio",2:"auxVideo",4:"video"},bO=((Zk=bO||{})[Zk.opus=111]="opus",Zk),wO=(e=>(e[e.h264=100]="h264",e[e.vp8=101]="vp8",e))(wO||{}),DO=(e=>(e.Big="big",e.Small="small",e))(DO||{}),CO=(e=>(e.Main="main",e.Aux="auxiliary",e))(CO||{}),NO=(e=>(e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e))(NO||{}),kO=((Qk=kO||{})[Qk.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",Qk[Qk.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",Qk[Qk.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",Qk[Qk.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",Qk[Qk.MUTE_AUDIO=32772]="MUTE_AUDIO",Qk[Qk.MUTE_VIDEO=32773]="MUTE_VIDEO",Qk[Qk.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",Qk[Qk.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",Qk[Qk.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",Qk[Qk.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",Qk[Qk.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",Qk[Qk.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",Qk[Qk.SWITCH_CAMERA=32780]="SWITCH_CAMERA",Qk[Qk.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",Qk[Qk.REPLACE_VIDEO=32782]="REPLACE_VIDEO",Qk[Qk.REPLACE_AUDIO=32783]="REPLACE_AUDIO",Qk[Qk.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",Qk[Qk.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",Qk[Qk.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",Qk[Qk.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",Qk[Qk.JOIN=32788]="JOIN",Qk[Qk.LEAVE=32789]="LEAVE",Qk[Qk.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",Qk[Qk.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",Qk[Qk.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",Qk[Qk.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",Qk[Qk.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",Qk[Qk.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",Qk[Qk.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",Qk[Qk.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",Qk[Qk.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",Qk[Qk.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",Qk[Qk.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",Qk[Qk.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",Qk[Qk.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",Qk[Qk.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",Qk[Qk.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",Qk[Qk.PUBLISH_AUX=32805]="PUBLISH_AUX",Qk[Qk.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",Qk[Qk.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",Qk[Qk.VIDEO_ENCODER=4004]="VIDEO_ENCODER",Qk[Qk.VIDEO_DECODER=4005]="VIDEO_DECODER",Qk),OO=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e))(OO||{}),MO=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e))(MO||{}),LO=(e=>(e.user="user",e.environment="environment",e))(LO||{}),PO=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e))(PO||{}),xO=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e))(xO||{}),UO=(e=>(e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e))(UO||{}),VO=(($k=VO||{})[$k.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",$k[$k.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",$k[$k.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",$k[$k.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",$k[$k.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",$k[$k.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",$k[$k.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",$k[$k.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",$k[$k.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",$k),FO=1e8,BO=class{constructor(){Hb(this,"mediaType",0)}set audio(e){e?this.mediaType|=1:this.mediaType&=-2}get audio(){return!!(1&this.mediaType)}set video(e){e?this.mediaType|=4:this.mediaType&=-5}get video(){return!!(4&this.mediaType)}set auxiliary(e){e?this.mediaType|=2:this.mediaType&=-3}get auxiliary(){return!!(2&this.mediaType)}set smallVideo(e){e?this.mediaType|=8:this.mediaType&=-9}get smallVideo(){return!!(8&this.mediaType)}},HO=(e=>(e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e))(HO||{}),jO=(e=>(e.H264="h264",e.H265="h265",e.VP8="vp8",e))(jO||{}),GO=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(GO||{}),WO=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(WO||{}),KO=(e=>(e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e))(KO||{}),zO=((Xk=zO||{})[Xk.SUCCESS=0]="SUCCESS",Xk[Xk.FAILED=1]="FAILED",Xk[Xk.WEBCODEC_INIT=2]="WEBCODEC_INIT",Xk[Xk.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",Xk[Xk.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",Xk[Xk.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",Xk[Xk.WASM_INIT=6]="WASM_INIT",Xk[Xk.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",Xk[Xk.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",Xk[Xk.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",Xk[Xk.TEST=10]="TEST",Xk[Xk.RENDER_2D_ERROR=11]="RENDER_2D_ERROR",Xk),qO=(e=>(e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e))(qO||{}),JO=(e=>(e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e))(JO||{}),YO={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"},XO={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(eC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(eC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(o,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(o,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:r}=e;return"Failed to join room - ".concat(t," code: ").concat(r)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:r,streamType:i}=e;return"failed to subscribe ".concat(r," ").concat(i," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},PLAY_FAILED:e=>"".concat(e.media," play failed, browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:r}=e;return"an error was caught in ".concat(t,".on('").concat(r,"', handler), please check your code in 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"please avoid repeated join.",CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:r,timesInSecond:i,maxSizeInSecond:o}=e;return"api ".concat(r," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(o," bytes"):i," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},$O=(e,t)=>t?"".concat(Ew,"/").concat(e,"/").concat(t):"".concat(Ew,"/").concat(e,"/index.html"),QO=()=>{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(Aw);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 ZO(e){let{key:t,data:r,link:i,addDocLink:o=!0}=e,n="",a="",s="";tC(XO[t])?n=XO[t](r):iC(XO[t])&&(n=XO[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=QO();i?s="".concat(i.className,".html#").concat(i.fnName):l&&l[t]&&(tC(l[t])?s=l[t](r):iC(l[t])&&(s=l[t]));let u=n;return XD()&&(c&&c[t]&&(tC(c[t])?a=c[t](r):iC(c[t])&&(a=c[t])),a&&(u=o?"".concat(a,"\n请查看文档: ").concat($O("zh-cn",s),"\n\n"):"".concat(a,"\n\n"),u+=n)),o&&(u+=" \nRefer to: ".concat($O("en",s),"\n")),u}var eM,tM=Fb(Jb(),1),rM=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Hb(this,"countMap",new Map),Hb(this,"distributionMap",new Map),Hb(this,"version"),Hb(this,"log",Kk.createLogger({id:"kv"})),e&&(Hk.on("102",(e=>{let{track:t,cost:r}=e;this.addSuccessEvent({key:t.kind===Lw.AUDIO?501700:511700,cost:r})})),Hk.on("103",(e=>{let{track:t,error:r}=e;this.addFailedEvent({key:t.kind===Lw.AUDIO?501700:511700,error:r})})))}getReportData(){let e={msg_sdk_basic_info:{uint32_sdk_version:MC(this.version||nw),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}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:r=!1}=e;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:r,useUV:i=!0}=e;var o;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(i&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let n=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map;n.set(r,(n.get(r)||0)+1),this.distributionMap.set(t,n)}addNumber(e){let{key:t,value:r,split:i=100,useUV:o=!1}=e;var n;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(o&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let a=(null==(n=this.distributionMap)?void 0:n.get(t))||new Map,s=0;if(oC(i))s=Math.floor(r/i);else for(let c=i.length-1;c>0;c--)if(r>i[c]){s=c;break}a.set(s,(a.get(s)||0)+1),this.distributionMap.set(t,a)}addSuccessEvent(e){let{key:t,cost:r,timeKey:i,split:o}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),r)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:i||t+100,value:r,split:o}):i||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:r}=e;if(!t)return;let i=Xb.UNKNOWN;r&&(oC(r)?i=r:(!rC(r.extraCode)||!rC(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})}},iM=((eM=iM||{})[eM.enterRoom=500700]="enterRoom",eM[eM.exitRoom=500701]="exitRoom",eM[eM.switchRole=500702]="switchRole",eM[eM.destroy=500703]="destroy",eM[eM.startLocalAudio=500704]="startLocalAudio",eM[eM.updateLocalAudio=500705]="updateLocalAudio",eM[eM.stopLocalAudio=500706]="stopLocalAudio",eM[eM.startLocalVideo=500707]="startLocalVideo",eM[eM.updateLocalVideo=500708]="updateLocalVideo",eM[eM.stopLocalVideo=500709]="stopLocalVideo",eM[eM.startScreenShare=500710]="startScreenShare",eM[eM.updateScreenShare=500711]="updateScreenShare",eM[eM.stopScreenShare=500712]="stopScreenShare",eM[eM.startRemoteVideo=500713]="startRemoteVideo",eM[eM.updateRemoteVideo=500714]="updateRemoteVideo",eM[eM.stopRemoteVideo=500715]="stopRemoteVideo",eM[eM.muteRemoteAudio=500716]="muteRemoteAudio",eM[eM.setRemoteAudioVolume=500717]="setRemoteAudioVolume",eM[eM.use=500718]="use",eM[eM.sendSEIMessage=5e5]="sendSEIMessage",eM[eM.sendCustomMessage=500001]="sendCustomMessage",eM),oM=(e=>(e[e.AudioMixer=550700]="AudioMixer",e[e.AIDenoiser=551700]="AIDenoiser",e[e.VirtualBackground=570700]="VirtualBackground",e[e.Beauty=571700]="Beauty",e[e.Watermark=572700]="Watermark",e[e.BasicBeauty=574700]="BasicBeauty",e[e.CDNStreaming=590700]="CDNStreaming",e[e.DeviceDetector=591700]="DeviceDetector",e[e.Debug=592700]="Debug",e))(oM||{}),nM=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e))(nM||{}),aM=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e))(aM||{}),sM=new rM(!0),cM=new rM(!1),lM=sM,uM={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},dM=new Map([[lN,["Firefox",uN]],[mN,["Edg",fN]],[ck,["Chrome",dk]],[hk,["Safari",mk]],[TN,["TBS",IN]],[AN,["XWEB",SN]],[DN&&rN,["WeChat",CN]],[MN,["QQ(Win)",LN]],[kN,["QQ(Mobile)",ON]],[NN,["QQ(Mobile X5)",ON]],[PN,["QQ(Mac)",xN]],[UN,["QQ(iPad)",VN]],[zN,["MI",qN]],[JN,["HW",$N]],[QN,["Samsung",ZN]],[ek,["OPPO",tk]],[rk,["VIVO",ik]],[hN,["EDGE",pN]],[gN,["SogouMobile",EN]],[vN,["Sogou",yN]]]);function hM(){let e=dM.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var pM=function(){return!(WN||hN||mN&&_N<80||lN&&dN<56)},mM=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},fM=function(){if(!navigator.mediaDevices)return gM()||Kk.error(XO.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},_M=!1;function gM(){return"http:"===location.protocol&&!Sk&&(_M||Kk.error(ZO({key:YO.NOT_SUPPORTED_HTTP})),_M=!0,!0)}var EM=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},vM=function(){return Gb(this,null,(function*(){if(uM.detail.isH264EncodeSupported&&uM.detail.isVp8EncodeSupported)return{isH264EncodeSupported:uM.detail.isH264EncodeSupported,isVp8EncodeSupported:uM.detail.isVp8EncodeSupported};let e,t=!1,r=!1;try{let i=new RTCPeerConnection,o=document.createElement(Lw.CANVAS);o.getContext("2d");let n=o.captureStream(0);return i.addTrack(n.getVideoTracks()[0],n),e=yield i.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),uM.detail.isH264EncodeSupported=t,uM.detail.isVp8EncodeSupported=r,{isH264EncodeSupported:uM.detail.isH264EncodeSupported,isVp8EncodeSupported:uM.detail.isVp8EncodeSupported}}catch(cD){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},yM=function(){return Gb(this,null,(function*(){if(uM.detail.isH264DecodeSupported&&uM.detail.isVp8DecodeSupported)return{isH264DecodeSupported:uM.detail.isH264DecodeSupported,isVp8DecodeSupported:uM.detail.isVp8DecodeSupported};let e,t=!1,r=!1;try{let i=new RTCPeerConnection;return e=yield i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:r}}catch(cD){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},TM=xC((()=>Gb(void 0,null,(function*(){if(uM.result&&uM.detail.isH264EncodeSupported&&uM.detail.isVp8EncodeSupported&&uM.detail.isH264DecodeSupported&&uM.detail.isVp8DecodeSupported)return uM;let e=Date.now(),t=pM(),r=JM(),i=mM(),o=fM(),{isH264EncodeSupported:n,isVp8EncodeSupported:a}=yield vM(),{isH264DecodeSupported:s,isVp8DecodeSupported:c}=yield yM();if(!n||!a){let e=yield vM();Kk.warn("detect encode again h264:".concat(n," vp8:").concat(a," result: ").concat(JSON.stringify(e))),n=e.isH264EncodeSupported,a=e.isVp8EncodeSupported}if(n&&s&&nN&&sk&&!AN&&!TN){let{encode:e,decode:t}=yield function(){return Gb(this,null,(function*(){return SM||(SM=new Promise((e=>Gb(this,null,(function*(){let t={encode:!1,decode:!1},r=()=>{};try{let i=document.createElement("canvas"),o=i.getContext("2d");i.width=320,i.height=240;let n=setInterval((()=>{o.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),a=-1,s=-1;r=()=>{clearInterval(a),clearInterval(n),clearTimeout(s),l.close(),u.close(),c.getTracks().forEach((e=>e.stop()))},s=setTimeout((()=>{r(),e(t)}),2e3);let c=i.captureStream(),l=new RTCPeerConnection({}),u=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});l.addEventListener("icecandidate",(e=>u.addIceCandidate(e.candidate))),u.addEventListener("icecandidate",(e=>l.addIceCandidate(e.candidate))),l.addTrack(c.getVideoTracks()[0],c);let d=yield l.createOffer();yield l.setLocalDescription(d),yield u.setRemoteDescription(d);let h=yield u.createAnswer(),p=tM.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=tM.default.write(p),yield u.setLocalDescription(h),yield l.setRemoteDescription(h),a=setInterval((()=>Gb(this,null,(function*(){t.encode&&t.decode&&(r(),e(t));let[i,o]=yield Promise.all([l.getSenders()[0].getStats(),u.getReceivers()[0].getStats()]);t.encode||i.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===Lw.VIDEO&&e.bytesSent>0&&(t.encode=!0)})),t.decode||o.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===Lw.VIDEO&&e.bytesReceived>0&&(t.decode=!0)}))}))),100)}catch(i){r(),Kk.warn("detectH264Supported failed",i),e({encode:!0,decode:!0})}})))).then((e=>(e.encode||(e.decode=!0),(!e.encode||!e.decode)&&Kk.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(Nk)),e))),SM)}))}();n=e,s=t}return uM.result=t&&r&&o&&(n||a)&&(s||c),uM.detail.isBrowserSupported=t,uM.detail.isWebRTCSupported=r,uM.detail.isWebCodecsSupported=i,uM.detail.isMediaDevicesSupported=o,uM.detail.isScreenShareSupported=AM(),uM.detail.isSmallStreamSupported=kM(),uM.detail.isH264EncodeSupported=n,uM.detail.isVp8EncodeSupported=a,uM.detail.isH264DecodeSupported=s,uM.detail.isVp8DecodeSupported=c,uM.result||Kk.error("".concat(navigator.userAgent," ").concat(CC(uM.detail,!1))),qk.setItem(eL,{ua:navigator.userAgent,checkResult:uM}),lM.addNumber({key:523800,value:Date.now()-e}),uM})))),IM=function(){return uM.result},AM=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},SM=null;var RM=(e,t,r)=>{"http:"===location.protocol&&!Sk&&(e[t]=()=>{throw new Qb({code:Xb.INVALID_OPERATION,message:XO.NOT_SUPPORTED_HTTP})})},bM=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(nC(e.selected)&&!e.selected)};function wM(){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 DM(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function CM(){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 NM(){return"captureStream"in HTMLCanvasElement.prototype}function kM(){return!(DN||oN||uk&&uk<63)&&!(!pM()||!NM())}var OM=function(){if(rC(window.RTCRtpTransceiver)||!xM()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:mD}),e.addTransceiver(Lw.AUDIO),t=!0}catch(sw){}return null==e||e.close(),t};function MM(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function LM(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function PM(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function xM(){return!(11===Ek&&!Ak)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var UM=!(!xM()||sk&&uk<86);function VM(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var FM="RTCRtpSender"in window;function BM(){return FM&&"replaceTrack"in window.RTCRtpSender.prototype}function HM(){return FM&&"setParameters"in window.RTCRtpSender.prototype&&LM()}var jM="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,GM=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,WM=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,KM=FM&&"createEncodedStreams"in window.RTCRtpSender.prototype&&ak()>=86,zM="RTCRtpScriptTransform"in window,qM=FM&&(KM||zM),JM=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function YM(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return rC(window.AudioDecoder)||(e.AudioDecoder=!0),rC(window.AudioEncoder)||(e.AudioEncoder=!0),rC(window.VideoDecoder)||(e.VideoDecoder=!0),rC(window.VideoEncoder)||(e.VideoEncoder=!0),rC(window.ImageDecoder)||(e.ImageDecoder=!0),e}function XM(){return"mediaSession"in navigator&&!rC(navigator.mediaSession.setActionHandler)}function $M(){return!rC(window.WebTransport)}function QM(){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 ZM(){let e={browser:"".concat(bk.name,"/").concat(bk.version),os:Pk(),displayResolution:wM(),isScreenShareSupported:AM(),isWebRTCSupported:JM(),isGetUserMediaSupported:DM(),isWebAudioSupported:CM(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:YM(),isMediaSessionSupported:XM(),isWebTransportSupported:$M()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var eL="checkResult";function tL(){gM();let e=qk.getItem(eL);e&&e.ua===navigator.userAgent&&(uM=e.checkResult),TM()}function rL(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var iL="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,oL=Fb(Wb(),1),nL=Symbol("instance"),aL=Symbol("cacheResult"),sL=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,hL.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},cL=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var lL=new Map;function uL(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=lL.get(i)||[];lL.has(i)||lL.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(r.context&&(i=pL.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[aL]:Promise.resolve(i[aL]);i.state instanceof sL&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof sL&&i.state.abort(i):("string"!=typeof i.state||!e.includes(i.state))&&(l=new cL(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new cL(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let u=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 u(l);let d=i.state,h=new sL(d,t,a);hL.call(i,h);let p=e=>{var o;return i[aL]=e,h.aborted||(hL.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[aL])),e},m=e=>(hL.call(i,d,e),u(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(oO){return m(new cL(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(oO),oO instanceof Error?oO:new Error(String(oO))))}}}}var dL="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 hL(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(pL.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var pL=class e extends oL.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[nL];o?this.name=o.name+"-"+o.count++:i[nL]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=lL.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);lL.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};dL(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){hL.call(this,e)}};pL.STATECHANGED="stateChanged",pL.UPDATEAFSM="updateAFSM",pL.INIT="[*]",pL.ON="on",pL.OFF="off",pL.instances=new Map,pL.instances2=new WeakMap;var mL="undefined"!=typeof window,fL=mL&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},_L=mL&&window.cancelIdleCallback||function(e){clearTimeout(e)},gL=mL&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),EL=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=Pb("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=xb(Pb({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=fC(),o=()=>{if(r=fC()-i,r>=t.delay&&(i=fC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=fL(o,{timeout:t.delay})};return t.ricID=fL(o,{timeout:t.delay})}static raf(t){let r,i=fC(),o=()=>document.hidden&&t.backgroundTask?(r=fC()-i,i=fC(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(o,t.delay-Math.floor(r%t.delay))):(r=fC()-i,r>=t.delay&&(i=fC()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(o));if(t.rafID=requestAnimationFrame(o),t.backgroundTask){let e=()=>{if(document.hidden){let e=fC()-i;e>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-e)}};document.addEventListener("visibilitychange",e),t.onVisibilitychange=e,document.hidden&&e()}return t.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:r,rafID:i,ricID:o,onVisibilitychange:n}=this.taskMap.get(e);return t&&clearInterval(t),r&&clearTimeout(r),i&&gL&&gL(i),o&&_L(o),n&&document.removeEventListener("visibilitychange",n),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.hasTask(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};Hb(EL,"taskMap",new Map),Hb(EL,"currentTaskID",1),Hb(EL,"sharedWorker",null),Hb(EL,"workerTasks",new Map);var vL=EL;Lw.SEI_MESSAGE;var yL={LOADED_DATA:Lw.LOADEDDATA,LOADED_META_DATA:Lw.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},TL={};Vb(TL,{create:()=>AL,remove:()=>SL});var IL=new WeakMap;function AL(e,t){IL.has(e)||IL.set(e,[]);let r=IL.get(e),i={add:(e,o)=>("addEventListener"in t?(r.push(t.removeEventListener.bind(t,e,o)),t.addEventListener(e,o)):(r.push(t.off.bind(t,e,o)),t.on(e,o)),i)};return i}function SL(e){let t=IL.get(e);t&&(t.forEach((e=>e())),IL.delete(e))}var RL=new class{constructor(){Hb(this,"_roomIdMap",new Map),Hb(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:nw,env:Rw.QCLOUD,browserVersion:bk.name+bk.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:r,userId:i,roomId:o}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=r,this._configs.userId=i,this._roomIdMap.set(i,String(o))}logSuccessEvent(e){Sk||!Kk.isAbleToUpload||this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(xb(Pb({},e),{result:"success"}))}logFailedEvent(e){if(Sk||!Kk.isAbleToUpload)return;let{eventType:t,code:r,error:i,userId:o}=e,n={roomId:this._roomIdMap.get(o||this._configs.userId),userId:o,eventType:t,result:"failed",code:r||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||Xb.UNKNOWN};this._configs.env===Rw.QCLOUD&&this.uploadEventToKibana(xb(Pb({},n),{error:i}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:r,error:i}=e,o={timestamp:ew(),sdkAppId:this._configs.sdkAppId,userId:r||this._configs.userId,version:nw,log:t};i&&(o.errorInfo=i.message,i.stack&&(o.errorInfo+="\n".concat(i.stack))),this.sendRequest(VD(this._configs.sdkAppId,Sw.LOG),o)}sendRequest(e,t){setTimeout((()=>FC({url:e,body:JSON.stringify(t),priority:"low"}).catch((()=>{}))),2e3)}},bL=new WeakMap;function wL(e){let{settings:t={retries:5,timeout:2e3},onError:r,onRetrying:i,onRetryFailed:o}=e;return function(e,n,a){let s=KC({retryFunction:a.value,settings:t,onError(t){let{error:i,retry:o,reject:a,retryFuncArgs:s}=t;var c;r?r.call(this,i,(()=>{var t;null!=(t=bL.get(e))&&t.has(n)?o():a(i)}),a,s):null!=(c=bL.get(e))&&c.has(n)?o():a(i)},onRetrying(t,r){var o;jC(i)&&i.call(this,t,r),null!=(o=bL.get(e))&&o.has(n)&&(bL.get(e).get(n).stopRetry=r)},onRetryFailed:o});return a.value=function(){let t=bL.get(e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return t?t.set(n,{args:i}):bL.set(e,new Map([[n,{args:i}]])),s.apply(this,i).finally((()=>{var t;return null==(t=bL.get(e))?void 0:t.delete(n)}))},a}}var DL=class extends pL{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,Hb(this,"id"),Hb(this,"element",null),Hb(this,"track"),Hb(this,"url"),Hb(this,"attr"),Hb(this,"mode"),Hb(this,"muted"),Hb(this,"_log"),Hb(this,"_pausedRetryCount"),Hb(this,"_isElementPlayingFired",!1),Hb(this,"_interval"),Hb(this,"_delayDestroyTimeoutId",0),Hb(this,"_playSuccessResolve"),Hb(this,"_isReplayByRecreateMediaStreamCalled",!1),Hb(this,"isInAutoPlayFailedState",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=bD,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 isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return Gb(this,null,(function*(){if(!this.isPlaying)try{this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),yield new Promise(((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)}))}catch(sw){let t=ZO({key:YO.PLAY_FAILED,data:{media:this.kind,error:sw}});if(this.track&&!this.track.muted&&this._log.warn(sw),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new Qb({code:Xb.PLAY_NOT_ALLOWED,message:t})}}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!pk?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(e)),this._delayDestroyTimeoutId=setTimeout((()=>this.destroyElement()),3*e)):this.destroyElement(),this.handleStopped(Lw.ENDED),this._interval>0&&vL.clearTask(this._interval)}destroyElement(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}pause(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}resume(){return this._log.info("resume"),this.isPlaying?Promise.resolve():yk?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 AL(this.element,this.element).add(Lw.PLAYING,e).add(Lw.ENDED,e).add(Lw.PAUSE,e).add(Lw.ERROR,e).add(Lw.LOADEDDATA,e).add(Lw.LOADEDMETADATA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==TL||TL.create(e,e).add(Lw.ENDED,t).add(Lw.MUTE,t).add(Lw.UNMUTE,t),e.readyState===Lw.ENDED&&this.handleTrackEvent({type:Lw.ENDED}),e.muted&&this.handleTrackEvent({type:Lw.MUTE})}}bindAutoPlayEvent(){Hk.on(Gk.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&SL(e)}unbindEvents(){this.element&&SL(this.element),this.unbindTrackEvents(),Hk.off(Gk.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){switch(e.type){case Lw.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(Lw.PLAYING),this._interval&&(vL.clearTask(this._interval),this._interval=-1);break;case Lw.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(Lw.ENDED);break;case Lw.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(Lw.PAUSE),oN&&(this._interval=vL.run("timeout",(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case Lw.ERROR:if(this.element&&this.element.error){this.handlePaused(Lw.ERROR);let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),RL.uploadEvent({log:"stat-".concat(this.kind,"-").concat(uD.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),XN||YN?this.emit(yL.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case Lw.LOADEDDATA:this.kind===Lw.VIDEO&&this.emit(yL.LOADED_DATA);break;case Lw.LOADEDMETADATA:this.kind===Lw.VIDEO&&this.emit(yL.LOADED_META_DATA)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((()=>{this._log.warn("replayByRecreateMediaStream success"),RL.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),lM.addSuccessEvent({key:this.kind===Lw.AUDIO?506700:516700})})).catch((()=>{var t;this._log.error("replayByRecreateMediaStream failed"),RL.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),lM.addFailedEvent({key:this.kind===Lw.AUDIO?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(yL.ERROR,e)}))}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise(((t,r)=>{PC(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)}),PC(5e3).then((()=>{var e,i;(!this.isPlaying||null!=(e=this.element)&&e.error)&&r(null==(i=this.element)?void 0:i.error),t()}))}))})).finally((()=>{this.element&&(this.element.onerror=null)}))}handleTrackEvent(e){switch(e.type){case Lw.ENDED:this.handleStopped(Lw.ENDED);break;case Lw.MUTE:this.handlePaused(Lw.MUTE);break;case Lw.UNMUTE:this._isElementPlayingFired?this.handlePlaying(Lw.UNMUTE):this.mode>0&&this.handlePlaying(this.mode.toString())}}handlePlaying(e){var t;null==(t=this._playSuccessResolve)||t.call(this,e),this.emit(yL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(yL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}handleStopped(e){this.emit(yL.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};Bb([wL({settings:{retries:2,timeout:0},onError(e,t,r,i){i[0]=(i[0]||1e3)+1e3,t()}})],DL.prototype,"doReplayByRecreateMediaStream",1),Bb([uL([],"PLAYING",{sync:!0})],DL.prototype,"handlePlaying",1),Bb([uL("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],DL.prototype,"handlePaused",1),Bb([uL([],"STOPPED",{sync:!0})],DL.prototype,"handleStopped",1);var CL,NL="trtc_autoplay",kL="".concat(NL,"_mask"),OL="".concat(NL,"_wrapper"),ML="".concat(NL,"_header"),LL="".concat(NL,"_content"),PL="".concat(NL,"_action_wrapper"),xL="".concat(NL,"_question"),UL="".concat(NL,"_collapse"),VL="".concat(NL,"_action_confirm"),FL="".concat(NL,"_detail"),BL="#2473E8",HL="dialog",jL="".concat(HL,"-show"),GL="".concat(HL,"-1"),WL="".concat(HL,"-2"),KL=!1,zL=()=>!!document.querySelector(".".concat(OL)),qL="".concat(Ew,"/").concat(XD()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),JL="<br><a href='".concat(qL,"' target='_blank'>").concat(XD()?"其他方案?":"Any other solution?","</a>"),YL="".concat(XD()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(JL):"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(JL)),XL=class{constructor(){if(Hb(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),Hb(this,"_dialogNode",null),Hb(this,"_bodyPosition",""),Hb(this,"_showDetail",!1),Hb(this,"_isCollapseClicked",!1),Hb(this,"_isQuestionClicked",!1),XD()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!KL){let e=document.createElement("style");e.innerHTML=".".concat(kL,"{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(kL," div:not(.").concat(PL,"){display:block !important;}.").concat(OL,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(OL," a{color:").concat(BL,";}.").concat(ML,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(LL,"{margin:8px 0;}.").concat(PL,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(UL,"{margin-right:auto;cursor:pointer}.").concat(xL,"{height:100%;line-height:16px;cursor:pointer;}.").concat(VL,"{margin-left:8px;color:#fff;background:").concat(BL,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(VL,":hover{opacity:0.9;}.").concat(UL,",.").concat(VL,",.").concat(LL,",.").concat(xL,"{font-size:14px;}@media screen and (max-width:750px){.").concat(OL,"{width:80vw;}}"),document.head.appendChild(e),KL=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(kL,"\"><div class='").concat(OL,"'><div class='").concat(ML,"'>").concat(location.host,"</div><div class='").concat(LL,"'>").concat(this.content,"</div><div class='").concat(FL,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(YL,"</div><div class='").concat(PL,"'></div></div></div>").trim();let t=document.createElement("button");t.className=VL,t.innerText=XD()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let r=document.createElement("div");r.className=xL,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=UL,i.innerText="".concat(XD()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let o=e.content.firstChild,n=o.querySelector(".".concat(PL));return n.appendChild(i),n.appendChild(r),n.appendChild(t),o}addDiaLog(){zL()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(OL)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",Kk.info("show autoplay dialog"),RL.uploadEvent({log:jL}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){Kk.warn("confirm clicked, try resume stream"),Hk.emit(Gk.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(FL));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||RL.uploadEvent({log:GL}),this._isCollapseClicked=!0}onQuestionClick(){window.open(qL,"_blank"),this._isQuestionClicked||RL.uploadEvent({log:WL}),this._isQuestionClicked=!0}},$L=class extends DL{constructor(e){super(e,Lw.VIDEO),Hb(this,"stat",{}),Hb(this,"_calculateTimeout",-1),Hb(this,"viewMirror",!1),Hb(this,"objectFit"),Hb(this,"container"),Hb(this,"canvas"),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,rC(e.viewMirror)||(this.viewMirror=e.viewMirror),rC(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}get isPlaying(){var e;return!("PLAYING"!==this._state||this.element&&this.element.paused)&&("live"===(null==(e=this.track)?void 0:e.readyState)&&!this.track.muted)}initializeElement(){var e;let t=document.createElement(Lw.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(Lw.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(Lw.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}handleTrackEvent(e){var t;super.handleTrackEvent(e),e.type===Lw.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0)}handleElementEvent(e){var t;if(2===this.mode)return;super.handleElementEvent(e);let r=e.type;if(r===Lw.PAUSE&&(this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id)),this._pausedRetryCount>0&&!zL()&&(this._log.info("".concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;r===Lw.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):r===Lw.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var r,i,o,n;this.canvas!==e&&(null==(r=this.canvas)||r.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?t:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(i=this.element)||i.remove(),null==(o=this.container)||o.appendChild(e)):this.element&&(null==(n=this.container)||n.appendChild(this.element)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}setPoster(e){this.element&&(this.element.poster=e)}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;super.stop(e),null==(t=this.canvas)||t.remove()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(yL.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}calculateStat(){try{if(rL()&&this.element&&this._calculateTimeout<0){let e=0,t=null,r=(i,o)=>{this.stat.width=o.width,this.stat.height=o.height,t&&(this.stat.fps=Math.round((o.presentedFrames-t.presentedFrames)/(i-e)*1e3)),e=i,t=o,this._calculateTimeout=-1,this.element&&(this._calculateTimeout=setTimeout((()=>{var e;return null==(e=this.element)?void 0:e.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(sw){this._log.warn("init stat failed",sw)}}};function QL(e,t){return Gb(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),Kk.info("worklet addModule success")}catch(sw){throw Kk.info("worklet addModule catch error. ".concat(sw.message)),sw}}))}"undefined"!=typeof AudioContext?CL=AudioContext:"undefined"!=typeof webkitAudioContext?CL=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(CL=mozAudioContext);var ZL,eP=-1;!function e(){try{if(ZL)return;(ZL=new CL({sampleRate:48e3})).onstatechange=()=>{Kk.info("context state: ".concat(ZL.state).concat("running"!==ZL.state?" visibilityState: ".concat(document.visibilityState):"")),tP()},clearTimeout(eP)}catch(CF){Kk.error("initAudioContext failed: ".concat(CF," typeof AudioContextClass: ").concat(typeof CL)),eP=setTimeout(e,1e3)}}();var tP=()=>{"suspended"===ZL.state?(oP(),document.addEventListener("click",tP)):"interrupted"===ZL.state?oP():(document.removeEventListener("visibilitychange",tP),document.removeEventListener("click",tP))},rP=0,iP=-1;function oP(){return new Promise(((e,t)=>{if("running"===ZL.state)return e();Date.now()-rP<1e3?(clearTimeout(iP),iP=setTimeout((()=>{rP=Date.now(),ZL.resume().then(e,t)}),1e3)):(clearTimeout(iP),rP=Date.now(),ZL.resume().then(e,t))})).catch((e=>{Kk.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",tP)}))}document.addEventListener("click",tP);var nP=e=>ZL,aP=class{constructor(){Hb(this,"node"),Hb(this,"node2"),Hb(this,"pre",new Set),Hb(this,"next",new Set),Hb(this,"context"),Hb(this,"connectedNodes",new Set),Hb(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(cD){Kk.error(cD)}}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(),lM.addSuccessEvent({key:502701})}catch(eO){Kk.error(eO),lM.addFailedEvent({key:502701,error:eO})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),lM.addSuccessEvent({key:502702})}catch(sw){Kk.error(sw),lM.addFailedEvent({key:502702,error:sw})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>{e._connect(t.node)||t.connectNext(e)}))}_connect(e){return!(!this.node||!e)&&((this.node2||this.node).connect(e),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(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.forEach((e=>{this.next.add(e),e.pre.add(this)})),this}},sP=class extends aP{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,Hb(this,"dataArray",new Uint8Array(0))}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,r=0,i="M".concat(t,",").concat(r);for(let o=0;o<e.length;o++)r=e[o]/128*100/2,i+="L".concat(t,",").concat(r),t+=1;return i}},cP=class{constructor(){Hb(this,"source",new aP),Hb(this,"gain",new aP),Hb(this,"destination",new aP)}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(nP().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){this.source.replaceNode(hP(e))}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}},lP=class extends cP{constructor(e){super(),this.context=e,Hb(this,"denoiser",new aP),Hb(this,"voiceChanger",new aP),this.source.pipeTo(this.denoiser.pipeTo(this.voiceChanger.pipeTo(this.gain.pipeTo(this.destination))))}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},uP=class{constructor(){Hb(this,"audioContext",nP()),Hb(this,"destination",this.audioContext.createMediaStreamDestination()),Hb(this,"inputs",new Set),Hb(this,"mixWeight",0),this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},dP=new WeakMap;function hP(e){let t=dP.get(e);if(t)return t;let r=nP();if(e instanceof HTMLAudioElement)t=r.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=r.createMediaStreamSource(new MediaStream([e]))}return dP.set(e,t),t}var pP=class e{constructor(e){Hb(this,"_volume",0),Hb(this,"_volumeDb",0),Hb(this,"_log"),Hb(this,"_scriptProcessorNode",null),Hb(this,"_audioWorkletNode",null),Hb(this,"_interval",200),Hb(this,"ready",this.preload());let{log:t}=e;this._log=t,Hk.on(Gk.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(!e.workletReady){let t='class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);';e.workletReady=QL(e.audioContext,URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}return e.workletReady.then((()=>this.initAudioWorklet())).catch((e=>(this._log.error("volumeMeter preload error: ".concat(e)),this.initScriptProcessor())))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");let t=!1;this._audioWorkletNode.port.onmessage=r=>{e.lastMessageTime=Date.now(),this._volume=r.data.volume||0,this._volumeDb=r.data.volumeDb||0,!t&&r.data.cacheLen&&r.data.outputLen&&(this._log.warn("worklet play success"),t=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(Zk){this._log.error("volumeMeter init audio worklet error: ".concat(Zk)),RL.logFailedEvent({userId:this._log.userId,eventType:uD.LOAD_WORKLET,error:Zk}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=nP().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let r=t.inputBuffer.getChannelData(0),i=0;for(let e=0;e<r.length;++e)i+=r[e]*r[e];this._volume=Math.sqrt(i/r.length)||0}}catch(Zk){this._log.error("volumeMeter init script processor error: ".concat(Zk))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,Hk.off(Gk.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})}};Hb(pP,"lastMessageTime",0),Hb(pP,"audioContext",nP()),Hb(pP,"workletReady");var mP=pP,fP=class extends aP{constructor(e){super(),Hb(this,"_volumeMeter"),this._volumeMeter=new mP(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}init(){return Gb(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}getVolumeDb(){return this._volumeMeter.getVolumeDb()}write(e){if(this.node){let t=e.allocationSize({planeIndex:0}),r=new Float32Array(t>>2);e.copyTo(r,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:r},[r.buffer]),e.close()}}},_P=mP,gP=Fb(Wb(),1),EP=e=>t=>t.deviceId===e,vP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";Hb(this,"kind"),Hb(this,"type"),Hb(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&&IP(this.devices[0])||t&&(r.forEach((e=>{if(e.deviceId&&!this.devices.find(EP(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Added");Kk.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!r.find(EP(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Removed");Kk.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}}))),this.devices=r}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},yP=class extends gP.EventEmitter{constructor(){super(),Hb(this,"audioInputs",new vP(Lw.AUDIO)),Hb(this,"videoInputs",new vP(Lw.VIDEO)),Hb(this,"audioOutputs",new vP(Lw.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||vL.run("interval",(()=>{this.update()}),{delay:1e4}))}init(){AP().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return Gb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let r=yield AP(t);return e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e}()}))}},TP=uw||lw?null:new yP;function IP(e){return e.deviceId===e.groupId&&""===e.groupId}function AP(){return Gb(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(gM()||!fM())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let r={audio:!1,video:!1};if(t.forEach((e=>{IP(e)&&(e.kind===Lw.AUDIO_INPUT?r.audio=!0:e.kind===Lw.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),r.audio||r.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(r),r.audio&&oP()}catch(eO){Kk.debug("capture before getDevices failed: ",eO)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let r={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&DP.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(r.getCapabilities=()=>e.getCapabilities()),r}))}()}))}function SP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return TP.update(e?1:0).then((e=>e.audioInputs.devices))}function RP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return TP.update(e?2:0).then((e=>e.videoInputs.devices))}var bP=!1;function wP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Gb(this,null,(function*(){return(oN||hk)&&(e=!1),TP.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var DP=new Set;function CP(e,t){return Gb(this,null,(function*(){let r=(yield SP()).find((e=>e.deviceId===wD));return!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t}))}var NP,kP=class extends cP{constructor(e){super(),this.log=e,Hb(this,"volumeMeter"),Hb(this,"volumeDestination"),Hb(this,"analyser",new sP),this.volumeMeter=new fP({log:this.log}),this.volumeDestination=new aP,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},OP=class e extends DL{constructor(e){super(e,Lw.AUDIO),Hb(this,"_outputDeviceId"),Hb(this,"_volume",1),Hb(this,"_destination",nP().createMediaStreamDestination()),Hb(this,"pipeline"),Hb(this,"volumeMeterMode","worklet"),this.mode=0,this.pipeline=new kP(this._log)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(e){if(("15.2"===_k||"15.3"===_k||"15.4"===_k)&&this.muted)return void this._log.info("audioElement is muted.");let t=NP||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,oC(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===NP&&(NP=void 0),this.bindElementEvents()}play(t){return Gb(this,null,(function*(){if(this.track)return this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==t?void 0:t.volume),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(nP().createAnalyser()),function(){Gb(this,null,(function*(){try{bP||(bP=!0,Kk.info("speakers:".concat((yield wP()).map((e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label))))))}catch(e){}}))}(),jb(e.prototype,this,"play").call(this)}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setSinkId(e){return Gb(this,null,(function*(){var t,r;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(r=(t=this.element).setSinkId)?void 0:r.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){this.element&&(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}},MP=class extends OP{setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(yL.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}},LP=class extends OP{constructor(e){super(e),Hb(this,"_sourceElement"),Hb(this,"_output",new aP),this.pipeline.source.pipeTo(this.pipeline.gain.pipeTo(this.pipeline.volumeMeter.pipeTo(this._output),this.pipeline.destination))}setOutput(){this.mode=1,this._output.setNode(nP().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(yL.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){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element"):oN||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),SL(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&pk&&(NP=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},PP=class extends pL{constructor(e){let{userId:t,sdkAppId:r,mediaType:i,room:o,PlayerClass:n=(1===i?LP:$L)}=e;var a;super(),Hb(this,"id",zk()),Hb(this,"userId",""),Hb(this,"isRemote"),Hb(this,"mediaType"),Hb(this,"room"),Hb(this,"user"),Hb(this,"_log"),Hb(this,"_inputTrack"),Hb(this,"_outputTrack"),Hb(this,"isPlayCalled"),Hb(this,"container",null),Hb(this,"player"),Hb(this,"subVideoPlayerMap"),Hb(this,"muted",!1),Hb(this,"abortCtrl"),Hb(this,"objectFit","cover"),Hb(this,"mirror"),Hb(this,"isScreen",!1),Hb(this,"manager"),Hb(this,"trackSettings"),Hb(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=i,this._log=Kk.createLogger({id:"".concat(this.kind[0],"t"),userId:null==(a=o||this.room)?void 0:a.userId,remoteUserId:this instanceof ZP?void 0:this.userId,sdkAppId:r,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof ZP}),this.player=new n({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log}),this.player.on(yL.PLAYER_STATE_CHANGED,(e=>{Hk.emit(Gk.PLAYER_STATE_CHANGED,Pb({track:this},e)),this.emit("player-state-changed",e)})),this.kind===Lw.VIDEO&&(this.player.on(yL.LOADED_DATA,(()=>{this.emitFirstVideoFrameEvent(yL.LOADED_DATA),Hk.emit(Gk.VIDEO_LOADED_DATA,{track:this})})),this.player.on(yL.LOADED_META_DATA,(()=>{this.emitFirstVideoFrameEvent(yL.LOADED_META_DATA)})),this.player.on(yL.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))}))),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this),this.onPlayerError&&this.player.on(yL.ERROR,this.onPlayerError.bind(this))}get log(){return this._log||Kk}get kind(){return 1===this.mediaType?Lw.AUDIO:Lw.VIDEO}get strMediaType(){return 4===this.mediaType?Lw.VIDEO:2===this.mediaType?Lw.SCREEN:Lw.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}play(e,t){return Gb(this,null,(function*(){let r=sC(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!rC(t.muted)&&this.setPlayerMute(t.muted),t&&!rC(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof $L&&(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),sC(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!rC(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===Lw.VIDEO)&&this.setPlayerMute(!0),t&&!rC(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof $L&&(this.player.setObjectFit(this.objectFit),t&&!rC(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof $L&&this.player.setContainer(r)),Hk.emit(Gk.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(t),sC(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(iO){throw this.handleAutoPlayFailed(iO),iO}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==Lw.VIDEO||rC(e)||e===this.mirror)return;this.mirror=e;let r=this.player;t&&(r=t);let i=this.manager;if(nC(this.mirror))return r.setViewMirror(this.mirror),void(i&&(i.mirror=!1));switch(this.mirror){case"view":i&&(i.mirror=!1),r.setViewMirror(!0);break;case"publish":i&&(i.mirror=!0),r.setViewMirror(!0);break;case"both":i&&(i.mirror=!0),r.setViewMirror(!1)}}playSubContainer(e,t){return Gb(this,null,(function*(){if(!this._outputTrack||this.kind===Lw.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,r)=>{var i;e.find((e=>r===e))||(t.stop(),null==(i=this.subVideoPlayerMap)||i.delete(r))}));for(let[i,o]of e.entries()){let e=this.subVideoPlayerMap.get(o);e?t&&(rC(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(o,new $L({id:this.userId||this.id,track:this.playerMediaTrack,container:o,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let r=[...this.subVideoPlayerMap.values()];for(let e of r)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(GC(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return Gb(this,null,(function*(){var e;this.isPlayCalled&&(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),Hk.emit(e?Gk.TRACK_MUTED:Gk.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){AL(e,e).add(Lw.MUTE,this.onTrackMuted).add(Lw.UNMUTE,this.onTrackUnmuted).add(Lw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Lw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){SL(e)}setInputMediaStreamTrack(e){var t;let r=this._inputTrack;if(e!==r)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,r&&this.uninstallTrackEvent(r),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,r||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((e=>this.handleAutoPlayFailed(e))),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(GC(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(e){if(this.room&&this.room.enableAutoPlayDialog)new XL;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0)}))};document.addEventListener("click",e,!0)}this.emit("error",e)}getVideoFrame(){return this.player instanceof $L?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,r,i;if(this.isFirstVideoFrameEmitted)return;let o=null==(t=this.mediaTrack)?void 0:t.getSettings(),n=(null==o?void 0:o.width)||(null==(r=this.player.element)?void 0:r.videoWidth)||0,a=(null==o?void 0:o.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;e===yL.LOADED_META_DATA&&!n&&!a||(e===yL.LOADED_DATA&&!n&&!a&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,this.emit("first-video-frame",{width:n,height:a,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}onTrackMuted(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}onTrackUnmuted(){this._log.info("".concat(this.kind," track is able to provide media output"))}onTrackEnded(){this._log.warn("".concat(this.kind," track ended"))}};Bb([uL([],pL.INIT,{sync:!0})],PP.prototype,"close",1);var xP=Object.prototype.hasOwnProperty;var UP=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($D(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(xP.call(e,t))return!1;return!0}return!1},VP=KC({retryFunction:function(e){return Gb(this,null,(function*(){let t=function(e){return{audio:BP(e),video:HP(e)}}(e);Kk.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],i=[],o=["label","deviceId","groupId"];t.audio&&(r=yield SP(),Kk.info("microphones: ".concat(DC(r.map((e=>xb(Pb({},e),{groupId:e.groupId.substring(0,8)}))),{keysToInclude:o})))),t.video&&(i=yield RP(),Kk.info("cameras: ".concat(DC(i,{keysToInclude:o}))));try{let e=yield navigator.mediaDevices.getUserMedia(t);return WM&&e.getTracks().forEach((e=>{Kk.info("".concat(e.kind," capabilities: ").concat(DC(e.getCapabilities(),{keysToInclude:LD})))})),t.audio&&oP(),e}catch(iO){let{message:o}=iO;throw"NotFoundError"===iO.name&&(e.video&&i&&0===i.length&&(o=ZO({key:YO.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(o=ZO({key:YO.MICROPHONE_NOT_FOUND}))),new Qb({code:Xb.INITIALIZE_FAILED,name:iO.name,message:o,constraint:iO.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:r,reject:i,retryFuncArgs:o,retriedCount:n}=e,a=n+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===a?(o[0].video&&(o[0].maxResolution=!1,(!hk||o[0].width*o[0].height<=2073600)&&o[0].frameRate&&(o[0].frameRate=o[0].frameRate>10?10:5)),o[0].retryWhenExactFailed&&o[0].useExactDeviceId&&(o[0].useExactDeviceId=!1)):2===a?o[0].useDeviceIdOnly=!0:3===a&&!o[0].useExactDeviceId&&(o[0].useTrueAsConstraint=!0),r()):i(t),o[0].microphoneId&&FP(o[0].microphoneId,!1),o[0].cameraId&&FP(o[0].cameraId,!0)},onRetrying:e=>{Kk.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{RL.logFailedEvent({eventType:uD.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{RL.logSuccessEvent({eventType:uD.GET_USER_MEDIA_RETRY}),RL.uploadEvent({log:"stat-".concat(uD.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function FP(e,t){return Gb(this,null,(function*(){let r=(t?yield RP():yield SP()).find((t=>t.deviceId===e));r&&tC(r.getCapabilities)&&Kk.warn(DC(r.getCapabilities(),{keysToInclude:LD}))}))}function BP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!UP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(oC(e.channelCount)&&(t.channelCount=e.channelCount),nC(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),nC(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),nC(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!UP(t)||t)}function HP(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&&!UP(r)?r:(e.width&&(r.width={ideal:e.width},t&&!lN&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},t&&!lN&&(r.height.max=e.height)),lN&&BN&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!UP(r)||r)}var jP=VP;function GP(e){return WP(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return Gb(this,null,(function*(){let r=yield t.apply(this,i);return yield e.call(this,...i),r}))}))}function WP(e){return function(t,r,i){return i.value=e(i.value,r),i}}var KP=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&Kk.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{Kk.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),zP=0,qP=class{constructor(){Hb(this,"log",Kk.createLogger({id:"fq".concat(++zP)})),Hb(this,"isRunning",!1),Hb(this,"queue",[])}get length(){return this.queue.length}get lastQueueItem(){return 0===this.length?null:this.queue[this.length-1]}push(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;let o=Pb({},e),n=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));return o.promise=n,t?this.length<=1?this.queue.push(o):null==(i=null==(r=this.lastQueueItem)?void 0:r.promise)||i.then(o.resolve,o.reject):this.queue.push(o),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),n}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}callNext(){if(this.isRunning||0===this.length)return;this.log.debug("callNext ",this.length);let{fn:e,args:t,context:r,resolve:i,reject:o}=this.queue[0];this.isRunning=!0,e.apply(r,t).then(i,o).finally((()=>{this.isRunning=!1,this.shift(),this.callNext()}))}},JP=new WeakMap,YP=new WeakMap;function XP(e){return function(t,r,i){let o=i.value,n=t=>e(...t);return i.value=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];let i=YP.get(this)||new Map,a=i.get(n(t))||new qP;return i.set(n(t),a),YP.set(this,i),a.push({fn:o,args:t,context:this})},i}}function $P(e,t){return WP(((r,i)=>function(){let i=e;try{for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let e=r.apply(this,n),s=fC();return uC(e)?e.then((e=>(t?lM.addSuccessEvent({key:i,cost:fC()-s}):lM.addSuccessEvent({key:i}),e))).catch((e=>{throw lM.addFailedEvent({key:i,error:e}),e})):(lM.addSuccessEvent({key:i}),e)}catch(cw){throw lM.addFailedEvent({key:i,error:cw}),cw}}))}var QP=class e extends PP{constructor(e,t){super({mediaType:e,PlayerClass:t}),Hb(this,"isRemote",!1),Hb(this,"deviceId"),Hb(this,"groupId",""),Hb(this,"label",""),Hb(this,"sourceTrack"),Hb(this,"_isRecapturing",!1),Hb(this,"_lastRecaptureTime",0),Hb(this,"_onMuteTimeoutId",-1),Hb(this,"_encodeCheckTimeoutId",-1),Hb(this,"profile")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){AL(e,e).add(Lw.MUTE,this.onTrackMuted).add(Lw.UNMUTE,this.onTrackUnmuted).add(Lw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Lw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){SL(e)}setStateToCapture(){}capture(e){return Gb(this,null,(function*(){var t;try{let r,i=fC();Hk.emit(Gk.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(r=new MediaStream,r.addTrack(e.customSource)):(null==(t=this.mediaTrack)||t.stop(),r=yield jP(e));let o=r.getTracks()[0];return this.sourceTrack=o,yield this.setInputMediaStreamTrack(o),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),Hk.emit(Gk.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:fC()-i}),r}catch(eO){throw Hk.emit(Gk.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:eO}),this.log.error("getUserMedia error observed ".concat(eO)),eO}}))}setInputMediaStreamTrack(e){return this.state===pL.INIT&&this.setStateToCapture(),super.setInputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;if(super.setOutputMediaStreamTrack(e),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}publish(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}unpublish(){this.room&&this.room.localTracks.delete(this),Hk.emit(Gk.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return Gb(this,null,(function*(){if(this.mediaTrack&&GM){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings(),{label:r}=this.mediaTrack;(yield function(e){return Gb(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:r,oldGroupId:i,oldLabel:o,kind:n}=e;return function*(){return t===r&&(n!==Lw.AUDIO||t!==wD||(yield CP(i,o)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=r,t&&(this.groupId=t),AP().then((t=>{let r=t.find((t=>t.deviceId===e));r&&this.emit("2",r)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===Lw.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Lw.AUDIO_INPUT);return!!DP.has(r)}(this.mediaTrack)||this.kind===Lw.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Lw.VIDEO_INPUT);return!!DP.has(r)}(this.mediaTrack)||this._isRecapturing||e&&BN&&hk)}onTrackMuted(){if(super.onTrackMuted(),KP(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<MD)return void setTimeout((()=>this.onTrackMuted()),MD);this._onMuteTimeoutId=setTimeout((()=>Gb(this,null,(function*(){var e;if(null!=(e=this.mediaTrack)&&e.muted){if((oN||nN)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return Gb(this,null,(function*(){if(jb(e.prototype,this,"onTrackEnded").call(this),this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<MD)return void setTimeout((()=>this.onTrackEnded()),MD);this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){return Gb(this,null,(function*(){var t;if(this._isRecapturing||!this._inputTrack)return;this.log.warn("recapture trying"),null==(t=this._inputTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let r={useExactDeviceId:!0};if("user"===e||"environment"===e)r.facingMode=e;else{let t;("audio"===this.kind?yield SP():yield RP()).find((t=>t.deviceId===e))&&(t=e),r.deviceId=t}return this.capture(r).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),Hk.emit(Gk.LOCAL_TRACK_RECAPTURE,{track:this})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),Hk.emit(Gk.LOCAL_TRACK_RECAPTURE,{track:this,error:e})}))}))}getRecoverCaptureDeviceId(){return Gb(this,null,(function*(){let e=this instanceof nx;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let r=(ex.get(t)||0)+1;if(ex.set(t,r),r>=3){let i=e?(yield RP()).find((e=>!ex.has(e.deviceId))):(yield SP()).find((e=>!ex.has(e.deviceId)));i&&(this.log.warn("".concat(t," capture fail ").concat(r," times, change new ").concat(i.deviceId)),t=i.deviceId)}}return t}))}close(){var e;super.close(),this._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}};Bb([uL(pL.INIT,"capture",{ignoreError:!0,sync:!0})],QP.prototype,"setStateToCapture",1),Bb([function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,r,i){let o=i.value;return i.value=function(){let t=JP.get(this)||new qP;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return JP.set(this,t),t.push({fn:o,args:i,context:this},e)},i}}()],QP.prototype,"capture",1),Bb([uL("capture","publish",{ignoreError:!0,success(){var e,t;this.room.localTracks.add(this),Hk.emit(Gk.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&(this._encodeCheckTimeoutId=setTimeout((()=>{var e,t;if(!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&this.isPublished&&this.isMediaTrackActive){let e=this.kind===Lw.AUDIO,t=this.stat.bytesSent>0;lM[t?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),t||(lM.addEnum({key:e?503701:513703,value:xk()}),RL.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(Mk()||Uk()),userId:this.userId}),this.log.warn("encode failed"),this.emit("6",this))}}),5e3))},fail(e){let t="error";if(e.cause instanceof RTCError){let r=e.cause;r.message.includes("timeout")?t="timeout":r.code===Xb.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),$P(521714,!1)],QP.prototype,"publish",1),Bb([WP((e=>function(){return Gb(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId)}))})),uL([],"capture",{sync:!0})],QP.prototype,"unpublish",1);var ZP=QP,ex=new Map;Hk.on(Gk.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&ex.delete(e.track.deviceId)}));var tx=class e extends ZP{constructor(e){super(1,MP),Hb(this,"mediaType",1),Hb(this,"volume",0),Hb(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),Hb(this,"playerMuted",!0),Hb(this,"pipeline"),Hb(this,"earMonitorGainNode",new aP),Hb(this,"_output",new aP),Hb(this,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),this.manager=e,this.pipeline=new lP(e),this.pipeline.gain.pipeTo(this.earMonitorGainNode.pipeTo(this._output),this.player.pipeline.volumeMeter),this.handleMicrophoneAdded=this.handleMicrophoneAdded.bind(this),this.handleMicrophoneRemoved=this.handleMicrophoneRemoved.bind(this)}get dbVolume(){return _P.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}setInputMediaStreamTrack(t){return Gb(this,null,(function*(){let r=this.trackSettings||{};lM.addEnum({key:501701,value:r.channelCount||0,useUV:!1}),lM.addEnum({key:501702,value:r.sampleRate||0,useUV:!1}),lM.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:o}=r;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:o}))),this.pipeline.source.channelCount=o||1,this.pipeline.replaceSource(t),yield jb(e.prototype,this,"setInputMediaStreamTrack").call(this,t),this.updatePlayingState(!!t)}))}capture(e){let{deviceId:t,customSource:r,useExactDeviceId:i=!0,retryWhenExactFailed:o=!0}=e;return super.capture({video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:i,retryWhenExactFailed:o,customSource:r})}switchDevice(e){return Gb(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e){if(e!==wD)return;if(yield CP(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1}),Hk.emit(Gk.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(cD){throw this.log.error("switch microphone failed ".concat(cD)),this.deviceId&&this.recapture(this.deviceId),cD}}}))}listenDeviceChange(){TP&&!TP.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&TP.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return Gb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e))),XV(this.userId,{eventId:2003,param1:6,streamType:1});let t=yield SP();t[0]?this.recapture(t[0].deviceId):TP.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}update3A(e){return Gb(this,arguments,(function(e){var t=this;let{echoCancellation:r,noiseSuppression:i,autoGainControl:o}=e;return function*(){let e=t.sourceTrack||t.mediaTrack;if(!e)return;let n=e.getConstraints(),a=!1;!rC(r)&&r!==t.profile.echoCancellation&&(t.profile.echoCancellation=r,n.echoCancellation=r,a=!0),!rC(i)&&i!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=i,n.noiseSuppression=i,a=!0),!rC(o)&&o!==t.profile.autoGainControl&&(t.profile.autoGainControl=o,n.autoGainControl=o,a=!0),a&&(lN||hk?yield e.applyConstraints(n).catch((e=>t._log.warn("update3A failed: ",e))):t.deviceId&&(yield t.recapture(t.deviceId)))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&lM.addEnum({key:502700,value:2})}setAudioVolume(e){super.setAudioVolume(0),oN&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(nP().createGain()),this._output.setNode(nP().destination)),this.earMonitorGainNode.node.gain.value=e}enableTrackANS(e){return this.update3A({noiseSuppression:e})}addDenoiser(e){var t;uk<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(lM.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}removeDenoiser(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0))}close(){this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),TP.off("audioInputAdded",this.handleMicrophoneAdded,this),TP.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}recapture(t){return Gb(this,null,(function*(){try{yield jb(e.prototype,this,"recapture").call(this,t)}catch(cD){let i=(yield SP()).find((e=>e.deviceId!==t));if(!i)throw cD;yield jb(e.prototype,this,"recapture").call(this,i.deviceId)}}))}encodeFrame(e){return this.manager?this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e}):e),e):e}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}},rx=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,r=[],i=0;for(let n=e;n<=t;n++){let e=this.dataView.getInt8(n);switch(e){case 0:case 1:case 2:case 3:2===i&&(r.push(3),i=0),0==e?i++:i=0,r.push(e);break;default:i=0,r.push(e)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,r=[],i=0;for(let n=e;n<=t;n++)switch(this.dataView.getInt8(n)){case 0:i++,r.push(this.dataView.getInt8(n));break;case 3:2!==i&&r.push(this.dataView.getInt8(n)),i=0;break;default:r.push(this.dataView.getInt8(n)),i=0}let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let o=6;o<this.dataView.buffer.byteLength;o++){let r=this.dataView.getUint8(o);if(t++,255!==r){e+=r;break}e+=255}let r=new ArrayBuffer(e),i=new DataView(r);for(let o=0;o<r.byteLength;o++,t++)i.setInt8(o,this.dataView.getInt8(t));return i}},ix=class{constructor(){Hb(this,"_seiMessageList",[]),Hb(this,"_smallSeiMessageList",[]),Hb(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,r=parseInt(String(t/255),10),i=t%255,o=[];o.push(0,0,0,1,6,this._seiPayloadType);for(let a=0;a<r;a++)o.push(255);o.push(i);let n=new DataView(e);return o.push(...new Uint8Array(n.buffer)),o.push(128),new rx(new DataView(new Uint8Array(o).buffer),!0)}sendSEI(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}isEmpty(){return!this._seiMessageList.length}getNaluCount(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}encode(e,t){let r=t?this._smallSeiMessageList:this._seiMessageList;if(r.length>0&&e.data.byteLength>0){let t=9-this.getNaluCount(e.data);if(t<=0)return 0;let i=r.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce(((e,t)=>e+t.dataView.byteLength),0),n=new ArrayBuffer(o+e.data.byteLength),a=new DataView(n),s=new DataView(e.data),c=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)a.setInt8(c++,i[e].dataView.getInt8(t));for(let r=0;r<e.data.byteLength;r++)a.setInt8(c++,s.getInt8(r));return e.data=n,i.length}return 0}},ox=class e extends ZP{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,$L),Hb(this,"profile",{width:640,height:480,frameRate:15,bitrate:500}),Hb(this,"avoidCropping",!1),Hb(this,"_scaleResolutionDownBy"),Hb(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),Hb(this,"small"),Hb(this,"isNeedToSetBandwidth"),Hb(this,"muteImage"),Hb(this,"manager"),Hb(this,"_seiCodec",new ix),this.manager=e;let t=()=>{this.isAllowed2k4k(this.profile)?this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),this.setProfile(xb(Pb({},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(GM&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e;return(null==(e=this._inputTrack)?void 0:e.contentHint)||""}get isQosClearFirst(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}setMute(t){return Gb(this,null,(function*(){var r,i,o;if(iC(t)){if(this.muteImage===t)return;yield null==(r=this.manager)?void 0:r.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:t}),this.muteImage=t,jb(e.prototype,this,"setMute").call(this,!1)}else this.muteImage&&(yield null==(o=this.manager)?void 0:o.deleteWatermark("mute"),this.muteImage=void 0),jb(e.prototype,this,"setMute").call(this,t)}))}capture(e){let{deviceId:t,facingMode:r,useExactDeviceId:i=!0,customSource:o,retryWhenExactFailed:n=!0}=e;return super.capture({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:n,customSource:o})}setProfile(e){let t=Pb({},e),r=t.width>t.height;t.width*t.height<=19200&&nN&&sk&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=r?240:180,t.height=r?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&Tk&&(t.width=r?1280:720,t.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(sk||lN)&&!Ck()&&t.width*t.height<=230400&&t.width/t.height==16/9&&(this._scaleResolutionDownBy=1280/t.width,t.width=1280,t.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?super.setProfile(t):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),super.setProfile(xb(Pb({},this.profile),{width:1920,height:1080})))}applyProfile(){return Gb(this,null,(function*(){var e;if(!this.mediaTrack)return;let{width:t=0,height:r=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=t*r,o=this.settings;if((o.height!==this.profile.height||o.width!==this.profile.width||o.frameRate!==this.profile.frameRate)&&this.deviceId&&(16===Ek?yield this.recapture(this.deviceId):(yield null==(e=this.sourceTrack||this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}),this.manager&&this.manager.changeInput(this)),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)){this.isNeedToSetBandwidth=!1;let{width:e=0,height:t=0}=(this.sourceTrack||this.mediaTrack).getSettings(),r=e*t;return r&&i&&r===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:Lw.VIDEO,videoType:Lw.BIG})}}))}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return GM&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){if(this._scaleResolutionDownBy)return this._scaleResolutionDownBy;let{settings:e}=this;return e.width===this.profile.width&&e.height===this.profile.height?1:kC()&&this.profile.width>this.profile.height&&e.height>e.width?Math.max(e.width/this.profile.height,e.height/this.profile.width,1):Math.max(e.width/this.profile.width,e.height/this.profile.height,1)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return Gb(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e))return;let t={useExactDeviceId:!0,retryWhenExactFailed:!1};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.mediaTrack.stop(),yield this.capture(t),Hk.emit(Gk.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(cD){throw this.log.error("switch camera failed ".concat(cD)),this.deviceId&&this.recapture(this.deviceId),cD}}))}listenDeviceChange(){TP&&!TP.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&TP.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return Gb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e))),XV(this.userId,{eventId:2003,param1:7,streamType:2});let t=yield RP();t[0]?this.recapture(t[0].deviceId):TP.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return Gb(this,null,(function*(){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 rC(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){TP.off("videoInputAdded",this.handleCameraAdded,this),TP.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}recapture(t){return Gb(this,null,(function*(){try{yield jb(e.prototype,this,"recapture").call(this,t)}catch(cD){let i=(yield RP()).find((e=>e.deviceId!==t));if(!i)throw cD;yield jb(e.prototype,this,"recapture").call(this,i.deviceId)}}))}setContentHint(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}};Bb([GP((function(e){this.setContentHint(e.contentHint||"motion")}))],ox.prototype,"capture",1);var nx=ox,ax=zk();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:ax,exposeOrigin:!0,permittedOrigins:["*"]})}catch(CF){}var sx=function(e){return Gb(this,null,(function*(){let t=null,r=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},r={width:hk?{max:e.width}:{ideal:e.width,max:e.width},height:hk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=r,e.systemAudio){let{echoCancellation:r=!0,noiseSuppression:i=!1,autoGainControl:o=!1}=e;t.audio={echoCancellation:r,noiseSuppression:i,autoGainControl:o,sampleRate:48e3}}return t}(e);Kk.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r)));let i=yield navigator.mediaDevices.getDisplayMedia(r);e.systemAudio&&0===i.getAudioTracks().length&&(ck&&uk<74||hk||lN)&&Kk.warn("Your browser not support capture system audio");let o=i.getVideoTracks()[0];if(o){if(e.frameRate)try{yield o.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(iO){Kk.warn("screen applyConstraints failed: ".concat(iO))}e.captureElement&&(yield function(e,t){return Gb(this,null,(function*(){var r;if("CropTarget"in window&&"fromElement"in CropTarget&&tC(e.cropTo))try{if((null==(r=e.getCaptureHandle())?void 0:r.handle)!==ax)return;let i=yield CropTarget.fromElement(t);yield e.cropTo(i)}catch(i){Kk.warn("cropTo target failed ".concat(i))}}))}(o,e.captureElement))}if(e.audio){let r=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return rC(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);Kk.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t=yield navigator.mediaDevices.getUserMedia(r),i.addTrack(t.getAudioTracks()[0])}return i}))},cx=class extends nx{constructor(e){super(e,2),Hb(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),Hb(this,"objectFit","contain"),Hb(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(e){return Gb(this,arguments,(function(e){var t=this;let{systemAudio:r=!1,autoGainControl:i,echoCancellation:o,noiseSuppression:n,audioTrack:a,videoTrack:s,captureElement:c,preferDisplaySurface:l}=e;return function*(){try{let e;return s||a?(e=new MediaStream,s&&e.addTrack(s),a&&e.addTrack(a)):e=yield sx({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:o,noiseSuppression:n,captureElement:c,preferDisplaySurface:l}),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(e){throw t.log.error("getDisplayMedia error observed ".concat(e)),e instanceof Qb?e:new Qb({code:Xb.INITIALIZE_FAILED,name:e.name,message:e.message})}}()}))}switchDevice(e){return Gb(this,null,(function*(){throw new Error("Method not implemented.")}))}};Bb([GP((function(e){this.setContentHint(e.contentHint||"detail")}))],cx.prototype,"capture",1);var lx,ux=class extends tx{constructor(e){super(e),this._log.id="s-".concat(this._log.id)}};function dx(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3,r=arguments.length>2?arguments[2]:void 0;return Gb(this,null,(function*(){let i=nP();lx||(lx=QL(i,URL.createObjectURL(new Blob(['registerProcessor("dumper",class extends AudioWorkletProcessor{constructor(e){super(),this.sourceSampleRate=e.processorOptions.sourceSampleRate||48e3,this.targetSampleRate=e.processorOptions.targetSampleRate||48e3,this.port.onmessage=e=>{this.port2=e.data.port}}process(e){return(this.port2||this.port).postMessage(this.resampleAll(e,this.sourceSampleRate,this.targetSampleRate)),!0}resampleAll(r,s,a){if(s===a)return r;var o=[];for(let t=0;t<r.length;t++){o[t]=[];for(let e=0;e<r[t].length;e++)o[t][e]=this.resample(r[t][e],s,a)}return o}resample(t,e,r){if(e===r)return t;var s=Math.round(t.length*(this.targetSampleRate/this.sourceSampleRate)),a=new Float32Array(s),o=(t.length-1)/(s-1);a[0]=t[0];for(let e=1;e<s-1;e++){var l=e*o,p=Math.floor(l),h=Math.ceil(l);a[e]=t[p]+(t[h]-t[p])*(l-p)}return a[s-1]=t[t.length-1],a}});'],{type:"application/javascript"})))),yield lx;let o=i.sampleRate,n=new AudioWorkletNode(i,"dumper",{numberOfInputs:e.length,numberOfOutputs:0,processorOptions:{sourceSampleRate:o,targetSampleRate:t}});return r&&n.port.postMessage({port:r},[r]),e.forEach(((e,t)=>e.connect(n,0,t))),new ReadableStream({start(e){n.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(n))),n.port.close()}})}))}var hx=class extends uP{constructor(e){super(),this.room=e,Hb(this,"_localAudioTrack"),Hb(this,"_localScreenAudioTrack"),Hb(this,"log",Kk.createLogger({id:"am"})),Hb(this,"denoiser"),Hb(this,"voiceChanger"),Hb(this,"mixChangedDebounce"),Hb(this,"encodePipeline",[]),Hb(this,"decodePipeline",[]),Hb(this,"getPCMAbortCtrlMap",new Map),Hb(this,"audioFrameEventConfigMap",new Map),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.installEvent()}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}dump(e){var t,r;if(!this._localAudioTrack)return;let i=[],o=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),o.push("mic")),null!=(r=this._localAudioPipline)&&r.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(e));let n=new AbortController,a=[],s=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),n.abort("timeout")}),1e3*e),c=()=>{for(let e=0;e<o.length;e++){let t=URL.createObjectURL(new Blob(a[e])),r=document.createElement("a");r.href=t,r.download="".concat(o[e],".pcm"),r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(t),r.remove()}clearTimeout(s),n.abort("download")},l=dx(i).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>a[t]=a[t]?a[t].concat(e[0]):[e[0]]))}}),n).catch((e=>c))));return{then:l.then.bind(l),download:c}}getPCM(e,t){var r,i,o;if(rC(WritableStream))return void this.log.warn("getPCM failed: browser not support WritableStream");let{enable:n,sampleRate:a=48e3,channelCount:s=1,port:c}=(""===t?this.audioFrameEventConfigMap.get(""):this.audioFrameEventConfigMap.get(t)||this.audioFrameEventConfigMap.get("*"))||{};if(!n)return;this.log.info("getPCM ".concat(t||"local"));let l,u,d=Math.floor(.04*a),h=new Float32Array(d),p=new Float32Array(d),m=0,f=new AbortController,_=""===t?null==(r=this._localAudioTrack)?void 0:r.mediaTrack:null==(o=null==(i=this.room)?void 0:i.remotePublishedUserMap.get(t))?void 0:o.remoteAudioTrack.mediaTrack;if(_)return dx([nP().createMediaStreamSource(new MediaStream([_]))],a,c).then((r=>r.pipeTo(new WritableStream({write(r){r[0][0]&&(m+r[0][0].length>d?(h.set(r[0][0].subarray(0,d-m),m),l=r[0][0].subarray(d-m),p.set(r[0][1].subarray(0,d-m),m),u=r[0][1].subarray(d-m),m+=d-m):(l&&(h.set(l,m),m+=l.length,l=void 0),u&&(p.set(u,m),u=void 0),h.set(r[0][0],m),p.set(r[0][1],m),m+=r[0][0].length),m>=d&&(m=0,e({userId:t,sampleRate:a,channelCount:s,data:1===s?h:[h,p]}),h=new Float32Array(d),p=new Float32Array(d)))}}),f).catch((e=>this.log.warn("stop getPCM reason:".concat(e)))))),f;this.log.info("getPCM failed: ".concat(t||"local"," has no audio track"))}get hasScreenAudioTrack(){return null!==this._localScreenAudioTrack}get hasAudioTrack(){return!rC(this._localAudioTrack)}changeInput(e){return e instanceof ux?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof tx?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof DV?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}mixOnChange(){return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((()=>{var e,t;return delete this.mixChangedDebounce,Promise.all([null==(e=this._localAudioTrack)?void 0:e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)?void 0:t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}removeInput(e){e instanceof ux?delete this._localScreenAudioTrack:e instanceof tx&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}removeDenoiser(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}addVoiceChanger(e,t){var r;this.voiceChanger=[e,t],null==(r=this._localAudioTrack)||r.pipeline.voiceChanger.setNode(e,t)}removeVoiceChanger(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}destroy(){this.close(),this.getPCMAbortCtrlMap.forEach((e=>null==e?void 0:e.abort("destroy"))),this.getPCMAbortCtrlMap.clear(),this.audioFrameEventConfigMap.clear(),this.uninstallEvent()}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}handleLocalTrackStarted(e){let{room:t,userId:r}=e;var i;if(t!==this.room||this.getPCMAbortCtrlMap.get(r))return;let o=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),"");this.getPCMAbortCtrlMap.set(r,o),this.getPCMAbortCtrlMap.get(r)&&(null==(i=this._localAudioTrack)||i.on("input-media-track-changed",(()=>{let e=this.getPCMAbortCtrlMap.get(r);e&&(e.abort("inputMediaTrackChanged"),e=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),""),this.getPCMAbortCtrlMap.set(r,e))})))}handleLocalTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopLocalAudio"),this.getPCMAbortCtrlMap.delete(r))}handleRemoteTrackStarted(e){let{room:t,userId:r}=e;if(t===this.room&&!this.getPCMAbortCtrlMap.get(r)){let e=this.room.audioManager.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),r);this.getPCMAbortCtrlMap.set(r,e)}}handleRemoteTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopRemoteAudio"),this.getPCMAbortCtrlMap.delete(r))}installEvent(){Hk.on("113",this.handleLocalTrackStarted,this),Hk.on("114",this.handleLocalTrackStopped,this),Hk.on("115",this.handleRemoteTrackStarted,this),Hk.on("116",this.handleRemoteTrackStopped,this)}uninstallEvent(){Hk.off("113",this.handleLocalTrackStarted),Hk.off("114",this.handleLocalTrackStopped),Hk.off("115",this.handleRemoteTrackStarted),Hk.off("116",this.handleRemoteTrackStopped)}};var px={};function mx(){}Vb(px,{Events:()=>Cx,Inspect:()=>yx,LastSink:()=>Tx,Sink:()=>Ix,Subscribe:()=>Ax,TimeoutError:()=>Nx,audit:()=>LU,bindCallback:()=>lU,bindNodeCallback:()=>uU,buffer:()=>Gx,bufferCount:()=>jx,bufferTime:()=>gV,call:()=>fx,catchError:()=>vV,combineLatest:()=>Vx,concat:()=>Px,concatMap:()=>nV,concatMapTo:()=>aV,count:()=>_U,create:()=>Rx,debounce:()=>UU,debounceTime:()=>VU,defer:()=>zx,delay:()=>EV,deliver:()=>bx,dispose:()=>gx,elementAt:()=>FU,empty:()=>pU,every:()=>WU,exhaustMap:()=>pV,exhaustMapTo:()=>mV,filter:()=>yU,find:()=>BU,findIndex:()=>HU,first:()=>jU,fromAnimationFrame:()=>sU,fromArray:()=>Xx,fromEvent:()=>tU,fromEventPattern:()=>eU,fromFetch:()=>iU,fromIterable:()=>oU,fromPromise:()=>rU,fromReadableStream:()=>aU,fromReader:()=>nU,groupBy:()=>fV,identity:()=>_x,ignoreElements:()=>TU,iif:()=>Ux,inspect:()=>Ex,interval:()=>$x,last:()=>GU,map:()=>JU,mapTo:()=>YU,max:()=>gU,merge:()=>Mx,mergeMap:()=>lV,mergeMapTo:()=>uV,min:()=>EU,never:()=>dU,nothing:()=>mx,of:()=>Yx,pairwise:()=>zU,pipe:()=>Sx,race:()=>Lx,range:()=>cU,reduce:()=>fU,retry:()=>RV,scan:()=>KU,share:()=>Ox,shareReplay:()=>xx,skip:()=>bU,skipUntil:()=>wU,skipWhile:()=>DU,startWith:()=>Bx,subject:()=>Kx,subscribe:()=>IV,sum:()=>vU,switchMap:()=>eV,switchMapTo:()=>rV,take:()=>IU,takeLast:()=>RU,takeUntil:()=>AU,takeWhile:()=>SU,tap:()=>AV,throttle:()=>OU,throwError:()=>hU,timeInterval:()=>_V,timeout:()=>SV,timer:()=>Qx,toPromise:()=>yV,toReadableStream:()=>TV,withLatestFrom:()=>Hx,zip:()=>Fx});var fx=e=>e(),_x=e=>e;function gx(){this.dispose()}var Ex=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,vx=1,yx=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new Dx(e,this,this.streamId++);return Cx.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},Tx=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=mx,this.error=mx,this.next=mx,this.dispose=mx,this.subscribe=mx,this.doDefer()}subscribe(e){return e instanceof yx?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(fx),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}},Ix=class extends Tx{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)}},Ax=class extends Tx{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mx,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:mx,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:mx;if(super(),this._next=t,this._error=r,this._complete=i,this.then=mx,e instanceof yx){let o={toString:()=>"subscribe",id:0,source:e};this.defer((()=>{Cx.defer(o,0)})),Cx.create(o),Cx.pipe(o),this.sourceId=o.id,this.subscribe(e),Cx.subscribe({id:o.id,end:!0}),t==mx?this._next=e=>Cx.next(o,0,e):this.next=e=>{Cx.next(o,0,e),t(e)},i==mx?this._complete=()=>Cx.complete(o,0):this.complete=()=>{this.dispose(),Cx.complete(o,0),i()},r==mx?this._error=e=>Cx.complete(o,0,e):this.error=e=>{this.dispose(),Cx.complete(o,0,e),r()}}else this.subscribe(e)}next(e){this._next(e)}complete(){this.dispose(),this._complete()}error(e){this.dispose(),this._error(e)}};function Sx(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 Rx(e,t,r){if(Ex()){let i=Object.defineProperties(Object.setPrototypeOf(e,yx.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}});Cx.create(i);for(let e=0;e<r.length;e++){let t=r[e];"function"==typeof t&&t instanceof yx&&Cx.addSource(i,t)}return i}return e}function bx(e,t){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return r=>{if(r instanceof yx){let o=Rx((t=>{let n=new e(t,...i);n.sourceId=o.id,n.subscribe(r)}),t,arguments);return o.source=r,Cx.pipe(o),o}return t=>r(new e(t,...i))}}}function wx(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var Dx=class extends Ix{constructor(e,t,r){super(e),this.source=t,this.id=r,this.sourceId=e.sourceId,this.defer((()=>{Cx.defer(this.source,this.id)}))}next(e){Cx.next(this.source,this.id,e),this.sink.next(e)}complete(){Cx.complete(this.source,this.id),this.sink.complete()}error(e){Cx.complete(this.source,this.id,e),this.sink.error(e)}},Cx={addSource(e,t){wx("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,r){wx("next",{id:e.id,streamId:t,data:r&&r.toString()})},subscribe(e,t){let{id:r,end:i}=e;wx("subscribe",{id:r,end:i,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,r){wx("complete",{id:e.id,streamId:t,err:r?r.toString():null})},defer(e,t){wx("defer",{id:e.id,streamId:t})},pipe(e){wx("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){wx("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=vx++),wx("create",{name:e.toString(),id:e.id})}},Nx=class extends Error{constructor(e){super("timeout after ".concat(e,"ms")),this.timeout=e}},kx=class extends Tx{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 Ox(){return e=>{let t=new kx(e);if(e instanceof yx){let r=Rx((e=>{t.add(e)}),"share",arguments);return t.sourceId=r.id,r.source=e,Cx.pipe(r),r}return Rx(t.add.bind(t),"share",arguments)}}function Mx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx((e=>{let r=new Ix(e),i=t.length;r.complete=()=>{0==--i&&e.complete()},t.forEach(r.bindSubscribe)}),"merge",arguments)}function Lx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx((e=>{let r=new Map;t.forEach((t=>{let i=new Ix(e);r.set(t,i),i.complete=()=>{r.delete(t),0===r.size?e.complete():i.dispose()},i.next=e=>{r.delete(t),r.forEach((e=>e.dispose())),i.resetNext(),i.resetComplete(),i.next(e)}})),t.forEach((e=>r.get(e).subscribe(e)))}),"race",arguments)}function Px(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx((e=>{let r=0,i=t.length,o=new Ix(e);o.complete=()=>{r<i&&!o.disposed?(o.doDefer(),o.subscribe(t[r++])):e.complete()},o.complete()}),"concat",arguments)}function xx(e){return t=>{let r=new kx(t),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((e=>e.next(t)))},Rx((e=>{e.defer((()=>r.remove(e))),i.forEach((t=>e.next(t))),r.add(e)}),"shareReplay",arguments)}}function Ux(e,t,r){return Rx((i=>e()?t(i):r(i)),"iif",arguments)}function Vx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx((e=>{let r=t.length,i=r,o=r,n=new Array(r),a=()=>{0==--o&&e.complete()};t.forEach(((t,r)=>{let o=new Ix(e);o.next=t=>{0==--i?(o.next=t=>{n[r]=t,e.next(n)},o.next(t)):n[r]=t},o.complete=a,o.subscribe(t)}))}),"combineLatest",arguments)}function Fx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx((e=>{let r=t.length,i=r,o=new Array(r),n=()=>{0==--i&&e.complete()};t.forEach(((t,r)=>{let i=new Ix(e),a=[];o[r]=a,i.next=t=>{a.push(t),o.every((e=>e.length))&&e.next(o.map((e=>e.shift())))},i.complete=n,i.subscribe(t)}))}),"zip",arguments)}function Bx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return e=>Rx((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;i<o&&!r.disposed;)r.next(t[i++]);r.disposed||r.subscribe(e)}),"startWith",arguments)}var Hx=bx(class extends Ix{constructor(e){super(e);let t=new Ix(this.sink);for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.next=e=>this.buffer=e,t.complete=mx,t.subscribe(Vx(...i))}next(e){this.buffer&&this.sink.next([e,...this.buffer])}},"withLatestFrom"),jx=bx(class extends Ix{constructor(e,t,r){super(e),this.bufferSize=t,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((t=>{t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((e=>this.sink.next(e))),super.complete()}},"bufferCount"),Gx=bx(class extends Ix{constructor(e,t){super(e),this.buffer=[];let r=new Ix(e);r.next=t=>{e.next(this.buffer),this.buffer=[]},r.complete=mx,r.subscribe(t)}next(e){this.buffer.push(e)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},"buffer"),Wx=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{c(i.next(e))}catch(t){n(t)}}function s(e){try{c(i.throw(e))}catch(t){n(t)}}function c(e){e.done?o(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(a,s)}c((i=i.apply(e,t||[])).next())}))};function Kx(e){let t=arguments,r=Ox()(Rx((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=mx,r.complete=mx,r.error=mx,r}function zx(e){return Rx((t=>t.subscribe(e())),"defer",arguments)}var qx=e=>t=>{setTimeout((()=>e(t)))},Jx=e=>qx((t=>{for(let r=0;!t.disposed&&r<e.length;r++)t.next(e[r]);t.complete()}));function Yx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Rx(Jx(t),"of",arguments)}function Xx(e){return Rx(Jx(e),"fromArray",arguments)}function $x(e){return Rx((t=>{let r=0,i=setInterval((()=>t.next(r++)),e);return t.defer((()=>{clearInterval(i)})),"interval"}),"interval",arguments)}function Qx(e,t){return Rx((r=>{let i=0,o=setTimeout((()=>{if(r.removeDefer(n),r.next(i++),t){let e=setInterval((()=>r.next(i++)),t);r.defer((()=>{clearInterval(e)}))}else r.complete()}),e),n=()=>{clearTimeout(o)};r.defer(n)}),"timer",arguments)}function Zx(e,t){return r=>{let i=e=>r.next(e);r.defer((()=>t(i))),e(i)}}function eU(e,t){return Rx(Zx(e,t),"fromEventPattern",arguments)}function tU(e,t){if("on"in e&&"off"in e)return Rx(Zx((r=>e.on(t,r)),(r=>e.off(t,r))),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return Rx(Zx((r=>e.addListener(t,r)),(r=>e.removeListener(t,r))),"fromEvent",arguments);if("addEventListener"in e)return Rx(Zx((r=>e.addEventListener(t,r)),(r=>e.removeEventListener(t,r))),"fromEvent",arguments);throw"target is not a EventDispachter"}function rU(e){return Rx((t=>{e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function iU(e,t){return Rx(zx((()=>rU(fetch(e,t)))),"fromFetch",arguments)}function oU(e){return Rx(qx((t=>{try{for(let r of e){if(t.disposed)return;t.next(r)}t.complete()}catch(sw){t.error(sw)}})),"fromIterable",arguments)}function nU(e){let t=r=>Wx(this,void 0,void 0,(function*(){if(r.disposed)return;let{done:i,value:o}=yield e.read();i?r.complete():(r.next(o),t(r))}));return Rx((e=>{t(e)}),"fromReader",arguments)}function aU(e){return Rx((t=>{let r=new AbortController,i=r.signal;t.defer((()=>r.abort("cancelled"))),e.pipeTo(new WritableStream({write(e){t.next(e)},close(){t.complete()},abort(e){t.error(e)}}),{signal:i}).then((()=>t.complete()),(e=>t.error(e)))}),"fromReadableStream",arguments)}function sU(){return Rx((e=>{let t=requestAnimationFrame((function r(i){e.disposed||(e.next(i),t=requestAnimationFrame(r))}));e.defer((()=>cancelAnimationFrame(t)))}),"fromAnimationFrame",arguments)}function cU(e,t){return Rx((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;for(;i<o&&!r.disposed;)r.next(i++);return r.complete(),"range"}),"range",arguments)}function lU(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return Rx((r=>{let o=i.concat((e=>(r.next(e),r.complete())));e.apply(t,o)}),"bindCallback",arguments)}function uU(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return Rx((r=>{let o=i.concat(((e,t)=>e?r.error(e):(r.next(t),r.complete())));e.apply(t,o)}),"bindNodeCallback",arguments)}function dU(){return Rx((()=>{}),"never",arguments)}function hU(e){return Rx((t=>t.error(e)),"throwError",arguments)}function pU(){return Rx((e=>e.complete()),"empty",arguments)}var mU=class extends Ix{constructor(e,t,r){super(e),this.f=t;let i=()=>{this.sink.next(this.acc),this.sink.complete()};void 0===r?this.next=e=>{this.acc=e,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(e){this.acc=this.f(this.acc,e)}},fU=bx(mU,"reduce"),_U=e=>bx(mU,"count")(((t,r)=>e(r)?t+1:t),0),gU=()=>bx(mU,"max")(Math.max),EU=()=>bx(mU,"min")(Math.min),vU=()=>bx(mU,"sum")(((e,t)=>e+t),0),yU=bx(class extends Ix{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"),TU=bx(class extends Ix{next(e){}},"ignoreElements"),IU=bx(class extends Ix{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0==--this.count&&this.complete()}},"take"),AU=bx(class extends Ix{constructor(e,t){super(e);let r=new Ix(e);r.next=()=>e.complete(),r.complete=gx,r.subscribe(t)}},"takeUntil"),SU=bx(class extends Ix{constructor(e,t){super(e),this.f=t}next(e){this.f(e)?this.sink.next(e):this.complete()}},"takeWhile"),RU=e=>fU(((t,r)=>(t.push(r),t.length>e&&t.shift(),t)),[]),bU=bx(class extends Ix{constructor(e,t){super(e),this.count=t}next(e){0==--this.count&&(this.next=super.next)}},"skip"),wU=bx(class extends Ix{constructor(e,t){super(e),e.next=mx;let r=new Ix(e);r.next=()=>{r.dispose(),e.resetNext()},r.complete=gx,r.subscribe(t)}},"skipUntil"),DU=bx(class extends Ix{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),CU={leading:!0,trailing:!1},NU=class extends Ix{constructor(e,t,r){super(e),this.durationSelector=t,this.trailing=r}cacheValue(e){this.last=e,this.disposed&&this.throttle(e)}send(e){this.sink.next(e),this.throttle(e)}throttle(e){this.reset(),this.subscribe(this.durationSelector(e))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},kU=class extends Ix{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:CU;super(e),this.durationSelector=t,this.config=r,this._throttle=new NU(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}complete(){this._throttle.throttle=mx,this._throttle.complete(),super.complete()}},OU=bx(kU,"throttle"),MU={leading:!1,trailing:!0},LU=e=>bx(kU,"audit")(e,MU),PU=class extends Ix{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},xU=class extends Ix{constructor(e,t){super(e),this.durationSelector=t,this._debounce=new PU(this.sink),this._debounce.dispose()}next(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}complete(){this._debounce.complete(),super.complete()}},UU=bx(xU,"debounce"),VU=e=>bx(xU,"debounceTime")((t=>Qx(e))),FU=bx(class extends Ix{constructor(e,t,r){super(e),this.count=t,this.defaultValue=r}next(e){0==this.count--&&(this.defaultValue=e,this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("not enough elements in sequence"))}},"elementAt"),BU=e=>t=>IU(1)(DU((t=>!e(t)))(t)),HU=bx(class extends Ix{constructor(e,t){super(e),this.f=t,this.i=0}next(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}},"findIndex"),jU=bx(class extends Ix{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"first"),GU=bx(class extends Ix{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"last"),WU=bx(class extends Ix{constructor(e,t){super(e),this.predicate=t,this.index=0}next(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){void 0!==this.result?(this.sink.next(this.result),super.complete()):this.error(new Error("no elements in sequence"))}},"every"),KU=bx(class extends Ix{constructor(e,t,r){super(e),this.f=t,void 0===r?this.next=e=>{this.acc=e,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(e){this.sink.next(this.acc=this.f(this.acc,e))}},"scan"),zU=bx(class extends Ix{constructor(){super(...arguments),this.hasLast=!1}next(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}},"pairwise"),qU=class extends Ix{constructor(e,t,r){super(e),this.mapper=t,this.thisArg=r}next(e){super.next(this.mapper.call(this.thisArg,e))}},JU=bx(qU,"map"),YU=e=>bx(qU,"mapTo")((t=>e)),XU=class extends Ix{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()}},$U=class extends Ix{constructor(e,t,r){super(e),this.makeSource=t,this.combineResults=r,this.index=0}subInner(e,t){let r=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(e,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},QU=class extends XU{},ZU=class extends $U{next(e){this.subInner(e,QU),this.next=e=>{this.currentSink.dispose(),this.subInner(e,QU)}}},eV=bx(ZU,"switchMap");function tV(e){return(t,r)=>e((()=>t),r)}var rV=tV(bx(ZU,"switchMapTo")),iV=class extends XU{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},oV=class extends $U{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(e){this.next2(e),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),iV),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}tryComplete(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}},nV=bx(oV,"concatMap"),aV=tV(bx(oV,"concatMapTo")),sV=class extends XU{tryComplete(){this.context.inners.delete(this),super.dispose(),0===this.context.inners.size&&this.context.resetComplete()}},cV=class extends $U{constructor(){super(...arguments),this.inners=new Set}next(e){this.subInner(e,sV),this.inners.add(this.currentSink)}tryComplete(){1===this.inners.size?this.inners.forEach((e=>e.resetComplete())):this.dispose()}},lV=bx(cV,"mergeMap"),uV=tV(bx(cV,"mergeMapTo")),dV=class extends XU{dispose(){this.context.resetNext(),super.dispose()}},hV=class extends $U{next(e){this.next=mx,this.subInner(e,dV)}},pV=bx(hV,"exhaustMap"),mV=tV(bx(hV,"exhaustMapTo")),fV=bx(class extends Ix{constructor(e,t){super(e),this.f=t,this.groups=new Map}next(e){let t=this.f(e),r=this.groups.get(t);void 0===r&&(r=Kx(),r.key=t,this.groups.set(t,r),super.next(r)),r.next(e)}complete(){this.groups.forEach((e=>e.complete())),super.complete()}error(e){this.groups.forEach((t=>t.error(e))),super.error(e)}},"groupBy"),_V=bx(class extends Ix{constructor(){super(...arguments),this.start=new Date}next(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},"timeInterval"),gV=bx(class extends Ix{constructor(e,t){super(e),this.miniseconds=t,this.buffer=[],this.id=setInterval((()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0}),this.miniseconds)}next(e){this.buffer.push(e)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},"bufferTime"),EV=bx(class extends Ix{constructor(e,t){super(e),this.buffer=[],this.delayTime=t}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(e){this.timeoutId=setTimeout((()=>{let e=this.buffer.shift();if(e){let{time:t,data:r}=e;super.next(r),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(t))}}),e)}next(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}complete(){this.timeoutId=setTimeout((()=>super.complete()),this.delayTime)}},"delay"),vV=bx(class extends Ix{constructor(e,t){super(e),this.selector=t}error(e){this.dispose(),this.selector(e)(this.sink)}},"catchError"),yV=()=>e=>new Promise(((t,r)=>{let i;new Ax(e,(e=>i=e),r,(()=>t(i)))})),TV=()=>e=>{let t;return new ReadableStream({start(r){t=new Ax(e,r.enqueue.bind(r),r.error.bind(r),r.close.bind(r))},cancel(){t.dispose()}})},IV=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:mx,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:mx,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:mx;return i=>new Ax(i,e,t,r)},AV=bx(class extends Ix{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"),SV=bx(class extends Ix{constructor(e,t){super(e),this.timeout=t,this.id=setTimeout((()=>this.error(new Nx(this.timeout))),this.timeout)}next(e){super.next(e),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},"timeout"),RV=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return t=>{if(t instanceof yx){let r=Rx((i=>{let o=e,n=new Ix(i);n.error=e=>{o-- >0?n.subscribe(t):i.error(e)},n.sourceId=r.id,n.subscribe(t)}),"retry",[e]);return r.source=t,Cx.pipe(r),r}return r=>{let i=e,o=new Ix(r);o.error=e=>{i-- >0?t(o):r.error(e)},t(o)}}},bV=class e extends PP{constructor(t,r,i){super({userId:r.userId,sdkAppId:t.sdkAppId,mediaType:i,room:t}),this.room=t,this.user=r,Hb(this,"tinyId"),Hb(this,"isRemote",!0),Hb(this,"jitterBufferDelay",0),Hb(this,"availableState"),Hb(this,"remotePublishState"),Hb(this,"_triggerCheckDecodeSubject",Kx(tU(this,e.STATE_SUBSCRIBE))),this.tinyId=r.tinyId,this.availableState=new pL("".concat(r.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new pL("".concat(r.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),Sx(Mx(tU(this,pL.STATECHANGED),tU(this.remotePublishState,pL.STATECHANGED)),JU((()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing))),IV((e=>{this.availableState.state!==(e?pL.ON:pL.OFF)&&(this.availableState.state=e?pL.ON:pL.OFF),this.updatePlayingState(e)})));let o=Sx(tU(this.player,yL.ERROR),yU((e=>e.code===MediaError.MEDIA_ERR_DECODE))),n=Sx(Qx(5e3),yU((()=>!(this.ignoreDecodeError||!this.isSubscribed||!this.isPlayCalled||!this.stat.bytesReceived)&&(!this.player.isPlaying&&!(this.kind===Lw.AUDIO?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1))))),a=Sx(Lx(o,n),AU(tU(this,pL.INIT)));Sx(this._triggerCheckDecodeSubject,yU((()=>!this.ignoreDecodeError)),rV(a),IV((e=>{this.reportDecodeResult(!1,e)})))}setMute(e){this.isRemotePublished&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}checkDecodeResult(){this._triggerCheckDecodeSubject.next(!0)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get ignoreDecodeError(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===pL.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){let r=this.kind===Lw.AUDIO;lM[e?"addSuccessEvent":"addFailedEvent"]({key:r?504700:514702}),e||(lM.addEnum({key:r?504701:514703,value:xk()}),RL.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(Mk()||Uk()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===Lw.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));super.updatePlayingState(e)}}close(){super.close(),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}onFlagChanged(){this.remotePublishState.state=this.isRemotePublished?pL.ON:pL.OFF}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};Hb(bV,"STATE_SUBSCRIBE","subscribe"),Bb([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 WP(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return new Promise(((o,a)=>{let s=setTimeout((()=>{let r=new Qb({code:Xb.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(e,"s")});Kk.warn(r),2===t?a(r):1===t&&o()}),1e3*e);r.apply(this,n).then(o,a).finally((()=>{clearTimeout(s)}))}))}))}(5,1)],bV.prototype,"waitHasMediaTrack",1),Bb([uL(pL.INIT,bV.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),Hk.emit(Gk.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),$P(521716,!1)],bV.prototype,"subscribe",1),Bb([uL(bV.STATE_SUBSCRIBE,pL.INIT,{sync:!0,success(){this.log.info("unsubscribed"),Hk.emit(Gk.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],bV.prototype,"unsubscribe",1);var wV=bV,DV=class extends wV{constructor(e,t){super(e,t,1),Hb(this,"volume",0),Hb(this,"mediaType",1),Hb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}get dbVolume(){return _P.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}decodeFrame(e){if(!this.manager)return e;let t=e;for(let r of this.manager.decodePipeline)if(r&&(t=r({frame:t,track:this}),!t))return;return t}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get isRemotePublished(){return this.user.muteState.audioAvailable}},CV=[-1,-1,1,-1,-1,1,1,1],NV=[0,0,1,0,0,1,1,1],kV=class extends pL{constructor(e,t){if(super(),this.context=e,Hb(this,"name"),Hb(this,"input"),Hb(this,"output"),Hb(this,"texture"),Hb(this,"ctx2d",null),Hb(this,"fbo"),Hb(this,"width",0),Hb(this,"height",0),Hb(this,"x",0),Hb(this,"y",0),Hb(this,"program"),Hb(this,"vertexShader"),Hb(this,"fragmentShader"),Hb(this,"totalFrames",0),Hb(this,"dropFrames",0),Hb(this,"matchInputSize",!0),Hb(this,"texCoordBuffer"),Hb(this,"positionBuffer"),Hb(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),Hb(this,"cost",0),Hb(this,"_canvas",null),Hb(this,"_image"),Hb(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 zV)e.ctx&&t.create2d&&("function"==typeof OffscreenCanvas&&16!==Ek?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(NV),this.positionBuffer=this.createBuffer(CV),!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.PACK_ALIGNMENT,1),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(eO){this.context.destroy(new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(eO.message||eO)}))}}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 KV&&this.render(e)||this.context instanceof zV&&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 KV){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(e,t,r,i,o){return!(!this.ctx2d||!e)&&(e instanceof ImageData?this.ctx2d.putImageData(e,t,r):(this.ctx2d.drawImage(e,t,r,i,o),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),!0)}getInfo(){var e;let{totalFrames:t,x:r,y:i,width:o,height:n,name:a,cost:s}=this,c=Date.now(),l=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:r,y:i,width:o,height:n,timestamp:c,fps:l,name:a,cost:s},Pb({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.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),r}};Bb([uL(pL.INIT,"connected",{sync:!0})],kV.prototype,"connect",1),Bb([uL("connected",pL.INIT,{ignoreError:!0,sync:!0})],kV.prototype,"disconnect",1),Bb([uL([],"closed",{sync:!0})],kV.prototype,"close",1);var OV=Sx($x(250),JU((()=>performance.now())),Ox()),MV=e=>t=>{let r=performance.now();Sx(OV,DU((t=>t-r<e)),IU(1))(t)},LV=[0,1,1,1,0,0,1,0],PV=class extends kV{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),Hb(this,"_intervalId",0),Hb(this,"_sequence",0),Hb(this,"checkGLError",!1),Hb(this,"checkVisibilityChange"),e instanceof zV?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(LV)}start(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),vL.clearTask(this._intervalId),this._intervalId=vL.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&(vL.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof KV){let e=this.context.ctx.getError();e&&this.context.destroy(new Qb({code:Xb.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(),!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;if(this._intervalId&&(vL.clearTask(this._intervalId),this._intervalId=0,1===e)){this.log.info("".concat(this.name," use requestVideoFrameCallback"));let e=()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")),document.removeEventListener("visibilitychange",e))};document.addEventListener("visibilitychange",e)}this.requestFrame(this._sequence++)}removeInput(e){super.removeInput(e),vL.clearTask(this._intervalId)}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}close(){super.close(),vL.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}},xV=class extends PV{constructor(e,t){super(e,t),Hb(this,"_videoTrack"),Hb(this,"_muteOb"),Hb(this,"_closedOb",tU(this,"closed")),Hb(this,"_subscription"),Hb(this,"_canvasContainer"),Number(mk)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),[this._videoTrack]=e._canvas.captureStream().getVideoTracks(),this._muteOb=tU(this._videoTrack,"mute"),Sx(tU(this._videoTrack,"ended"),AU(this._closedOb),IV((()=>{this.context.destroy(new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})))}enableCheckMute(){this._subscription=Sx(this._muteOb,AU(this._closedOb),rV(MV(5e3)),yU((()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)})),IV((()=>{this.context.destroy(new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}disableCheckMute(){var e;null==(e=this._subscription)||e.dispose()}get videoTrack(){return this._videoTrack}putCanvasIntoDom(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}render(e){return this.putCanvasIntoDom(),super.render(e)}render2d(e){return this.putCanvasIntoDom(),super.render2d(e)}close(){var e,t;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},UV=class extends xV{render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}},VV=class extends xV{constructor(e,t,r){super(e,{name:"smallDestination",logger:r}),this.resolution=t}resize(e,t){let r,i=e*t,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>o?r=i/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),super.resize(e/Math.sqrt(r),t/Math.sqrt(r))}},FV=class extends kV{constructor(e,t){super(e,Pb({name:"imageSource"},t)),Hb(this,"_lastImage"),Hb(this,"_totalFrames",0),Hb(this,"_autoResize",!1),Hb(this,"_canvasRendered"),Hb(this,"_videoCallbackId",0),Hb(this,"waitingFirstFrame",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===Ek&&(this._canvasRendered=Kx(),Sx(this._canvasRendered,Bx(this._image),eV((e=>e instanceof HTMLCanvasElement?tU(e,"rendered"):pU())),AU(tU(this,"closed")),IV((()=>{this.update()}))))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){let e=this.image;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),rL()&&!document.hidden&&(this._videoCallbackId=e.requestVideoFrameCallback(((e,t)=>{this.waitingFirstFrame&&this.onFirstFrame(),document.hidden||(this._totalFrames=t.presentedFrames,this.update(1))})))}_render(e,t){var r;let{width:i,height:o}=this,{image:n}=this;if(n instanceof HTMLVideoElement){if(this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:o}=n),!i||!o)return!1;n.width=i,n.height=o}else if(n instanceof HTMLImageElement||n instanceof ImageData||n instanceof ImageBitmap){if(({width:i,height:o}=n),n!==this._lastImage)this._lastImage=n;else if(i===this.width&&o===this.height)return!1}else n instanceof HTMLCanvasElement||n instanceof OffscreenCanvas?(({width:i,height:o}=n),this._lastImage=n):"undefined"!=typeof VideoFrame&&n instanceof VideoFrame&&(({displayWidth:i,displayHeight:o}=n),null==(r=this._lastImage)||r.close(),this._lastImage=n);if(!this._autoResize)return!0;if(this.width===i&&this.height===o&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}this.resize(i,o)}return!0}get image(){return this._image}set image(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},BV=class extends FV{constructor(e,t,r){super(e,r),this._player=t,this.name="videoPlayerSource",Sx(tU(this._player,yL.PLAYER_STATE_CHANGED),AU(tU(this,"closed")),yU((e=>{let{state:t}=e;return"PLAYING"===t})),IV((()=>{this.tryVideoFrameCallback()})))}get image(){return this._player.element}},HV=class extends BV{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,r){super(e,new $L({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()}},jV=class extends pL{constructor(e){super(),Hb(this,"frameRate"),Hb(this,"_canvas"),Hb(this,"log"),Hb(this,"hasAlpha",!1),Hb(this,"name"),Hb(this,"error"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}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 HV(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new xV(this,e)}createVideoImageSource(e,t){return new FV(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new BV(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};Hb(jV,"_ids",0);var GV={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},WV=class extends jV{constructor(){super(...arguments),Hb(this,"defaultProgam"),Hb(this,"defaultVShader"),Hb(this,"defaultFShader"),Hb(this,"ctx")}create(){if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(jV._ids++)),this.ctx=this._canvas.getContext("webgl2",GV),!this.ctx)throw new Qb({code:Xb.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 Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}destroy(e){let t="";return e&&(t=e.message,this.error=e,lM.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}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e}setSize(e,t){var r;null==(r=this.ctx)||r.viewport(0,0,e,t),super.setSize(e,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}};Hb(WV,"UNAVAILABLE","unavailable"),Bb([uL(pL.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),lM.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),lM.addSuccessEvent({key:512700})}})],WV.prototype,"create",1),Bb([uL("created",pL.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(WV.UNAVAILABLE,e),this.removeAllListeners()}})],WV.prototype,"destroy",1);var KV=WV,zV=class extends jV{constructor(){super(...arguments),Hb(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(jV._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(()=>{this.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(()=>{this.log.warn("2d context restored")}))}destroy(e){let t="";e&&(t=e.message,this.error=e,lM.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),lM.addSuccessEvent({key:512703})}};Bb([uL(pL.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),lM.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d"),lM.addSuccessEvent({key:512701})}})],zV.prototype,"create",1),Bb([uL("created",pL.INIT,{ignoreError:!0,sync:!0})],zV.prototype,"destroy",1);var qV=class extends wV{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),Hb(this,"mediaType",4),Hb(this,"source"),Hb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager,this.once("first-video-frame",(e=>{this.room.emit("first-video-frame",e)}))}play(e,t){return(nC(null==t?void 0:t.canvasRender)?t.canvasRender:17===Ek)&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then((()=>{this.player.calculateStat()}))}useCanvasPlayer(){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),!this.player.element)return;let e=new zV({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});let t=new PV(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),rL()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,r=(i=t,[15,30,45,60].reduce(((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e)));var i;!oC(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),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)}onDecodeDowngradeStateChanged(e){this.emit("decode-downgrade-state-changed",e)}},JV=class extends qV{constructor(e,t){super(e,t,2),Hb(this,"mediaType",2),Hb(this,"objectFit","contain")}get isRemotePublished(){return this.user.muteState.hasAuxiliary}},YV=new Map;function XV(e,t){let r=xb(Pb({},t),{timestamp:Zb()});YV.has(e)?YV.get(e).push(r):YV.set(e,[r])}function $V(e){if(YV.has(e)){let t=YV.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType})));return YV.delete(e),t}return[]}function QV(e,t,r,i){try{if(sC(e))for(let o=0;o<e.length;o++)ZV.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else ZV.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}catch(eO){throw Kk.error(eO),eO}}function ZV(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;if(rC(r)){if(t.required)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_REQUIRED,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(rC(t.defaultValue))return;r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),tC(t.type[i])&&r instanceof t.type[i]&&(e=!0),iC(t.type[i])&&eC(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_TYPE,data:{key:i,rule:{type:t.type.map((e=>dC(e)?hC(e):iC(e)?e:eC(e)))},fnName:o,value:r},link:{className:n,fnName:o}})})}else if(!rC(t.type)&&eC(r)!==t.type)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_TYPE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!1===t.allowEmpty){let e=oC(r)&&(0===r||Number.isNaN(r)),a=iC(r)&&""===r.trim();if(e||a)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_EMPTY,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}if(t.notLessThanZero&&oC(r)&&r<0)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.CANNOT_LESS_THAN_ZERO,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!rC(t.min)&&oC(r)&&r<t.min)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_MIN,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!rC(t.max)&&oC(r)&&r>t.max)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_MAX,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(iC(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}else if(tC(t.instanceOf)&&!(r instanceof t.instanceOf))throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(t.values&&!t.values.includes(r))throw new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.INVALID_PARAMETER_RANGE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});let{properties:a}=t;$D(a)&&aC(r)&&Object.keys(a).forEach((e=>{ZV.call(this,{rule:a[e],value:r&&r[e],key:"".concat(i,".").concat(e),fnName:o,className:n})}));let{arrayItem:s}=t;$D(s)&&sC(r)&&r.forEach(((e,t)=>{ZV.call(this,{rule:s,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),tC(t.validate)&&t.validate.call(this,r,i,o,n,this)}Hk.on(Gk.JOIN_SUCCESS,(e=>{let{room:t}=e;XV(t.userId,{eventId:32788})})),Hk.on(Gk.LEAVE_START,(e=>{let{room:t}=e;XV(t.userId,{eventId:32789})})),Hk.on(Gk.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),XV(t.room.userId,{eventId:e})}})),Hk.on(Gk.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),XV(t.room.userId,{eventId:e})}})),Hk.on(Gk.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Lw.AUDIO?XV(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):XV(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),Hk.on(Gk.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Lw.AUDIO?XV(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):XV(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),Hk.on(Gk.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&XV(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&XV(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&XV(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),Hk.on(Gk.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&XV(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&XV(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&XV(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),Hk.on(Gk.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&XV(t.room.userId,{eventId:t.kind===Lw.VIDEO?32780:32781})})),Hk.on(Gk.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&XV(t.room.userId,{eventId:t.kind===Lw.VIDEO?32782:32783})})),Hk.on(Gk.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o}=e;switch(o){case"CONNECTED":t="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":t=32794}t&&XV(r.userId,{eventId:t})})),Hk.on(Gk.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o,remoteUserId:n}=e,a=!!n;switch(o){case"CONNECTED":t="RECONNECTING"===i?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(t=a?32802:32799);break;case"RECONNECTING":t=a?32800:32797}t&&XV(r.userId,{eventId:t,remoteUserId:n})})),Hk.on(Gk.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(e=>{let{implementation:t,userId:r,remoteUserId:i,codec:o,isHWCodec:n,prevImplementation:a,streamType:s}=e,c=n?1:0;a||(c=n?3:2);let l="h264"===o?0:2,u={eventId:4004,param1:c,param2:l,streamType:s||2};i&&(u.remoteUserId=i,u.eventId=4005),XV(r,u),lM.addEnum({key:i?514701:513701,value:c}),lM.addEnum({key:i?514700:513700,value:l})})),Hk.on(Gk.LOCAL_TRACK_RECAPTURE,(e=>{let{track:t,error:r}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===Lw.AUDIO?(e.streamType=1,r&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,r&&(e.param1=8)),XV(t.userId,e)}})),Fb(Wb(),1);var eF=Object.create,tF=Object.defineProperty,rF=Object.defineProperties,iF=Object.getOwnPropertyDescriptor,oF=Object.getOwnPropertyDescriptors,nF=Object.getOwnPropertyNames,aF=Object.getOwnPropertySymbols,sF=Object.getPrototypeOf,cF=Object.prototype.hasOwnProperty,lF=Object.prototype.propertyIsEnumerable,uF=(e,t,r)=>t in e?tF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dF=(e,t)=>{for(var r in t||(t={}))cF.call(t,r)&&uF(e,r,t[r]);if(aF)for(var r of aF(t))lF.call(t,r)&&uF(e,r,t[r]);return e},hF=(e,t)=>rF(e,oF(t)),pF=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?iF(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&tF(t,r,n),n},mF=(e,t,r)=>uF(e,"symbol"!=typeof t?t+"":t,r),fF=((e,t)=>function(){return t||(0,e[nF(e)[0]])((t={exports:{}}).exports,t),t.exports})({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),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 o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},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 o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},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,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,n),!0;case 6:return u.fn.call(u.context,t,r,o,n,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,n);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)}}),_F=((e,t,r)=>(r=null!=e?eF(sF(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of nF(t))cF.call(e,o)||o===r||tF(e,o,{get:()=>t[o],enumerable:!(i=iF(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:tF(r,"default",{value:e,enumerable:!0}),e)))(fF(),1),gF=Symbol("instance"),EF=Symbol("cacheResult"),vF=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,SF.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},yF=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var TF=new Map;function IF(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=TF.get(i)||[];TF.has(i)||TF.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(r.context&&(i=RF.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[EF]:Promise.resolve(i[EF]);i.state instanceof vF&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof vF&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(l=new yF(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new yF(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let u=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 u(l);let d=i.state,h=new vF(d,t,a);SF.call(i,h);let p=e=>{var o;return i[EF]=e,h.aborted||(SF.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[EF])),e},m=e=>(SF.call(i,d,e),u(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(oO){return m(new yF(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(oO),oO instanceof Error?oO:new Error(String(oO))))}}}}var AF="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 SF(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(RF.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var RF=class e extends _F.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[gF];o?this.name=o.name+"-"+o.count++:i[gF]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=TF.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);TF.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};AF(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){SF.call(this,e)}};RF.STATECHANGED="stateChanged",RF.UPDATEAFSM="updateAFSM",RF.INIT="[*]",RF.ON="on",RF.OFF="off",RF.instances=new Map,RF.instances2=new WeakMap;var bF=class extends RF{constructor(){super(...arguments),mF(this,"decoder"),mF(this,"config")}initialize(){return Gb(this,null,(function*(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}))}configure(e){this.config=e,this.decoder.configure(hF(dF({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function wF(){var e;self.onmessage=t=>{if("init"===t.data.type){let{canvas:r,wasmScript:i,wasmBinary:o}=t.data,n=null==r?void 0:r.getContext("2d"),a=0,s=0,c={wasmBinary:o,postRun:()=>{e=new c.VideoDecoder({videoInfo(e,t){a=e,s=t,console.log("video info",e,t)},yuvData(e,t){let i=a*s,o=i>>2,l=c.HEAPU32[e>>2],u=c.HEAPU32[1+(e>>2)],d=c.HEAPU32[2+(e>>2)],h=c.HEAPU8.subarray(l,l+i),p=c.HEAPU8.subarray(u,u+o),m=c.HEAPU8.subarray(d,d+o),f=new Uint8Array(i+o+o);f.set(h),f.set(p,i),f.set(m,i+o);let _=new VideoFrame(f,{codedWidth:a,codedHeight:s,format:"I420",timestamp:t});r?(null==n||n.drawImage(_,0,0,r.width,r.height),null==n||n.commit()):self.postMessage({type:"yuvData",videoFrame:_},[_])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+i)()(c)}else if("decode"===t.data.type){let{packet:r}=t.data;null==e||e.decode(r.data,"key"==r.type,r.timestamp)}else if("setCodec"===t.data.type){let{codec:r,format:i,description:o}=t.data;null==e||e.setCodec(r,i,null!=o?o:"")}}}pF([IF([RF.INIT,"closed"],"initialized")],bF.prototype,"initialize",1),pF([IF("initialized","configured",{sync:!0})],bF.prototype,"configure",1),pF([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return(e,r,i)=>{let o=i.value,n=r;i.value=function(){if(!t.includes(this.state.toString()))throw new yF(this.state,"".concat(this.name," ").concat(n," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return o.apply(this,r)}}}("configured")],bF.prototype,"decode",1),pF([IF([],RF.INIT,{sync:!0})],bF.prototype,"reset",1),pF([IF([],"closed",{ignoreError:!0,sync:!0})],bF.prototype,"close",1);var DF=class extends RF{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.createModule=e,this.wasmBinary=t,this.workerMode=r,this.canvas=i,this.yuvMode=o,mF(this,"worker"),mF(this,"decoder"),mF(this,"config"),mF(this,"module",{}),mF(this,"width",0),mF(this,"height",0)}initialize(e){return Gb(this,null,(function*(){var t;if(this.workerMode){let e=new RegExp("\\{(.+)\\}","s").exec(wF.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));let r=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),i=yield this.wasmBinary;return console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:r,wasmScript:this.createModule.toString(),wasmBinary:i},r?[r,i]:[i]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){let{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}let r=this.module;return this.wasmBinary&&(r.wasmBinary=yield this.wasmBinary),r.print=e=>console.log(e),r.printErr=e=>console.log("[JS] ERROR: ".concat(e)),r.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{r.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(r,e),this.createModule(r)}))}))}configure(e){var t,r,i;this.config=e;let o=this.config.codec.startsWith("avc")?"avc":"hevc",n=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,n,null!=(t=this.config.description)?t:""),null==(i=this.worker)||i.postMessage({type:"setCodec",codec:o,format:n,description:this.config.description})}decode(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let r={width:e,height:t};this.emit("videoCodecInfo",r)}yuvData(e,t){if(!this.module)return;let r=this.width*this.height,i=r>>2,o=this.module.HEAPU32[e>>2],n=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),c=this.module.HEAPU8.subarray(n,n+i),l=this.module.HEAPU8.subarray(a,a+i);if(this.yuvMode)return void this.emit("videoFrame",{y:s,u:c,v:l,timestamp:t});let u=new Uint8Array(r+i+i);u.set(s),u.set(c,r),u.set(l,r+i),this.emit("videoFrame",new VideoFrame(u,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};pF([IF([RF.INIT,"closed"],"initialized")],DF.prototype,"initialize",1),pF([IF("initialized","configured",{sync:!0})],DF.prototype,"configure",1),pF([IF([],RF.INIT,{sync:!0})],DF.prototype,"reset",1),pF([IF([],"closed",{sync:!0})],DF.prototype,"close",1);var CF,NF=(CF="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,i=e;i.ready=new Promise(((e,i)=>{t=e,r=i}));var o,n,a,s=Object.assign({},i),c="./this.program",l="object"==typeof window,u="function"==typeof importScripts,d=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(l||u)&&(u?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),CF&&(d=CF),d=0!==d.indexOf("blob:")?d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},u&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),n=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)});var h,p,m=i.print||console.log.bind(console),f=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(c=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(h=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&U("no native wasm support detected");var _,g,E,v,y,T,I,A,S,R,b,w,D,C=!1,N=[],k=[],O=[],M=0,L=null;function P(e){M++,i.monitorRunDependencies&&i.monitorRunDependencies(M)}function x(e){if(M--,i.monitorRunDependencies&&i.monitorRunDependencies(M),0==M&&L){var t=L;L=null,t()}}function U(e){i.onAbort&&i.onAbort(e),f(e="Aborted("+e+")"),C=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function V(e){return e.startsWith("data:application/octet-stream;base64,")}function F(e){if(e==R&&h)return new Uint8Array(h);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function B(e,t,r){return(i=e,h||!l&&!u||"function"!=typeof fetch?Promise.resolve().then((()=>F(i))):fetch(i,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+i+"'";return e.arrayBuffer()})).catch((()=>F(i)))).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{f("failed to asynchronously prepare wasm: "+e),U(e)}));var i}V(R="videodec.wasm")||(b=R,R=i.locateFile?i.locateFile(b,d):d+b);var H=e=>{for(;e.length>0;)e.shift()(i)};function j(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){T[this.ptr+4>>2]=e},this.get_type=function(){return T[this.ptr+4>>2]},this.set_destructor=function(e){T[this.ptr+8>>2]=e},this.get_destructor=function(){return T[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,_[this.ptr+12|0]=e},this.get_caught=function(){return 0!=_[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,_[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=_[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){T[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return T[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Rt(this.get_type()))return T[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var G={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,i=e.length-1;i>=0;i--){var o=e[i];"."===o?e.splice(i,1):".."===o?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=G.isAbs(e),r="/"===e.substr(-1);return(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=G.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=G.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return G.normalize(e.join("/"))},join2:(e,t)=>G.normalize(e+"/"+t)},W=e=>(W=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);U("initRandomDevice")})())(e),K={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:ie.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t=G.isAbs(i)}return(t?"/":"")+(e=G.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=K.resolve(e).substr(1),t=K.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),n=Math.min(i.length,o.length),a=n,s=0;s<n;s++)if(i[s]!==o[s]){a=s;break}var c=[];for(s=a;s<i.length;s++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}},z="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,q=(e,t,r)=>{for(var i=t+r,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&z)return z.decode(e.subarray(t,o));for(var n="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var c=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|c:(7&a)<<18|s<<12|c<<6|63&e[t++])<65536)n+=String.fromCharCode(a);else{var l=a-65536;n+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else n+=String.fromCharCode((31&a)<<6|s)}else n+=String.fromCharCode(a)}return n},J=[],Y=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++r):t+=3}return t},X=(e,t,r,i)=>{if(!(i>0))return 0;for(var o=r,n=r+i-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=n)break;t[r++]=s}else if(s<=2047){if(r+1>=n)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=n)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function $(e,t,r){var i=r>0?r:Y(e)+1,o=new Array(i),n=X(e,o,0,o.length);return t&&(o.length=n),o}var Q={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){Q.ttys[e]={input:[],output:[],ops:t},ie.registerDevice(e,Q.stream_ops)},stream_ops:{open:function(e){var t=Q.ttys[e.node.rdev];if(!t)throw new ie.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.get_char)throw new ie.ErrnoError(60);for(var n=0,a=0;a<i;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(c){throw new ie.ErrnoError(29)}if(void 0===s&&0===n)throw new ie.ErrnoError(6);if(null==s)break;n++,t[r+a]=s}return n&&(e.node.timestamp=Date.now()),n},write:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.put_char)throw new ie.ErrnoError(60);try{for(var n=0;n<i;n++)e.tty.ops.put_char(e.tty,t[r+n])}catch(a){throw new ie.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),n}},default_tty_ops:{get_char:function(e){return(()=>{if(!J.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;J=$(e,!0)}return J.shift()})()},put_char:function(e,t){null===t||10===t?(m(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(m(q(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(f(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(f(q(e.output,0)),e.output=[])}}},Z=e=>{U()},ee={ops_table:null,mount:e=>ee.createNode(null,"/",16895,0),createNode(e,t,r,i){if(ie.isBlkdev(r)||ie.isFIFO(r))throw new ie.ErrnoError(63);ee.ops_table||(ee.ops_table={dir:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,lookup:ee.node_ops.lookup,mknod:ee.node_ops.mknod,rename:ee.node_ops.rename,unlink:ee.node_ops.unlink,rmdir:ee.node_ops.rmdir,readdir:ee.node_ops.readdir,symlink:ee.node_ops.symlink},stream:{llseek:ee.stream_ops.llseek}},file:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:{llseek:ee.stream_ops.llseek,read:ee.stream_ops.read,write:ee.stream_ops.write,allocate:ee.stream_ops.allocate,mmap:ee.stream_ops.mmap,msync:ee.stream_ops.msync}},link:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,readlink:ee.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:ie.chrdev_stream_ops}});var o=ie.createNode(e,t,r,i);return ie.isDir(o.mode)?(o.node_ops=ee.ops_table.dir.node,o.stream_ops=ee.ops_table.dir.stream,o.contents={}):ie.isFile(o.mode)?(o.node_ops=ee.ops_table.file.node,o.stream_ops=ee.ops_table.file.stream,o.usedBytes=0,o.contents=null):ie.isLink(o.mode)?(o.node_ops=ee.ops_table.link.node,o.stream_ops=ee.ops_table.link.stream):ie.isChrdev(o.mode)&&(o.node_ops=ee.ops_table.chrdev.node,o.stream_ops=ee.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=ie.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ie.isDir(e.mode)?t.size=4096:ie.isFile(e.mode)?t.size=e.usedBytes:ie.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ee.resizeFileStorage(e,t.size)},lookup(e,t){throw ie.genericErrors[44]},mknod:(e,t,r,i)=>ee.createNode(e,t,r,i),rename(e,t,r){if(ie.isDir(e.mode)){var i;try{i=ie.lookupNode(t,r)}catch(n){}if(i)for(var o in i.contents)throw new ie.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=ie.lookupNode(e,t);for(var i in r.contents)throw new ie.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var i=ee.createNode(e,t,41471,0);return i.link=r,i},readlink(e){if(!ie.isLink(e.mode))throw new ie.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,i,o){var n=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,i);if(a>8&&n.subarray)t.set(n.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=n[o+s];return a},write(e,t,r,i,o,n){if(!i)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(n)return a.contents=t.subarray(r,r+i),a.usedBytes=i,i;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+i),a.usedBytes=i,i;if(o+i<=a.usedBytes)return a.contents.set(t.subarray(r,r+i),o),i}if(ee.expandFileStorage(a,o+i),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+i),o);else for(var s=0;s<i;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+i),i},llseek(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&ie.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new ie.ErrnoError(28);return i},allocate(e,t,r){ee.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,i,o){if(!ie.isFile(e.node.mode))throw new ie.ErrnoError(43);var n,a,s=e.node.contents;if(2&o||s.buffer!==_.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(n=Z()))throw new ie.ErrnoError(48);_.set(s,n)}else a=!1,n=s.byteOffset;return{ptr:n,allocated:a}},msync:(e,t,r,i,o)=>(ee.stream_ops.write(e,t,0,i,r,!1),0)}},te=i.preloadPlugins||[];function re(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ie={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=K.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ie.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),i=ie.root,o="/",n=0;n<r.length;n++){var a=n===r.length-1;if(a&&t.parent)break;if(i=ie.lookupNode(i,r[n]),o=G.join2(o,r[n]),ie.isMountpoint(i)&&(!a||a&&t.follow_mount)&&(i=i.mounted.root),!a||t.follow)for(var s=0;ie.isLink(i.mode);){var c=ie.readlink(o);if(o=K.resolve(G.dirname(o),c),i=ie.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ie.ErrnoError(32)}}return{path:o,node:i}},getPath:e=>{for(var t;;){if(ie.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%ie.nameTable.length},hashAddNode:e=>{var t=ie.hashName(e.parent.id,e.name);e.name_next=ie.nameTable[t],ie.nameTable[t]=e},hashRemoveNode:e=>{var t=ie.hashName(e.parent.id,e.name);if(ie.nameTable[t]===e)ie.nameTable[t]=e.name_next;else for(var r=ie.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=ie.mayLookup(e);if(r)throw new ie.ErrnoError(r,e);for(var i=ie.hashName(e.id,t),o=ie.nameTable[i];o;o=o.name_next){var n=o.name;if(o.parent.id===e.id&&n===t)return o}return ie.lookup(e,t)},createNode:(e,t,r,i)=>{var o=new ie.FSNode(e,t,r,i);return ie.hashAddNode(o),o},destroyNode:e=>{ie.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ie.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>ie.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,t)=>{try{return ie.lookupNode(e,t),20}catch(r){}return ie.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var i;try{i=ie.lookupNode(e,t)}catch(n){return n.errno}var o=ie.nodePermissions(e,"wx");if(o)return o;if(r){if(!ie.isDir(i.mode))return 54;if(ie.isRoot(i)||ie.getPath(i)===ie.cwd())return 10}else if(ie.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?ie.isLink(e.mode)?32:ie.isDir(e.mode)&&("r"!==ie.flagsToPermissionString(t)||512&t)?31:ie.nodePermissions(e,ie.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=ie.MAX_OPEN_FDS;e++)if(!ie.streams[e])return e;throw new ie.ErrnoError(33)},getStreamChecked:e=>{var t=ie.getStream(e);if(!t)throw new ie.ErrnoError(8);return t},getStream:e=>ie.streams[e],createStream:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ie.FSStream||(ie.FSStream=function(){this.shared={}},ie.FSStream.prototype={},Object.defineProperties(ie.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new ie.FSStream,e),-1==t&&(t=ie.nextfd()),e.fd=t,ie.streams[t]=e,e},closeStream:e=>{ie.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ie.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ie.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ie.devices[e]={stream_ops:t}},getDevice:e=>ie.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ie.syncFSRequests++,ie.syncFSRequests>1&&f("warning: ".concat(ie.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ie.getMounts(ie.root.mount),i=0;function o(e){return ie.syncFSRequests--,t(e)}function n(e){if(e)return n.errored?void 0:(n.errored=!0,o(e));++i>=r.length&&o(null)}r.forEach((t=>{if(!t.type.syncfs)return n(null);t.type.syncfs(t,e,n)}))},mount:(e,t,r)=>{var i,o="/"===r,n=!r;if(o&&ie.root)throw new ie.ErrnoError(10);if(!o&&!n){var a=ie.lookupPath(r,{follow_mount:!1});if(r=a.path,i=a.node,ie.isMountpoint(i))throw new ie.ErrnoError(10);if(!ie.isDir(i.mode))throw new ie.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,o?ie.root=c:i&&(i.mounted=s,i.mount&&i.mount.mounts.push(s)),c},unmount:e=>{var t=ie.lookupPath(e,{follow_mount:!1});if(!ie.isMountpoint(t.node))throw new ie.ErrnoError(28);var r=t.node,i=r.mounted,o=ie.getMounts(i);Object.keys(ie.nameTable).forEach((e=>{for(var t=ie.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ie.destroyNode(t),t=r}})),r.mounted=null;var n=r.mount.mounts.indexOf(i);r.mount.mounts.splice(n,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var i=ie.lookupPath(e,{parent:!0}).node,o=G.basename(e);if(!o||"."===o||".."===o)throw new ie.ErrnoError(28);var n=ie.mayCreate(i,o);if(n)throw new ie.ErrnoError(n);if(!i.node_ops.mknod)throw new ie.ErrnoError(63);return i.node_ops.mknod(i,o,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ie.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ie.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var r=e.split("/"),i="",o=0;o<r.length;++o)if(r[o]){i+="/"+r[o];try{ie.mkdir(i,t)}catch(n){if(20!=n.errno)throw n}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,ie.mknod(e,t,r)),symlink:(e,t)=>{if(!K.resolve(e))throw new ie.ErrnoError(44);var r=ie.lookupPath(t,{parent:!0}).node;if(!r)throw new ie.ErrnoError(44);var i=G.basename(t),o=ie.mayCreate(r,i);if(o)throw new ie.ErrnoError(o);if(!r.node_ops.symlink)throw new ie.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename:(e,t)=>{var r,i,o=G.dirname(e),n=G.dirname(t),a=G.basename(e),s=G.basename(t);if(r=ie.lookupPath(e,{parent:!0}).node,i=ie.lookupPath(t,{parent:!0}).node,!r||!i)throw new ie.ErrnoError(44);if(r.mount!==i.mount)throw new ie.ErrnoError(75);var c,l=ie.lookupNode(r,a),u=K.relative(e,n);if("."!==u.charAt(0))throw new ie.ErrnoError(28);if("."!==(u=K.relative(t,o)).charAt(0))throw new ie.ErrnoError(55);try{c=ie.lookupNode(i,s)}catch(p){}if(l!==c){var d=ie.isDir(l.mode),h=ie.mayDelete(r,a,d);if(h)throw new ie.ErrnoError(h);if(h=c?ie.mayDelete(i,s,d):ie.mayCreate(i,s))throw new ie.ErrnoError(h);if(!r.node_ops.rename)throw new ie.ErrnoError(63);if(ie.isMountpoint(l)||c&&ie.isMountpoint(c))throw new ie.ErrnoError(10);if(i!==r&&(h=ie.nodePermissions(r,"w")))throw new ie.ErrnoError(h);ie.hashRemoveNode(l);try{r.node_ops.rename(l,i,s)}catch(p){throw p}finally{ie.hashAddNode(l)}}},rmdir:e=>{var t=ie.lookupPath(e,{parent:!0}).node,r=G.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!0);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.rmdir)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.rmdir(t,r),ie.destroyNode(i)},readdir:e=>{var t=ie.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ie.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ie.lookupPath(e,{parent:!0}).node;if(!t)throw new ie.ErrnoError(44);var r=G.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!1);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.unlink)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.unlink(t,r),ie.destroyNode(i)},readlink:e=>{var t=ie.lookupPath(e).node;if(!t)throw new ie.ErrnoError(44);if(!t.node_ops.readlink)throw new ie.ErrnoError(28);return K.resolve(ie.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var r=ie.lookupPath(e,{follow:!t}).node;if(!r)throw new ie.ErrnoError(44);if(!r.node_ops.getattr)throw new ie.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>ie.stat(e,!0),chmod:(e,t,r)=>{var i;if(!(i="string"==typeof e?ie.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ie.chmod(e,t,!0)},fchmod:(e,t)=>{var r=ie.getStreamChecked(e);ie.chmod(r.node,t)},chown:(e,t,r,i)=>{var o;if(!(o="string"==typeof e?ie.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,r)=>{ie.chown(e,t,r,!0)},fchown:(e,t,r)=>{var i=ie.getStreamChecked(e);ie.chown(i.node,t,r)},truncate:(e,t)=>{if(t<0)throw new ie.ErrnoError(28);var r;if(!(r="string"==typeof e?ie.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);if(ie.isDir(r.mode))throw new ie.ErrnoError(31);if(!ie.isFile(r.mode))throw new ie.ErrnoError(28);var i=ie.nodePermissions(r,"w");if(i)throw new ie.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var r=ie.getStreamChecked(e);if(!(2097155&r.flags))throw new ie.ErrnoError(28);ie.truncate(r.node,t)},utime:(e,t,r)=>{var i=ie.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new ie.ErrnoError(44);var o;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error("Unknown file open mode: ".concat(e));return t}(t):t)?4095&r|32768:0,"object"==typeof e)o=e;else{e=G.normalize(e);try{o=ie.lookupPath(e,{follow:!(131072&t)}).node}catch(c){}}var n=!1;if(64&t)if(o){if(128&t)throw new ie.ErrnoError(20)}else o=ie.mknod(e,r,0),n=!0;if(!o)throw new ie.ErrnoError(44);if(ie.isChrdev(o.mode)&&(t&=-513),65536&t&&!ie.isDir(o.mode))throw new ie.ErrnoError(54);if(!n){var a=ie.mayOpen(o,t);if(a)throw new ie.ErrnoError(a)}512&t&&!n&&ie.truncate(o,0),t&=-131713;var s=ie.createStream({node:o,path:ie.getPath(o),flags:t,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!i.logReadFiles||1&t||(ie.readFiles||(ie.readFiles={}),e in ie.readFiles||(ie.readFiles[e]=1)),s},close:e=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{ie.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ie.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ie.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,i,o)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(1==(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.read)throw new ie.ErrnoError(28);var n=void 0!==o;if(n){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,r,i,o);return n||(e.position+=a),a},write:(e,t,r,i,o,n)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.write)throw new ie.ErrnoError(28);e.seekable&&1024&e.flags&&ie.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,r,i,o,n);return a||(e.position+=s),s},allocate:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(t<0||r<=0)throw new ie.ErrnoError(28);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(!ie.isFile(e.node.mode)&&!ie.isDir(e.node.mode))throw new ie.ErrnoError(43);if(!e.stream_ops.allocate)throw new ie.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,i,o)=>{if(2&i&&!(2&o)&&2!=(2097155&e.flags))throw new ie.ErrnoError(2);if(1==(2097155&e.flags))throw new ie.ErrnoError(2);if(!e.stream_ops.mmap)throw new ie.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,o)},msync:(e,t,r,i,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(!e.stream_ops.ioctl)throw new ie.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'.concat(t.encoding,'"'));var r,i=ie.open(e,t.flags),o=ie.stat(e).size,n=new Uint8Array(o);return ie.read(i,n,0,o,0),"utf8"===t.encoding?r=q(n,0):"binary"===t.encoding&&(r=n),ie.close(i),r},writeFile:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var i=ie.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(Y(t)+1),n=X(t,o,0,o.length);ie.write(i,o,0,n,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ie.write(i,t,0,t.byteLength,void 0,r.canOwn)}ie.close(i)},cwd:()=>ie.currentPath,chdir:e=>{var t=ie.lookupPath(e,{follow:!0});if(null===t.node)throw new ie.ErrnoError(44);if(!ie.isDir(t.node.mode))throw new ie.ErrnoError(54);var r=ie.nodePermissions(t.node,"x");if(r)throw new ie.ErrnoError(r);ie.currentPath=t.path},createDefaultDirectories:()=>{ie.mkdir("/tmp"),ie.mkdir("/home"),ie.mkdir("/home/web_user")},createDefaultDevices:()=>{ie.mkdir("/dev"),ie.registerDevice(ie.makedev(1,3),{read:()=>0,write:(e,t,r,i,o)=>i}),ie.mkdev("/dev/null",ie.makedev(1,3)),Q.register(ie.makedev(5,0),Q.default_tty_ops),Q.register(ie.makedev(6,0),Q.default_tty1_ops),ie.mkdev("/dev/tty",ie.makedev(5,0)),ie.mkdev("/dev/tty1",ie.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=W(e).byteLength),e[--t]);ie.createDevice("/dev","random",r),ie.createDevice("/dev","urandom",r),ie.mkdir("/dev/shm"),ie.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ie.mkdir("/proc");var e=ie.mkdir("/proc/self");ie.mkdir("/proc/self/fd"),ie.mount({mount:()=>{var t=ie.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var r=+t,i=ie.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{i.stdin?ie.createDevice("/dev","stdin",i.stdin):ie.symlink("/dev/tty","/dev/stdin"),i.stdout?ie.createDevice("/dev","stdout",null,i.stdout):ie.symlink("/dev/tty","/dev/stdout"),i.stderr?ie.createDevice("/dev","stderr",null,i.stderr):ie.symlink("/dev/tty1","/dev/stderr"),ie.open("/dev/stdin",0),ie.open("/dev/stdout",1),ie.open("/dev/stderr",1)},ensureErrnoError:()=>{ie.ErrnoError||(ie.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ie.ErrnoError.prototype=new Error,ie.ErrnoError.prototype.constructor=ie.ErrnoError,[44].forEach((e=>{ie.genericErrors[e]=new ie.ErrnoError(e),ie.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ie.ensureErrnoError(),ie.nameTable=new Array(4096),ie.mount(ee,{},"/"),ie.createDefaultDirectories(),ie.createDefaultDevices(),ie.createSpecialDirectories(),ie.filesystems={MEMFS:ee}},init:(e,t,r)=>{ie.init.initialized=!0,ie.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,ie.createStandardStreams()},quit:()=>{ie.init.initialized=!1;for(var e=0;e<ie.streams.length;e++){var t=ie.streams[e];t&&ie.close(t)}},findObject:(e,t)=>{var r=ie.analyzePath(e,t);return r.exists?r.object:null},analyzePath:(e,t)=>{try{e=(i=ie.lookupPath(e,{follow:!t})).path}catch(o){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=ie.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=G.basename(e),i=ie.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(o){r.error=o.errno}return r},createPath:(e,t,r,i)=>{e="string"==typeof e?e:ie.getPath(e);for(var o=t.split("/").reverse();o.length;){var n=o.pop();if(n){var a=G.join2(e,n);try{ie.mkdir(a)}catch(s){}e=a}}return a},createFile:(e,t,r,i,o)=>{var n=G.join2("string"==typeof e?e:ie.getPath(e),t),a=re(i,o);return ie.create(n,a)},createDataFile:(e,t,r,i,o,n)=>{var a=t;e&&(e="string"==typeof e?e:ie.getPath(e),a=t?G.join2(e,t):e);var s=re(i,o),c=ie.create(a,s);if(r){if("string"==typeof r){for(var l=new Array(r.length),u=0,d=r.length;u<d;++u)l[u]=r.charCodeAt(u);r=l}ie.chmod(c,146|s);var h=ie.open(c,577);ie.write(h,r,0,r.length,0,n),ie.close(h),ie.chmod(c,s)}return c},createDevice:(e,t,r,i)=>{var o=G.join2("string"==typeof e?e:ie.getPath(e),t),n=re(!!r,!!i);ie.createDevice.major||(ie.createDevice.major=64);var a=ie.makedev(ie.createDevice.major++,0);return ie.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{i&&i.buffer&&i.buffer.length&&i(10)},read:(e,t,i,o,n)=>{for(var a=0,s=0;s<o;s++){var c;try{c=r()}catch(l){throw new ie.ErrnoError(29)}if(void 0===c&&0===a)throw new ie.ErrnoError(6);if(null==c)break;a++,t[i+s]=c}return a&&(e.node.timestamp=Date.now()),a},write:(e,t,r,o,n)=>{for(var a=0;a<o;a++)try{i(t[r+a])}catch(s){throw new ie.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),ie.mkdev(o,n,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!o)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=$(o(e.url),!0),e.usedBytes=e.contents.length}catch(t){throw new ie.ErrnoError(29)}},createLazyFile:(e,t,r,i,o)=>{function n(){this.lengthKnown=!1,this.chunks=[]}if(n.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},n.prototype.setDataGetter=function(e){this.getter=e},n.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,n=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,a=1048576;o||(a=i);var s=this;s.setDataGetter((e=>{var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,i-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),i!==a&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):$(o.responseText||"",!0)})(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!n&&i||(a=i=1,i=this.getter(0).length,a=i,m("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!u)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new n;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:r};var c=ie.createFile(e,t,s,i,o);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};function d(e,t,r,i,o){var n=e.node.contents;if(o>=n.length)return 0;var a=Math.min(n.length-o,i);if(n.slice)for(var s=0;s<a;s++)t[r+s]=n[o+s];else for(s=0;s<a;s++)t[r+s]=n.get(o+s);return a}return Object.keys(c.stream_ops).forEach((e=>{var t=c.stream_ops[e];l[e]=function(){return ie.forceLoadFile(c),t.apply(null,arguments)}})),l.read=(e,t,r,i,o)=>(ie.forceLoadFile(c),d(e,t,r,i,o)),l.mmap=(e,t,r,i,o)=>{ie.forceLoadFile(c);var n=Z();if(!n)throw new ie.ErrnoError(48);return d(e,_,n,t,r),{ptr:n,allocated:!0}},c.stream_ops=l,c}},oe=(e,t)=>e?q(g,e,t):"",ne={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(G.isAbs(t))return t;var i;if(i=-100===e?ie.cwd():ne.getStreamFromFD(e).path,0==t.length){if(!r)throw new ie.ErrnoError(44);return i}return G.join2(i,t)},doStat:function(e,t,r){try{var i=e(t)}catch(s){if(s&&s.node&&G.normalize(t)!==G.normalize(ie.getPath(s.node)))return-54;throw s}y[r>>2]=i.dev,y[r+4>>2]=i.mode,T[r+8>>2]=i.nlink,y[r+12>>2]=i.uid,y[r+16>>2]=i.gid,y[r+20>>2]=i.rdev,D=[i.size>>>0,(w=i.size,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+24>>2]=D[0],y[r+28>>2]=D[1],y[r+32>>2]=4096,y[r+36>>2]=i.blocks;var o=i.atime.getTime(),n=i.mtime.getTime(),a=i.ctime.getTime();return D=[Math.floor(o/1e3)>>>0,(w=Math.floor(o/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+40>>2]=D[0],y[r+44>>2]=D[1],T[r+48>>2]=o%1e3*1e3,D=[Math.floor(n/1e3)>>>0,(w=Math.floor(n/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+56>>2]=D[0],y[r+60>>2]=D[1],T[r+64>>2]=n%1e3*1e3,D=[Math.floor(a/1e3)>>>0,(w=Math.floor(a/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+72>>2]=D[0],y[r+76>>2]=D[1],T[r+80>>2]=a%1e3*1e3,D=[i.ino>>>0,(w=i.ino,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+88>>2]=D[0],y[r+92>>2]=D[1],0},doMsync:function(e,t,r,i,o){if(!ie.isFile(t.node.mode))throw new ie.ErrnoError(43);if(2&i)return 0;var n=g.slice(e,e+r);ie.msync(t,n,o,r,i)},varargs:void 0,get:()=>(ne.varargs+=4,y[ne.varargs-4>>2]),getStr:e=>oe(e),getStreamFromFD:function(e){return ie.getStreamChecked(e)}};function ae(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: ".concat(e))}}var se=void 0;function ce(e){for(var t="",r=e;g[r];)t+=se[g[r++]];return t}var le={},ue={},de={},he=void 0;function pe(e){throw new he(e)}var me=void 0;function fe(e){throw new me(e)}function _e(e,t,r){function i(t){var i=r(t);i.length!==e.length&&fe("Mismatched type converter count");for(var o=0;o<e.length;++o)ge(e[o],i[o])}e.forEach((function(e){de[e]=t}));var o=new Array(t.length),n=[],a=0;t.forEach(((e,t)=>{ue.hasOwnProperty(e)?o[t]=ue[e]:(n.push(e),le.hasOwnProperty(e)||(le[e]=[]),le[e].push((()=>{o[t]=ue[e],++a===n.length&&i(o)})))})),0===n.length&&i(o)}function ge(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i=t.name;if(e||pe('type "'.concat(i,'" must have a positive integer typeid pointer')),ue.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;pe("Cannot register type '".concat(i,"' twice"))}if(ue[e]=t,delete de[e],le.hasOwnProperty(e)){var o=le[e];delete le[e],o.forEach((e=>e()))}}(e,t,r)}function Ee(e){pe(e.$$.ptrType.registeredClass.name+" instance already deleted")}var ve=!1;function ye(e){}function Te(e){var t;e.count.value-=1,0===e.count.value&&((t=e).smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr))}function Ie(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var i=Ie(e,t,r.baseClass);return null===i?null:r.downcast(i)}var Ae={},Se=[];function Re(){for(;Se.length;){var e=Se.pop();e.$$.deleteScheduled=!1,e.delete()}}var be=void 0,we={};function De(e,t){return t.ptrType&&t.ptr||fe("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&fe("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ce(Object.create(e,{$$:{value:t}}))}var Ce=function(e){return"undefined"==typeof FinalizationRegistry?(Ce=e=>e,e):(ve=new FinalizationRegistry((e=>{Te(e.$$)})),ye=e=>ve.unregister(e),(Ce=e=>{var t=e.$$;if(t.smartPtr){var r={$$:t};ve.register(e,r,e)}return e})(e))};function Ne(){}function ke(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function Oe(e,t){return e=ke(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Me(e,t,r){if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||pe("Function '".concat(r,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}}function Le(e,t,r,i,o,n,a,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=o,this.getActualType=n,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function Pe(e,t,r){for(;t!==r;)t.upcast||pe("Expected null or instance of ".concat(r.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function xe(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Ue(e,t){var r;if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var i=t.$$.ptrType.registeredClass;if(r=Pe(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&pe("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,et.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:pe("Unsupporting sharing policy")}return r}function Ve(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Fe(e){return this.fromWireType(y[e>>2])}function Be(e,t,r,i,o,n,a,s,c,l,u){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=u,o||void 0!==t.baseClass?this.toWireType=Ue:i?(this.toWireType=xe,this.destructorFunction=null):(this.toWireType=Ve,this.destructorFunction=null)}var He=[],je=e=>{var t=He[e];return t||(e>=He.length&&(He.length=e+1),He[e]=t=S.get(e)),t};function Ge(e,t){var r,o,n,a=(e=ce(e)).includes("j")?(r=e,o=t,n=[],function(){return n.length=0,Object.assign(n,arguments),((e,t,r)=>{return e.includes("j")?(o=t,n=r,a=i["dynCall_"+e],n&&n.length?a.apply(null,[o].concat(n)):a.call(null,o)):je(t).apply(null,r);var o,n,a})(r,o,n)}):je(t);return"function"!=typeof a&&pe("unknown function pointer with signature ".concat(e,": ").concat(t)),a}var We=void 0;function Ke(e){var t=St(e),r=ce(t);return It(t),r}function ze(e,t){var r=[],i={};throw t.forEach((function e(t){i[t]||ue[t]||(de[t]?de[t].forEach(e):(r.push(t),i[t]=!0))})),new We("".concat(e,": ")+r.map(Ke).join([", "]))}function qe(e,t){for(var r=[],i=0;i<e;i++)r.push(T[t+4*i>>2]);return r}function Je(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Ye(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var r=Oe(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,o=e.apply(i,t);return o instanceof Object?o:i}function Xe(e,t,r,i,o,n){var a=t.length;a<2&&pe("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==t[1]&&null!==r,c=!1,l=1;l<t.length;++l)if(null!==t[l]&&void 0===t[l].destructorFunction){c=!0;break}var u="void"!==t[0].name,d="",h="";for(l=0;l<a-2;++l)d+=(0!==l?", ":"")+"arg"+l,h+=(0!==l?", ":"")+"arg"+l+"Wired";var p="\n return function ".concat(ke(e),"(").concat(d,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");c&&(p+="var destructors = [];\n");var m=c?"destructors":"null",f=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[pe,i,o,Je,t[0],t[1]];for(s&&(p+="var thisWired = classParam.toWireType("+m+", this);\n"),l=0;l<a-2;++l)p+="var arg"+l+"Wired = argType"+l+".toWireType("+m+", arg"+l+"); // "+t[l+2].name+"\n",f.push("argType"+l),_.push(t[l+2]);if(s&&(h="thisWired"+(h.length>0?", ":"")+h),p+=(u||n?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",c)p+="runDestructors(destructors);\n";else for(l=s?1:2;l<t.length;++l){var g=1===l?"thisWired":"arg"+(l-2)+"Wired";null!==t[l].destructorFunction&&(p+=g+"_dtor("+g+"); // "+t[l].name+"\n",f.push(g+"_dtor"),_.push(t[l].destructorFunction))}return u&&(p+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),p+="}\n",f.push(p),Ye(Function,f).apply(null,_)}function $e(){this.allocated=[void 0],this.freelist=[]}var Qe=new $e;function Ze(e){e>=Qe.reserved&&0==--Qe.get(e).refcount&&Qe.free(e)}var et={toValue:e=>(e||pe("Cannot use deleted val. handle = "+e),Qe.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qe.allocate({refcount:1,value:e})}}};function tt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function rt(e,t){switch(t){case 2:return function(e){return this.fromWireType(I[e>>2])};case 3:return function(e){return this.fromWireType(A[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function it(e,t,r){switch(t){case 0:return r?function(e){return _[e]}:function(e){return g[e]};case 1:return r?function(e){return E[e>>1]}:function(e){return v[e>>1]};case 2:return r?function(e){return y[e>>2]}:function(e){return T[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var ot,nt,at="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,st=(e,t)=>{for(var r=e,i=r>>1,o=i+t/2;!(i>=o)&&v[i];)++i;if((r=i<<1)-e>32&&at)return at.decode(g.subarray(e,r));for(var n="",a=0;!(a>=t/2);++a){var s=E[e+2*a>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},ct=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,o=(r-=2)<2*e.length?r/2:e.length,n=0;n<o;++n){var a=e.charCodeAt(n);E[t>>1]=a,t+=2}return E[t>>1]=0,t-i},lt=e=>2*e.length,ut=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var o=y[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var n=o-65536;i+=String.fromCharCode(55296|n>>10,56320|1023&n)}else i+=String.fromCharCode(o)}return i},dt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,o=i+r-4,n=0;n<e.length;++n){var a=e.charCodeAt(n);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++n)),y[t>>2]=a,(t+=4)+4>o)break}return y[t>>2]=0,t-i},ht=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t},pt={},mt=[],ft=[],_t={},gt=()=>{if(!gt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in _t)void 0===_t[t]?delete e[t]:e[t]=_t[t];var r=[];for(var t in e)r.push("".concat(t,"=").concat(e[t]));gt.strings=r}return gt.strings},Et=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ie.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i};Object.defineProperties(Et.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ie.isDir(this.mode)}},isDevice:{get:function(){return ie.isChrdev(this.mode)}}}),ie.FSNode=Et,ie.createPreloadedFile=function(e,t,r,i,o,a,s,c,l,u){var d=t?K.resolve(G.join2(e,t)):e;function h(r){function n(r){u&&u(),c||ie.createDataFile(e,t,r,i,o,l),a&&a(),x()}(function(e,t,r,i){"undefined"!=typeof Browser&&Browser.init();var o=!1;return te.forEach((function(n){o||n.canHandle(t)&&(n.handle(e,t,r,i),o=!0)})),o})(r,d,n,(()=>{s&&s(),x()}))||n(r)}P(),"string"==typeof r?((e,t,r,i)=>{var o=i?"":"al ".concat(e);n(e,(r=>{var i;i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),r||U(i),t(new Uint8Array(r)),o&&x()}),(t=>{if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&P()})(r,(e=>h(e)),s):h(r)},ie.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);se=e}(),he=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},me=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Ne.prototype.isAliasOf=function(e){if(!(this instanceof Ne&&e instanceof Ne))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,i=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)o=i.upcast(o),i=i.baseClass;return t===i&&r===o},Ne.prototype.clone=function(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Ce(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},Ne.prototype.delete=function(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),ye(this),Te(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},Ne.prototype.isDeleted=function(){return!this.$$.ptr},Ne.prototype.deleteLater=function(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),Se.push(this),1===Se.length&&be&&be(Re),this.$$.deleteScheduled=!0,this},i.getInheritedInstanceCount=function(){return Object.keys(we).length},i.getLiveInheritedInstances=function(){var e=[];for(var t in we)we.hasOwnProperty(t)&&e.push(we[t]);return e},i.flushPendingDeletes=Re,i.setDelayFunction=function(e){be=e,Se.length&&be&&be(Re)},Be.prototype.getPointee=function(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},Be.prototype.destructor=function(e){this.rawDestructor&&this.rawDestructor(e)},Be.prototype.argPackAdvance=8,Be.prototype.readValueFromPointer=Fe,Be.prototype.deleteObject=function(e){null!==e&&e.delete()},Be.prototype.fromWireType=function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=function(e,t){return t=function(e,t){for(void 0===t&&pe("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),we[t]}(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function o(){return this.isSmartPointer?De(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):De(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var n,a=this.registeredClass.getActualType(t),s=Ae[a];if(!s)return o.call(this);n=this.isConst?s.constPointerType:s.pointerType;var c=Ie(t,this.registeredClass,n.registeredClass);return null===c?o.call(this):this.isSmartPointer?De(n.registeredClass.instancePrototype,{ptrType:n,ptr:c,smartPtrType:this,smartPtr:e}):De(n.registeredClass.instancePrototype,{ptrType:n,ptr:c})},We=i.UnboundTypeError=(ot=Error,(nt=Oe("UnboundTypeError",(function(e){this.name="UnboundTypeError",this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(ot.prototype),nt.prototype.constructor=nt,nt.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},nt),Object.assign($e.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Qe.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Qe.reserved=Qe.allocated.length,i.count_emval_handles=function(){for(var e=0,t=Qe.reserved;t<Qe.allocated.length;++t)void 0!==Qe.allocated[t]&&++e;return e};var vt,yt={p:function(e,t,r){throw new j(e).init(t,r),e},C:function(e,t,r){ne.varargs=r;try{var i=ne.getStreamFromFD(e);switch(t){case 0:return(o=ne.get())<0?-28:ie.createStream(i,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return i.flags;case 4:var o=ne.get();return i.flags|=o,0;case 5:return o=ne.get(),E[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return y[At()>>2]=28,-1}}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},w:function(e,t,r,i){ne.varargs=i;try{t=ne.getStr(t),t=ne.calculateAt(e,t);var o=i?ne.get():0;return ie.open(t,r,o).fd}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},t:function(e,t,r,i,o){},n:function(e,t,r,i,o){var n=ae(r);ge(e,{name:t=ce(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:o},argPackAdvance:8,readValueFromPointer:function(e){var i;if(1===r)i=_;else if(2===r)i=E;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);i=y}return this.fromWireType(i[e>>n])},destructorFunction:null})},r:function(e,t,r,o,n,a,s,c,l,u,d,h,p){d=ce(d),a=Ge(n,a),c&&(c=Ge(s,c)),u&&(u=Ge(l,u)),p=Ge(h,p);var m,f,_,g=ke(d);m=g,f=function(){ze("Cannot construct ".concat(d," due to unbound types"),[o])},i.hasOwnProperty(m)?(pe("Cannot register public name '".concat(m,"' twice")),Me(i,m,m),i.hasOwnProperty(_)&&pe("Cannot register multiple overloads of a function with the same number of arguments (".concat(_,")!")),i[m].overloadTable[_]=f):i[m]=f,_e([e,t,r],o?[o]:[],(function(t){var r,n;t=t[0],n=o?(r=t.registeredClass).instancePrototype:Ne.prototype;var s=Oe(g,(function(){if(Object.getPrototypeOf(this)!==l)throw new he("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new he(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new he("Tried to invoke ctor of ".concat(d," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(h.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:s}});s.prototype=l;var h=new Le(d,s,l,p,r,a,c,u);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m,f,_,E=new Be(d,h,!0,!1,!1),v=new Be(d+"*",h,!1,!1,!1),y=new Be(d+" const*",h,!1,!0,!1);return Ae[e]={pointerType:v,constPointerType:y},m=g,f=s,i.hasOwnProperty(m)||fe("Replacing nonexistant public symbol"),i[m].overloadTable,i[m]=f,i[m].argCount=_,[E,v,y]}))},q:function(e,t,r,i,o,n){var a=qe(t,r);o=Ge(i,o),_e([],[e],(function(e){var r="constructor ".concat((e=e[0]).name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new he("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=()=>{ze("Cannot construct ".concat(e.name," due to unbound types"),a)},_e([],a,(function(i){return i.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Xe(r,i,null,o,n),[]})),[]}))},d:function(e,t,r,i,o,n,a,s,c){var l=qe(r,i);t=ce(t),n=Ge(o,n),_e([],[e],(function(e){var i="".concat((e=e[0]).name,".").concat(t);function o(){ze("Cannot call ".concat(i," due to unbound types"),l)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var u=e.registeredClass.instancePrototype,d=u[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,u[t]=o):(Me(u,t,i),u[t].overloadTable[r-2]=o),_e([],l,(function(o){var s=Xe(i,o,e,n,a,c);return void 0===u[t].overloadTable?(s.argCount=r-2,u[t]=s):u[t].overloadTable[r-2]=s,[]})),[]}))},D:function(e,t){ge(e,{name:t=ce(t),fromWireType:function(e){var t=et.toValue(e);return Ze(e),t},toWireType:function(e,t){return et.toHandle(t)},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:null})},k:function(e,t,r){var i=ae(r);ge(e,{name:t=ce(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:rt(t,i),destructorFunction:null})},c:function(e,t,r,i,o){t=ce(t);var n=ae(r),a=e=>e;if(0===i){var s=32-8*r;a=e=>e<<s>>>s}var c=t.includes("unsigned");ge(e,{name:t,fromWireType:a,toWireType:c?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:it(t,n,0!==i),destructorFunction:null})},b:function(e,t,r){var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=T,r=t[e>>=2],o=t[e+1];return new i(t.buffer,o,r)}ge(e,{name:r=ce(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=ce(t));ge(e,{name:t,fromWireType:function(e){var t,i=T[e>>2],o=e+4;if(r)for(var n=o,a=0;a<=i;++a){var s=o+a;if(a==i||0==g[s]){var c=oe(n,s-n);void 0===t?t=c:(t+="\0",t+=c),n=s+1}}else{var l=new Array(i);for(a=0;a<i;++a)l[a]=String.fromCharCode(g[o+a]);t=l.join("")}return It(e),t},toWireType:function(e,t){var i;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||pe("Cannot pass non-string to std::string"),i=r&&o?Y(t):t.length;var n=Tt(4+i+1),a=n+4;if(T[n>>2]=i,r&&o)X(t,g,a,i+1);else if(o)for(var s=0;s<i;++s){var c=t.charCodeAt(s);c>255&&(It(a),pe("String has UTF-16 code units that do not fit in 8 bits")),g[a+s]=c}else for(s=0;s<i;++s)g[a+s]=t[s];return null!==e&&e.push(It,n),n},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},f:function(e,t,r){var i,o,n,a,s;r=ce(r),2===t?(i=st,o=ct,a=lt,n=()=>v,s=1):4===t&&(i=ut,o=dt,a=ht,n=()=>T,s=2),ge(e,{name:r,fromWireType:function(e){for(var r,o=T[e>>2],a=n(),c=e+4,l=0;l<=o;++l){var u=e+4+l*t;if(l==o||0==a[u>>s]){var d=i(c,u-c);void 0===r?r=d:(r+="\0",r+=d),c=u+t}}return It(e),r},toWireType:function(e,i){"string"!=typeof i&&pe("Cannot pass non-string to C++ string type ".concat(r));var n=a(i),c=Tt(4+n+t);return T[c>>2]=n>>s,o(i,c+4,n+t),null!==e&&e.push(It,c),c},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},o:function(e,t){ge(e,{isVoid:!0,name:t=ce(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,i){var o,n;(e=mt[e])(t=et.toValue(t),r=void 0===(n=pt[o=r])?ce(o):n,null,i)},m:Ze,l:function(e,t){var r=function(e,t){for(var r,i,o,n=new Array(e),a=0;a<e;++a)n[a]=(r=T[t+4*a>>2],i="parameter "+a,void 0===(o=ue[r])&&pe(i+" has unknown type "+Ke(r)),o);return n}(e,t),i=r[0],o=i.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",n=ft[o];if(void 0!==n)return n;for(var a=["retType"],s=[i],c="",l=0;l<e-1;++l)c+=(0!==l?", ":"")+"arg"+l,a.push("argType"+l),s.push(r[1+l]);var u,d,h="return function "+ke("methodCaller_"+o)+"(handle, name, destructors, args) {\n",p=0;for(l=0;l<e-1;++l)h+=" var arg"+l+" = argType"+l+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=r[l+1].argPackAdvance;for(h+=" var rv = handle[name]("+c+");\n",l=0;l<e-1;++l)r[l+1].deleteObject&&(h+=" argType"+l+".deleteObject(arg"+l+");\n");return i.isVoid||(h+=" return retType.toWireType(destructors, rv);\n"),h+="};\n",a.push(h),u=Ye(Function,a).apply(null,s),d=mt.length,mt.push(u),n=d,ft[o]=n,n},a:()=>{U("")},e:function(){return Date.now()},v:()=>g.length,A:(e,t,r)=>g.copyWithin(e,t,t+r),u:e=>{g.length,U("OOM")},y:(e,t)=>{var r=0;return gt().forEach((function(i,o){var n=t+r;T[e+4*o>>2]=n,((e,t)=>{for(var r=0;r<e.length;++r)_[0|t++]=e.charCodeAt(r);_[0|t]=0})(i,n),r+=i.length+1})),0},z:(e,t)=>{var r=gt();T[e>>2]=r.length;var i=0;return r.forEach((function(e){i+=e.length+1})),T[t>>2]=i,0},i:function(e){try{var t=ne.getStreamFromFD(e);return ie.close(t),0}catch(r){if(void 0===ie||"ErrnoError"!==r.name)throw r;return r.errno}},x:function(e,t){try{var r=ne.getStreamFromFD(e),i=r.tty?2:ie.isDir(r.mode)?3:ie.isLink(r.mode)?7:4;return _[0|t]=i,E[t+2>>1]=0,D=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+8>>2]=D[0],y[t+12>>2]=D[1],D=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+16>>2]=D[0],y[t+20>>2]=D[1],0}catch(o){if(void 0===ie||"ErrnoError"!==o.name)throw o;return o.errno}},B:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var c=ie.read(e,_,a,s,i);if(c<0)return-1;if(o+=c,c<s)break;void 0!==i&&(i+=c)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}},s:function(e,t,r,i,o){var n,a,s=(a=r)+2097152>>>0<4194305-!!(n=t)?(n>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var c=ne.getStreamFromFD(e);return ie.llseek(c,s,i),D=[c.position>>>0,(w=c.position,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[o>>2]=D[0],y[o+4>>2]=D[1],c.getdents&&0===s&&0===i&&(c.getdents=null),0}catch(l){if(void 0===ie||"ErrnoError"!==l.name)throw l;return l.errno}},h:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var c=ie.write(e,_,a,s,i);if(c<0)return-1;o+=c,void 0!==i&&(i+=c)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}}},Tt=(function(){var e,t,o,n,a={a:yt};function s(e,t){var r,o,n=e.exports;return r=(p=n).E.buffer,i.HEAP8=_=new Int8Array(r),i.HEAP16=E=new Int16Array(r),i.HEAP32=y=new Int32Array(r),i.HEAPU8=g=new Uint8Array(r),i.HEAPU16=v=new Uint16Array(r),i.HEAPU32=T=new Uint32Array(r),i.HEAPF32=I=new Float32Array(r),i.HEAPF64=A=new Float64Array(r),S=p.H,o=p.F,k.unshift(o),x(),n}if(P(),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(c){f("Module.instantiateWasm callback failed with error: "+c),r(c)}(e=h,t=R,o=a,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||V(t)||"function"!=typeof fetch?B(t,o,n):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,o).then(n,(function(e){return f("wasm streaming compile failed: "+e),f("falling back to ArrayBuffer instantiation"),B(t,o,n)}))))).catch(r)}(),e=>(Tt=p.G)(e)),It=e=>(It=p.I)(e),At=()=>(At=p.J)(),St=e=>(St=p.K)(e),Rt=(i.__embind_initialize_bindings=()=>(i.__embind_initialize_bindings=p.L)(),e=>(Rt=p.M)(e));function bt(){function e(){vt||(vt=!0,i.calledRun=!0,C||(i.noFSInit||ie.init.initialized||ie.init(),ie.ignorePermissions=!1,H(k),t(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),O.unshift(e);var e;H(O)}()))}M>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)e=i.preRun.shift(),N.unshift(e);var e;H(N)}(),M>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),e()}),1)):e()))}if(i.dynCall_jiji=(e,t,r,o,n)=>(i.dynCall_jiji=p.N)(e,t,r,o,n),i._ff_h264_cabac_tables=67061,L=function e(){vt||bt(),vt||(L=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return bt(),e.ready}),kF=NF,OF=class extends DF{constructor(e){super(kF,null!=e&&e.wasmPath?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}};(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0})();var MF=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(MF||{});function LF(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var PF=class e{constructor(e){this.core=e,mF(this,"contextMap",new Map),mF(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return null!=e&&e.track?"".concat(e.track.userId).concat(e.track.streamType):"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){switch(e){case"wasm":return new OF(hF(dF({},t),{wasmPath:"".concat(this.core.assetsPath||".","/videodec.wasm")}));case"webCodecs":return new bF;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;var i;return(null==(i=this.decodeProcessorMap.get(r))?void 0:i({frame:t,track:r}))||t},type:3})}decode(e){let{pipe:t,take:r,subscribe:i}=this.core.rx;return o=>{let{frame:n,track:a}=o;if(a!==e.track||"empty"===n.type)return n;if(this.contextMap.has(a))return this.contextMap.get(a).decode(n);let s=this.core.room.videoManager.createDecodeContext(hF(dF({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,r(1),i((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:a})}))),this.contextMap.set(a,s),s.decode(n)}}stop(e){if(null!=e&&e.track){let t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;let r=LF()-e.startPerformanceTime,{renderFreezeTotal:i,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e);r&&this.core.kvStatManager.addNumber({key:514850,value:Math.floor(i/r*100),split:1}),r&&this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/r*100),split:1}),e.inputFrameCount&&this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1})}addKVReportBeforeExitRoom(e){let{room:t}=e;t===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){let t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(hF(dF({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){let r=this.core.room.badCaseDetector.getRenderFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),i=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),o=0;r&&r.freezeTimeline.forEach((e=>{let{startTime:r,endTime:i}=e;r>t.startPerformanceTime&&(o+=0===i?LF()-r:i-r)}));let n=0;return i&&i.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(n+=e.getDuration())})),{renderFreezeTotal:o,dataFreezeTotal:n}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};mF(PF,"Name","TRTCVideoDecoder");var xF=PF,UF=Fb(Wb());function VF(e){let{timesInSecond:t,maxSizeInSecond:r,getSize:i}=e;return WP(((e,o)=>{let n=new WeakMap;return Hk.on(Gk.ROOM_DESTROY,(e=>{let{room:t}=e;return n.delete(t)})),function(){let a=n.get(this);for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},n.set(this,a)),0===a.timestamp?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),i&&(a.totalSizeInSecond+=i(...c)),0!==a.timestamp&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=t||a.totalSizeInSecond>r))throw new Qb({code:Xb.INVALID_OPERATION,message:ZO({key:YO.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=t,isSize:a.totalSizeInSecond>r,name:o,timesInSecond:t,maxSizeInSecond:r}})});a.callCountInSecond++,e.call(this,...c)}}))}var FF,BF=!0,HF={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},jF={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},GF=((FF=GF||{})[FF.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",FF[FF.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",FF[FF.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",FF[FF.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",FF[FF.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",FF[FF.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",FF[FF.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",FF[FF.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",FF[FF.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",FF[FF.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",FF[FF.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",FF[FF.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",FF[FF.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",FF[FF.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",FF[FF.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",FF[FF.INVALID_ROOM_ID_REQUIED=5015]="INVALID_ROOM_ID_REQUIED",FF[FF.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",FF[FF.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",FF[FF.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",FF[FF.INVALID_OPERATION=5100]="INVALID_OPERATION",FF[FF.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",FF[FF.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",FF[FF.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",FF[FF.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",FF[FF.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",FF[FF.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",FF[FF.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",FF[FF.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",FF[FF.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",FF[FF.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",FF[FF.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",FF[FF.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",FF[FF.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",FF[FF.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",FF[FF.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",FF[FF.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",FF[FF.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",FF[FF.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",FF[FF.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",FF[FF.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",FF[FF.DEVICE_ERROR=5300]="DEVICE_ERROR",FF[FF.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",FF[FF.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",FF[FF.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",FF[FF.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",FF[FF.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",FF[FF.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",FF[FF.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",FF[FF.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",FF[FF.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",FF[FF.SERVER_ERROR=5400]="SERVER_ERROR",FF[FF.NEED_TO_BUY=5401]="NEED_TO_BUY",FF[FF.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",FF[FF.OPERATION_FAILED=5500]="OPERATION_FAILED",FF[FF.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",FF[FF.REJOIN_FAILED=5502]="REJOIN_FAILED",FF[FF.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",FF[FF.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",FF[FF.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",FF[FF.OPERATION_ABORT=5998]="OPERATION_ABORT",FF[FF.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",FF);var WF=xb(Pb({},XO),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(eC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(eC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,value:i}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(i,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,value:i}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(i,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing ").concat(r.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone is not turned on.")},INVALID_BUFFER_EMPTY:e=>{let{key:t}=e;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:e=>{let{fnName:t}=e;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got device exception").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:r=KF(t),error:i}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(i?" error: ".concat(i.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:r}=e;return"'".concat(t,"' failed, reason: ").concat(null==r?void 0:r.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:r}=e;return"video context error ".concat(t," ").concat((null==r?void 0:r.name)||""," ").concat((null==r?void 0:r.message)||"")},SERVER_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got server error: ").concat(null==r?void 0:r.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:r}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(r)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' throw unknown exception").concat(r?", error: ".concat(r.toString(),"."):".")}});function KF(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var zF=class e extends Error{constructor(e){let{code:t,extraCode:r,message:i="",messageParams:o,fnName:n="",originError:a}=e;var s;let c;c=i||function(e){let t,{code:r,params:i,enableDocLink:o=!1}=e,a="",s=GF[r];try{t=WF[s]}catch(n){t=WF.UNKNOWN_ERROR}return tC(t)?a=t(i):iC(t)&&(a=t),i.fnName&&!a.includes(i.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(i.fnName,"()")),o&&(a+=" doc:"),a}({code:t===jF.SERVER_ERROR?t:r||t,params:Pb({fnName:n,error:a},o)}),super(c),Hb(this,"name","RtcError"),Hb(this,"code"),Hb(this,"extraCode"),Hb(this,"functionName"),Hb(this,"message"),Hb(this,"handler"),Hb(this,"originError"),this.name=GF[t],this.code=t,this.extraCode=r,this.functionName=n,this.originError=a,this.message=c,5302===this.extraCode&&null!=(s=this.originError)&&s.message.includes("system")&&(this.handler=()=>{let e=document.createElement("a");FN?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):BN&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(t,r,i){let o=t;if(t instanceof Qb){let{stack:n}=t,a={code:jF.UNKNOWN_ERROR,fnName:r,originError:t};switch(t.getCode()){case Xb.INVALID_PARAMETER:a.code=jF.INVALID_PARAMETER,a.message=t.message;break;case Xb.INVALID_OPERATION:a.code=jF.INVALID_OPERATION;break;case Xb.NOT_SUPPORTED:case Xb.NOT_SUPPORTED_H264:a.code=jF.ENV_NOT_SUPPORTED,t.getCode()===Xb.NOT_SUPPORTED_H264&&(a.extraCode=t.message.includes(XO.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case Xb.JOIN_ROOM_FAILED:a.messageParams={fnParams:i};case Xb.SERVER_TIMEOUT:case Xb.SWITCH_ROLE_FAILED:a.code=jF.SERVER_ERROR,a.extraCode=t.getExtraCode();break;case Xb.API_CALL_ABORTED:a.code=jF.OPERATION_ABORT;break;case Xb.DEVICE_NOT_FOUND:case Xb.DEVICE_AUTO_RECOVER_FAILED:case Xb.INITIALIZE_FAILED:a.code=5300,t.name&&(a.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(t.name));break;case Xb.UNKNOWN:break;default:a.code=jF.OPERATION_FAILED}o=new e(a),n&&(o.stack+=n.substr(n.indexOf("\n")))}else{if(t instanceof e)return t;o=new e({code:jF.UNKNOWN_ERROR,fnName:r,originError:t})}return o}};var qF=zF,JF={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},YF={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},XF={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,r){if(iC(e)&&!document.getElementById(e))throw new qF({code:jF.INVALID_PARAMETER,extraCode:5009,fnName:r,messageParams:{key:t}})}},$F={name:"userId",required:!0,type:"string"},QF={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[HF.AUDIO_PROFILE_STANDARD,HF.AUDIO_PROFILE_STANDARD_STEREO,HF.AUDIO_PROFILE_HIGH,HF.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function ZF(e,t){if(!e)throw new qF({code:jF.INVALID_OPERATION,extraCode:5101,fnName:t})}function eB(e,t,r){if(!e)throw new qF({code:jF.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:r}})}var tB={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,r){if(this._room.isJoined)throw new qF({code:jF.INVALID_OPERATION,extraCode:5104,fnName:r});if(e.roomId){if(iC(e.roomId))throw new qF({code:jF.INVALID_PARAMETER,extraCode:5016,fnName:r,messageParams:{key:t}});if(!(/^[1-9]\d*$/.test(String(e.roomId))&&e.roomId<4294967295))throw new qF({code:jF.INVALID_PARAMETER,extraCode:5013,fnName:r,messageParams:{key:t}})}else{if(!e.strRoomId)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5015,fnName:r});if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e.strRoomId))throw new qF({code:jF.INVALID_PARAMETER,extraCode:5012,fnName:r,messageParams:{key:t}})}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:XF,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:JF},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&gM())throw new qF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:xb(Pb({},XF),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:JF}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:QF},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&gM())throw new qF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:QF}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:XF,publish:{type:"boolean"},option:YF},validate(e,t,r,i,o){var n;if(null==(n=null==e?void 0:e.option)||!n.videoTrack){if(gM())throw new qF({code:jF.ENV_NOT_SUPPORTED,extraCode:5201});if(!AM())throw new qF({code:jF.ENV_NOT_SUPPORTED,fnName:r,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:XF,publish:{type:"boolean"},option:YF}},muteRemoteAudio:[$F,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[$F,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:XF,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){ZF(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(eB(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new qF({code:jF.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:xb(Pb({},XF),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){ZF(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(eB(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new qF({code:jF.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,r){if("*"!==e.userId&&rC(e.streamType))throw new qF({code:jF.INVALID_PARAMETER,extraCode:5014,fnName:r})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,r){ZF(this._room.isJoining||this._room.isJoined,r)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,r,i){if(!qM)throw new qF({code:jF.ENV_NOT_SUPPORTED,fnName:r,extraCode:5207});if(!this._room.enableSEI)throw new qF({code:jF.INVALID_OPERATION,fnName:r,extraCode:5108});if(e.byteLength>1e3)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:r});ZF(this._room.isJoined,r)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(e,t,r){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new qF({code:jF.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:r})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(e,t,r,i){if(e.byteLength>1e3)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5017,fnName:r,messageParams:{key:t}})}}},validate(e,t,r){if(ZF(this._room.isJoined,r),"live"===this._room.scene&&"audience"===this._room.role)throw new qF({code:jF.INVALID_OPERATION,extraCode:5107,fnName:r,messageParams:{key:t}})}}},rB={TRTC:tB},iB=class extends Error{};function oB(e,t){let r=SC(e);for(let i=0;i<t.length;i++)AC(r[i],t[i]);return r}function nB(e){this._resolve=Promise.resolve(e)}function aB(e){this._reject=Promise.reject(e)}var sB=class e{constructor(t,r){this.instance=t,this.group=r,Hb(this,"started",!1),Hb(this,"ops",[]),Hb(this,"startSame",(()=>!0)),Hb(this,"mergeUpdate",oB);let i=e.instances.get(t);i?i.set(r,this):e.instances.set(t,new Map([[r,this]]))}static get(t,r){if(!r)return;let i=e.instances.get(t);return i&&i.get(r)||new e(t,r)}static gets(t,r){let i=e.instances.get(t),o=[];return i&&i.forEach(((e,t)=>{r.test(t)&&o.push(e)})),o}action(e,t,r){let i=t=>{var r;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(r=this.currentOp)||r.action(),t},o=t=>{var r,i;throw this.ops.shift(),0===e&&2===(null==(r=this.currentOp)?void 0:r.type)&&this.ops.shift().reject(new iB("start failed")),null==(i=this.currentOp)||i.action(),t},n={type:e,action:()=>t(...n.args).then(i,o),args:r,resolve:nB,reject:aB};try{switch(this.state){case 1:if(0===e)throw new iB("already started");break;case 4:if(2===e)throw new iB("not started");break;default:return this.cacheOp(n)}}catch(tO){return Promise.reject(tO)}return this.ops.push(n),n.promise=t(...n.args).then(i,o)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new iB("already start");break;case 3:switch(e.type){case 2:throw new iB("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new iB("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new iB("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new iB("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new iB("start not allowed after update");case 0:throw new iB("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new iB("keep start")),new iB("already start")}}e.promise=new Promise(((t,r)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(r):e.reject=r}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};Hb(sB,"instances",new WeakMap);var cB=sB,lB=new WeakMap,uB=(e,t)=>{if(t instanceof iB){let{stack:r}=t;t=new qF({code:jF.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),r&&(t.stack+=r.substr(r.indexOf("\n")))}throw t};function dB(e,t){return WP(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let s=cB.get(this,"string"==typeof e?e:e.call(this,...n));return s?(t&&(s.startSame=t.bind(this)),s.action(0,r.bind(this),n).catch(uB.bind(null,i))):r.apply(this,n)}))}function hB(e,t){let{merge:r,debounce:i}=t||{};return WP(((t,o)=>function(){for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];let c=cB.get(this,"string"==typeof e?e:e.call(this,...a));if(!c)return t.apply(this,a);if(r&&(c.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,a)){let{delay:e,getKey:r}=i;return new Promise(((i,n)=>{var s,l;let u=null==(s=lB.get(this))?void 0:s.get(r(...a));if(u){let{timeoutId:e,resolve:t}=u;clearTimeout(e),t()}let d=setTimeout((()=>{if(3===c.state||4===c.state)return i();c.action(2,t.bind(this),a).catch(uB.bind(null,o)).then(i,n)}),e);lB.has(this)?null==(l=lB.get(this))||l.set(r(...a),{timeoutId:d,resolve:i}):lB.set(this,new Map([[r(...a),{timeoutId:d,resolve:i}]]))}))}return c.action(2,t.bind(this),a).catch(uB.bind(null,o))}))}function pB(e){return WP(((t,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a="function"==typeof e?e.call(this,...o):e;if(a instanceof RegExp)return Promise.all(cB.gets(this,a).map((e=>e.action(3,(()=>Promise.resolve()),o)))).then((()=>t.call(this,...o)));let s=cB.get(this,a);return s?s.action(3,t.bind(this),o).catch(uB.bind(null,r)):t.apply(this,o)}))}var mB={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame"},fB=new Set([mB.ERROR,mB.AUTOPLAY_FAILED,mB.KICKED_OUT,mB.REMOTE_USER_ENTER,mB.REMOTE_USER_EXIT,mB.REMOTE_AUDIO_AVAILABLE,mB.REMOTE_AUDIO_UNAVAILABLE,mB.REMOTE_VIDEO_AVAILABLE,mB.REMOTE_VIDEO_UNAVAILABLE,mB.CONNECTION_STATE_CHANGED,mB.PUBLISH_STATE_CHANGED,mB.SCREEN_SHARE_STOPPED,mB.DEVICE_CHANGED,mB.FIRST_VIDEO_FRAME]);function _B(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function gB(e){return e===HF.QOS_PREFERENCE_CLEAR?"detail":e===HF.QOS_PREFERENCE_SMOOTH?"motion":""}var EB={};Vb(EB,{bytes2ms:()=>KD,convertObjectNumberToInt:()=>LC,copyProperties:()=>WD,deepClone:()=>SC,deepMerge:()=>AC,delay:()=>PC,fibonacci:()=>QD,formatedTime:()=>wC,getConstructorName:()=>hC,getContainerFromElement:()=>bC,getEnv:()=>xD,getInternalVersion:()=>gC,getLoggerUrl:()=>VD,getMediaStreamTrackInfo:()=>VC,getMuteStateFromFlag:()=>yC,getNetworkType:()=>BD,getNumNetworkType:()=>GD,getReconnectionTimeout:()=>ZD,getStringByteLength:()=>NC,getTurnServer:()=>TC,getUint32Version:()=>MC,getValueType:()=>eC,getViewListFromView:()=>RC,glog:()=>YD,ipv4ToUint32:()=>IC,isArray:()=>sC,isAudioWorkletSupported:()=>pC,isBoolean:()=>nC,isConstructor:()=>dC,isEmpty:()=>vC,isFunction:()=>tC,isLangChinese:()=>XD,isMediaStreamTrack:()=>cC,isNumber:()=>oC,isObject:()=>aC,isOverseaSdkAppId:()=>UD,isPlainObject:()=>$D,isPortrait:()=>kC,isPromise:()=>uC,isRemoteTrack:()=>lC,isString:()=>iC,isUndefined:()=>rC,loadImage:()=>OC,ms2bytes:()=>qD,ms2samples:()=>JD,normalizeUrl:()=>UC,performanceNow:()=>fC,promiseAny:()=>mC,samples2ms:()=>zD,setNetworkType:()=>jD,stringify:()=>DC,stringifyIncludeValue:()=>CC,throttlePromise:()=>xC});var vB={};Vb(vB,{ScheduleRequestType:()=>bB,getAbilityConfig:()=>DB,getScheduleDomain:()=>CB,isNeedToSchedule:()=>TB,scheduleProxy:()=>SB,sendScheduleRequest:()=>AB,setIsNeedToSchedule:()=>IB,setScheduleProxy:()=>RB});var yB=null,TB=!0;function IB(e){nC(e)&&e!==TB&&(TB=e,Kk.info("setIsNeedToSchedule ".concat(e)))}function AB(e){return Gb(this,arguments,(function(e){let{userId:t,sdkAppId:r,useStringRoomId:i,roomId:o,userSig:n,version:a,frameWorkType:s,role:c,latencyLevel:l}=e;return function*(){if(!TB&&yB)return{isCached:!0,result:yB};let e={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(r)),u.append("isStrGroupId",String(i)),u.append("groupId",String(o)),u.append("sdkVersion",a),u.append("userSig",String(n)),c&&u.append("role",String(c)),l&&u.append("latencyLevel",String(l)),s&&u.append("frameWorkType",String(s));let d=fC(),h=yield function(e,t,r){return new Promise(((i,o)=>{let n=null;mC([kB((e=>t.count[0]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[0]=i.message,n||(a>=1&&(s[0]=wB(r,"config",Lw.MAIN,!0)),o())}))(wB(r,"config",Lw.MAIN),e,{get timeout(){return 1e3*QD(2+t.count[0])}}),kB((e=>t.count[1]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[1]=i.message,n||(a>=2&&(s[0]=wB(r,"config",Lw.BACKUP,!0)),o())}))(wB(r,"config",Lw.BACKUP),e,{get timeout(){return 1e3*QD(2+t.count[1])}})]).then((e=>{n=e,i(n)})).catch(o)}))}(u,e,r);h.config&&(h.config.loggerDomain&&pw(h.config.loggerDomain),nC(h.config.scheduleCache)&&IB(!h.config.scheduleCache)),e.delta=fC()-d;let p=function(e,t,r){let i={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),n=wB(e,"config",Lw.MAIN),a=wB(e,"config",Lw.BACKUP);for(let e of o)if(e.startTime>=r&&(e.name===n||e.name===a)&&e.transferSize>0){let r=e.name===n?Lw.MAIN:Lw.BACKUP,o=Math.round(e.duration),a=Math.round(e.domainLookupStart-e.startTime),s=e.redirectStart>0?Math.round(e.redirectEnd-e.redirectStart):0,c=e.fetchStart>0?Math.round(e.domainLookupStart-e.fetchStart):0,l=Math.round(e.domainLookupEnd-e.domainLookupStart),u=Math.round(e.requestStart-e.secureConnectionStart),d=Math.round(e.secureConnectionStart-e.connectStart),h=Math.round(e.responseStart-e.requestStart),p=Math.round(e.responseEnd-e.responseStart),m=[l,u,d,h,p];RL.uploadEvent({log:"stat-schedule-net:".concat(o,"(").concat(a,"(").concat(s,"->").concat(c,")->").concat(m.join("->"),") ").concat(r),userId:t}),i=xb(Pb({},i),{totalCost:o,local:a,dns:l,tcp:d,tls:u,request:h,response:p});break}}catch(n){Kk.error("getScheduleDetailCost error",n)}return i}(Number(r),t,d);return yB=h,{isCached:!1,result:h,detailCost:p}}catch(u){let e=sC(u)?u[0]:u,t=oC(e.code)?e.code:0,r="schedule failed".concat(e.message?": ".concat(e.message):""),i=new Qb({code:Xb.SCHEDULE_FAILED,extraCode:t,message:ZO({key:YO.JOIN_ROOM_FAILED,data:{error:r,code:t}})});throw Kk.error(r,t),i}}()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(AD).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),Hk.on("28",(()=>IB(!0))),Hk.on("63",(()=>IB(!0))),Hk.on("84",(()=>IB(!0))),Hk.on("201",(e=>{"RECONNECTING"===e.state&&IB(!0)})),Hk.on("202",(e=>{"RECONNECTING"===e.state&&IB(!0)}));var SB={main:"",backup:""};function RB(e){sC(e)?(SB.main=e[0],SB.backup=e[1]):SB.main=e}var bB=(e=>(e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e))(bB||{});function wB(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Lw.MAIN,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(SB[r]||CB(e,r,i),"/api/v1/").concat(t)}function DB(e,t,r){let i=wB(e,t),o=wB(e,t,Lw.BACKUP),n=new URLSearchParams(r).toString();return mC([fetch("".concat(i,"?").concat(n)).then((e=>e.json())),fetch("".concat(o,"?").concat(n)).then((e=>e.json()))])}function CB(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Lw.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=UD(e)?i?r===Lw.MAIN?AD.MAIN_OVERSEA_BACKUP:AD.BACKUP_OVERSEA:r===Lw.MAIN?AD.MAIN_OVERSEA:AD.BACKUP_OVERSEA:r===Lw.MAIN?AD.MAIN:AD.BACKUP,t}function NB(e,t,r){return new Promise(((i,o)=>{FC({url:e,body:t,timeout:r.timeout,priority:"high"}).then((e=>{0===e.data.code?i(e.data.data):o({code:e.data.code,message:e.data.msg})})).catch(o)}))}var kB=(e,t)=>KC({retryFunction:NB,settings:{retries:3,timeout:0},onError:t,onRetrying:e});var OB=class{constructor(){Hb(this,"_log"),this._log=Kk.createLogger({id:"fd"})}download(e,t){return Gb(this,null,(function*(){let{type:r="blob"}=t||{};e=UC(e);try{let t,i=fC();if(t=tC(fetch)?yield this.downloadWithFetch(e,r):yield this.downloadWithXHR(e,r),!t||!t.data)throw new Error("data is empty");let o=fC()-i;return this._log.info("downloaded: ".concat(e,", return type: ").concat(r,", cost: ").concat(o,"ms")),lM.addSuccessEvent({key:522700,cost:fC()-i}),t.data}catch(eO){throw this._log.error("failed to download: ".concat(e,", error: ").concat(eO)),lM.addFailedEvent({key:522700,error:eO}),eO}}))}downloadWithFetch(e,t){return Gb(this,null,(function*(){this._log.info("download with fetch: ".concat(e,", return type: ").concat(t));try{let r,i=yield fetch(e);if(!i.ok)throw new Error("network response was not ok");return r="arraybuffer"===t?yield i.arrayBuffer():yield i.blob(),{data:r}}catch(cD){throw cD}}))}downloadWithXHR(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise(((r,i)=>{let o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=t,o.onload=()=>{200===o.status||0===o.status&&o.response?r({data:o.response}):i(new Error("XHR failed"))},o.onerror=i,o.send(null)}))}loadWasm(e,t){return Gb(this,null,(function*(){this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t)));let r=fC(),i=null,o=null;if(tC(WebAssembly.instantiateStreaming)&&!(e=>e.startsWith("data:application/octet-stream;base64,"))(e)&&!(e=>e.startsWith("file://"))(e)&&tC(fetch))try{let r=fetch(e);i=(yield WebAssembly.instantiateStreaming(r,t)).instance}catch(cw){o=cw}if(!i)try{let r=yield this.download(e,{type:"arraybuffer"});i=(yield WebAssembly.instantiate(r,t)).instance}catch(cw){o=cw}if(i){let t=fC()-r;return this._log.info("loadedWasm ".concat(e,", cost: ").concat(t,"ms")),lM.addSuccessEvent({key:522701,cost:t}),i}throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),lM.addFailedEvent({key:522701,error:o}),o}))}};Bb([wL({settings:{timeout:0,retries:3},onRetrying(e){this._log.warn("download retrying: ".concat(e))}})],OB.prototype,"download",1);var MB=new OB;function LB(e){let{TRTC:t,room:r,errorModule:i,assetsPath:o}=e;return{TRTC:t,room:r,assetsPath:o,fileDownloader:MB,innerEmitter:Hk,constants:iw,environment:qC,utils:EB,eventLogger:RL,log:this.room.getLogger(),loggerManager:Kk,errorModule:i,kvStatManager:lM,rtcDectection:Jk,trtc:this,rx:px,enums:Yk,schedule:vB,clearStarted:(e,t)=>{let r=e.getAlias(),i=cB.instances.get(this);if(i)if(t){let e=i.get(r+t);if(!e)return;e.started=!1}else i.forEach(((e,t)=>{t.startsWith(r)&&(e.started=!1)}))},startGetPCM:dx,createAudioNode:hP}}var PB=new WeakMap;function xB(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return WP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{VB.call(this,t,o,r,this._name)}catch(eO){return Promise.reject(eO)}return e.apply(this,o)}))}function UB(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return WP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{VB.call(this,t,o,r,this._name)}catch(eO){throw eO}return e.apply(this,o)}))}function VB(e,t,r,i){if(sC(e))for(let o=0;o<e.length;o++)FB.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else FB.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}function FB(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;function a(e){return{code:jF.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:i,rule:t,value:r}}}if(rC(r)){if(t.required)throw new qF(a(5001));if(rC(t.defaultValue))return void(tC(t.validate)&&t.validate.call(this,r,i,o,n,this));r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),tC(t.type[i])&&r instanceof t.type[i]&&(e=!0),iC(t.type[i])&&eC(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new qF({code:jF.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:i,rule:{type:t.type.map((e=>dC(e)?hC(e):iC(e)?e:eC(e)))},value:r}})}else if(!rC(t.type)&&eC(r)!==t.type)throw new qF(a(5002));if(!1===t.allowEmpty){let e=oC(r)&&(0===r||Number.isNaN(r)),t=iC(r)&&""===r.trim();if(e||t)throw new qF(a(5003))}if(t.notLessThanZero&&oC(r)&&r<0)throw new qF(a(5006));if(!rC(t.min)&&oC(r)&&r<t.min)throw new qF(a(5007));if(!rC(t.max)&&oC(r)&&r>t.max)throw new qF(a(5008));if(iC(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new qF(a(5004))}else if(tC(t.instanceOf)&&!(r instanceof t.instanceOf))throw new qF(a(5004));if(Array.isArray(t.values)&&!t.values.includes(r))throw new qF(a(5005));let{properties:s}=t;$D(s)&&aC(r)&&Object.keys(s).forEach((e=>{FB.call(this,{rule:s[e],value:r&&r[e],key:"".concat(e),fnName:o,className:n})}));let{arrayItem:c}=t;$D(c)&&sC(r)&&r.forEach(((e,t)=>{FB.call(this,{rule:c,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),tC(t.validate)&&t.validate.call(this,r,i,o,n,this)}function BB(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=()=>"",replaceArg:r,getKVReportKey:i,ignoreLog:o}=e;return WP(((e,n)=>function(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];var l;function u(e,t,i){if(i&&i.includes(e))return"hided";if(r){let e=r(...s);if(s[e.argIndex]===t)return e.value}if(t===s||e in s)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(eC(t)):t instanceof MediaStreamTrack?VC(t):(JSON.stringify(t),t)}catch(nO){return"type:".concat(eC(t))}}let d=this._log||Kk;if(null!=o&&o(...s))return e.apply(this,s);s.length>0?d.info("".concat(n,"() ").concat(JSON.stringify(s,((e,t)=>u(e,t,["userSig","privateMapKey"]))))):d.info("".concat(n,"()"));let h=i?i(...s):iM[n];try{let r=e.apply(this,s),i=fC();return uC(r)?r.then((e=>(d.info("".concat(n,"() success ").concat(t.call(this,...s))),lM.addSuccessEvent({key:h,cost:fC()-i}),e))).catch((e=>{var r;let i=(e=qF.convertFrom.call(this,e,n,1===s.length?s[0]:s)).extraCode||e.code,o=null!=(r=e.message)&&r.includes(i)?"":" code:".concat(i);throw d.error("".concat(n,"() failed ").concat(t.call(this,...s)," ").concat(e).concat(o," params: ").concat(JSON.stringify(s,u))),lM.addFailedEvent({key:h,error:e}),e})):(lM.addSuccessEvent({key:h}),r)}catch(Xk){let t=(Xk=qF.convertFrom.call(this,Xk,n)).extraCode||Xk.code,r=null!=(l=Xk.message)&&l.includes(t)?"":" code:".concat(t);throw d.error("".concat(n,"() failed ").concat(Xk).concat(r," params: ").concat(JSON.stringify(s,u))),lM.addFailedEvent({key:h,error:Xk}),Xk}}))}var HB=e=>WP(((t,r)=>function(i,o){return Gb(this,null,(function*(){let n=this._plugins.get(i);if(!n)throw this._log.error("plugin ".concat(String(i)," is not found")),new qF({code:jF.OPERATION_ABORT,message:"plugin ".concat(String(i)," is not found"),fnName:r});if(tC(n.constructor.isSupported)&&!n.constructor.isSupported())throw this._log.error("plugin ".concat(String(i)," is not supported")),new qF({code:jF.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(i)," is not supported"),extraCode:5210,fnName:r});return VB.call(this,n.getValidateRule(e),[o],r,"TRTC"),t.call(this,n,o)}))})),jB=0,GB=class{constructor(e,t){Hb(this,"player"),Hb(this,"publisher"),Hb(this,"mixInput"),this.mixInput=new lP(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}updateSettings(e){this.player&&(rC(e.volume)||(this.volume=e.volume),rC(e.loop)||(this.loop=e.loop),rC(e.playbackRate)||(this.playbackRate=e.playbackRate))}updateListener(e){if(this.player){if(e.onDurationChange){let{onDurationChange:t}=e;this.player.ondurationchange=e=>{t(e.target.duration)}}if(e.onTimeUpdate){let t=e.onTimeUpdate,{player:r}=this;r.ontimeupdate=()=>{t(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}reset(){this.seek(0),this.mixInput.connect()}seek(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}play(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}set playbackRate(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}};function WB(e,t){if(t&&"function"!=typeof t)throw new qF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var KB=class e{constructor(e){this.core=e,Hb(this,"log"),Hb(this,"mixedMusicMap",new Map),Hb(this,"cacheMusicMap",new Map),jB+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(jB)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(jB)),this.core=e}getName(){return e.Name}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return Gb(this,null,(function*(){let{room:t}=this.core;this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:r,url:i}=e;if(this.mixedMusicMap.has(r))return;let o=this.cacheMusicMap.get(r);o?e.url?o.reset():(o.mixInput.replaceSource(e.track),o.mixInput.connect()):(o=new GB(e,t.audioManager),this.cacheMusicMap.set(r,o)),o.updateListener(e),o.updateSettings(e),yield o.play(),this.mixedMusicMap.set(r,o),this.log.info("start mix audio track ".concat(r," success.")),lM.addEnum({key:502700,value:3}),this.kvUpload(e)}))}update(e){return Gb(this,null,(function*(){let{id:t,operation:r,seekFrom:i,playbackRate:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let n=this.mixedMusicMap.get(t);n?(n.updateSettings(e),n.updateListener(e),rC(r)||n.setOperation(r),rC(i)||n.seek(i),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return Gb(this,arguments,(function(e){var t=this;let{id:r}=e;return function*(){var e;t.mixedMusicMap.has(r)&&(t.log.info("remove music source, music id: ".concat(r)),null==(e=t.mixedMusicMap.get(r))||e.stop(),t.mixedMusicMap.delete(r)),"*"===r&&t.destroyAllMusic()}()}))}kvUpload(e){let{track:t,loop:r,volume:i,playbackRate:o,operation:n,seekFrom:a,onTimeUpdate:s,onDurationChange:c,onEnded:l}=e;t&&lM.addCount({key:502711}),r&&lM.addCount({key:502703}),i&&lM.addCount({key:502704}),o&&lM.addCount({key:502705}),n&&lM.addCount({key:502706}),a&&lM.addCount({key:502707}),"function"!=typeof s&&lM.addCount({key:502709}),"function"!=typeof l&&lM.addCount({key:502710}),"function"!=typeof c&&lM.addCount({key:502708})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>this.stop({id:t})))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};Hb(KB,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,r){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],i=["mp3","ogg","wav","flac"],o=t.split(".").pop(),n=i.indexOf(o)>=0,a=t.startsWith("blob"),s=t.startsWith("data");if(!(n||a||s))throw new qF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:r})}if(!e.url&&!e.track)throw new qF({code:jF.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});WB("onTimeUpdate",e.onTimeUpdate),WB("onEnded",e.onEnded),WB("onDurationChange",e.onDurationChange)}}),Hb(KB,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(e,t,r){WB("onTimeUpdate",e.onTimeUpdate),WB("onEnded",e.onEnded),WB("onDurationChange",e.onDurationChange)}}),Hb(KB,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),Hb(KB,"Name","AudioMixer");var zB,qB=KB,JB=0,YB=class e{constructor(e){this.core=e,Hb(this,"log"),Hb(this,"audioContext",nP()),Hb(this,"workletNode"),JB+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(JB)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(JB)),e.assetsPath&&this.preload("".concat(e.assetsPath,"/denoiser-wasm.js")).catch((e=>{}))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,r,i,o){if(!e.room.audioManager.hasAudioTrack)throw new qF({code:jF.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(e){return zB||(zB=this.doPreload(e)),zB}doPreload(e){return Gb(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),r=URL.createObjectURL(t);try{yield QL(this.audioContext,r)}catch(eO){throw this.log.error("load worklet failed",eO),eO}finally{URL.revokeObjectURL(r)}}))}getName(){return e.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser_".concat(Date.now())}getValidateRule(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return Gb(this,null,(function*(){let{room:t,schedule:r}=this.core;if(yield this.preload("".concat(e.assetsPath,"/denoiser-wasm.js")),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:i,sign:o,status:n,message:a}=yield function(e,t){return Gb(this,arguments,(function(e,t){let{sdkAppId:r,userId:i,userSig:o,timestamp:a}=t;return function*(){try{let{data:{errCode:t,errMsg:n,sign:s,status:c}}=yield e.getAbilityConfig(r,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:r,userId:i,userSig:o,timestamp:a});if("1"===c)return{auth:!0,sign:s,status:c,message:n};let l="Init RTCAIDenoiser failed.",u="";switch(t){case 1:u="Please check your params.";break;case 2:u="You need to buy packages. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 3:u="Server is invalid. Please contact our engineer. ";break;case 4:u="Your packages is not active. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 5:u="Your packages is expired. Refer to: https://cloud.tencent.com/document/product/647/44247";break;case 6:u="Your version is not supported."}return{auth:!1,status:c,message:n?"".concat(l," Reason: ").concat(n,". ").concat(u):"".concat(l,", ").concat(u)}}catch(n){return{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(n)}}}()}))}(r,xb(Pb({},e),{timestamp:t}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(a)),new qF({code:jF.INVALID_PARAMETER,message:a});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:o,status:n}}),this.workletNode.port.onmessage=e=>{var t;let{data:r}=e;if("cost"===r.type){let e=(null==r?void 0:r.max)>20?"warn":(null==r?void 0:r.max)>10?"info":"debug";this.log[e]("avg cost: ".concat(r.value," max: ").concat(null==r?void 0:r.max,"(").concat(tw(new Date(null==r?void 0:r.maxCostTimestamp)),") hist: ").concat(null==(t=null==r?void 0:r.hist)?void 0:t.join(" ")))}else"log"===r.type&&this.log[r.logLevel]("".concat(r.value))}}this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(){return Gb(this,null,(function*(){}))}stop(){return Gb(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};Hb(YB,"updateValidateRule",{type:"object"}),Hb(YB,"stopValidateRule",{type:"object"}),Hb(YB,"Name","AIDenoiser");var XB=YB;var $B=Fb(Wb(),1),QB=class extends $B.EventEmitter{constructor(){super(),Hb(this,"observer"),Hb(this,"state","nominal"),this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return Gb(this,null,(function*(){if(!this.observer)try{"PressureObserver"in window&&!nN&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(sw){RL.uploadEvent({log:"stat-pressure-detector-start-failed",error:sw})}}))}onPressureChange(e){let t=this.stateNum,r=e[e.length-1];this.state=r.state,(this.stateNum>3||t>3)&&Kk.info("".concat(r.source,": ").concat(r.state)),this.emit("state-changed",{type:r.source,state:this.state})}destroy(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(cD){RL.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:cD})}}},ZB=new QB;function eH(e){let[t,r]=e,i=r.byteLength,o=parseInt(String(i/255),10),n=i%255,a=[];a.push(0,0,0,1,6,t);for(let c=0;c<o;c++)a.push(255);a.push(n);let s=new DataView(r);return a.push(...new Uint8Array(s.buffer)),a.push(128),new rx(new DataView(new Uint8Array(a).buffer),!0)}function tH(e){let{frame:t,seiMessageList:r}=e;if(!r||0===r.length||0===t.data.byteLength)return t;let i=9-function(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}(t.data);if(i<=0)return t;let o=r.splice(0,i).reverse().map(eH),n=o.reduce(((e,t)=>e+t.dataView.byteLength),0),a=new ArrayBuffer(n+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),l=0;for(let u=0;u<o.length;u++)for(let e=0;e<o[u].dataView.byteLength;e++)s.setInt8(l++,o[u].dataView.getInt8(e));for(let u=0;u<t.data.byteLength;u++)s.setInt8(l++,c.getInt8(u));return t.data=a,t}function rH(e){let{frame:t,onSEI:r}=e;try{let e=new DataView(t.data);if(function(e){return"empty"===e.type||0===e.data.byteLength}(t)||!function(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}(e))return t;let i=[],o=0,n=-1,a=-1;for(let r=0;r<t.data.byteLength;r++){let s=e.getUint8(r);if(0===s)o++;else if(1===s){if(2===o||3===o){let s=r-o;if(-1===n?n=s:-1===a&&(a=s,i.push(new rx(new DataView(e.buffer.slice(n,a)))),n=s,a=-1),6!==e.getUint8(r+1)){t.data=e.buffer.slice(s);break}}o=0}else o=0}null==r||r(i.reverse())}catch(sw){}return t}var iH=0,oH=class e{constructor(e){this.core=e,Hb(this,"log"),Hb(this,"_seiMessageList",[]),Hb(this,"_smallSeiMessageList",[]),Hb(this,"_subStreamSeiMessageList",[]),iH++,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(iH)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(iH)),this.core=e,this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode(e){let{frame:t,mediaType:r}=e;try{return tH({frame:t,seiMessageList:8===r?this._smallSeiMessageList:2===r?this._subStreamSeiMessageList:this._seiMessageList})}catch(cD){this.log.warn(cD)}return t}decode(e){let{frame:t,track:r}=e;return rH({frame:t,onSEI:e=>{e.forEach((e=>{this.core.trtc.emit(mB.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}destroy(){this.log.debug("destory"),this.stop(),delete this.core}getValidateRule(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:KM?this.encode:tH,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:KM?this.decode:rH,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update(e){let{buffer:t,options:r}=e;var i;let o=[r.seiPayloadType,t],n=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(o):(this._seiMessageList.push(o),n&&this._smallSeiMessageList.push(o)),null==(i=this.core.room.scriptTransformWorker)||i.postMessage({type:"sei",data:o,isMain:!r.toSubStream,small:n})}getName(){return e.Name}getAlias(){return"sei"}getGroup(){return"sei"}};Hb(oH,"autoStart",!0),Hb(oH,"Name","SEI");var nH=oH;function aH(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function sH(e){let{frame:t,onDump:r}=e;return null==r||r(),t}var cH={"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=>{cH["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}}));var lH,uH=0,dH=class e{constructor(e){this.core=e,Hb(this,"_core"),Hb(this,"log"),Hb(this,"dumpLocalVideoMap",{}),Hb(this,"dumpRemoteVideoMap",{}),Hb(this,"dialog"),this._core=e,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(++uH)}),this.log.info("created")}getName(){return e.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}start(){return Gb(this,null,(function*(){var e;!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_ENABLE_DEBUG_PLUGIN"))||(yield this.openDebugDiaLog(),this.addVideoProcessor())}))}update(){}stop(){this.closeDebugDiaLog(),this.removeVideoProcessor()}destroy(){this.stop()}openDebugDiaLog(){return Gb(this,null,(function*(){var e;try{if(lH)yield lH;else{let t=Date.now(),r=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(nw,"/assets/debug-dialog.js");lH=this.loadScript(r),yield lH,this.log.info("download debug dialog script cost: ".concat(Date.now()-t,"ms"))}this.dialog=new TRTCDebugDialog(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap),this._core.kvStatManager.addSuccessEvent({key:592705})}catch(sw){this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(sw))}}))}closeDebugDiaLog(){var e;null==(e=this.dialog)||e.closeDialog(),this.dialog=null}addVideoProcessor(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):aH,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):sH,type:1})}removeVideoProcessor(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}encodeVideo(e){let{frame:t,mediaType:r}=e;return aH({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 sH({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())}})}loadScript(e){return new Promise(((t,r)=>{this.log.info("loading debug dialog from ".concat(e));let i=document.createElement("script");i.type="text/javascript",i.onload=t,i.onerror=r,i.crossOrigin="anonymous",i.src=e,document.head.append?document.head.append(i):document.getElementsByTagName("head")[0].appendChild(i)}))}};Hb(dH,"Name","Debug"),Hb(dH,"autoStart",!0),Bb([wL({settings:{timeout:3e3,retries:3},onError(e,t,r){var i;null!=(i=null==e?void 0:e.message)&&i.includes("timeout")?t():r(e)}})],dH.prototype,"loadScript",1);var hH=dH,pH=e=>{switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},mH=class{constructor(e,t,r){Hb(this,"trackDoneOB"),Hb(this,"startOB"),Hb(this,"stopOB"),Hb(this,"inputFrameCount",0),Hb(this,"decodedFrameCount",0),Hb(this,"type","auto"),Hb(this,"config"),Hb(this,"decoder"),Hb(this,"_decodeSink");let{kvStatManager:i,trtc:o}=e;this.config=r.config,this.trackDoneOB=tU(t,pL.INIT),this.stopOB=Kx(),this.startOB=Kx(),"auto"===r.type?this.type="webCodecs":this.type=r.type;let n=Kx();Sx(this.startOB,Bx(0),eV((e=>{let r=this.pipe(t);return n.next("STARTING"),t.log.info("decoder type: ".concat(this.type)),Sx(r,AU(this.stopOB),IV((()=>{}),(r=>{t.log.error(r),i.addFailedEvent({key:pH(this.type),error:r}),e>4?this.startOB.error(r):this.startOB.next(e+1)}))),Sx(r,IU(1),vV(pU))})),AU(this.stopOB),IV((()=>{t.player.setOutput(),n.next("STARTED")}),(e=>{n.next("FAILED")}),(()=>{i.addSuccessEvent({key:pH(this.type)}),i.addSuccessEvent({key:504702})})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}close(e){this.stopOB.next(e)}pipe(e){return Ox()((t=>Gb(this,null,(function*(){this._decodeSink=t,t.defer((()=>{var e;null==(e=this.decoder)||e.close()}));let{type:r}=this;try{if("webCodecs"===r)this.decoder=new AudioDecoder({error:r=>{e.log.error(r),t.error(4)},output:r=>{this.decodedFrameCount++,t.next(r),e.player.write(r)}});this.decoder.configure(this.config)}catch(eO){e.log.error(eO),t.error("webCodecs"===r?2:6)}}))))}decodeFrame(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}},fH={type:"object"},_H=class e{constructor(e){this.core=e,Hb(this,"log"),Hb(this,"contextMap",new Map),Hb(this,"decodeProcessorMap",new WeakMap),this.log=e.log.createChild({id:"".concat(this.getAlias())})}getAlias(){return e.Name}getGroup(e){return e.track.userId+e.track.streamType}getName(){return e.Name}getValidateRule(e){return fH}start(e){let{track:t}=e;this.decodeProcessorMap.set(t,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;return this.decodeProcessorMap.has(r)?this.decodeProcessorMap.get(r)({frame:t,track:r}):t},type:3})}decode(e){return t=>{let{frame:r,track:i}=t;if(i!==e.track)return r;if(this.contextMap.has(i))return this.contextMap.get(i).decodeFrame(r);let o=new mH(this.core,i,e);return Sx(o.trackDoneOB,IU(1),IV((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:i})}))),this.contextMap.set(i,o),o.decodeFrame(r)}}stop(e){let{track:t}=e,r=this.contextMap.get(t);r&&(r.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}update(e){let t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new mH(this.core,e.track,e))}}};Hb(_H,"Name","TRTCAudioDecoder");var gH=_H,EH=class{constructor(){Hb(this,"log"),this.log=Kk.createLogger({id:"exp"})}call(e,t){return Gb(this,null,(function*(){return tC(this[e])?this[e](t):Promise.reject(new Qb({code:Xb.INVALID_PARAMETER,message:ZO({key:YO.API_NOT_EXIST,data:{name:e}})}))}))}enableAudioFrameEvent(e){return Gb(this,null,(function*(){let{trtcInstance:t,enable:r,userId:i,sampleRate:o=48e3,channelCount:n=1,port:a}=e,{audioManager:s}=t.room,{getPCMAbortCtrlMap:c,audioFrameEventConfigMap:l}=s;if(l.set(i,{enable:r,sampleRate:o,channelCount:n}),r)if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isAvailable){if(c.get(e.userId))return;let r=s.getPCM((e=>{t.emit(mB.AUDIO_FRAME,e)}),e.userId);c.set(e.userId,r)}}));else{if(c.get(i))return;let e=s.getPCM((e=>{t.emit(mB.AUDIO_FRAME,e)}),i);c.set(i,e)}else if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isSubscribed){let{userId:t}=e,r=c.get(t);null==r||r.abort("disable"),c.delete(t)}}));else{let e=c.get(i);null==e||e.abort("disable"),c.delete(i)}}))}};Bb([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return WP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return QV.call(this,t,o,r,this._name),e.apply(this,o)}))}({name:"options",type:"object",required:!0,properties:{enable:{required:!0,type:"boolean"},userId:{required:!0,type:"string"},sampleRate:{type:"number",values:[8e3,16e3,32e3,44100,48e3]},channelCount:{type:"number",values:[1,2]},port:{type:"messageport"}}})],EH.prototype,"enableAudioFrameEvent",1);var vH=new EH,yH=0,TH=new Set,IH=null;aw("5.10.2-wasm.2"),qk.checkStorage(),tL();var AH={RtcError:qF,ErrorCode:jF,ErrorCodeDictionary:GF},SH=class e extends UF.EventEmitter{constructor(t,r){super(),Hb(this,"_room"),Hb(this,"_eventListened",new Set),Hb(this,"_localVideoTrack",null),Hb(this,"_localAudioTrack",null),Hb(this,"_localScreenTrack",null),Hb(this,"_localScreenAudioTrack",null),Hb(this,"_localVideoConfig",null),Hb(this,"_localScreenConfig",null),Hb(this,"_localAudioConfig",null),Hb(this,"_remoteVideoConfigMap",new Map),Hb(this,"_remoteAudioConfigMap",new Map),Hb(this,"_remoteAudioVolumeMap",new Map),Hb(this,"_remoteAudioMuteMap",new Map),Hb(this,"_mediaTrackMap",new WeakMap),Hb(this,"_log",Kk.createLogger({id:"t".concat(++yH)})),Hb(this,"_plugins",new Map),Hb(this,"_networkQuality",null),Hb(this,"_speakerId"),this._room=new t(Pb({logger:this._log,frameWorkType:e.frameWorkType},r)),this._room.videoDecodeFallbackType=r.videoDecodeFallback,this._log.info("create() ".concat(JSON.stringify(r,((e,t)=>"plugins"===e?t.map((e=>e.Name)):t)))),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}}),r.plugins&&r.plugins.forEach((e=>{this._use(e,r.assetsPath)})),this._use(qB,r.assetsPath),this._use(XB,r.assetsPath),this._use(gH,r.assetsPath||vw),this._use(hH),r.enableSEI&&qM&&this._use(nH),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),1===r.volumeType&&e.forEach((e=>{var t;let r=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;r&&(e.volume=r.dbVolume)})),this.emit(mB.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{this._log.error(new qF({code:jF.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:r}=e;e.emit=function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{return r.apply(e,o)}catch(eO){let r=ZO({key:YO.CATCH_HANDLER_ERROR,data:{name:t,event:o[0]},addDocLink:!1});return Kk.warn("".concat(r,"\n\n").concat(eO.stack)),!1}}})(this,"trtc")}static create(e){}static _create(t,r){!function(){var e;if(BF){BF=!1,5!==Kk.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(Ew,"/en/index.html")),console.info("* Changelog: ".concat(Ew,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),Kk.info("TRTC Web SDK Version:",nw),Sk||Kk.debug("Build Time:","2025-05-26 17:35:19");let t="UA: ".concat(navigator.userAgent," \nCPU core: ").concat(navigator.hardwareConcurrency,", GPU: ").concat(Ok()),r=navigator.deviceMemory;r&&(t+=", minRAM: ".concat(r,"GB")),Kk.info(t),Kk.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),kk().then((e=>{e&&Kk.info(Nk)}))}}();let i=new e(t,r||{});return TH.add(i),i}get room(){return this._room}_listenEvents(){AL(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(mB.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(mB.REMOTE_USER_EXIT,{userId:e}),this._remoteAudioVolumeMap.delete(e)})).add("banned",(e=>{this._exitRoom().finally((()=>{this.emit(mB.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().finally((()=>{this.emit(mB.ERROR,qF.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(mB.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e;let t=xb(Pb({},e),{uplinkRTT:Math.min(e.uplinkRTT,PD),downlinkRTT:Math.min(e.downlinkRTT,PD)});this.emit(mB.NETWORK_QUALITY,t)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{AL(t,t).add("player-state-changed",(r=>{let i=xb(Pb({},r),{userId:e.userId});t.kind===Lw.VIDEO&&(i.streamType=_B(t.streamType)),this.emit(t.kind===Lw.AUDIO?mB.AUDIO_PLAY_STATE_CHANGED:mB.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(e=>{e.getCode()===Xb.PLAY_NOT_ALLOWED&&this.emit(mB.AUTOPLAY_FAILED,{userId:t.userId,resume:()=>t.player.resume()})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{SL(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:r}=e,{userId:i}=r,o=t.audioAvailable,n=t.videoAvailable,{audioAvailable:a,videoAvailable:s}=r;a||this._remoteAudioConfigMap.delete(i),s||this._removeRemoteVideoConfig(i,"main"),r.hasAuxiliary||this._removeRemoteVideoConfig(i,"sub"),n!==s&&(s?this._onVideoAvailable({userId:i,streamType:"main"}):this._onVideoUnavailable({userId:i,streamType:"main"}),this.emit(s?mB.REMOTE_VIDEO_AVAILABLE:mB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==a&&(a?this._onAudioAvailable({userId:i}):this._onAudioUnavailable({userId:i,muteState:r}),this.emit(a?mB.REMOTE_AUDIO_AVAILABLE:mB.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),t.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?this._onVideoAvailable({userId:i,streamType:"sub"}):this._onVideoUnavailable({userId:i,streamType:"sub"}),this.emit(r.hasAuxiliary?mB.REMOTE_VIDEO_AVAILABLE:mB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(e=>{this.emit(mB.SEI_MESSAGE,xb(Pb({},e),{streamType:_B(e.streamType)}))})).add("firewall-restriction",(()=>{this.emit(mB.ERROR,new qF({code:jF.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(e=>{var t,r,i,o,n,a,s;let c={2:"big",3:"small",7:"sub"},l={rtt:Math.min(e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(r=this._networkQuality)?void 0:r.uplinkRTT)||(null==(i=this._networkQuality)?void 0:i.downlinkRTT)||0,PD),upLoss:(null==(o=this._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(n=this._networkQuality)?void 0:n.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_level)||0)/FO},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/FO,point2pointDelay:(e.msg_audio_status.uint32_audio_p2p_delay||0)+(e.msg_audio_status.uint32_audio_cache_ms||0),jitterBufferDelay:e.msg_audio_status.uint32_audio_cache_ms||0},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type],point2pointDelay:(e.uint32_video_p2p_delay||0)+(e.uint32_video_cache_ms||0),jitterBufferDelay:e.uint32_video_cache_ms||0})))})))};this.emit(mB.STATISTICS,l)})).add("custom-message",(e=>{this.emit(mB.CUSTOM_MESSAGE,e)})).add("layerData",(e=>this.emit(mB.LAYER_DATA,e))).add("first-video-frame",(e=>{this.emit(mB.FIRST_VIDEO_FRAME,xb(Pb({},e),{streamType:_B(e.streamType)}))})).add("audio-frame",(e=>{this.emit(mB.AUDIO_FRAME,e)})),AL(this,TP).add("audioInputAdded",(e=>{this.emit(mB.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(mB.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(mB.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(mB.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>Gb(this,null,(function*(){if(this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),IH&&IH.deviceId===DD){let e=(yield wP()).find((e=>e.deviceId===DD));e&&IH.groupId!==e.groupId&&(IH=e,this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>Gb(this,null,(function*(){this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield wP())[0];if(!t||!IH||IH.groupId===t.groupId)return;let r=IH.deviceId===e.deviceId,i=IH.deviceId===DD&&IH.deviceId===t.deviceId;(r||i)&&(IH=t,this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))}))))}use(e){let t,r;"plugin"in e?(t=e.plugin,r=e.assetsPath):t=e,this._use(t,r||vw)}_use(t,r){if(this._plugins.get(t.Name))return void this._log.warn("duplicate install plugin",t.Name);let i=new t(LB.call(this,{TRTC:e,room:this._room,errorModule:AH,assetsPath:r}));this._plugins.set(t.Name,i),t.autoStart&&this.startPlugin(t.Name)}enterRoom(t){return Gb(this,null,(function*(){var r,i;let{scene:o="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:a=!0,autoReceiveVideo:s=!1}=t;t.proxy&&(this._room.setProxyServer(t.proxy),!iC(t.proxy)&&t.proxy.turnServer&&(null==(i=(r=this._room).setTurnServer)||i.call(r,t.proxy.turnServer,t.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=a,this._room.autoReceiveVideo=s,nC(t.preferHW)&&(this._room.preferHW=t.preferHW),t.playoutDelay&&(this._room.playoutDelay=t.playoutDelay),t.jitterBufferDelay&&(this._room.jitterBufferDelay=t.jitterBufferDelay);let c={sdkAppId:t.sdkAppId,userId:t.userId,userSig:t.userSig,privateMapKey:t.privateMapKey||null,latencyLevel:t.latencyLevel,role:"audience"===t.role?21:20,roomId:t.roomId||0,strRoomId:t.strRoomId||"",businessInfo:t.businessInfo||null,streamId:null,userDefineRecordId:t.userDefineRecordId||null,frameWorkType:t.frameWorkType,component:t.component,language:t.language,priority:t.priority,useVp8:t.useVp8,keepAlive:t.keepAlive};t.strRoomId&&!t.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,yield this._room.join(c,o,e.frameWorkType),this._checkTrackToPublish(),ZB.start()}))}exitRoom(){return Gb(this,null,(function*(){return yield this._exitRoom()}))}switchRole(e,t){return Gb(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){SL(this),this.removeAllListeners(),this._room.destroy(),TH.delete(this),0===TH.size&&ZB.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((e=>{var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),Hk.off("102",this._onLocalTrackCaptured,this)}startLocalAudio(){return Gb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:r=!0,mute:i,option:o}=t,n=new tx(e._room.audioManager),a={},s={muted:!0};o&&(rC(o.microphoneId)?rC(o.audioTrack)||(a.customSource=o.audioTrack):a.deviceId=o.microphoneId,o&&oC(o.captureVolume)&&n.setCaptureVolume(o.captureVolume),rC(o.profile)||(iC(o.profile)?kw[o.profile]&&n.setProfile(kw[o.profile]):n.setProfile(o.profile)),oC(o.earMonitorVolume)&&(s.muted=!(o.earMonitorVolume>0),s.volume=o.earMonitorVolume),rC(o.echoCancellation)||(n.profile.echoCancellation=o.echoCancellation),rC(o.noiseSuppression)||(n.profile.noiseSuppression=o.noiseSuppression),rC(o.autoGainControl)||(n.profile.autoGainControl=o.autoGainControl)),n.on("5",(t=>{e.emit(mB.ERROR,new qF({code:jF.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),n.on("2",(t=>{e.emit(mB.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),n.on("4",(t=>{let r;t.error&&(r=qF.convertFrom(t.error)),e.emit(mB.PUBLISH_STATE_CHANGED,xb(Pb({},t),{error:r}))})),e._listenOutputTrackChanged(n),e._speakerId&&n.setAudioOutput(e._speakerId),yield n.capture(a),rC(i)||n.setMute(i),AL(n,n).add("player-state-changed",(t=>{e.emit(mB.AUDIO_PLAY_STATE_CHANGED,xb(Pb({},t),{userId:""}))})),r&&e._room.isJoined&&e._room.publish(n).catch((()=>{})),e._localAudioTrack=n,e._localAudioConfig=xb(Pb({},t),{publish:r}),yield e._updateAudioPlayOption({playOption:s,track:n}),Hk.emit("113",{userId:"",room:e.room})}()}))}updateLocalAudio(e){return Gb(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:r,option:i}=e,o={};i&&(i.microphoneId?yield this._localAudioTrack.switchDevice(i.microphoneId):rC(i.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack)),rC(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),rC(i.earMonitorVolume)||(o.muted=!(i.earMonitorVolume>0),o.volume=i.earMonitorVolume),yield this._localAudioTrack.update3A(i)),this._room.isJoined&&!rC(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),rC(r)||this._localAudioTrack.setMute(r),yield this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),AC(this._localAudioConfig,e)}))}stopLocalAudio(){return Gb(this,null,(function*(){this._localAudioTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),Hk.emit("114",{userId:"",room:this.room}),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),SL(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return Gb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:r,publish:i=!0,mute:o,option:n}=t,a=new nx(e._room.videoManager),s={},c={};nC(null==n?void 0:n.avoidCropping)&&(a.avoidCropping=n.avoidCropping),n&&(n.cameraId?s.deviceId=n.cameraId:rC(n.useFrontCamera)?rC(n.videoTrack)||(s.customSource=n.videoTrack):s.facingMode=n.useFrontCamera?Lw.FACING_MODE_USER:Lw.FACING_MODE_ENVIRONMENT,n.qosPreference&&(s.contentHint=gB(n.qosPreference)),rC(n.profile)||(iC(n.profile)?Ow[n.profile]&&a.setProfile(Ow[n.profile]):a.setProfile(n.profile)),rC(n.fillMode)||(c.objectFit=n.fillMode),rC(n.mirror)||(c.mirror=n.mirror),rC(n.small)||(kM()?iC(n.small)?a.small=Ow[n.small]:!0===n.small?a.small=Ow["120p"]:a.small=n.small:e._log.warn("small stream is not supported"))),a.once("first-video-frame",(t=>{e.emit(mB.FIRST_VIDEO_FRAME,xb(Pb({},t),{streamType:_B(t.streamType)}))})),a.on("5",(t=>{e.emit(mB.ERROR,new qF({code:jF.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),a.on("2",(t=>{e.emit(mB.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),a.on("4",(t=>{let r;t.error&&(r=qF.convertFrom(t.error)),e.emit(mB.PUBLISH_STATE_CHANGED,xb(Pb({},t),{error:r}))})),e._listenOutputTrackChanged(a),yield a.capture(s),rC(o)||(yield a.setMute(o)),AL(a,a).add("player-state-changed",(t=>{e.emit(mB.VIDEO_PLAY_STATE_CHANGED,xb(Pb({},t),{userId:"",streamType:"main"}))})),i&&e._room.isJoined&&e._room.publish(a).catch((()=>{})),e._localVideoTrack=a,e._localVideoConfig=xb(Pb({},t),{view:r,publish:i}),yield e._updateVideoPlayOption({view:r,playOption:c,track:a})}()}))}updateLocalVideo(e){return Gb(this,null,(function*(){if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:t,publish:r,mute:i,option:o}=e,n={};if(o)if(rC(o.profile)||(iC(o.profile)?Ow[o.profile]&&this._localVideoTrack.setProfile(Ow[o.profile]):this._localVideoTrack.setProfile(o.profile),(!o.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(o.cameraId))&&rC(o.useFrontCamera)&&(yield this._localVideoTrack.applyProfile())),o.cameraId?yield this._localVideoTrack.switchDevice(o.cameraId):rC(o.useFrontCamera)?rC(o.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(o.videoTrack)):yield this._localVideoTrack.switchDevice(o.useFrontCamera?Lw.FACING_MODE_USER:Lw.FACING_MODE_ENVIRONMENT),rC(o.fillMode)||(n.objectFit=o.fillMode),rC(o.mirror)||(n.mirror=o.mirror),o.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(gB(o.qosPreference)),o.small){let e=!this._localVideoTrack.small;kM()?(!0===o.small?this._localVideoTrack.small=Ow["120p"]:iC(o.small)?this._localVideoTrack.small=Ow[o.small]:this._localVideoTrack.small=o.small,this._room.videoManager.update(),e&&this._room.enableSmall(!0)):this._log.warn("small stream is not supported")}else!1===o.small&&this._localVideoTrack.small&&(delete this._localVideoTrack.small,this._room.videoManager.update(),this._room.enableSmall(!1));this._room.isJoined&&!rC(r)&&(r&&!this._localVideoConfig.publish&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._localVideoConfig.publish&&!r&&this._room.unpublish(this._localVideoTrack).catch((()=>{}))),rC(i)||(yield this._localVideoTrack.setMute(i)),yield this._updateVideoPlayOption({view:t,playOption:n,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),AC(this._localVideoConfig,e)}))}stopLocalVideo(){return Gb(this,null,(function*(){this._localVideoTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),SL(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return Gb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:r=null,publish:i=!0,option:o}=t,n=new cx(e._room.videoManager);n.on("4",(t=>{let r;t.error&&(r=qF.convertFrom(t.error)),e.emit(mB.PUBLISH_STATE_CHANGED,xb(Pb({},t),{error:r}))})),n.once("first-video-frame",(t=>{e.emit(mB.FIRST_VIDEO_FRAME,xb(Pb({},t),{streamType:_B(t.streamType)}))})),e._listenOutputTrackChanged(n),"main"===t.streamType&&(n.mediaType=4);let a=null,s={},c={};o&&(rC(o.profile)||(iC(o.profile)?Mw[o.profile]&&n.setProfile(Mw[o.profile]):n.setProfile(o.profile)),o.systemAudio&&(s.systemAudio=!0,s.echoCancellation=o.echoCancellation,s.noiseSuppression=o.noiseSuppression,s.autoGainControl=o.autoGainControl),rC(o.fillMode)||(c.objectFit=o.fillMode),o.videoTrack&&(s.videoTrack=o.videoTrack),o.audioTrack&&(s.audioTrack=o.audioTrack),o.captureElement&&(s.captureElement=o.captureElement),o.preferDisplaySurface&&(s.preferDisplaySurface=o.preferDisplaySurface),o.qosPreference&&(s.contentHint=gB(o.qosPreference)));let l=yield n.capture(s);if(n.mediaTrack.addEventListener(Lw.ENDED,(()=>{e._stopScreenShare(),e.emit(mB.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(a=new ux(e._room.audioManager),yield a.setInputMediaStreamTrack(l.getAudioTracks()[0]),e._speakerId&&a.setAudioOutput(e._speakerId)),AL(n,n).add("player-state-changed",(t=>{e.emit(mB.VIDEO_PLAY_STATE_CHANGED,xb(Pb({},t),{userId:"",streamType:"sub"}))})),i&&e._room.isJoined){let t=[n];a&&t.push(a),e._room.publish(...t).catch((()=>{}))}e._localScreenTrack=n,e._localScreenAudioTrack=a,e._localScreenConfig=xb(Pb({},t),{view:r,publish:i}),yield e._updateVideoPlayOption({view:r,playOption:c,track:n})}()}))}updateScreenShare(e){return Gb(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:r,option:i}=e,o={};if(i&&(rC(i.fillMode)||(o.objectFit=i.fillMode),i.qosPreference)){let e=gB(i.qosPreference);this._localScreenTrack.setContentHint(e)}this._room.isJoined&&!rC(r)&&(r&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((()=>{}))),this._localScreenConfig.publish&&!r&&(this._room.unpublish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((()=>{})))),yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),AC(this._localScreenConfig,e)}))}stopScreenShare(){return Gb(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return Gb(this,null,(function*(){let{view:t,userId:r,streamType:i,option:o}=e,n="".concat(r,"_").concat(i);if(this._remoteVideoConfigMap.has(n))return void this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i));let a=this._room.remotePublishedUserMap.get(r);if(!a)return;let s={},c="main"===i?a.remoteVideoTrack:a.remoteAuxiliaryTrack;this._listenOutputTrackChanged(c),o&&(rC(o.fillMode)||(s.objectFit=o.fillMode),rC(o.mirror)||(s.mirror=o.mirror),rC(o.poster)||(s.poster=o.poster),s.canvasRender=o.canvasRender,"main"===i&&!rC(o.small)&&(!a.remoteVideoTrack.isSubscribing&&!a.remoteVideoTrack.isSubscribed&&a.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,c.user))),yield this._room.subscribe(c),yield this._enableVideoDecodeFallback(c,i),yield this._updateVideoPlayOption({view:t,playOption:s,track:c}),this._emitTrackEvent(c),this._remoteVideoConfigMap.set(n,{config:e}),o&&!rC(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:c,view:t,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot})}))}updateRemoteVideo(e){return Gb(this,null,(function*(){var t,r;let{view:i,userId:o,streamType:n,option:a}=e,s="".concat(o,"_").concat(n),c=this._remoteVideoConfigMap.get(s);if(!c||!this._room.remotePublishedUserMap.has(o))return;let l={};a&&(rC(a.fillMode)||(l.objectFit=a.fillMode),rC(a.mirror)||(l.mirror=a.mirror));let u=null,d=this._room.remotePublishedUserMap.get(o);if("main"===n&&null!=d&&d.muteState.hasVideo&&(u=d.remoteVideoTrack),"sub"===n&&null!=d&&d.muteState.hasAuxiliary&&(u=d.remoteAuxiliaryTrack),!u)return;let{config:h}=c;"main"===n&&a&&!rC(a.small)&&this._room.changeType(a.small,u.user),yield this._updateVideoPlayOption({view:i,playOption:l,track:u,prevConfig:h}),AC(h,e);let p=rC(null==a?void 0:a.receiveWhenViewVisible)?null==(t=h.option)?void 0:t.receiveWhenViewVisible:a.receiveWhenViewVisible,m=rC(i)?h.view:i,f=rC(null==a?void 0:a.viewRoot)?null==(r=h.option)?void 0:r.viewRoot:a.viewRoot;this._observeView({remoteTrack:u,view:m,receiveWhenViewVisible:p,viewRoot:f})}))}stopRemoteVideo(e){return Gb(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Gb(this,null,(function*(){let r=[],i=this._room.remotePublishedUserMap.get(e.userId);if(i){let{muteState:t,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=i;"main"===e.streamType&&(o.stop(),t.hasVideo&&r.push(o)),"sub"===e.streamType&&(n.stop(),t.hasAuxiliary&&r.push(n))}for(let e of r)t&&(yield this._room.unsubscribe(e),this._mediaTrackMap.delete(e.outMediaTrack));this._removeRemoteVideoConfig(e.userId,e.streamType)}))}_removeRemoteVideoConfig(e,t){let r="".concat(e,"_").concat(t),i=this._remoteVideoConfigMap.get(r);i&&i.observer&&i.observer.disconnect(),this._remoteVideoConfigMap.delete(r)}muteRemoteAudio(e,t){return Gb(this,null,(function*(){this._remoteAudioMuteMap.set(e,t);try{if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&!this._remoteAudioConfigMap.has(t.userId)&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):this._remoteAudioConfigMap.has(e)||(yield this._startRemoteAudio({userId:e}))}catch(eO){throw this._remoteAudioMuteMap.delete(e),eO}}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let r of e)this._remoteAudioVolumeMap.set(r.userId,t),r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}else if(e){let r=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),r&&r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}}startPlugin(e,t){return Gb(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return Gb(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return Gb(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,r){if(this.listeners(e).includes(t))return this;if(this._log.debug("on",e),super.on(e,t,r),this._eventListened.add(e),this.listeners(mB.AUDIO_FRAME).length>0){let{audioFrameEventConfigMap:e}=this.room.audioManager;e.get("")||e.set("",{enable:!0}),this._localAudioTrack&&this.room.audioManager.handleLocalTrackStarted({userId:"",room:this.room})}return this}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];try{fB.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(r)))}catch(eO){}return super.emit(e,...r)}off(t,r,i){if(this._log.debug("off",t),"*"===t?(this._eventListened.clear(),this.removeAllListeners()):super.off(t,r,i),(t===e.EVENT.AUDIO_FRAME||"*"===t)&&0===this.listeners(e.EVENT.AUDIO_FRAME).length){let{getPCMAbortCtrlMap:e}=this.room.audioManager;e.forEach((e=>{null==e||e.abort("off")})),e.clear()}return this}getAudioTrack(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},r=null,i="main",o=!1;if(iC(t)?e=t:(e=t.userId,o=!0===t.processed,t.streamType&&(i=t.streamType)),e){let t=this._room.remotePublishedUserMap.get(e);t&&(r=t.remoteAudioTrack)}else r="sub"===i?this._localScreenAudioTrack:this._localAudioTrack;return r?o&&r.outMediaTrack&&r.outMediaTrack!==r.mediaTrack?r.outMediaTrack.clone():r.mediaTrack:null}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:r="main",processed:i=!1}=e,o=null;if(""===t)"main"===r&&this._localVideoTrack&&(o=this._localVideoTrack),"sub"===r&&this._localScreenTrack&&(o=this._localScreenTrack);else{let e=this._room.remotePublishedUserMap.get(t);e&&(o="main"===r?e.remoteVideoTrack:e.remoteAuxiliaryTrack)}return o?i&&o.outMediaTrack&&o.outMediaTrack!==o.mediaTrack?o.outMediaTrack.clone():o.mediaTrack:null}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:r="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=e&&e.muteState.hasVideo)return e.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=e&&e.muteState.hasAuxiliary)return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}_setCurrentSpeaker(e){var t,r;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(r=this._localScreenAudioTrack)||r.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}setCurrentSpeaker(e){return Gb(this,null,(function*(){(yield wP()).forEach((t=>{t.deviceId===e&&(this._setCurrentSpeaker(e),this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),IH=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/TRTC.html#.setCurrentSpeaker')}))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return Gb(this,null,(function*(){let{userId:t}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let i={},o=r.remoteAudioTrack;this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId);try{let r=this._remoteAudioVolumeMap.get(t),n=oC(r)?r:100;i.volume=n,this._remoteAudioConfigMap.set(t,e),yield this._room.subscribe(o),Sx(tU(o,"decode-failed"),AU(tU(o,pL.INIT)),IV((()=>{this.startPlugin(gH.Name,{track:o,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),yield this._updateAudioPlayOption({playOption:i,track:o}),Hk.emit("115",{userId:t,room:this.room})}catch(tO){throw this._remoteAudioConfigMap.delete(t),tO}this._emitTrackEvent(o)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Gb(this,null,(function*(){let r=this._room.remotePublishedUserMap.get(e.userId);r&&(r.remoteAudioTrack.stop(),r.muteState.hasAudio&&t&&(yield this._room.unsubscribe(r.remoteAudioTrack)),this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId)),Hk.emit("116",{userId:e.userId,room:this.room})}))}_enableVideoDecodeFallback(e,t){let r,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),Sx(tU(e,"decode-failed"),AU(tU(e,pL.INIT)),AV((()=>{this.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),rV(tU(e,"decode-downgrade-state-changed")),IV((i=>{r=i.state,this.emit(mB.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,xb(Pb({},i),{streamType:t,userId:e.userId}))}),(t=>{e.log.error("fallback",t)}),(()=>{"STARTED"===r&&e.log.info("fallback complete")}))))}_updateVideoPlayOption(e){return Gb(this,arguments,(function(e){let{view:t,playOption:r,track:i,prevConfig:o}=e;return function*(){if(i.setMirror(r.mirror),rC(t)&&o&&o.view&&!vC(r)){let e=RC(o.view);e.length>0&&(yield i.play(e,r))}if(!rC(t)){let e=RC(t);e.length>0?yield i.play(e,r):i.stop()}}()}))}_updateAudioPlayOption(e){return Gb(this,arguments,(function(e){let{playOption:t={},track:r,prevConfig:i}=e;return function*(){if(!r.isPlayCalled)try{yield r.play(null,t)}catch(cw){}rC(t.muted)||r.setPlayerMute(t.muted),rC(t.volume)||r.setAudioVolume(t.volume/100)}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e,!1)))}_emitTrackEvent(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===r||(this._mediaTrackMap.set(e.outMediaTrack,r),this.emit(mB.TRACK,{userId:r,streamType:_B(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}_checkTrackToPublish(){var e,t,r;let i=[];if(null!=(e=this._localAudioConfig)&&e.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(t=this._localVideoConfig)&&t.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack)),0!==i.length)return this._room.publish(...i).catch((()=>{}))}_observeView(e){let{remoteTrack:t,view:r,receiveWhenViewVisible:i=!1,viewRoot:o}=e;if(rC(r))return;let n=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(_B(t.streamType)));if(!n)return;let a=n.observer||void 0;if(null===r||sC(r)&&0===r.length||!i)return null==a||a.disconnect(),void(t.isSubscribed||this._room.subscribe(t).catch((()=>{})));let s=n.visibleViewMap||new Map,c=-1;(!a||a.root!==o)&&(null==a||a.disconnect(),s.clear(),a=new IntersectionObserver((e=>{e.forEach((e=>{s.set(e.target,e.isIntersecting),t.log.info("view ".concat(e.target.id," is").concat(e.isIntersecting?"":" not"," visible"))})),clearTimeout(c),c=window.setTimeout((()=>{[...s.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:o}));let l=new Set(RC(r));s.forEach(((e,t)=>{l.has(t)||(a.unobserve(t),s.delete(t))})),l.forEach((e=>{s.set(e,!0),a.observe(e)})),a.takeRecords().forEach((e=>{s.set(e.target,e.isIntersecting)})),n.visibleViewMap=s,n.observer=a}_exitRoom(){return Gb(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),new Set([...this._remoteAudioConfigMap.keys(),...this._remoteAudioMuteMap.keys()]).forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",r=e.split("_".concat(t))[0];r&&this._stopRemoteVideo({userId:r,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._remoteAudioVolumeMap.clear(),function(e){let t=PB.get(e);t&&(t.forEach((e=>clearTimeout(e))),PB.delete(e))}(this),this._room.remotePublishedUserMap.forEach((e=>{SL(e.remoteAudioTrack),SL(e.remoteVideoTrack),SL(e.remoteAuxiliaryTrack)}))}))}_stopScreenShare(){return Gb(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t).catch((()=>{}))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),SL(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_onLocalTrackCaptured(e){let{track:t}=e;"audio"===t.kind&&(!IH||IP(IH))&&(this._initActiveSpeaker(),Hk.off("102",this._onLocalTrackCaptured,this))}_initActiveSpeaker(){return Gb(this,null,(function*(){if(IH&&!IP(IH))this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:IH});else{let e=yield wP();e[0]&&!IP(e[0])?(IH=e[0],this.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]})):Hk.on("102",this._onLocalTrackCaptured,this)}}))}_onAudioAvailable(e){let{userId:t}=e,r=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===r||this._room.autoReceiveAudio&&!r)&&this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:r}=e;if(!this._room.autoReceiveVideo)return;let i=this._room.remotePublishedUserMap.get(t);if(i){let e="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,t=[e];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&t.push(i.remoteAudioTrack),this._room.subscribe(...t).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:r}=e;r.hasAudio&&r.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:r}=e;this._stopRemoteVideo({userId:t,streamType:r},!1).catch((()=>{}))}sendSEIMessage(e,t){var r;let i=this._plugins.get("SEI");i&&(i.update({buffer:e,options:xb(Pb({seiPayloadType:243},t),{small:!(null==(r=this._localVideoTrack)||!r.small)})}),lM.addCount({key:5e5,useUV:!0}))}sendCustomMessage(e){var t,r;null==(r=(t=this._room).sendCustomMessage)||r.call(t,e),lM.addCount({key:500001,useUV:!0})}callExperimentalAPI(e,t){return Gb(this,null,(function*(){return this._log.info("callExperimentalAPI(".concat(e,", ").concat(JSON.stringify(t),")")),vH.call(e,Pb({trtcInstance:this},t))}))}static setLogLevel(e,t){Kk.setLogLevel(e),rC(t)||(t?Kk.enableUploadLog():Kk.disableUploadLog())}static isSupported(){return TM()}static getCameraList(){return RP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getMicrophoneList(){return SP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getSpeakerList(){return wP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static setCurrentSpeaker(t){return Gb(this,null,(function*(){if(!nN||t!==HF.SPEAKER&&t!==HF.HEADSET)(yield wP()).forEach((e=>{e.deviceId===t&&(TH.forEach((r=>{r._setCurrentSpeaker(t),r.emit(mB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e})})),IH=e)}));else{let r=yield e.getMicrophoneList(),i="";if(r.forEach((e=>{e.label===t&&(i=e.deviceId)})),!i)return;TH.forEach((e=>Gb(this,null,(function*(){e._localAudioTrack&&(yield e.updateLocalAudio({option:{microphoneId:i}}))}))))}}))}static _addKVStat(e){let{type:t,key:r,value:i,base:o,useUV:n,version:a}=e;switch(a&&(cM.version=a),t){case"count":cM.addCount({key:r,useUV:n});break;case"enum":cM.addEnum({key:r,value:i,useUV:n});break;case"number":cM.addNumber({key:r,value:i,split:o})}}};Hb(SH,"_loggerManager",Kk),Hb(SH,"EVENT",mB),Hb(SH,"ERROR_CODE",jF),Hb(SH,"TYPE",HF),Hb(SH,"frameWorkType",30),Bb([BB({replaceArg:e=>({argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}})})],SH.prototype,"use",1),Bb([xB(rB.TRTC.enterRoom),dB("room",((e,t)=>{let[r]=e,[i]=t;return(r.roomId||r.strRoomId)===(i.roomId||i.strRoomId)&&r.userId===i.userId&&r.sdkAppId===i.sdkAppId})),WP((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),BB()],SH.prototype,"enterRoom",1),Bb([BB()],SH.prototype,"exitRoom",1),Bb([xB(rB.TRTC.switchRole),hB("room",{merge:(e,t)=>t}),BB()],SH.prototype,"switchRole",1),Bb([BB()],SH.prototype,"destroy",1),Bb([xB(rB.TRTC.startLocalAudio),dB("audio",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)===(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)})),BB()],SH.prototype,"startLocalAudio",1),Bb([xB(rB.TRTC.updateLocalAudio),hB("audio",{debounce:{delay:200,getKey:()=>"".concat(yH,"-localAudio"),isNeedToDebounce:e=>{var t;return!rC(null==(t=e.option)?void 0:t.captureVolume)}}}),BB()],SH.prototype,"updateLocalAudio",1),Bb([pB("audio"),BB()],SH.prototype,"stopLocalAudio",1),Bb([xB(rB.TRTC.startLocalVideo),dB("video",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)===(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)})),BB()],SH.prototype,"startLocalVideo",1),Bb([xB(rB.TRTC.updateLocalVideo),hB("video"),BB()],SH.prototype,"updateLocalVideo",1),Bb([pB("video"),BB()],SH.prototype,"stopLocalVideo",1),Bb([xB(rB.TRTC.startScreenShare),dB("screen",(()=>!0)),BB()],SH.prototype,"startScreenShare",1),Bb([xB(rB.TRTC.updateScreenShare),hB("screen"),BB()],SH.prototype,"updateScreenShare",1),Bb([BB()],SH.prototype,"stopScreenShare",1),Bb([xB(rB.TRTC.startRemoteVideo),dB((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),BB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],SH.prototype,"startRemoteVideo",1),Bb([xB(rB.TRTC.updateRemoteVideo),hB((e=>"v".concat(e.userId).concat(e.streamType))),BB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],SH.prototype,"updateRemoteVideo",1),Bb([xB(rB.TRTC.stopRemoteVideo),WP((e=>function(t){return Gb(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),BB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],SH.prototype,"stopRemoteVideo",1),Bb([pB((e=>"v".concat(e.userId).concat(e.streamType)))],SH.prototype,"_stopRemoteVideo",1),Bb([xB(...rB.TRTC.muteRemoteAudio),BB({getRemoteId:e=>e})],SH.prototype,"muteRemoteAudio",1),Bb([UB(...rB.TRTC.setRemoteAudioVolume),function(e,t){return WP(((r,i)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a=PB.get(this);a||(a=new Map,PB.set(this,a));let s=t(...o),c=a.get(s);if(!c||c<=0){r.apply(this,o);let t=setTimeout((()=>{var e;null==(e=PB.get(this))||e.delete(s)}),e);a.set(s,t)}else{clearTimeout(c);let t=window.setTimeout((()=>{var e;r.apply(this,o),null==(e=PB.get(this))||e.delete(s)}),e);a.set(s,t)}}))}(200,(e=>e)),BB({getRemoteId:e=>e})],SH.prototype,"setRemoteAudioVolume",1),Bb([HB("start"),GP((e=>{var t;return null==(t=e.afterStart)?void 0:t.call(e)})),dB(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),BB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>oM[e.getName()],ignoreLog:e=>"Debug"===e.getName()})],SH.prototype,"startPlugin",1),Bb([HB("update"),hB(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),BB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>nM[e.getName()]})],SH.prototype,"updatePlugin",1),Bb([HB("stop"),pB(((e,t)=>{if(e.disableRandomCall)return null;let r=e.getGroup(t),i=e.getAlias();return"*"===r?new RegExp("".concat(i,".*")):i+r})),BB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>aM[e.getName()]})],SH.prototype,"stopPlugin",1),Bb([UB(...rB.TRTC.enableAudioVolumeEvaluation)],SH.prototype,"enableAudioVolumeEvaluation",1),Bb([BB()],SH.prototype,"getVideoSnapshot",1),Bb([BB()],SH.prototype,"_setCurrentSpeaker",1),Bb([dB((e=>"a".concat(e.userId)),(()=>!0))],SH.prototype,"_startRemoteAudio",1),Bb([WP((e=>function(t){return Gb(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(xb(Pb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),pB((e=>"a".concat(e.userId)))],SH.prototype,"_stopRemoteAudio",1),Bb([pB("room")],SH.prototype,"_exitRoom",1),Bb([pB("screen")],SH.prototype,"_stopScreenShare",1),Bb([xB(...rB.TRTC.sendSEIMessage),VF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].byteLength}})],SH.prototype,"sendSEIMessage",1),Bb([xB(rB.TRTC.sendCustomMessage),VF({timesInSecond:30,maxSizeInSecond:8e3,getSize:e=>e.data.byteLength})],SH.prototype,"sendCustomMessage",1),Bb([xB(rB.TRTC.create)],SH,"_create",1);var RH=SH,bH=class{constructor(e,t){Hb(this,"_flag"),Hb(this,"terminalType"),Hb(this,"userId"),Hb(this,"tinyId"),Hb(this,"role"),Hb(this,"remoteAudioTrack"),Hb(this,"remoteVideoTrack"),Hb(this,"remoteAuxiliaryTrack"),this.userId=t.userId||"",this.tinyId=t.tinyId||"",this.role=t.role||"audience",this.terminalType=t.terminalType,this.remoteAudioTrack=new DV(e,this),this.remoteVideoTrack=new qV(e,this),this.remoteAuxiliaryTrack=new JV(e,this),this.flag=t.flag||0}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return yC(this.flag,this.userId)}get flag(){return this._flag}set flag(e){if(e===this._flag)return;let t,r=this.muteState;this._flag=e;let i=this.muteState;for(t in i)r[t]!=i[t]&&console.log(this.userId,t,r[t],"->",i[t]);this.remoteAudioTrack.onFlagChanged(),this.remoteVideoTrack.onFlagChanged(),this.remoteAuxiliaryTrack.onFlagChanged()}},wH=class{constructor(){Hb(this,"_set",new Set),Hk.on(Gk.LEAVE_SUCCESS,this.delete,this)}add(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,r||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(i)}delete(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,t.roomId||r,t.sdkAppId,t.useStringRoomId);this._set.delete(i)}getKey(e,t,r,i){return"".concat(r,"_").concat(t,"_").concat(e,"_").concat(i)}isJoined(e){let{userId:t,roomId:r,sdkAppId:i,room:o}=e;return"rtc"!==o.scene&&this._set.has(this.getKey(t,r,i,o.useStringRoomId))}};function DH(){return Gb(this,null,(function*(){let e,t;try{let t=yield SP();e=t&&t.length}catch(d){}try{let e=yield RP();t=e&&e.length}catch(d){}let r={microphone:e,camera:t},{isH264EncodeSupported:i,isVp8EncodeSupported:o,isH264DecodeSupported:n,isVp8DecodeSupported:a}=this.checkSystemResult.detail,s=Jk.basis(),c={webRTC:s.isWebRTCSupported,getUserMedia:s.isGetUserMediaSupported,webSocket:s.isWebSocketsSupported,screenShare:s.isScreenShareSupported,webAudio:s.isWebAudioSupported,h264Encode:i,h264Decode:n,vp8Encode:o,vp8Decode:a},l={browser:s.browser,os:s.os,trtc:c,devices:r},u={isWebCodecSupported:s.isWebCodecSupported,isMediaSessionSupported:s.isMediaSessionSupported,isWebTransportSupported:s.isWebTransportSupported};RL.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),RL.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(u)),userId:this.userId})}))}var CH=class{constructor(e){Hb(this,"_frameWorkType"),Hb(this,"_component"),Hb(this,"_language"),Hb(this,"connectionType"),Hb(this,"_room"),Hb(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),Hb(this,"_keyPrefix"),Hb(this,"_log"),Hb(this,"_intervalId"),Hb(this,"_firstPublishedUserList"),Hb(this,"_networkQuality"),Hb(this,"_basicInfo"),Hb(this,"_pathJoinRoom"),Hb(this,"_pathLeaveRoom"),Hb(this,"_pathMainVideoMap"),Hb(this,"_pathMainAudioMap"),Hb(this,"_pathAuxiliaryMap"),Hb(this,"_remoteStreamStatMap"),Hb(this,"_localStreamStat"),Hb(this,"_eventMap",new Map),Hb(this,"_captureCostSum",0),Hb(this,"_captureCostCount",0),Hb(this,"isDestroyed",!1),this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=Kk.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&tC(this[e])&&(this[e]=function(e){let{fn:t,context:r}=e;return function(){try{for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];let n=t.apply(r,i);return uC(n)?n.catch((e=>Kk.error("".concat(t.name,"() error observed ").concat(e)))):n}catch(cD){Kk.error("".concat(t.name,"() error observed ").concat(cD))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents()}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:nw,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,kk().then((e=>{this._basicInfo.string_os_version=Uk(),this._basicInfo.string_device_name=e&&e.mobile?e.model:this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),Hk.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(Gk.JOIN_START,this.handleJoinStart).addEvent(Gk.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(Gk.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(Gk.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(Gk.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(Gk.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(Gk.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(Gk.JOIN_FAILED,this.handleJoinFailed).addEvent(Gk.LEAVE_START,this.handleLeaveStart).addEvent(Gk.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(Gk.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(Gk.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(Gk.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(Gk.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(Gk.PUBLISH_START,this.handlePublishStart).addEvent(Gk.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(Gk.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(Gk.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(Gk.PLAY_TRACK_START,this.handlePlayStart).addEvent(Gk.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(Gk.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,type:i}=e;!t.isRemote||!this.hitTest(t.room)||"PLAYING"===r&&(i===Lw.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(Gk.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(Gk.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(Gk.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(Gk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let o=r.hasAudio||r.hasVideo||r.hasSmall,n=r.hasAuxiliary,a=i.hasAudio||i.hasVideo||i.hasSmall,s=i.hasAuxiliary;!o&&a&&this.handleRemoteStreamAdded(i.userId,"main"),!n&&s&&this.handleRemoteStreamAdded(i.userId,"auxiliary")})).addEvent(Gk.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:r}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=r.ice,this._pathJoinRoom.int32_dtls_cost=r.dtls,this._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}uninstallEvents(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach(((e,t)=>Hk.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),vL.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(rC(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),rC(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),rC(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:r}=e;if(this.hitTest(t)&&r){let{totalCost:e,local:t,dns:i,tcp:o,tls:n,request:a,response:s}=r;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=i,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=n,this._pathJoinRoom.int32_schedule_request=a,this._pathJoinRoom.int32_schedule_response=s}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:r}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),r&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=r instanceof Qb?Number(r.getExtraCode()||r.getCode()):Xb.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:r}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleRemoteStreamAdded(e,t){var r;let i="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(i)){let o={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:xb(Pb({},kH),{msg_user_info:new OH({userId:e,tinyId:null==(r=this._room.remotePublishedUserMap.get(e))?void 0:r.tinyId,role:20})})};o.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(i,o)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:r,streamType:i,subscribeState:o}=e;if(!this.hitTest(t))return;let{userId:n,tinyId:a,role:s}=r,c=new OH({userId:n,tinyId:a,role:"anchor"===s?20:21}),l=Date.now(),u="".concat(n,"_").concat(i),d=this._remoteStreamStatMap.get(u);d&&0===d.subscribeStartTime&&(d.subscribeStartTime=l),"main"===i?(r.muteState.hasVideo&&(o.video||o.smallVideo)&&!this._pathMainVideoMap.has(u)&&this._pathMainVideoMap.set(u,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:n,sendSubscribeCMDTime:l}),r.muteState.hasAudio&&o.audio&&!this._pathMainAudioMap.has(u)&&this._pathMainAudioMap.set(u,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:n,sendSubscribeCMDTime:l})):r.muteState.hasAuxiliary&&o.auxiliary&&!this._pathAuxiliaryMap.has(u)&&this._pathAuxiliaryMap.set(u,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:r,streamType:i}=e;if(this.hitTest(t)){let e="".concat(r.userId,"_").concat(i),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._remoteStreamStatMap.get(r);0===(null==i?void 0:i.playStreamTime)&&(i.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._pathMainVideoMap.get(r);i&&0===i.statsToReport.uint64_combine_first_frame_time&&(i.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=Date.now(),i=this._pathMainVideoMap.get(t),o=this._remoteStreamStatMap.get(t);if(o){let{statsToReport:t}=o;if(t.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){let e=r-this._pathJoinRoom.uint64_start_time;t.uint32_video_render_first=e,lM.addNumber({key:516820,value:e})}}0===(null==i?void 0:i.statsToReport.uint64_render_first_frame_time)&&(i.statsToReport.uint64_render_first_frame_time=r)}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=this._pathMainAudioMap.get(t);r&&0===r.statsToReport.uint64_play_first_frame_time&&(r.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:r,userId:i,videoDelay:o,audioDelay:n}=e,a=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(a)a.totalRTT+=t,a.totalLoss+=r,o&&(a.totalVideoDelay=(a.totalVideoDelay||0)+o,a.videoDelayCount=(a.videoDelayCount||0)+1),n&&(a.totalAudioDelay=(a.totalAudioDelay||0)+n,a.audioDelayCount=(a.audioDelayCount||0)+1),a.count++;else{let e,a,s,c;o&&(a=o,s=1),n&&(e=n,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(i,{totalRTT:t,totalLoss:r,count:1,totalAudioDelay:e,totalVideoDelay:a,audioDelayCount:c,videoDelayCount:s})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_device_info:t,msg_up_stream_info:r,msg_down_stream_info:i}=e.report;if(r.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:t,uint32_video_width:i,uint32_video_height:o}=r.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=t,this._localStreamStat.totalVideoWidth+=i,this._localStreamStat.totalVideoHeight+=o,this._localStreamStat.videoCount++}if(r.msg_audio_status){let{uint32_audio_level:e}=r.msg_audio_status;Math.floor(e/FO*100)>0&&(this._localStreamStat.totalAudioLevel+=e/FO,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:r,msg_video_status:i}=e,o=t.str_identifier,n=this._room.remotePublishedUserMap.get(o);if(i.forEach((e=>{let t=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(o,"_").concat(t?"main":"auxiliary"),a=this._remoteStreamStatMap.get(i);if(a&&(t&&null!=n&&n.remoteVideoTrack.isSubscribed||r&&null!=n&&n.remoteAuxiliaryTrack)){a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height);let r=t?n.remoteVideoTrack:n.remoteAuxiliaryTrack;r.stat.jitterBufferDelay&&(a.videoJitterBufferDelay=r.stat.jitterBufferDelay),r.stat.framesReceived&&(a.statsToReport.uint32_video_consume_render_rate=Math.floor(r.stat.framesDecoded/r.stat.framesReceived*Mb(10,6)))}})),!vC(r)){let e="".concat(o,"_main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&null!=n&&n.remoteAudioTrack.isSubscribed&&(t.totalAudioBitrate+=r.uint32_audio_codec_bitrate,t.audioCount++,n.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=n.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/FO*100)>0&&(t.totalAudioLevel+=r.uint32_audio_level/FO,t.audioLevelCount++))}})),t.uint32_audio_capture_cost&&(this._captureCostSum+=t.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:r}=e,i={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[r.name]||(r instanceof Qb?r.getExtraCode()||r.getCode():Xb.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=i,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=i,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Vw))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Hw))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Bw))>=0}hitTest(e){return e===this._room}prepareReport(){if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:r}=e,i=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){let{totalLoss:t,count:r,audioDelayCount:o,videoDelayCount:n,totalAudioDelay:a,totalVideoDelay:s}=i;e.statsToReport.uint32_avg_down_loss=Math.floor(t/r),o&&a&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(a/o),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),n&&s&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/n))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:o}=this._room;o&&(e.statsToReport.uint32_audio_play_time=o.getDuration(t,Lw.AUDIO),e.statsToReport.uint32_video_play_time=o.getDuration(t,Lw.VIDEO)),e.statsToReport.uint32_video_render_first&&(e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,NH));let{badCaseDetector:n}=this._room,{dataFreeze:a,count:s}=n.getDataFreezeDuration(t),{renderFreeze:c}=n.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=s,e.statsToReport.uint32_video_block_time=Math.min(a,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),n.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>NH&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+NH):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>NH&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+NH):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>NH&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+NH)}getReportData(){this._basicInfo.uint32_networkType=GD();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new OH({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:IC(this._signalInfo.relayIp),uint32_client_ip:IC(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Mb(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:IC(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return LC(e),e}report(){return Gb(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),this.initData()}catch(Zk){this._log.warn(Zk)}finally{this.isDestroyed&&(this._room=null)}}))}upload(e){return Gb(this,null,(function*(){if(0===e.msg_path_enter_room.uint64_start_time)return;let t=Number(this._room.sdkAppId),r=yield BC(e),i=r instanceof ArrayBuffer,o="".concat(VD(t,Sw.KEY_POINT),"&gzip=").concat(+i),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,r));let a=[this.uploadKVStat(lM),this.uploadKVStat(cM)];n||a.push(FC({url:o,body:r,priority:"low"})),yield Promise.all(a)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return Gb(this,null,(function*(){let t=e.getReportData();if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=xb(Pb({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let r=yield BC(t),i="".concat(VD(+this._room.sdkAppId,Sw.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),o=!1;navigator.sendBeacon&&(o=navigator.sendBeacon(i,r)),o||FC({url:i,body:r})}))}};Bb([wL({settings:{timeout:500,retries:3}})],CH.prototype,"upload",1);var NH=5e3,kH={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},OH=class{constructor(e){Hb(this,"str_identifier"),Hb(this,"str_tinyid"),Hb(this,"uint32_role"),this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},MH=CH,LH=class{constructor(){Hb(this,"_startTime"),Hb(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=fC())}stop(){0===this._endTime&&(this._endTime=fC())}getDuration(){return 0===this._endTime?fC()-this._startTime:this._endTime-this._startTime}get startTime(){return this._startTime}get endTime(){return this._endTime}},PH=class{constructor(e){Hb(this,"_room",null),Hb(this,"_durationMap"),Hb(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(Gk.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(Gk.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(Gk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;var o;let{userId:n}=i;if(!this.hitTest(t))return;r.hasAudio&&!i.hasAudio&&this.stopDurationItem("".concat(n,"_main"),Lw.AUDIO),r.hasVideo&&!i.hasVideo&&this.stopDurationItem("".concat(n,"_main"),Lw.VIDEO),r.hasAuxiliary&&!i.hasAuxiliary&&this.stopDurationItem("".concat(n,"_auxiliary"),Lw.VIDEO);let a=null==(o=this._room)?void 0:o.remotePublishedUserMap.get(n);a&&(!r.hasAudio&&i.hasAudio&&a.remoteAudioTrack.isSubscribed&&this.addDuractionItem(n,Lw.AUDIO,"main"),!r.hasVideo&&i.hasVideo&&a.remoteVideoTrack.isSubscribed&&this.addDuractionItem(n,Lw.VIDEO,"main"),!r.hasAuxiliary&&i.hasAuxiliary&&a.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(n,Lw.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>Hk.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>Hk.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{track:t}=e;if(!this.hitTest(t.room))return;let{userId:r,streamType:i,kind:o}=t;t.isSubscribed?this.addDuractionItem(r,o,i):this.stopDurationItem("".concat(r,"_").concat(i),o)}handleUnsubscribed(e){let{track:t}=e;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,r){let i="".concat(e,"_").concat(r),o=new LH,n=this._durationMap.get(i);n?this.isRecording(n[t])||n[t].push(o):this._durationMap.set(i,{userId:e,type:r,audio:t===Lw.AUDIO?[o]:[],video:t===Lw.AUDIO?[]:[o]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let r=this._durationMap.get(e)[t].find((e=>0===e.endTime));r&&r.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},xH=class{constructor(e){Hb(this,"_room"),Hb(this,"_renderFreezeMap",new Map),Hb(this,"_isVideoPlayingEventFiredMap",new Map),Hb(this,"_dataFreezeMap",new Map),Hb(this,"_monitorFreezeData",new Map),Hb(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}getRenderFreezeMap(){return this._renderFreezeMap}getDataFreezeMap(){return this._dataFreezeMap}installEvents(){this._eventMap.set(Gk.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(Gk.PLAY_TRACK_START,this.onPlayTrackStart).set(Gk.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:r,remotePublishedUser:i}=e;if(!this.hitTest(t))return;let{userId:o}=i,n="".concat(o,"_").concat(r);this.stopDataFreeze({key:n,userId:o,type:r})})).set(Gk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let{userId:o}=i;if(r.hasVideo&&!i.hasVideo){let e="main",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}if(r.hasAuxiliary&&!i.hasAuxiliary){let e="auxiliary",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}})).set(Gk.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,reason:i,type:o}=e;if(t.isRemote&&t.room&&this.hitTest(t.room)&&o===Lw.VIDEO){if("PLAYING"===r){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}i===Lw.MUTE?this.onVideoTrackMuted(t):i===Lw.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(Gk.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>Hk.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>Hk.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r),o=this._dataFreezeMap.get(i),n=new LH;o?o.durationItemList.push(n):this._dataFreezeMap.set(i,{userId:t,type:r,durationItemList:[n],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r);this.stopDataFreeze({key:i,userId:t,type:r})}onHearBeatReport(e){let{room:t,report:r}=e;this.hitTest(t)&&r.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:r,muteState:i}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&i.hasVideo&&!i.videoMuted&&t.remoteVideoTrack.isSubscribed&&this.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&i.hasAuxiliary&&t.remoteAuxiliaryTrack.isSubscribed&&this.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:r,type:i}=e,o=this._dataFreezeMap.get(t);if(!o||!o.isFreezing())return;let n=o.durationItemList[o.durationItemList.length-1];n.stop();let a=n.getDuration();a>ED?this._monitorFreezeData.set(t,{userId:r,type:i,duration:a}):o.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let r=t.getDuration();return e+Math.min(r,5e3)}),0)}handleRenderFreeze(e){return Gb(this,arguments,(function(e){var t=this;let{userId:r,fps:i,type:o}=e;return function*(){let e="".concat(r,"_").concat(o),n=t._renderFreezeMap.get(e);if(i<=2){let i=fC();n&&!n.isFreeze&&(n.freezeTimeline.push({startTime:i,endTime:0}),n.isFreeze=!0),n||t._renderFreezeMap.set(e,{userId:r,type:o,isFreeze:!0,freezeTimeline:[{startTime:i,endTime:0}],renderFreezeTotal:0})}else if(n&&n.isFreeze){n.isFreeze=!1;let e=n.freezeTimeline.pop();if(e){e.endTime=fC();let t=e.endTime-e.startTime;n.freezeTimeline.push(e),n.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room)||t.kind!==Lw.VIDEO||!t.isRemotePublished)return;let r="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(r)||this._isVideoPlayingEventFiredMap.set(r,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},r=this._dataFreezeMap.get(e);if(r){if(r.isFreezing()){let e=r.durationItemList[r.durationItemList.length-1];e.stop(),e.getDuration()<ED&&r.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(r.durationItemList),t.count=r.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),r=0,i=0;if(t)if(t.isFreeze){let e=fC()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;r=t.renderFreezeTotal+Math.min(e,5e3),i=t.freezeTimeline.length}else r=t.renderFreezeTotal;return{renderFreeze:r,count:i}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},UH=Fb(Wb(),1),VH=[1,0,0,0,1,1,0,1],FH=class extends kV{constructor(e,t){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"mirror",logger:t}),e instanceof KV)try{this.setTexBuffer(VH)}catch(cD){e.destroy(new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(cD.message||cD)}))}}draw2d(e,t,r,i,o){if(this.ctx2d){this.ctx2d.save(),this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0);let n=super.draw2d(e,t,r,i,o);return this.ctx2d.restore(),n}return!1}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}},BH=class{constructor(e,t){this.node=e,this.layout=t,Hb(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}},HH=class extends kV{constructor(e,t){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,logger:t}),Hb(this,"inputs",[])}addInput(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");let r=new BH(e,t);this.inputs[t.zIndex]=r}resize(e,t){let r=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(r.width,r.height),this.context instanceof KV&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return super.connect(e,...r),this.resize(0,0),e}removeInput(e){this.inputs[this.inputs.findIndex((t=>(null==t?void 0:t.node)===e))]=void 0}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),!this.inputs.reduce(((t,r)=>(!r||!r.node.requestFrame(e))&&t),!0)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(!this.inputs.reduce(((t,r)=>(!r||!r.node.requestFrame(e))&&t),!0)&&this.ctx2d){this.ctx2d.clearRect(0,0,this.width,this.height);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&this.draw2d(t.node.image,t.x,t.y,t.width,t.height)}return!0}return!1}getInfo(){let{totalFrames:e,x:t,y:r,width:i,height:o,name:n}=this,a=Date.now(),s=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:r,width:i,height:o,timestamp:a,fps:s,name:n},Pb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}close(){super.close(),this.inputs.forEach((e=>{var t,r;if(e&&(null==(t=e.node)||t.disconnect(),e.positionBuffer&&this.context instanceof KV))try{null==(r=this.context.ctx)||r.deleteBuffer(e.positionBuffer)}catch(iO){}}))}},jH=class extends HV{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,width:t.width,height:t.height,logger:e.log}),Hb(this,"_bgTexture"),Hb(this,"_waterMarkTexture"),Hb(this,"_lastMaskTexture"),Hb(this,"_lastMaskFbo"),Hb(this,"_textureValid",!1),Hb(this,"_selfieTextureValid",!1),Hb(this,"_selfieSegmentation"),Hb(this,"wasm"),Hb(this,"_prePrograme"),Hb(this,"_segmentationMask"),Hb(this,"_weixin",!1),t.selfieSegmentation&&(this._selfieSegmentation=t.selfieSegmentation,this._selfieSegmentation.onResults=this.onPredict.bind(this));try{this.init(t)}catch(eO){e.log.error(eO),e.destroy(new Qb({code:Xb.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(eO.message||eO)}))}}init(e){let t=e.Wasm,r=this.context.ctx;if(this.wasm=new t.AllIn1(r),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,e.waterMark){let{x:t,y:r,width:i,height:o}=e.waterMark;this.wasm.setWaterMark(t,r,i,o)}if(e.beautyParams){let{beauty:t,brightness:r,ruddy:i}=e.beautyParams;this.wasm.setBeauty(t,r,i,null==e?void 0:e.width,null==e?void 0:e.height)}if(this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),r.uniform1i(r.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(r.uniform1i(r.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(r.uniform1i(r.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),r.uniform1i(r.getUniformLocation(this.program,"lastMask"),4),this._weixin){let e=this.context.createShader(r.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),t=this.context.createShader(r.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(t,e),r.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),r.uniform1i(r.getUniformLocation(this._prePrograme,"mask"),1)}}onPredict(e){var t;let r=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture))),this.useProgram(),this._weixin?this.useTexture():null==this||this._selfieSegmentation.bindTexture(),r.activeTexture(r.TEXTURE1),null==(t=this._selfieSegmentation)||t.bindTexture2d(e),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this._bgTexture||null),r.activeTexture(r.TEXTURE3),r.bindTexture(r.TEXTURE_2D,this._waterMarkTexture||null),this.useBufferFrame(),r.drawArrays(r.TRIANGLE_STRIP,0,4),this._segmentationMask=e,this.totalFrames++}onFirstFrame(){this.waitingFirstFrame=!1;let e=this.context.ctx;this.useTexture(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}render(e){var t,r,i,o;let n=this.context.ctx,{image:a}=this;this.tryVideoFrameCallback();let{videoWidth:s,videoHeight:c}=a;if(0===s||0===c||!this.available)return!1;a.width=s,a.height=c;let l=!1;if(this.totalFrames)this._weixin?this.useTexture():null==(t=this._selfieSegmentation)||t.bindTexture(),l=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),l=this._textureValid,this._textureValid=!0}return this.width===s&&this.height===c&&l?n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,a):(this.resize(s,c),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,a)),this._weixin&&(n.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask&&(n.activeTexture(n.TEXTURE1),null==(r=this._selfieSegmentation)||r.bindTexture2d(this._segmentationMask),n.bindFramebuffer(n.FRAMEBUFFER,this._lastMaskFbo||null)),n.drawArrays(n.TRIANGLE_STRIP,0,4),null==(i=this._selfieSegmentation)||i.bindTexture(),this._segmentationMask?n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,0,0,s,c):n.copyTexImage2D(n.TEXTURE_2D,0,n.RGBA,0,0,s,c,0)),this.wasm.vbMode&&(null==(o=this._selfieSegmentation)||o.send(s,c)),this.totalFrames||(n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._bgTexture||null),n.activeTexture(n.TEXTURE3),n.bindTexture(n.TEXTURE_2D,this._waterMarkTexture||null),n.drawArrays(n.TRIANGLE_STRIP,0,4)),!1}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),null==(e=this.wasm)||e.close()}},GH=class extends kV{constructor(e){super(e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}),Hb(this,"yTextureRef"),Hb(this,"uTextureRef"),Hb(this,"vTextureRef"),Hb(this,"Y"),Hb(this,"U"),Hb(this,"V"),this.useProgram();let t=this.context.ctx;t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),this.setTexBuffer([0,1,1,1,0,0,1,0]),this.yTextureRef=this._initTexture("ySampler",0),this.uTextureRef=this._initTexture("uSampler",1),this.vTextureRef=this._initTexture("vSampler",2),this._canvas=e._canvas}_initTexture(e,t){let r=this.context.ctx,i=r.createTexture();return r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),r.uniform1i(r.getUniformLocation(this.program,e),t),i}render(e){let t=this.context.ctx,r=this.width,i=this.height;return this.useProgram(),t.viewport(0,0,r,i),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r,i,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}resize(e,t){super.resize(e,t);let r=this.context.ctx;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.yTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e,t,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this.uTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this.vTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null)}},WH=[e=>{e.codec="avc1.42e01f"},e=>{delete e.hardwareAcceleration}],KH=(e,t)=>{switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")};var zH=0,qH=class{constructor(e){Hb(this,"id",zH++),Hb(this,"trackDoneOB"),Hb(this,"startOB"),Hb(this,"stopOB"),Hb(this,"decoder"),Hb(this,"videoContext"),Hb(this,"gop",0),Hb(this,"gop_helper",0),Hb(this,"waitFirstKeyFrame",!0),Hb(this,"startTimestamp",0),Hb(this,"startTime",0),Hb(this,"startPerformanceTime",0),Hb(this,"inputFrameCount",0),Hb(this,"decodedFrameCount",0),Hb(this,"decodeFrameCount",0),Hb(this,"downgradeLevel",0),Hb(this,"lastDowngradeTime",0),Hb(this,"lastFrameDiff",0),Hb(this,"lastDecodeFrameTimestamp",0),Hb(this,"config"),Hb(this,"gop_before_configure",[]),Hb(this,"videoElement"),Hb(this,"type","wasm"),Hb(this,"goodType"),Hb(this,"renderer","2d"),Hb(this,"wasmOption"),Hb(this,"createDecoder"),Hb(this,"_decodeSink"),Hb(this,"isReported",!1),Hb(this,"track"),Hb(this,"stateChangeOB"),Hb(this,"failedReason");let{track:t,createDecoder:r}=e;if(this.stateChangeOB=Kx(),this.track=t,this.createDecoder=r,this.wasmOption={yuvMode:"webgl"===e.renderer,wasmPath:e.wasmPath,workerMode:e.workerMode,canvas:e.canvas},this.config=e.config,this.videoElement=e.videoElement,this.renderer=e.renderer,this.trackDoneOB=tU(t.availableState,pL.OFF),this.stopOB=Kx(),"auto"===e.type){switch(e.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=e.type;this.changeRenderer(this.renderer),Sx(this.stateChangeOB,KU(((e,r)=>(e!==r&&t.onDecodeDowngradeStateChanged({type:this.type,renderer:this.renderer,reason:this.failedReason,prevState:e,state:r}),r)),"INITIALIZED"),AU(this.stopOB),IV()),this.start()}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");let t=Sx(this.pipe(this.track),AU(this.stopOB),Ox());Sx(t,IV((()=>{this.track.stat.framesDecoded++}),(t=>{if(this.track.log.error("".concat(this.id," play failed: ").concat(t," retryCount: ").concat(e)),lM.addFailedEvent({key:KH(this.type,this.renderer),error:t}),e>4)this.failedReason=t,this.stateChangeOB.next("FAILED");else{if(this.goodType)return void this.start(e);switch(this.type){case"webCodecs":this.type="wasm",this.changeRenderer("webgl");break;case"wasm":if("webgl"===this.renderer)this.changeRenderer("videoFrame")}this.start(e+1)}}),(()=>{this.track.log.warn("".concat(this.id," decoderOB completed")),lM.addSuccessEvent({key:KH(this.type,this.renderer)}),lM.addSuccessEvent({key:514704})}))),Sx(t,IU(1),IV((()=>{this.track.player.handlePlaying("canvas"),this.goodType=this.type,this.stateChangeOB.next("STARTED")})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.start()}close(e){this.stopOB.next(e)}changeRenderer(e){this.renderer=e,"videoFrame"===this.renderer&&!EM()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}decode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;if(this.failedReason)return;this.inputFrameCount++;let o=new Uint8Array(e.data);if(!function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]}(o)||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;let n=!1;switch(31&o[4]){case 5:case 7:n=!0}if("configured"!==(null==(r=this.decoder)?void 0:r.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),n&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!t&&(this.gop_before_configure.forEach((e=>this.decode(e,!0))),this.gop_before_configure=[]);let{timestamp:a}=e;if(n?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!n)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=a,this.startTime=Date.now(),this.startPerformanceTime=fC()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(a," ").concat(null==(i=e.getMetadata)?void 0:i.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=a,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}checkDowngradeByFrameDiff(){let e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}checkDowngradeByTimestampDiff(e){let t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}pipe(e){return t=>Gb(this,null,(function*(){this._decodeSink=t;let r,i=e.mediaTrack;t.defer((()=>{var t;i&&(e.player.setCanvas(),e.setInputMediaStreamTrack(i)),null==r||r.close(),null==(t=this.videoContext)||t.destroy(),delete this._decodeSink}));let{renderer:o,type:n}=this;e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer));try{switch(n){case"wasm":r=this.createDecoder(n,this.wasmOption);break;case"webCodecs":for(let e=0;e<=WH.length;e++){let{supported:r}=yield VideoDecoder.isConfigSupported(this.config);if(r)break;if(e===WH.length)return void t.error(3);WH[e](this.config)}r=this.createDecoder(n);break;default:throw new Error("not supported yet")}let i=0;if(r.on("videoFrame",(r=>{this.decodedFrameCount++,i++,(i<=10||i%500==0)&&e.log.debug("frame ".concat(i," ").concat(this.decodedFrameCount,"/").concat(this.decodeFrameCount," decoded ").concat(r.timestamp)),Date.now()-this.lastDowngradeTime>5e3&&("webCodecs"===this.type?this.checkDowngradeByFrameDiff():"wasm"===this.type&&this.checkDowngradeByTimestampDiff(r.timestamp)),t.next(r)})),r.on("error",(r=>{e.log.error(r),t.error("webCodecs"===n?4:8)})),yield r.initialize(this.videoElement),!this._decodeSink)return;if(r.configure(this.config),"wasm"===n&&"webgl"===o){this.videoContext=new KV({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on(KV.UNAVAILABLE,(r=>{e.log.error(r),t.error(7)}));let i=new GH(this.videoContext);r.on("videoCodecInfo",(e=>i.resize(e.width,e.height))),r.on("videoFrame",(e=>{({y:i.Y,u:i.U,v:i.V}=e),1===this.downgradeLevel?this.decodedFrameCount%2==0&&i.render(this.decodedFrameCount):i.render(this.decodedFrameCount)})),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}else if("videoFrame"===o){e.player.setCanvas();let t=new MediaStreamTrackGenerator({kind:"video"}),i=t.writable.getWriter();e.setInputMediaStreamTrack(t),r.on("videoFrame",(e=>i.write(e)))}else{this.videoContext=new zV({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1});let i=this.videoContext.createVideoImageSource();r.on("videoFrame",(r=>{try{i.image=r,i.update()}catch(o){delete this.goodType,e.log.error(o),t.error(11)}}));let o=new PV(this.videoContext,{name:"remotePlayer",logger:e.log});i.connect(o),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}this.decoder=r}catch(tO){e.log.error(tO),t.error("webCodecs"===n?2:6)}}))}},JH=class extends UH.EventEmitter{constructor(e){super(),this.room=e,Hb(this,"videoContext"),Hb(this,"_glVideoContext"),Hb(this,"_2dVideoContext"),Hb(this,"destination"),Hb(this,"smallVideoContext"),Hb(this,"smallDestination"),Hb(this,"smallTrackSource"),Hb(this,"smallImageSource"),Hb(this,"_isMirror",!1),Hb(this,"cameraTrack"),Hb(this,"cameraNode"),Hb(this,"mirrorNode"),Hb(this,"mixNode"),Hb(this,"screenTrack"),Hb(this,"screenNode"),Hb(this,"selfModel",!1),Hb(this,"blurRadius",3),Hb(this,"arTrack"),Hb(this,"Wasm"),Hb(this,"waterMarkNode"),Hb(this,"_waterMarkOption"),Hb(this,"watermarkImageList",[]),Hb(this,"_beautyParams"),Hb(this,"isUsingArTrack",!1),Hb(this,"_isMixScreen",!1),Hb(this,"_virtualBackground"),Hb(this,"_virtualBackgroundAbortCallback"),Hb(this,"virtualBackgroundInstance"),Hb(this,"_bgAssetPath"),Hb(this,"log",Kk.createLogger({id:"vm"})),Hb(this,"_checkId",0),Hb(this,"_use2d",!1),Hb(this,"_autoSwitchRenderMode",!0),Hb(this,"_selfieSegmentation"),Hb(this,"encodePipeline",[]),Hb(this,"decodePipeline",[]),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.smallVideoContext=new zV({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new zV({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new KV({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}initializeGlVideoContext(){try{this._glVideoContext.create(),this._glVideoContext.on(KV.UNAVAILABLE,(e=>{var t;this.emit("error",e),this.log.warn("video context unavailable",e),null==(t=this._virtualBackgroundAbortCallback)||t.call(this,e),this.update().catch((e=>{this.log.error(e)}))}))}catch(sw){this.emit("error",sw)}}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=vL.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),vL.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(pk||this._isMixScreen||this._isMirror||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?lM.addFailedEvent({key:t,error:e}):lM.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new KV({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}initVirtualBackground(e){return this._selfieSegmentation=e,this._selfieSegmentation.changeModel()}setSmallVideo(e,t){if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new VV(this.smallVideoContext,e,this.log),this.smallVideoContext.on(KV.UNAVAILABLE,(e=>{this.log.warn("small video context lost",e)}))}if(this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t)this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.resize(t.width,t.height),this.smallImageSource.connect(this.smallDestination));else if(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource)this.smallTrackSource.replaceTrack(this.initialTrack);else{this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource");let{width:e,height:t}=this.cameraTrack.settings;this.smallTrackSource.resize(e,t),this.smallTrackSource.connect(this.smallDestination)}}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}_setMainOutput(e){var t;try{let r=this.cameraTrack,{small:i,player:o}=r;this.setSmallVideo(i,e),pk&&o.setCanvas(e);let n=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),n=this.arTrack),this._selfieSegmentation&&e&&!this._use2d&&(this._selfieSegmentation._glName||this._selfieSegmentation.setCanvas(e)),this.log.info("set main output ".concat(n?n.label:"no output track")),r.setOutputMediaStreamTrack(n)}catch(eO){this.log.error("set main output failed",eO)}}update(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Gb(this,null,(function*(){var t,r,i;if(!this.cameraTrack||!this.initialTrack)return;if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:o,profile:n}=this.cameraTrack;if(this._use2d||!this._virtualBackground&&!this._beautyParams?(this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===Ek?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof HV?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof HV?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(o.width,o.height)):e&&this.cameraNode&&this.destination?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():this.destination=new UV(this.videoContext,{name:"mainDestination",logger:this.log}),this.cameraNode=new jH(this.videoContext,{input:this.initialTrack,width:o.width,height:o.height,mirror:this._isMirror,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute()),this.videoContext.frameRate=n.frameRate,this._use2d){let e=this.cameraNode;e.disconnect(),this._isMirror&&(this.mirrorNode||(this.mirrorNode=new FH(this.videoContext,this.log)),e=e.connect(this.mirrorNode),e.disconnect(),this.log.info("start mirror")),this.mixNode&&this.mixNode.close(),delete this.mixNode,(this._isMixScreen||this._hasWaterMark)&&(this.mixNode=new HH(this.videoContext,this.log),e.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption?(this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y):null==(t=this.waterMarkNode)||t.resize(o.width,o.height),null==(r=this.waterMarkNode)||r.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&!this.screenNode&&(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource")),null==(i=this.screenNode)||i.connect(this.mixNode,{zIndex:0}),e=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))),e.connect(this.destination)}return this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext._canvas)}))}changeInput(e){var t,r,i,o;if(e instanceof cx)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof nx)return this.log.info("change video input",null==(r=e.mediaTrack)?void 0:r.label),this.setCameraTrack(e);if(e instanceof qV){this.log.info("change remote input",null==(i=e.mediaTrack)?void 0:i.label);let t=e.mediaTrack;return e.setOutputMediaStreamTrack(t)}this.log.warn("change unknown input",null==(o=e.mediaTrack)?void 0:o.label)}removeInput(e){var t;e instanceof cx?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof nx?(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof qV&&e.source&&e.source.context.destroy()}setCameraTrack(e){return Gb(this,null,(function*(){this.cameraTrack=e,this.update(!0)}))}setScreenTrack(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}getWatermarkImage(e,t){return Gb(this,null,(function*(){let r=document.createElement("canvas");t&&e&&(r.height=t,r.width=e);let i=r.getContext("2d");if(!i)throw new Qb({code:Xb.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((e=>{let{image:t,x:r,y:o,width:n,height:a}=e;i.drawImage(t,r,o,n,a)})),OC(r.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setBeautyParams(e){return Gb(this,null,(function*(){this._beautyParams=e,this.update()}))}stopBeauty(){return Gb(this,null,(function*(){this._beautyParams=void 0,this.update()}))}setWatermark(e){return Gb(this,null,(function*(){var t,r;let i;try{i=yield OC((null==e?void 0:e.imageElement)||e.imageUrl)}catch(u){throw new Qb({code:Xb.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:o=0,y:n=0,width:a=i.width,height:s=i.height,type:c="watermark",zIndex:l=2}=e;this.watermarkImageList.some((e=>e.type===c))?(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==c)),this.pushWaterMarkImageList({x:o,y:n,width:a,height:s,image:i,zIndex:l,type:c,imageUrl:e.imageUrl}),i=yield this.getWatermarkImage(null==(t=this.cameraTrack)?void 0:t.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height),this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(i.width,i.height),this.waterMarkNode.image=i):this.update()):(this.pushWaterMarkImageList({x:o,y:n,width:a,height:s,image:i,zIndex:l,type:c,imageUrl:e.imageUrl}),yield this.freshWatermark()),this.log.info("set watermark",JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t)))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return Gb(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t))),yield this.freshWatermark()}))}freshWatermark(){return Gb(this,null,(function*(){var e,t,r;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let i=yield this.getWatermarkImage(null==(t=this.cameraTrack)?void 0:t.settings.width,null==(r=this.cameraTrack)?void 0:r.settings.height);this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update()}))}setVirtualBackground(e){return Gb(this,null,(function*(){if(e){if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield OC(e.imageUrl):(this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type)}else delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;if(this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),yield this.update(),this._virtualBackground&&!this._glVideoContext.available)throw new Qb({code:Xb.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)})}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isMirror||(null==(t=this.mirrorNode)||t.close(),delete this.mirrorNode),this.update())}get mirror(){return this._isMirror}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return Gb(this,null,(function*(){var e;null!=(e=this.cameraTrack)&&e.mediaTrack&&(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}createDecodeContext(e){return new qH(e)}clear(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.mirrorNode,delete this.screenNode,delete this.waterMarkNode}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}};Bb([function(e){return WP(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return Gb(this,null,(function*(){try{return yield t.apply(this,i)}catch(eO){e.call(this,eO)}}))}))}((function(e){this.log.error("update failed",e)}))],JH.prototype,"update",1);var YH=0,XH=class extends pL{constructor(e){super("room"),Hb(this,"seq",++YH),Hb(this,"sdkAppId"),Hb(this,"userId"),Hb(this,"userSig"),Hb(this,"privateMapKey"),Hb(this,"latencyLevel"),Hb(this,"tinyId"),Hb(this,"scene"),Hb(this,"roomId"),Hb(this,"useStringRoomId"),Hb(this,"role","anchor"),Hb(this,"joinParams",null),Hb(this,"localTracks",new Set),Hb(this,"enableAutoPlayDialog",!0),Hb(this,"autoReceiveAudio",!0),Hb(this,"autoReceiveVideo",!0),Hb(this,"proxy_ws"),Hb(this,"proxy_wt"),Hb(this,"proxy_unified"),Hb(this,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),Hb(this,"keyPointManager"),Hb(this,"audioManager"),Hb(this,"videoManager"),Hb(this,"callDurationCalculator"),Hb(this,"badCaseDetector"),Hb(this,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),Hb(this,"videoDecodeFallbackType"),Hb(this,"_isUsingCachedSchedule",!1),Hb(this,"_log",Kk.createLogger({id:"r".concat(this.seq)})),Hb(this,"_joinedTimestamp",0),Hb(this,"_sdkType"),Hb(this,"heartbeatReport"),Hb(this,"quality"),Hb(this,"enableSEI"),Hb(this,"isDestroyed",!1),this.useStringRoomId=!!e.useStringRoomId,nC(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),nC(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),nC(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new MH({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new PH({room:this}),this.badCaseDetector=new xH({room:this}),this.audioManager=new hx(this),this.videoManager=new JH(this)}get scriptTransformWorker(){}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}get localMainVideoTrack(){for(let e of this.localTracks)if(4&e.mediaType)return e;return null}get localAuxVideoTrack(){for(let e of this.localTracks)if(2&e.mediaType)return e;return null}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return Gb(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return Gb(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return Gb(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(iC(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if($D(e)){let{websocketProxy:t,webtransportProxy:r,loggerProxy:i,scheduleProxy:o,unifiedProxy:n}=e;this.proxy_ws=t,this.proxy_wt=r,this.proxy_unified=n,n?(RB([n,n]),pw("https://".concat(n))):(i&&pw(i),o&&RB(o))}Hk.once(Gk.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:SB.main,sched_back_domain:SB.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return Gb(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return Gb(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let r of this.quality.downlinkInfo)t.downlinksRTT[r.userId]=r.rtt;return t}))}getRemoteVideoStats(){return Gb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let r={};return e.remotePublishedUserMap.forEach((e=>{let i="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=i.stat})),r}()}))}checkDestroy(){if(this.isDestroyed)throw new Qb({code:Xb.INVALID_OPERATION,message:ZO({key:YO.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(XO.INVALID_DESTROY),new Qb({code:Xb.INVALID_OPERATION,message:ZO({key:YO.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,Hk.emit(Gk.ROOM_DESTROY,{room:this})}schedule(e,t){return Gb(this,null,(function*(){var r,i,o;let n=fC();try{let{isCached:a,result:s,detailCost:c}=yield AB({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:nw,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});this._isUsingCachedSchedule=a,this._log.info("schedule cache:".concat(+a," ").concat(DC(s,{keysToExclude:["username","credential"]}))),a&&Hk.once(Gk.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=Pb(Pb({},this.scheduleResult),s),oC(null==(r=s.config)?void 0:r.retryCount)&&aD(s.config.retryCount),iC(null==(i=s.config)?void 0:i.loggerDomain)&&pw(s.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=s.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,Hk.emit(Gk.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:c}),lM.addSuccessEvent({key:521700,cost:fC()-n,split:50})}catch(a){throw lM.addFailedEvent({key:521700,error:a}),a}}))}sendAbilityStatus(e){}enableInsertableStreams(){return Promise.resolve()}};var $H={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},QH="__INLINE__WORKER__",ZH="__INLINE__WASM__",{debug:ej}=console;$H.debug||(console.debug=()=>{});var tj,rj=!QH.startsWith("__"),ij=!ZH.startsWith("__");function oj(){let e=UC("".concat($H.assetsPath?"".concat($H.assetsPath,"/"):"","worker.js"));return rj?URL.createObjectURL(new Blob([atob(QH)],{type:"application/javascript"})):e.startsWith("http")?fetch(e).then((e=>e.blob().then((e=>URL.createObjectURL(e))))):e}function nj(){return Gb(this,null,(function*(){let e=$H.assetsPath?"".concat($H.assetsPath,"/"):"";return tj||(tj=ij?(new TextEncoder).encode(atob(ZH)).buffer:yield fetch(UC("".concat(e,"av_processing.wasm"))).then((e=>e.arrayBuffer())),tj)}))}var aj=new class{constructor(){Hb(this,"playPort"),Hb(this,"playPortSent",!1),Hb(this,"worklet"),Hb(this,"workletPromise")}init(){return this.workletPromise||(this.workletPromise=this._init()),this.workletPromise}_init(){return Gb(this,null,(function*(){let e=nP(),t=oj();try{yield e.audioWorklet.addModule("string"==typeof t?t:yield t),Kk.info("global audio player worklet addModule success",t)}catch(cD){throw Kk.error("global audio player worklet addModule failed:",cD),cD}return this.worklet=new AudioWorkletNode(e,"global-audio-player",{processorOptions:{wasm:yield nj(),flag:$H},numberOfInputs:2}),Kk.info("global audio player worklet created",e.state),this.worklet.connect(e.destination),this.playPort=this.worklet.port,this.playPort}))}playAudio(e){return Gb(this,null,(function*(){this.playPortSent||(this.playPortSent=!0,e(yield this.init()))}))}},sj="undefined"!=typeof self&&(!("top"in self)||self===top)&&"showOpenFilePicker"in self&&"showOpenFilePicker";sj?Promise.resolve().then((function(){return dj})):Promise.resolve().then((function(){return gj})),sj?Promise.resolve().then((function(){return fj})):Promise.resolve().then((function(){return Ej}));var cj=sj?Promise.resolve().then((function(){return _j})):Promise.resolve().then((function(){return vj}));function lj(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(this,null,(function*(){return(yield cj).default(...t)}))}var uj=e=>Gb(void 0,null,(function*(){let t=yield e.getFile();return t.handle=e,t})),dj={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){Array.isArray(e)||(e=[e]);let t=[];e.forEach(((e,r)=>{t[r]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map((i=>{t[r].accept[i]=e.extensions||[]})):t[r].accept["*/*"]=e.extensions||[]}));let r=yield window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=yield Promise.all(r.map(uj));return e[0].multiple?i:i[0]}()}))}};function hj(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return hj=function(e){this.s=e,this.n=e.next},hj.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new hj(e)}var pj,mj=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return Gb(void 0,[e,t,...i],(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.name,i=arguments.length>3?arguments[3]:void 0;return function*(){let o=[],n=[];var a,s=!1,c=!1;try{for(var l,u=function(e){var t,r,i,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,i=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(i&&null!=(t=e[i]))return new hj(t.call(e));r="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(l=yield u.next()).done;s=!1){let a=l.value,s="".concat(r,"/").concat(a.name);"file"===a.kind?n.push(a.getFile().then((t=>(t.directoryHandle=e,t.handle=a,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>s}))))):"directory"!==a.kind||!t||i&&i(a)||o.push(mj(a,t,s,i))}}catch(d){c=!0,a=d}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(c)throw a}}return[...(yield Promise.all(o)).flat(),...yield Promise.all(n)]}()}))},fj={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){e.recursive=e.recursive||!1,e.mode=e.mode||"read";let t=yield window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return mj(t,e.recursive,void 0,e.skipDirectory)}()}))}},_j={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Gb(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[{}],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return function*(){Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";let n=[],a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach(((e,t)=>{n[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&a&&e.mimeTypes.push(a),e.mimeTypes.map((r=>{n[t].accept[r]=e.extensions||[]}))):a?n[t].accept[a]=e.extensions||[]:n[t].accept["*/*"]=e.extensions||[]})),r)try{yield r.getFile()}catch(l){if(r=null,i)throw l}let s=r||(yield window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:n,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1}));!r&&o&&o(s);let c=yield s.createWritable();return"stream"in e?(yield e.stream().pipeTo(c),s):"body"in e?(yield e.body.pipeTo(c),s):(yield c.write(yield e),yield c.close(),s)}()}))}},gj={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),new Promise(((t,r)=>{let i=document.createElement("input");i.type="file";let o=[...e.map((e=>e.mimeTypes||[])),...e.map((e=>e.extensions||[]))].join();i.multiple=e[0].multiple||!1,i.accept=o||"",i.style.display="none",document.body.append(i);let n=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(n,(()=>a(r)),i),s=()=>{window.removeEventListener("focus",s),i.remove()};i.addEventListener("click",(()=>{window.addEventListener("focus",s)})),i.addEventListener("change",(()=>{window.removeEventListener("focus",s),i.remove(),n(i.multiple?Array.from(i.files):i.files[0])})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},Ej={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise(((t,r)=>{let i=document.createElement("input");i.type="file",i.webkitdirectory=!0;let o=e=>{"function"==typeof n&&n(),t(e)},n=e[0].legacySetup&&e[0].legacySetup(o,(()=>n(r)),i);i.addEventListener("change",(()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter((t=>t.webkitRelativePath.split("/").every((t=>!e[0].skipDirectory({name:t,kind:"directory"})))))):t=t.filter((e=>2===e.webkitRelativePath.split("/").length)),o(t)})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},vj={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Gb(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){Array.isArray(t)&&(t=t[0]);let r=document.createElement("a"),i=e;"body"in e&&(i=yield function(e,t){return Gb(this,null,(function*(){let r=e.getReader(),i=new ReadableStream({start:e=>function t(){return Gb(this,null,(function*(){return r.read().then((r=>{let{done:i,value:o}=r;if(!i)return e.enqueue(o),t();e.close()}))}))}()}),o=new Response(i),n=yield o.blob();return r.releaseLock(),new Blob([n],{type:t})}))}(e.body,e.headers.get("content-type"))),r.download=t.fileName||"Untitled",r.href=URL.createObjectURL(yield i);let o=()=>{"function"==typeof n&&n()},n=t.legacySetup&&t.legacySetup(o,(()=>n()),r);return r.addEventListener("click",(()=>{setTimeout((()=>URL.revokeObjectURL(r.href)),3e4),o()})),r.click(),null}()}))}},yj=class{constructor(e){this.name=e,Hb(this,"ready"),Hb(this,"worker"),Hb(this,"ports"),Hb(this,"ids",1),Hb(this,"transactions",new Map),Hb(this,"log"),Hb(this,"addTransaction",(e=>(this.transactions.set(++this.ids,e),this.ids)))}postMessage(e,t){var r;null==(r=this.worker)||r.postMessage(e,t)}create(e){return Gb(this,null,(function*(){if(this.ready)return this.ready;e||(e=this.name),console.time("createWorker_".concat(e));let t=oj(),r=new Worker("string"==typeof t?t:yield t,{name:e});return this.worker=r,this.ready=new Promise(((t,i)=>Gb(this,null,(function*(){r.onmessage=r=>{let{data:{id:o,type:n,payload:a}}=r;var s;if(o)null==(s=this.transactions.get(o))||s(a),this.transactions.delete(o);else switch(n){case"error":console.timeEnd("createWorker_".concat(e)),console.warn("worker error:",a),i(a);break;case"ready":console.timeEnd("createWorker_".concat(e)),t(this);break;case"updateAFSM":if(a.value){let e="string"==typeof a.old?a.old:"".concat(a.old.action,"ing"),t="string"==typeof a.value?a.value:"".concat(a.value.action,"ing");console.log(wC(),a.group,a.name,e,"👉",t)}break;case"log":console.log(a);break;case"glog":window.dispatchEvent(new CustomEvent(n,{detail:a}))}},r.postMessage({wasm:yield nj(),flag:$H},this.ports)}))))}))}destroy(){var e;console.log("destroy worker",this.name),delete this.ready,null==(e=this.worker)||e.terminate()}},Tj=class{constructor(e,t,r){this.worker=e,Hb(this,"channel",new MessageChannel),Hb(this,"ready"),this.ready=new Promise(((e,r)=>{this.worker.postMessage({id:this.worker.addTransaction(e),payload:t},[this.channel.port2])})).then((e=>(0===e.err&&(this.worker.sessionCount++,this.channel.port1.onmessage=r),e)))}postMessage(){this.channel.port1.postMessage(...arguments)}destroy(){0==--this.worker.sessionCount&&this.worker.destroy()}},Ij=new class e extends yj{constructor(){super("main"),Hb(this,"switchValue",new Map),Hb(this,"extendChannel"),Hb(this,"sessionCount",0)}setSwitchValue(e,t){var r;this.switchValue.set(e,t),null==(r=this.extendChannel)||r.port1.postMessage([e,t])}create(){return Gb(this,null,(function*(){return this.ready?this.ready:(this.extendChannel=new MessageChannel,this.ports=[this.extendChannel.port2],yield jb(e.prototype,this,"create").call(this),this.switchValue.forEach(((e,t)=>{this.extendChannel.port1.postMessage([t,e])})),this)}))}};function Aj(e){return Gb(this,null,(function*(){yield Ij.create(),Hk.emit(Gk.JOIN_SEND_CMD,{room:this});let t=new Tj(Ij,e,(e=>{let r=e.data;if("string"==typeof r)this.onWorkerEvent(r);else if(null==r)this.onWorkerEvent("client-banned",0),t.destroy();else{let{cmd:e,payload:t}=r;this.onWorkerEvent(e,t)}})),{err:r,data:i}=yield t.ready;if("number"==typeof r){if(Hk.emit(Gk.JOIN_RECEIVED_CMD_RES,{room:this,code:r}),0===r)return Object.assign(this,i,{session:t});throw new Qb({code:Xb.JOIN_ROOM_FAILED,extraCode:Number(r),message:ZO({key:YO.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:r,errorMsg:""}})})}throw r}))}function Sj(e){return Gb(this,null,(function*(){Ij.setSwitchValue("useAINS",e)}))}function Rj(e){return Gb(this,null,(function*(){Ij.setSwitchValue("useV2",e)}))}function bj(e){let t=new MediaStreamTrackGenerator({kind:"audio"});e.setInputMediaStreamTrack(t),this.postMessage({cmd:"pullAudio",payload:{tinyId:e.tinyId,writable:t.writable}},[t.writable])}function wj(e){return Gb(this,null,(function*(){var t;this._log.info("pull video",e);let r=Date.now(),i=0,o=new MessageChannel;this.postMessage({cmd:"pullVideo",payload:{mediaType:e.mediaType,tinyId:e.tinyId}},[o.port1]),(t=e.stat).framesReceived||(t.framesReceived=0),Sx(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Object.defineProperties(Kx(),{postMessage:{value:e.postMessage.bind(e)},port:{get:()=>e,set(t){e.onmessage=mx,e.onmessageerror=mx,e=t,i()}}});function i(){e.onmessage=i=>{i.data?i.ports.length||t?r.next(i):r.next(i.data):(r.complete(),e.close())},e.onmessageerror=t=>{r.error(t),e.close()}}return i(),r}(o.port2),AU(tU(e,pL.INIT)),IV((t=>{let{data:o,packetsReceived:n}=t;e.stat.packetsReceived=n,e.stat.framesReceived++,i++;let a,s=31&o[4];if(i<=10){let e=Array.from(o.slice(0,10)).map((e=>e.toString(16).padStart(2,"0"))).join(" ");this._log.info("Frame ".concat(i," - Size: ").concat(o.length," bytes, Type: ").concat(s,", Timestamp: ").concat(Date.now()-r,"ms First 10 bytes: ").concat(e))}switch(s){case 5:case 7:a="key";break;default:a="delta"}e.isAvailable?e.decodeFrame({data:o.buffer,type:a,timestamp:1e3*(Date.now()-r)}):console.warn("track is not available")}),(()=>{}),(()=>{o.port2.postMessage(null),o.port2.close()})))}))}Object.defineProperties(window,{useAINS:{set:Sj},useWt:{set:function(e){return Gb(this,null,(function*(){Ij.setSwitchValue("useWt",e)}))}},enableDebug:{set(e){console.debug=e?ej:()=>{},Ij.setSwitchValue("enableDebug",e)}},useV2:{set:Rj},dump:{value(){if(pj||(console.warn("dump audio will be activated at next time join room"),pj=[]),!pj.length)return void console.warn("no audio data to dump,try it later");let e=[];return pj.forEach((t=>{e.push(new Uint16Array([t.length])),e.push(t)})),lj(new Blob(e),{fileName:"audio dump hex",extensions:[".hex"]})}},dumpAudio:{value(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"audio",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,r=[],i=new Promise((i=>{let o=new MessageChannel;Ij.extendChannel.port1.postMessage(["dump",e],[o.port1]),o.port2.onmessage=n=>{let{data:a}=n;console.log(a),r.push(a),r.length>t&&(o.port2.onmessage=null,Ij.extendChannel.port1.postMessage(["dump",e]),o.port2.close(),i(new Blob(r)))}}));return lj(i,{fileName:e,extensions:[".pcm"]})}},hardDec:{set(e){switch(e){case!0:$H.useHardDecoder="prefer-hardware";break;case!1:$H.useHardDecoder="prefer-software";break;default:$H.useHardDecoder="no-preference"}}}});var Dj=[];function Cj(e){var t;let r=Kx();if("joined"!==this.state)throw new Error("Room is not joined");if("publish"===e.state)return;for(let l=0;l<=Dj.length;l++)if(!Dj[l]){Dj[l]=this,this.index=l;break}let i=e.profile;this._log.info("start push audio",this.index,i);let o=new MessageChannel,n=e.enableEncodeFrame?new MessageChannel:null;null==(t=this.session)||t.postMessage({cmd:"pushAudio",payload:Pb({index:this.index},i)},n?[o.port2,n.port2]:[o.port2]),o.port1.onmessage=t=>{null==t.data||("number"==typeof t.data?r.next(t.data):n&&n.port1.postMessage(xb(Pb({},t.data),{data:new Uint8Array(e.encodeFrame({data:t.data.data.buffer,timestamp:t.data.timestamp}).data)})))};let a,s=new MediaStream,c=e=>{let t=s.getAudioTracks()[0];t&&(a.disconnect(),s.removeTrack(t)),s.addTrack(e),this._log.info("push audio track:",e.readyState,e.getSettings().deviceId),a=nP().createMediaStreamSource(s),a.connect(aj.worklet,0,this.index)};Sx(tU(e,"output-media-track-changed"),AU(tU(e,"capture")),IV(c,console.error,(()=>{this._log.info("stop push audio",i),e.volume=0,a.disconnect(),Dj[this.index]=null,n&&n.port1.postMessage(null),o.port1.postMessage(null)}))),Sx(r,AV((t=>e.volume=t)),rV(MV(1e3)),IV((()=>{e.volume=0}))),c(e.outMediaTrack)}var Nj=class{constructor(e,t,r,i){this.localTrack=e,this.type=t,this.config=r,this.port=i,Hb(this,"track"),Hb(this,"label"),Hb(this,"insertKeyFrame",!0),Hb(this,"encoder"),Hb(this,"tsMap",new Map),e._log.info("create Video Encoder",r)}trans(e,t,r){return Gb(this,null,(function*(){let i=yield this.recreate(r);t.signal.addEventListener("abort",(()=>{i.close()}));let o=0;return e.pipeThrough(new TransformStream({transform:(e,t)=>{"configured"===i.state&&(this.tsMap.set(o,Date.now()),this.encode(e),o++,t.enqueue(e))}}),t)}))}encode(e){this.encoder.encode(e,{keyFrame:this.insertKeyFrame}),this.insertKeyFrame=!1}start(e,t,r){return Gb(this,null,(function*(){yield this.recreate(r);let i=0;e.pipeTo(new WritableStream({write:e=>{"configured"===this.encoder.state&&(i<10&&this.localTrack.log.info("capture ".concat(this.label," track frame:"),i,Date.now(),e.timestamp,e.displayWidth,e.displayHeight),(e.displayWidth!==this.config.width||e.displayHeight!==this.config.height)&&(this.localTrack.log.info("resize video track frame:",e.displayWidth,e.displayHeight,this.config.width,this.config.height),this.configure({width:e.displayWidth,height:e.displayHeight})),this.tsMap.set(i,Date.now()),this.encode(e),i<10&&this.localTrack.log.info("encode ".concat(this.label," track frame:"),i),i++,e.close())}}),t).catch((e=>{var t;this.localTrack.log.warn(e),null==(t=this.encoder)||t.close()}))}))}recreate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gb(this,null,(function*(){let r=0,i=new VideoEncoder({output:i=>{let o=this.tsMap.get(r);if(this.tsMap.delete(i.timestamp),r<10&&(0===r&&0===t&&Hk.emit(Gk.SEND_FIRST_VIDEO_FRAME,{room:e}),this.localTrack.log.info("encoded ".concat(this.label," track frame:"),r,Date.now(),i.timestamp)),r++,!1===this.track.enabled)return;let n=null;if(this.localTrack.enableEncodeFrame){n=new Uint8Array(i.byteLength),i.copyTo(n);let e=this.localTrack.encodeFrame({data:n.buffer},3===this.type);n=new Uint8Array(e.data)}n?(this.localTrack.stat.bytesSent+=n.length,this.port.postMessage({chunk:{type:i.type,timestamp:i.timestamp,data:n,duration:i.duration},timestamp:o},[n.buffer])):(this.localTrack.stat.bytesSent+=i.byteLength,this.port.postMessage({chunk:i,timestamp:o}))},error:r=>{this.localTrack.log.warn(r,this.config),setTimeout((()=>this.recreate(e,t+1)),100)}});return this.encoder=i,yield this.configure({},0===r?t:0),i}))}configure(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Gb(this,null,(function*(){var r;if(Object.assign(this.config,e),0===t)for(let e=0;e<=WH.length;e++){let{supported:t}=yield VideoDecoder.isConfigSupported(this.config);if(t)break;if(e===WH.length)return;WH[e](this.config)}else t<=WH.length&&WH[t-1](this.config);null==(r=this.encoder)||r.configure(this.config)}))}close(){this.port.postMessage(null),this.port.close()}};function kj(e,t){return Gb(this,null,(function*(){let r=2===e.mediaType,i=r?"screen":"video",o={codec:"avc1.640028",latencyMode:"realtime",avc:{format:"annexb"},hardwareAcceleration:$H.useHardEncoder,width:t.profile.width,height:t.profile.height,framerate:t.profile.frameRate,bitrate:1e3*t.profile.bitrate},n=new MessageChannel;this.postMessage({cmd:"pushVideo",payload:t},[n.port1]);let a=new Nj(e,t.type,o,n.port2);return n.port2.onmessage=e=>{if(260===e.data)a.insertKeyFrame=!0;else if(!r){let{bitrate:t}=e.data;YD({configureBr:[e.data.bitrate,t]}),a.configure({bitrate:t})}},this._log.info("start push",i,t),a}))}function Oj(e){return Gb(this,null,(function*(){var t;let r=2===e.mediaType,i=r?"screen":"video",o={type:r?7:2,profile:e.profile,trackType:r?"screen":"camera",crypto:!(null==(t=e.manager)||!t.encodePipeline[0])};!r&&e.outMediaTrack instanceof CanvasCaptureMediaStreamTrack&&(o.trackType="canvas");let{trackType:n}=o,{width:a,height:s}=e.outMediaTrack.getSettings();o.profile.width=a,o.profile.height=s;let c=yield kj.call(this,e,o);this._log.info("VideoEncoder created",o);let l,u=t=>Gb(this,null,(function*(){if(null==l||l.abort("track changed"),!t)return;l=new AbortController;let{width:r,height:o,displaySurface:a}=t.getSettings();r&&(c.config.width=r),o&&(c.config.height=o);let s,u=JC.match(/Chrome\/(\d+)/);"114"===(null==u?void 0:u[1])&&"browser"===a&&delete c.config.hardwareAcceleration,this._log.info("push",i,"track:",t.readyState,t.getSettings()),s="undefined"!=typeof MediaStreamTrackProcessor?new MediaStreamTrackProcessor({track:t}).readable:new ReadableStream({pull(t){return Gb(this,null,(function*(){if(rL())return new Promise((r=>{var i;null==(i=e.player.element)||i.requestVideoFrameCallback(((i,o)=>{let n=new VideoFrame(e.player.element);t.enqueue(n),r()}))}))}))}});let d="small"in e&&e.small;return d?(this.smallEncoder||(this.smallEncoder=yield kj.call(this,e,{profile:d,type:3,trackType:n})),this.smallEncoder.track=t,this.smallEncoder.label="small",s=yield this.smallEncoder.trans(s,l,this)):this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder),c.track=t,c.label=i,c.start(s,l,this)}));return Sx(tU(e,"output-media-track-changed"),AU(tU(e,"capture")),IV(u,console.error,(()=>{var e;this._log.info("stop push",i,o),l.abort("unpublish"),c.close(),null==(e=this.smallEncoder)||e.close()}))),u(e.outMediaTrack)}))}var Mj=class e extends pL{constructor(t){var r,i;super(null!=(i=null==(r=t.roomid)?void 0:r.toString())?i:t.name,"volumeEvaluation"),this.room=t,Hb(this,"enableInBackground",!1),Hb(this,"interval",400),t.on("joined",(()=>{this.emit(e.INTERVALCHANGED,this.interval)})),Sx(tU(this,e.INTERVALCHANGED),eV((e=>"joined"===this.room.state?this.room.fromWorker("getAudioEnergy",e):Sx((e=>t=>{let r=0,i=performance.now();Sx(OV,JU((t=>(t-i)/e|0)),yU((e=>e!=r&&(r=e,!0))))(t)})(e),JU((()=>[]))))),IV((e=>{e.forEach((e=>{this.room.remotePublishedUserMap.has(e.userId)&&(this.room.remotePublishedUserMap.get(e.userId).remoteAudioTrack.volume=e.volume)})),(!document.hidden||this.enableInBackground)&&this.state==pL.ON&&this.room.emit("audio-volume",e)})))}start(t,r){this.interval=t,this.enableInBackground=r,this.emit(e.INTERVALCHANGED,this.interval)}stop(){}};Hb(Mj,"INTERVALCHANGED","intervalChanged"),Bb([uL([pL.INIT,pL.OFF],pL.ON)],Mj.prototype,"start",1),Bb([uL([],pL.OFF)],Mj.prototype,"stop",1);var Lj=Mj,Pj=class extends XH{constructor(e){super(e),Hb(this,"index",0),Hb(this,"session"),Hb(this,"tinyid"),Hb(this,"roomid"),Hb(this,"openid"),Hb(this,"socketid"),Hb(this,"relayip"),Hb(this,"clientip"),Hb(this,"remotePublishedUserMap",new Map),Hb(this,"bussinessInfo"),Hb(this,"token"),Hb(this,"audioVolumeEvalution",new Lj(this)),Hb(this,"enableAIVoice",Sj),Hb(this,"AbilityOption",{AVLimit:{EncVideoCodec:"H265",EncVideoWidth:0,EncVideoHeight:0,EncVideoBr:"0",EncVideoFps:0,EncAudioCodec:"opus",EncAudioFS:0,EncAudioCh:0,EncAudioBr:"0"},GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:navigator.platform,uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:Vk(),uint32_device_type:0,str_os_verion:Fk(),uint32_link_type:1,str_client_version:nw,uint32_net_type:Cw[rw.getNetworkType()],ua:navigator.userAgent,version:""}}),Hb(this,"joinAbortController",new AbortController),Hb(this,"smallAbortCtrl"),Hb(this,"smallEncoder"),e.tinyId&&(this.tinyId=e.tinyId,Rj(!0)),this._log||(this._log=e.logger),this.bussinessInfo=e.bussinessInfo,e.encodedDataProcessingListener&&this.setEncodedDataProcessingListener(e.encodedDataProcessingListener)}replaceTrack(e){return Gb(this,null,(function*(){}))}getLogger(){return this._log}postMessage(e,t){this.session&&(e?"string"==typeof e?this.session.postMessage({cmd:e,payload:t}):this.session.postMessage(e,t):this.session.postMessage(null))}sendMessage(e,t){return new Promise(((r,i)=>{"joined"!=this.state&&i("join room first");let o=new MessageChannel;this.postMessage({cmd:e,payload:t},[o.port1]),o.port2.onmessageerror=i,o.port2.onmessage=e=>{o.port2.close(),r(e.data)}}))}fromWorker(e,t){if("joined"!=this.state)throw"join room first";return r=>{var i;let o=new MessageChannel;o.port2.onmessage=e=>{e.data?r.next(e.data):r.complete()},o.port2.onmessageerror=e=>r.error(e),r.defer((()=>{o.port2.postMessage(null),o.port2.close()})),null==(i=this.session)||i.postMessage({cmd:e,payload:t},[o.port1])}}switchRole(e){return Gb(this,null,(function*(){if(e!==this.role)return this._log.info("switchRole() => switch role to: ".concat(e)),"audience"==e&&this.unpublish(...this.localTracks),this.sendMessage("switchRole","audience"==e?21:20).then((t=>{this.role=e}))}))}join(e,t,r){return Gb(this,null,(function*(){var i,o,n;let a=rw.getEnv(),s=hM(),c={isH264EncodeSupported:this.checkSystemResult.detail.isH264EncodeSupported,isVp8EncodeSupported:this.checkSystemResult.detail.isVp8EncodeSupported,frameWorkType:r,params:e,proxy_wt:null==(i=this.proxy_wt)?void 0:i.replace("https://",""),proxy_ws:null==(o=this.proxy_ws)?void 0:o.replace("wss://",""),proxy_cloud:null!=(n=this.scheduleResult.iceServers)&&n.length?this.scheduleResult.iceServers[0].urls:[],proxy_unified:this.proxy_unified,domains:this.scheduleResult.domains,env:a,osName:Pk(),browserInfo:hM(),tinyId:this.tinyId,joinReq:{useStrRoomid:!!this.useStringRoomId,roomid:String(e.roomId||e.strRoomId),sdkAppID:String(e.sdkAppId),userSig:e.userSig,privMapEncrypt:e.privateMapKey||"",privMap:"",pstnBizType:0,role:"user",jsSdkVersion:nw,browserVersion:s.browserName+s.browserVersion,closeLocalMedia:!0,trtcscene:"live"===t?2:1,trtcrole:e.role,bussinessInfo:e.businessInfo||this.bussinessInfo||"",isAuxUser:0,autoSubscribe:this.autoReceiveAudio&&this.autoReceiveVideo,AbilityOption:this.AbilityOption}};yield Aj.call(this,c),console.log(this),aj.playAudio((e=>this.postMessage({cmd:"setAudioWorkletPort"},[e]))),this.checkDestroy()}))}leave(){return Gb(this,null,(function*(){this.remotePublishedUserMap.forEach((e=>{e.remoteAudioTrack.close(),e.remoteAuxiliaryTrack.close(),e.remoteVideoTrack.close()})),this.postMessage(null),this.remotePublishedUserMap.clear(),this.localTracks.forEach(((e,t)=>t.unpublish()))}))}getSignalInfo(){return{tinyId:this.tinyid,clientIp:this.clientip,signalIp:"",relayIp:this.relayip,relayInnerIp:"",relayPort:0}}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e<=0?this.audioVolumeEvalution.stop():this.audioVolumeEvalution.start(e,t)}getLocalAudioStats(){return this.sendMessage("getLocalAudioStats")}getLocalVideoStats(){return this.sendMessage("getLocalVideoStats")}afterJoin(){return Gb(this,null,(function*(){Sx((e=>Gb(this,null,(function*(){let t=new MessageChannel;t.port2.onmessage=r=>{r.data?e.next({data:r.data,port:t.port2}):e.complete()},t.port2.onmessageerror=t=>e.error(t),e.defer((()=>{t.port2.postMessage(null),t.port2.close()})),this.postMessage({cmd:"decodeAudio",payload:!!this.audioManager.decodePipeline[0]},[t.port1])}))),AU(tU(this,"left")),IV((e=>{let{data:t,port:r}=e,i=this.audioManager.decodePipeline[0]({frame:{data:t.data.buffer}});r.postMessage(xb(Pb({},t),{data:new Uint8Array(i.data)}),[i.data])})))}))}onWorkerEvent(e,t){switch("network-quality"!==e&&console.info(this.userId,"onWorkerEvent",e,JSON.stringify(t)),e){case Gk.RECEIVED_PUBLISHED_USER_LIST:return void Hk.emit(e,Pb({room:this},t));case"1":if(t.userId===this.userId)return;return void this.emit("peer-join",t);case"2":return void this.emit("peer-leave",t);case"3":let r=new bH(this,t);return this.remotePublishedUserMap.set(t.userId,r),void this.emit("remote-published",r);case"5":{let e=t,r=this.remotePublishedUserMap.get(e);r&&(r.remoteVideoTrack.close(),r.remoteAuxiliaryTrack.close(),r.remoteAudioTrack.close(),this.remotePublishedUserMap.delete(e),this.emit("remote-unpublished",r))}return;case"banned":switch(t){case 8:return void this.emit("banned",{reason:"kick",message:""});case 2:case 6:case 4:return void this.emit("banned",{reason:"banned",message:""});case 7:case 5:return void this.emit("banned",{reason:"room_disband",message:""})}break;case"6":{let{prevMuteState:e,muteState:r,flag:i}=t,o=this.remotePublishedUserMap.get(r.userId);if(!o)return void this.emit("remote-publish-state-changed",t);o.flag=i}return Hk.emit(Gk.REMOTE_PUBLISH_STATE_CHANGED,Pb({room:this},t)),void this.emit("remote-publish-state-changed",t);case"network-quality":this.quality=Pb({},t);let{uplinkLoss:i,uplinkRTT:o,uplinkInfo:n,downlinkInfo:a,msg_down_stream_info:s}=t,c={str_sdk_version:nw,uint64_datetime:Date.now(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyid},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:Cw[BD()]},msg_event_msg:$V(this.userId),str_acc_ip:this.relayip,str_client_ip:this.clientip,msg_up_stream_info:n,msg_down_stream_info:s};Hk.emit(Gk.HEARTBEAT_REPORT,{room:this,report:c}),this.emit("heartbeat-report",c),Hk.emit(Gk.NETWORK_QUALITY,{room:this,uplink:{rtt:o,loss:i},downlinks:a}),delete t.downlinkInfo;break;case"signal-connection-state-changed":return void Hk.emit(Gk.SIGNAL_CONNECTION_STATE_CHANGED,Pb({room:this},t))}this.emit(e,t)}sendStartPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("publishCdn",e)}sendStopPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("stopPublishCdn",e)}sendStartMixTranscode(e){return this.sendMessage("startMcuMix",e)}sendStopMixTranscode(e){return this.sendMessage("stopMcuMix",e)}publish(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),r=this.sendMessage("publish",e).then((e=>0!==e.err?Promise.reject(e.err):e)),i=0;yield Promise.all(t.map((e=>Gb(this,null,(function*(){if(1===(yield r,e.muted&&(i|=e.mediaType),AL(e,e).add("mute",(()=>{this.postMessage("mute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,remove:!0})})).add("unmute",(()=>{this.postMessage("unmute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,add:!0})})),e.mediaType))Cj.call(this,e);else yield Oj.call(this,e)}))))),i&&this.postMessage("mute",{mediaType:i,srctinyid:this.tinyid,userId:this.openid,remove:!0})}))}unpublish(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(this,null,(function*(){t.forEach(SL)}))}subscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),{userId:r,tinyId:i,streamType:o}=t[0],n=this.remotePublishedUserMap.get(r),a=Pb({},n.subscribeState),s=Object.assign(new BO,a);s.mediaType|=e,Hk.emit(Gk.SUBSCRIBE_START,{room:this,streamType:o,remotePublishedUser:n,subscribeState:s});let c=yield this.sendMessage("subscribe",{mediaType:s.mediaType,userId:r,srctinyid:i,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8,2].filter((e=>s.mediaType&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}});console.dir("subscribe",c),yield Promise.all(t.filter((e=>!e.isSubscribed)).map((e=>1===e.mediaType?bj.call(this,e):wj.call(this,e)))),Hk.emit(Gk.SUBSCRIBE_SUCCESS,{room:this,streamType:o,remotePublishedUser:n})}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Gb(this,null,(function*(){let e=0;for(let r of t)e|=r.mediaType;if(t.length){let{userId:r,streamType:i,tinyId:o}=t[0];yield this.sendMessage("unSubscribe",{mediaType:e,srctinyid:o,userId:r});for(let e of t)e.unsubscribe();Hk.emit(Gk.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:this.remotePublishedUserMap.get(r)})}}))}enableSmall(e){return Gb(this,null,(function*(){var t;if(e){if(this.videoManager.smallTrack){let e=this.videoManager.cameraTrack;this.smallEncoder=yield kj.call(this,e,{profile:e.small,type:3,trackType:"camera"});let t=new MediaStreamTrackProcessor({track:this.videoManager.smallTrack}).readable;this.smallEncoder.track=this.videoManager.smallTrack,this.smallEncoder.label="small",this.smallAbortCtrl=new AbortController,this.smallEncoder.start(t,this.smallAbortCtrl,this),this._log.info("push small")}}else null==(t=this.smallAbortCtrl)||t.abort("stop"),this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder)}))}changeType(e,t){let r=this.remotePublishedUserMap.get(t.userId),i=e?8:4;if(r.remoteVideoTrack.mediaType===i)return;let o={srctinyid:t.tinyId,mediaType:i,userId:t.userId,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8].filter((e=>i&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}};r.remoteVideoTrack.mediaType=o.mediaType,this.postMessage("changetype",o)}destroy(){this.isDestroyed||(super.destroy(),this.isDestroyed=!0,this.joinAbortController.abort("destroy"))}};Bb([GP(Pj.prototype.afterJoin),uL(["left",pL.INIT],"joined"),WP((e=>{let t=new wH;return function(r,i,o){return Gb(this,null,(function*(){let n=String(r.roomId||r.strRoomId);if(this.userId=r.userId,this.sdkAppId=r.sdkAppId,this.userSig=r.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=i,r.privateMapKey=r.privateMapKey||"",this.isJoined)throw new Qb({code:Xb.INVALID_OPERATION,message:ZO({key:YO.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:n,sdkAppId:this.sdkAppId,room:this}))throw new Qb({code:Xb.INVALID_OPERATION,message:ZO({key:YO.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:n}),this.role=21===r.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(n," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),Hk.emit(Gk.JOIN_START,{room:this,roomId:n,params:r});let a=rw.getEnv();a||(a=Rw.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(xw.OLD_CLOUD_LADDER)?a=Rw.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(xw.WEBRTC)&&(a=Rw.WEBRTC))),RL.setConfig({env:a,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:n}),Jk.checkSystemRequirementsInternal().then((e=>{this.checkSystemResult=e,DH.call(this)}));try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!rw.getEnv()&&(yield this.schedule(r,o));let t=yield e.call(this,r,i,o);return this.roomId=n,this._joinedTimestamp=rw.performanceNow(),Hk.emit(Gk.JOIN_SUCCESS,{room:this}),30===o&&!r.component&&RL.uploadEvent({log:"stat-conv-".concat(Number(Sk),"-").concat(location.hostname),userId:this.userId}),t}catch(tO){throw t.delete({room:this,roomId:n}),Hk.emit(Gk.JOIN_FAILED,{room:this,error:tO}),tO}}))}}))],Pj.prototype,"join",1),Bb([uL("joined","left",{ignoreError:!0}),WP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Gb(this,null,(function*(){Hk.emit(Gk.LEAVE_START,{room:this}),yield e.call(this,...r),Hk.emit(Gk.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))}))],Pj.prototype,"leave",1),Bb([XP((function(){return 0})),WP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Gb(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||(r=r.filter((e=>e.outMediaTrack&&"capture"===e.state)),!r.length))return;Hk.emit("61",{room:this});let t=e.apply(this,r);return r.forEach((e=>e.publish(this,t))),t}))}))],Pj.prototype,"publish",1),Bb([XP((function(){return 0})),WP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>e.unpublish())),o}))],Pj.prototype,"unpublish",1),Bb([XP((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].userId})),WP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>!e.isSubscribed&&e.subscribe(o))),o}))],Pj.prototype,"subscribe",1);var xj=Pj;return RH.frameWorkType=37,RH.create=function(e){let t=RH._create.call(this,xj,e);return t._use(xF,null==e?void 0:e.assetsPath),null!=e&&e.assetsPath&&($H.assetsPath=null==e?void 0:e.assetsPath),console.log("trtc wasm sdk:",nw,"created",$H),t},Object.assign(RH.prototype,{_setCurrentSpeaker(e){let t=nP();return null!=t&&t.setSinkId?t.setSinkId(e):Promise.reject("not support")},_enableVideoDecodeFallback(e,t){return Gb(this,null,(function*(){return this.startPlugin(xF.Name,{type:"webCodecs",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:"wasm"}),new Promise(((t,r)=>{Sx(tU(e,"decode-downgrade-state-changed"),yU((e=>"STARTED"===e.state)),IU(1),SV(1e4),AU(tU(e,pL.INIT)),IV(t,r))}))}))}}),RH}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TRTC=t()}(this,(function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=function(e){return e&&e.Math===Math&&e},r=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof e&&e)||t("object"==typeof e&&e)||function(){return this}()||Function("return this")(),i={},o=function(e){try{return!!e()}catch(t){return!0}},n=!o((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),a=!o((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),s=a,c=Function.prototype.call,l=s?c.bind(c):function(){return c.apply(c,arguments)},u={},d={}.propertyIsEnumerable,h=Object.getOwnPropertyDescriptor,p=h&&!d.call({1:2},1);u.f=p?function(e){var t=h(this,e);return!!t&&t.enumerable}:d;var m,f,_=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},g=a,E=Function.prototype,v=E.call,y=g&&E.bind.bind(v,v),T=g?y:function(e){return function(){return v.apply(e,arguments)}},I=T,A=I({}.toString),S=I("".slice),R=function(e){return S(A(e),8,-1)},b=o,w=R,D=Object,C=T("".split),N=b((function(){return!D("z").propertyIsEnumerable(0)}))?function(e){return"String"===w(e)?C(e,""):D(e)}:D,k=function(e){return null==e},O=k,M=TypeError,L=function(e){if(O(e))throw new M("Can't call method on "+e);return e},P=N,x=L,U=function(e){return P(x(e))},V="object"==typeof document&&document.all,F=void 0===V&&void 0!==V?function(e){return"function"==typeof e||e===V}:function(e){return"function"==typeof e},B=F,H=function(e){return"object"==typeof e?null!==e:B(e)},W=r,j=F,G=function(e,t){return arguments.length<2?(r=W[e],j(r)?r:void 0):W[e]&&W[e][t];var r},K=T({}.isPrototypeOf),z=r.navigator,q=z&&z.userAgent,Y=q?String(q):"",J=r,X=Y,$=J.process,Q=J.Deno,Z=$&&$.versions||Q&&Q.version,ee=Z&&Z.v8;ee&&(f=(m=ee.split("."))[0]>0&&m[0]<4?1:+(m[0]+m[1])),!f&&X&&(!(m=X.match(/Edge\/(\d+)/))||m[1]>=74)&&(m=X.match(/Chrome\/(\d+)/))&&(f=+m[1]);var te=f,re=te,ie=o,oe=r.String,ne=!!Object.getOwnPropertySymbols&&!ie((function(){var e=Symbol("symbol detection");return!oe(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&re&&re<41})),ae=ne&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,se=G,ce=F,le=K,ue=Object,de=ae?function(e){return"symbol"==typeof e}:function(e){var t=se("Symbol");return ce(t)&&le(t.prototype,ue(e))},he=String,pe=function(e){try{return he(e)}catch(t){return"Object"}},me=F,fe=pe,_e=TypeError,ge=function(e){if(me(e))return e;throw new _e(fe(e)+" is not a function")},Ee=ge,ve=k,ye=function(e,t){var r=e[t];return ve(r)?void 0:Ee(r)},Te=l,Ie=F,Ae=H,Se=TypeError,Re={exports:{}},be=r,we=Object.defineProperty,De=function(e,t){try{we(be,e,{value:t,configurable:!0,writable:!0})}catch(r){be[e]=t}return t},Ce=r,Ne=De,ke="__core-js_shared__",Oe=Re.exports=Ce[ke]||Ne(ke,{});(Oe.versions||(Oe.versions=[])).push({version:"3.40.0",mode:"global",copyright:"© 2014-2025 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE",source:"https://github.com/zloirock/core-js"});var Me=Re.exports,Le=Me,Pe=function(e,t){return Le[e]||(Le[e]=t||{})},xe=L,Ue=Object,Ve=function(e){return Ue(xe(e))},Fe=Ve,Be=T({}.hasOwnProperty),He=Object.hasOwn||function(e,t){return Be(Fe(e),t)},We=T,je=0,Ge=Math.random(),Ke=We(1..toString),ze=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ke(++je+Ge,36)},qe=Pe,Ye=He,Je=ze,Xe=ne,$e=ae,Qe=r.Symbol,Ze=qe("wks"),et=$e?Qe.for||Qe:Qe&&Qe.withoutSetter||Je,tt=function(e){return Ye(Ze,e)||(Ze[e]=Xe&&Ye(Qe,e)?Qe[e]:et("Symbol."+e)),Ze[e]},rt=l,it=H,ot=de,nt=ye,at=function(e,t){var r,i;if("string"===t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;if(Ie(r=e.valueOf)&&!Ae(i=Te(r,e)))return i;if("string"!==t&&Ie(r=e.toString)&&!Ae(i=Te(r,e)))return i;throw new Se("Can't convert object to primitive value")},st=TypeError,ct=tt("toPrimitive"),lt=function(e,t){if(!it(e)||ot(e))return e;var r,i=nt(e,ct);if(i){if(void 0===t&&(t="default"),r=rt(i,e,t),!it(r)||ot(r))return r;throw new st("Can't convert object to primitive value")}return void 0===t&&(t="number"),at(e,t)},ut=lt,dt=de,ht=function(e){var t=ut(e,"string");return dt(t)?t:t+""},pt=H,mt=r.document,ft=pt(mt)&&pt(mt.createElement),_t=function(e){return ft?mt.createElement(e):{}},gt=_t,Et=!n&&!o((function(){return 7!==Object.defineProperty(gt("div"),"a",{get:function(){return 7}}).a})),vt=n,yt=l,Tt=u,It=_,At=U,St=ht,Rt=He,bt=Et,wt=Object.getOwnPropertyDescriptor;i.f=vt?wt:function(e,t){if(e=At(e),t=St(t),bt)try{return wt(e,t)}catch(r){}if(Rt(e,t))return It(!yt(Tt.f,e,t),e[t])};var Dt={},Ct=n&&o((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Nt=H,kt=String,Ot=TypeError,Mt=function(e){if(Nt(e))return e;throw new Ot(kt(e)+" is not an object")},Lt=n,Pt=Et,xt=Ct,Ut=Mt,Vt=ht,Ft=TypeError,Bt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Wt="enumerable",jt="configurable",Gt="writable";Dt.f=Lt?xt?function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Gt in r&&!r[Gt]){var i=Ht(e,t);i&&i[Gt]&&(e[t]=r.value,r={configurable:jt in r?r[jt]:i[jt],enumerable:Wt in r?r[Wt]:i[Wt],writable:!1})}return Bt(e,t,r)}:Bt:function(e,t,r){if(Ut(e),t=Vt(t),Ut(r),Pt)try{return Bt(e,t,r)}catch(i){}if("get"in r||"set"in r)throw new Ft("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Kt=Dt,zt=_,qt=n?function(e,t,r){return Kt.f(e,t,zt(1,r))}:function(e,t,r){return e[t]=r,e},Yt={exports:{}},Jt=n,Xt=He,$t=Function.prototype,Qt=Jt&&Object.getOwnPropertyDescriptor,Zt=Xt($t,"name"),er={EXISTS:Zt,PROPER:Zt&&"something"===function(){}.name,CONFIGURABLE:Zt&&(!Jt||Jt&&Qt($t,"name").configurable)},tr=F,rr=Me,ir=T(Function.toString);tr(rr.inspectSource)||(rr.inspectSource=function(e){return ir(e)});var or,nr,ar,sr=rr.inspectSource,cr=F,lr=r.WeakMap,ur=cr(lr)&&/native code/.test(String(lr)),dr=ze,hr=Pe("keys"),pr=function(e){return hr[e]||(hr[e]=dr(e))},mr={},fr=ur,_r=r,gr=H,Er=qt,vr=He,yr=Me,Tr=pr,Ir=mr,Ar="Object already initialized",Sr=_r.TypeError,Rr=_r.WeakMap;if(fr||yr.state){var br=yr.state||(yr.state=new Rr);br.get=br.get,br.has=br.has,br.set=br.set,or=function(e,t){if(br.has(e))throw new Sr(Ar);return t.facade=e,br.set(e,t),t},nr=function(e){return br.get(e)||{}},ar=function(e){return br.has(e)}}else{var wr=Tr("state");Ir[wr]=!0,or=function(e,t){if(vr(e,wr))throw new Sr(Ar);return t.facade=e,Er(e,wr,t),t},nr=function(e){return vr(e,wr)?e[wr]:{}},ar=function(e){return vr(e,wr)}}var Dr={set:or,get:nr,has:ar,enforce:function(e){return ar(e)?nr(e):or(e,{})},getterFor:function(e){return function(t){var r;if(!gr(t)||(r=nr(t)).type!==e)throw new Sr("Incompatible receiver, "+e+" required");return r}}},Cr=T,Nr=o,kr=F,Or=He,Mr=n,Lr=er.CONFIGURABLE,Pr=sr,xr=Dr.enforce,Ur=Dr.get,Vr=String,Fr=Object.defineProperty,Br=Cr("".slice),Hr=Cr("".replace),Wr=Cr([].join),jr=Mr&&!Nr((function(){return 8!==Fr((function(){}),"length",{value:8}).length})),Gr=String(String).split("String"),Kr=Yt.exports=function(e,t,r){"Symbol("===Br(Vr(t),0,7)&&(t="["+Hr(Vr(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!Or(e,"name")||Lr&&e.name!==t)&&(Mr?Fr(e,"name",{value:t,configurable:!0}):e.name=t),jr&&r&&Or(r,"arity")&&e.length!==r.arity&&Fr(e,"length",{value:r.arity});try{r&&Or(r,"constructor")&&r.constructor?Mr&&Fr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var i=xr(e);return Or(i,"source")||(i.source=Wr(Gr,"string"==typeof t?t:"")),e};Function.prototype.toString=Kr((function(){return kr(this)&&Ur(this).source||Pr(this)}),"toString");var zr=Yt.exports,qr=F,Yr=Dt,Jr=zr,Xr=De,$r=function(e,t,r,i){i||(i={});var o=i.enumerable,n=void 0!==i.name?i.name:t;if(qr(r)&&Jr(r,n,i),i.global)o?e[t]=r:Xr(t,r);else{try{i.unsafe?e[t]&&(o=!0):delete e[t]}catch(a){}o?e[t]=r:Yr.f(e,t,{value:r,enumerable:!1,configurable:!i.nonConfigurable,writable:!i.nonWritable})}return e},Qr={},Zr=Math.ceil,ei=Math.floor,ti=Math.trunc||function(e){var t=+e;return(t>0?ei:Zr)(t)},ri=ti,ii=function(e){var t=+e;return t!=t||0===t?0:ri(t)},oi=ii,ni=Math.max,ai=Math.min,si=function(e,t){var r=oi(e);return r<0?ni(r+t,0):ai(r,t)},ci=ii,li=Math.min,ui=function(e){var t=ci(e);return t>0?li(t,9007199254740991):0},di=ui,hi=function(e){return di(e.length)},pi=U,mi=si,fi=hi,_i=function(e){return function(t,r,i){var o=pi(t),n=fi(o);if(0===n)return!e&&-1;var a,s=mi(i,n);if(e&&r!=r){for(;n>s;)if((a=o[s++])!=a)return!0}else for(;n>s;s++)if((e||s in o)&&o[s]===r)return e||s||0;return!e&&-1}},gi={includes:_i(!0),indexOf:_i(!1)},Ei=He,vi=U,yi=gi.indexOf,Ti=mr,Ii=T([].push),Ai=function(e,t){var r,i=vi(e),o=0,n=[];for(r in i)!Ei(Ti,r)&&Ei(i,r)&&Ii(n,r);for(;t.length>o;)Ei(i,r=t[o++])&&(~yi(n,r)||Ii(n,r));return n},Si=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ri=Ai,bi=Si.concat("length","prototype");Qr.f=Object.getOwnPropertyNames||function(e){return Ri(e,bi)};var wi={};wi.f=Object.getOwnPropertySymbols;var Di=G,Ci=Qr,Ni=wi,ki=Mt,Oi=T([].concat),Mi=Di("Reflect","ownKeys")||function(e){var t=Ci.f(ki(e)),r=Ni.f;return r?Oi(t,r(e)):t},Li=He,Pi=Mi,xi=i,Ui=Dt,Vi=function(e,t,r){for(var i=Pi(t),o=Ui.f,n=xi.f,a=0;a<i.length;a++){var s=i[a];Li(e,s)||r&&Li(r,s)||o(e,s,n(t,s))}},Fi=o,Bi=F,Hi=/#|\.prototype\./,Wi=function(e,t){var r=Gi[ji(e)];return r===zi||r!==Ki&&(Bi(t)?Fi(t):!!t)},ji=Wi.normalize=function(e){return String(e).replace(Hi,".").toLowerCase()},Gi=Wi.data={},Ki=Wi.NATIVE="N",zi=Wi.POLYFILL="P",qi=Wi,Yi=r,Ji=i.f,Xi=qt,$i=$r,Qi=De,Zi=Vi,eo=qi,to=function(e,t){var r,i,o,n,a,s=e.target,c=e.global,l=e.stat;if(r=c?Yi:l?Yi[s]||Qi(s,{}):Yi[s]&&Yi[s].prototype)for(i in t){if(n=t[i],o=e.dontCallGetSet?(a=Ji(r,i))&&a.value:r[i],!eo(c?i:s+(l?".":"#")+i,e.forced)&&void 0!==o){if(typeof n==typeof o)continue;Zi(n,o)}(e.sham||o&&o.sham)&&Xi(n,"sham",!0),$i(r,i,n,e)}},ro={};ro[tt("toStringTag")]="z";var io="[object z]"===String(ro),oo=F,no=R,ao=tt("toStringTag"),so=Object,co="Arguments"===no(function(){return arguments}()),lo=io?no:function(e){var t,r,i;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(r){}}(t=so(e),ao))?r:co?no(t):"Object"===(i=no(t))&&oo(t.callee)?"Arguments":i},uo=lo,ho=String,po=function(e){if("Symbol"===uo(e))throw new TypeError("Cannot convert a Symbol value to a string");return ho(e)},mo=zr,fo=Dt,_o=function(e,t,r){return r.get&&mo(r.get,t,{getter:!0}),r.set&&mo(r.set,t,{setter:!0}),fo.f(e,t,r)},go=to,Eo=n,vo=T,yo=He,To=F,Io=K,Ao=po,So=_o,Ro=Vi,bo=r.Symbol,wo=bo&&bo.prototype;if(Eo&&To(bo)&&(!("description"in wo)||void 0!==bo().description)){var Do={},Co=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:Ao(arguments[0]),t=Io(wo,this)?new bo(e):void 0===e?bo():bo(e);return""===e&&(Do[t]=!0),t};Ro(Co,bo),Co.prototype=wo,wo.constructor=Co;var No="Symbol(description detection)"===String(bo("description detection")),ko=vo(wo.valueOf),Oo=vo(wo.toString),Mo=/^Symbol\((.*)\)[^)]+$/,Lo=vo("".replace),Po=vo("".slice);So(wo,"description",{configurable:!0,get:function(){var e=ko(this);if(yo(Do,e))return"";var t=Oo(e),r=No?Po(t,7,-1):Lo(t,Mo,"$1");return""===r?void 0:r}}),go({global:!0,constructor:!0,forced:!0},{Symbol:Co})}var xo=r,Uo={},Vo=tt;Uo.f=Vo;var Fo=xo,Bo=He,Ho=Uo,Wo=Dt.f,jo=function(e){var t=Fo.Symbol||(Fo.Symbol={});Bo(t,e)||Wo(t,e,{value:Ho.f(e)})};jo("asyncIterator");var Go=R,Ko=Array.isArray||function(e){return"Array"===Go(e)},zo=TypeError,qo=R,Yo=T,Jo=function(e){if("Function"===qo(e))return Yo(e)},Xo=ge,$o=a,Qo=Jo(Jo.bind),Zo=function(e,t){return Xo(e),void 0===t?e:$o?Qo(e,t):function(){return e.apply(t,arguments)}},en=Ko,tn=hi,rn=function(e){if(e>9007199254740991)throw zo("Maximum allowed index exceeded");return e},on=Zo,nn=function(e,t,r,i,o,n,a,s){for(var c,l,u=o,d=0,h=!!a&&on(a,s);d<i;)d in r&&(c=h?h(r[d],d,t):r[d],n>0&&en(c)?(l=tn(c),u=nn(e,t,c,l,u,n-1)-1):(rn(u+1),e[u]=c),u++),d++;return u},an=nn,sn=T,cn=o,ln=F,un=lo,dn=sr,hn=function(){},pn=G("Reflect","construct"),mn=/^\s*(?:class|function)\b/,fn=sn(mn.exec),_n=!mn.test(hn),gn=function(e){if(!ln(e))return!1;try{return pn(hn,[],e),!0}catch(t){return!1}},En=function(e){if(!ln(e))return!1;switch(un(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return _n||!!fn(mn,dn(e))}catch(t){return!0}};En.sham=!0;var vn=!pn||cn((function(){var e;return gn(gn.call)||!gn(Object)||!gn((function(){e=!0}))||e}))?En:gn,yn=Ko,Tn=vn,In=H,An=tt("species"),Sn=Array,Rn=function(e){var t;return yn(e)&&(t=e.constructor,(Tn(t)&&(t===Sn||yn(t.prototype))||In(t)&&null===(t=t[An]))&&(t=void 0)),void 0===t?Sn:t},bn=function(e,t){return new(Rn(e))(0===t?0:t)},wn=an,Dn=Ve,Cn=hi,Nn=ii,kn=bn;to({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=Dn(this),r=Cn(t),i=kn(t,0);return i.length=wn(i,t,t,r,0,void 0===e?1:Nn(e)),i}});var On={},Mn=Ai,Ln=Si,Pn=Object.keys||function(e){return Mn(e,Ln)},xn=n,Un=Ct,Vn=Dt,Fn=Mt,Bn=U,Hn=Pn;On.f=xn&&!Un?Object.defineProperties:function(e,t){Fn(e);for(var r,i=Bn(t),o=Hn(t),n=o.length,a=0;n>a;)Vn.f(e,r=o[a++],i[r]);return e};var Wn,jn=G("document","documentElement"),Gn=Mt,Kn=On,zn=Si,qn=mr,Yn=jn,Jn=_t,Xn="prototype",$n="script",Qn=pr("IE_PROTO"),Zn=function(){},ea=function(e){return"<"+$n+">"+e+"</"+$n+">"},ta=function(e){e.write(ea("")),e.close();var t=e.parentWindow.Object;return e=null,t},ra=function(){try{Wn=new ActiveXObject("htmlfile")}catch(o){}var e,t,r;ra="undefined"!=typeof document?document.domain&&Wn?ta(Wn):(t=Jn("iframe"),r="java"+$n+":",t.style.display="none",Yn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(ea("document.F=Object")),e.close(),e.F):ta(Wn);for(var i=zn.length;i--;)delete ra[Xn][zn[i]];return ra()};qn[Qn]=!0;var ia=Object.create||function(e,t){var r;return null!==e?(Zn[Xn]=Gn(e),r=new Zn,Zn[Xn]=null,r[Qn]=e):r=ra(),void 0===t?r:Kn.f(r,t)},oa=tt,na=ia,aa=Dt.f,sa=oa("unscopables"),ca=Array.prototype;void 0===ca[sa]&&aa(ca,sa,{configurable:!0,value:na(null)});var la=function(e){ca[sa][e]=!0},ua=gi.includes,da=la;to({target:"Array",proto:!0,forced:o((function(){return!Array(1).includes()}))},{includes:function(e){return ua(this,e,arguments.length>1?arguments[1]:void 0)}}),da("includes");var ha,pa,ma,fa={},_a=!o((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),ga=He,Ea=F,va=Ve,ya=_a,Ta=pr("IE_PROTO"),Ia=Object,Aa=Ia.prototype,Sa=ya?Ia.getPrototypeOf:function(e){var t=va(e);if(ga(t,Ta))return t[Ta];var r=t.constructor;return Ea(r)&&t instanceof r?r.prototype:t instanceof Ia?Aa:null},Ra=o,ba=F,wa=H,Da=Sa,Ca=$r,Na=tt("iterator"),ka=!1;[].keys&&("next"in(ma=[].keys())?(pa=Da(Da(ma)))!==Object.prototype&&(ha=pa):ka=!0);var Oa=!wa(ha)||Ra((function(){var e={};return ha[Na].call(e)!==e}));Oa&&(ha={}),ba(ha[Na])||Ca(ha,Na,(function(){return this}));var Ma={IteratorPrototype:ha,BUGGY_SAFARI_ITERATORS:ka},La=Dt.f,Pa=He,xa=tt("toStringTag"),Ua=function(e,t,r){e&&!r&&(e=e.prototype),e&&!Pa(e,xa)&&La(e,xa,{configurable:!0,value:t})},Va=Ma.IteratorPrototype,Fa=ia,Ba=_,Ha=Ua,Wa=fa,ja=function(){return this},Ga=function(e,t,r,i){var o=t+" Iterator";return e.prototype=Fa(Va,{next:Ba(+!i,r)}),Ha(e,o,!1),Wa[o]=ja,e},Ka=T,za=ge,qa=H,Ya=function(e){return qa(e)||null===e},Ja=String,Xa=TypeError,$a=function(e,t,r){try{return Ka(za(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}},Qa=H,Za=L,es=function(e){if(Ya(e))return e;throw new Xa("Can't set "+Ja(e)+" as a prototype")},ts=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=$a(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(i){}return function(r,i){return Za(r),es(i),Qa(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0),rs=to,is=l,os=F,ns=Ga,as=Sa,ss=ts,cs=Ua,ls=qt,us=$r,ds=fa,hs=er.PROPER,ps=er.CONFIGURABLE,ms=Ma.IteratorPrototype,fs=Ma.BUGGY_SAFARI_ITERATORS,_s=tt("iterator"),gs="keys",Es="values",vs="entries",ys=function(){return this},Ts=function(e,t,r,i,o,n,a){ns(r,t,i);var s,c,l,u=function(e){if(e===o&&f)return f;if(!fs&&e&&e in p)return p[e];switch(e){case gs:case Es:case vs:return function(){return new r(this,e)}}return function(){return new r(this)}},d=t+" Iterator",h=!1,p=e.prototype,m=p[_s]||p["@@iterator"]||o&&p[o],f=!fs&&m||u(o),_="Array"===t&&p.entries||m;if(_&&(s=as(_.call(new e)))!==Object.prototype&&s.next&&(as(s)!==ms&&(ss?ss(s,ms):os(s[_s])||us(s,_s,ys)),cs(s,d,!0)),hs&&o===Es&&m&&m.name!==Es&&(ps?ls(p,"name",Es):(h=!0,f=function(){return is(m,this)})),o)if(c={values:u(Es),keys:n?f:u(gs),entries:u(vs)},a)for(l in c)(fs||h||!(l in p))&&us(p,l,c[l]);else rs({target:t,proto:!0,forced:fs||h},c);return p[_s]!==f&&us(p,_s,f,{name:o}),ds[t]=f,c},Is=function(e,t){return{value:e,done:t}},As=U,Ss=la,Rs=fa,bs=Dr,ws=Dt.f,Ds=Ts,Cs=Is,Ns=n,ks="Array Iterator",Os=bs.set,Ms=bs.getterFor(ks),Ls=Ds(Array,"Array",(function(e,t){Os(this,{type:ks,target:As(e),index:0,kind:t})}),(function(){var e=Ms(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,Cs(void 0,!0);switch(e.kind){case"keys":return Cs(r,!1);case"values":return Cs(t[r],!1)}return Cs([r,t[r]],!1)}),"values"),Ps=Rs.Arguments=Rs.Array;if(Ss("keys"),Ss("values"),Ss("entries"),Ns&&"values"!==Ps.name)try{ws(Ps,"name",{value:"values"})}catch(YW){}var xs=ge,Us=Ve,Vs=N,Fs=hi,Bs=TypeError,Hs="Reduce of empty array with no initial value",Ws=function(e){return function(t,r,i,o){var n=Us(t),a=Vs(n),s=Fs(n);if(xs(r),0===s&&i<2)throw new Bs(Hs);var c=e?s-1:0,l=e?-1:1;if(i<2)for(;;){if(c in a){o=a[c],c+=l;break}if(c+=l,e?c<0:s<=c)throw new Bs(Hs)}for(;e?c>=0:s>c;c+=l)c in a&&(o=r(o,a[c],c,n));return o}},js={left:Ws(!1),right:Ws(!0)},Gs=o,Ks=function(e,t){var r=[][e];return!!r&&Gs((function(){r.call(null,t||function(){return 1},1)}))},zs=r,qs=Y,Ys=R,Js=function(e){return qs.slice(0,e.length)===e},Xs=Js("Bun/")?"BUN":Js("Cloudflare-Workers")?"CLOUDFLARE":Js("Deno/")?"DENO":Js("Node.js/")?"NODE":zs.Bun&&"string"==typeof Bun.version?"BUN":zs.Deno&&"object"==typeof Deno.version?"DENO":"process"===Ys(zs.process)?"NODE":zs.window&&zs.document?"BROWSER":"REST",$s="NODE"===Xs,Qs=js.left;to({target:"Array",proto:!0,forced:!$s&&te>79&&te<83||!Ks("reduce")},{reduce:function(e){var t=arguments.length;return Qs(this,e,t,t>1?arguments[1]:void 0)}});var Zs=js.right;to({target:"Array",proto:!0,forced:!$s&&te>79&&te<83||!Ks("reduceRight")},{reduceRight:function(e){return Zs(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}});var ec=to,tc=Ko,rc=T([].reverse),ic=[1,2];ec({target:"Array",proto:!0,forced:String(ic)===String(ic.reverse())},{reverse:function(){return tc(this)&&(this.length=this.length),rc(this)}});var oc=pe,nc=TypeError,ac=T([].slice),sc=ac,cc=Math.floor,lc=function(e,t){var r=e.length;if(r<8)for(var i,o,n=1;n<r;){for(o=n,i=e[n];o&&t(e[o-1],i)>0;)e[o]=e[--o];o!==n++&&(e[o]=i)}else for(var a=cc(r/2),s=lc(sc(e,0,a),t),c=lc(sc(e,a),t),l=s.length,u=c.length,d=0,h=0;d<l||h<u;)e[d+h]=d<l&&h<u?t(s[d],c[h])<=0?s[d++]:c[h++]:d<l?s[d++]:c[h++];return e},uc=lc,dc=Y.match(/firefox\/(\d+)/i),hc=!!dc&&+dc[1],pc=/MSIE|Trident/.test(Y),mc=Y.match(/AppleWebKit\/(\d+)\./),fc=!!mc&&+mc[1],_c=to,gc=T,Ec=ge,vc=Ve,yc=hi,Tc=function(e,t){if(!delete e[t])throw new nc("Cannot delete property "+oc(t)+" of "+oc(e))},Ic=po,Ac=o,Sc=uc,Rc=Ks,bc=hc,wc=pc,Dc=te,Cc=fc,Nc=[],kc=gc(Nc.sort),Oc=gc(Nc.push),Mc=Ac((function(){Nc.sort(void 0)})),Lc=Ac((function(){Nc.sort(null)})),Pc=Rc("sort"),xc=!Ac((function(){if(Dc)return Dc<70;if(!(bc&&bc>3)){if(wc)return!0;if(Cc)return Cc<603;var e,t,r,i,o="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)Nc.push({k:t+i,v:r})}for(Nc.sort((function(e,t){return t.v-e.v})),i=0;i<Nc.length;i++)t=Nc[i].k.charAt(0),o.charAt(o.length-1)!==t&&(o+=t);return"DGBEFHACIJK"!==o}}));_c({target:"Array",proto:!0,forced:Mc||!Lc||!Pc||!xc},{sort:function(e){void 0!==e&&Ec(e);var t=vc(this);if(xc)return void 0===e?kc(t):kc(t,e);var r,i,o=[],n=yc(t);for(i=0;i<n;i++)i in t&&Oc(o,t[i]);for(Sc(o,function(e){return function(t,r){return void 0===r?-1:void 0===t?1:void 0!==e?+e(t,r)||0:Ic(t)>Ic(r)?1:-1}}(e)),r=yc(o),i=0;i<r;)t[i]=o[i++];for(;i<n;)Tc(t,i++);return t}}),la("flat");var Uc="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView,Vc=$r,Fc=function(e,t,r){for(var i in t)Vc(e,i,t[i],r);return e},Bc=K,Hc=TypeError,Wc=function(e,t){if(Bc(t,e))return e;throw new Hc("Incorrect invocation")},jc=ii,Gc=ui,Kc=RangeError,zc=function(e){if(void 0===e)return 0;var t=jc(e),r=Gc(t);if(t!==r)throw new Kc("Wrong length or index");return r},qc=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1},Yc=4503599627370496,Jc=qc,Xc=function(e){return e+Yc-Yc},$c=Math.abs,Qc=function(e,t,r,i){var o=+e,n=$c(o),a=Jc(o);if(n<i)return a*Xc(n/i/t)*i*t;var s=(1+t/2220446049250313e-31)*n,c=s-(s-n);return c>r||c!=c?Infinity*a:a*c},Zc=Math.fround||function(e){return Qc(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)},el=Array,tl=Math.abs,rl=Math.pow,il=Math.floor,ol=Math.log,nl=Math.LN2,al={pack:function(e,t,r){var i,o,n,a=el(r),s=8*r-t-1,c=(1<<s)-1,l=c>>1,u=23===t?rl(2,-24)-rl(2,-77):0,d=e<0||0===e&&1/e<0?1:0,h=0;for((e=tl(e))!=e||Infinity===e?(o=e!=e?1:0,i=c):(i=il(ol(e)/nl),e*(n=rl(2,-i))<1&&(i--,n*=2),(e+=i+l>=1?u/n:u*rl(2,1-l))*n>=2&&(i++,n/=2),i+l>=c?(o=0,i=c):i+l>=1?(o=(e*n-1)*rl(2,t),i+=l):(o=e*rl(2,l-1)*rl(2,t),i=0));t>=8;)a[h++]=255&o,o/=256,t-=8;for(i=i<<t|o,s+=t;s>0;)a[h++]=255&i,i/=256,s-=8;return a[h-1]|=128*d,a},unpack:function(e,t){var r,i=e.length,o=8*i-t-1,n=(1<<o)-1,a=n>>1,s=o-7,c=i-1,l=e[c--],u=127&l;for(l>>=7;s>0;)u=256*u+e[c--],s-=8;for(r=u&(1<<-s)-1,u>>=-s,s+=t;s>0;)r=256*r+e[c--],s-=8;if(0===u)u=1-a;else{if(u===n)return r?NaN:l?-Infinity:Infinity;r+=rl(2,t),u-=a}return(l?-1:1)*r*rl(2,u-t)}},sl=Ve,cl=si,ll=hi,ul=function(e){for(var t=sl(this),r=ll(t),i=arguments.length,o=cl(i>1?arguments[1]:void 0,r),n=i>2?arguments[2]:void 0,a=void 0===n?r:cl(n,r);a>o;)t[o++]=e;return t},dl=F,hl=H,pl=ts,ml=function(e,t,r){var i,o;return pl&&dl(i=t.constructor)&&i!==r&&hl(o=i.prototype)&&o!==r.prototype&&pl(e,o),e},fl=r,_l=T,gl=n,El=Uc,vl=qt,yl=_o,Tl=Fc,Il=o,Al=Wc,Sl=ii,Rl=ui,bl=zc,wl=Zc,Dl=al,Cl=Sa,Nl=ts,kl=ul,Ol=ac,Ml=ml,Ll=Vi,Pl=Ua,xl=Dr,Ul=er.PROPER,Vl=er.CONFIGURABLE,Fl="ArrayBuffer",Bl="DataView",Hl="prototype",Wl="Wrong index",jl=xl.getterFor(Fl),Gl=xl.getterFor(Bl),Kl=xl.set,zl=fl[Fl],ql=zl,Yl=ql&&ql[Hl],Jl=fl[Bl],Xl=Jl&&Jl[Hl],$l=Object.prototype,Ql=fl.Array,Zl=fl.RangeError,eu=_l(kl),tu=_l([].reverse),ru=Dl.pack,iu=Dl.unpack,ou=function(e){return[255&e]},nu=function(e){return[255&e,e>>8&255]},au=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},su=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},cu=function(e){return ru(wl(e),23,4)},lu=function(e){return ru(e,52,8)},uu=function(e,t,r){yl(e[Hl],t,{configurable:!0,get:function(){return r(this)[t]}})},du=function(e,t,r,i){var o=Gl(e),n=bl(r),a=!!i;if(n+t>o.byteLength)throw new Zl(Wl);var s=o.bytes,c=n+o.byteOffset,l=Ol(s,c,c+t);return a?l:tu(l)},hu=function(e,t,r,i,o,n){var a=Gl(e),s=bl(r),c=i(+o),l=!!n;if(s+t>a.byteLength)throw new Zl(Wl);for(var u=a.bytes,d=s+a.byteOffset,h=0;h<t;h++)u[d+h]=c[l?h:t-h-1]};if(El){var pu=Ul&&zl.name!==Fl;Il((function(){zl(1)}))&&Il((function(){new zl(-1)}))&&!Il((function(){return new zl,new zl(1.5),new zl(NaN),1!==zl.length||pu&&!Vl}))?pu&&Vl&&vl(zl,"name",Fl):((ql=function(e){return Al(this,Yl),Ml(new zl(bl(e)),this,ql)})[Hl]=Yl,Yl.constructor=ql,Ll(ql,zl)),Nl&&Cl(Xl)!==$l&&Nl(Xl,$l);var mu=new Jl(new ql(2)),fu=_l(Xl.setInt8);mu.setInt8(0,2147483648),mu.setInt8(1,2147483649),!mu.getInt8(0)&&mu.getInt8(1)||Tl(Xl,{setInt8:function(e,t){fu(this,e,t<<24>>24)},setUint8:function(e,t){fu(this,e,t<<24>>24)}},{unsafe:!0})}else Yl=(ql=function(e){Al(this,Yl);var t=bl(e);Kl(this,{type:Fl,bytes:eu(Ql(t),0),byteLength:t}),gl||(this.byteLength=t,this.detached=!1)})[Hl],Xl=(Jl=function(e,t,r){Al(this,Xl),Al(e,Yl);var i=jl(e),o=i.byteLength,n=Sl(t);if(n<0||n>o)throw new Zl("Wrong offset");if(n+(r=void 0===r?o-n:Rl(r))>o)throw new Zl("Wrong length");Kl(this,{type:Bl,buffer:e,byteLength:r,byteOffset:n,bytes:i.bytes}),gl||(this.buffer=e,this.byteLength=r,this.byteOffset=n)})[Hl],gl&&(uu(ql,"byteLength",jl),uu(Jl,"buffer",Gl),uu(Jl,"byteLength",Gl),uu(Jl,"byteOffset",Gl)),Tl(Xl,{getInt8:function(e){return du(this,1,e)[0]<<24>>24},getUint8:function(e){return du(this,1,e)[0]},getInt16:function(e){var t=du(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=du(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return su(du(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return su(du(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return iu(du(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return iu(du(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){hu(this,1,e,ou,t)},setUint8:function(e,t){hu(this,1,e,ou,t)},setInt16:function(e,t){hu(this,2,e,nu,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){hu(this,2,e,nu,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){hu(this,4,e,au,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){hu(this,4,e,au,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){hu(this,4,e,cu,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){hu(this,8,e,lu,t,arguments.length>2&&arguments[2])}});Pl(ql,Fl),Pl(Jl,Bl);var _u={ArrayBuffer:ql,DataView:Jl},gu=G,Eu=_o,vu=n,yu=tt("species"),Tu=function(e){var t=gu(e);vu&&t&&!t[yu]&&Eu(t,yu,{configurable:!0,get:function(){return this}})},Iu=Tu,Au="ArrayBuffer",Su=_u[Au];to({global:!0,constructor:!0,forced:r[Au]!==Su},{ArrayBuffer:Su}),Iu(Au);var Ru=to,bu=Jo,wu=o,Du=Mt,Cu=si,Nu=ui,ku=_u.ArrayBuffer,Ou=_u.DataView,Mu=Ou.prototype,Lu=bu(ku.prototype.slice),Pu=bu(Mu.getUint8),xu=bu(Mu.setUint8);Ru({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:wu((function(){return!new ku(2).slice(1,void 0).byteLength}))},{slice:function(e,t){if(Lu&&void 0===t)return Lu(Du(this),e);for(var r=Du(this).byteLength,i=Cu(e,r),o=Cu(void 0===t?r:t,r),n=new ku(Nu(o-i)),a=new Ou(this),s=new Ou(n),c=0;i<o;)xu(s,c++,Pu(a,i++));return n}});var Uu,Vu,Fu,Bu,Hu=vn,Wu=pe,ju=TypeError,Gu=function(e){if(Hu(e))return e;throw new ju(Wu(e)+" is not a constructor")},Ku=Mt,zu=Gu,qu=k,Yu=tt("species"),Ju=function(e,t){var r,i=Ku(e).constructor;return void 0===i||qu(r=Ku(i)[Yu])?t:zu(r)},Xu=a,$u=Function.prototype,Qu=$u.apply,Zu=$u.call,ed="object"==typeof Reflect&&Reflect.apply||(Xu?Zu.bind(Qu):function(){return Zu.apply(Qu,arguments)}),td=TypeError,rd=function(e,t){if(e<t)throw new td("Not enough arguments");return e},id=/(?:ipad|iphone|ipod).*applewebkit/i.test(Y),od=r,nd=ed,ad=Zo,sd=F,cd=He,ld=o,ud=jn,dd=ac,hd=_t,pd=rd,md=id,fd=$s,_d=od.setImmediate,gd=od.clearImmediate,Ed=od.process,vd=od.Dispatch,yd=od.Function,Td=od.MessageChannel,Id=od.String,Ad=0,Sd={},Rd="onreadystatechange";ld((function(){Uu=od.location}));var bd=function(e){if(cd(Sd,e)){var t=Sd[e];delete Sd[e],t()}},wd=function(e){return function(){bd(e)}},Dd=function(e){bd(e.data)},Cd=function(e){od.postMessage(Id(e),Uu.protocol+"//"+Uu.host)};_d&&gd||(_d=function(e){pd(arguments.length,1);var t=sd(e)?e:yd(e),r=dd(arguments,1);return Sd[++Ad]=function(){nd(t,void 0,r)},Vu(Ad),Ad},gd=function(e){delete Sd[e]},fd?Vu=function(e){Ed.nextTick(wd(e))}:vd&&vd.now?Vu=function(e){vd.now(wd(e))}:Td&&!md?(Bu=(Fu=new Td).port2,Fu.port1.onmessage=Dd,Vu=ad(Bu.postMessage,Bu)):od.addEventListener&&sd(od.postMessage)&&!od.importScripts&&Uu&&"file:"!==Uu.protocol&&!ld(Cd)?(Vu=Cd,od.addEventListener("message",Dd,!1)):Vu=Rd in hd("script")?function(e){ud.appendChild(hd("script"))[Rd]=function(){ud.removeChild(this),bd(e)}}:function(e){setTimeout(wd(e),0)});var Nd={set:_d,clear:gd},kd=r,Od=n,Md=Object.getOwnPropertyDescriptor,Ld=function(e){if(!Od)return kd[e];var t=Md(kd,e);return t&&t.value},Pd=function(){this.head=null,this.tail=null};Pd.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 xd,Ud,Vd,Fd,Bd,Hd=Pd,Wd=/ipad|iphone|ipod/i.test(Y)&&"undefined"!=typeof Pebble,jd=/web0s(?!.*chrome)/i.test(Y),Gd=r,Kd=Ld,zd=Zo,qd=Nd.set,Yd=Hd,Jd=id,Xd=Wd,$d=jd,Qd=$s,Zd=Gd.MutationObserver||Gd.WebKitMutationObserver,eh=Gd.document,th=Gd.process,rh=Gd.Promise,ih=Kd("queueMicrotask");if(!ih){var oh=new Yd,nh=function(){var e,t;for(Qd&&(e=th.domain)&&e.exit();t=oh.get();)try{t()}catch(YW){throw oh.head&&xd(),YW}e&&e.enter()};Jd||Qd||$d||!Zd||!eh?!Xd&&rh&&rh.resolve?((Fd=rh.resolve(void 0)).constructor=rh,Bd=zd(Fd.then,Fd),xd=function(){Bd(nh)}):Qd?xd=function(){th.nextTick(nh)}:(qd=zd(qd,Gd),xd=function(){qd(nh)}):(Ud=!0,Vd=eh.createTextNode(""),new Zd(nh).observe(Vd,{characterData:!0}),xd=function(){Vd.data=Ud=!Ud}),ih=function(e){oh.head||xd(),oh.add(e)}}var ah=ih,sh=function(e){try{return{error:!1,value:e()}}catch(YW){return{error:!0,value:YW}}},ch=r.Promise,lh=r,uh=ch,dh=F,hh=qi,ph=sr,mh=tt,fh=Xs,_h=te;uh&&uh.prototype;var gh=mh("species"),Eh=!1,vh=dh(lh.PromiseRejectionEvent),yh=hh("Promise",(function(){var e=ph(uh),t=e!==String(uh);if(!t&&66===_h)return!0;if(!_h||_h<51||!/native code/.test(e)){var r=new uh((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[gh]=i,!(Eh=r.then((function(){}))instanceof i))return!0}return!(t||"BROWSER"!==fh&&"DENO"!==fh||vh)})),Th={CONSTRUCTOR:yh,REJECTION_EVENT:vh,SUBCLASSING:Eh},Ih={},Ah=ge,Sh=TypeError,Rh=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw new Sh("Bad Promise constructor");t=e,r=i})),this.resolve=Ah(t),this.reject=Ah(r)};Ih.f=function(e){return new Rh(e)};var bh,wh,Dh,Ch=to,Nh=$s,kh=r,Oh=l,Mh=$r,Lh=ts,Ph=Ua,xh=Tu,Uh=ge,Vh=F,Fh=H,Bh=Wc,Hh=Ju,Wh=Nd.set,jh=ah,Gh=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(YW){}},Kh=sh,zh=Hd,qh=Dr,Yh=ch,Jh=Ih,Xh="Promise",$h=Th.CONSTRUCTOR,Qh=Th.REJECTION_EVENT,Zh=Th.SUBCLASSING,ep=qh.getterFor(Xh),tp=qh.set,rp=Yh&&Yh.prototype,ip=Yh,op=rp,np=kh.TypeError,ap=kh.document,sp=kh.process,cp=Jh.f,lp=cp,up=!!(ap&&ap.createEvent&&kh.dispatchEvent),dp="unhandledrejection",hp=function(e){var t;return!(!Fh(e)||!Vh(t=e.then))&&t},pp=function(e,t){var r,i,o,n=t.value,a=1===t.state,s=a?e.ok:e.fail,c=e.resolve,l=e.reject,u=e.domain;try{s?(a||(2===t.rejection&&Ep(t),t.rejection=1),!0===s?r=n:(u&&u.enter(),r=s(n),u&&(u.exit(),o=!0)),r===e.promise?l(new np("Promise-chain cycle")):(i=hp(r))?Oh(i,r,c,l):c(r)):l(n)}catch(YW){u&&!o&&u.exit(),l(YW)}},mp=function(e,t){e.notified||(e.notified=!0,jh((function(){for(var r,i=e.reactions;r=i.get();)pp(r,e);e.notified=!1,t&&!e.rejection&&_p(e)})))},fp=function(e,t,r){var i,o;up?((i=ap.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),kh.dispatchEvent(i)):i={promise:t,reason:r},!Qh&&(o=kh["on"+e])?o(i):e===dp&&Gh("Unhandled promise rejection",r)},_p=function(e){Oh(Wh,kh,(function(){var t,r=e.facade,i=e.value;if(gp(e)&&(t=Kh((function(){Nh?sp.emit("unhandledRejection",i,r):fp(dp,r,i)})),e.rejection=Nh||gp(e)?2:1,t.error))throw t.value}))},gp=function(e){return 1!==e.rejection&&!e.parent},Ep=function(e){Oh(Wh,kh,(function(){var t=e.facade;Nh?sp.emit("rejectionHandled",t):fp("rejectionhandled",t,e.value)}))},vp=function(e,t,r){return function(i){e(t,i,r)}},yp=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,mp(e,!0))},Tp=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new np("Promise can't be resolved itself");var i=hp(t);i?jh((function(){var r={done:!1};try{Oh(i,t,vp(Tp,r,e),vp(yp,r,e))}catch(YW){yp(r,YW,e)}})):(e.value=t,e.state=1,mp(e,!1))}catch(YW){yp({done:!1},YW,e)}}};if($h&&(op=(ip=function(e){Bh(this,op),Uh(e),Oh(bh,this);var t=ep(this);try{e(vp(Tp,t),vp(yp,t))}catch(YW){yp(t,YW)}}).prototype,(bh=function(e){tp(this,{type:Xh,done:!1,notified:!1,parent:!1,reactions:new zh,rejection:!1,state:0,value:null})}).prototype=Mh(op,"then",(function(e,t){var r=ep(this),i=cp(Hh(this,ip));return r.parent=!0,i.ok=!Vh(e)||e,i.fail=Vh(t)&&t,i.domain=Nh?sp.domain:void 0,0===r.state?r.reactions.add(i):jh((function(){pp(i,r)})),i.promise})),wh=function(){var e=new bh,t=ep(e);this.promise=e,this.resolve=vp(Tp,t),this.reject=vp(yp,t)},Jh.f=cp=function(e){return e===ip||undefined===e?new wh(e):lp(e)},Vh(Yh)&&rp!==Object.prototype)){Dh=rp.then,Zh||Mh(rp,"then",(function(e,t){var r=this;return new ip((function(e,t){Oh(Dh,r,e,t)})).then(e,t)}),{unsafe:!0});try{delete rp.constructor}catch(YW){}Lh&&Lh(rp,op)}Ch({global:!0,constructor:!0,wrap:!0,forced:$h},{Promise:ip}),Ph(ip,Xh,!1),xh(Xh);var Ip=fa,Ap=tt("iterator"),Sp=Array.prototype,Rp=function(e){return void 0!==e&&(Ip.Array===e||Sp[Ap]===e)},bp=lo,wp=ye,Dp=k,Cp=fa,Np=tt("iterator"),kp=function(e){if(!Dp(e))return wp(e,Np)||wp(e,"@@iterator")||Cp[bp(e)]},Op=l,Mp=ge,Lp=Mt,Pp=pe,xp=kp,Up=TypeError,Vp=function(e,t){var r=arguments.length<2?xp(e):t;if(Mp(r))return Lp(Op(r,e));throw new Up(Pp(e)+" is not iterable")},Fp=l,Bp=Mt,Hp=ye,Wp=function(e,t,r){var i,o;Bp(e);try{if(!(i=Hp(e,"return"))){if("throw"===t)throw r;return r}i=Fp(i,e)}catch(YW){o=!0,i=YW}if("throw"===t)throw r;if(o)throw i;return Bp(i),r},jp=Zo,Gp=l,Kp=Mt,zp=pe,qp=Rp,Yp=hi,Jp=K,Xp=Vp,$p=kp,Qp=Wp,Zp=TypeError,em=function(e,t){this.stopped=e,this.result=t},tm=em.prototype,rm=function(e,t,r){var i,o,n,a,s,c,l,u=r&&r.that,d=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),m=!(!r||!r.INTERRUPTED),f=jp(t,u),_=function(e){return i&&Qp(i,"normal",e),new em(!0,e)},g=function(e){return d?(Kp(e),m?f(e[0],e[1],_):f(e[0],e[1])):m?f(e,_):f(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(o=$p(e)))throw new Zp(zp(e)+" is not iterable");if(qp(o)){for(n=0,a=Yp(e);a>n;n++)if((s=g(e[n]))&&Jp(tm,s))return s;return new em(!1)}i=Xp(e,o)}for(c=h?e.next:i.next;!(l=Gp(c,i)).done;){try{s=g(l.value)}catch(YW){Qp(i,"throw",YW)}if("object"==typeof s&&s&&Jp(tm,s))return s}return new em(!1)},im=tt("iterator"),om=!1;try{var nm=0,am={next:function(){return{done:!!nm++}},return:function(){om=!0}};am[im]=function(){return this},Array.from(am,(function(){throw 2}))}catch(YW){}var sm=function(e,t){try{if(!t&&!om)return!1}catch(YW){return!1}var r=!1;try{var i={};i[im]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(YW){}return r},cm=ch,lm=Th.CONSTRUCTOR||!sm((function(e){cm.all(e).then(void 0,(function(){}))})),um=l,dm=ge,hm=Ih,pm=sh,mm=rm;to({target:"Promise",stat:!0,forced:lm},{all:function(e){var t=this,r=hm.f(t),i=r.resolve,o=r.reject,n=pm((function(){var r=dm(t.resolve),n=[],a=0,s=1;mm(e,(function(e){var c=a++,l=!1;s++,um(r,t,e).then((function(e){l||(l=!0,n[c]=e,--s||i(n))}),o)})),--s||i(n)}));return n.error&&o(n.value),r.promise}});var fm=to,_m=Th.CONSTRUCTOR,gm=ch,Em=G,vm=F,ym=$r,Tm=gm&&gm.prototype;if(fm({target:"Promise",proto:!0,forced:_m,real:!0},{catch:function(e){return this.then(void 0,e)}}),vm(gm)){var Im=Em("Promise").prototype.catch;Tm.catch!==Im&&ym(Tm,"catch",Im,{unsafe:!0})}var Am=l,Sm=ge,Rm=Ih,bm=sh,wm=rm;to({target:"Promise",stat:!0,forced:lm},{race:function(e){var t=this,r=Rm.f(t),i=r.reject,o=bm((function(){var o=Sm(t.resolve);wm(e,(function(e){Am(o,t,e).then(r.resolve,i)}))}));return o.error&&i(o.value),r.promise}});var Dm=Ih;to({target:"Promise",stat:!0,forced:Th.CONSTRUCTOR},{reject:function(e){var t=Dm.f(this);return(0,t.reject)(e),t.promise}});var Cm=Mt,Nm=H,km=Ih,Om=function(e,t){if(Cm(e),Nm(t)&&t.constructor===e)return t;var r=km.f(e);return(0,r.resolve)(t),r.promise},Mm=to,Lm=Th.CONSTRUCTOR,Pm=Om;G("Promise"),Mm({target:"Promise",stat:!0,forced:Lm},{resolve:function(e){return Pm(this,e)}});var xm=to,Um=ch,Vm=o,Fm=G,Bm=F,Hm=Ju,Wm=Om,jm=$r,Gm=Um&&Um.prototype;if(xm({target:"Promise",proto:!0,real:!0,forced:!!Um&&Vm((function(){Gm.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hm(this,Fm("Promise")),r=Bm(e);return this.then(r?function(r){return Wm(t,e()).then((function(){return r}))}:e,r?function(r){return Wm(t,e()).then((function(){throw r}))}:e)}}),Bm(Um)){var Km=Fm("Promise").prototype.finally;Gm.finally!==Km&&jm(Gm,"finally",Km,{unsafe:!0})}var zm=H,qm=R,Ym=tt("match"),Jm=function(e){var t;return zm(e)&&(void 0!==(t=e[Ym])?!!t:"RegExp"===qm(e))},Xm=Mt,$m=function(){var e=Xm(this),t="";return e.hasIndices&&(t+="d"),e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),e.dotAll&&(t+="s"),e.unicode&&(t+="u"),e.unicodeSets&&(t+="v"),e.sticky&&(t+="y"),t},Qm=l,Zm=He,ef=K,tf=$m,rf=RegExp.prototype,of=function(e){var t=e.flags;return void 0!==t||"flags"in rf||Zm(e,"flags")||!ef(rf,e)?t:Qm(tf,e)},nf=o,af=r.RegExp,sf=nf((function(){var e=af("a","y");return e.lastIndex=2,null!==e.exec("abcd")})),cf=sf||nf((function(){return!af("a","y").sticky})),lf={BROKEN_CARET:sf||nf((function(){var e=af("^r","gy");return e.lastIndex=2,null!==e.exec("str")})),MISSED_STICKY:cf,UNSUPPORTED_Y:sf},uf=Dt.f,df=o,hf=r.RegExp,pf=df((function(){var e=hf(".","s");return!(e.dotAll&&e.test("\n")&&"s"===e.flags)})),mf=o,ff=r.RegExp,_f=mf((function(){var e=ff("(?<a>b)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$<a>c")})),gf=n,Ef=r,vf=T,yf=qi,Tf=ml,If=qt,Af=ia,Sf=Qr.f,Rf=K,bf=Jm,wf=po,Df=of,Cf=lf,Nf=function(e,t,r){r in e||uf(e,r,{configurable:!0,get:function(){return t[r]},set:function(e){t[r]=e}})},kf=$r,Of=o,Mf=He,Lf=Dr.enforce,Pf=Tu,xf=pf,Uf=_f,Vf=tt("match"),Ff=Ef.RegExp,Bf=Ff.prototype,Hf=Ef.SyntaxError,Wf=vf(Bf.exec),jf=vf("".charAt),Gf=vf("".replace),Kf=vf("".indexOf),zf=vf("".slice),qf=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,Yf=/a/g,Jf=/a/g,Xf=new Ff(Yf)!==Yf,$f=Cf.MISSED_STICKY,Qf=Cf.UNSUPPORTED_Y,Zf=gf&&(!Xf||$f||xf||Uf||Of((function(){return Jf[Vf]=!1,Ff(Yf)!==Yf||Ff(Jf)===Jf||"/a/i"!==String(Ff(Yf,"i"))})));if(yf("RegExp",Zf)){for(var e_=function(e,t){var r,i,o,n,a,s,c=Rf(Bf,this),l=bf(e),u=void 0===t,d=[],h=e;if(!c&&l&&u&&e.constructor===e_)return e;if((l||Rf(Bf,e))&&(e=e.source,u&&(t=Df(h))),e=void 0===e?"":wf(e),t=void 0===t?"":wf(t),h=e,xf&&"dotAll"in Yf&&(i=!!t&&Kf(t,"s")>-1)&&(t=Gf(t,/s/g,"")),r=t,$f&&"sticky"in Yf&&(o=!!t&&Kf(t,"y")>-1)&&Qf&&(t=Gf(t,/y/g,"")),Uf&&(n=function(e){for(var t,r=e.length,i=0,o="",n=[],a=Af(null),s=!1,c=!1,l=0,u="";i<=r;i++){if("\\"===(t=jf(e,i)))t+=jf(e,++i);else if("]"===t)s=!1;else if(!s)switch(!0){case"["===t:s=!0;break;case"("===t:if(o+=t,"?:"===zf(e,i+1,i+3))continue;Wf(qf,zf(e,i+1))&&(i+=2,c=!0),l++;continue;case">"===t&&c:if(""===u||Mf(a,u))throw new Hf("Invalid capture group name");a[u]=!0,n[n.length]=[u,l],c=!1,u="";continue}c?u+=t:o+=t}return[o,n]}(e),e=n[0],d=n[1]),a=Tf(Ff(e,t),c?this:Bf,e_),(i||o||d.length)&&(s=Lf(a),i&&(s.dotAll=!0,s.raw=e_(function(e){for(var t,r=e.length,i=0,o="",n=!1;i<=r;i++)"\\"!==(t=jf(e,i))?n||"."!==t?("["===t?n=!0:"]"===t&&(n=!1),o+=t):o+="[\\s\\S]":o+=t+jf(e,++i);return o}(e),r)),o&&(s.sticky=!0),d.length&&(s.groups=d)),e!==h)try{If(a,"source",""===h?"(?:)":h)}catch(YW){}return a},t_=Sf(Ff),r_=0;t_.length>r_;)Nf(e_,Ff,t_[r_++]);Bf.constructor=e_,e_.prototype=Bf,kf(Ef,"RegExp",e_,{constructor:!0})}Pf("RegExp");var i_=l,o_=T,n_=po,a_=$m,s_=lf,c_=ia,l_=Dr.get,u_=pf,d_=_f,h_=Pe("native-string-replace",String.prototype.replace),p_=RegExp.prototype.exec,m_=p_,f_=o_("".charAt),__=o_("".indexOf),g_=o_("".replace),E_=o_("".slice),v_=function(){var e=/a/,t=/b*/g;return i_(p_,e,"a"),i_(p_,t,"a"),0!==e.lastIndex||0!==t.lastIndex}(),y_=s_.BROKEN_CARET,T_=void 0!==/()??/.exec("")[1];(v_||T_||y_||u_||d_)&&(m_=function(e){var t,r,i,o,n,a,s,c=this,l=l_(c),u=n_(e),d=l.raw;if(d)return d.lastIndex=c.lastIndex,t=i_(m_,d,u),c.lastIndex=d.lastIndex,t;var h=l.groups,p=y_&&c.sticky,m=i_(a_,c),f=c.source,_=0,g=u;if(p&&(m=g_(m,"y",""),-1===__(m,"g")&&(m+="g"),g=E_(u,c.lastIndex),c.lastIndex>0&&(!c.multiline||c.multiline&&"\n"!==f_(u,c.lastIndex-1))&&(f="(?: "+f+")",g=" "+g,_++),r=new RegExp("^(?:"+f+")",m)),T_&&(r=new RegExp("^"+f+"$(?!\\s)",m)),v_&&(i=c.lastIndex),o=i_(p_,p?r:c,g),p?o?(o.input=E_(o.input,_),o[0]=E_(o[0],_),o.index=c.lastIndex,c.lastIndex+=o[0].length):c.lastIndex=0:v_&&o&&(c.lastIndex=c.global?o.index+o[0].length:i),T_&&o&&o.length>1&&i_(h_,o[0],r,(function(){for(n=1;n<arguments.length-2;n++)void 0===arguments[n]&&(o[n]=void 0)})),o&&h)for(o.groups=a=c_(null),n=0;n<h.length;n++)a[(s=h[n])[0]]=o[s[1]];return o});var I_=m_;to({target:"RegExp",proto:!0,forced:/./.exec!==I_},{exec:I_});var A_=n,S_=_o,R_=$m,b_=o,w_=r.RegExp,D_=w_.prototype,C_=A_&&b_((function(){var e=!0;try{w_(".","d")}catch(YW){e=!1}var t={},r="",i=e?"dgimsy":"gimsy",o=function(e,i){Object.defineProperty(t,e,{get:function(){return r+=i,!0}})},n={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var a in e&&(n.hasIndices="d"),n)o(a,n[a]);return Object.getOwnPropertyDescriptor(D_,"flags").get.call(t)!==i||r!==i}));C_&&S_(D_,"flags",{configurable:!0,get:R_});var N_=ii,k_=po,O_=L,M_=RangeError,L_=T,P_=ui,x_=po,U_=function(e){var t=k_(O_(this)),r="",i=N_(e);if(i<0||Infinity===i)throw new M_("Wrong number of repetitions");for(;i>0;(i>>>=1)&&(t+=t))1&i&&(r+=t);return r},V_=L,F_=L_(U_),B_=L_("".slice),H_=Math.ceil,W_=function(e){return function(t,r,i){var o,n,a=x_(V_(t)),s=P_(r),c=a.length,l=void 0===i?" ":x_(i);return s<=c||""===l?a:((n=F_(l,H_((o=s-c)/l.length))).length>o&&(n=B_(n,0,o)),e?a+n:n+a)}},j_={start:W_(!1),end:W_(!0)},G_=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(Y),K_=j_.start;to({target:"String",proto:!0,forced:G_},{padStart:function(e){return K_(this,e,arguments.length>1?arguments[1]:void 0)}});var z_=l,q_=$r,Y_=I_,J_=o,X_=tt,$_=qt,Q_=X_("species"),Z_=RegExp.prototype,eg=T,tg=ii,rg=po,ig=L,og=eg("".charAt),ng=eg("".charCodeAt),ag=eg("".slice),sg=function(e){return function(t,r){var i,o,n=rg(ig(t)),a=tg(r),s=n.length;return a<0||a>=s?e?"":void 0:(i=ng(n,a))<55296||i>56319||a+1===s||(o=ng(n,a+1))<56320||o>57343?e?og(n,a):i:e?ag(n,a,a+2):o-56320+(i-55296<<10)+65536}},cg={codeAt:sg(!1),charAt:sg(!0)},lg=cg.charAt,ug=T,dg=Ve,hg=Math.floor,pg=ug("".charAt),mg=ug("".replace),fg=ug("".slice),_g=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,gg=/\$([$&'`]|\d{1,2})/g,Eg=function(e,t,r,i,o,n){var a=r+e.length,s=i.length,c=gg;return void 0!==o&&(o=dg(o),c=_g),mg(n,c,(function(n,c){var l;switch(pg(c,0)){case"$":return"$";case"&":return e;case"`":return fg(t,0,r);case"'":return fg(t,a);case"<":l=o[fg(c,1,-1)];break;default:var u=+c;if(0===u)return n;if(u>s){var d=hg(u/10);return 0===d?n:d<=s?void 0===i[d-1]?pg(c,1):i[d-1]+pg(c,1):n}l=i[u-1]}return void 0===l?"":l}))},vg=l,yg=Mt,Tg=F,Ig=R,Ag=I_,Sg=TypeError,Rg=ed,bg=l,wg=T,Dg=function(e,t,r,i){var o=X_(e),n=!J_((function(){var t={};return t[o]=function(){return 7},7!==""[e](t)})),a=n&&!J_((function(){var t=!1,r=/a/;return"split"===e&&((r={}).constructor={},r.constructor[Q_]=function(){return r},r.flags="",r[o]=/./[o]),r.exec=function(){return t=!0,null},r[o](""),!t}));if(!n||!a||r){var s=/./[o],c=t(o,""[e],(function(e,t,r,i,o){var a=t.exec;return a===Y_||a===Z_.exec?n&&!o?{done:!0,value:z_(s,t,r,i)}:{done:!0,value:z_(e,r,t,i)}:{done:!1}}));q_(String.prototype,e,c[0]),q_(Z_,o,c[1])}i&&$_(Z_[o],"sham",!0)},Cg=o,Ng=Mt,kg=F,Og=k,Mg=ii,Lg=ui,Pg=po,xg=L,Ug=function(e,t,r){return t+(r?lg(e,t).length:1)},Vg=ye,Fg=Eg,Bg=function(e,t){var r=e.exec;if(Tg(r)){var i=vg(r,e,t);return null!==i&&yg(i),i}if("RegExp"===Ig(e))return vg(Ag,e,t);throw new Sg("RegExp#exec called on incompatible receiver")},Hg=tt("replace"),Wg=Math.max,jg=Math.min,Gg=wg([].concat),Kg=wg([].push),zg=wg("".indexOf),qg=wg("".slice),Yg="$0"==="a".replace(/./,"$0"),Jg=!!/./[Hg]&&""===/./[Hg]("a","$0");Dg("replace",(function(e,t,r){var i=Jg?"$":"$0";return[function(e,r){var i=xg(this),o=Og(e)?void 0:Vg(e,Hg);return o?bg(o,e,i,r):bg(t,Pg(i),e,r)},function(e,o){var n=Ng(this),a=Pg(e);if("string"==typeof o&&-1===zg(o,i)&&-1===zg(o,"$<")){var s=r(t,n,a,o);if(s.done)return s.value}var c=kg(o);c||(o=Pg(o));var l,u=n.global;u&&(l=n.unicode,n.lastIndex=0);for(var d,h=[];null!==(d=Bg(n,a))&&(Kg(h,d),u);){""===Pg(d[0])&&(n.lastIndex=Ug(a,Lg(n.lastIndex),l))}for(var p,m="",f=0,_=0;_<h.length;_++){for(var g,E=Pg((d=h[_])[0]),v=Wg(jg(Mg(d.index),a.length),0),y=[],T=1;T<d.length;T++)Kg(y,void 0===(p=d[T])?p:String(p));var I=d.groups;if(c){var A=Gg([E],y,v,a);void 0!==I&&Kg(A,I),g=Pg(Rg(o,void 0,A))}else g=Fg(E,a,v,y,I,o);v>=f&&(m+=qg(a,f,v)+g,f=v+E.length)}return m+qg(a,f)}]}),!!Cg((function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$<a>")}))||!Yg||Jg);var Xg="\t\n\v\f\r \u2028\u2029\ufeff",$g=L,Qg=po,Zg=Xg,eE=T("".replace),tE=RegExp("^["+Zg+"]+"),rE=RegExp("(^|[^"+Zg+"])["+Zg+"]+$"),iE=function(e){return function(t){var r=Qg($g(t));return 1&e&&(r=eE(r,tE,"")),2&e&&(r=eE(r,rE,"$1")),r}},oE={start:iE(1),end:iE(2),trim:iE(3)},nE=er.PROPER,aE=o,sE=Xg,cE=oE.trim;to({target:"String",proto:!0,forced:function(e){return aE((function(){return!!sE[e]()||"
"!=="
"[e]()||nE&&sE[e].name!==e}))}("trim")},{trim:function(){return cE(this)}});var lE,uE,dE,hE={exports:{}},pE=Uc,mE=n,fE=r,_E=F,gE=H,EE=He,vE=lo,yE=pe,TE=qt,IE=$r,AE=_o,SE=K,RE=Sa,bE=ts,wE=tt,DE=ze,CE=Dr.enforce,NE=Dr.get,kE=fE.Int8Array,OE=kE&&kE.prototype,ME=fE.Uint8ClampedArray,LE=ME&&ME.prototype,PE=kE&&RE(kE),xE=OE&&RE(OE),UE=Object.prototype,VE=fE.TypeError,FE=wE("toStringTag"),BE=DE("TYPED_ARRAY_TAG"),HE="TypedArrayConstructor",WE=pE&&!!bE&&"Opera"!==vE(fE.opera),jE=!1,GE={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},KE={BigInt64Array:8,BigUint64Array:8},zE=function(e){var t=RE(e);if(gE(t)){var r=NE(t);return r&&EE(r,HE)?r[HE]:zE(t)}},qE=function(e){if(!gE(e))return!1;var t=vE(e);return EE(GE,t)||EE(KE,t)};for(lE in GE)(dE=(uE=fE[lE])&&uE.prototype)?CE(dE)[HE]=uE:WE=!1;for(lE in KE)(dE=(uE=fE[lE])&&uE.prototype)&&(CE(dE)[HE]=uE);if((!WE||!_E(PE)||PE===Function.prototype)&&(PE=function(){throw new VE("Incorrect invocation")},WE))for(lE in GE)fE[lE]&&bE(fE[lE],PE);if((!WE||!xE||xE===UE)&&(xE=PE.prototype,WE))for(lE in GE)fE[lE]&&bE(fE[lE].prototype,xE);if(WE&&RE(LE)!==xE&&bE(LE,xE),mE&&!EE(xE,FE))for(lE in jE=!0,AE(xE,FE,{configurable:!0,get:function(){return gE(this)?this[BE]:void 0}}),GE)fE[lE]&&TE(fE[lE],BE,lE);var YE={NATIVE_ARRAY_BUFFER_VIEWS:WE,TYPED_ARRAY_TAG:jE&&BE,aTypedArray:function(e){if(qE(e))return e;throw new VE("Target is not a typed array")},aTypedArrayConstructor:function(e){if(_E(e)&&(!bE||SE(PE,e)))return e;throw new VE(yE(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(mE){if(r)for(var o in GE){var n=fE[o];if(n&&EE(n.prototype,e))try{delete n.prototype[e]}catch(YW){try{n.prototype[e]=t}catch(a){}}}xE[e]&&!r||IE(xE,e,r?t:WE&&OE[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,o;if(mE){if(bE){if(r)for(i in GE)if((o=fE[i])&&EE(o,e))try{delete o[e]}catch(YW){}if(PE[e]&&!r)return;try{return IE(PE,e,r?t:WE&&PE[e]||t)}catch(YW){}}for(i in GE)!(o=fE[i])||o[e]&&!r||IE(o,e,t)}},getTypedArrayConstructor:zE,isView:function(e){if(!gE(e))return!1;var t=vE(e);return"DataView"===t||EE(GE,t)||EE(KE,t)},isTypedArray:qE,TypedArray:PE,TypedArrayPrototype:xE},JE=r,XE=o,$E=sm,QE=YE.NATIVE_ARRAY_BUFFER_VIEWS,ZE=JE.ArrayBuffer,ev=JE.Int8Array,tv=!QE||!XE((function(){ev(1)}))||!XE((function(){new ev(-1)}))||!$E((function(e){new ev,new ev(null),new ev(1.5),new ev(e)}),!0)||XE((function(){return 1!==new ev(new ZE(2),1,void 0).length})),rv=H,iv=Math.floor,ov=Number.isInteger||function(e){return!rv(e)&&isFinite(e)&&iv(e)===e},nv=ii,av=RangeError,sv=function(e){var t=nv(e);if(t<0)throw new av("The argument can't be less than 0");return t},cv=RangeError,lv=function(e,t){var r=sv(e);if(r%t)throw new cv("Wrong offset");return r},uv=Math.round,dv=lo,hv=lt,pv=TypeError,mv=function(e){var t=hv(e,"number");if("number"==typeof t)throw new pv("Can't convert number to bigint");return BigInt(t)},fv=Zo,_v=l,gv=Gu,Ev=Ve,vv=hi,yv=Vp,Tv=kp,Iv=Rp,Av=function(e){var t=dv(e);return"BigInt64Array"===t||"BigUint64Array"===t},Sv=YE.aTypedArrayConstructor,Rv=mv,bv=Zo,wv=N,Dv=Ve,Cv=hi,Nv=bn,kv=T([].push),Ov=function(e){var t=1===e,r=2===e,i=3===e,o=4===e,n=6===e,a=7===e,s=5===e||n;return function(c,l,u,d){for(var h,p,m=Dv(c),f=wv(m),_=Cv(f),g=bv(l,u),E=0,v=d||Nv,y=t?v(c,_):r||a?v(c,0):void 0;_>E;E++)if((s||E in f)&&(p=g(h=f[E],E,m),e))if(t)y[E]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return E;case 2:kv(y,h)}else switch(e){case 4:return!1;case 7:kv(y,h)}return n?-1:i||o?o:y}},Mv={forEach:Ov(0),map:Ov(1),filter:Ov(2),some:Ov(3),every:Ov(4),find:Ov(5),findIndex:Ov(6),filterReject:Ov(7)},Lv=hi,Pv=to,xv=r,Uv=l,Vv=n,Fv=tv,Bv=YE,Hv=_u,Wv=Wc,jv=_,Gv=qt,Kv=ov,zv=ui,qv=zc,Yv=lv,Jv=function(e){var t=uv(e);return t<0?0:t>255?255:255&t},Xv=ht,$v=He,Qv=lo,Zv=H,ey=de,ty=ia,ry=K,iy=ts,oy=Qr.f,ny=function(e){var t,r,i,o,n,a,s,c,l=gv(this),u=Ev(e),d=arguments.length,h=d>1?arguments[1]:void 0,p=void 0!==h,m=Tv(u);if(m&&!Iv(m))for(c=(s=yv(u,m)).next,u=[];!(a=_v(c,s)).done;)u.push(a.value);for(p&&d>2&&(h=fv(h,arguments[2])),r=vv(u),i=new(Sv(l))(r),o=Av(i),t=0;r>t;t++)n=p?h(u[t],t):u[t],i[t]=o?Rv(n):+n;return i},ay=Mv.forEach,sy=Tu,cy=_o,ly=Dt,uy=i,dy=function(e,t,r){for(var i=0,o=arguments.length>2?r:Lv(t),n=new e(o);o>i;)n[i]=t[i++];return n},hy=ml,py=Dr.get,my=Dr.set,fy=Dr.enforce,_y=ly.f,gy=uy.f,Ey=xv.RangeError,vy=Hv.ArrayBuffer,yy=vy.prototype,Ty=Hv.DataView,Iy=Bv.NATIVE_ARRAY_BUFFER_VIEWS,Ay=Bv.TYPED_ARRAY_TAG,Sy=Bv.TypedArray,Ry=Bv.TypedArrayPrototype,by=Bv.isTypedArray,wy="BYTES_PER_ELEMENT",Dy="Wrong length",Cy=function(e,t){cy(e,t,{configurable:!0,get:function(){return py(this)[t]}})},Ny=function(e){var t;return ry(yy,e)||"ArrayBuffer"===(t=Qv(e))||"SharedArrayBuffer"===t},ky=function(e,t){return by(e)&&!ey(t)&&t in e&&Kv(+t)&&t>=0},Oy=function(e,t){return t=Xv(t),ky(e,t)?jv(2,e[t]):gy(e,t)},My=function(e,t,r){return t=Xv(t),!(ky(e,t)&&Zv(r)&&$v(r,"value"))||$v(r,"get")||$v(r,"set")||r.configurable||$v(r,"writable")&&!r.writable||$v(r,"enumerable")&&!r.enumerable?_y(e,t,r):(e[t]=r.value,e)};Vv?(Iy||(uy.f=Oy,ly.f=My,Cy(Ry,"buffer"),Cy(Ry,"byteOffset"),Cy(Ry,"byteLength"),Cy(Ry,"length")),Pv({target:"Object",stat:!0,forced:!Iy},{getOwnPropertyDescriptor:Oy,defineProperty:My}),hE.exports=function(e,t,r){var i=e.match(/\d+/)[0]/8,o=e+(r?"Clamped":"")+"Array",n="get"+e,a="set"+e,s=xv[o],c=s,l=c&&c.prototype,u={},d=function(e,t){_y(e,t,{get:function(){return function(e,t){var r=py(e);return r.view[n](t*i+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,o){var n=py(e);n.view[a](t*i+n.byteOffset,r?Jv(o):o,!0)}(this,t,e)},enumerable:!0})};Iy?Fv&&(c=t((function(e,t,r,o){return Wv(e,l),hy(Zv(t)?Ny(t)?void 0!==o?new s(t,Yv(r,i),o):void 0!==r?new s(t,Yv(r,i)):new s(t):by(t)?dy(c,t):Uv(ny,c,t):new s(qv(t)),e,c)})),iy&&iy(c,Sy),ay(oy(s),(function(e){e in c||Gv(c,e,s[e])})),c.prototype=l):(c=t((function(e,t,r,o){Wv(e,l);var n,a,s,u=0,h=0;if(Zv(t)){if(!Ny(t))return by(t)?dy(c,t):Uv(ny,c,t);n=t,h=Yv(r,i);var p=t.byteLength;if(void 0===o){if(p%i)throw new Ey(Dy);if((a=p-h)<0)throw new Ey(Dy)}else if((a=zv(o)*i)+h>p)throw new Ey(Dy);s=a/i}else s=qv(t),n=new vy(a=s*i);for(my(e,{buffer:n,byteOffset:h,byteLength:a,length:s,view:new Ty(n)});u<s;)d(e,u++)})),iy&&iy(c,Sy),l=c.prototype=ty(Ry)),l.constructor!==c&&Gv(l,"constructor",c),fy(l).TypedArrayConstructor=c,Ay&&Gv(l,Ay,o);var h=c!==s;u[o]=c,Pv({global:!0,constructor:!0,forced:h,sham:!Iy},u),wy in c||Gv(c,wy,i),wy in l||Gv(l,wy,i),sy(o)}):hE.exports=function(){};var Ly=hE.exports;Ly("Float32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Float64",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Int8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Int16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Int32",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Uint8",(function(e){return function(t,r,i){return e(this,t,r,i)}}),!0),Ly("Uint16",(function(e){return function(t,r,i){return e(this,t,r,i)}})),Ly("Uint32",(function(e){return function(t,r,i){return e(this,t,r,i)}}));var Py=ul,xy=mv,Uy=lo,Vy=l,Fy=o,By=YE.aTypedArray,Hy=YE.exportTypedArrayMethod,Wy=T("".slice);Hy("fill",(function(e){var t=arguments.length;By(this);var r="Big"===Wy(Uy(this),0,3)?xy(e):+e;return Vy(Py,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)}),Fy((function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e})));var jy=r,Gy=l,Ky=YE,zy=hi,qy=lv,Yy=Ve,Jy=o,Xy=jy.RangeError,$y=jy.Int8Array,Qy=$y&&$y.prototype,Zy=Qy&&Qy.set,eT=Ky.aTypedArray,tT=Ky.exportTypedArrayMethod,rT=!Jy((function(){var e=new Uint8ClampedArray(2);return Gy(Zy,e,{length:1,0:3},1),3!==e[1]})),iT=rT&&Ky.NATIVE_ARRAY_BUFFER_VIEWS&&Jy((function(){var e=new $y(2);return e.set(1),e.set("2",1),0!==e[0]||2!==e[1]}));tT("set",(function(e){eT(this);var t=qy(arguments.length>1?arguments[1]:void 0,1),r=Yy(e);if(rT)return Gy(Zy,this,r,t);var i=this.length,o=zy(r),n=0;if(o+t>i)throw new Xy("Wrong length");for(;n<o;)this[t+n]=r[n++]}),!rT||iT);var oT=Jo,nT=o,aT=ge,sT=uc,cT=hc,lT=pc,uT=te,dT=fc,hT=YE.aTypedArray,pT=YE.exportTypedArrayMethod,mT=r.Uint16Array,fT=mT&&oT(mT.prototype.sort),_T=!(!fT||nT((function(){fT(new mT(2),null)}))&&nT((function(){fT(new mT(2),{})}))),gT=!!fT&&!nT((function(){if(uT)return uT<74;if(cT)return cT<67;if(lT)return!0;if(dT)return dT<602;var e,t,r=new mT(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(fT(r,(function(e,t){return(e/4|0)-(t/4|0)})),e=0;e<516;e++)if(r[e]!==i[e])return!0}));pT("sort",(function(e){return void 0!==e&&aT(e),gT?fT(this,e):sT(hT(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))}),!gT||_T);var ET=to,vT=l,yT=T,TT=L,IT=F,AT=k,ST=Jm,RT=po,bT=ye,wT=of,DT=Eg,CT=tt("replace"),NT=TypeError,kT=yT("".indexOf);yT("".replace);var OT=yT("".slice),MT=Math.max;ET({target:"String",proto:!0},{replaceAll:function(e,t){var r,i,o,n,a,s,c,l,u,d=TT(this),h=0,p="";if(!AT(e)){if(ST(e)&&(r=RT(TT(wT(e))),!~kT(r,"g")))throw new NT("`.replaceAll` does not allow non-global regexes");if(i=bT(e,CT))return vT(i,e,d,t)}for(o=RT(d),n=RT(e),(a=IT(t))||(t=RT(t)),s=n.length,c=MT(1,s),l=kT(o,n);-1!==l;)u=a?RT(t(n,l,o)):DT(n,o,l,[],void 0,t),p+=OT(o,h,l)+u,h=l+s,l=l+c>o.length?-1:kT(o,n,l+c);return h<o.length&&(p+=OT(o,h)),p}});var LT={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},PT=_t("span").classList,xT=PT&&PT.constructor&&PT.constructor.prototype,UT=xT===Object.prototype?void 0:xT,VT=Mv.forEach,FT=Ks("forEach")?[].forEach:function(e){return VT(this,e,arguments.length>1?arguments[1]:void 0)},BT=r,HT=LT,WT=UT,jT=FT,GT=qt,KT=function(e){if(e&&e.forEach!==jT)try{GT(e,"forEach",jT)}catch(YW){e.forEach=jT}};for(var zT in HT)HT[zT]&&KT(BT[zT]&&BT[zT].prototype);KT(WT);var qT=r,YT=LT,JT=UT,XT=Ls,$T=qt,QT=Ua,ZT=tt("iterator"),eI=XT.values,tI=function(e,t){if(e){if(e[ZT]!==eI)try{$T(e,ZT,eI)}catch(YW){e[ZT]=eI}if(QT(e,t,!0),YT[t])for(var r in XT)if(e[r]!==XT[r])try{$T(e,r,XT[r])}catch(YW){e[r]=XT[r]}}};for(var rI in YT)tI(qT[rI]&&qT[rI].prototype,rI);tI(JT,"DOMTokenList");var iI=cg.charAt,oI=po,nI=Dr,aI=Ts,sI=Is,cI="String Iterator",lI=nI.set,uI=nI.getterFor(cI);aI(String,"String",(function(e){lI(this,{type:cI,string:oI(e),index:0})}),(function(){var e,t=uI(this),r=t.string,i=t.index;return i>=r.length?sI(void 0,!0):(e=iI(r,i),t.index+=e.length,sI(e,!1))}));var dI=o,hI=n,pI=tt("iterator"),mI=!dI((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&&!hI||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[pI]||"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})),fI=n,_I=T,gI=l,EI=o,vI=Pn,yI=wi,TI=u,II=Ve,AI=N,SI=Object.assign,RI=Object.defineProperty,bI=_I([].concat),wI=!SI||EI((function(){if(fI&&1!==SI({b:1},SI(RI({},"a",{enumerable:!0,get:function(){RI(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!==SI({},e)[r]||vI(SI({},t)).join("")!==i}))?function(e,t){for(var r=II(e),i=arguments.length,o=1,n=yI.f,a=TI.f;i>o;)for(var s,c=AI(arguments[o++]),l=n?bI(vI(c),n(c)):vI(c),u=l.length,d=0;u>d;)s=l[d++],fI&&!gI(a,c,s)||(r[s]=c[s]);return r}:SI,DI=Mt,CI=Wp,NI=n,kI=Dt,OI=_,MI=Zo,LI=l,PI=Ve,xI=function(e,t,r,i){try{return i?t(DI(r)[0],r[1]):t(r)}catch(YW){CI(e,"throw",YW)}},UI=Rp,VI=vn,FI=hi,BI=function(e,t,r){NI?kI.f(e,t,OI(0,r)):e[t]=r},HI=Vp,WI=kp,jI=Array,GI=T,KI=2147483647,zI=/[^\0-\u007E]/,qI=/[.\u3002\uFF0E\uFF61]/g,YI="Overflow: input needs wider integers to process",JI=RangeError,XI=GI(qI.exec),$I=Math.floor,QI=String.fromCharCode,ZI=GI("".charCodeAt),eA=GI([].join),tA=GI([].push),rA=GI("".replace),iA=GI("".split),oA=GI("".toLowerCase),nA=function(e){return e+22+75*(e<26)},aA=function(e,t,r){var i=0;for(e=r?$I(e/700):e>>1,e+=$I(e/t);e>455;)e=$I(e/35),i+=36;return $I(i+36*e/(e+38))},sA=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r<i;){var o=ZI(e,r++);if(o>=55296&&o<=56319&&r<i){var n=ZI(e,r++);56320==(64512&n)?tA(t,((1023&o)<<10)+(1023&n)+65536):(tA(t,o),r--)}else tA(t,o)}return t}(e);var r,i,o=e.length,n=128,a=0,s=72;for(r=0;r<e.length;r++)(i=e[r])<128&&tA(t,QI(i));var c=t.length,l=c;for(c&&tA(t,"-");l<o;){var u=KI;for(r=0;r<e.length;r++)(i=e[r])>=n&&i<u&&(u=i);var d=l+1;if(u-n>$I((KI-a)/d))throw new JI(YI);for(a+=(u-n)*d,n=u,r=0;r<e.length;r++){if((i=e[r])<n&&++a>KI)throw new JI(YI);if(i===n){for(var h=a,p=36;;){var m=p<=s?1:p>=s+26?26:p-s;if(h<m)break;var f=h-m,_=36-m;tA(t,QI(nA(m+f%_))),h=$I(f/_),p+=36}tA(t,QI(nA(h))),s=aA(a,d,l===c),a=0,l++}}a++,n++}return eA(t,"")},cA=to,lA=T,uA=si,dA=RangeError,hA=String.fromCharCode,pA=String.fromCodePoint,mA=lA([].join);cA({target:"String",stat:!0,arity:1,forced:!!pA&&1!==pA.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,o=0;i>o;){if(t=+arguments[o++],uA(t,1114111)!==t)throw new dA(t+" is not a valid code point");r[o]=t<65536?hA(t):hA(55296+((t-=65536)>>10),t%1024+56320)}return mA(r,"")}});var fA=to,_A=r,gA=Ld,EA=G,vA=l,yA=T,TA=n,IA=mI,AA=$r,SA=_o,RA=Fc,bA=Ua,wA=Ga,DA=Dr,CA=Wc,NA=F,kA=He,OA=Zo,MA=lo,LA=Mt,PA=H,xA=po,UA=ia,VA=_,FA=Vp,BA=kp,HA=Is,WA=rd,jA=uc,GA=tt("iterator"),KA="URLSearchParams",zA=KA+"Iterator",qA=DA.set,YA=DA.getterFor(KA),JA=DA.getterFor(zA),XA=gA("fetch"),$A=gA("Request"),QA=gA("Headers"),ZA=$A&&$A.prototype,eS=QA&&QA.prototype,tS=_A.TypeError,rS=_A.encodeURIComponent,iS=String.fromCharCode,oS=EA("String","fromCodePoint"),nS=parseInt,aS=yA("".charAt),sS=yA([].join),cS=yA([].push),lS=yA("".replace),uS=yA([].shift),dS=yA([].splice),hS=yA("".split),pS=yA("".slice),mS=yA(/./.exec),fS=/\+/g,_S=/^[0-9a-f]+$/i,gS=function(e,t){var r=pS(e,t,t+2);return mS(_S,r)?nS(r,16):NaN},ES=function(e){for(var t=0,r=128;r>0&&e&r;r>>=1)t++;return t},vS=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},yS=function(e){for(var t=(e=lS(e,fS," ")).length,r="",i=0;i<t;){var o=aS(e,i);if("%"===o){if("%"===aS(e,i+1)||i+3>t){r+="%",i++;continue}var n=gS(e,i+1);if(n!=n){r+=o,i++;continue}i+=2;var a=ES(n);if(0===a)o=iS(n);else{if(1===a||a>4){r+="�",i++;continue}for(var s=[n],c=1;c<a&&!(++i+3>t||"%"!==aS(e,i));){var l=gS(e,i+1);if(l!=l){i+=3;break}if(l>191||l<128)break;cS(s,l),i+=2,c++}if(s.length!==a){r+="�";continue}var u=vS(s);null===u?r+="�":o=oS(u)}}r+=o,i++}return r},TS=/[!'()~]|%20/g,IS={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},AS=function(e){return IS[e]},SS=function(e){return lS(rS(e),TS,AS)},RS=wA((function(e,t){qA(this,{type:zA,target:YA(e).entries,index:0,kind:t})}),KA,(function(){var e=JA(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,HA(void 0,!0);var i=t[r];switch(e.kind){case"keys":return HA(i.key,!1);case"values":return HA(i.value,!1)}return HA([i.key,i.value],!1)}),!0),bS=function(e){this.entries=[],this.url=null,void 0!==e&&(PA(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===aS(e,0)?pS(e,1):e:xA(e)))};bS.prototype={type:KA,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,o,n,a,s,c=this.entries,l=BA(e);if(l)for(r=(t=FA(e,l)).next;!(i=vA(r,t)).done;){if(n=(o=FA(LA(i.value))).next,(a=vA(n,o)).done||(s=vA(n,o)).done||!vA(n,o).done)throw new tS("Expected sequence with length 2");cS(c,{key:xA(a.value),value:xA(s.value)})}else for(var u in e)kA(e,u)&&cS(c,{key:u,value:xA(e[u])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,o=hS(e,"&"),n=0;n<o.length;)(t=o[n++]).length&&(r=hS(t,"="),cS(i,{key:yS(uS(r)),value:yS(sS(r,"="))}))},serialize:function(){for(var e,t=this.entries,r=[],i=0;i<t.length;)e=t[i++],cS(r,SS(e.key)+"="+SS(e.value));return sS(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var wS=function(){CA(this,DS);var e=qA(this,new bS(arguments.length>0?arguments[0]:void 0));TA||(this.size=e.entries.length)},DS=wS.prototype;if(RA(DS,{append:function(e,t){var r=YA(this);WA(arguments.length,2),cS(r.entries,{key:xA(e),value:xA(t)}),TA||this.length++,r.updateURL()},delete:function(e){for(var t=YA(this),r=WA(arguments.length,1),i=t.entries,o=xA(e),n=r<2?void 0:arguments[1],a=void 0===n?n:xA(n),s=0;s<i.length;){var c=i[s];if(c.key!==o||void 0!==a&&c.value!==a)s++;else if(dS(i,s,1),void 0!==a)break}TA||(this.size=i.length),t.updateURL()},get:function(e){var t=YA(this).entries;WA(arguments.length,1);for(var r=xA(e),i=0;i<t.length;i++)if(t[i].key===r)return t[i].value;return null},getAll:function(e){var t=YA(this).entries;WA(arguments.length,1);for(var r=xA(e),i=[],o=0;o<t.length;o++)t[o].key===r&&cS(i,t[o].value);return i},has:function(e){for(var t=YA(this).entries,r=WA(arguments.length,1),i=xA(e),o=r<2?void 0:arguments[1],n=void 0===o?o:xA(o),a=0;a<t.length;){var s=t[a++];if(s.key===i&&(void 0===n||s.value===n))return!0}return!1},set:function(e,t){var r=YA(this);WA(arguments.length,1);for(var i,o=r.entries,n=!1,a=xA(e),s=xA(t),c=0;c<o.length;c++)(i=o[c]).key===a&&(n?dS(o,c--,1):(n=!0,i.value=s));n||cS(o,{key:a,value:s}),TA||(this.size=o.length),r.updateURL()},sort:function(){var e=YA(this);jA(e.entries,(function(e,t){return e.key>t.key?1:-1})),e.updateURL()},forEach:function(e){for(var t,r=YA(this).entries,i=OA(e,arguments.length>1?arguments[1]:void 0),o=0;o<r.length;)i((t=r[o++]).value,t.key,this)},keys:function(){return new RS(this,"keys")},values:function(){return new RS(this,"values")},entries:function(){return new RS(this,"entries")}},{enumerable:!0}),AA(DS,GA,DS.entries,{name:"entries"}),AA(DS,"toString",(function(){return YA(this).serialize()}),{enumerable:!0}),TA&&SA(DS,"size",{get:function(){return YA(this).entries.length},configurable:!0,enumerable:!0}),bA(wS,KA),fA({global:!0,constructor:!0,forced:!IA},{URLSearchParams:wS}),!IA&&NA(QA)){var CS=yA(eS.has),NS=yA(eS.set),kS=function(e){if(PA(e)){var t,r=e.body;if(MA(r)===KA)return t=e.headers?new QA(e.headers):new QA,CS(t,"content-type")||NS(t,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),UA(e,{body:VA(0,xA(r)),headers:VA(0,t)})}return e};if(NA(XA)&&fA({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return XA(e,arguments.length>1?kS(arguments[1]):{})}}),NA($A)){var OS=function(e){return CA(this,ZA),new $A(e,arguments.length>1?kS(arguments[1]):{})};ZA.constructor=OS,OS.prototype=ZA,fA({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:OS})}}var MS,LS=to,PS=n,xS=mI,US=r,VS=Zo,FS=T,BS=$r,HS=_o,WS=Wc,jS=He,GS=wI,KS=function(e){var t=PI(e),r=VI(this),i=arguments.length,o=i>1?arguments[1]:void 0,n=void 0!==o;n&&(o=MI(o,i>2?arguments[2]:void 0));var a,s,c,l,u,d,h=WI(t),p=0;if(!h||this===jI&&UI(h))for(a=FI(t),s=r?new this(a):jI(a);a>p;p++)d=n?o(t[p],p):t[p],BI(s,p,d);else for(s=r?new this:[],u=(l=HI(t,h)).next;!(c=LI(u,l)).done;p++)d=n?xI(l,o,[c.value,p],!0):c.value,BI(s,p,d);return s.length=p,s},zS=ac,qS=cg.codeAt,YS=function(e){var t,r,i=[],o=iA(rA(oA(e),qI,"."),".");for(t=0;t<o.length;t++)r=o[t],tA(i,XI(zI,r)?"xn--"+sA(r):r);return eA(i,".")},JS=po,XS=Ua,$S=rd,QS={URLSearchParams:wS,getState:YA},ZS=Dr,eR=ZS.set,tR=ZS.getterFor("URL"),rR=QS.URLSearchParams,iR=QS.getState,oR=US.URL,nR=US.TypeError,aR=US.parseInt,sR=Math.floor,cR=Math.pow,lR=FS("".charAt),uR=FS(/./.exec),dR=FS([].join),hR=FS(1..toString),pR=FS([].pop),mR=FS([].push),fR=FS("".replace),_R=FS([].shift),gR=FS("".split),ER=FS("".slice),vR=FS("".toLowerCase),yR=FS([].unshift),TR="Invalid scheme",IR="Invalid host",AR="Invalid port",SR=/[a-z]/i,RR=/[\d+-.a-z]/i,bR=/\d/,wR=/^0x/i,DR=/^[0-7]+$/,CR=/^\d+$/,NR=/^[\da-f]+$/i,kR=/[\0\t\n\r #%/:<>?@[\\\]^|]/,OR=/[\0\t\n\r #/:<>?@[\\\]^|]/,MR=/^[\u0000-\u0020]+/,LR=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,PR=/[\t\n\r]/g,xR=function(e){var t,r,i,o;if("number"==typeof e){for(t=[],r=0;r<4;r++)yR(t,e%256),e=sR(e/256);return dR(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,o=0,n=0;n<8;n++)0!==e[n]?(o>r&&(t=i,r=o),i=null,o=0):(null===i&&(i=n),++o);return o>r?i:t}(e),r=0;r<8;r++)o&&0===e[r]||(o&&(o=!1),i===r?(t+=r?":":"::",o=!0):(t+=hR(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},UR={},VR=GS({},UR,{" ":1,'"':1,"<":1,">":1,"`":1}),FR=GS({},VR,{"#":1,"?":1,"{":1,"}":1}),BR=GS({},FR,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),HR=function(e,t){var r=qS(e,0);return r>32&&r<127&&!jS(t,e)?e:encodeURIComponent(e)},WR={ftp:21,file:null,http:80,https:443,ws:80,wss:443},jR=function(e,t){var r;return 2===e.length&&uR(SR,lR(e,0))&&(":"===(r=lR(e,1))||!t&&"|"===r)},GR=function(e){var t;return e.length>1&&jR(ER(e,0,2))&&(2===e.length||"/"===(t=lR(e,2))||"\\"===t||"?"===t||"#"===t)},KR=function(e){return"."===e||"%2e"===vR(e)},zR={},qR={},YR={},JR={},XR={},$R={},QR={},ZR={},eb={},tb={},rb={},ib={},ob={},nb={},ab={},sb={},cb={},lb={},ub={},db={},hb={},pb=function(e,t,r){var i,o,n,a=JS(e);if(t){if(o=this.parse(a))throw new nR(o);this.searchParams=null}else{if(void 0!==r&&(i=new pb(r,!0)),o=this.parse(a,null,i))throw new nR(o);(n=iR(new rR)).bindURL(this),this.searchParams=n}};pb.prototype={type:"URL",parse:function(e,t,r){var i,o,n,a,s,c=this,l=t||zR,u=0,d="",h=!1,p=!1,m=!1;for(e=JS(e),t||(c.scheme="",c.username="",c.password="",c.host=null,c.port=null,c.path=[],c.query=null,c.fragment=null,c.cannotBeABaseURL=!1,e=fR(e,MR,""),e=fR(e,LR,"$1")),e=fR(e,PR,""),i=KS(e);u<=i.length;){switch(o=i[u],l){case zR:if(!o||!uR(SR,o)){if(t)return TR;l=YR;continue}d+=vR(o),l=qR;break;case qR:if(o&&(uR(RR,o)||"+"===o||"-"===o||"."===o))d+=vR(o);else{if(":"!==o){if(t)return TR;d="",l=YR,u=0;continue}if(t&&(c.isSpecial()!==jS(WR,d)||"file"===d&&(c.includesCredentials()||null!==c.port)||"file"===c.scheme&&!c.host))return;if(c.scheme=d,t)return void(c.isSpecial()&&WR[c.scheme]===c.port&&(c.port=null));d="","file"===c.scheme?l=nb:c.isSpecial()&&r&&r.scheme===c.scheme?l=JR:c.isSpecial()?l=ZR:"/"===i[u+1]?(l=XR,u++):(c.cannotBeABaseURL=!0,mR(c.path,""),l=ub)}break;case YR:if(!r||r.cannotBeABaseURL&&"#"!==o)return TR;if(r.cannotBeABaseURL&&"#"===o){c.scheme=r.scheme,c.path=zS(r.path),c.query=r.query,c.fragment="",c.cannotBeABaseURL=!0,l=hb;break}l="file"===r.scheme?nb:$R;continue;case JR:if("/"!==o||"/"!==i[u+1]){l=$R;continue}l=eb,u++;break;case XR:if("/"===o){l=tb;break}l=lb;continue;case $R:if(c.scheme=r.scheme,o===MS)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=zS(r.path),c.query=r.query;else if("/"===o||"\\"===o&&c.isSpecial())l=QR;else if("?"===o)c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=zS(r.path),c.query="",l=db;else{if("#"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=zS(r.path),c.path.length--,l=lb;continue}c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,c.path=zS(r.path),c.query=r.query,c.fragment="",l=hb}break;case QR:if(!c.isSpecial()||"/"!==o&&"\\"!==o){if("/"!==o){c.username=r.username,c.password=r.password,c.host=r.host,c.port=r.port,l=lb;continue}l=tb}else l=eb;break;case ZR:if(l=eb,"/"!==o||"/"!==lR(d,u+1))continue;u++;break;case eb:if("/"!==o&&"\\"!==o){l=tb;continue}break;case tb:if("@"===o){h&&(d="%40"+d),h=!0,n=KS(d);for(var f=0;f<n.length;f++){var _=n[f];if(":"!==_||m){var g=HR(_,BR);m?c.password+=g:c.username+=g}else m=!0}d=""}else if(o===MS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(h&&""===d)return"Invalid authority";u-=KS(d).length+1,d="",l=rb}else d+=o;break;case rb:case ib:if(t&&"file"===c.scheme){l=sb;continue}if(":"!==o||p){if(o===MS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()){if(c.isSpecial()&&""===d)return IR;if(t&&""===d&&(c.includesCredentials()||null!==c.port))return;if(a=c.parseHost(d))return a;if(d="",l=cb,t)return;continue}"["===o?p=!0:"]"===o&&(p=!1),d+=o}else{if(""===d)return IR;if(a=c.parseHost(d))return a;if(d="",l=ob,t===ib)return}break;case ob:if(!uR(bR,o)){if(o===MS||"/"===o||"?"===o||"#"===o||"\\"===o&&c.isSpecial()||t){if(""!==d){var E=aR(d,10);if(E>65535)return AR;c.port=c.isSpecial()&&E===WR[c.scheme]?null:E,d=""}if(t)return;l=cb;continue}return AR}d+=o;break;case nb:if(c.scheme="file","/"===o||"\\"===o)l=ab;else{if(!r||"file"!==r.scheme){l=lb;continue}switch(o){case MS:c.host=r.host,c.path=zS(r.path),c.query=r.query;break;case"?":c.host=r.host,c.path=zS(r.path),c.query="",l=db;break;case"#":c.host=r.host,c.path=zS(r.path),c.query=r.query,c.fragment="",l=hb;break;default:GR(dR(zS(i,u),""))||(c.host=r.host,c.path=zS(r.path),c.shortenPath()),l=lb;continue}}break;case ab:if("/"===o||"\\"===o){l=sb;break}r&&"file"===r.scheme&&!GR(dR(zS(i,u),""))&&(jR(r.path[0],!0)?mR(c.path,r.path[0]):c.host=r.host),l=lb;continue;case sb:if(o===MS||"/"===o||"\\"===o||"?"===o||"#"===o){if(!t&&jR(d))l=lb;else if(""===d){if(c.host="",t)return;l=cb}else{if(a=c.parseHost(d))return a;if("localhost"===c.host&&(c.host=""),t)return;d="",l=cb}continue}d+=o;break;case cb:if(c.isSpecial()){if(l=lb,"/"!==o&&"\\"!==o)continue}else if(t||"?"!==o)if(t||"#"!==o){if(o!==MS&&(l=lb,"/"!==o))continue}else c.fragment="",l=hb;else c.query="",l=db;break;case lb:if(o===MS||"/"===o||"\\"===o&&c.isSpecial()||!t&&("?"===o||"#"===o)){if(".."===(s=vR(s=d))||"%2e."===s||".%2e"===s||"%2e%2e"===s?(c.shortenPath(),"/"===o||"\\"===o&&c.isSpecial()||mR(c.path,"")):KR(d)?"/"===o||"\\"===o&&c.isSpecial()||mR(c.path,""):("file"===c.scheme&&!c.path.length&&jR(d)&&(c.host&&(c.host=""),d=lR(d,0)+":"),mR(c.path,d)),d="","file"===c.scheme&&(o===MS||"?"===o||"#"===o))for(;c.path.length>1&&""===c.path[0];)_R(c.path);"?"===o?(c.query="",l=db):"#"===o&&(c.fragment="",l=hb)}else d+=HR(o,FR);break;case ub:"?"===o?(c.query="",l=db):"#"===o?(c.fragment="",l=hb):o!==MS&&(c.path[0]+=HR(o,UR));break;case db:t||"#"!==o?o!==MS&&("'"===o&&c.isSpecial()?c.query+="%27":c.query+="#"===o?"%23":HR(o,UR)):(c.fragment="",l=hb);break;case hb:o!==MS&&(c.fragment+=HR(o,VR))}u++}},parseHost:function(e){var t,r,i;if("["===lR(e,0)){if("]"!==lR(e,e.length-1))return IR;if(t=function(e){var t,r,i,o,n,a,s,c=[0,0,0,0,0,0,0,0],l=0,u=null,d=0,h=function(){return lR(e,d)};if(":"===h()){if(":"!==lR(e,1))return;d+=2,u=++l}for(;h();){if(8===l)return;if(":"!==h()){for(t=r=0;r<4&&uR(NR,h());)t=16*t+aR(h(),16),d++,r++;if("."===h()){if(0===r)return;if(d-=r,l>6)return;for(i=0;h();){if(o=null,i>0){if(!("."===h()&&i<4))return;d++}if(!uR(bR,h()))return;for(;uR(bR,h());){if(n=aR(h(),10),null===o)o=n;else{if(0===o)return;o=10*o+n}if(o>255)return;d++}c[l]=256*c[l]+o,2!=++i&&4!==i||l++}if(4!==i)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;c[l++]=t}else{if(null!==u)return;d++,u=++l}}if(null!==u)for(a=l-u,l=7;0!==l&&a>0;)s=c[l],c[l--]=c[u+a-1],c[u+--a]=s;else if(8!==l)return;return c}(ER(e,1,-1)),!t)return IR;this.host=t}else if(this.isSpecial()){if(e=YS(e),uR(kR,e))return IR;if(t=function(e){var t,r,i,o,n,a,s,c=gR(e,".");if(c.length&&""===c[c.length-1]&&c.length--,(t=c.length)>4)return e;for(r=[],i=0;i<t;i++){if(""===(o=c[i]))return e;if(n=10,o.length>1&&"0"===lR(o,0)&&(n=uR(wR,o)?16:8,o=ER(o,8===n?1:2)),""===o)a=0;else{if(!uR(10===n?CR:8===n?DR:NR,o))return e;a=aR(o,n)}mR(r,a)}for(i=0;i<t;i++)if(a=r[i],i===t-1){if(a>=cR(256,5-t))return null}else if(a>255)return null;for(s=pR(r),i=0;i<r.length;i++)s+=r[i]*cR(256,3-i);return s}(e),null===t)return IR;this.host=t}else{if(uR(OR,e))return IR;for(t="",r=KS(e),i=0;i<r.length;i++)t+=HR(r[i],UR);this.host=t}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return jS(WR,this.scheme)},shortenPath:function(){var e=this.path,t=e.length;!t||"file"===this.scheme&&1===t&&jR(e[0],!0)||e.length--},serialize:function(){var e=this,t=e.scheme,r=e.username,i=e.password,o=e.host,n=e.port,a=e.path,s=e.query,c=e.fragment,l=t+":";return null!==o?(l+="//",e.includesCredentials()&&(l+=r+(i?":"+i:"")+"@"),l+=xR(o),null!==n&&(l+=":"+n)):"file"===t&&(l+="//"),l+=e.cannotBeABaseURL?a[0]:a.length?"/"+dR(a,"/"):"",null!==s&&(l+="?"+s),null!==c&&(l+="#"+c),l},setHref:function(e){var t=this.parse(e);if(t)throw new nR(t);this.searchParams.update()},getOrigin:function(){var e=this.scheme,t=this.port;if("blob"===e)try{return new mb(e.path[0]).origin}catch(YW){return"null"}return"file"!==e&&this.isSpecial()?e+"://"+xR(this.host)+(null!==t?":"+t:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(e){this.parse(JS(e)+":",zR)},getUsername:function(){return this.username},setUsername:function(e){var t=KS(JS(e));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<t.length;r++)this.username+=HR(t[r],BR)}},getPassword:function(){return this.password},setPassword:function(e){var t=KS(JS(e));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<t.length;r++)this.password+=HR(t[r],BR)}},getHost:function(){var e=this.host,t=this.port;return null===e?"":null===t?xR(e):xR(e)+":"+t},setHost:function(e){this.cannotBeABaseURL||this.parse(e,rb)},getHostname:function(){var e=this.host;return null===e?"":xR(e)},setHostname:function(e){this.cannotBeABaseURL||this.parse(e,ib)},getPort:function(){var e=this.port;return null===e?"":JS(e)},setPort:function(e){this.cannotHaveUsernamePasswordPort()||(""===(e=JS(e))?this.port=null:this.parse(e,ob))},getPathname:function(){var e=this.path;return this.cannotBeABaseURL?e[0]:e.length?"/"+dR(e,"/"):""},setPathname:function(e){this.cannotBeABaseURL||(this.path=[],this.parse(e,cb))},getSearch:function(){var e=this.query;return e?"?"+e:""},setSearch:function(e){""===(e=JS(e))?this.query=null:("?"===lR(e,0)&&(e=ER(e,1)),this.query="",this.parse(e,db)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var e=this.fragment;return e?"#"+e:""},setHash:function(e){""!==(e=JS(e))?("#"===lR(e,0)&&(e=ER(e,1)),this.fragment="",this.parse(e,hb)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var mb=function(e){var t=WS(this,fb),r=$S(arguments.length,1)>1?arguments[1]:void 0,i=eR(t,new pb(e,!1,r));PS||(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())},fb=mb.prototype,_b=function(e,t){return{get:function(){return tR(this)[e]()},set:t&&function(e){return tR(this)[t](e)},configurable:!0,enumerable:!0}};if(PS&&(HS(fb,"href",_b("serialize","setHref")),HS(fb,"origin",_b("getOrigin")),HS(fb,"protocol",_b("getProtocol","setProtocol")),HS(fb,"username",_b("getUsername","setUsername")),HS(fb,"password",_b("getPassword","setPassword")),HS(fb,"host",_b("getHost","setHost")),HS(fb,"hostname",_b("getHostname","setHostname")),HS(fb,"port",_b("getPort","setPort")),HS(fb,"pathname",_b("getPathname","setPathname")),HS(fb,"search",_b("getSearch","setSearch")),HS(fb,"searchParams",_b("getSearchParams")),HS(fb,"hash",_b("getHash","setHash"))),BS(fb,"toJSON",(function(){return tR(this).serialize()}),{enumerable:!0}),BS(fb,"toString",(function(){return tR(this).serialize()}),{enumerable:!0}),oR){var gb=oR.createObjectURL,Eb=oR.revokeObjectURL;gb&&BS(mb,"createObjectURL",VS(gb,oR)),Eb&&BS(mb,"revokeObjectURL",VS(Eb,oR))}XS(mb,"URL"),LS({global:!0,constructor:!0,forced:!xS,sham:!PS},{URL:mb});var vb=l;to({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return vb(URL.prototype.toString,this)}});var yb,Tb=Object.create,Ib=Object.defineProperty,Ab=Object.defineProperties,Sb=Object.getOwnPropertyDescriptor,Rb=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertyNames,wb=Object.getOwnPropertySymbols,Db=Object.getPrototypeOf,Cb=Object.prototype.hasOwnProperty,Nb=Object.prototype.propertyIsEnumerable,kb=Reflect.get,Ob=Math.pow,Mb=(e,t,r)=>t in e?Ib(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Lb=(e,t)=>{for(var r in t||(t={}))Cb.call(t,r)&&Mb(e,r,t[r]);if(wb)for(var r of wb(t))Nb.call(t,r)&&Mb(e,r,t[r]);return e},Pb=(e,t)=>Ab(e,Rb(t)),xb=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ub=(e,t)=>{for(var r in t)Ib(e,r,{get:t[r],enumerable:!0})},Vb=(e,t,r)=>(r=null!=e?Tb(Db(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of bb(t))!Cb.call(e,o)&&o!==r&&Ib(e,o,{get:()=>t[o],enumerable:!(i=Sb(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:Ib(r,"default",{value:e,enumerable:!0}),e)),Fb=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?Sb(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&Ib(t,r,n),n},Bb=(e,t,r)=>Mb(e,"symbol"!=typeof t?t+"":t,r),Hb=(e,t,r)=>kb(Db(e),r,t),Wb=(e,t,r)=>new Promise(((i,o)=>{var n=e=>{try{s(r.next(e))}catch(eO){o(eO)}},a=e=>{try{s(r.throw(e))}catch(eO){o(eO)}},s=e=>e.done?i(e.value):Promise.resolve(e.value).then(n,a);s((r=r.apply(e,t)).next())})),jb=xb(((e,t)=>{var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),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 o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},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 o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},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,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,n),!0;case 6:return u.fn.call(u.context,t,r,o,n,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn===t&&(!o||a.once)&&(!r||a.context===r)&&s(this,n);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)})),Gb=xb(((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")}))}))})),Kb=xb((e=>{var t=function(e){return String(Number(e))===e?Number(e):e},r=function(e,r,i){var o=e.name&&e.names;e.push&&!r[e.push]?r[e.push]=[]:o&&!r[e.name]&&(r[e.name]={});var n=e.push?{}:o?r[e.name]:r;(function(e,r,i,o){if(o&&!i)r[o]=t(e[1]);else for(var n=0;n<i.length;n+=1)null!=e[n+1]&&(r[i[n]]=t(e[n+1]))})(i.match(e.reg),n,e.names,e.name),e.push&&r[e.push].push(n)},i=Gb(),o=RegExp.prototype.test.bind(/^([a-z])=(.*)/);e.parse=function(e){var t={},n=[],a=t;return e.split(/(\r\n|\r|\n)/).filter(o).forEach((function(e){var t=e[0],o=e.slice(2);"m"===t&&(n.push({rtp:[],fmtp:[]}),a=n[n.length-1]);for(var s=0;s<(i[t]||[]).length;s+=1){var c=i[t][s];if(c.reg.test(o))return r(c,a,o)}})),t.media=n,t};var n=function(e,r){var i=r.split(/=(.+)/,2);return 2===i.length?e[i[0]]=t(i[1]):1===i.length&&r.length>1&&(e[i[0]]=void 0),e};e.parseParams=function(e){return e.split(/;\s?/).reduce(n,{})},e.parseFmtpConfig=e.parseParams,e.parsePayloads=function(e){return e.toString().split(" ").map(Number)},e.parseRemoteCandidates=function(e){for(var r=[],i=e.split(" ").map(t),o=0;o<i.length;o+=3)r.push({component:i[o],ip:i[o+1],port:i[o+2]});return r},e.parseImageAttributes=function(e){return e.split(" ").map((function(e){return e.substring(1,e.length-1).split(",").reduce(n,{})}))},e.parseSimulcastStreamList=function(e){return e.split(";").map((function(e){return e.split(",").map((function(e){var r,i=!1;return"~"!==e[0]?r=t(e):(r=t(e.substring(1,e.length)),i=!0),{scid:r,paused:i}}))}))}})),zb=xb(((e,t)=>{var r=Gb(),i=/%[sdv%]/g,o=function(e){var t=1,r=arguments,o=r.length;return e.replace(i,(function(e){if(t>=o)return e;var i=r[t];switch(t+=1,e){case"%%":return"%";case"%s":return String(i);case"%d":return Number(i);case"%v":return""}}))},n=function(e,t,r){var i=[e+"="+(t.format instanceof Function?t.format(t.push?r:r[t.name]):t.format)];if(t.names)for(var n=0;n<t.names.length;n+=1){var a=t.names[n];t.name?i.push(r[t.name][a]):i.push(r[t.names[n]])}else i.push(r[t.name]);return o.apply(null,i)},a=["v","o","s","i","u","e","p","c","b","t","r","z","a"],s=["i","c","b","a"];t.exports=function(e,t){t=t||{},null==e.version&&(e.version=0),null==e.name&&(e.name=" "),e.media.forEach((function(e){null==e.payloads&&(e.payloads="")}));var i=t.outerOrder||a,o=t.innerOrder||s,c=[];return i.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?c.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){c.push(n(t,r,e))}))}))})),e.media.forEach((function(e){c.push(n("m",r.m[0],e)),o.forEach((function(t){r[t].forEach((function(r){r.name in e&&null!=e[r.name]?c.push(n(t,r,e)):r.push in e&&null!=e[r.push]&&e[r.push].forEach((function(e){c.push(n(t,r,e))}))}))}))})),c.join("\r\n")+"\r\n"}})),qb=xb((e=>{var t=Kb(),r=zb(),i=Gb();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})),Yb=((yb=Yb||{})[yb.INVALID_PARAMETER=4096]="INVALID_PARAMETER",yb[yb.INVALID_OPERATION=4097]="INVALID_OPERATION",yb[yb.NOT_SUPPORTED=4098]="NOT_SUPPORTED",yb[yb.DEVICE_NOT_FOUND=4099]="DEVICE_NOT_FOUND",yb[yb.INITIALIZE_FAILED=4100]="INITIALIZE_FAILED",yb[yb.SIGNAL_CHANNEL_SETUP_FAILED=16385]="SIGNAL_CHANNEL_SETUP_FAILED",yb[yb.SIGNAL_CHANNEL_ERROR=16386]="SIGNAL_CHANNEL_ERROR",yb[yb.ICE_TRANSPORT_ERROR=16387]="ICE_TRANSPORT_ERROR",yb[yb.JOIN_ROOM_FAILED=16388]="JOIN_ROOM_FAILED",yb[yb.CREATE_OFFER_FAILED=16389]="CREATE_OFFER_FAILED",yb[yb.SIGNAL_CHANNEL_RECONNECTION_FAILED=16390]="SIGNAL_CHANNEL_RECONNECTION_FAILED",yb[yb.UPLINK_RECONNECTION_FAILED=16391]="UPLINK_RECONNECTION_FAILED",yb[yb.DOWNLINK_RECONNECTION_FAILED=16392]="DOWNLINK_RECONNECTION_FAILED",yb[yb.REMOTE_STREAM_NOT_EXIST=16400]="REMOTE_STREAM_NOT_EXIST",yb[yb.CLIENT_BANNED=16448]="CLIENT_BANNED",yb[yb.SERVER_TIMEOUT=16449]="SERVER_TIMEOUT",yb[yb.SUBSCRIPTION_TIMEOUT=16450]="SUBSCRIPTION_TIMEOUT",yb[yb.PLAY_NOT_ALLOWED=16451]="PLAY_NOT_ALLOWED",yb[yb.DEVICE_AUTO_RECOVER_FAILED=16452]="DEVICE_AUTO_RECOVER_FAILED",yb[yb.START_PUBLISH_CDN_FAILED=16453]="START_PUBLISH_CDN_FAILED",yb[yb.STOP_PUBLISH_CDN_FAILED=16454]="STOP_PUBLISH_CDN_FAILED",yb[yb.START_MIX_TRANSCODE_FAILED=16455]="START_MIX_TRANSCODE_FAILED",yb[yb.STOP_MIX_TRANSCODE_FAILED=16456]="STOP_MIX_TRANSCODE_FAILED",yb[yb.NOT_SUPPORTED_H264=16457]="NOT_SUPPORTED_H264",yb[yb.SWITCH_ROLE_FAILED=16458]="SWITCH_ROLE_FAILED",yb[yb.API_CALL_TIMEOUT=16459]="API_CALL_TIMEOUT",yb[yb.SCHEDULE_FAILED=16460]="SCHEDULE_FAILED",yb[yb.API_CALL_ABORTED=16461]="API_CALL_ABORTED",yb[yb.SPC_INITIALIZED_FAILED=16462]="SPC_INITIALIZED_FAILED",yb[yb.VIDEO_MANAGER_ERROR=16463]="VIDEO_MANAGER_ERROR",yb[yb.SWITCH_ROOM_FAILED=16464]="SWITCH_ROOM_FAILED",yb[yb.UNKNOWN=65535]="UNKNOWN",yb),Jb=Yb,Xb=class extends Error{constructor(e){let{name:t="RtcError",message:r,code:i=Jb.UNKNOWN,extraCode:o=0,constraint:n}=e,a="<".concat(function(e){for(let t in Jb)if(Jb[t]===e)return t;return"UNKNOWN"}(i)," 0x").concat(i.toString(16),">"),s="".concat(r).concat(n?" constraint: ".concat(n):"").concat(null!=r&&r.includes(a)?"":" ".concat(a));super(s),Bb(this,"code"),Bb(this,"extraCode"),Bb(this,"message"),Bb(this,"originMessage"),Bb(this,"name"),Bb(this,"constraint"),this.code=i,this.extraCode=o,this.name=t,this.message=s,this.constraint=n,this.originMessage=r}getCode(){return this.code}getExtraCode(){return this.extraCode}toString(){return this.originMessage}},$b=Xb;(new Date).getTime();var Qb=function(){return(new Date).getTime()+0},Zb=function(){let e=new Date;return e.setTime(Qb()),e.toLocaleString()},ew=function(e){let t=String(e.getMilliseconds());return"padStart"in String.prototype&&(t=t.toString().padStart(3,"0")),"".concat(e.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/,"$1"),":").concat(t)},tw={};Ub(tw,{bytes2ms:()=>zD,calculateScaleResolutionDownNumber:()=>BC,convertObjectNumberToInt:()=>PC,copyProperties:()=>KD,deepClone:()=>RC,deepMerge:()=>SC,delay:()=>xC,fibonacci:()=>ZD,formatedTime:()=>DC,getConstructorName:()=>pC,getContainerFromElement:()=>wC,getEnv:()=>UD,getInternalVersion:()=>EC,getLoggerUrl:()=>FD,getMediaStreamTrackInfo:()=>FC,getMuteStateFromFlag:()=>TC,getNetworkType:()=>HD,getNumNetworkType:()=>GD,getReconnectionTimeout:()=>eC,getStringByteLength:()=>kC,getTurnServer:()=>IC,getUint32Version:()=>LC,getValueType:()=>tC,getViewListFromView:()=>bC,glog:()=>XD,ipv4ToUint32:()=>AC,isArray:()=>cC,isAudioWorkletSupported:()=>mC,isBoolean:()=>aC,isConstructor:()=>hC,isEmpty:()=>yC,isFunction:()=>rC,isLangChinese:()=>$D,isMediaStreamTrack:()=>lC,isNumber:()=>nC,isObject:()=>sC,isOverseaSdkAppId:()=>VD,isPlainObject:()=>QD,isPortrait:()=>OC,isPromise:()=>dC,isRemoteTrack:()=>uC,isRotate90Or270:()=>HC,isString:()=>oC,isUndefined:()=>iC,loadImage:()=>MC,ms2bytes:()=>YD,ms2samples:()=>JD,normalizeUrl:()=>VC,performanceNow:()=>_C,promiseAny:()=>fC,samples2ms:()=>qD,setNetworkType:()=>jD,stringify:()=>CC,stringifyIncludeValue:()=>NC,throttlePromise:()=>UC});var rw={};Ub(rw,{AUDIO_MUTE_BIT:()=>jw,AUDIO_STAT_BIT:()=>Ww,AUX_STAT_BIT:()=>Hw,AUX_STREAM_MSID:()=>Yw,BACKEND_ENV:()=>Uw,BASE_DOC_URL:()=>gw,BASE_HOST:()=>pw,CAPABILITIES_KEYS:()=>PD,CLASS_NAME:()=>bD,CLOUD_CONSOLE_URL:()=>_w,CROSS_ROOM_BIT:()=>zw,DATA_FREEZE_TIMING:()=>vD,DEFAULT_ASSETS_URL:()=>Ew,DOC_URL:()=>vw,DTLS_STATE_UNKNOWN:()=>oD,ENV_NAME:()=>Sw,EXCHANGE_SDP_TIMEOUT:()=>mD,IS_WORKER:()=>cw,IS_WORKLET:()=>lw,KIBANA_EVENT:()=>dD,LOCAL_STREAM_PUBLISH_STATE:()=>ED,LOGGER_CMD_TYPE:()=>Aw,LOGGER_DOMAIN:()=>yw,LOGGER_DOMAIN_OVERSEA:()=>Tw,LOG_LEVEL:()=>Rw,LOG_LEVEL_NAME:()=>kD,MAIN_STREAM_MSID:()=>qw,MAX_RTT:()=>xD,MICROPHONE_COMMUNICATIONS:()=>ND,MICROPHONE_DEFAULT:()=>DD,MUTE_ALL_BIT:()=>Kw,NAME:()=>Pw,NETWORK_TYPE:()=>Dw,NOT_SUPPORTED_H264:()=>gD,PAUSED_RETRY_COUNT:()=>wD,PEERCONNECTION_CONNECTING_TIMEOUT:()=>AD,PEER_CONNECTION_STATE:()=>nD,PEER_LEAVE_REASON:()=>OD,RECOVER_CAPTURE_INTERVAL:()=>LD,REMOTE_STREAM_TYPE_AUX:()=>Xw,REMOTE_STREAM_TYPE_MAIN:()=>Jw,RENDER_FREEZE_TIMING:()=>yD,SCHEDULE_DOMAIN:()=>SD,SCHEDULE_TIMEOUT:()=>RD,SDP_SEMANTICS_PLAN_B:()=>_D,SDP_SEMANTICS_UNIFIED_PLAN:()=>fD,SECOND_HOST:()=>mw,SIGNAL_PING_PONG_INTERVAL:()=>ww,SIGNAL_PING_TIMEOUT:()=>bw,SIGNAL_RECONNECTION_COUNT:()=>uD,SMALL_STAT_BIT:()=>Bw,SPEAKER_DEFAULT:()=>CD,STORAGE_EXPIRES_TIME:()=>Cw,STREAM_TYPE_BIG:()=>TD,STREAM_TYPE_SMALL:()=>ID,SUBSCRIBE_SMALL_RETRY_COUNT:()=>MD,SYNC_USER_LIST_INTERVAL:()=>hD,Scene:()=>Vw,THIRD_HOST:()=>fw,TRANSPORT_DIRECTION:()=>xw,TRTC_ERROR_ASSISTANCE:()=>Iw,TRTC_QUALITY_BAD:()=>tD,TRTC_QUALITY_DISCONNECTED:()=>iD,TRTC_QUALITY_EXCELLENT:()=>Qw,TRTC_QUALITY_GOOD:()=>Zw,TRTC_QUALITY_POOR:()=>eD,TRTC_QUALITY_UNKNOWN:()=>$w,TRTC_QUALITY_VERY_BAD:()=>rD,UPDATE_OFFER_TIMEOUT:()=>pD,VIDEO_MUTE_BIT:()=>Gw,VIDEO_STAT_BIT:()=>Fw,audioProfileMap:()=>Nw,defaultBigVideoProfile:()=>Ow,defaultSmallVideoProfile:()=>Mw,getRetryCount:()=>cD,getScriptDir:()=>uw,innerVersion:()=>iw,loggerProxy:()=>dw,screenProfileMap:()=>Lw,setLoggerProxy:()=>hw,setRetryCount:()=>sD,setVersion:()=>nw,version:()=>ow,videoProfileMap:()=>kw});var iw="4.15.00.1600",ow="5.0.0";function nw(e){ow=e;let[t,r,i]=e.split(".").map((e=>parseInt(e,10)));iw="".concat(t,".").concat(Math.min(15,r),".").concat(Math.min(15,i),".").concat(r.toString().padStart(2,"0")).concat(i.toString().padStart(2,"0"))}var aw,sw,cw="undefined"!=typeof importScripts,lw="undefined"!=typeof registerProcessor,uw=()=>{let e=cw?self.location.href:document.currentScript.src;return e.substring(0,e.lastIndexOf("/")+1)},dw="",hw=e=>dw=e,pw="web.sdk.qcloud.com",mw="web.sdk.tencent.cn",fw="web.sdk.cloud.tencent.cn",_w="https://console.cloud.tencent.com/trtc",gw="https://".concat(pw,"/trtc/webrtc/v5/doc"),Ew="https://web.sdk.qcloud.com/trtc/webrtc/v5/assets/",vw="".concat(gw,"/zh-cn/"),yw="https://yun.tim.qq.com",Tw="https://apisgp.my-imcloud.com",Iw="trtc_error_assistance",Aw={LOG:"jssdk_log",EVENT:"jssdk_event",KEY_POINT:"jssdk_new_endreport",KV_STAT:"jssdk_key_metrics_report"},Sw={QCLOUD:"qcloud",OLD_CLOUD_LADDER:"trtc",WEBRTC:"webrtc"},Rw=((sw=Rw||{})[sw.TRACE=0]="TRACE",sw[sw.DEBUG=1]="DEBUG",sw[sw.INFO=2]="INFO",sw[sw.WARN=3]="WARN",sw[sw.ERROR=4]="ERROR",sw[sw.NONE=5]="NONE",sw),bw=18e3,ww=2e3,Dw={unknown:0,wifi:1,"3g":2,"2g":3,"4g":4,wired:5,"5g":6},Cw=6048e5,Nw={standard:{sampleRate:48e3,channelCount:1,bitrate:40},"standard-stereo":{sampleRate:48e3,channelCount:2,bitrate:64},high:{sampleRate:48e3,channelCount:1,bitrate:128},"high-stereo":{sampleRate:48e3,channelCount:2,bitrate:192}},kw={"120p":{width:160,height:120,frameRate:15,bitrate:200},"120p_2":{width:160,height:120,frameRate:15,bitrate:100},"180p":{width:320,height:180,frameRate:15,bitrate:350},"180p_2":{width:320,height:180,frameRate:15,bitrate:150},"240p":{width:320,height:240,frameRate:15,bitrate:400},"240p_2":{width:320,height:240,frameRate:15,bitrate:200},"360p":{width:640,height:360,frameRate:15,bitrate:800},"360p_2":{width:640,height:360,frameRate:15,bitrate:400},"480p":{width:640,height:480,frameRate:15,bitrate:900},"480p_2":{width:640,height:480,frameRate:15,bitrate:500},"720p":{width:1280,height:720,frameRate:15,bitrate:1500},"1080p":{width:1920,height:1080,frameRate:15,bitrate:2e3},"1440p":{width:2560,height:1440,frameRate:30,bitrate:4860},"4K":{width:3840,height:2160,frameRate:30,bitrate:9e3}},Ow=kw["480p_2"],Mw=kw["120p_2"],Lw={"480p":{width:640,height:480,frameRate:5,bitrate:900},"480p_2":{width:640,height:480,frameRate:30,bitrate:1e3},"720p":{width:1280,height:720,frameRate:5,bitrate:1200},"720p_2":{width:1280,height:720,frameRate:30,bitrate:3e3},"1080p":{width:1920,height:1080,frameRate:5,bitrate:1600},"1080p_2":{width:1920,height:1080,frameRate:30,bitrate:4e3}},Pw={CANVAS:"canvas",AUDIO:"audio",VIDEO:"video",SCREEN:"screen",SMALL:"small",BIG:"big",AUXILIARY:"auxiliary",SMALL_VIDEO:"smallVideo",FACING_MODE_USER:"user",FACING_MODE_ENVIRONMENT:"environment",MUTE:"mute",UNMUTE:"unmute",ENDED:"ended",PLAYING:"playing",PAUSE:"pause",ERROR:"error",LOADEDDATA:"loadeddata",LOADEDMETADATA:"loadedmetadata",AUDIO_INPUT:"audioinput",VIDEO_INPUT:"videoinput",DETAIL:"detail",TEXT:"text",MAIN:"main",BACKUP:"backup",BANNED:"banned",KICK:"kick",USER_TIME_OUT:"user_time_out",ROOM_DISBAND:"room_disband",SEI_MESSAGE:"sei-message",ADD:"add",REMOVE:"remove",REPLACE:"replace",TRACK:"track",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",TRANSCEIVER_DIRECTION_SENDONLY:"sendonly",TRANSCEIVER_DIRECTION_RECVONLY:"recvonly",ENTER_PICTURE_IN_PICTURE:"enterpictureinpicture",LEAVE_PICTURE_IN_PICTURE:"leavepictureinpicture"},xw={INACTIVE:"inactive",SENDONLY:"sendonly",RECVONLY:"recvonly"},Uw={OLD_CLOUD_LADDER:"wss://trtc.rtc.qq.com",WEBRTC:"wss://webrtc.qq.com"},Vw=((aw=Vw||{}).LIVE="live",aw.RTC="rtc",aw),Fw=1,Bw=2,Hw=4,Ww=8,jw=64,Gw=16,Kw=112,zw=128,qw="5Y2wZK8nANNAoVw6dSAHVjNxrD1ObBM2kBPV",Yw="224d130c-7b5c-415b-aaa2-79c2eb5a6df2",Jw=Pw.MAIN,Xw=Pw.AUXILIARY,$w=0,Qw=1,Zw=2,eD=3,tD=4,rD=5,iD=6,oD="unknown",nD={NEW:"new",CONNECTING:"connecting",FAILED:"failed",CLOSED:"closed",DISCONNECTED:"disconnected",CONNECTED:"connected",COMPLETED:"completed"},aD=1/0;function sD(e){aD=e}function cD(){return aD}var lD,uD=30,dD={JOIN:"join",DELTA_JOIN:"delta-join",REJOIN:"rejoin",LEAVE:"leave",DELTA_LEAVE:"delta-leave",PUBLISH:"publish",DELTA_PUBLISH:"delta-publish",UNPUBLISH:"unpublish",SUBSCRIBE:"subscribe",UNSUBSCRIBE:"unsubscribe",UPLINK_CONNECTION:"uplink-connection",UPLINK_RECONNECTION:"uplink-reconnection",DOWNLINK_CONNECTION:"downlink-connection",DOWNLINK_RECONNECTION:"downlink-reconnection",ON_TRACK:"ontrack",ICE_CONNECTION_STATE:"iceConnectionState",LOCAL_STREAM_INITIALIZE:"stream-initialize",SIGNAL_CONNECTION:"websocketConnectionState",SIGNAL_RECONNECTION:"websocketReconnectionState",UPDATE_STREAM:"update-stream",RECOVER_LOCAL_AUDIO_TRACK:"recover-local-audio-track",RECOVER_LOCAL_VIDEO_TRACK:"recover-local-video-track",RECOVER_SUBSCRIPTION:"recover-subscription",START_MIX_TRANSCODE:"start-mix-transcode",STOP_MIX_TRANSCODE:"stop-mix-transcode",PLAYER_ERROR:"player-error",SCHEDULE:"schedule",LOAD_WORKLET:"load-worklet",VIDEO_FROZEN_COUNT:"videoFrozenCount",GET_USER_MEDIA_RETRY:"getUserMedia-retry"},hD=1e4,pD=1e4,mD=1e4,fD="unified-plan",_D="plan-b",gD=1028,ED=((lD=ED||{})[lD.UNPUBLISH=-1]="UNPUBLISH",lD[lD.PUBLISHING=0]="PUBLISHING",lD[lD.PUBLISHED=1]="PUBLISHED",lD),vD=500,yD=1e3,TD=Pw.BIG,ID=Pw.SMALL,AD=1e4,SD={MAIN:"schedule.cloud-rtc.com",BACKUP:"schedule.cloud-rtc.net",MAIN_OVERSEA:"schedule.rtc-web.com",BACKUP_OVERSEA:"schedule.rtc-web.io",MAIN_OVERSEA_BACKUP:"intl-schedule.cloud-rtc.com"},RD=2e3,bD={TRTC:"TRTC",CLIENT:"Client",LOCAL_STREAM:"LocalStream",REMOTE_STREAM:"RemoteStream",STREAM:"Stream"},wD=5,DD="default",CD=DD,ND="communications",kD=Object.keys(Rw),OD=["normal leave","timeout leave","kick","role change"],MD=10,LD=2e3,PD=["width","height","frameRate","facingMode","sampleRate","sampleSize","channelCount","deviceId","min","max"],xD=1e4,UD=function(){return new URLSearchParams(location.search).get("trtc_env")||""},VD=e=>Number(e)<14e8,FD=function(e,t){let r;r=dw||(VD(e)?Tw:yw);let i=Math.floor(Math.random()*Ob(2,31));return"".concat(r,"/v5/AVQualityReportSvc/C2S?random=").concat(i,"&sdkappid=").concat(e,"&cmdtype=").concat(t)},BD="unknown";function HD(){if("unknown"!==BD)return BD;let{userAgent:e,connection:t}=navigator,r=(e.match(/NetType\/\S+/)||[])[0]||"";r=r.toLowerCase().replace("nettype/",""),"3gnet"===r&&(r="3g");let i=t&&t.type&&t.type.toLowerCase(),o=t&&t.effectiveType&&t.effectiveType.toLowerCase();return"slow-2"===o&&(o="2g"),i&&(BD=WD(i,o)),BD}function WD(e,t){if(Dw[e])return e;switch(e){case"cellular":case"wimax":return t||"unknown";case"ethernet":return"wired";default:return"unknown"}}function jD(e){BD=WD(e)}function GD(){return Dw[HD()]}function KD(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 zD(e){return qD(e/4,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function qD(e){return 1e3*e/(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function YD(e){return 4*JD(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)}function JD(e){return e*(arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3)/1e3}var XD="undefined"!=typeof window&&"function"==typeof window.glog?window.glog:()=>{},$D=()=>{let e=navigator.language;return e=e.substring(0,2),"zh"===e},QD=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let 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 ZD(e){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return e<=1?t:ZD(e-1,t,(arguments.length>1&&void 0!==arguments[1]?arguments[1]:1)+t)}function eC(e){return e>8?3e4:1e3*ZD(e)}function tC(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}var rC=e=>"function"==typeof e,iC=e=>void 0===e,oC=e=>"string"==typeof e,nC=e=>"number"==typeof e,aC=e=>"boolean"==typeof e,sC=e=>"object"===tC(e),cC=e=>"array"===tC(e),lC=e=>tC(e)==="MediaStreamTrack".toLowerCase(),uC=e=>e.isRemote,dC=e=>"promise"===tC(e),hC=e=>rC(e)&&e.prototype.constructor===e,pC=e=>hC(e)?e.prototype.constructor.name:"",mC="undefined"!=typeof AudioWorkletNode;function fC(e){return new Promise(((t,r)=>{let i=[];e.forEach((o=>{o.then(t).catch((t=>{i.push(t),i.length===e.length&&r(i)}))}))}))}function _C(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var gC=e=>+e<10?"0".concat(e):e,EC=e=>{let t=e.match(/^\d+\.\d+\.\d+/)[0];if(!t)return e;let r=t.split("."),i=gC(r[1])+gC(r[2]);return r[1]-15>0&&(r[1]="15"),r[2]-15>0&&(r[2]="15"),"".concat(r.join("."),".").concat(i)},vC=Object.prototype.hasOwnProperty;function yC(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(QD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(vC.call(e,t))return!1;return!0}return!1}function TC(e,t){return{userId:t,hasAudio:!!(e&Ww),hasVideo:!!(e&Fw),hasAuxiliary:!!(e&Hw),hasSmall:!!(e&Bw),audioMuted:!!(e&jw),videoMuted:!!(e&Gw),audioAvailable:!(!(e&Ww)||e&jw),videoAvailable:!(!(e&Fw)||e&Gw)}}function IC(e){let t={urls:e.url.startsWith("turn:")||e.url.startsWith("turns:")?e.url:"turn:".concat(e.url)};return!iC(e.username)&&!iC(e.credential)&&(t.username=e.username,t.credential=e.credential,t.credentialType="password",iC(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 SC=function(e,t,r,i){if(!sC(e)||!sC(t))return 0;let o,n=0,a=Object.keys(t);for(let s=0,c=a.length;s<c;s++)if(o=a[s],!(iC(t[o])||r&&r.includes(o)))if(sC(e[o])&&sC(t[o]))n+=SC(e[o],t[o],r,i);else{if(i&&i.includes(t[o]))continue;e[o]!==t[o]&&(e[o]=RC(t[o]),n+=1)}return n};function RC(e){if(cC(e)){let t=[];return e.forEach(((e,r)=>{t[r]=RC(e)})),t}if(sC(e)){let t={};return Object.keys(e).forEach((r=>{t[r]=RC(e[r])})),t}return e}var bC=e=>{let t=[];if(cC(e))t=[...e];else if(oC(e)){let r=document.getElementById(e);r&&t.push(r)}else e&&t.push(e);return t},wC=e=>oC(e)?document.getElementById(e):e,DC=()=>(e=>{let t=e=>e<10?"0".concat(e):"".concat(e),r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),n=t(e.getHours()),a=t(e.getMinutes()),s=t(e.getSeconds());return"".concat(r,"/").concat(i,"/").concat(o," ").concat(n,":").concat(a,":").concat(s)})(new Date);function CC(e,t){let{keysToInclude:r,keysToExclude:i}=t;try{if(cC(e))return"[".concat(e.map((e=>CC(e,{keysToInclude:r,keysToExclude:i}))).join(","),"]");if(!QD(e)||!cC(r)&&!cC(i))return JSON.stringify(e);let t={},o=new Set(r),n=new Set(i);return Object.keys(e).forEach((a=>{(0===n.size&&o.has(a)||0===o.size&&!n.has(a))&&(t[a]=QD(e[a])||cC(e[a])?JSON.parse(CC(e[a],{keysToExclude:i,keysToInclude:r})):e[a])})),JSON.stringify(t)}catch(lD){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)})),CC(e,{keysToInclude:r})}function kC(e){return e.replace(/[\u4e00-\u9fa5]/g,"aa").length}var OC=()=>{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},MC=e=>Wb(void 0,null,(function*(){return 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 $b({code:Jb.INVALID_PARAMETER,message:"load image failed, url: ".concat(e)}))}}))})),LC=e=>{let t=e.split(".");return+t[0]<<24|+t[1]<<16|+t[2]<<8|+t[3]},PC=e=>(Object.keys(e).forEach((t=>{nC(e[t])&&(t.startsWith("uint")||t.startsWith("int"))?e[t]=Math.floor(e[t]):(QD(e[t])||cC(e[t]))&&PC(e[t])})),e);function xC(e,t){return new Promise((r=>{let i=setTimeout(r,e);t&&t(i)}))}function UC(e,t){let r=null;return function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return r||(r=e.apply(t||this,o),r.finally((()=>r=null)),r)}}function VC(e){return e.replace(/(^|[^:])\/{2,}/g,"$1/")}function FC(e){var t;try{let{width:r,height:i,frameRate:o,sampleRate:n,sampleSize:a,channelCount:s}=null==(t=e.getSettings)?void 0:t.call(e),c=e.kind===Pw.AUDIO?"".concat(n,"x").concat(a,"@").concat(s):"".concat(r,"x").concat(i,"@").concat(o),l=e.stats?" stats: ".concat(JSON.stringify(e.stats).replaceAll('"',"")):"";return"".concat(e.id," ").concat(e.readyState," muted:").concat(e.muted," ").concat(e.kind," ").concat(e.label," ").concat(c).concat(l)}catch(aw){return""}}function BC(e,t){return e.width*e.height==t.width*t.height?1:OC()&&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 HC(e){return 90===e||270===e}function WC(e){let{url:t,body:r,method:i="POST",timeout:o,priority:n}=e;return new Promise(((e,a)=>{if("fetch"in window)return fetch(t,{method:i,body:r,priority:n}).then((e=>e.text())).then((t=>{try{e({data:JSON.parse(t)})}catch(eO){e({data:t})}}),a);let s=new XMLHttpRequest;s.onreadystatechange=()=>{if(4===s.readyState)if(s.status>=200&&s.status<300)try{let t=JSON.parse(s.response);e({data:t})}catch(t){e({data:s.response})}else a({status:s.status,statusText:s.statusText||"request failed!"})},s.timeout=o||5e3,s.open(i,t,!0),s.send(r)}))}function jC(e){return Wb(this,null,(function*(){let t=_C(),r=JSON.stringify(e);try{if(!CompressionStream||r.length<=2800)return r;let e=new Blob([r],{type:"application/json"}).stream().pipeThrough(new CompressionStream("gzip")),i=yield(yield(yield new Response(e)).blob()).arrayBuffer();return Yk.debug("compressJSON ".concat(r.length," -> ").concat(i.byteLength," ").concat(_C()-t,"ms")),i}catch(lD){return r}}))}var GC=Object.prototype.hasOwnProperty,KC=e=>"function"==typeof e,zC=e=>e.isRemote,qC=function(e){if(!e||"object"!=typeof e||"[object Object]"!=Object.prototype.toString.call(e))return!1;let t=Object.getPrototypeOf(e);if(null===t)return!0;let r=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Function.prototype.toString.call(r)===Function.prototype.toString.call(Object)};var YC=function(e){let{retryFunction:t,settings:r,onError:i,onRetrying:o,onRetryFailed:n,onRetrySuccess:a,context:s}=e;return function(){for(var e=arguments.length,c=new Array(e),l=0;l<e;l++)c[l]=arguments[l];let{retries:u=5,timeout:d=1e3}=r,h=0,p=-1,m=0,f=(e,r)=>Wb(this,null,(function*(){let l=s||this;try{let r=yield t.apply(l,c);h>0&&a&&a.call(this,h),h=0,e(r)}catch(_){let t=()=>{clearTimeout(p),h=0,m=2,r(_)},a=()=>{2!==m&&h<(KC(u)?u():u)?(h++,m=1,KC(o)&&o.call(this,h,t),p=window.setTimeout((()=>{p=-1,f(e,r)}),KC(d)?d(h):d)):(t(),KC(n)&&n.call(this,_))};KC(i)?i.call(this,{error:_,retry:a,reject:r,retryFuncArgs:c,retriedCount:h}):a()}}));return new Promise(f)}},JC=class{constructor(e){Bb(this,"userId"),Bb(this,"remoteUserId"),Bb(this,"id"),Bb(this,"sdkAppId"),Bb(this,"type"),Bb(this,"isLocal"),this.id=e.id,this.userId=e.userId,this.sdkAppId=e.sdkAppId,this.remoteUserId=e.remoteUserId,this.isLocal="boolean"!=typeof e.isLocal||e.isLocal,this.type=this.isLocal?"":e.type}createChild(e){return Object.setPrototypeOf(e,this)}setUserId(e){this.userId=e}setSdkAppId(e){this.sdkAppId=e}log(e,t){let r=this.isLocal?this.userId:this.remoteUserId;t.unshift("[".concat(this.isLocal?"↑":"↓").concat(this.type&&"main"!==this.type?"*":"").concat(this.id).concat(r?"|".concat(r):"","]")),Yk.log(e,t,void 0===this.userId||function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(qC(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(GC.call(e,t))return!1;return!0}return!1}(this.userId),this.userId,this.sdkAppId)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(2,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(1,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(3,t)}error(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.log(4,t)}},XC={};Ub(XC,{ANDROID_VERSION:()=>lN,CHROME_MAJOR_VERSION:()=>pk,CHROME_VERSION:()=>mk,EDGE_VERSION:()=>_N,EDG_MAJOR_VERSION:()=>vN,EDG_VERSION:()=>EN,FIREFOX_MAJOR_VERSION:()=>mN,FIREFOX_VERSION:()=>pN,HUAWEI_VERSION:()=>ek,IE_VERSION:()=>NN,IOS_MAIN_VERSION:()=>Tk,IOS_VERSION:()=>vk,IPADQQB_VERSION:()=>HN,IS_ANDROID:()=>cN,IS_ANDROID_WEBVIEW:()=>Ek,IS_ANY_SAFARI:()=>_k,IS_CHROME:()=>dk,IS_CHROME_OS:()=>KN,IS_CHROMIUM_BASE:()=>uk,IS_DESKTOP_IOS_CHROME:()=>bk,IS_EDG:()=>gN,IS_EDGE:()=>fN,IS_ELECTRON:()=>YN,IS_FIREFOX:()=>hN,IS_HEADLESS_CHROME:()=>hk,IS_HONOR:()=>ZN,IS_HUAWEI:()=>QN,IS_HUAWEIBROWSER:()=>$N,IS_IE:()=>CN,IS_IE8:()=>DN,IS_IOS:()=>sN,IS_IOS_13_OR_14:()=>Sk,IS_IOS_15_1:()=>Ak,IS_IOS_CHROME:()=>Rk,IS_IPAD:()=>iN,IS_IPADQQB:()=>BN,IS_IPAD_PRO:()=>oN,IS_IPHONE:()=>nN,IS_IPOD:()=>aN,IS_LINUX:()=>GN,IS_LOCAL:()=>wk,IS_MAC:()=>jN,IS_MACQQB:()=>VN,IS_MIBROWSER:()=>JN,IS_MQQB:()=>LN,IS_NATIVE_ANDROID:()=>dN,IS_OLD_ANDROID:()=>uN,IS_OPENHARMONY:()=>sk,IS_OPPOBROWSER:()=>ik,IS_SAFARI:()=>fk,IS_SAFARI_15_1:()=>Ik,IS_SAMSUNGBROWSER:()=>tk,IS_SOGOU:()=>IN,IS_SOGOUM:()=>yN,IS_TBS:()=>SN,IS_UCBROWSER:()=>qN,IS_VIVOBROWSER:()=>nk,IS_WECHAT:()=>kN,IS_WIN:()=>WN,IS_WQQB:()=>xN,IS_WX:()=>zN,IS_X5MQQB:()=>MN,IS_XWEB:()=>bN,MACQQB_VERSION:()=>FN,MI_VERSION:()=>XN,MQQB_VERSION:()=>PN,OPENHARMONY_VERSION:()=>ck,OPPO_VERSION:()=>ok,SAFARI_VERSION:()=>gk,SAMSUNG_VERSION:()=>rk,SOGOUM_VERSION:()=>TN,SOGOU_VERSION:()=>AN,TBS_VERSION:()=>RN,UA_DATA_STRING:()=>Mk,USER_AGENT:()=>$C,VIVO_VERSION:()=>ak,WECHAT_VERSION:()=>ON,WQQB_VERSION:()=>UN,XWEB_VERSION:()=>wN,browserInfo:()=>Ck,getBrowserInfo:()=>Nk,getChromeMajorVersion:()=>lk,getDeviceModel:()=>xk,getGPUInfo:()=>Pk,getOSName:()=>Vk,getOSNumber:()=>Fk,getOSString:()=>Bk,getOSType:()=>Wk,getTerminalType:()=>Hk,getUserAgentData:()=>Lk,isLocalStorageEnabled:()=>Dk,isMobile:()=>Ok,isVersionSmallerThan:()=>yk});var $C="undefined"==typeof navigator?"":navigator.userAgent,QC=e=>new RegExp(e,"i").test($C),ZC=e=>{if(QC(e)){let t=new RegExp("".concat(e,"\\/([\\d.]+)")),r=$C.match(t);if(r&&r[1])return r[1]}return""},eN=e=>{if(QC(e)){let t=new RegExp("".concat(e,"\\/(\\d+)")),r=$C.match(t);if(r&&r[1])return parseFloat(r[1])}return NaN},tN=/AppleWebKit\/([\d.]+)/i.exec($C),rN=tN?parseFloat(tN[1]):NaN,iN=QC("iPad"),oN="undefined"!=typeof navigator&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&QC("Macintosh"),nN=QC("iPhone")&&!iN,aN=QC("iPod"),sN=nN||iN||aN||oN,cN=QC("Android"),lN=function(){if(cN){let e=$C.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}(),uN=cN&&QC("webkit")&&lN<2.3,dN=cN&&lN<5&&rN<537,hN=QC("Firefox"),pN=ZC("Firefox"),mN=eN("Firefox"),fN=QC("Edge"),_N=ZC("Edge"),gN=QC("Edg"),EN=ZC("Edg"),vN=eN("Edg"),yN=QC("SogouMobileBrowser"),TN=ZC("SogouMobileBrowser"),IN=QC("MetaSr\\s"),AN=ZC("MetaSr\\s"),SN=QC("TBS"),RN=ZC("TBS"),bN=QC("XWEB"),wN=ZC("XWEB"),DN=QC("MSIE\\s8\\.0"),CN=QC("MSIE\\/\\d+"),NN=function(){if(CN){let e=/MSIE\s(\d+)\.\d/.exec($C),t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test($C)&&/rv:11.0/.test($C)&&(t=11),t}return NaN}(),kN=QC("(micromessenger|webbrowser)"),ON=ZC("MicroMessenger"),MN=!SN&&QC("MQQBrowser")&&QC("COVC"),LN=!SN&&QC("MQQBrowser")&&!QC("COVC"),PN=LN||MN?ZC("MQQBrowser"):"",xN=!SN&&QC(" QQBrowser"),UN=ZC(" QQBrowser"),VN=!SN&&QC("QQBrowserLite"),FN=ZC("QQBrowserLite"),BN=!SN&&QC("MQBHD"),HN=ZC("MQBHD"),WN=QC("Windows"),jN=!sN&&QC("MAC OS X"),GN=!cN&&QC("Linux"),KN=QC("CrOS"),zN=QC("MicroMessenger"),qN=QC("UCBrowser"),YN=QC("Electron"),JN=QC("MiuiBrowser"),XN=ZC("MiuiBrowser"),$N=QC("HuaweiBrowser"),QN=QC("Huawei")||QC("HUAWEI"),ZN=QC("Honor")||QC("HONOR"),ek=ZC("HuaweiBrowser"),tk=QC("SamsungBrowser"),rk=ZC("SamsungBrowser"),ik=QC("HeyTapBrowser"),ok=ZC("HeyTapBrowser"),nk=QC("VivoBrowser"),ak=ZC("VivoBrowser"),sk=QC("OpenHarmony"),ck=ZC("OpenHarmony"),lk=()=>eN("Chrome"),uk=QC("Chrome"),dk=!fN&&!IN&&!yN&&!SN&&!bN&&!gN&&!xN&&!JN&&!$N&&!tk&&!ik&&!nk&&uk,hk=QC("HeadlessChrome"),pk=lk(),mk=ZC("Chrome"),fk=!uk&&!LN&&!MN&&!VN&&!BN&&QC("Safari"),_k=fk||sN,gk=ZC("Version"),Ek=/Android.*(wv|.0.0.0)/.test($C),vk=(()=>{if(oN)return gk;if(sN){let e=$C.match(/OS (\d+)_(\d+)/i);if(e&&e[1]){let t=e[1];return e[2]&&(t+=".".concat(e[2])),t}}return""})();function yk(e,t){let r=e.split(".").map((e=>Number(e))),i=t.split(".").map((e=>Number(e)));for(let o=0;o<Math.max(r.length,i.length);o++){let e=r[o]||0,t=i[o]||0;if(e<t)return!0;if(e>t)return!1}return!1}var Tk=Number(vk.split(".")[0]),Ik="15.1"===gk,Ak="15.1"===vk,Sk=(()=>{let e=Number(vk.split(".")[0]);return 14===e||13===e})(),Rk=QC("CriOS"),bk=Rk&&"11.1.1"===gk,wk="undefined"!=typeof location&&("file:"===location.protocol||"localhost"===location.hostname||"127.0.0.1"===location.hostname),Dk=(()=>{let e;return()=>{if(void 0===e)try{e=!!window.localStorage}catch(rO){e=!1}return e}})(),Ck=Nk();function Nk(){let e=new Map([[hN,["Firefox",pN]],[gN,["Edg",EN]],[dk,["Chrome",mk]],[fk,["Safari",gk]],[SN,["TBS",RN]],[bN,["XWEB",wN]],[kN&&nN,["WeChat",ON]],[xN,["QQ(Win)",UN]],[LN,["QQ(Mobile)",PN]],[MN,["QQ(Mobile X5)",PN]],[VN,["QQ(Mac)",FN]],[BN,["QQ(iPad)",HN]],[JN,["MI",XN]],[$N,["HW",ek]],[tk,["Samsung",rk]],[ik,["OPPO",ok]],[nk,["VIVO",ak]],[fN,["EDGE",_N]],[yN,["SogouMobile",TN]],[IN,["Sogou",AN]]]),t="unknown",r="unknown";return e.has(!0)&&([t,r]=e.get(!0)),{name:t,version:r}}var kk=null;function Ok(){return kk&&"boolean"==typeof kk.mobile?kk.mobile:cN||sN||nN||iN||sk}var Mk="";function Lk(){return Wb(this,null,(function*(){if(kk)return kk;if(!navigator.userAgentData||"function"!=typeof navigator.userAgentData.getHighEntropyValues)return null;try{return(kk=yield navigator.userAgentData.getHighEntropyValues(["architecture","bitness","model","platformVersion","fullVersionList"]))&&!Mk&&(Mk="UAData: ".concat(kk.platform,"/").concat(kk.platformVersion),kk.architecture&&kk.bitness&&(Mk+=" ".concat(kk.architecture,"/").concat(kk.bitness)),kk.mobile&&(Mk+=" mobile"),kk.model&&(Mk+=" model: ".concat(kk.model.replace(/\s+/g,"/"))),kk.fullVersionList&&(Mk+=" ".concat(kk.fullVersionList.filter((e=>"Not/A)Brand"!==e.brand)).map((e=>"".concat(e.brand,"/").concat(e.version))).join(",")))),kk}catch(PF){return null}}))}function Pk(){try{let e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(!t)return"";let r=t.getExtension("WEBGL_debug_renderer_info");if(r){let e=t.getParameter(r.UNMASKED_VENDOR_WEBGL),i=t.getParameter(r.UNMASKED_RENDERER_WEBGL);return"".concat(e," ").concat(i)}return""}catch(PF){return""}}function xk(){return(null==kk?void 0:kk.model)||""}var Uk=new Map([[cN,"Android"],[sN,"iOS"],[WN,"Windows"],[jN,"MacOS"],[GN,"Linux"],[KN,"ChromeOS"]]),Vk=function(){return Uk.get(!0)?Uk.get(!0):kk?kk.platform:"unknown"};function Fk(){return WN?1:cN?2:jN?3:sN?4:GN?5:KN?6:0}var Bk=()=>{let e=Vk();return e+="/".concat(Ck.name,"/").concat(fk?Ck.version:Ck.version.split(".")[0]),null!=kk&&kk.platformVersion&&(e+="/".concat(kk.platformVersion)),null!=kk&&kk.architecture&&(e+="/".concat(kk.architecture)),e};function Hk(){return cN?4:nN?2:iN?3:jN?12:WN?5:GN?13:sk?22:1}function Wk(){return cN?"Android":nN?"iPhone":iN?"iPad":jN?"Mac":WN?"Windows":GN?"Linux":"unknown"}var jk,Gk=new(Vb(jb(),1).default),Kk=((jk=Kk||{}).ROOM_DESTROY="1",jk.JOIN_START="21",jk.JOIN_SCHEDULE_SUCCESS="22",jk.JOIN_SIGNAL_CONNECTION_START="23",jk.JOIN_SIGNAL_CONNECTION_END="24",jk.JOIN_SEND_CMD="25",jk.JOIN_RECEIVED_CMD_RES="26",jk.JOIN_SUCCESS="27",jk.JOIN_FAILED="28",jk.LEAVE_START="51",jk.LEAVE_SEND_CMD="52",jk.LEAVE_SUCCESS="53",jk.PUBLISH_START="61",jk.SEND_FIRST_VIDEO_FRAME="62",jk.PUBLISH_FAILED="63",jk.SUBSCRIBE_START="81",jk.SUBSCRIBE_SUCCESS="82",jk.SUBSCRIBE_FAILED="84",jk.UNSUBSCRIBE_SUCCESS="83",jk.LOCAL_TRACK_CAPTURE_START="101",jk.LOCAL_TRACK_CAPTURE_SUCCESS="102",jk.LOCAL_TRACK_CAPTURE_FAILED="103",jk.LOCAL_TRACK_PUBLISHED="104",jk.LOCAL_TRACK_UNPUBLISHED="105",jk.LOCAL_TRACK_REPLACED="106",jk.SWITCH_DEVICE_SUCCESS="107",jk.TRACK_MUTED="108",jk.TRACK_UNMUTED="109",jk.REMOTE_TRACK_SUBSCRIBED="110",jk.REMOTE_TRACK_UNSUBSCRIBED="111",jk.LOCAL_TRACK_RECAPTURE="112",jk.LOCAL_AUDIO_STARTED="113",jk.LOCAL_AUDIO_STOPPED="114",jk.REMOTE_AUDIO_STARTED="115",jk.REMOTE_AUDIO_STOPPED="116",jk.PLAY_TRACK_START="151",jk.PLAYER_STATE_CHANGED="152",jk.VIDEO_LOADED_DATA="153",jk.AUTOPLAY_DIALOG_CLICK_CONFIRM="154",jk.SIGNAL_CONNECTION_STATE_CHANGED="201",jk.PEER_CONNECTION_STATE_CHANGED="202",jk.SINGLE_CONNECTION_STAT="203",jk.SPC_RECONNECTED="204",jk.HEARTBEAT_REPORT="251",jk.RECEIVED_PUBLISHED_USER_LIST="252",jk.REMOTE_PUBLISH_STATE_CHANGED="253",jk.AUDIO_LEVEL_INTERVAL="260",jk.NETWORK_QUALITY="261",jk.VIDEO_CODEC_IMPLEMENTATION_CHANGED="262",jk.QUALITY_LIMITATION_CHANGED="263",jk.LOG="264",jk.SWITCH_ROOM_START="401",jk.SWITCH_ROOM_SUCCESS="407",jk.SWITCH_ROOM_FAILED="408",jk),zk=Kk,qk=class e{constructor(){Bb(this,"_isEnableUploadLog",!0),Bb(this,"_localJoinedUser",new Map),Bb(this,"_queue",[]),Bb(this,"_timeoutId",-1),Bb(this,"_logLevel",1),Bb(this,"_logLevelToUpload",2),!cw&&!lw&&(this.checkURLParam(),this.installEvents())}get isAbleToUpload(){return this._isEnableUploadLog&&-1!==this._timeoutId}installEvents(){Gk.on(zk.JOIN_SCHEDULE_SUCCESS,(e=>{let{schedule:t}=e;var r;null!=(r=null==t?void 0:t.config)&&r.logLevelToUpload&&Rw[t.config.logLevelToUpload]&&(this._logLevelToUpload=t.config.logLevelToUpload)})),Gk.on(zk.JOIN_SUCCESS,(e=>{let{room:t}=e;this.addJoinedUser({userId:t.userId,sdkAppId:t.sdkAppId}),this.startUpload()})),Gk.once(zk.JOIN_FAILED,(()=>{this.startUpload()})),Gk.on(zk.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.deleteJoinedUser(t.userId)}))}startUpload(){-1===this._timeoutId&&this.uploadInterval()}addJoinedUser(e){this._localJoinedUser.set(e.userId,e),this.startUpload()}deleteJoinedUser(e){this._localJoinedUser.delete(e)}uploadInterval(){this.upload().catch((()=>{})),this._timeoutId=window.setTimeout((()=>this.uploadInterval()),5e3)}getLogsToUpload(){let e={map:new Map,splicedQueue:[]};if(this._queue[0].forAllJoinedClients&&0===this._localJoinedUser.size)return e;let t=0;for(;t<this._queue.length&&50!==t;t++){let r=this._queue[t];if(r.forAllJoinedClients)this._localJoinedUser.forEach((t=>{let{userId:i,sdkAppId:o}=t;e.map.has(i)?e.map.get(i).logs.push(r):e.map.set(i,{userId:i,sdkAppId:o,logs:[r]})}));else if(oC(r.userId)&&nC(r.sdkAppId)){let{userId:t,sdkAppId:i}=r;e.map.has(t)?e.map.get(t).logs.push(r):e.map.set(t,{userId:t,sdkAppId:i,logs:[r]})}}return e.map.size>0&&(e.splicedQueue=this._queue.splice(0,t)),e}upload(){return Wb(this,null,(function*(){if(0===this._queue.length||!this._isEnableUploadLog)return;let{map:e,splicedQueue:t}=this.getLogsToUpload();if(0===e.size)return;try{let t=[...e.values()];for(let e=0;e<t.length;e++){let{userId:r,sdkAppId:i,logs:o}=t[e];yield this.uploadLogWithRetry(JSON.stringify({timestamp:Zb(),sdkAppId:String(i),userId:r,version:ow,log:o.map((e=>e.log)).join("\n")}),i),o.forEach((e=>e.uploaded=!0))}}catch(iO){}let r=t.filter((e=>!e.uploaded));r.length>0&&(this._queue=r.concat(this._queue))}))}uploadLogWithRetry(e,t){return YC({retryFunction:()=>WC({url:FD(t,Aw.LOG),body:e,timeout:5e3,priority:"low"}),settings:{retries:3,timeout:2e3},onError:e=>{let{retry:t}=e;t()}})()}getPrefix(e){let t=new Date;return t.setTime(Qb()),"[".concat(ew(t),"] <").concat(Rw[e],">")}getLogLevel(){return this._logLevel}setLogLevel(e){iC(Rw[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(aw){return""}}log(t,r){let i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],o=arguments.length>3?arguments[3]:void 0,n=arguments.length>4?arguments[4]:void 0;var a;r.unshift(this.getPrefix(t));let s={log:r.reduce(((e,t)=>"".concat(e," ").concat(this.logChunkToString(t)).trim()),""),level:t,userId:o,sdkAppId:n,forAllJoinedClients:i};if(Gk.emit(zk.LOG,{log:s}),this._isEnableUploadLog&&t>=this._logLevelToUpload&&this._queue.push(s),t<this._logLevel)return;let c=(null==(a=Rw[t])?void 0:a.toLowerCase())||"info";e.PRINT_LOG_TAG?console[c]("%cTRTC%c%s","padding: 1px 4px;border-radius: 3px;color: #fff;background: #1E88E5;","display: inline",...r):console[c](...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){return new JC(e)}checkURLParam(){let e=new URLSearchParams(location.search).get("logLevelToUpload"),t=e?Number(e):-1;Rw[t]&&(this._logLevelToUpload=t)}getQueue(){return this._queue}};Bb(qk,"PRINT_LOG_TAG",!(sN||cN||hk));var Yk=new qk,Jk=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)}))},Xk=new class{constructor(){Bb(this,"_prefix","TRTC"),Bb(this,"_queue",new Map)}getRealKey(e){return"".concat(this._prefix,"_").concat(e)}checkStorage(){Dk()&&(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(iO){return!1}return!1})).forEach((e=>localStorage.removeItem(e))))}doFlush(){if(Dk())try{for(let[e,t]of this._queue)localStorage.setItem(e,JSON.stringify(t))}catch(rO){Yk.warn(rO)}}getItem(e){if(!Dk())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(aw){Yk.warn(aw)}}setItem(e,t){if(Dk())try{let r={expiresIn:Date.now()+Cw,value:t};this._queue.set(this.getRealKey(e),r)}catch(lD){Yk.warn(lD)}}deleteItem(e){if(!Dk())return!1;try{return e=this.getRealKey(e),this._queue.delete(e),localStorage.removeItem(e),!0}catch(aw){return Yk.warn(aw),!1}}clear(){if(Dk())try{localStorage.clear()}catch(rO){Yk.warn(rO)}}},$k={};Ub($k,{HTTPS_API:()=>NM,IS_GET_CAPABILITIES_SUPPORTED:()=>JM,IS_GET_SETTINGS_SUPPORTED:()=>YM,IS_GET_SYNCHRONIZATION_SOURCES_SUPPORTED:()=>qM,IS_INSERTABLE_STREAM_SUPPORTED:()=>XM,IS_JITTER_BUFFER_TARGET_SUPPORTED:()=>cL,IS_RTC_RTP_SENDER_SUPPORTED:()=>GM,IS_SCRIPT_TRANSFORM_SUPPORTED:()=>$M,IS_SEI_SUPPORTED:()=>QM,IS_SPC_SUPPORTED:()=>WM,basis:()=>oL,capabilityCheck:()=>aL,checkSystemRequirementsInternal:()=>bM,decodeSupportStatus:()=>RM,encodeSupportStatus:()=>SM,getBrowserInfo:()=>gM,getDisplayResolution:()=>OM,isAddTransceiverSupported:()=>HM,isBrowserSupported:()=>EM,isGetReceiversSupported:()=>VM,isGetSendersSupported:()=>FM,isGetTransceiversSupported:()=>BM,isGetUserMediaSupported:()=>MM,isMediaDevicesSupported:()=>yM,isMediaSessionSupported:()=>tL,isMediaStreamTrackProcessorSupported:()=>AM,isReplaceTrackSupported:()=>KM,isRequestVideoFrameCallbackSupported:()=>sL,isSIMDSupported:()=>iL,isScreenCaptureApiAvailable:()=>DM,isSelectedCandidatePair:()=>kM,isSetParametersSupported:()=>zM,isSmallStreamAPISupported:()=>PM,isSmallStreamSupported:()=>xM,isStopTransceiverSupported:()=>jM,isTRTCSupported:()=>wM,isUnifiedPlanDefault:()=>UM,isUsedInHttpProtocol:()=>IM,isWebAudioSupported:()=>LM,isWebCodecSupported:()=>eL,isWebCodecsSupported:()=>vM,isWebRTCSupported:()=>ZM,isWebTransportSupported:()=>rL});var Qk={};Ub(Qk,{AUDIO_LEVEL_SCALE:()=>WO,AudioCodecPipelineType:()=>qO,AudioDecoderDowngradeState:()=>AO,AudioPlayerMode:()=>FO,AudioType:()=>CO,BASIC_TYPE:()=>GO,BannedReason:()=>BO,CONNECTION_CLOSED_REASON:()=>uO,ClientEvent:()=>dO,CodecType:()=>YO,ConnectionEvent:()=>lO,ConnectionState:()=>IO,DECODE_FAILED_ERROR_CODE:()=>JO,FacingMode:()=>UO,LeaveReason:()=>HO,LocalTrackEvent:()=>pO,MULTI_VIDEO_DATA_TYPE:()=>MO,MediaType:()=>wO,MediaTypeLabel:()=>DO,MonitorEventId:()=>LO,MutedFlag:()=>EO,NetworkQualityValue:()=>PO,PlayerState:()=>mO,ReceiveMode:()=>xO,RemoteStreamType:()=>OO,RemoteTrackEvent:()=>gO,RoomEvent:()=>fO,SMALL_MODE:()=>QO,SceneNumber:()=>vO,StreamEvent:()=>hO,StreamType:()=>kO,SubscribeMediaType:()=>jO,TIMER_TYPE:()=>$O,TRACK_ACTION:()=>bO,TRACK_KIND:()=>RO,TrackEvent:()=>_O,UserRole:()=>TO,UserRoleNumber:()=>yO,VideoCodec:()=>KO,VideoCodecPipelineType:()=>zO,VideoContentHint:()=>XO,VideoDecoderDowngradeState:()=>SO,VideoPlayerMode:()=>VO,VideoType:()=>NO});var Zk,eO,tO,rO,iO,oO,nO,aO,sO,cO,lO=((cO=lO||{}).TRACK_ADDED="track-added",cO.TRACK_UPDATED="track-updated",cO.TRACK_SUBSCRIBED="track-subscribed",cO.STREAM_ADDED="stream-added",cO.STREAM_REMOVED="stream-removed",cO.STREAM_UPDATED="stream-updated",cO.STREAM_PUBLISHED="stream-published",cO.STREAM_SUBSCRIBED="stream-subscribed",cO.STREAM_UNSUBSCRIBED="stream-unsubscribed",cO.STATE_CHANGED="state-changed",cO.ERROR="error",cO.CONNECTION_STATE_CHANGED="connection-state-changed",cO.FIREWALL_RESTRICTION="firewall-restriction",cO.SEI_MESSAGE="sei-message",cO.CLOSED="closed",cO),uO=(e=>(e.REMOTE_LEAVE="remote user exitRoom",e.REMOTE_UNPUBLISH="remote user unpublished",e.LOCAL_LEAVE="you exitRoom",e.LOCAL_UNPUBLISH="you unpublished",e.LOCAL_UNSUBSCRIBE="you unsubscribed",e.SWITCH_ROLE="you switch role to audience",e))(uO||{}),dO=((sO=dO||{}).STREAM_ADDED="stream-added",sO.STREAM_REMOVED="stream-removed",sO.STREAM_UPDATED="stream-updated",sO.STREAM_SUBSCRIBED="stream-subscribed",sO.CONNECTION_STATE_CHANGED="connection-state-changed",sO.PEER_JOIN="peer-join",sO.PEER_LEAVE="peer-leave",sO.MUTE_AUDIO="mute-audio",sO.MUTE_VIDEO="mute-video",sO.UNMUTE_AUDIO="unmute-audio",sO.UNMUTE_VIDEO="unmute-video",sO.CLIENT_BANNED="client-banned",sO.NETWORK_QUALITY="network-quality",sO.AUDIO_VOLUME="audio-volume",sO.SEI_MESSAGE="sei-message",sO.ERROR="error",sO),hO=((aO=hO||{}).PLAYER_STATE_CHANGED="player-state-changed",aO.SCREEN_SHARING_STOPPED="screen-sharing-stopped",aO.CONNECTION_STATE_CHANGED="connection-state-changed",aO.DEVICE_AUTO_RECOVERED="device-auto-recovered",aO.ERROR="error",aO),pO=(e=>(e.DEVICE_AUTO_RECOVERED="1",e.DEVICE_RECOVER_FAILED="5",e.DEVICE_CHANGED="2",e.ERROR="3",e.PUBLISH_STATE_CHANGED="4",e.ENCODE_FAILED="6",e))(pO||{}),mO=(e=>(e.PAUSED="PAUSED",e.PLAYING="PLAYING",e.STOPPED="STOPPED",e))(mO||{}),fO=((nO=fO||{}).PEER_JOIN="peer-join",nO.PEER_LEAVE="peer-leave",nO.SIGNAL_CONNECTION_STATE_CHANGED="signal-connection-state-changed",nO.MEDIA_CONNECTION_STATE_CHANGED="media-connection-state-changed",nO.BANNED="banned",nO.NETWORK_QUALITY="network-quality",nO.AUDIO_VOLUME="audio-volume",nO.SEI_MESSAGE="sei-message",nO.ERROR="error",nO.REMOTE_PUBLISH_STATE_CHANGED="remote-publish-state-changed",nO.REMOTE_PUBLISHED="remote-published",nO.REMOTE_UNPUBLISHED="remote-unpublished",nO.FIREWALL_RESTRICTION="firewall-restriction",nO.HEARTBEAT_REPORT="heartbeat-report",nO.CUSTOM_MESSAGE="custom-message",nO.LAYER_DATA="layerData",nO.FIRST_VIDEO_FRAME="first-video-frame",nO.DUMP="dump",nO.AUDIO_FRAME="audio-frame",nO.SUBSCRIBE_SMALL_VIDEO_CHANGED="subscribe-small-video-changed",nO),_O=((oO=_O||{}).PLAYER_STATE_CHANGED="player-state-changed",oO.MUTE="mute",oO.UNMUTE="unmute",oO.ERROR="error",oO.INPUT_MEDIA_TRACK_CHANGED="input-media-track-changed",oO.OUTPUT_MEDIA_TRACK_CHANGED="output-media-track-changed",oO.FIRST_VIDEO_FRAME="first-video-frame",oO),gO=(e=>(e.DECODE_FAILED="decode-failed",e.DECODE_DOWNGRADE_STATE_CHANGED="decode-downgrade-state-changed",e))(gO||{}),EO=(e=>(e[e.VIDEO=1]="VIDEO",e[e.SMALL=2]="SMALL",e[e.AUX=4]="AUX",e[e.AUDIO=8]="AUDIO",e[e.VIDEO_MUTE=16]="VIDEO_MUTE",e[e.AUX_MUTE=32]="AUX_MUTE",e[e.AUDIO_MUTE=64]="AUDIO_MUTE",e))(EO||{}),vO=(e=>(e[e.RTC=1]="RTC",e[e.LIVE=2]="LIVE",e))(vO||{}),yO=(e=>(e[e.ANCHOR=20]="ANCHOR",e[e.AUDIENCE=21]="AUDIENCE",e))(yO||{}),TO=(e=>(e.ANCHOR="anchor",e.AUDIENCE="audience",e))(TO||{}),IO=(e=>(e.CONNECTED="CONNECTED",e.DISCONNECTED="DISCONNECTED",e.CONNECTING="CONNECTING",e.RECONNECTED="RECONNECTED",e.RECONNECTING="RECONNECTING",e))(IO||{}),AO=((iO=AO||{}).INITIALIZED="INITIALIZED",iO.STARTING="STARTING",iO.STARTED="STARTED",iO.FAILED="FAILED",iO),SO=(e=>(e.INITIALIZED="INITIALIZED",e.STARTING="STARTING",e.STARTED="STARTED",e.FAILED="FAILED",e))(SO||{}),RO=(e=>(e.AUDIO="audio",e.VIDEO="video",e.AUXILIARY="auxVideo",e))(RO||{}),bO=(e=>(e.ADD="add",e.REMOVE="remove",e))(bO||{}),wO=(e=>(e[e.NULL=0]="NULL",e[e.AUDIO=1]="AUDIO",e[e.AUX_VIDEO=2]="AUX_VIDEO",e[e.BIG_VIDEO=4]="BIG_VIDEO",e[e.SMALL_VIDEO=8]="SMALL_VIDEO",e))(wO||{}),DO={1:"audio",2:"auxVideo",4:"video"},CO=((rO=CO||{})[rO.opus=111]="opus",rO),NO=(e=>(e[e.h264=100]="h264",e[e.vp8=101]="vp8",e))(NO||{}),kO=(e=>(e.Big="big",e.Small="small",e))(kO||{}),OO=(e=>(e.Main="main",e.Aux="auxiliary",e))(OO||{}),MO=(e=>(e[e.MULTI_DATA_AUDIO=1]="MULTI_DATA_AUDIO",e[e.MULTI_DATA_BIG_IMG=2]="MULTI_DATA_BIG_IMG",e[e.MULTI_DATA_SMALL_IMG=3]="MULTI_DATA_SMALL_IMG",e[e.MULTI_DATA_AUX_IMG=7]="MULTI_DATA_AUX_IMG",e[e.MULTI_DATA_TYPE_BUTT=12]="MULTI_DATA_TYPE_BUTT",e))(MO||{}),LO=((tO=LO||{})[tO.PUBLISH_VIDEO=32768]="PUBLISH_VIDEO",tO[tO.PUBLISH_AUDIO=32769]="PUBLISH_AUDIO",tO[tO.UNPUBLISH_VIDEO=32770]="UNPUBLISH_VIDEO",tO[tO.UNPUBLISH_AUDIO=32771]="UNPUBLISH_AUDIO",tO[tO.MUTE_AUDIO=32772]="MUTE_AUDIO",tO[tO.MUTE_VIDEO=32773]="MUTE_VIDEO",tO[tO.UNMUTE_AUDIO=32774]="UNMUTE_AUDIO",tO[tO.UNMUTE_VIDEO=32775]="UNMUTE_VIDEO",tO[tO.SUBSCRIBE_VIDEO=32776]="SUBSCRIBE_VIDEO",tO[tO.SUBSCRIBE_AUDIO=32777]="SUBSCRIBE_AUDIO",tO[tO.UNSUBSCRIBE_VIDEO=32778]="UNSUBSCRIBE_VIDEO",tO[tO.UNSUBSCRIBE_AUDIO=32779]="UNSUBSCRIBE_AUDIO",tO[tO.SWITCH_CAMERA=32780]="SWITCH_CAMERA",tO[tO.SWITCH_MICROPHONE=32781]="SWITCH_MICROPHONE",tO[tO.REPLACE_VIDEO=32782]="REPLACE_VIDEO",tO[tO.REPLACE_AUDIO=32783]="REPLACE_AUDIO",tO[tO.MUTE_REMOTE_VIDEO=32784]="MUTE_REMOTE_VIDEO",tO[tO.MUTE_REMOTE_AUDIO=32785]="MUTE_REMOTE_AUDIO",tO[tO.UNMUTE_REMOTE_VIDEO=32786]="UNMUTE_REMOTE_VIDEO",tO[tO.UNMUTE_REMOTE_AUDIO=32787]="UNMUTE_REMOTE_AUDIO",tO[tO.JOIN=32788]="JOIN",tO[tO.LEAVE=32789]="LEAVE",tO[tO.SIGNAL_DISCONNECTED=32790]="SIGNAL_DISCONNECTED",tO[tO.SIGNAL_CONNECTED=32791]="SIGNAL_CONNECTED",tO[tO.TRANSPORT_UPLINK_CONNECTED=32792]="TRANSPORT_UPLINK_CONNECTED",tO[tO.TRANSPORT_DOWNLINK_CONNECTED=32793]="TRANSPORT_DOWNLINK_CONNECTED",tO[tO.SIGNAl_RECONNECTING=32794]="SIGNAl_RECONNECTING",tO[tO.SIGNAL_RECONNECT_SUCCESS=32795]="SIGNAL_RECONNECT_SUCCESS",tO[tO.SIGNAL_RECONNECT_FAIL=32796]="SIGNAL_RECONNECT_FAIL",tO[tO.TRANSPORT_UPLINK_RECONNECTING=32797]="TRANSPORT_UPLINK_RECONNECTING",tO[tO.TRANSPORT_UPLINK_RECONNECT_SUCCESS=32798]="TRANSPORT_UPLINK_RECONNECT_SUCCESS",tO[tO.TRANSPORT_UPLINK_RECONNECT_FAIL=32799]="TRANSPORT_UPLINK_RECONNECT_FAIL",tO[tO.TRANSPORT_DOWNLINK_RECONNECTING=32800]="TRANSPORT_DOWNLINK_RECONNECTING",tO[tO.TRANSPORT_DOWNLINK_RECONNECT_SUCCESS=32801]="TRANSPORT_DOWNLINK_RECONNECT_SUCCESS",tO[tO.TRANSPORT_DOWNLINK_RECONNECT_FAIL=32802]="TRANSPORT_DOWNLINK_RECONNECT_FAIL",tO[tO.SUBSCRIBE_SMALL_VIDEO=32803]="SUBSCRIBE_SMALL_VIDEO",tO[tO.UNSUBSCRIBE_SMALL_VIDEO=32804]="UNSUBSCRIBE_SMALL_VIDEO",tO[tO.PUBLISH_AUX=32805]="PUBLISH_AUX",tO[tO.UNPUBLISH_AUX=32806]="UNPUBLISH_AUX",tO[tO.DEVICE_CAPTURE=2003]="DEVICE_CAPTURE",tO[tO.VIDEO_ENCODER=4004]="VIDEO_ENCODER",tO[tO.VIDEO_DECODER=4005]="VIDEO_DECODER",tO),PO=(e=>(e[e.UNKNOWN=0]="UNKNOWN",e[e.EXCELLENT=1]="EXCELLENT",e[e.GOOD=2]="GOOD",e[e.POOR=3]="POOR",e[e.BAD=4]="BAD",e[e.VERY_BAD=5]="VERY_BAD",e[e.DISCONNECTED=6]="DISCONNECTED",e))(PO||{}),xO=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTO_AUDIO=1]="AUTO_AUDIO",e[e.AUTO_VIDEO=2]="AUTO_VIDEO",e[e.AUTO_ALL=3]="AUTO_ALL",e))(xO||{}),UO=(e=>(e.user="user",e.environment="environment",e))(UO||{}),VO=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CANVAS_FROM_ELEMENT=1]="CANVAS_FROM_ELEMENT",e[e.CANVAS_WITHOUT_ELEMENT=2]="CANVAS_WITHOUT_ELEMENT",e))(VO||{}),FO=(e=>(e[e.ELEMENT=0]="ELEMENT",e[e.CONTEXT=1]="CONTEXT",e))(FO||{}),BO=(e=>(e.BANNED="banned",e.KICK="kick",e.USER_TIME_OUT="user_time_out",e.ROOM_DISBAND="room_disband",e))(BO||{}),HO=((eO=HO||{})[eO.USER_EXIT_REASON_TC_USER_EXIT_NORMAL=0]="USER_EXIT_REASON_TC_USER_EXIT_NORMAL",eO[eO.USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT=1]="USER_EXIT_REASON_TC_USER_EXIT_TIMEOUT",eO[eO.USER_EXIT_REASON_TC_USER_EXIT_KICKED=2]="USER_EXIT_REASON_TC_USER_EXIT_KICKED",eO[eO.USER_EXIT_REASON_TC_USER_EXIT_CHANGED=3]="USER_EXIT_REASON_TC_USER_EXIT_CHANGED",eO[eO.USER_KICK_OUT_CODE_BUSINESS_USER=4]="USER_KICK_OUT_CODE_BUSINESS_USER",eO[eO.USER_KICK_OUT_CODE_BUSINESS_ROOM=5]="USER_KICK_OUT_CODE_BUSINESS_ROOM",eO[eO.USER_KICK_OUT_CODE_SERVER_USER=6]="USER_KICK_OUT_CODE_SERVER_USER",eO[eO.USER_KICK_OUT_CODE_SERVER_ROOM=7]="USER_KICK_OUT_CODE_SERVER_ROOM",eO[eO.USER_KICK_SESS_EXSIT=8]="USER_KICK_SESS_EXSIT",eO),WO=1e8,jO=class{constructor(){Bb(this,"mediaType",0)}set audio(e){e?this.mediaType|=1:this.mediaType&=-2}get audio(){return!!(1&this.mediaType)}set video(e){e?this.mediaType|=4:this.mediaType&=-5}get video(){return!!(4&this.mediaType)}set auxiliary(e){e?this.mediaType|=2:this.mediaType&=-3}get auxiliary(){return!!(2&this.mediaType)}set smallVideo(e){e?this.mediaType|=8:this.mediaType&=-9}get smallVideo(){return!!(8&this.mediaType)}},GO=(e=>(e.String="string",e.Number="number",e.Boolean="boolean",e.Array="array",e.Object="object",e))(GO||{}),KO=(e=>(e.H264="h264",e.H265="h265",e.VP8="vp8",e))(KO||{}),zO=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.DUMP=1]="DUMP",e[e.SEI=2]="SEI",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(zO||{}),qO=(e=>(e[e.ENCRYPT_AND_DECRYPT=0]="ENCRYPT_AND_DECRYPT",e[e.NTP_TO_AUDIO_FRAME=1]="NTP_TO_AUDIO_FRAME",e[e.DUMP=2]="DUMP",e[e.ENCODE_AND_DECODE=3]="ENCODE_AND_DECODE",e))(qO||{}),YO=(e=>(e.WebRTC="webrtc",e.WebCodecs="webcodecs",e.WebAssembly="webassembly",e))(YO||{}),JO=((Zk=JO||{})[Zk.SUCCESS=0]="SUCCESS",Zk[Zk.FAILED=1]="FAILED",Zk[Zk.WEBCODEC_INIT=2]="WEBCODEC_INIT",Zk[Zk.WEBCODEC_CONFIG_NOT_SUPPORT=3]="WEBCODEC_CONFIG_NOT_SUPPORT",Zk[Zk.WEBCODEC_DECODER_ERROR=4]="WEBCODEC_DECODER_ERROR",Zk[Zk.WEBCODEC_TRACK_MUTE=5]="WEBCODEC_TRACK_MUTE",Zk[Zk.WASM_INIT=6]="WASM_INIT",Zk[Zk.WASM_WEBGL_UNAVALIABLE=7]="WASM_WEBGL_UNAVALIABLE",Zk[Zk.WASM_DECODER_ERROR=8]="WASM_DECODER_ERROR",Zk[Zk.WASM_TRACK_MUTE=9]="WASM_TRACK_MUTE",Zk[Zk.TEST=10]="TEST",Zk[Zk.RENDER_2D_ERROR=11]="RENDER_2D_ERROR",Zk),XO=(e=>(e.NONE="",e.DETAIL="detail",e.MOTION="motion",e.TEXT="text",e))(XO||{}),$O=(e=>(e.INTERVAL="interval",e.TIMEOUT="timeout",e.RAF="raf",e.RIC="ric",e.INTERVAL_IN_WORKER="intervalInWorker",e))($O||{}),QO=(e=>(e.CANVAS="canvas",e.API="api",e))(QO||{}),ZO={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"},eM={AVOID_REPEATED_CALL:e=>"previous ".concat(e.name,"() is ongoing, please avoid repeated calls."),INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(tC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(tC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(o,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,fnName:i,value:o}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(o,".")},API_CALL_TIMEOUT:e=>"".concat(e.commandDesc||e.command," timeout observed."),SIGNAL_CHANNEL_RECONNECTION_FAILED:"signal channel reconnection failed, please check your network.",SIGNAL_CHANNEL_SETUP_FAILED:e=>"SignalChannel setup failure: (errorCode: ".concat(e.errorCode,", errorMsg: ").concat(e.errorMsg," })."),ERROR_MESSAGE(e){let t="".concat(e.type," failed");return e.message&&(t="".concat(t,": ").concat(e.message,".")),t},EXCHANGE_SDP_TIMEOUT:"exchange sdp timeout.",DOWNLINK_RECONNECTION_FAILED:"downlink reconnection failed, please check your network and re-join room.",EXCHANGE_SDP_FAILED:e=>"exchange sdp failed ".concat(e.errMsg,"."),UPDATE_OFFER_TIMEOUT:"update offer timeout observed.",UPLINK_RECONNECTION_FAILED:"uplink reconnection failed, please check your network and publish again.",INVALID_RECORDID:"recordId must be an integer number.",INVALID_PURE_AUDIO:"pureAudioPushMode must be 1 or 2.",INVALID_STREAMID:"streamId must be a sting literal within 64 bytes, and not be empty.",INVALID_USER_DEFINE_RECORDID:"userDefineRecordId must be a sting literal contains (a-zA-Z),(0-9), underline and hyphen, within 64 bytes, and not be empty.",INVALID_USER_DEFINE_PUSH_ARGS:"userDefinePushArgs must be a sting literal within 256 bytes, and not be empty.",INVALID_PROXY:'proxy server url must start with "wss://".',INVALID_JOIN:"duplicate join() called.",INVALID_ROOMID_STRING:e=>"'".concat(e,"' must be validate string when useStringRoomId is true."),INVALID_ROOMID_INTEGER:e=>"'".concat(e,"' must be an integer between [1, 4294967294] when useStringRoomId is false."),INVALID_SIGNAL_CHANNEL:"SignalChannel is not ready yet.",JOIN_ROOM_TIMEOUT:"join room timeout.",JOIN_ROOM_FAILED(e){let{error:t,code:r}=e;return"Failed to join room - ".concat(t," code: ").concat(r)},REJOIN_ROOM_FAILED:e=>"reJoin room: ".concat(e.roomId," failed, please check your network."),INVALID_DESTROY:"please call leave() before destroy().",INVALID_PUBLISH:"please call join() before publish().",INVALID_UNPUBLISH:"stream has not been published yet.",INVALID_AUDIENCE:'no permission to publish() under live/audience, please call switchRole("anchor") firstly before publish().',INVALID_INITIALIZE:"cannot publish stream because stream is not initialized, is switching device, or has been closed.",INVALID_DUPLICATE_PUBLISHING:e=>"duplicate ".concat(e," stream publishing, please unpublish your prev ").concat(e," stream and then re-publish."),INVALID_SUBSCRIBE_UNDEFINED:"stream is undefined or null.",INVALID_SUBSCRIBE_LOCAL:"stream cannot be LocalStream.",INVALID_REMOTE_STREAM:"remoteStream does not exist because it has been unpublished by remote peer.",SUBSCRIBE_FAILED(e){let{message:t,userId:r,streamType:i}=e;return"failed to subscribe ".concat(r," ").concat(i," stream, reason: ").concat(t,".")},INVALID_ROLE:"switchRole can only be called in live mode.",INVALID_PARAMETER_SWITCH_ROLE:"role could only be set to a value as anchor or audience.",INVALID_OPERATION_SWITCH_ROLE:"please call join() before switchRole().",SWITCH_ROLE_TIMEOUT:"switchRole timeout.",SWITCH_ROLE_FAILED:e=>"switchRole failed, errCode: ".concat(e.code," errMsg: ").concat(e.message,"."),CLIENT_BANNED:e=>"client was banned because of ".concat(e.message,"."),INVALID_OPERATION_START_PUBLISH_CDN:"please call startPublishCDNStream() after join room and publish the local stream.",INVALID_OPERATION_STOP_PUBLISH_CDN:"please call startPublishCDNStream() before stopPublishCDNStream().",START_PUBLISH_CDN_FAILED:e=>"startPublishCDNStream failed, errMsg: ".concat(e.message,"."),STOP_PUBLISH_CDN_FAILED:e=>"stopPublishCDNStream failed, errMsg: ".concat(e.message,"."),INVALID_STREAM_ID:e=>"'".concat(e,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores."),START_MIX_TRANSCODE:"please call startMixTranscode() after join().",STOP_MIX_TRANSCODE:"please call stopMixTranscode() after startMixTranscode().",INVALID_AUDIO_VOLUME:"interval must be a number.",ENABLE_SMALL_STREAM_PUBLISHED:"Cannot enable small stream after localStream published.",DISABLE_SMALL_STREAM_PUBLISHED:"Cannot disable small stream after localStream published.",NOT_SUPPORTED_SMALL_STREAM:"your browser does not support opening small stream.",INVALID_SMALL_STREAM_PROFILE:"small stream profile is invalid.",INVALID_PARAMETER_REMOTE_STREAM:"remoteStream is invalid.",INVALID_OPERATION_CHANGE_SMALL:"cannot switch to the small stream without subscribing to the video of remoteStream.",REMOTE_NOT_PUBLISH_SMALL_STREAM:"remote peer does not publish small stream.",INVALID_SWITCH_DEVICE:"cannot switch device on current stream.",INVALID_SWITCH_DEVICE_PUBLISHING:"cannot switch device when publishing localStream.",INVALID_REPLACE_TRACK:"cannot replace track when publishing localStream.",INVALID_INITIALIZE_LOCAL_STREAM:"local stream has not initialized yet.",INVALID_ADD_TRACK_REPETITIVE:"previous addTrack is ongoing, please avoid repetitive execution.",INVALID_ADD_TRACK_REMOVING:"cannot add track when a track is removing.",INVALID_ADD_TRACK_PUBLISHING:"cannot add track when publishing localStream.",INVALID_STREAM_INITIALIZED:"your local stream haven't been initialized yet.",INVALID_ADD_TRACK_NUMBER:"a Stream has at most one audio track and one video track.",INVALID_REMOVE_AUDIO_TRACK:"remove audio track is not supported on your browser.",INVALID_REMOVE_AUDIO_ADDING:"cannot remove track when a track is adding.",INVALID_REMOVE_AUDIO_ON:"previous removeTrack is ongoing, please avoid repetitive execution.",INVALID_REMOVE_TRACK_PUBLISHING:"cannot remove track when publishing localStream.",INVALID_REMOVE_TRACK_NOT_TRACK:"localStream has not this track.",INVALID_REMOVE_TRACK_NUMBER:"remove the only video track is not supported, please use replaceTrack or muteVideo.",INVALID_REPLACE_TRACK_NO_TRACK:e=>"cannot replace ".concat(e.kind," track because stream has not ").concat(e.kind," track"),NOT_BUG_PACKAGE:"You need to buy packages, refer to tencent console.",START_MIX_TRANSCODE_FAILED:e=>"startMixTranscode failed, errMsg: ".concat(e.message,"."),STOP_MIX_TRANSCODE_FAILED:e=>"stopMixTranscode failed, errMsg: ".concat(e.message,"."),MIX_TRANSCODE_NOT_STARTED:"mixTranscode has not been started.",CANNOT_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},MIX_PARAMS_VIDEO_FRAMERATE:"'config.videoFramerate' should be an integer between 0 and 30, excluding 0.",MIX_PARAMS_VIDEO_GOP:"'config.videoGOP' should be an integer between 1 and 8.",MIX_PARAMS_AUDIO_BITRATE:"'config.audioBitrate' should be an integer between 32 and 192.",MIX_PARAMS_USER_Z_ORDER:e=>"'".concat(e,"' is required and must be between 1 and 15."),MIX_PARAMS_NOT_SELF:"'config.mixUsers' must contain self.",MIX_PARAMS_USER_STREAM:"'config.videoWidth' and 'config.videoHeight' of output stream should be contain all mix stream.",INVALID_PLAY:"duplicate play() call observed, please stop() firstly.",INVALID_ELEMENT_ID:e=>{let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE:e=>{let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},PLAY_FAILED:e=>"".concat(e.media," play failed, browser exception: ").concat(e.error.toString()),INVALID_USERID:"userId cannot be all spaces.",INVALID_CREATE_STREAM_SOURCE:"LocalStream must be created by createStream() with either audio/video or audioSource/videoSource, but can not be mixed with audio/video and audioSource/videoSource.",INVALID_CREATE_STREAM_SCREEN:"screen/video cannot be both true.",INVALID_CREATE_STREAM_AUDIO:"audio/screenAudio cannot be both true.",INVALID_CREATE_STREAM_SCREEN_AUDIO:"when screen is true, screenAudio can be configured.",NOT_SUPPORTED_HTTP:"http protocol does not support the ability to capture microphone, camera and screen. please use https to deploy your page.",NOT_SUPPORTED_WEBRTC:"your browser or environment does not support full WebRTC capabilities.",NOT_SUPPORTED_PROFILE:"your browser does not support setVideoProfile.",NOT_SUPPORTED_MEDIA:"your browser or environment does not support navigator.mediaDevices.",NOT_SUPPORTED_H264ENCODE:"your device does not support H.264 encoding.",NOT_SUPPORTED_H264DECODE:"your device does not support H.264 decoding.",NOT_SUPPORTED_TRACK:e=>"".concat(e,"Track is not supported on your browser."),NOT_SUPPORTED_SWITCH_DEVICE:"switchDevice is not supported on your browser.",NOT_SUPPORTED_CAPTURE:"Your browser or environment does not support screen sharing, please check whether the browser version.",MICROPHONE_NOT_FOUND:"no microphone detected, please check your microphone.",CAMERA_NOT_FOUND:"no camera detected, please check your camera.",SIGNAL_RESPONSE_FAILED:e=>"".concat(e.signalResponse," failed, response code is ").concat(e.code," , errMsg: ").concat(e.message,"."),CATCH_HANDLER_ERROR(e){let{name:t,event:r}=e;return"an error was caught in ".concat(t,".on('").concat(r,"', handler), please check your code in 'handler'.")},API_NOT_EXIST(e){let{name:t}=e;return"experimental api ".concat(t," does not exist.")},REPEAT_JOIN:e=>"please avoid repeated join.",CONNECTION_CLOSED:"remoteStream has been unsubscribed or unpublished by remote user.",SUBSCRIBE_ALL_FALSE:"cannot subscribe when both audio & video are false, use client.unsubscribe() instead",CLIENT_DESTROYED(e){let{funName:t}=e;return"failed to call ".concat(t,"() because client was destroyed.")},SEI_NOT_SUPPORT:e=>"not support to sendSEIMessage".concat(!1===e?" without using h264 codec":""),SEI_DISABLED:"SEI is disabled",SEI_BEFORE_PUBLISH:"please call sendSEIMessage() after publish() success",SEI_NOT_VIDEO:"cannot send sei when localStream has not video.",CALL_FREQUENCY_LIMIT:e=>{let{isSize:t,name:r,timesInSecond:i,maxSizeInSecond:o}=e;return"api ".concat(r," call ").concat(t?"size":"times"," is over ").concat(t?"".concat(o," bytes"):i," in a second.")},CONNECTION_ABORTED:e=>"connection aborted due to: ".concat(e),API_CALL_ABORTED(e){let t;return t=e.message.includes("REMOTE_STREAM_NOT_EXIST")?"Subscribe ".concat(e.userId," ").concat(e.streamType," stream aborted, reason: remote user ").concat(e.userId," unpublished stream."):"API aborted, reason: ".concat(e.message),t},DUPLICATE_AUX:"only one auxiliary stream can be published in a room.",NOT_SUPPORTED_AUX:"publish auxiliary stream is not supported on your browser.",INVALID_PARAMETER_STREAMTYPE:e=>"'streamType' is required when 'userId' is not '*', calling ".concat(e,"()")},tM=(e,t)=>t?"".concat(gw,"/").concat(e,"/").concat(t):"".concat(gw,"/").concat(e,"/index.html"),rM=()=>{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(Iw);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 iM(e){let{key:t,data:r,link:i,addDocLink:o=!0}=e,n="",a="",s="";rC(eM[t])?n=eM[t](r):oC(eM[t])&&(n=eM[t]);let{TRTC_ERROR_INFO:c,TRTC_ERROR_LINK:l}=rM();i?s="".concat(i.className,".html#").concat(i.fnName):l&&l[t]&&(rC(l[t])?s=l[t](r):oC(l[t])&&(s=l[t]));let u=n;return $D()&&(c&&c[t]&&(rC(c[t])?a=c[t](r):oC(c[t])&&(a=c[t])),a&&(u=o?"".concat(a,"\n请查看文档: ").concat(tM("zh-cn",s),"\n\n"):"".concat(a,"\n\n"),u+=n)),o&&(u+=" \nRefer to: ".concat(tM("en",s),"\n")),u}var oM,nM,aM=Vb(qb(),1),sM=class{constructor(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];Bb(this,"countMap",new Map),Bb(this,"distributionMap",new Map),Bb(this,"version"),Bb(this,"log",Yk.createLogger({id:"kv"})),e&&(Gk.on("102",(e=>{let{track:t,cost:r}=e;this.addSuccessEvent({key:t.kind===Pw.AUDIO?501700:511700,cost:r})})),Gk.on("103",(e=>{let{track:t,error:r}=e;this.addFailedEvent({key:t.kind===Pw.AUDIO?501700:511700,error:r})})))}getReportData(){let e={msg_sdk_basic_info:{uint32_sdk_version:LC(this.version||ow),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}}))}}))};return this.countMap.clear(),this.distributionMap.clear(),e}clear(){this.countMap.clear(),this.distributionMap.clear()}isEnumKey(e){let t=+String(e).slice(-3);return t>=700&&t<799}isErrorCodeKey(e){let t=+String(e).slice(-3);return t>=600&&t<699}isCountKey(e){let t=+String(e).slice(-3);return t>=0&&t<599}isNumberKey(e){let t=+String(e).slice(-3);return t>=800&&t<899}addCount(e){let{key:t,useUV:r=!1}=e;this.isCountKey(t)?r&&this.countMap.has(t)||this.countMap.set(t,(this.countMap.get(t)||0)+1):this.log.debug("".concat(t," is not count key, last 3 number should be 0~599"))}addEnum(e){let{key:t,value:r,useUV:i=!0}=e;var o;if(!this.isEnumKey(t))return this.log.debug("".concat(t," is not enum key, last 3 number should be 700~799"));if(i&&this.countMap.has(t))return;this.countMap.set(t,(this.countMap.get(t)||0)+1);let n=(null==(o=this.distributionMap)?void 0:o.get(t))||new Map;n.set(r,(n.get(r)||0)+1),this.distributionMap.set(t,n)}addNumber(e){let{key:t,value:r,split:i=100,useUV:o=!1,max:n=5e3}=e;var a;if(!this.isNumberKey(t))return this.log.debug("".concat(t," is not number key, last 3 number should be 800~899"));if(o&&this.countMap.has(t))return;r>n&&(r=n),this.countMap.set(t,(this.countMap.get(t)||0)+1);let s=(null==(a=this.distributionMap)?void 0:a.get(t))||new Map,c=0;if(nC(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:o}=e;if(t&&(this.addEnum({key:t,value:1,useUV:!1}),r)){let e=+String(t).slice(-3);e<800&&e>=700?this.addNumber({key:i||t+100,value:r,split:o}):i||this.log.debug("time stat ignored, ".concat(t))}}addFailedEvent(e){let{key:t,error:r}=e;if(!t)return;let i=Jb.UNKNOWN;r&&(nC(r)?i=r:(!iC(r.extraCode)||!iC(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})}},cM=((nM=cM||{})[nM.enterRoom=500700]="enterRoom",nM[nM.exitRoom=500701]="exitRoom",nM[nM.switchRole=500702]="switchRole",nM[nM.destroy=500703]="destroy",nM[nM.startLocalAudio=500704]="startLocalAudio",nM[nM.updateLocalAudio=500705]="updateLocalAudio",nM[nM.stopLocalAudio=500706]="stopLocalAudio",nM[nM.startLocalVideo=500707]="startLocalVideo",nM[nM.updateLocalVideo=500708]="updateLocalVideo",nM[nM.stopLocalVideo=500709]="stopLocalVideo",nM[nM.startScreenShare=500710]="startScreenShare",nM[nM.updateScreenShare=500711]="updateScreenShare",nM[nM.stopScreenShare=500712]="stopScreenShare",nM[nM.startRemoteVideo=500713]="startRemoteVideo",nM[nM.updateRemoteVideo=500714]="updateRemoteVideo",nM[nM.stopRemoteVideo=500715]="stopRemoteVideo",nM[nM.muteRemoteAudio=500716]="muteRemoteAudio",nM[nM.setRemoteAudioVolume=500717]="setRemoteAudioVolume",nM[nM.use=500718]="use",nM[nM.switchRoom=500719]="switchRoom",nM[nM.sendSEIMessage=5e5]="sendSEIMessage",nM[nM.sendCustomMessage=500001]="sendCustomMessage",nM),lM=((oM=lM||{})[oM.AudioMixer=550700]="AudioMixer",oM[oM.AIDenoiser=551700]="AIDenoiser",oM[oM.VirtualBackground=570700]="VirtualBackground",oM[oM.Beauty=571700]="Beauty",oM[oM.Watermark=572700]="Watermark",oM[oM.BasicBeauty=574700]="BasicBeauty",oM[oM.CDNStreaming=590700]="CDNStreaming",oM[oM.DeviceDetector=591700]="DeviceDetector",oM[oM.Debug=592700]="Debug",oM[oM.SmallStreamAutoSwitcher=593700]="SmallStreamAutoSwitcher",oM[oM.VideoMixer=594700]="VideoMixer",oM),uM=(e=>(e[e.AudioMixer=550701]="AudioMixer",e[e.AIDenoiser=551701]="AIDenoiser",e[e.VirtualBackground=570701]="VirtualBackground",e[e.Beauty=571701]="Beauty",e[e.Watermark=572701]="Watermark",e[e.BasicBeauty=574701]="BasicBeauty",e[e.CDNStreaming=590701]="CDNStreaming",e[e.DeviceDetector=591701]="DeviceDetector",e[e.Debug=592701]="Debug",e[e.SmallStreamAutoSwitcher=593701]="SmallStreamAutoSwitcher",e[e.VideoMixer=594701]="VideoMixer",e))(uM||{}),dM=(e=>(e[e.AudioMixer=550702]="AudioMixer",e[e.AIDenoiser=551702]="AIDenoiser",e[e.VirtualBackground=570702]="VirtualBackground",e[e.Beauty=571702]="Beauty",e[e.Watermark=572702]="Watermark",e[e.BasicBeauty=574702]="BasicBeauty",e[e.CDNStreaming=590702]="CDNStreaming",e[e.DeviceDetector=591702]="DeviceDetector",e[e.Debug=592702]="Debug",e[e.SmallStreamAutoSwitcher=593702]="SmallStreamAutoSwitcher",e[e.VideoMixer=594702]="VideoMixer",e))(dM||{}),hM=new sM(!0),pM=new sM(!1),mM=hM,fM={result:!1,detail:{isBrowserSupported:!1,isWebRTCSupported:!1,isWebCodecsSupported:!1,isMediaDevicesSupported:!1,isScreenShareSupported:!1,isSmallStreamSupported:!1,isH264EncodeSupported:!1,isVp8EncodeSupported:!1,isH264DecodeSupported:!1,isVp8DecodeSupported:!1}},_M=new Map([[hN,["Firefox",pN]],[gN,["Edg",EN]],[dk,["Chrome",mk]],[fk,["Safari",gk]],[SN,["TBS",RN]],[bN,["XWEB",wN]],[kN&&nN,["WeChat",ON]],[xN,["QQ(Win)",UN]],[LN,["QQ(Mobile)",PN]],[MN,["QQ(Mobile X5)",PN]],[VN,["QQ(Mac)",FN]],[BN,["QQ(iPad)",HN]],[JN,["MI",XN]],[$N,["HW",ek]],[tk,["Samsung",rk]],[ik,["OPPO",ok]],[nk,["VIVO",ak]],[fN,["EDGE",_N]],[yN,["SogouMobile",TN]],[IN,["Sogou",AN]]]);function gM(){let e=_M.get(!0);return{browserName:e?e[0]:"unknown",browserVersion:e?e[1]:"unknown"}}var EM=function(){return!(qN||fN||gN&&vN<80||hN&&mN<56)},vM=function(){return["VideoDecoder","VideoEncoder","AudioEncoder","AudioDecoder","MediaStreamTrackGenerator"].every((e=>e in window))},yM=function(){if(!navigator.mediaDevices)return IM()||Yk.error(eM.NOT_SUPPORTED_MEDIA),!1;let e=["getUserMedia","enumerateDevices"];return e.filter((e=>e in navigator.mediaDevices)).length===e.length},TM=!1;function IM(){return"http:"===location.protocol&&!wk&&(TM||Yk.error(iM({key:ZO.NOT_SUPPORTED_HTTP})),TM=!0,!0)}var AM=function(){return(null==window?void 0:window.OffscreenCanvas)&&(null==window?void 0:window.MediaStreamTrackProcessor)&&(null==window?void 0:window.MediaStreamTrackGenerator)},SM=function(){return Wb(this,null,(function*(){if(fM.detail.isH264EncodeSupported&&fM.detail.isVp8EncodeSupported)return{isH264EncodeSupported:fM.detail.isH264EncodeSupported,isVp8EncodeSupported:fM.detail.isVp8EncodeSupported};let e,t=!1,r=!1;try{let i=new RTCPeerConnection,o=document.createElement(Pw.CANVAS);o.getContext("2d");let n=o.captureStream(0);return i.addTrack(n.getVideoTracks()[0],n),e=yield i.createOffer(),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),fM.detail.isH264EncodeSupported=t,fM.detail.isVp8EncodeSupported=r,{isH264EncodeSupported:fM.detail.isH264EncodeSupported,isVp8EncodeSupported:fM.detail.isVp8EncodeSupported}}catch(lD){return{isH264EncodeSupported:!1,isVp8EncodeSupported:!1}}}))},RM=function(){return Wb(this,null,(function*(){if(fM.detail.isH264DecodeSupported&&fM.detail.isVp8DecodeSupported)return{isH264DecodeSupported:fM.detail.isH264DecodeSupported,isVp8DecodeSupported:fM.detail.isVp8DecodeSupported};let e,t=!1,r=!1;try{let i=new RTCPeerConnection;return e=yield i.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0}),-1!==e.sdp.toLowerCase().indexOf("h264")&&(t=!0),-1!==e.sdp.toLowerCase().indexOf("vp8")&&(r=!0),i.close(),{isH264DecodeSupported:t,isVp8DecodeSupported:r}}catch(lD){return{isH264DecodeSupported:!1,isVp8DecodeSupported:!1}}}))},bM=UC((()=>Wb(void 0,null,(function*(){if(fM.result&&fM.detail.isH264EncodeSupported&&fM.detail.isVp8EncodeSupported&&fM.detail.isH264DecodeSupported&&fM.detail.isVp8DecodeSupported)return fM;let e=Date.now(),t=EM(),r=ZM(),i=vM(),o=yM(),{isH264EncodeSupported:n,isVp8EncodeSupported:a}=yield SM(),{isH264DecodeSupported:s,isVp8DecodeSupported:c}=yield RM();if(!n||!a){let e=yield SM();Yk.warn("detect encode again h264:".concat(n," vp8:").concat(a," result: ").concat(JSON.stringify(e))),n=e.isH264EncodeSupported,a=e.isVp8EncodeSupported}if(n&&s&&cN&&uk&&!bN&&!SN){let{encode:e,decode:t}=yield function(){return Wb(this,null,(function*(){return CM||(CM=new Promise((e=>Wb(this,null,(function*(){let t={encode:!1,decode:!1},r=()=>{};try{let i=document.createElement("canvas"),o=i.getContext("2d");i.width=320,i.height=240;let n=setInterval((()=>{o.fillText("test",Math.floor(320*Math.random()),Math.floor(240*Math.random()))}),66),a=-1,s=-1;r=()=>{clearInterval(a),clearInterval(n),clearTimeout(s),l.close(),u.close(),c.getTracks().forEach((e=>e.stop()))},s=setTimeout((()=>{r(),e(t)}),2e3);let c=i.captureStream(),l=new RTCPeerConnection({}),u=new RTCPeerConnection({offerToReceiveAudio:!0,offerToReceiveVideo:!0});l.addEventListener("icecandidate",(e=>u.addIceCandidate(e.candidate))),u.addEventListener("icecandidate",(e=>l.addIceCandidate(e.candidate))),l.addTrack(c.getVideoTracks()[0],c);let d=yield l.createOffer();yield l.setLocalDescription(d),yield u.setRemoteDescription(d);let h=yield u.createAnswer(),p=aM.default.parse(h.sdp),m=p.media[0].rtp.findIndex((e=>"H264"===e.codec));p.media[0].rtp=[p.media[0].rtp[m]],p.media[0].fmtp=p.media[0].fmtp.filter((e=>e.payload===p.media[0].rtp[0].payload)),p.media[0].rtcpFb&&(p.media[0].rtcpFb=p.media[0].rtcpFb.filter((e=>e.payload===p.media[0].rtp[0].payload))),h.sdp=aM.default.write(p),yield u.setLocalDescription(h),yield l.setRemoteDescription(h),a=setInterval((()=>Wb(this,null,(function*(){t.encode&&t.decode&&(r(),e(t));let[i,o]=yield Promise.all([l.getSenders()[0].getStats(),u.getReceivers()[0].getStats()]);t.encode||i.forEach((e=>{"outbound-rtp"===e.type&&e.mediaType===Pw.VIDEO&&e.bytesSent>0&&(t.encode=!0)})),t.decode||o.forEach((e=>{"inbound-rtp"===e.type&&e.mediaType===Pw.VIDEO&&e.bytesReceived>0&&(t.decode=!0)}))}))),100)}catch(i){r(),Yk.warn("detectH264Supported failed",i),e({encode:!0,decode:!0})}})))).then((e=>(e.encode||(e.decode=!0),(!e.encode||!e.decode)&&Yk.warn("detectH264Supported encode: ".concat(e.encode," decode: ").concat(e.decode," ").concat(Mk)),e))),CM)}))}();n=e,s=t}return fM.result=t&&r&&o&&(n||a)&&(s||c),fM.detail.isBrowserSupported=t,fM.detail.isWebRTCSupported=r,fM.detail.isWebCodecsSupported=i,fM.detail.isMediaDevicesSupported=o,fM.detail.isScreenShareSupported=DM(),fM.detail.isSmallStreamSupported=xM(),fM.detail.isH264EncodeSupported=n,fM.detail.isVp8EncodeSupported=a,fM.detail.isH264DecodeSupported=s,fM.detail.isVp8DecodeSupported=c,fM.result||Yk.error("".concat(navigator.userAgent," ").concat(NC(fM.detail,!1))),Xk.setItem(nL,{ua:navigator.userAgent,checkResult:fM}),mM.addNumber({key:523800,value:Date.now()-e}),fM})))),wM=function(){return fM.result},DM=function(){return!(!navigator.mediaDevices||!navigator.mediaDevices.getDisplayMedia)},CM=null;var NM=(e,t,r)=>{"http:"===location.protocol&&!wk&&(e[t]=()=>{throw new $b({code:Jb.INVALID_OPERATION,message:eM.NOT_SUPPORTED_HTTP})})},kM=function(e){return!("candidate-pair"!==e.type||!e.nominated||"in-progress"!==e.state&&"succeeded"!==e.state)&&!(aC(e.selected)&&!e.selected)};function OM(){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 MM(){return navigator.getUserMedia||navigator.mediaDevices&&navigator.mediaDevices.getUserMedia}function LM(){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 PM(){return"captureStream"in HTMLCanvasElement.prototype}function xM(){return!(kN||sN||pk&&pk<63)&&!(!EM()||!PM())}var UM=function(){if(iC(window.RTCRtpTransceiver)||!HM()||!("currentDirection"in RTCRtpTransceiver.prototype))return!1;let e=null,t=!1;try{e=new RTCPeerConnection({sdpSemantics:fD}),e.addTransceiver(Pw.AUDIO),t=!0}catch(aw){}return null==e||e.close(),t};function VM(){return"RTCPeerConnection"in window&&"getReceivers"in window.RTCPeerConnection.prototype}function FM(){return"RTCPeerConnection"in window&&"getSenders"in window.RTCPeerConnection.prototype}function BM(){return"RTCPeerConnection"in window&&"getTransceivers"in window.RTCPeerConnection.prototype}function HM(){return!(11===Tk&&!bk)&&("RTCPeerConnection"in window&&"addTransceiver"in window.RTCPeerConnection.prototype)}var WM=!(!HM()||uk&&pk<86);function jM(){return"RTCRtpTransceiver"in window&&"stop"in window.RTCRtpTransceiver.prototype}var GM="RTCRtpSender"in window;function KM(){return GM&&"replaceTrack"in window.RTCRtpSender.prototype}function zM(){return GM&&"setParameters"in window.RTCRtpSender.prototype&&FM()}var qM="RTCRtpReceiver"in window&&"getSynchronizationSources"in window.RTCRtpReceiver.prototype,YM=window.MediaStreamTrack&&"getSettings"in MediaStreamTrack.prototype,JM=window.MediaStreamTrack&&"getCapabilities"in MediaStreamTrack.prototype,XM=GM&&"createEncodedStreams"in window.RTCRtpSender.prototype&&lk()>=86,$M="RTCRtpScriptTransform"in window,QM=GM&&(XM||$M),ZM=function(){return["RTCPeerConnection","webkitRTCPeerConnection","RTCIceGatherer"].filter((e=>e in window)).length>0};function eL(){let e={AudioDecoder:!1,AudioEncoder:!1,VideoDecoder:!1,VideoEncoder:!1,ImageDecoder:!1};return iC(window.AudioDecoder)||(e.AudioDecoder=!0),iC(window.AudioEncoder)||(e.AudioEncoder=!0),iC(window.VideoDecoder)||(e.VideoDecoder=!0),iC(window.VideoEncoder)||(e.VideoEncoder=!0),iC(window.ImageDecoder)||(e.ImageDecoder=!0),e}function tL(){return"mediaSession"in navigator&&!iC(navigator.mediaSession.setActionHandler)}function rL(){return!iC(window.WebTransport)}function iL(){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 oL(){let e={browser:"".concat(Ck.name,"/").concat(Ck.version),os:Vk(),displayResolution:OM(),isScreenShareSupported:DM(),isWebRTCSupported:ZM(),isGetUserMediaSupported:MM(),isWebAudioSupported:LM(),isWebSocketsSupported:"WebSocket"in window&&2===window.WebSocket.CLOSING,isWebCodecSupported:eL(),isMediaSessionSupported:tL(),isWebTransportSupported:rL()};return navigator.userAgent.includes("miniProgram")&&(e.browser="mini/".concat(e.browser)),e}var nL="checkResult";function aL(){IM();let e=Xk.getItem(nL);e&&e.ua===navigator.userAgent&&(fM=e.checkResult),bM()}function sL(){return"requestVideoFrameCallback"in HTMLVideoElement.prototype}var cL="RTCRtpReceiver"in window&&"jitterBufferTarget"in window.RTCRtpReceiver.prototype,lL=Vb(jb(),1),uL=Symbol("instance"),dL=Symbol("cacheResult"),hL=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,gL.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},pL=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var mL=new Map;function fL(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=mL.get(i)||[];mL.has(i)||mL.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(r.context&&(i=EL.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[dL]:Promise.resolve(i[dL]);i.state instanceof hL&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof hL&&i.state.abort(i):("string"!=typeof i.state||!e.includes(i.state))&&(l=new pL(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new pL(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let u=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 u(l);let d=i.state,h=new hL(d,t,a);gL.call(i,h);let p=e=>{var o;return i[dL]=e,h.aborted||(gL.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[dL])),e},m=e=>(gL.call(i,d,e),u(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(sO){return m(new pL(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(sO),sO instanceof Error?sO:new Error(String(sO))))}}}}var _L="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 gL(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(EL.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var EL=class e extends lL.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[uL];o?this.name=o.name+"-"+o.count++:i[uL]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=mL.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);mL.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};_L(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){gL.call(this,e)}};EL.STATECHANGED="stateChanged",EL.UPDATEAFSM="updateAFSM",EL.INIT="[*]",EL.ON="on",EL.OFF="off",EL.instances=new Map,EL.instances2=new WeakMap;var vL="undefined"!=typeof window,yL=vL&&window.requestIdleCallback||function(e){let t=Date.now();return setTimeout((()=>{e({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-t))})}),1e3)},TL=vL&&window.cancelIdleCallback||function(e){clearTimeout(e)},IL=vL&&(window.cancelAnimationFrame||window.mozCancelAnimationFrame),AL=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=Lb("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=Pb(Lb({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=_C(),o=()=>{if(r=_C()-i,r>=t.delay&&(i=_C()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),!e.isBreakLoop(t))return t.ricID=yL(o,{timeout:t.delay})};return t.ricID=yL(o,{timeout:t.delay})}static raf(t){let r,i=_C(),o=()=>document.hidden&&t.backgroundTask?(r=_C()-i,i=_C(),t.callback(),t.loopCount+=1,e.isBreakLoop(t)?void 0:t.timeoutID=setTimeout(o,t.delay-Math.floor(r%t.delay))):(r=_C()-i,r>=t.delay&&(i=_C()-Math.floor(r%t.delay),t.callback(),t.loopCount+=1),e.isBreakLoop(t)?void 0:t.rafID=requestAnimationFrame(o));if(t.rafID=requestAnimationFrame(o),t.backgroundTask){let e=()=>{if(document.hidden){let e=_C()-i;e>=t.delay?o():t.timeoutID=setTimeout(o,t.delay-e)}};document.addEventListener("visibilitychange",e),t.onVisibilitychange=e,document.hidden&&e()}return t.taskID}static hasTask(e){return this.taskMap.has(e)}static clearTask(e){if(!this.taskMap.has(e))return!0;let{intervalID:t,timeoutID:r,rafID:i,ricID:o,onVisibilitychange:n}=this.taskMap.get(e);return t&&clearInterval(t),r&&clearTimeout(r),i&&IL&&IL(i),o&&TL(o),n&&document.removeEventListener("visibilitychange",n),this.taskMap.delete(e),!0}static isBreakLoop(e){return!this.hasTask(e.taskID)||0!==e.count&&e.loopCount>=e.count&&(this.clearTask(e.taskID),!0)}};Bb(AL,"taskMap",new Map),Bb(AL,"currentTaskID",1),Bb(AL,"sharedWorker",null),Bb(AL,"workerTasks",new Map);var SL=AL;Pw.SEI_MESSAGE;var RL={LOADED_DATA:Pw.LOADEDDATA,LOADED_META_DATA:Pw.LOADEDMETADATA,MEDIA_TRACK_CHANGED:"media-track-changed",PLAYER_STATE_CHANGED:"player-state-changed",ERROR:"error"},bL={};Ub(bL,{create:()=>DL,remove:()=>CL});var wL=new WeakMap;function DL(e,t){wL.has(e)||wL.set(e,[]);let r=wL.get(e),i={add:(e,o)=>("addEventListener"in t?(r.push(t.removeEventListener.bind(t,e,o)),t.addEventListener(e,o)):(r.push(t.off.bind(t,e,o)),t.on(e,o)),i)};return i}function CL(e){let t=wL.get(e);t&&(t.forEach((e=>e())),wL.delete(e))}var NL=new class{constructor(){Bb(this,"_roomIdMap",new Map),Bb(this,"_configs"),"undefined"==typeof registerProcessor&&(this._configs={sdkAppId:"",userId:"",version:ow,env:Sw.QCLOUD,browserVersion:Ck.name+Ck.version,ua:navigator.userAgent})}setConfig(e){let{sdkAppId:t,env:r,userId:i,roomId:o}=e;t!==this._configs.sdkAppId&&(this._configs.sdkAppId=String(t)),this._configs.env=r,this._configs.userId=i,this._roomIdMap.set(i,String(o))}logSuccessEvent(e){wk||!Yk.isAbleToUpload||this._configs.env===Sw.QCLOUD&&this.uploadEventToKibana(Pb(Lb({},e),{result:"success"}))}logFailedEvent(e){if(wk||!Yk.isAbleToUpload)return;let{eventType:t,code:r,error:i,userId:o}=e,n={roomId:this._roomIdMap.get(o||this._configs.userId),userId:o,eventType:t,result:"failed",code:r||(null==i?void 0:i.extraCode)||(null==i?void 0:i.code)||Jb.UNKNOWN};this._configs.env===Sw.QCLOUD&&this.uploadEventToKibana(Pb(Lb({},n),{error:i}))}uploadEventToKibana(e){let t="stat-".concat(e.eventType,"-").concat(e.result);("delta-join"===e.eventType||"delta-leave"===e.eventType||"delta-publish"===e.eventType)&&(t="".concat(e.eventType,":").concat(e.delta)),this.uploadEvent({log:t,userId:e.userId}),"failed"===e.result&&(t="stat-".concat(e.eventType,"-").concat(e.result,"-").concat(e.code),this.uploadEvent({log:t,userId:e.userId,error:e.error}))}uploadEvent(e){let{log:t,userId:r,error:i}=e,o={timestamp:Zb(),sdkAppId:this._configs.sdkAppId,userId:r||this._configs.userId,version:ow,log:t};i&&(o.errorInfo=i.message,i.stack&&(o.errorInfo+="\n".concat(i.stack))),this.sendRequest(FD(this._configs.sdkAppId,Aw.LOG),o)}sendRequest(e,t){setTimeout((()=>WC({url:e,body:JSON.stringify(t),priority:"low"}).catch((()=>{}))),2e3)}},kL=new WeakMap;function OL(e){let{settings:t={retries:5,timeout:2e3},onError:r,onRetrying:i,onRetryFailed:o}=e;return function(e,n,a){let s=YC({retryFunction:a.value,settings:t,onError(t){let{error:i,retry:o,reject:a,retryFuncArgs:s}=t;var c;r?r.call(this,i,(()=>{var t;null!=(t=kL.get(e))&&t.has(n)?o():a(i)}),a,s):null!=(c=kL.get(e))&&c.has(n)?o():a(i)},onRetrying(t,r){var o;KC(i)&&i.call(this,t,r),null!=(o=kL.get(e))&&o.has(n)&&(kL.get(e).get(n).stopRetry=r)},onRetryFailed:o});return a.value=function(){let t=kL.get(e);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return t?t.set(n,{args:i}):kL.set(e,new Map([[n,{args:i}]])),s.apply(this,i).finally((()=>{var t;return null==(t=kL.get(e))?void 0:t.delete(n)}))},a}}var ML=class extends EL{constructor(e,t){super(e.id,"".concat(t,"-player")),this.kind=t,Bb(this,"id"),Bb(this,"element",null),Bb(this,"track"),Bb(this,"url"),Bb(this,"attr"),Bb(this,"mode"),Bb(this,"muted"),Bb(this,"_log"),Bb(this,"_pausedRetryCount"),Bb(this,"_isElementPlayingFired",!1),Bb(this,"_interval"),Bb(this,"_delayDestroyTimeoutId",0),Bb(this,"_playSuccessResolve"),Bb(this,"_isReplayByRecreateMediaStreamCalled",!1),Bb(this,"isInAutoPlayFailedState",!1),this.id=e.id,this._log=e.log,this.track=e.track,this.muted=e.muted,this._pausedRetryCount=wD,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 isStopped(){return"STOPPED"===this._state}setAttr(e){this.attr=e}setUrl(e){this.track&&(this.unbindTrackEvents(),this.element&&(this.element.srcObject=null),this.track=null),e!==this.url&&(this.url=e,null!==e&&this.element&&(this.element.crossOrigin="anonymous",this.element.src=e))}play(){return Wb(this,null,(function*(){if(!this.isPlaying)try{this._delayDestroyTimeoutId&&(clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0,this.bindTrackEvents(),this.bindElementEvents()),this.bindAutoPlayEvent(),yield new Promise(((e,t)=>{this._playSuccessResolve=e,this.element.play().then(e,t)}))}catch(aw){let t=iM({key:ZO.PLAY_FAILED,data:{media:this.kind,error:aw}});if(this.track&&!this.track.muted&&this._log.warn(aw),t.includes("NotAllowedError"))throw this.isInAutoPlayFailedState=!0,new $b({code:Jb.PLAY_NOT_ALLOWED,message:t})}}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this._isElementPlayingFired=!1,this.unbindEvents(),e>0&&!_k?this._delayDestroyTimeoutId||(this._log.info("destroy element after 3 * ".concat(e)),this._delayDestroyTimeoutId=setTimeout((()=>this.destroyElement()),3*e)):this.destroyElement(),this.handleStopped(Pw.ENDED),this._interval>0&&SL.clearTask(this._interval)}destroyElement(){this.element&&(this._log.debug("destroy element"),this.element.remove(),this.element.srcObject=null,this.element=null),clearTimeout(this._delayDestroyTimeoutId),this._delayDestroyTimeoutId=0}pause(){var e;this.isPlaying&&(null==(e=this.element)||e.pause())}resume(){return this._log.info("resume"),this.isPlaying?Promise.resolve():Ak?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 DL(this.element,this.element).add(Pw.PLAYING,e).add(Pw.ENDED,e).add(Pw.PAUSE,e).add(Pw.ERROR,e).add(Pw.LOADEDDATA,e).add(Pw.LOADEDMETADATA,e)}}bindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;if(e){let t=this.handleTrackEvent.bind(this);null==bL||bL.create(e,e).add(Pw.ENDED,t).add(Pw.MUTE,t).add(Pw.UNMUTE,t),e.readyState===Pw.ENDED&&this.handleTrackEvent({type:Pw.ENDED}),e.muted&&this.handleTrackEvent({type:Pw.MUTE})}}bindAutoPlayEvent(){Gk.on(zk.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}unbindTrackEvents(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.track;e&&CL(e)}unbindEvents(){this.element&&CL(this.element),this.unbindTrackEvents(),Gk.off(zk.AUTOPLAY_DIALOG_CLICK_CONFIRM,this.resume,this)}handleElementEvent(e){switch(e.type){case Pw.PLAYING:this.isInAutoPlayFailedState=!1,this._isElementPlayingFired=!0,this._log.info("".concat(this.kind," player is playing")),this.handlePlaying(Pw.PLAYING),this._interval&&(SL.clearTask(this._interval),this._interval=-1);break;case Pw.ENDED:this._log.info("".concat(this.kind," player is ended")),this.handleStopped(Pw.ENDED);break;case Pw.PAUSE:this._log.info("".concat(this.kind," player is paused")),this.handlePaused(Pw.PAUSE),sN&&(this._interval=SL.run("timeout",(()=>{this.element&&"PAUSED"===this._state&&this.resume()}),{delay:3e3}));break;case Pw.ERROR:if(this.element&&this.element.error){this.handlePaused(Pw.ERROR);let{code:e,message:t}=this.element.error;this._log.error("".concat(this.kind," ").concat(this._log.isLocal?"local":"remote"," MediaError code: ").concat(e," message: ").concat(t," userAgent: ").concat(navigator.userAgent)),NL.uploadEvent({log:"stat-".concat(this.kind,"-").concat(dD.PLAYER_ERROR,"-").concat(e,"-").concat(navigator.userAgent),error:this.element.error}),ZN||QN?this.emit(RL.ERROR,this.element.error):this.replayByRecreateMediaStream(this.element.error)}break;case Pw.LOADEDDATA:this.kind===Pw.VIDEO&&this.emit(RL.LOADED_DATA);break;case Pw.LOADEDMETADATA:this.kind===Pw.VIDEO&&this.emit(RL.LOADED_META_DATA)}}replayByRecreateMediaStream(e){if(!this._isReplayByRecreateMediaStreamCalled)return this._isReplayByRecreateMediaStreamCalled=!0,this.doReplayByRecreateMediaStream(1e3).then((()=>{this._log.warn("replayByRecreateMediaStream success"),NL.uploadEvent({log:"stat-replayByRecreateMediaStream-success"}),mM.addSuccessEvent({key:this.kind===Pw.AUDIO?506700:516700})})).catch((()=>{var t;this._log.error("replayByRecreateMediaStream failed"),NL.uploadEvent({log:"stat-replayByRecreateMediaStream-failed"}),mM.addFailedEvent({key:this.kind===Pw.AUDIO?506700:516700,error:null==(t=this.element)?void 0:t.error}),this.emit(RL.ERROR,e)}))}doReplayByRecreateMediaStream(e){return this._log.warn("delay ".concat(e,"ms to recreate mediaStream")),new Promise(((t,r)=>{xC(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)}),xC(5e3).then((()=>{var e,i;(!this.isPlaying||null!=(e=this.element)&&e.error)&&r(null==(i=this.element)?void 0:i.error),t()}))}))})).finally((()=>{this.element&&(this.element.onerror=null)}))}handleTrackEvent(e){switch(e.type){case Pw.ENDED:this.handleStopped(Pw.ENDED);break;case Pw.MUTE:this.handlePaused(Pw.MUTE);break;case Pw.UNMUTE:this._isElementPlayingFired?this.handlePlaying(Pw.UNMUTE):this.mode>0&&this.handlePlaying(this.mode.toString())}}handlePlaying(e){var t;null==(t=this._playSuccessResolve)||t.call(this,e),this.emit(RL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PLAYING",reason:e})}handlePaused(e){this.emit(RL.PLAYER_STATE_CHANGED,{type:this.kind,state:"PAUSED",reason:e})}handleStopped(e){this.emit(RL.PLAYER_STATE_CHANGED,{type:this.kind,state:"STOPPED",reason:e})}getElement(){return this.element}};Fb([OL({settings:{retries:2,timeout:0},onError(e,t,r,i){i[0]=(i[0]||1e3)+1e3,t()}})],ML.prototype,"doReplayByRecreateMediaStream",1),Fb([fL([],"PLAYING",{sync:!0})],ML.prototype,"handlePlaying",1),Fb([fL("PLAYING","PAUSED",{ignoreError:!0,sync:!0})],ML.prototype,"handlePaused",1),Fb([fL([],"STOPPED",{sync:!0})],ML.prototype,"handleStopped",1);var LL,PL="trtc_autoplay",xL="".concat(PL,"_mask"),UL="".concat(PL,"_wrapper"),VL="".concat(PL,"_header"),FL="".concat(PL,"_content"),BL="".concat(PL,"_action_wrapper"),HL="".concat(PL,"_question"),WL="".concat(PL,"_collapse"),jL="".concat(PL,"_action_confirm"),GL="".concat(PL,"_detail"),KL="#2473E8",zL="dialog",qL="".concat(zL,"-show"),YL="".concat(zL,"-1"),JL="".concat(zL,"-2"),XL=!1,$L=()=>!!document.querySelector(".".concat(UL)),QL="".concat(gw,"/").concat($D()?"zh-cn":"en","/tutorial-21-advanced-auto-play-policy.html"),ZL="<br><a href='".concat(QL,"' target='_blank'>").concat($D()?"其他方案?":"Any other solution?","</a>"),eP="".concat($D()?"浏览器自动播放策略:在用户与页面产生交互(点击、触摸)之前,浏览器禁止播放有声媒体。该弹窗用于帮助用户恢复音视频播放。".concat(ZL):"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(ZL)),tP=class{constructor(){if(Bb(this,"content","音视频播放被浏览器拦截,请点击“恢复播放”。"),Bb(this,"_dialogNode",null),Bb(this,"_bodyPosition",""),Bb(this,"_showDetail",!1),Bb(this,"_isCollapseClicked",!1),Bb(this,"_isQuestionClicked",!1),$D()||(this.content='Media playback failed. Click the "Resume" to resume playback.'),!XL){let e=document.createElement("style");e.innerHTML=".".concat(xL,"{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(xL," div:not(.").concat(BL,"){display:block !important;}.").concat(UL,"{padding:14px;background:#fff;border-radius:3px;box-shadow:0px 3px 15px #434343;border:1px solid #d1cfcf;max-width:500px;}.").concat(UL," a{color:").concat(KL,";}.").concat(VL,"{overflow:hidden;text-overflow:ellipsis;font-size:16px;font-weight:600;}.").concat(FL,"{margin:8px 0;}.").concat(BL,"{width:100%;display:flex !important;align-items:center;justify-content:right;float:right;}.").concat(WL,"{margin-right:auto;cursor:pointer}.").concat(HL,"{height:100%;line-height:16px;cursor:pointer;}.").concat(jL,"{margin-left:8px;color:#fff;background:").concat(KL,";padding:4px 12px;outline:none;border:1px solid;border-radius:3px;font-weight:bold;}.").concat(jL,":hover{opacity:0.9;}.").concat(WL,",.").concat(jL,",.").concat(FL,",.").concat(HL,"{font-size:14px;}@media screen and (max-width:750px){.").concat(UL,"{width:80vw;}}"),document.head.appendChild(e),XL=!0}this.addDiaLog()}createDiaLog(){let e=document.createElement("template");e.innerHTML='<div class="'.concat(xL,"\"><div class='").concat(UL,"'><div class='").concat(VL,"'>").concat(location.host,"</div><div class='").concat(FL,"'>").concat(this.content,"</div><div class='").concat(GL,'\' style="visibility:hidden;width:100%;height:0;font-size:12px;color:gray;">').concat(eP,"</div><div class='").concat(BL,"'></div></div></div>").trim();let t=document.createElement("button");t.className=jL,t.innerText=$D()?"恢复播放":"Resume",t.onclick=this.onConfirm.bind(this);let r=document.createElement("div");r.className=HL,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=WL,i.innerText="".concat($D()?"详情 >":"Detail >"),i.onclick=this.onCollapseClick.bind(this);let o=e.content.firstChild,n=o.querySelector(".".concat(BL));return n.appendChild(i),n.appendChild(r),n.appendChild(t),o}addDiaLog(){$L()||(this._dialogNode=this.createDiaLog(),document.body.appendChild(this._dialogNode),this._dialogNode.onclick=this.onConfirm.bind(this),this._dialogNode.querySelector(".".concat(UL)).onclick=e=>e.stopPropagation(),this._bodyPosition=document.body.style.position,document.body.style.position="fixed",Yk.info("show autoplay dialog"),NL.uploadEvent({log:qL}))}deleteDiaLog(){this._dialogNode&&(document.body.removeChild(this._dialogNode),document.body.style.position=this._bodyPosition,this._dialogNode=null)}onConfirm(){Yk.warn("confirm clicked, try resume stream"),Gk.emit(zk.AUTOPLAY_DIALOG_CLICK_CONFIRM),this.deleteDiaLog()}onCollapseClick(){let e=this._dialogNode.querySelector(".".concat(GL));e.style.visibility="".concat(this._showDetail?"hidden":"visible"),e.style.height="".concat(this._showDetail?0:"fit-content"),this._showDetail=!this._showDetail,this._isCollapseClicked||NL.uploadEvent({log:YL}),this._isCollapseClicked=!0}onQuestionClick(){window.open(QL,"_blank"),this._isQuestionClicked||NL.uploadEvent({log:JL}),this._isQuestionClicked=!0}},rP=class extends ML{constructor(e){super(e,Pw.VIDEO),Bb(this,"stat",{}),Bb(this,"_calculateTimeout",-1),Bb(this,"viewMirror",!1),Bb(this,"objectFit"),Bb(this,"container"),Bb(this,"canvas"),this.mode=e.canvas?1:0,this.container=e.container,this.canvas=e.canvas,iC(e.viewMirror)||(this.viewMirror=e.viewMirror),iC(e.objectFit)||(this.objectFit=e.objectFit),this.initializeElement()}get isPlaying(){var e;return!("PLAYING"!==this._state||this.element&&this.element.paused)&&("live"===(null==(e=this.track)?void 0:e.readyState)&&!this.track.muted)}initializeElement(){var e;let t=document.createElement(Pw.VIDEO);this.track&&2!==this.mode&&(t.srcObject=new MediaStream([this.track])),t.muted=!0,t.setAttribute("id","video_".concat(this.id)),t.setAttribute("style",this.styleAttribute),this.canvas&&this.canvas.setAttribute("style",this.styleAttribute),t.setAttribute("autoplay","autoplay"),t.setAttribute("playsinline","playsinline"),this.element=t,null==(e=this.container)||e.appendChild(this.elementToRender),this.bindElementEvents(),this.calculateStat()}get styleAttribute(){let e="width: 100%; height: 100%; object-fit: ".concat(this.objectFit,";background-color: black;");return this.viewMirror&&(e+="transform: scaleX(-1);"),e}setContainer(e){var t;this.container=e,this.track&&this.elementToRender&&(null==(t=this.container)||t.appendChild(this.elementToRender))}bindElementEvents(){let e=super.bindElementEvents();this.handleElementEvent=this.handleElementEvent.bind(this),e&&e.add(Pw.ENTER_PICTURE_IN_PICTURE,this.handleElementEvent).add(Pw.LEAVE_PICTURE_IN_PICTURE,this.handleElementEvent)}handleTrackEvent(e){var t;super.handleTrackEvent(e),e.type===Pw.MUTE&&null!=(t=this.stat)&&t.fps&&(this.stat.fps=0)}handleElementEvent(e){var t,r;if(2===this.mode)return;super.handleElementEvent(e);let i=e.type;if(i===Pw.PAUSE&&(this.container&&document.getElementById(this.container.id)||this._log.warn("".concat(this.kind," player has been remove, element ID: ").concat(null==(t=this.container)?void 0:t.id)),this.container&&this.container!==document.getElementById(this.container.id)&&(this._pausedRetryCount=wD,this._log.info("view container ".concat(null==(r=this.container)?void 0:r.id," is recreated"))),this._pausedRetryCount>0&&!$L()&&(this._log.info("[".concat(wD-this._pausedRetryCount+1,"/").concat(wD,"] ").concat(this.kind," player auto resume when paused")),this.resume(),this._pausedRetryCount--),this.stat.fps&&(this.stat.fps=0)),this.viewMirror&&this.element){let e=this.element.style.transform;i===Pw.ENTER_PICTURE_IN_PICTURE?this.element.style.transform=e.replace("scaleX(-1)",""):i===Pw.LEAVE_PICTURE_IN_PICTURE&&!e.includes("scaleX")&&(this.element.style.transform="".concat(e," scaleX(-1)"))}}setCanvas(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;var r,i,o,n;this.canvas!==e&&(null==(r=this.canvas)||r.remove(),null==e||e.setAttribute("style",this.styleAttribute),this.canvas=e,this.mode=e?t:0,2===this.mode&&this.setTrack(e.captureStream().getVideoTracks()[0]),e?(null==(i=this.element)||i.remove(),null==(o=this.container)||o.appendChild(e)):this.element&&(null==(n=this.container)||n.appendChild(this.element)))}setAttr(e){let t=Object.assign({autoplay:"autoplay",playsinline:"playsinline",muted:!0},e);t.style=Object.assign({width:"100%",height:"100%"},t.style),super.setAttr(t)}get mirror(){return this.viewMirror}setRect(e,t){this.elementToRender&&(this.elementToRender.style.width="".concat(e,"px"),this.elementToRender.style.height="".concat(t,"px"))}setViewMirror(e){this.elementToRender&&(this.elementToRender.style.transform=e?"scaleX(-1)":""),this.viewMirror=e}setObjectFit(e){this.elementToRender&&(this.elementToRender.style.objectFit="".concat(e)),this.objectFit=e}setPoster(e){this.element&&(this.element.poster=e)}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;var t;super.stop(e),null==(t=this.canvas)||t.remove()}play(){return this.element?this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender):this.initializeElement(),2===this.mode?Promise.resolve():super.play()}get elementToRender(){return this.canvas||this.element}setTrack(e){e!==this.track&&(this.unbindTrackEvents(),this.track=e,this.emit(RL.MEDIA_TRACK_CHANGED,e),null!==e&&(this.bindTrackEvents(),this.element&&2!==this.mode&&(this.element.srcObject=new MediaStream([e]),this.element.remove()),this.elementToRender&&this.elementToRender.parentElement!==this.container&&this.container&&this.container.append(this.elementToRender)))}getVideoFrame(){if(this.canvas)return this.canvas.toDataURL("image/png");if(!this.element)return"";let e=document.createElement("canvas");return e.width=this.element.videoWidth,e.height=this.element.videoHeight,e.getContext("2d").drawImage(this.element,0,0),e.toDataURL("image/png")}getElement(){return this.element}calculateStat(){try{if(sL()&&this.element&&this._calculateTimeout<0){let e=0,t=null,r=(i,o)=>{this.stat.width=o.width,this.stat.height=o.height,t&&(this.stat.fps=Math.round((o.presentedFrames-t.presentedFrames)/(i-e)*1e3)),e=i,t=o,this._calculateTimeout=-1,this.element&&(this._calculateTimeout=setTimeout((()=>{var e;return null==(e=this.element)?void 0:e.requestVideoFrameCallback(r)}),2e3))};this.element.requestVideoFrameCallback(r)}}catch(aw){this._log.warn("init stat failed",aw)}}};function iP(e,t){return Wb(this,null,(function*(){if(!e.audioWorklet)return Promise.reject("audioWorklet is not supported");try{yield e.audioWorklet.addModule(t),Yk.info("worklet addModule success")}catch(aw){throw Yk.info("worklet addModule catch error. ".concat(aw.message)),aw}}))}"undefined"!=typeof AudioContext?LL=AudioContext:"undefined"!=typeof webkitAudioContext?LL=webkitAudioContext:"undefined"!=typeof mozAudioContext&&(LL=mozAudioContext);var oP,nP=-1;!function e(){try{if(oP)return;(oP=new LL({sampleRate:48e3})).onstatechange=()=>{Yk.info("context state: ".concat(oP.state).concat("running"!==oP.state?" visibilityState: ".concat(document.visibilityState):"")),aP()},clearTimeout(nP)}catch(PF){Yk.error("initAudioContext failed: ".concat(PF," typeof AudioContextClass: ").concat(typeof LL)),nP=setTimeout(e,1e3)}}();var aP=()=>{"suspended"===oP.state?(lP(),document.addEventListener("click",aP)):"interrupted"===oP.state?lP():(document.removeEventListener("visibilitychange",aP),document.removeEventListener("click",aP))},sP=0,cP=-1;function lP(){return new Promise(((e,t)=>{if("running"===oP.state)return e();Date.now()-sP<1e3?(clearTimeout(cP),cP=setTimeout((()=>{sP=Date.now(),oP.resume().then(e,t)}),1e3)):(clearTimeout(cP),sP=Date.now(),oP.resume().then(e,t))})).catch((e=>{Yk.warn("context resume failed: ".concat(e)),document.addEventListener("visibilitychange",aP)}))}document.addEventListener("click",aP);var uP=e=>oP,dP=class{constructor(){Bb(this,"node"),Bb(this,"node2"),Bb(this,"pre",new Set),Bb(this,"next",new Set),Bb(this,"context"),Bb(this,"connectedNodes",new Set),Bb(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(lD){Yk.error(lD)}}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(),mM.addSuccessEvent({key:502701})}catch(iO){Yk.error(iO),mM.addFailedEvent({key:502701,error:iO})}}deleteNode(){var e;if(this.node)try{this._disconnect(),delete this.node,delete this.node2,null==(e=this.context)||e.reduceMixWeight(),this.preNodeReconnect(),mM.addSuccessEvent({key:502702})}catch(aw){Yk.error(aw),mM.addFailedEvent({key:502702,error:aw})}}preNodeReconnect(){this.pre.forEach((e=>{e.node?e.reconnect():e.preNodeReconnect()}))}connectNext(e){this.next.forEach((t=>{e._connect(t.node)||t.connectNext(e)}))}_connect(e){return!(!this.node||!e)&&((this.node2||this.node).connect(e),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(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.forEach((e=>{this.next.add(e),e.pre.add(this)})),this}},hP=class extends dP{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:256;super(),this.fftSize=e,Bb(this,"dataArray",new Uint8Array(0))}setNode(e){e.fftSize=this.fftSize,this.dataArray=new Uint8Array(e.frequencyBinCount),super.setNode(e)}getByteTimeDomainData(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),this.dataArray}get level(){var e;return null==(e=this.node)||e.getByteTimeDomainData(this.dataArray),Math.max(...this.dataArray)/128-1}get timeDomainPathData(){let e=this.getByteTimeDomainData(),t=0,r=0,i="M".concat(t,",").concat(r);for(let o=0;o<e.length;o++)r=e[o]/128*100/2,i+="L".concat(t,",").concat(r),t+=1;return i}},pP=class{constructor(){Bb(this,"source",new dP),Bb(this,"gain",new dP),Bb(this,"destination",new dP)}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(uP().createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}replaceSource(e){this.source.replaceNode(gP(e))}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}},mP=class extends pP{constructor(e){super(),this.context=e,Bb(this,"denoiser",new dP),Bb(this,"voiceChanger",new dP),this.source.pipeTo(this.denoiser.pipeTo(this.voiceChanger.pipeTo(this.gain.pipeTo(this.destination))))}connect(){this.context.inputs.has(this)||(this.destination.setNode(this.context.destination),this.source.setContext(this.context),this.denoiser.setContext(this.context),this.voiceChanger.setContext(this.context),this.gain.setContext(this.context),this.context.inputs.add(this))}disconnect(){this.context.inputs.has(this)&&(this.destination.deleteNode(),this.source.removeContext(),this.denoiser.removeContext(),this.voiceChanger.removeContext(),this.gain.removeContext(),this.context.inputs.delete(this))}remove(){this.gain.deleteNode(),this.denoiser.deleteNode(),this.voiceChanger.deleteNode(),this.source.deleteNode(),this.disconnect()}setVolume(e){1!==e?(this.gain.node||this.gain.setNode(this.context.audioContext.createGain()),this.gain.node.gain.value=e):this.gain.node&&this.gain.deleteNode()}},fP=class{constructor(){Bb(this,"audioContext",uP()),Bb(this,"destination",this.audioContext.createMediaStreamDestination()),Bb(this,"inputs",new Set),Bb(this,"mixWeight",0),this.destination.channelCount=1}addMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.mixWeight+=e,this.mixWeight-1==e+1>>1&&this.mixOnChange()}reduceMixWeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.addMixWeight(-e)}close(){this.inputs.forEach((e=>e.remove()))}get mixTrack(){return this.destination.stream.getAudioTracks()[0]}},_P=new WeakMap;function gP(e){let t=_P.get(e);if(t)return t;let r=uP();if(e instanceof HTMLAudioElement)t=r.createMediaElementSource(e);else{if(!(e instanceof MediaStreamTrack))return e;t=r.createMediaStreamSource(new MediaStream([e]))}return _P.set(e,t),t}var EP=class e{constructor(e){Bb(this,"_volume",0),Bb(this,"_volumeDb",0),Bb(this,"_log"),Bb(this,"_scriptProcessorNode",null),Bb(this,"_audioWorkletNode",null),Bb(this,"_interval",200),Bb(this,"ready",this.preload());let{log:t}=e;this._log=t,Gk.on(zk.AUDIO_LEVEL_INTERVAL,this.handleAudioLevelInterval,this)}static get isRunning(){return Date.now()-e.lastMessageTime<2e3}get node(){return this._audioWorkletNode||this._scriptProcessorNode}preload(){if(!e.workletReady){let t='class VolumeMeterWorklet extends AudioWorkletProcessor{constructor(){super(),this.volume=0,this.intervalTime=200,this.tick=200,this.isStop=!1,this.cache=[],this.sentFirstInfo1=!1,this.unmute=!1,this.port.onmessage=t=>{var e=t.data;switch(e.name){case"chunk":this.cache.push(...e.data),this.sentFirstInfo1||(this.port.postMessage({cl:e.data.length}),this.sentFirstInfo1=!0);break;case"setIntervalTime":this.intervalTime=e.intervalTime;break;case"unmute":this.unmute=!0;break;case"stop":this.isStop=!0}}}process(t,s){t=t[0],s=s[0];if(t||s){if(this.isStop)return!1;var i=s&&s[0]?s[0].length:0,h=this.cache.length,a=(i<h?(s[0].set(this.cache.slice(0,i)),this.cache=this.cache.slice(i)):this.unmute&&s[0].set(t[0]),(i<h?s:t)[0]);if(a){let e=0;for(let t=0;t<a.length;++t)e=Math.max(Math.abs(a[t]),e);s=a.reduce((t,e)=>t+e*e,0)/a.length;this.volume=e,this.tick-=a.length,this.tick<0&&(this.tick+=this.intervalTime/1e3*sampleRate,this.port.postMessage({volume:this.volume,volumeDb:Math.max(10*Math.log10(s)+100,0)/100,cacheLen:h,outputLen:i}))}}return!0}}registerProcessor("volume-meter",VolumeMeterWorklet);';e.workletReady=iP(e.audioContext,URL.createObjectURL(new Blob([t],{type:"application/javascript"})))}return e.workletReady.then((()=>this.initAudioWorklet())).catch((e=>(this._log.error("volumeMeter preload error: ".concat(e)),this.initScriptProcessor())))}initAudioWorklet(){if(!this._audioWorkletNode)try{this._audioWorkletNode=new AudioWorkletNode(e.audioContext,"volume-meter");let t=!1;this._audioWorkletNode.port.onmessage=r=>{e.lastMessageTime=Date.now(),this._volume=r.data.volume||0,this._volumeDb=r.data.volumeDb||0,!t&&r.data.cacheLen&&r.data.outputLen&&(this._log.warn("worklet play success"),t=!0)},this.handleAudioLevelInterval({interval:this._interval})}catch(rO){this._log.error("volumeMeter init audio worklet error: ".concat(rO)),NL.logFailedEvent({userId:this._log.userId,eventType:dD.LOAD_WORKLET,error:rO}),this.initScriptProcessor()}}initScriptProcessor(){if(!this._scriptProcessorNode)try{this._scriptProcessorNode=uP().createScriptProcessor(2048,1,1),this._scriptProcessorNode.onaudioprocess=t=>{e.lastMessageTime=Date.now();let r=t.inputBuffer.getChannelData(0),i=0;for(let e=0;e<r.length;++e)i+=r[e]*r[e];this._volume=Math.sqrt(i/r.length)||0}}catch(rO){this._log.error("volumeMeter init script processor error: ".concat(rO))}}destroy(){this._scriptProcessorNode&&(this._scriptProcessorNode.onaudioprocess=null),this._audioWorkletNode&&(this._audioWorkletNode.port.postMessage({name:"stop"}),this._audioWorkletNode.port.onmessage=null),this._audioWorkletNode=null,this._scriptProcessorNode=null,Gk.off(zk.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})}};Bb(EP,"lastMessageTime",0),Bb(EP,"audioContext",uP()),Bb(EP,"workletReady");var vP=EP,yP=class extends dP{constructor(e){super(),Bb(this,"_volumeMeter"),this._volumeMeter=new vP(e)}deleteNode(){super.deleteNode(),this._volumeMeter.destroy()}init(){return Wb(this,null,(function*(){yield this._volumeMeter.preload(),this.setNode(this._volumeMeter.node)}))}getCalculatedVolume(){return this._volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this._volumeMeter.getInternalAudioLevel()}getVolumeDb(){return this._volumeMeter.getVolumeDb()}write(e){if(this.node){let t=e.allocationSize({planeIndex:0}),r=new Float32Array(t>>2);e.copyTo(r,{planeIndex:0}),this.node.port.postMessage({name:"chunk",data:r},[r.buffer]),e.close()}}},TP=vP,IP=Vb(jb(),1),AP=e=>t=>t.deviceId===e,SP=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Input";Bb(this,"kind"),Bb(this,"type"),Bb(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&&wP(this.devices[0])||t&&(r.forEach((e=>{if(e.deviceId&&!this.devices.find(AP(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Added");Yk.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}})),this.devices.forEach((e=>{if(e.deviceId&&!r.find(AP(e.deviceId))){let r="".concat(this.kind).concat(this.type,"Removed");Yk.warn("".concat(r,": ").concat(JSON.stringify(e))),t.emit(r,e)}}))),this.devices=r}hasDevice(e){return!!this.devices.find((t=>t.deviceId===e))}},RP=class extends IP.EventEmitter{constructor(){super(),Bb(this,"audioInputs",new SP(Pw.AUDIO)),Bb(this,"videoInputs",new SP(Pw.VIDEO)),Bb(this,"audioOutputs",new SP(Pw.AUDIO,"Output")),this.init(),navigator.mediaDevices&&(navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",(()=>this.update())),"ondevicechange"in navigator.mediaDevices||SL.run("interval",(()=>{this.update()}),{delay:1e4}))}init(){DP().then((e=>{this.audioInputs.update(e),this.videoInputs.update(e),this.audioOutputs.update(e)}))}update(){return Wb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){let r=yield DP(t);return e.audioInputs.update(r,e),e.videoInputs.update(r,e),e.audioOutputs.update(r,e),e}()}))}},bP=lw||cw?null:new RP;function wP(e){return e.deviceId===e.groupId&&""===e.groupId}function DP(){return Wb(this,arguments,(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){if(IM()||!yM())return[];let t=yield navigator.mediaDevices.enumerateDevices();if(0!==e){let r={audio:!1,video:!1};if(t.forEach((e=>{wP(e)&&(e.kind===Pw.AUDIO_INPUT?r.audio=!0:e.kind===Pw.VIDEO_INPUT&&(r.video=!0))})),2===e&&(r.audio=!1),1===e&&(r.video=!1),r.audio||r.video){let e;try{e=yield navigator.mediaDevices.getUserMedia(r),r.audio&&lP()}catch(iO){Yk.debug("capture before getDevices failed: ",iO)}t=yield navigator.mediaDevices.enumerateDevices(),null==e||e.getTracks().forEach((e=>e.stop()))}}return t.map(((e,t)=>{let r={kind:e.kind,deviceId:e.deviceId,groupId:e.groupId,label:e.label||"".concat(e.kind,"_").concat(t)};return e.deviceId.length>0&&MP.add("".concat(e.deviceId,"_").concat(e.kind)),e.getCapabilities&&(r.getCapabilities=()=>e.getCapabilities()),r}))}()}))}function CP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return bP.update(e?1:0).then((e=>e.audioInputs.devices))}function NP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return bP.update(e?2:0).then((e=>e.videoInputs.devices))}var kP=!1;function OP(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Wb(this,null,(function*(){return(sN||fk)&&(e=!1),bP.update(e?1:0).then((e=>e.audioOutputs.devices))}))}var MP=new Set;function LP(e,t){return Wb(this,null,(function*(){let r=(yield CP()).find((e=>e.deviceId===DD));return!t&&(null==r?void 0:r.groupId)===e||(null==r?void 0:r.groupId)===e&&r.label===t}))}var PP,xP=class extends pP{constructor(e){super(),this.log=e,Bb(this,"volumeMeter"),Bb(this,"volumeDestination"),Bb(this,"analyser",new hP),this.volumeMeter=new yP({log:this.log}),this.volumeDestination=new dP,this.volumeMeter.pipeTo(this.volumeDestination)}destroy(){this.gain.deleteNode(),this.volumeMeter.deleteNode(),this.analyser.deleteNode(),this.source.deleteNode(),this.destination.deleteNode(),this.volumeDestination.deleteNode()}},UP=class e extends ML{constructor(e){super(e,Pw.AUDIO),Bb(this,"_outputDeviceId"),Bb(this,"_volume",1),Bb(this,"_destination",uP().createMediaStreamDestination()),Bb(this,"pipeline"),Bb(this,"volumeMeterMode","worklet"),this.mode=0,this.pipeline=new xP(this._log)}getMediaStream(){return this.pipeline.stream||(this.track?new MediaStream([this.track]):null)}initializeElement(e){if(("15.2"===vk||"15.3"===vk||"15.4"===vk)&&this.muted)return void this._log.info("audioElement is muted.");let t=PP||new Audio;t.setAttribute("autoplay","autoplay"),t.srcObject=this.getMediaStream(),t.muted=this.muted,this.element=t,nC(e)&&(this.element.volume=Math.min(Math.max(e,0),1)),t===PP&&(PP=void 0),this.bindElementEvents()}play(t){return Wb(this,null,(function*(){if(this.track)return this.pipeline.source.node||this.pipeline.replaceSource(this.track),this.element||this.initializeElement(null==t?void 0:t.volume),this._outputDeviceId&&(yield this.setSinkId(this._outputDeviceId)),"worklet"===this.volumeMeterMode?this.pipeline.volumeMeter.init():"analyser"===this.volumeMeterMode&&this.pipeline.analyser.setNode(uP().createAnalyser()),function(){Wb(this,null,(function*(){try{kP||(kP=!0,Yk.info("speakers:".concat((yield OP()).map((e=>" ".concat(e.deviceId.slice(0,8),": ").concat(e.label))))))}catch(e){}}))}(),Hb(e.prototype,this,"play").call(this)}))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy(),super.stop(e)}setSinkId(e){return Wb(this,null,(function*(){var t,r;this._outputDeviceId!==e&&(this._outputDeviceId=e),this.element&&this.element.sinkId!==e&&(yield null==(r=(t=this.element).setSinkId)?void 0:r.call(t,e))}))}get useDestination(){return!!this.pipeline.stream}setLoop(e){this.element&&(this.element.loop=e)}getAudioLevel(){return this.pipeline.volumeMeter.getCalculatedVolume()}getInternalAudioLevel(){return this.pipeline.volumeMeter.getInternalAudioLevel()}},VP=class extends UP{setTrack(e){this.track!==e&&(this.unbindTrackEvents(),this.track=e,this.emit(RL.MEDIA_TRACK_CHANGED,e),e&&(this.bindTrackEvents(),this.element&&(this.element.srcObject=new MediaStream([e]))))}setVolume(e){this._volume=e,this.element&&(this.element.volume=e)}},FP=class extends UP{constructor(e){super(e),Bb(this,"_sourceElement"),Bb(this,"_output",new dP),this.pipeline.source.pipeTo(this.pipeline.gain.pipeTo(this.pipeline.volumeMeter.pipeTo(this._output),this.pipeline.destination))}setOutput(){this.mode=1,this._output.setNode(uP().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(RL.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){this._volume=e,this.useDestination?(this.pipeline.setVolume(e),this._log.info("set pipeline volume: ".concat(e))):e<=1?this.element?(this._log.info("set element volume: ".concat(e)),this.element.volume=e):this._log.info("set element volume: no element"):sN||(this._log.info("start set pipeline volume: ".concat(e)),this.pipeline.setVolume(e),this.element&&!this._sourceElement&&(this.pipeline.destination.setNode(this._destination),CL(this.element),this._sourceElement=this.element,this._sourceElement.muted=!0,this.element=null,this.play()))}stop(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.pipeline.destroy();let t=this._sourceElement||this.element;t&&_k&&(PP=t),this._sourceElement&&(this._sourceElement.srcObject=null,delete this._sourceElement),super.stop(e)}},BP=class extends EL{constructor(e){let{userId:t,sdkAppId:r,mediaType:i,room:o,PlayerClass:n=(1===i?FP:rP)}=e;var a;super(),Bb(this,"id",Jk()),Bb(this,"userId",""),Bb(this,"isRemote"),Bb(this,"mediaType"),Bb(this,"room"),Bb(this,"user"),Bb(this,"_log"),Bb(this,"_inputTrack"),Bb(this,"_outputTrack"),Bb(this,"isPlayCalled"),Bb(this,"container",null),Bb(this,"player"),Bb(this,"subVideoPlayerMap"),Bb(this,"muted",!1),Bb(this,"abortCtrl"),Bb(this,"objectFit","cover"),Bb(this,"mirror"),Bb(this,"rotation"),Bb(this,"isScreen",!1),Bb(this,"manager"),Bb(this,"trackSettings"),Bb(this,"isFirstVideoFrameEmitted",!1),this.userId=t||"",this.mediaType=i,this._log=Yk.createLogger({id:"".concat(this.kind[0],"t"),userId:null==(a=o||this.room)?void 0:a.userId,remoteUserId:this instanceof nx?void 0:this.userId,sdkAppId:r,type:2===this.mediaType?"auxiliary":"main",isLocal:this instanceof nx}),this.player=new n({id:this.userId||this.id,track:null,muted:!1,container:null,log:this._log}),this.player.on(RL.PLAYER_STATE_CHANGED,(e=>{Gk.emit(zk.PLAYER_STATE_CHANGED,Lb({track:this},e)),this.emit("player-state-changed",e)})),this.kind===Pw.VIDEO&&(this.player.on(RL.LOADED_DATA,(()=>{this.emitFirstVideoFrameEvent(RL.LOADED_DATA),Gk.emit(zk.VIDEO_LOADED_DATA,{track:this})})),this.player.on(RL.LOADED_META_DATA,(()=>{this.emitFirstVideoFrameEvent(RL.LOADED_META_DATA)})),this.player.on(RL.MEDIA_TRACK_CHANGED,(e=>{var t;null==(t=this.subVideoPlayerMap)||t.forEach((t=>t.setTrack(e)))}))),this.onTrackMuted=this.onTrackMuted.bind(this),this.onTrackUnmuted=this.onTrackUnmuted.bind(this),this.onTrackEnded=this.onTrackEnded.bind(this),this.onPlayerError&&this.player.on(RL.ERROR,this.onPlayerError.bind(this))}get log(){return this._log||Yk}get kind(){return 1===this.mediaType?Pw.AUDIO:Pw.VIDEO}get strMediaType(){return 4===this.mediaType?Pw.VIDEO:2===this.mediaType?Pw.SCREEN:Pw.AUDIO}get streamType(){return 2&this.mediaType?"auxiliary":"main"}get isMediaTrackActive(){return!!this.mediaTrack&&(!this.mediaTrack.muted&&"live"===this.mediaTrack.readyState&&this.mediaTrack.enabled)}play(e,t){return Wb(this,null,(function*(){let r=cC(e)?e[0]:e;if(this.isPlayCalled)return this.log.info("play update options: ".concat(JSON.stringify(t))),t&&!iC(t.muted)&&this.setPlayerMute(t.muted),t&&!iC(t.objectFit)&&(this.objectFit=t.objectFit),void(this.player instanceof rP&&(this.player.setObjectFit(this.objectFit),this.container!==r&&r&&(this.container=r,this.player.setContainer(r)),cC(e)&&e.length>=1&&(yield this.playSubContainer(e.slice(1),t))));if(t&&!iC(t.muted)?this.setPlayerMute(t.muted):(!this.isRemote||this.kind===Pw.VIDEO)&&this.setPlayerMute(!0),t&&!iC(t.objectFit)&&(this.objectFit=t.objectFit),this.player instanceof rP&&(this.player.setObjectFit(this.objectFit),t&&!iC(t.poster)&&this.player.setPoster(t.poster)),this.isPlayCalled=!0,r&&(this.container=r,this.player instanceof rP&&this.player.setContainer(r)),Gk.emit(zk.PLAY_TRACK_START,{track:this}),this._outputTrack){this._log.info("play with options: ".concat(JSON.stringify(t)));try{this.player.setTrack(this.playerMediaTrack),yield this.player.play(t),cC(e)&&e.length>1&&(yield this.playSubContainer(e.slice(1),t))}catch(aO){throw this.handleAutoPlayFailed(aO),aO}}else this.log.info("play has not mediaTrack, abort")}))}setMirror(e,t){if(this.isScreen||this.kind!==Pw.VIDEO||iC(e)||e===this.mirror)return;this.mirror=e;let r=this.player;t&&(r=t);let i=this.manager;if(aC(this.mirror))return r.setViewMirror(this.mirror),void(i&&(i.mirror=!1));switch(this.mirror){case"view":i&&(i.mirror=!1),r.setViewMirror(!0);break;case"publish":i&&(i.mirror=!0),r.setViewMirror(!0);break;case"both":i&&(i.mirror=!0),r.setViewMirror(!1)}}playSubContainer(e,t){return Wb(this,null,(function*(){if(!this._outputTrack||this.kind===Pw.AUDIO)return;this.subVideoPlayerMap||(this.subVideoPlayerMap=new Map),this.subVideoPlayerMap.forEach(((t,r)=>{var i;e.find((e=>r===e))||(t.stop(),null==(i=this.subVideoPlayerMap)||i.delete(r))}));for(let[i,o]of e.entries()){let e=this.subVideoPlayerMap.get(o);e?t&&(iC(t.objectFit)||e.setObjectFit(t.objectFit)):this.subVideoPlayerMap.set(o,new rP({id:this.userId||this.id,track:this.playerMediaTrack,container:o,muted:this.player.muted,objectFit:this.objectFit,log:this.log.createChild({id:"vp-sub".concat(i+1)})}))}let r=[...this.subVideoPlayerMap.values()];for(let e of r)e.setViewMirror(this.player.mirror),yield e.play()}))}setAudioOutput(e){return this.player.setSinkId(e)}setAudioVolume(e){this.player.setVolume(e)}getAudioLevel(){return this.player.getAudioLevel()||0}getInternalAudioLevel(){var e;return(null==(e=this.player)?void 0:e.getInternalAudioLevel())||0}stop(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.isPlayCalled&&(this.isPlayCalled=!1,this.player&&(this.log.info("stop ".concat(this.kind," player")),this.player.stop(zC(this)&&!e?this.jitterBufferDelay:0)),this.subVideoPlayerMap&&this.subVideoPlayerMap.size>0&&this.subVideoPlayerMap.forEach((e=>{e.stop()})),this.container=null)}resume(){return Wb(this,null,(function*(){var e;this.isPlayCalled&&(yield null==(e=this.player)?void 0:e.resume())}))}close(){this.log.info("close"),this.isPlayCalled&&this.stop(!0)}setMute(e){this.muted=e,this._inputTrack&&(this._inputTrack.enabled=!e),this._outputTrack&&(this._outputTrack.enabled=!e),this.emit(e?"mute":"unmute",this),Gk.emit(e?zk.TRACK_MUTED:zk.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){DL(e,e).add(Pw.MUTE,this.onTrackMuted).add(Pw.UNMUTE,this.onTrackUnmuted).add(Pw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Pw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){CL(e)}setInputMediaStreamTrack(e){var t;let r=this._inputTrack;if(e!==r)return this._inputTrack=e,this.trackSettings=null==(t=e.getSettings)?void 0:t.call(e),e.enabled=!this.muted,r&&this.uninstallTrackEvent(r),this.installTrackEvent(e),this.emit("input-media-track-changed",e||null,r||null),this.manager?this.manager.changeInput(this):this.setOutputMediaStreamTrack(e)}setOutputMediaStreamTrack(e){var t;e!==this._outputTrack&&(this.isRemote?this.log.debug("setOutputMediaStreamTrack",e.label):this.log.info("setOutputMediaStreamTrack",null==(t=e.getSettings)?void 0:t.call(e).deviceId,e.label),this._outputTrack=e,this._inputTrack&&(this._outputTrack.contentHint=this._inputTrack.contentHint,this._outputTrack.enabled=this._inputTrack.enabled),this.updatePlayingState(!!e),this.emit("output-media-track-changed",e))}setMediaType(e){this.mediaType=e}updatePlayingState(e){if(this.isPlayCalled)if(e){if(this.player.setTrack(this.playerMediaTrack),this.player.isStopped)return this.player.play().catch((e=>this.handleAutoPlayFailed(e))),void this.log.info("playing state updated, play ".concat(this.kind))}else if(!this.player.isStopped)return this.player.stop(zC(this)?this.jitterBufferDelay:0),void this.log.info("playing state updated, stop ".concat(this.kind));this.log.debug("updatePlayingState abort ".concat(this.isPlayCalled," ").concat(e," ").concat(this.player.isStopped))}handleAutoPlayFailed(e){if(this.room&&this.room.enableAutoPlayDialog)new tP;else{let e=()=>{this.resume().then((()=>{document.removeEventListener("click",e,!0)}))};document.addEventListener("click",e,!0)}this.emit("error",e)}getVideoFrame(){return this.player instanceof rP?this.player.getVideoFrame():""}emitFirstVideoFrameEvent(e){var t,r,i;if(this.isFirstVideoFrameEmitted)return;let o=null==(t=this.mediaTrack)?void 0:t.getSettings(),n=(null==o?void 0:o.width)||(null==(r=this.player.element)?void 0:r.videoWidth)||0,a=(null==o?void 0:o.height)||(null==(i=this.player.element)?void 0:i.videoHeight)||0;e===RL.LOADED_META_DATA&&!n&&!a||(e===RL.LOADED_DATA&&!n&&!a&&this._log.warn("the dimension of video is 0x0 in first-video-frame event"),this.isFirstVideoFrameEmitted=!0,HC(this.rotation)&&([n,a]=[a,n]),this.emit("first-video-frame",{width:n,height:a,streamType:this.streamType,userId:this.isRemote?this.userId:""}))}onTrackMuted(){this._log.warn("".concat(this.kind," track is unable to provide media output"))}onTrackUnmuted(){this._log.info("".concat(this.kind," track is able to provide media output"))}onTrackEnded(){this._log.warn("".concat(this.kind," track ended"))}};Fb([fL([],EL.INIT,{sync:!0})],BP.prototype,"close",1);var HP=Object.prototype.hasOwnProperty;var WP=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e||"function"==typeof e||Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(QD(e))switch(Object.prototype.toString.call(e)){case"[object File]":case"[object Map]":case"[object Set]":return 0===e.size;case"[object Object]":for(let t in e)if(HP.call(e,t))return!1;return!0}return!1},jP=YC({retryFunction:function(e){return Wb(this,null,(function*(){let t=function(e){return{audio:KP(e),video:zP(e)}}(e);Yk.info("getUserMedia with constraints: ".concat(JSON.stringify(t)));let r=[],i=[],o=["label","deviceId","groupId"];t.audio&&(r=yield CP(),Yk.info("microphones: ".concat(CC(r.map((e=>Pb(Lb({},e),{groupId:e.groupId.substring(0,8)}))),{keysToInclude:o})))),t.video&&(i=yield NP(),Yk.info("cameras: ".concat(CC(i,{keysToInclude:o}))));try{let e=yield navigator.mediaDevices.getUserMedia(t);return JM&&e.getTracks().forEach((e=>{Yk.info("".concat(e.kind," capabilities: ").concat(CC(e.getCapabilities(),{keysToInclude:PD})))})),t.audio&&lP(),e}catch(aO){let{message:o}=aO;throw"NotFoundError"===aO.name&&(e.video&&i&&0===i.length&&(o=iM({key:ZO.CAMERA_NOT_FOUND})),e.audio&&r&&0===r.length&&(o=iM({key:ZO.MICROPHONE_NOT_FOUND}))),new $b({code:Jb.INITIALIZE_FAILED,name:aO.name,message:o,constraint:aO.constraint})}}))},settings:{retries:3,timeout:500},onError:e=>{let{error:t,retry:r,reject:i,retryFuncArgs:o,retriedCount:n}=e,a=n+1;"NotReadableError"===t.name||"OverconstrainedError"===t.name?(1===a?(o[0].video&&(o[0].maxResolution=!1,(!fk||o[0].width*o[0].height<=2073600)&&o[0].frameRate&&(o[0].frameRate=o[0].frameRate>10?10:5)),o[0].retryWhenExactFailed&&o[0].useExactDeviceId&&(o[0].useExactDeviceId=!1)):2===a?o[0].useDeviceIdOnly=!0:3===a&&!o[0].useExactDeviceId&&(o[0].useTrueAsConstraint=!0),r()):i(t),o[0].microphoneId&&GP(o[0].microphoneId,!1),o[0].cameraId&&GP(o[0].cameraId,!0)},onRetrying:e=>{Yk.warn("getUserMedia NotReadableError observed, retrying [".concat(e,"/3]"))},onRetryFailed:e=>{NL.logFailedEvent({eventType:dD.GET_USER_MEDIA_RETRY,error:e})},onRetrySuccess:e=>{NL.logSuccessEvent({eventType:dD.GET_USER_MEDIA_RETRY}),NL.uploadEvent({log:"stat-".concat(dD.GET_USER_MEDIA_RETRY,"-success-").concat(e)})}});function GP(e,t){return Wb(this,null,(function*(){let r=(t?yield NP():yield CP()).find((t=>t.deviceId===e));r&&rC(r.getCapabilities)&&Yk.warn(CC(r.getCapabilities(),{keysToInclude:PD}))}))}function KP(e){if(!e.audio)return!1;if(e.useTrueAsConstraint)return!0;let t={echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0,sampleRate:e.sampleRate};return!WP(e.microphoneId)&&(t.deviceId=e.useExactDeviceId?{exact:e.microphoneId}:e.microphoneId,e.useDeviceIdOnly)?t:(nC(e.channelCount)&&(t.channelCount=e.channelCount),aC(e.echoCancellation)&&!e.echoCancellation&&(t.echoCancellation=!1),aC(e.noiseSuppression)&&!e.noiseSuppression&&(t.noiseSuppression=!1),aC(e.autoGainControl)&&!e.autoGainControl&&(t.autoGainControl=!1),!!WP(t)||t)}function zP(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&&!WP(r)?r:(e.width&&(r.width={ideal:e.width},t&&!hN&&(r.width.max=e.width)),e.height&&(r.height={ideal:e.height},t&&!hN&&(r.height.max=e.height)),hN&&jN&&e.width&&e.height&&e.width*e.height<101376&&(r.width=e.width,r.height=e.height),e.frameRate&&(r.frameRate=e.frameRate),!!WP(r)||r)}var qP=jP;function YP(e){return JP(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return Wb(this,null,(function*(){let r=yield t.apply(this,i);return yield e.call(this,...i),r}))}))}function JP(e){return function(t,r,i){return i.value=e(i.value,r),i}}var XP=(()=>{let e=!1,t=document.visibilityState;return()=>{document.visibilityState!==t&&Yk.info("visibility change: ".concat(document.visibilityState)),!e&&(document.addEventListener("visibilitychange",(()=>{Yk.info("visibility change: ".concat(document.visibilityState)),t=document.visibilityState})),e=!0)}})(),$P=0,QP=class{constructor(){Bb(this,"log",Yk.createLogger({id:"fq".concat(++$P)})),Bb(this,"isRunning",!1),Bb(this,"queue",[])}get length(){return this.queue.length}get lastQueueItem(){return 0===this.length?null:this.queue[this.length-1]}push(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;let o=Lb({},e),n=new Promise(((e,t)=>{o.resolve=e,o.reject=t}));return o.promise=n,t?this.length<=1?this.queue.push(o):null==(i=null==(r=this.lastQueueItem)?void 0:r.promise)||i.then(o.resolve,o.reject):this.queue.push(o),this.log.debug("push ".concat(this.length)),this.isRunning||this.callNext(),n}shift(){let e=this.queue.shift();return this.log.debug("shift ".concat(this.length)),e}callNext(){if(this.isRunning||0===this.length)return;this.log.debug("callNext ",this.length);let{fn:e,args:t,context:r,resolve:i,reject:o}=this.queue[0];this.isRunning=!0,e.apply(r,t).then(i,o).finally((()=>{this.isRunning=!1,this.shift(),this.callNext()}))}},ZP=new WeakMap,ex=new WeakMap;function tx(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(t,r,i){let o=i.value;return i.value=function(){let t=ZP.get(this)||new QP;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];return ZP.set(this,t),t.push({fn:o,args:i,context:this},e)},i}}function rx(e){return function(t,r,i){let o=i.value,n=t=>e(...t);return i.value=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];let i=ex.get(this)||new Map,a=i.get(n(t))||new QP;return i.set(n(t),a),ex.set(this,i),a.push({fn:o,args:t,context:this})},i}}function ix(e,t){return JP(((r,i)=>function(){let i=e;try{for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let e=r.apply(this,n),s=_C();return dC(e)?e.then((e=>(t?mM.addSuccessEvent({key:i,cost:_C()-s}):mM.addSuccessEvent({key:i}),e))).catch((e=>{throw mM.addFailedEvent({key:i,error:e}),e})):(mM.addSuccessEvent({key:i}),e)}catch(sw){throw mM.addFailedEvent({key:i,error:sw}),sw}}))}var ox=class e extends BP{constructor(e,t){super({mediaType:e,PlayerClass:t}),Bb(this,"isRemote",!1),Bb(this,"deviceId"),Bb(this,"groupId",""),Bb(this,"label",""),Bb(this,"sourceTrack"),Bb(this,"_isRecapturing",!1),Bb(this,"_lastRecaptureTime",0),Bb(this,"_onMuteTimeoutId",-1),Bb(this,"_encodeCheckTimeoutId",-1),Bb(this,"profile")}get enableEncodeFrame(){return!1}get isPublishing(){return"publishing"===this.state.toString()}get isPublished(){return"publish"===this.state}encodeFrame(e,t){throw new Error("Method not implemented.")}installTrackEvent(e){DL(e,e).add(Pw.MUTE,this.onTrackMuted).add(Pw.UNMUTE,this.onTrackUnmuted).add(Pw.ENDED,this.onTrackEnded),e.muted&&this.onTrackMuted(),e.readyState===Pw.ENDED&&this.onTrackEnded()}uninstallTrackEvent(e){CL(e)}setStateToReady(){}capture(e){return Wb(this,null,(function*(){var t;try{let r,i=_C();Gk.emit(zk.LOCAL_TRACK_CAPTURE_START,{track:this}),e.customSource?(r=new MediaStream,r.addTrack(e.customSource)):(null==(t=this.mediaTrack)||t.stop(),r=yield qP(e));let o=r.getTracks()[0];return this.sourceTrack=o,yield this.setInputMediaStreamTrack(o),e.customSource||(this.updateDeviceIdInUse(),this.listenDeviceChange()),Gk.emit(zk.LOCAL_TRACK_CAPTURE_SUCCESS,{track:this,cost:_C()-i}),r}catch(iO){throw Gk.emit(zk.LOCAL_TRACK_CAPTURE_FAILED,{track:this,error:iO}),this.log.error("getUserMedia error observed ".concat(iO)),iO}}))}setOutputMediaStreamTrack(e){var t;if(super.setOutputMediaStreamTrack(e),this.setStateToReady(),this.isPublishing||this.isPublished)return null==(t=this.room)?void 0:t.replaceTrack(this)}publish(e,t){return this.room=e,this.emit("4",{mediaType:this.strMediaType,state:"starting",prevState:"stopped"}),this.userId=e.userId,this._log.setUserId(e.userId),this._log.setSdkAppId(e.sdkAppId),t}unpublish(){this.room&&this.room.localTracks.delete(this),Gk.emit(zk.LOCAL_TRACK_UNPUBLISHED,{track:this})}updateDeviceIdInUse(){return Wb(this,null,(function*(){if(this.mediaTrack&&YM){let{deviceId:e,groupId:t}=this.mediaTrack.getSettings(),{label:r}=this.mediaTrack;(yield function(e){return Wb(this,arguments,(function(e){let{newDeviceId:t,oldDeviceId:r,oldGroupId:i,oldLabel:o,kind:n}=e;return function*(){return t===r&&(n!==Pw.AUDIO||t!==DD||(yield LP(i,o)))}()}))}({newDeviceId:e,oldDeviceId:this.deviceId,oldGroupId:this.groupId,oldLabel:this.label,kind:this.kind}))||(this.deviceId=e,this.label=r,t&&(this.groupId=t),DP().then((t=>{let r=t.find((t=>t.deviceId===e));r&&this.emit("2",r)})))}}))}setProfile(e){this.log.info("setProfile",e),Object.assign(this.profile,e)}isNeedToRecapture(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return!(!this.deviceId||!this.mediaTrack||this.kind===Pw.AUDIO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("mic")||t.includes("麦克风"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Pw.AUDIO_INPUT);return!!MP.has(r)}(this.mediaTrack)||this.kind===Pw.VIDEO&&!function(e){if(e instanceof CanvasCaptureMediaStreamTrack||!(e instanceof MediaStreamTrack))return!1;let t=e.label.toLocaleLowerCase();if(t.includes("camera")||t.includes("webcam"))return!0;let r="".concat(((null==e?void 0:e.getSettings())||{}).deviceId,"_").concat(Pw.VIDEO_INPUT);return!!MP.has(r)}(this.mediaTrack)||this._isRecapturing||e&&jN&&fk)}onTrackMuted(){if(super.onTrackMuted(),XP(),this.isNeedToRecapture(!0)){if(Date.now()-this._lastRecaptureTime<LD)return void setTimeout((()=>this.onTrackMuted()),LD);this._onMuteTimeoutId=setTimeout((()=>Wb(this,null,(function*(){var e;if(null!=(e=this.mediaTrack)&&e.muted){if((sN||cN)&&"visible"!==document.visibilityState)return;this.recapture(yield this.getRecoverCaptureDeviceId())}}))),5e3)}}onTrackUnmuted(){super.onTrackUnmuted(),this._onMuteTimeoutId>0&&clearTimeout(this._onMuteTimeoutId)}onTrackEnded(){return Wb(this,null,(function*(){if(Hb(e.prototype,this,"onTrackEnded").call(this),this.isNeedToRecapture()){if(Date.now()-this._lastRecaptureTime<LD)return void setTimeout((()=>this.onTrackEnded()),LD);this.recapture(yield this.getRecoverCaptureDeviceId())}}))}recapture(e){return Wb(this,null,(function*(){var t;if(this._isRecapturing||!this._inputTrack)return;this.log.warn("recapture trying"),null==(t=this._inputTrack)||t.stop(),this._isRecapturing=!0,this._lastRecaptureTime=Date.now();let r={useExactDeviceId:!0};if("user"===e||"environment"===e)r.facingMode=e;else{let t;("audio"===this.kind?yield CP():yield NP()).find((t=>t.deviceId===e))&&(t=e),r.deviceId=t}return this.capture(r).then((()=>{this._isRecapturing=!1,this.log.warn("recapture success"),this.emit("1",{deviceId:this.deviceId}),Gk.emit(zk.LOCAL_TRACK_RECAPTURE,{track:this})})).catch((e=>{this._isRecapturing=!1,this.log.warn("recapture failed ".concat(e.message)),this.emit("5",e),Gk.emit(zk.LOCAL_TRACK_RECAPTURE,{track:this,error:e})}))}))}getRecoverCaptureDeviceId(){return Wb(this,null,(function*(){let e=this instanceof dx;if(e&&this.facingMode)return this.facingMode;let{deviceId:t}=this;if(t){let r=(ax.get(t)||0)+1;if(ax.set(t,r),r>=3){let i=e?(yield NP()).find((e=>!ax.has(e.deviceId))):(yield CP()).find((e=>!ax.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._inputTrack&&(this._inputTrack.stop(),this.uninstallTrackEvent(this._inputTrack)),null==(e=this.manager)||e.removeInput(this)}close(){super.close(),this.stopCapture()}};Fb([fL(EL.INIT,"ready",{ignoreError:!0,sync:!0})],ox.prototype,"setStateToReady",1),Fb([tx()],ox.prototype,"capture",1),Fb([fL("ready","publish",{ignoreError:!0,success(){var e,t;this.room.localTracks.add(this),Gk.emit(zk.LOCAL_TRACK_PUBLISHED,{track:this}),this.emit("4",{mediaType:this.strMediaType,state:"started",prevState:"starting"}),!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&(this._encodeCheckTimeoutId=setTimeout((()=>{var e,t;if(!(((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.uplinkNetworkQuality)||0)>3)&&this.isPublished&&this.isMediaTrackActive){let e=this.kind===Pw.AUDIO,t=this.stat.bytesSent>0;mM[t?"addSuccessEvent":"addFailedEvent"]({key:e?503700:513702}),t||(mM.addEnum({key:e?503701:513703,value:Fk()}),NL.uploadEvent({log:"stat-encode-failed-".concat(this.kind,"-").concat(xk()||Bk()),userId:this.userId}),this.log.warn("encode failed"),this.emit("6",this))}}),5e3))},fail(e){let t="error";if(e.cause instanceof RTCError){let r=e.cause;r.message.includes("timeout")?t="timeout":r.code===Jb.API_CALL_ABORTED&&(t="api-call")}this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:"starting",reason:t,error:e.cause||e})}}),ix(521714,!1)],ox.prototype,"publish",1),Fb([JP((e=>function(){return Wb(this,null,(function*(){let t="publish"===this.state?"started":"starting";e.call(this),this.emit("4",{mediaType:this.strMediaType,state:"stopped",prevState:t,reason:"api-call"}),clearTimeout(this._encodeCheckTimeoutId)}))})),fL([],"ready",{sync:!0})],ox.prototype,"unpublish",1);var nx=ox,ax=new Map;Gk.on(zk.SWITCH_DEVICE_SUCCESS,(e=>{e.track.deviceId&&ax.delete(e.track.deviceId)}));var sx=class e extends nx{constructor(e){super(1,VP),Bb(this,"mediaType",1),Bb(this,"volume",0),Bb(this,"profile",{echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0,sampleRate:48e3,channelCount:1,bitrate:40}),Bb(this,"playerMuted",!0),Bb(this,"pipeline"),Bb(this,"earMonitorGainNode",new dP),Bb(this,"_output",new dP),Bb(this,"stat",{bytesSent:0,packetsSent:0,audioLevel:0,totalAudioEnergy:0}),this.manager=e,this.pipeline=new mP(e),this.pipeline.gain.pipeTo(this.earMonitorGainNode.pipeTo(this._output),this.player.pipeline.volumeMeter),this.handleMicrophoneAdded=this.handleMicrophoneAdded.bind(this),this.handleMicrophoneRemoved=this.handleMicrophoneRemoved.bind(this)}get dbVolume(){return TP.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}getAudioLevel(){let e=(this.volume||super.getAudioLevel())*this.captureVolume;return e>1?1:e}setInputMediaStreamTrack(t){return Wb(this,null,(function*(){let r=this.trackSettings||{};mM.addEnum({key:501701,value:r.channelCount||0,useUV:!1}),mM.addEnum({key:501702,value:r.sampleRate||0,useUV:!1}),mM.addEnum({key:502700,value:0});let{sampleRate:i,channelCount:o}=r;this._log.info("local audio track input ".concat(JSON.stringify({sampleRate:i,channelCount:o}))),this.pipeline.source.channelCount=o||1,this.pipeline.replaceSource(t),yield Hb(e.prototype,this,"setInputMediaStreamTrack").call(this,t),this.updatePlayingState(!!t)}))}capture(e){let{deviceId:t,customSource:r,useExactDeviceId:i=!0,retryWhenExactFailed:o=!0}=e;return super.capture({video:!1,audio:!0,microphoneId:t,echoCancellation:this.profile.echoCancellation,autoGainControl:this.profile.autoGainControl,noiseSuppression:this.profile.noiseSuppression,sampleRate:this.profile.sampleRate,channelCount:this.profile.channelCount,useExactDeviceId:i,retryWhenExactFailed:o,customSource:r})}switchDevice(e){return Wb(this,null,(function*(){if(this.mediaTrack){if(this.deviceId===e){if(e!==DD)return;if(yield LP(this.groupId,this.label))return}try{this.log.info("switchDevice audio to: ".concat(e)),this.mediaTrack&&this.mediaTrack.stop(),yield this.capture({deviceId:e,useExactDeviceId:!0,retryWhenExactFailed:!1}),Gk.emit(zk.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch microphone success")}catch(lD){throw this.log.error("switch microphone failed ".concat(lD)),this.deviceId&&this.recapture(this.deviceId),lD}}}))}listenDeviceChange(){bP&&!bP.listeners("audioInputRemoved").includes(this.handleMicrophoneRemoved)&&bP.on("audioInputRemoved",this.handleMicrophoneRemoved,this)}handleMicrophoneRemoved(e){return Wb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current microphone is lost: ".concat(JSON.stringify(e))),rF(this.userId,{eventId:2003,param1:6,streamType:1});let t=yield CP();t[0]?this.recapture(t[0].deviceId):bP.on("audioInputAdded",this.handleMicrophoneAdded,this)}}))}handleMicrophoneAdded(e){this.log.warn("microphone added: ".concat(JSON.stringify(e))),this.recapture(e.deviceId)}update3A(e){return Wb(this,arguments,(function(e){var t=this;let{echoCancellation:r,noiseSuppression:i,autoGainControl:o}=e;return function*(){let e=t.sourceTrack||t.mediaTrack;if(!e)return;let n=e.getConstraints(),a=!1;!iC(r)&&r!==t.profile.echoCancellation&&(t.profile.echoCancellation=r,n.echoCancellation=r,a=!0),!iC(i)&&i!==t.profile.noiseSuppression&&(t.profile.noiseSuppression=i,n.noiseSuppression=i,a=!0),!iC(o)&&o!==t.profile.autoGainControl&&(t.profile.autoGainControl=o,n.autoGainControl=o,a=!0),a&&(hN||fk?yield e.applyConstraints(n).catch((e=>t._log.warn("update3A failed: ",e))):t.deviceId&&(yield t.recapture(t.deviceId)))}()}))}get captureVolume(){return this.pipeline.volume}setCaptureVolume(e){this.pipeline.setVolume(e/100),this.pipeline.gain.node&&mM.addEnum({key:502700,value:2})}setAudioVolume(e){super.setAudioVolume(0),sN&&this.player.setMuted(!0),this.earMonitorGainNode.node||(this.earMonitorGainNode.setNode(uP().createGain()),this._output.setNode(uP().destination)),this.earMonitorGainNode.node.gain.value=e}enableTrackANS(e){return this.update3A({noiseSuppression:e})}addDenoiser(e){var t;pk<=92&&48e3!==(null==(t=this.trackSettings)?void 0:t.sampleRate)?this._log.warn("denoiser only support sampleRate 48000 before chrome 93"):(mM.addEnum({key:502700,value:1}),this.pipeline.denoiser.setNode(e),this.enableTrackANS(!1))}removeDenoiser(e){this.pipeline.denoiser.node===e&&(this.pipeline.denoiser.deleteNode(),this.enableTrackANS(!0))}close(){this.pipeline.remove(),this.earMonitorGainNode.deleteNode(),this._output.deleteNode(),bP.off("audioInputAdded",this.handleMicrophoneAdded,this),bP.off("audioInputRemoved",this.handleMicrophoneRemoved,this),super.close()}recapture(t){return Wb(this,null,(function*(){try{yield Hb(e.prototype,this,"recapture").call(this,t)}catch(lD){let i=(yield CP()).find((e=>e.deviceId!==t));if(!i)throw lD;yield Hb(e.prototype,this,"recapture").call(this,i.deviceId)}}))}encodeFrame(e){return this.manager?this.manager.encodePipeline.reduceRight(((e,t)=>t?t({frame:e}):e),e):e}get enableEncodeFrame(){return!!this.manager&&this.manager.encodePipeline.some((e=>e))}},cx=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.dataView=e,this.isSEI&&(t?this.addPreventionByte():this.removePreventionByte())}addPreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-2,r=[],i=0;for(let n=e;n<=t;n++){let e=this.dataView.getInt8(n);switch(e){case 0:case 1:case 2:case 3:2===i&&(r.push(3),i=0),0==e?i++:i=0,r.push(e);break;default:i=0,r.push(e)}}r.push(this.dataView.getInt8(this.dataView.byteLength-1));let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}removePreventionByte(){let e=this.seiPayloadStartIndex,t=this.dataView.byteLength-1,r=[],i=0;for(let n=e;n<=t;n++)switch(this.dataView.getInt8(n)){case 0:i++,r.push(this.dataView.getInt8(n));break;case 3:2!==i&&r.push(this.dataView.getInt8(n)),i=0;break;default:r.push(this.dataView.getInt8(n)),i=0}let o=new DataView(new Uint8Array([...new Uint8Array(this.dataView.buffer).slice(0,e),...r]).buffer);this.dataView=o}get isSEI(){return 6===this.dataView.getUint8(4)}get seiPayloadStartIndex(){let e=6;for(let t=6;t<this.dataView.buffer.byteLength&&(e++,255===this.dataView.getUint8(t));t++);return e}get seiPayloadType(){return this.isSEI?this.dataView.getUint8(5):null}get seiPayload(){if(!this.isSEI)return null;let e=0,t=6;for(let o=6;o<this.dataView.buffer.byteLength;o++){let r=this.dataView.getUint8(o);if(t++,255!==r){e+=r;break}e+=255}let r=new ArrayBuffer(e),i=new DataView(r);for(let o=0;o<r.byteLength;o++,t++)i.setInt8(o,this.dataView.getInt8(t));return i}},lx=class{constructor(){Bb(this,"_seiMessageList",[]),Bb(this,"_smallSeiMessageList",[]),Bb(this,"_seiPayloadType",243)}encodeSEINalu(e){let t=e.byteLength,r=parseInt(String(t/255),10),i=t%255,o=[];o.push(0,0,0,1,6,this._seiPayloadType);for(let a=0;a<r;a++)o.push(255);o.push(i);let n=new DataView(e);return o.push(...new Uint8Array(n.buffer)),o.push(128),new cx(new DataView(new Uint8Array(o).buffer),!0)}sendSEI(e,t){null!=t&&t.seiPayloadType&&(this._seiPayloadType=t.seiPayloadType),this._seiMessageList.push(e),null!=t&&t.small&&this._smallSeiMessageList.push(e)}isEmpty(){return!this._seiMessageList.length}getNaluCount(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}encode(e,t){let r=t?this._smallSeiMessageList:this._seiMessageList;if(r.length>0&&e.data.byteLength>0){let t=9-this.getNaluCount(e.data);if(t<=0)return 0;let i=r.splice(0,t).reverse().map(this.encodeSEINalu.bind(this)),o=i.reduce(((e,t)=>e+t.dataView.byteLength),0),n=new ArrayBuffer(o+e.data.byteLength),a=new DataView(n),s=new DataView(e.data),c=0;for(let e=0;e<i.length;e++)for(let t=0;t<i[e].dataView.byteLength;t++)a.setInt8(c++,i[e].dataView.getInt8(t));for(let r=0;r<e.data.byteLength;r++)a.setInt8(c++,s.getInt8(r));return e.data=n,i.length}return 0}},ux=class e extends nx{constructor(e){super(arguments.length>1&&void 0!==arguments[1]?arguments[1]:4,rP),Bb(this,"profile",Lb({},Ow)),Bb(this,"avoidCropping",!1),Bb(this,"_scaleResolutionDownBy"),Bb(this,"stat",{bytesSent:0,packetsSent:0,framesEncoded:0,framesSent:0,frameWidth:0,frameHeight:0,fpsCapture:0}),Bb(this,"small"),Bb(this,"isNeedToSetBandwidth"),Bb(this,"muteImage"),Bb(this,"manager"),Bb(this,"_seiCodec",new lx),this.manager=e;let t=()=>{this.isAllowed2k4k(this.profile)?this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),this.setProfile(Pb(Lb({},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(YM&&this.mediaTrack)return this.mediaTrack.getSettings().facingMode}get contentHint(){var e;return(null==(e=this._inputTrack)?void 0:e.contentHint)||""}get isQosClearFirst(){var e;return"detail"===(null==(e=this._inputTrack)?void 0:e.contentHint)}setMute(t){return Wb(this,null,(function*(){var r,i,o;if(oC(t)){if(this.muteImage===t)return;yield null==(r=this.manager)?void 0:r.deleteWatermark("mute"),yield null==(i=this.manager)?void 0:i.setWatermark({x:0,y:0,width:this.settings.width,height:this.settings.height,type:"mute",zIndex:999,imageUrl:t}),this.muteImage=t,Hb(e.prototype,this,"setMute").call(this,!1)}else this.muteImage&&(yield null==(o=this.manager)?void 0:o.deleteWatermark("mute"),this.muteImage=void 0),Hb(e.prototype,this,"setMute").call(this,t)}))}capture(e){let{deviceId:t,facingMode:r,useExactDeviceId:i=!0,customSource:o,retryWhenExactFailed:n=!0}=e;return super.capture({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:n,customSource:o})}setProfile(e){let t=Lb({},e),r=t.width>t.height;t.width*t.height<=19200&&cN&&uk&&(this.log.warn("resolution is ".concat(t.width,"*").concat(t.height,", fallback to 240*180")),t.width=r?240:180,t.height=r?180:240,t.bitrate=Math.max(t.bitrate,150)),t.width*t.height>921600&&Sk&&(t.width=r?1280:720,t.height=r?720:1280,this.log.warn("reset to 1280 * 720 on iOS 13~14")),this.avoidCropping&&(uk||hN)&&!Ok()&&t.width*t.height<=230400&&t.width/t.height==16/9&&(this._scaleResolutionDownBy=1280/t.width,t.width=1280,t.height=720,this.log.warn("capture 720p, scale: ".concat(this._scaleResolutionDownBy))),t.bitrate&&(this.isNeedToSetBandwidth=t.bitrate!==this.profile.bitrate),this.isAllowed2k4k(this.profile)?super.setProfile(t):(this.log.warn("Resolution is reset to 1080p, need to upgrade ability here https://cloud.tencent.com/document/product/647/85386"),super.setProfile(Pb(Lb({},this.profile),{width:1920,height:1080})))}applyProfile(){return Wb(this,null,(function*(){var e;if(!this.mediaTrack)return;let{width:t=0,height:r=0}=(this.sourceTrack||this.mediaTrack).getSettings(),i=t*r,o=this.settings;if((o.height!==this.profile.height||o.width!==this.profile.width||o.frameRate!==this.profile.frameRate)&&this.deviceId&&(16===Tk?yield this.recapture(this.deviceId):(yield null==(e=this.sourceTrack||this.mediaTrack)?void 0:e.applyConstraints({width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate}),this.manager&&this.manager.changeInput(this)),this.room&&this.settings.height>=1440&&"publish"===this.state&&this.room.sendAbilityStatus({"2k4k":1}),this.isNeedToSetBandwidth&&this.room&&this.room.setBandWidth)){this.isNeedToSetBandwidth=!1;let{width:e=0,height:t=0}=(this.sourceTrack||this.mediaTrack).getSettings(),r=e*t;return r&&i&&r===i?void this.log.warn("set bandwidth failed: resolution is not changed"):this.room.setBandWidth({bandwidth:this.profile.bitrate,type:Pw.VIDEO,videoType:Pw.BIG})}}))}get settings(){let e={width:this.profile.width,height:this.profile.height,frameRate:this.profile.frameRate},t=this.sourceTrack||this.mediaTrack;return YM&&t&&Object.assign(e,t.getSettings()),e}get scaleResolutionDownBy(){return this._scaleResolutionDownBy?this._scaleResolutionDownBy:BC(this.settings,this.profile)}isAllowed2k4k(e){var t;return!(this.room&&this.room.scheduleResult&&!this.isScreen&&!(e.height*e.width<3686400))||1===(null==(t=this.room.scheduleResult.trtcAutoConf)?void 0:t["2k4k"])}isNeedToSwitchDevice(e){return!(!this.mediaTrack||this.deviceId===e||this.facingMode===e)}switchDevice(e){return Wb(this,null,(function*(){try{if(!this.isNeedToSwitchDevice(e))return;let t={useExactDeviceId:!0,retryWhenExactFailed:!1};"user"===e||"environment"===e?t.facingMode=e:t.deviceId=e,this.mediaTrack.stop(),yield this.capture(t),Gk.emit(zk.SWITCH_DEVICE_SUCCESS,{track:this}),this.log.info("switch camera success")}catch(lD){throw this.log.error("switch camera failed ".concat(lD)),this.deviceId&&this.recapture(this.deviceId),lD}}))}updateSmallConfig(e){var t,r;this._log.info("update small stream config: ".concat(JSON.stringify(e)));let i=!this.small;this.small=e,null==(t=this.manager)||t.update(),i&&(null==(r=this.room)||r.enableSmall(!0)),this.log.info("update small stream config success")}stopSmall(){var e,t;this.small&&(delete this.small,null==(e=this.manager)||e.update(),null==(t=this.room)||t.enableSmall(!1))}listenDeviceChange(){bP&&!bP.listeners("videoInputRemoved").includes(this.handleCameraRemoved)&&bP.on("videoInputRemoved",this.handleCameraRemoved,this)}handleCameraRemoved(e){return Wb(this,null,(function*(){if(e.deviceId===this.deviceId){this.log.warn("current camera is lost: ".concat(JSON.stringify(e))),rF(this.userId,{eventId:2003,param1:7,streamType:2});let t=yield NP();t[0]?this.recapture(t[0].deviceId):bP.on("videoInputAdded",this.handleCameraAdded,this)}}))}handleCameraAdded(e){return Wb(this,null,(function*(){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 iC(this.mirror)&&!this.isScreen&&this.setMirror("view"),super.play(e,t)}close(){bP.off("videoInputAdded",this.handleCameraAdded,this),bP.off("videoInputRemoved",this.handleCameraRemoved,this),super.close()}recapture(t){return Wb(this,null,(function*(){try{yield Hb(e.prototype,this,"recapture").call(this,t)}catch(lD){let i=(yield NP()).find((e=>e.deviceId!==t));if(!i)throw lD;yield Hb(e.prototype,this,"recapture").call(this,i.deviceId)}}))}setContentHint(e){this.mediaTrack&&"contentHint"in this.mediaTrack&&(this.mediaTrack.contentHint!==e&&(this.log.info("setContentHint ".concat(e)),this.mediaTrack.contentHint=e),this.outMediaTrack&&this.outMediaTrack.contentHint!==e&&(this.outMediaTrack.contentHint=e))}setRotation(e){this.manager&&(this.isScreen||iC(e)||e!==this.rotation&&(this.rotation=e,this.manager.rotation=e))}};Fb([YP((function(e){this.setContentHint(e.contentHint||"motion")}))],ux.prototype,"capture",1);var dx=ux,hx=Jk();if("undefined"!=typeof navigator&&navigator.mediaDevices&&"setCaptureHandleConfig"in navigator.mediaDevices)try{navigator.mediaDevices.setCaptureHandleConfig({handle:hx,exposeOrigin:!0,permittedOrigins:["*"]})}catch(PF){}var px=function(e){return Wb(this,null,(function*(){let t=null,r=function(e){let t={preferCurrentTab:"current-tab"===e.preferDisplaySurface||!!e.captureElement,systemAudio:"include",selfBrowserSurface:"include",surfaceSwitching:"include"},r={width:fk?{max:e.width}:{ideal:e.width,max:e.width},height:fk?{max:e.height}:{ideal:e.height,max:e.height},frameRate:e.frameRate,displaySurface:e.preferDisplaySurface||"monitor"};if(t.video=r,e.systemAudio){let{echoCancellation:r=!0,noiseSuppression:i=!1,autoGainControl:o=!1}=e;t.audio={echoCancellation:r,noiseSuppression:i,autoGainControl:o,sampleRate:48e3}}return t}(e);Yk.info("getDisplayMedia with constraints: ".concat(JSON.stringify(r)));let i=yield navigator.mediaDevices.getDisplayMedia(r);e.systemAudio&&0===i.getAudioTracks().length&&(dk&&pk<74||fk||hN)&&Yk.warn("Your browser not support capture system audio");let o=i.getVideoTracks()[0];if(o){if(e.frameRate)try{yield o.applyConstraints({frameRate:{min:e.frameRate,ideal:e.frameRate},width:e.width,height:e.height})}catch(aO){Yk.warn("screen applyConstraints failed: ".concat(aO))}e.captureElement&&(yield function(e,t){return Wb(this,null,(function*(){var r;if("CropTarget"in window&&"fromElement"in CropTarget&&rC(e.cropTo))try{if((null==(r=e.getCaptureHandle())?void 0:r.handle)!==hx)return;let i=yield CropTarget.fromElement(t);yield e.cropTo(i)}catch(i){Yk.warn("cropTo target failed ".concat(i))}}))}(o,e.captureElement))}if(e.audio){let r=function(e){let t={echoCancellation:e.echoCancellation,autoGainControl:e.autoGainControl,noiseSuppression:e.noiseSuppression,sampleRate:e.sampleRate,channelCount:e.channelCount};return iC(e.microphoneId)||(t.deviceId=e.microphoneId),{audio:t,video:!1}}(e);Yk.info("getUserMedia with constraints: ".concat(JSON.stringify(r))),t=yield navigator.mediaDevices.getUserMedia(r),i.addTrack(t.getAudioTracks()[0])}return i}))},mx=class extends dx{constructor(e){super(e,2),Bb(this,"profile",{width:1920,height:1080,frameRate:5,bitrate:1600}),Bb(this,"objectFit","contain"),Bb(this,"isScreen",!0),this._log.id="s-".concat(this._log.id)}capture(e){return Wb(this,arguments,(function(e){var t=this;let{systemAudio:r=!1,autoGainControl:i,echoCancellation:o,noiseSuppression:n,audioTrack:a,videoTrack:s,captureElement:c,preferDisplaySurface:l}=e;return function*(){try{let e;return s||a?(e=new MediaStream,s&&e.addTrack(s),a&&e.addTrack(a)):e=yield px({audio:!1,systemAudio:r,width:t.profile.width,height:t.profile.height,frameRate:t.profile.frameRate,autoGainControl:i,echoCancellation:o,noiseSuppression:n,captureElement:c,preferDisplaySurface:l}),yield t.setInputMediaStreamTrack(e.getVideoTracks()[0]),e}catch(oM){throw t.log.error("getDisplayMedia error observed ".concat(oM)),oM instanceof $b?oM:new $b({code:Jb.INITIALIZE_FAILED,name:oM.name,message:oM.message})}}()}))}switchDevice(e){return Wb(this,null,(function*(){throw new Error("Method not implemented.")}))}};Fb([YP((function(e){this.setContentHint(e.contentHint||"detail")}))],mx.prototype,"capture",1);var fx,_x=class extends sx{constructor(e){super(e),this._log.id="s-".concat(this._log.id)}};function gx(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:48e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=arguments.length>3?arguments[3]:void 0;return Wb(this,null,(function*(){let o=uP();fx||(fx=iP(o,URL.createObjectURL(new Blob(['registerProcessor("dumper",class extends AudioWorkletProcessor{constructor(e){super(),this.sourceSampleRate=e.processorOptions.sourceSampleRate||48e3,this.targetSampleRate=e.processorOptions.targetSampleRate||48e3,this.port.onmessage=e=>{this.port2=e.data.port}}process(e){return(this.port2||this.port).postMessage(this.resampleAll(e,this.sourceSampleRate,this.targetSampleRate)),!0}resampleAll(r,s,a){if(s===a)return r;var o=[];for(let t=0;t<r.length;t++){o[t]=[];for(let e=0;e<r[t].length;e++)o[t][e]=this.resample(r[t][e],s,a)}return o}resample(t,e,r){if(e===r)return t;var s=Math.round(t.length*(this.targetSampleRate/this.sourceSampleRate)),a=new Float32Array(s),o=(t.length-1)/(s-1);a[0]=t[0];for(let e=1;e<s-1;e++){var l=e*o,p=Math.floor(l),h=Math.ceil(l);a[e]=t[p]+(t[h]-t[p])*(l-p)}return a[s-1]=t[t.length-1],a}});'],{type:"application/javascript"})))),yield fx;let n=o.sampleRate,a=new AudioWorkletNode(o,"dumper",{numberOfInputs:e.length,numberOfOutputs:0,processorOptions:{sourceSampleRate:n,targetSampleRate:t}});return a.channelCountMode="explicit",a.channelCount=r,i&&a.port.postMessage({port:i},[i]),e.forEach(((e,t)=>e.connect(a,0,t))),new ReadableStream({start(e){a.port.onmessage=t=>{e.enqueue(t.data)}},cancel(){e.forEach((e=>e.disconnect(a))),a.port.close()}})}))}var Ex=class extends fP{constructor(e){super(),this.room=e,Bb(this,"_localAudioTrack"),Bb(this,"_localScreenAudioTrack"),Bb(this,"log",Yk.createLogger({id:"am"})),Bb(this,"denoiser"),Bb(this,"voiceChanger"),Bb(this,"mixChangedDebounce"),Bb(this,"encodePipeline",[]),Bb(this,"decodePipeline",[]),Bb(this,"getPCMAbortCtrlMap",new Map),Bb(this,"audioFrameEventConfigMap",new Map),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.installEvent()}get _localAudioPipline(){var e;return null==(e=this._localAudioTrack)?void 0:e.pipeline}dump(e){var t,r;if(!this._localAudioTrack)return;let i=[],o=[];null!=(t=this._localAudioPipline)&&t.source.node&&(i.push(this._localAudioPipline.source.node),o.push("mic")),null!=(r=this._localAudioPipline)&&r.denoiser.node&&(i.push(this._localAudioPipline.denoiser.node),o.push("mic-processed")),this.mixWeight>1&&(i.push(this.audioContext.createMediaStreamSource(this._localAudioPipline.stream)),o.push("mix")),this.log.info("dump audio track ".concat(o,", duration: ").concat(e));let n=new AbortController,a=[],s=setTimeout((()=>{this.log.info('dump audio track complete please input "download()" to download.'),n.abort("timeout")}),1e3*e),c=()=>{for(let e=0;e<o.length;e++){let t=URL.createObjectURL(new Blob(a[e])),r=document.createElement("a");r.href=t,r.download="".concat(o[e],".pcm"),r.style.display="none",document.body.appendChild(r),r.click(),URL.revokeObjectURL(t),r.remove()}clearTimeout(s),n.abort("download")},l=gx(i).then((e=>e.pipeTo(new WritableStream({write(e){e.forEach(((e,t)=>a[t]=a[t]?a[t].concat(e[0]):[e[0]]))}}),n).catch((e=>c))));return{then:l.then.bind(l),download:c}}getPCM(e,t){var r,i,o;if(iC(WritableStream))return void this.log.warn("getPCM failed: browser not support WritableStream");let{enable:n,sampleRate:a=48e3,channelCount:s=1,port:c}=(""===t?this.audioFrameEventConfigMap.get(""):this.audioFrameEventConfigMap.get(t)||this.audioFrameEventConfigMap.get("*"))||{};if(!n)return;this.log.info("getPCM ".concat(t||"local"));let l,u,d=Math.floor(.04*a),h=new Float32Array(d),p=new Float32Array(d),m=0,f=new AbortController,_=""===t?null==(r=this._localAudioTrack)?void 0:r.mediaTrack:null==(o=null==(i=this.room)?void 0:i.remotePublishedUserMap.get(t))?void 0:o.remoteAudioTrack.mediaTrack;if(_)return gx([uP().createMediaStreamSource(new MediaStream([_]))],a,s,c).then((r=>r.pipeTo(new WritableStream({write(r){r[0][0]&&(m+r[0][0].length>d?(h.set(r[0][0].subarray(0,d-m),m),l=r[0][0].subarray(d-m),r[0][1]&&(p.set(r[0][1].subarray(0,d-m),m),u=r[0][1].subarray(d-m)),m+=d-m):(l&&(h.set(l,m),m+=l.length,l=void 0),u&&(p.set(u,m),u=void 0),h.set(r[0][0],m),r[0][1]&&p.set(r[0][1],m),m+=r[0][0].length),m>=d&&(m=0,e({userId:t,sampleRate:a,channelCount:s,data:1===s?h:[h,p]}),h=new Float32Array(d),p=new Float32Array(d)))}}),f).catch((e=>this.log.warn("stop getPCM reason:".concat(e)))))),f;this.log.info("getPCM failed: ".concat(t||"local"," has no audio track"))}get hasScreenAudioTrack(){return null!==this._localScreenAudioTrack}get hasAudioTrack(){return!iC(this._localAudioTrack)}changeInput(e){return e instanceof _x?(this._localScreenAudioTrack=e,e.pipeline.connect(),this.mixOnChange()):e instanceof sx?(this._localAudioTrack=e,this.denoiser&&e.addDenoiser(this.denoiser),e.pipeline.connect(),this.mixOnChange()):e instanceof LV?e.setOutputMediaStreamTrack(e.mediaTrack):void 0}mixOnChange(){return this.mixChangedDebounce||(this.mixChangedDebounce=Promise.resolve().then((()=>{var e,t;return delete this.mixChangedDebounce,Promise.all([null==(e=this._localAudioTrack)?void 0:e.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localAudioTrack.mediaTrack),null==(t=this._localScreenAudioTrack)?void 0:t.setOutputMediaStreamTrack(this.mixWeight>1?this.mixTrack:this._localScreenAudioTrack.mediaTrack)])}))),this.mixChangedDebounce}removeInput(e){e instanceof _x?delete this._localScreenAudioTrack:e instanceof sx&&delete this._localAudioTrack}addDenoiser(e){var t;this.denoiser=e,null==(t=this._localAudioTrack)||t.addDenoiser(e)}removeDenoiser(e){var t;delete this.denoiser,null==(t=this._localAudioTrack)||t.removeDenoiser(e)}addVoiceChanger(e,t){var r;this.voiceChanger=[e,t],null==(r=this._localAudioTrack)||r.pipeline.voiceChanger.setNode(e,t)}removeVoiceChanger(){var e;delete this.voiceChanger,null==(e=this._localAudioTrack)||e.pipeline.voiceChanger.deleteNode()}destroy(){this.close(),this.getPCMAbortCtrlMap.forEach((e=>null==e?void 0:e.abort("destroy"))),this.getPCMAbortCtrlMap.clear(),this.audioFrameEventConfigMap.clear(),this.uninstallEvent()}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}handleLocalTrackStarted(e){let{room:t,userId:r}=e;var i;if(t!==this.room||this.getPCMAbortCtrlMap.get(r))return;let o=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),"");this.getPCMAbortCtrlMap.set(r,o),this.getPCMAbortCtrlMap.get(r)&&(null==(i=this._localAudioTrack)||i.on("input-media-track-changed",(()=>{let e=this.getPCMAbortCtrlMap.get(r);e&&(e.abort("inputMediaTrackChanged"),e=this.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),""),this.getPCMAbortCtrlMap.set(r,e))})))}handleLocalTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopLocalAudio"),this.getPCMAbortCtrlMap.delete(r))}handleRemoteTrackStarted(e){let{room:t,userId:r}=e;if(t===this.room&&!this.getPCMAbortCtrlMap.get(r)){let e=this.room.audioManager.getPCM((e=>{var t;null==(t=this.room)||t.emit("audio-frame",e)}),r);this.getPCMAbortCtrlMap.set(r,e)}}handleRemoteTrackStopped(e){let{room:t,userId:r}=e;if(t!==this.room)return;let i=this.getPCMAbortCtrlMap.get(r);i&&(i.abort("stopRemoteAudio"),this.getPCMAbortCtrlMap.delete(r))}installEvent(){Gk.on("113",this.handleLocalTrackStarted,this),Gk.on("114",this.handleLocalTrackStopped,this),Gk.on("115",this.handleRemoteTrackStarted,this),Gk.on("116",this.handleRemoteTrackStopped,this)}uninstallEvent(){Gk.off("113",this.handleLocalTrackStarted),Gk.off("114",this.handleLocalTrackStopped),Gk.off("115",this.handleRemoteTrackStarted),Gk.off("116",this.handleRemoteTrackStopped)}};var vx={};function yx(){}Ub(vx,{Events:()=>Px,Inspect:()=>bx,LastSink:()=>wx,Sink:()=>Dx,Subscribe:()=>Cx,TimeoutError:()=>xx,audit:()=>BU,bindCallback:()=>fU,bindNodeCallback:()=>_U,buffer:()=>Jx,bufferCount:()=>Yx,bufferTime:()=>AV,call:()=>Tx,catchError:()=>RV,combineLatest:()=>Gx,concat:()=>Hx,concatMap:()=>dV,concatMapTo:()=>hV,count:()=>IU,create:()=>kx,debounce:()=>jU,debounceTime:()=>GU,defer:()=>Qx,delay:()=>SV,deliver:()=>Ox,dispose:()=>Ax,elementAt:()=>KU,empty:()=>vU,every:()=>XU,exhaustMap:()=>vV,exhaustMapTo:()=>yV,filter:()=>bU,find:()=>zU,findIndex:()=>qU,first:()=>YU,fromAnimationFrame:()=>pU,fromArray:()=>rU,fromEvent:()=>sU,fromEventPattern:()=>aU,fromFetch:()=>lU,fromIterable:()=>uU,fromPromise:()=>cU,fromReadableStream:()=>hU,fromReader:()=>dU,groupBy:()=>TV,identity:()=>Ix,ignoreElements:()=>wU,iif:()=>jx,inspect:()=>Sx,interval:()=>iU,last:()=>JU,map:()=>eV,mapTo:()=>tV,max:()=>AU,merge:()=>Fx,mergeMap:()=>fV,mergeMapTo:()=>_V,min:()=>SU,never:()=>gU,nothing:()=>yx,of:()=>tU,pairwise:()=>QU,pipe:()=>Nx,race:()=>Bx,range:()=>mU,reduce:()=>TU,retry:()=>kV,scan:()=>$U,share:()=>Vx,shareReplay:()=>Wx,skip:()=>OU,skipUntil:()=>MU,skipWhile:()=>LU,startWith:()=>zx,subject:()=>$x,subscribe:()=>DV,sum:()=>RU,switchMap:()=>aV,switchMapTo:()=>cV,take:()=>DU,takeLast:()=>kU,takeUntil:()=>CU,takeWhile:()=>NU,tap:()=>CV,throttle:()=>VU,throwError:()=>EU,timeInterval:()=>IV,timeout:()=>NV,timer:()=>oU,toPromise:()=>bV,toReadableStream:()=>wV,withLatestFrom:()=>qx,zip:()=>Kx});var Tx=e=>e(),Ix=e=>e;function Ax(){this.dispose()}var Sx=()=>"undefined"!=typeof __FASTRX_DEVTOOLS__,Rx=1,bx=class extends Function{toString(){return"".concat(this.name,"(").concat(this.args.length?[...this.args].join(", "):"",")")}subscribe(e){let t=new Lx(e,this,this.streamId++);return Px.subscribe({id:this.id,end:!1},{nodeId:t.sourceId,streamId:t.id}),this(t),t}},wx=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=yx,this.error=yx,this.next=yx,this.dispose=yx,this.subscribe=yx,this.doDefer()}subscribe(e){return e instanceof bx?e.subscribe(this):e(this),this}get bindSubscribe(){return e=>this.subscribe(e)}doDefer(){this.defers.forEach(Tx),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}},Dx=class extends wx{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)}},Cx=class extends wx{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yx,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yx,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:yx;if(super(),this._next=t,this._error=r,this._complete=i,this.then=yx,e instanceof bx){let o={toString:()=>"subscribe",id:0,source:e};this.defer((()=>{Px.defer(o,0)})),Px.create(o),Px.pipe(o),this.sourceId=o.id,this.subscribe(e),Px.subscribe({id:o.id,end:!0}),t==yx?this._next=e=>Px.next(o,0,e):this.next=e=>{Px.next(o,0,e),t(e)},i==yx?this._complete=()=>Px.complete(o,0):this.complete=()=>{this.dispose(),Px.complete(o,0),i()},r==yx?this._error=e=>Px.complete(o,0,e):this.error=e=>{this.dispose(),Px.complete(o,0,e),r()}}else this.subscribe(e)}next(e){this._next(e)}complete(){this.dispose(),this._complete()}error(e){this.dispose(),this._error(e)}};function Nx(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 kx(e,t,r){if(Sx()){let i=Object.defineProperties(Object.setPrototypeOf(e,bx.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}});Px.create(i);for(let e=0;e<r.length;e++){let t=r[e];"function"==typeof t&&t instanceof bx&&Px.addSource(i,t)}return i}return e}function Ox(e,t){return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return r=>{if(r instanceof bx){let o=kx((t=>{let n=new e(t,...i);n.sourceId=o.id,n.subscribe(r)}),t,arguments);return o.source=r,Px.pipe(o),o}return t=>r(new e(t,...i))}}}function Mx(e,t){window.postMessage({source:"fastrx-devtools-backend",payload:{event:e,payload:t}})}var Lx=class extends Dx{constructor(e,t,r){super(e),this.source=t,this.id=r,this.sourceId=e.sourceId,this.defer((()=>{Px.defer(this.source,this.id)}))}next(e){Px.next(this.source,this.id,e),this.sink.next(e)}complete(){Px.complete(this.source,this.id),this.sink.complete()}error(e){Px.complete(this.source,this.id,e),this.sink.error(e)}},Px={addSource(e,t){Mx("addSource",{id:e.id,name:e.toString(),source:{id:t.id,name:t.toString()}})},next(e,t,r){Mx("next",{id:e.id,streamId:t,data:r&&r.toString()})},subscribe(e,t){let{id:r,end:i}=e;Mx("subscribe",{id:r,end:i,sink:{nodeId:t&&t.nodeId,streamId:t&&t.streamId}})},complete(e,t,r){Mx("complete",{id:e.id,streamId:t,err:r?r.toString():null})},defer(e,t){Mx("defer",{id:e.id,streamId:t})},pipe(e){Mx("pipe",{name:e.toString(),id:e.id,source:{id:e.source.id,name:e.source.toString()}})},update(e){Mx("update",{id:e.id,name:e.toString()})},create(e){e.id||(e.id=Rx++),Mx("create",{name:e.toString(),id:e.id})}},xx=class extends Error{constructor(e){super("timeout after ".concat(e,"ms")),this.timeout=e}},Ux=class extends wx{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 Vx(){return e=>{let t=new Ux(e);if(e instanceof bx){let r=kx((e=>{t.add(e)}),"share",arguments);return t.sourceId=r.id,r.source=e,Px.pipe(r),r}return kx(t.add.bind(t),"share",arguments)}}function Fx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx((e=>{let r=new Dx(e),i=t.length;r.complete=()=>{0==--i&&e.complete()},t.forEach(r.bindSubscribe)}),"merge",arguments)}function Bx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx((e=>{let r=new Map;t.forEach((t=>{let i=new Dx(e);r.set(t,i),i.complete=()=>{r.delete(t),0===r.size?e.complete():i.dispose()},i.next=e=>{r.delete(t),r.forEach((e=>e.dispose())),i.resetNext(),i.resetComplete(),i.next(e)}})),t.forEach((e=>r.get(e).subscribe(e)))}),"race",arguments)}function Hx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx((e=>{let r=0,i=t.length,o=new Dx(e);o.complete=()=>{r<i&&!o.disposed?(o.doDefer(),o.subscribe(t[r++])):e.complete()},o.complete()}),"concat",arguments)}function Wx(e){return t=>{let r=new Ux(t),i=[];return r.next=function(t){i.push(t),i.length>e&&i.shift(),this.sinks.forEach((e=>e.next(t)))},kx((e=>{e.defer((()=>r.remove(e))),i.forEach((t=>e.next(t))),r.add(e)}),"shareReplay",arguments)}}function jx(e,t,r){return kx((i=>e()?t(i):r(i)),"iif",arguments)}function Gx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx((e=>{let r=t.length,i=r,o=r,n=new Array(r),a=()=>{0==--o&&e.complete()};t.forEach(((t,r)=>{let o=new Dx(e);o.next=t=>{0==--i?(o.next=t=>{n[r]=t,e.next(n)},o.next(t)):n[r]=t},o.complete=a,o.subscribe(t)}))}),"combineLatest",arguments)}function Kx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx((e=>{let r=t.length,i=r,o=new Array(r),n=()=>{0==--i&&e.complete()};t.forEach(((t,r)=>{let i=new Dx(e),a=[];o[r]=a,i.next=t=>{a.push(t),o.every((e=>e.length))&&e.next(o.map((e=>e.shift())))},i.complete=n,i.subscribe(t)}))}),"zip",arguments)}function zx(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return e=>kx((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length;for(;i<o&&!r.disposed;)r.next(t[i++]);r.disposed||r.subscribe(e)}),"startWith",arguments)}var qx=Ox(class extends Dx{constructor(e){super(e);let t=new Dx(this.sink);for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];t.next=e=>this.buffer=e,t.complete=yx,t.subscribe(Gx(...i))}next(e){this.buffer&&this.sink.next([e,...this.buffer])}},"withLatestFrom"),Yx=Ox(class extends Dx{constructor(e,t,r){super(e),this.bufferSize=t,this.startBufferEvery=r,this.buffer=[],this.count=0,this.startBufferEvery&&(this.buffers=[[]])}next(e){this.startBufferEvery?(this.count++===this.startBufferEvery&&(this.buffers.push([]),this.count=1),this.buffers.forEach((t=>{t.push(e)})),this.buffers[0].length===this.bufferSize&&this.sink.next(this.buffers.shift())):(this.buffer.push(e),this.buffer.length===this.bufferSize&&(this.sink.next(this.buffer),this.buffer=[]))}complete(){this.buffer.length?this.sink.next(this.buffer):this.buffers.length&&this.buffers.forEach((e=>this.sink.next(e))),super.complete()}},"bufferCount"),Jx=Ox(class extends Dx{constructor(e,t){super(e),this.buffer=[];let r=new Dx(e);r.next=t=>{e.next(this.buffer),this.buffer=[]},r.complete=yx,r.subscribe(t)}next(e){this.buffer.push(e)}complete(){this.buffer.length&&this.sink.next(this.buffer),super.complete()}},"buffer"),Xx=function(e,t,r,i){return new(r||(r=Promise))((function(o,n){function a(e){try{c(i.next(e))}catch(oM){n(oM)}}function s(e){try{c(i.throw(e))}catch(oM){n(oM)}}function c(e){e.done?o(e.value):function(e){return e instanceof r?e:new r((function(t){t(e)}))}(e.value).then(a,s)}c((i=i.apply(e,t||[])).next())}))};function $x(e){let t=arguments,r=Vx()(kx((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=yx,r.complete=yx,r.error=yx,r}function Qx(e){return kx((t=>t.subscribe(e())),"defer",arguments)}var Zx=e=>t=>{setTimeout((()=>e(t)))},eU=e=>Zx((t=>{for(let r=0;!t.disposed&&r<e.length;r++)t.next(e[r]);t.complete()}));function tU(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return kx(eU(t),"of",arguments)}function rU(e){return kx(eU(e),"fromArray",arguments)}function iU(e){return kx((t=>{let r=0,i=setInterval((()=>t.next(r++)),e);return t.defer((()=>{clearInterval(i)})),"interval"}),"interval",arguments)}function oU(e,t){return kx((r=>{let i=0,o=setTimeout((()=>{if(r.removeDefer(n),r.next(i++),t){let e=setInterval((()=>r.next(i++)),t);r.defer((()=>{clearInterval(e)}))}else r.complete()}),e),n=()=>{clearTimeout(o)};r.defer(n)}),"timer",arguments)}function nU(e,t){return r=>{let i=e=>r.next(e);r.defer((()=>t(i))),e(i)}}function aU(e,t){return kx(nU(e,t),"fromEventPattern",arguments)}function sU(e,t){if("on"in e&&"off"in e)return kx(nU((r=>e.on(t,r)),(r=>e.off(t,r))),"fromEvent",arguments);if("addListener"in e&&"removeListener"in e)return kx(nU((r=>e.addListener(t,r)),(r=>e.removeListener(t,r))),"fromEvent",arguments);if("addEventListener"in e)return kx(nU((r=>e.addEventListener(t,r)),(r=>e.removeEventListener(t,r))),"fromEvent",arguments);throw"target is not a EventDispachter"}function cU(e){return kx((t=>{e.then(t.next.bind(t),t.error.bind(t))}),"fromPromise",arguments)}function lU(e,t){return kx(Qx((()=>cU(fetch(e,t)))),"fromFetch",arguments)}function uU(e){return kx(Zx((t=>{try{for(let r of e){if(t.disposed)return;t.next(r)}t.complete()}catch(aw){t.error(aw)}})),"fromIterable",arguments)}function dU(e){let t=r=>Xx(this,void 0,void 0,(function*(){if(r.disposed)return;let{done:i,value:o}=yield e.read();i?r.complete():(r.next(o),t(r))}));return kx((e=>{t(e)}),"fromReader",arguments)}function hU(e){return kx((t=>{let r=new AbortController,i=r.signal;t.defer((()=>r.abort("cancelled"))),e.pipeTo(new WritableStream({write(e){t.next(e)},close(){t.complete()},abort(e){t.error(e)}}),{signal:i}).then((()=>t.complete()),(e=>t.error(e)))}),"fromReadableStream",arguments)}function pU(){return kx((e=>{let t=requestAnimationFrame((function r(i){e.disposed||(e.next(i),t=requestAnimationFrame(r))}));e.defer((()=>cancelAnimationFrame(t)))}),"fromAnimationFrame",arguments)}function mU(e,t){return kx((function(r){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t+e;for(;i<o&&!r.disposed;)r.next(i++);return r.complete(),"range"}),"range",arguments)}function fU(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return kx((r=>{let o=i.concat((e=>(r.next(e),r.complete())));e.apply(t,o)}),"bindCallback",arguments)}function _U(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return kx((r=>{let o=i.concat(((e,t)=>e?r.error(e):(r.next(t),r.complete())));e.apply(t,o)}),"bindNodeCallback",arguments)}function gU(){return kx((()=>{}),"never",arguments)}function EU(e){return kx((t=>t.error(e)),"throwError",arguments)}function vU(){return kx((e=>e.complete()),"empty",arguments)}var yU=class extends Dx{constructor(e,t,r){super(e),this.f=t;let i=()=>{this.sink.next(this.acc),this.sink.complete()};void 0===r?this.next=e=>{this.acc=e,this.complete=i,this.resetNext()}:(this.acc=r,this.complete=i)}next(e){this.acc=this.f(this.acc,e)}},TU=Ox(yU,"reduce"),IU=e=>Ox(yU,"count")(((t,r)=>e(r)?t+1:t),0),AU=()=>Ox(yU,"max")(Math.max),SU=()=>Ox(yU,"min")(Math.min),RU=()=>Ox(yU,"sum")(((e,t)=>e+t),0),bU=Ox(class extends Dx{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"),wU=Ox(class extends Dx{next(e){}},"ignoreElements"),DU=Ox(class extends Dx{constructor(e,t){super(e),this.count=t}next(e){this.sink.next(e),0==--this.count&&this.complete()}},"take"),CU=Ox(class extends Dx{constructor(e,t){super(e);let r=new Dx(e);r.next=()=>e.complete(),r.complete=Ax,r.subscribe(t)}},"takeUntil"),NU=Ox(class extends Dx{constructor(e,t){super(e),this.f=t}next(e){this.f(e)?this.sink.next(e):this.complete()}},"takeWhile"),kU=e=>TU(((t,r)=>(t.push(r),t.length>e&&t.shift(),t)),[]),OU=Ox(class extends Dx{constructor(e,t){super(e),this.count=t}next(e){0==--this.count&&(this.next=super.next)}},"skip"),MU=Ox(class extends Dx{constructor(e,t){super(e),e.next=yx;let r=new Dx(e);r.next=()=>{r.dispose(),e.resetNext()},r.complete=Ax,r.subscribe(t)}},"skipUntil"),LU=Ox(class extends Dx{constructor(e,t){super(e),this.f=t}next(e){this.f(e)||(this.next=super.next,this.next(e))}},"skipWhile"),PU={leading:!0,trailing:!1},xU=class extends Dx{constructor(e,t,r){super(e),this.durationSelector=t,this.trailing=r}cacheValue(e){this.last=e,this.disposed&&this.throttle(e)}send(e){this.sink.next(e),this.throttle(e)}throttle(e){this.reset(),this.subscribe(this.durationSelector(e))}next(){this.complete()}complete(){this.dispose(),this.trailing&&this.send(this.last)}},UU=class extends Dx{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:PU;super(e),this.durationSelector=t,this.config=r,this._throttle=new xU(this.sink,this.durationSelector,this.config.trailing),this._throttle.dispose()}next(e){this._throttle.disposed&&this.config.leading?this._throttle.send(e):this._throttle.cacheValue(e)}complete(){this._throttle.throttle=yx,this._throttle.complete(),super.complete()}},VU=Ox(UU,"throttle"),FU={leading:!1,trailing:!0},BU=e=>Ox(UU,"audit")(e,FU),HU=class extends Dx{next(){this.complete()}complete(){this.dispose(),this.sink.next(this.last)}},WU=class extends Dx{constructor(e,t){super(e),this.durationSelector=t,this._debounce=new HU(this.sink),this._debounce.dispose()}next(e){this._debounce.dispose(),this._debounce.reset(),this._debounce.last=e,this._debounce.subscribe(this.durationSelector(e))}complete(){this._debounce.complete(),super.complete()}},jU=Ox(WU,"debounce"),GU=e=>Ox(WU,"debounceTime")((t=>oU(e))),KU=Ox(class extends Dx{constructor(e,t,r){super(e),this.count=t,this.defaultValue=r}next(e){0==this.count--&&(this.defaultValue=e,this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("not enough elements in sequence"))}},"elementAt"),zU=e=>t=>DU(1)(LU((t=>!e(t)))(t)),qU=Ox(class extends Dx{constructor(e,t){super(e),this.f=t,this.i=0}next(e){this.f(e)?(this.sink.next(this.i++),this.complete()):++this.i}},"findIndex"),YU=Ox(class extends Dx{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e,this.complete())}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"first"),JU=Ox(class extends Dx{constructor(e,t,r){super(e),this.f=t,this.defaultValue=r,this.index=0}next(e){(!this.f||this.f(e,this.index++))&&(this.defaultValue=e)}complete(){void 0!==this.defaultValue?(this.sink.next(this.defaultValue),super.complete()):this.error(new Error("no elements in sequence"))}},"last"),XU=Ox(class extends Dx{constructor(e,t){super(e),this.predicate=t,this.index=0}next(e){this.predicate(e,this.index++)?this.result=!0:(this.result=!1,this.complete())}complete(){void 0!==this.result?(this.sink.next(this.result),super.complete()):this.error(new Error("no elements in sequence"))}},"every"),$U=Ox(class extends Dx{constructor(e,t,r){super(e),this.f=t,void 0===r?this.next=e=>{this.acc=e,this.resetNext(),this.sink.next(this.acc)}:this.acc=r}next(e){this.sink.next(this.acc=this.f(this.acc,e))}},"scan"),QU=Ox(class extends Dx{constructor(){super(...arguments),this.hasLast=!1}next(e){this.hasLast?this.sink.next([this.last,e]):this.hasLast=!0,this.last=e}},"pairwise"),ZU=class extends Dx{constructor(e,t,r){super(e),this.mapper=t,this.thisArg=r}next(e){super.next(this.mapper.call(this.thisArg,e))}},eV=Ox(ZU,"map"),tV=e=>Ox(ZU,"mapTo")((t=>e)),rV=class extends Dx{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()}},iV=class extends Dx{constructor(e,t,r){super(e),this.makeSource=t,this.combineResults=r,this.index=0}subInner(e,t){let r=this.currentSink=new t(this.sink,e,this);this.complete=this.tryComplete,r.complete=r.tryComplete,r.subscribe(this.makeSource(e,this.index++))}tryComplete(){this.currentSink.resetComplete(),this.dispose()}},oV=class extends rV{},nV=class extends iV{next(e){this.subInner(e,oV),this.next=e=>{this.currentSink.dispose(),this.subInner(e,oV)}}},aV=Ox(nV,"switchMap");function sV(e){return(t,r)=>e((()=>t),r)}var cV=sV(Ox(nV,"switchMapTo")),lV=class extends rV{tryComplete(){this.dispose(),this.context.sources.length?this.context.subNext():(this.context.resetNext(),this.context.resetComplete())}},uV=class extends iV{constructor(){super(...arguments),this.sources=[],this.next2=this.sources.push.bind(this.sources)}next(e){this.next2(e),this.subNext()}subNext(){this.next=this.next2,this.subInner(this.sources.shift(),lV),this.disposed&&0===this.sources.length&&this.currentSink.resetComplete()}tryComplete(){0===this.sources.length&&this.currentSink.resetComplete(),this.dispose()}},dV=Ox(uV,"concatMap"),hV=sV(Ox(uV,"concatMapTo")),pV=class extends rV{tryComplete(){this.context.inners.delete(this),super.dispose(),0===this.context.inners.size&&this.context.resetComplete()}},mV=class extends iV{constructor(){super(...arguments),this.inners=new Set}next(e){this.subInner(e,pV),this.inners.add(this.currentSink)}tryComplete(){1===this.inners.size?this.inners.forEach((e=>e.resetComplete())):this.dispose()}},fV=Ox(mV,"mergeMap"),_V=sV(Ox(mV,"mergeMapTo")),gV=class extends rV{dispose(){this.context.resetNext(),super.dispose()}},EV=class extends iV{next(e){this.next=yx,this.subInner(e,gV)}},vV=Ox(EV,"exhaustMap"),yV=sV(Ox(EV,"exhaustMapTo")),TV=Ox(class extends Dx{constructor(e,t){super(e),this.f=t,this.groups=new Map}next(e){let t=this.f(e),r=this.groups.get(t);void 0===r&&(r=$x(),r.key=t,this.groups.set(t,r),super.next(r)),r.next(e)}complete(){this.groups.forEach((e=>e.complete())),super.complete()}error(e){this.groups.forEach((t=>t.error(e))),super.error(e)}},"groupBy"),IV=Ox(class extends Dx{constructor(){super(...arguments),this.start=new Date}next(e){this.sink.next({value:e,interval:Number(new Date)-Number(this.start)}),this.start=new Date}},"timeInterval"),AV=Ox(class extends Dx{constructor(e,t){super(e),this.miniseconds=t,this.buffer=[],this.id=setInterval((()=>{this.sink.next(this.buffer.concat()),this.buffer.length=0}),this.miniseconds)}next(e){this.buffer.push(e)}complete(){this.sink.next(this.buffer),super.complete()}dispose(){clearInterval(this.id),super.dispose()}},"bufferTime"),SV=Ox(class extends Dx{constructor(e,t){super(e),this.buffer=[],this.delayTime=t}dispose(){clearTimeout(this.timeoutId),super.dispose()}delay(e){this.timeoutId=setTimeout((()=>{let e=this.buffer.shift();if(e){let{time:t,data:r}=e;super.next(r),this.buffer.length&&this.delay(Number(this.buffer[0].time)-Number(t))}}),e)}next(e){this.buffer.length||this.delay(this.delayTime),this.buffer.push({time:new Date,data:e})}complete(){this.timeoutId=setTimeout((()=>super.complete()),this.delayTime)}},"delay"),RV=Ox(class extends Dx{constructor(e,t){super(e),this.selector=t}error(e){this.dispose(),this.selector(e)(this.sink)}},"catchError"),bV=()=>e=>new Promise(((t,r)=>{let i;new Cx(e,(e=>i=e),r,(()=>t(i)))})),wV=()=>e=>{let t;return new ReadableStream({start(r){t=new Cx(e,r.enqueue.bind(r),r.error.bind(r),r.close.bind(r))},cancel(){t.dispose()}})},DV=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:yx,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yx,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yx;return i=>new Cx(i,e,t,r)},CV=Ox(class extends Dx{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"),NV=Ox(class extends Dx{constructor(e,t){super(e),this.timeout=t,this.id=setTimeout((()=>this.error(new xx(this.timeout))),this.timeout)}next(e){super.next(e),clearTimeout(this.id),this.next=super.next}dispose(){clearTimeout(this.id),super.dispose()}},"timeout"),kV=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1/0;return t=>{if(t instanceof bx){let r=kx((i=>{let o=e,n=new Dx(i);n.error=e=>{o-- >0?n.subscribe(t):i.error(e)},n.sourceId=r.id,n.subscribe(t)}),"retry",[e]);return r.source=t,Px.pipe(r),r}return r=>{let i=e,o=new Dx(r);o.error=e=>{i-- >0?t(o):r.error(e)},t(o)}}},OV=class e extends BP{constructor(t,r,i){super({userId:r.userId,sdkAppId:t.sdkAppId,mediaType:i,room:t}),this.room=t,this.user=r,Bb(this,"tinyId"),Bb(this,"isRemote",!0),Bb(this,"jitterBufferDelay",0),Bb(this,"availableState"),Bb(this,"remotePublishState"),Bb(this,"_triggerCheckDecodeSubject",$x(sU(this,e.STATE_SUBSCRIBE))),this.tinyId=r.tinyId,this.availableState=new EL("".concat(r.userId,"-").concat(this.mediaType,"-available"),"remote-track-available"),this.remotePublishState=new EL("".concat(r.userId,"-").concat(this.mediaType,"-remote-publish"),"remote-track-publish"),Nx(Fx(sU(this,EL.STATECHANGED),sU(this.remotePublishState,EL.STATECHANGED)),eV((()=>this.isRemotePublished&&(this.isSubscribed||this.isSubscribing))),DV((e=>{this.availableState.state!==(e?EL.ON:EL.OFF)&&(this.availableState.state=e?EL.ON:EL.OFF),this.updatePlayingState(e)})));let o=Nx(sU(this.player,RL.ERROR),bU((e=>e.code===MediaError.MEDIA_ERR_DECODE))),n=Nx(oU(5e3),bU((()=>!(this.ignoreDecodeError||!this.isSubscribed||!this.isPlayCalled||!this.stat.bytesReceived)&&(!this.player.isPlaying&&!(this.kind===Pw.AUDIO?this.getAudioLevel()>0:this.stat.framesDecoded>0)||(this.reportDecodeResult(!0),!1))))),a=Nx(Bx(o,n),CU(sU(this,EL.INIT)));Nx(this._triggerCheckDecodeSubject,bU((()=>!this.ignoreDecodeError)),cV(a),DV((e=>{this.reportDecodeResult(!1,e)})))}setMute(e){this.isRemotePublished&&super.setMute(e)}setInputMediaStreamTrack(e){super.setInputMediaStreamTrack(e),this.isRemotePublished&&this.isSubscribed&&this.player.setTrack(this.outMediaTrack)}checkDecodeResult(){this._triggerCheckDecodeSubject.next(!0)}waitHasMediaTrack(){return new Promise((e=>{this.mediaTrack?e():this.once("input-media-track-changed",e)}))}get ignoreDecodeError(){var e,t;return((null==(t=null==(e=this.room)?void 0:e.networkQuality)?void 0:t.downlinkNetworkQuality)||0)>3||this.player.isInAutoPlayFailedState}get isSubscribing(){return"subscribeing"===this.state.toString()}get isSubscribed(){return this.state===e.STATE_SUBSCRIBE}get isAvailable(){return this.availableState.state===EL.ON}get isNeedPlay(){return this.isAvailable&&this.isPlayCalled}subscribe(e){return e}unsubscribe(){this.player.setTrack(null),"main"===this.streamType&&"video"===this.kind&&this.room.changeType(!1,this.user)}reportDecodeResult(e,t){let r=this.kind===Pw.AUDIO;mM[e?"addSuccessEvent":"addFailedEvent"]({key:r?504700:514702}),e||(mM.addEnum({key:r?504701:514703,value:Fk()}),NL.uploadEvent({log:"stat-decode-failed-".concat(this.kind,"-").concat(xk()||Bk()),userId:this.room.userId}),this._log.warn("decode failed: isPlaying: ".concat(this.player.isPlaying," ").concat(this.kind===Pw.AUDIO?"audioLevel: ".concat(this.getAudioLevel()):"framesDecoded: ".concat(this.stat.framesDecoded>0))),this.emit("decode-failed",{error:t}))}updatePlayingState(e){if(this.isPlayCalled&&this.player.isStopped===e){if(e&&(!this.isSubscribed||!this.isRemotePublished||!this.outMediaTrack))return void this.log.info("abort play, isSubscribed: ".concat(this.isSubscribed," isAvailable: ").concat(this.isRemotePublished," hasTrack: ").concat(!!this.outMediaTrack," "));super.updatePlayingState(e)}}close(){super.close(),this.outMediaTrack&&this.uninstallTrackEvent(this.outMediaTrack)}onFlagChanged(){this.remotePublishState.state=this.isRemotePublished?EL.ON:EL.OFF}onTrackMuted(){this.isNeedPlay&&super.onTrackMuted()}onTrackUnmuted(){this.isNeedPlay&&super.onTrackUnmuted()}onTrackEnded(){this.isNeedPlay&&super.onTrackEnded()}};Bb(OV,"STATE_SUBSCRIBE","subscribe"),Fb([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 JP(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return new Promise(((o,a)=>{let s=setTimeout((()=>{let r=new $b({code:Jb.API_CALL_TIMEOUT,message:"checkPendingPromise ".concat(i,"() timeout ").concat(e,"s")});Yk.warn(r),2===t?a(r):1===t&&o()}),1e3*e);r.apply(this,n).then(o,a).finally((()=>{clearTimeout(s)}))}))}))}(5,1)],OV.prototype,"waitHasMediaTrack",1),Fb([fL(EL.INIT,OV.STATE_SUBSCRIBE,{success(){this.log.info("subscribed"),Gk.emit(zk.REMOTE_TRACK_SUBSCRIBED,{track:this})},ignoreError:!0}),ix(521716,!1)],OV.prototype,"subscribe",1),Fb([fL(OV.STATE_SUBSCRIBE,EL.INIT,{sync:!0,success(){this.log.info("unsubscribed"),Gk.emit(zk.REMOTE_TRACK_UNSUBSCRIBED,{track:this})}})],OV.prototype,"unsubscribe",1);var MV=OV,LV=class extends MV{constructor(e,t){super(e,t,1),Bb(this,"volume",0),Bb(this,"mediaType",1),Bb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.audioManager}get dbVolume(){return TP.isRunning?this.player.pipeline.volumeMeter.getVolumeDb():Math.floor(Math.max(10*Math.log10(this.volume)+100,0))}decodeFrame(e){if(!this.manager)return e;let t=e;for(let r of this.manager.decodePipeline)if(r&&(t=r({frame:t,track:this}),!t))return;return t}getAudioLevel(){let e=this.volume||super.getAudioLevel();return e>1?1:e}get isRemotePublished(){return this.user.muteState.audioAvailable}},PV=[-1,-1,1,-1,-1,1,1,1],xV=[0,0,1,0,0,1,1,1],UV=class extends EL{constructor(e,t){if(super(),this.context=e,Bb(this,"name"),Bb(this,"input"),Bb(this,"output"),Bb(this,"texture"),Bb(this,"ctx2d",null),Bb(this,"fbo"),Bb(this,"width",0),Bb(this,"height",0),Bb(this,"x",0),Bb(this,"y",0),Bb(this,"program"),Bb(this,"vertexShader"),Bb(this,"fragmentShader"),Bb(this,"totalFrames",0),Bb(this,"dropFrames",0),Bb(this,"matchInputSize",!0),Bb(this,"texCoordBuffer"),Bb(this,"positionBuffer"),Bb(this,"lastInfo",{name:"",timestamp:0,totalFrames:0,x:0,y:0,width:0,height:0,fps:0}),Bb(this,"cost",0),Bb(this,"_canvas",null),Bb(this,"_image"),Bb(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 QV)e.ctx&&t.create2d&&("function"==typeof OffscreenCanvas&&16!==Tk?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(xV),this.positionBuffer=this.createBuffer(PV),!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.PACK_ALIGNMENT,1),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(iO){this.context.destroy(new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(iO.message||iO)}))}}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 $V&&this.render(e)||this.context instanceof QV&&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 $V){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(e,t,r,i,o){return!(!this.ctx2d||!e)&&(e instanceof ImageData?this.ctx2d.putImageData(e,t,r):(this.ctx2d.drawImage(e,t,r,i,o),"undefined"!=typeof VideoFrame&&e instanceof VideoFrame&&e.close()),!0)}getInfo(){var e;let{totalFrames:t,x:r,y:i,width:o,height:n,name:a,cost:s}=this,c=Date.now(),l=(t-this.lastInfo.totalFrames)/((c-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:t,x:r,y:i,width:o,height:n,timestamp:c,fps:l,name:a,cost:s},Lb({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.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,e),r}};Fb([fL(EL.INIT,"connected",{sync:!0})],UV.prototype,"connect",1),Fb([fL("connected",EL.INIT,{ignoreError:!0,sync:!0})],UV.prototype,"disconnect",1),Fb([fL([],"closed",{sync:!0})],UV.prototype,"close",1);var VV=Nx(iU(250),eV((()=>performance.now())),Vx()),FV=e=>t=>{let r=performance.now();Nx(VV,LU((t=>t-r<e)),DU(1))(t)},BV=[0,1,1,1,0,0,1,0],HV=class extends UV{constructor(e,t){super(e,Object.assign({useDefaultProgram:!0,createTexture:!1,name:"destination"},t)),Bb(this,"_intervalId",0),Bb(this,"_sequence",0),Bb(this,"checkGLError",!1),Bb(this,"checkVisibilityChange"),e instanceof QV?this.ctx2d=e.ctx||null:e.available&&null!=t&&t.mirrorUpAndDown&&this.setTexBuffer(BV)}start(e){this.log.info("".concat(this.name," start render ").concat(e," fps")),SL.clearTask(this._intervalId),this._intervalId=SL.run("intervalInWorker",(()=>{if(e!==this.context.frameRate&&(SL.clearTask(this._intervalId),this.start(this.context.frameRate)),this.requestFrame(this._sequence++),this.checkGLError&&this.context instanceof $V){let e=this.context.ctx.getError();e&&this.context.destroy(new $b({code:Jb.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(),!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;if(this._intervalId&&(SL.clearTask(this._intervalId),this._intervalId=0,1===e)){this.log.info("".concat(this.name," use requestVideoFrameCallback"));let e=()=>{document.hidden&&(this.start(this.context.frameRate),this.log.info("".concat(this.name," use timer")),document.removeEventListener("visibilitychange",e))};document.addEventListener("visibilitychange",e)}this.requestFrame(this._sequence++)}removeInput(e){super.removeInput(e),SL.clearTask(this._intervalId)}resize(e,t){super.resize(e,t),this.context.setSize(e,t)}close(){super.close(),SL.clearTask(this._intervalId),document.removeEventListener("visibilitychange",this.checkVisibilityChange)}},WV=class extends HV{constructor(e,t){super(e,t),Bb(this,"_videoTrack"),Bb(this,"_muteOb"),Bb(this,"_closedOb",sU(this,"closed")),Bb(this,"_subscription"),Bb(this,"_canvasContainer"),Number(gk)<17&&(this._canvasContainer=document.createElement("div"),this._canvasContainer.style.display="none"),[this._videoTrack]=e._canvas.captureStream().getVideoTracks(),this._muteOb=sU(this._videoTrack,"mute"),Nx(sU(this._videoTrack,"ended"),CU(this._closedOb),DV((()=>{this.context.destroy(new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:8,message:"video track ended"}))})))}enableCheckMute(){this._subscription=Nx(this._muteOb,CU(this._closedOb),cV(FV(5e3)),bU((()=>{var e;return!(null==(e=this._videoTrack)||!e.muted||document.hidden)})),DV((()=>{this.context.destroy(new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:7,message:"video track muted"}))})))}disableCheckMute(){var e;null==(e=this._subscription)||e.dispose()}get videoTrack(){return this._videoTrack}putCanvasIntoDom(){!this.context._canvas||!this._canvasContainer||document.getElementById(this.context._canvas.id)||(this.log.info("".concat(this.name," put canvas to body")),document.body.appendChild(this._canvasContainer),this._canvasContainer.appendChild(this.context._canvas))}render(e){return this.putCanvasIntoDom(),super.render(e)}render2d(e){return this.putCanvasIntoDom(),super.render2d(e)}close(){var e,t;super.close(),null==(e=this._videoTrack)||e.stop(),delete this._videoTrack,null==(t=this._canvasContainer)||t.remove()}},jV=class extends WV{render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))}},GV=class extends WV{constructor(e,t,r){super(e,{name:"smallDestination",logger:r}),this.resolution=t}resize(e,t){let r,i=e*t,o=this.resolution.width*this.resolution.height;this.log.info("big res: ".concat(e,"*").concat(t," small res: ").concat(this.resolution.width,"*").concat(this.resolution.height," ")),i>o?r=i/o:(this.log.warn("Small stream resolution is not smaller than big stream, which is invalid. big: ".concat(e," * ").concat(t," small: ").concat(this.resolution.width," * ").concat(this.resolution.height)),r=i/19200),super.resize(e/Math.sqrt(r),t/Math.sqrt(r))}},KV=class extends UV{constructor(e,t){super(e,Lb({name:"imageSource"},t)),Bb(this,"_lastImage"),Bb(this,"_totalFrames",0),Bb(this,"_autoResize",!1),Bb(this,"_canvasRendered"),Bb(this,"_videoCallbackId",0),Bb(this,"waitingFirstFrame",!0),Bb(this,"shouldUpdate",!0),this._autoResize=!1!==(null==t?void 0:t.autoResize),16===Tk&&(this._canvasRendered=$x(),Nx(this._canvasRendered,zx(this._image),aV((e=>e instanceof HTMLCanvasElement?sU(e,"rendered"):vU())),CU(sU(this,"closed")),DV((()=>{this.update()}))))}onFirstFrame(){this.waitingFirstFrame=!1}tryVideoFrameCallback(){let e=this.image;this._videoCallbackId&&e.cancelVideoFrameCallback(this._videoCallbackId),sL()&&!document.hidden&&(this._videoCallbackId=e.requestVideoFrameCallback(((e,t)=>{this.waitingFirstFrame&&this.onFirstFrame(),document.hidden||(this._totalFrames=t.presentedFrames,this.update(1))})))}_render(e,t){var r;let{width:i,height:o}=this,{image:n}=this;if(n instanceof HTMLVideoElement){if(this.shouldUpdate&&this.tryVideoFrameCallback(),({videoWidth:i,videoHeight:o}=n),!i||!o)return!1;n.width=i,n.height=o}else if(n instanceof HTMLImageElement||n instanceof ImageData||n instanceof ImageBitmap){if(({width:i,height:o}=n),n!==this._lastImage)this._lastImage=n;else if(i===this.width&&o===this.height)return!1}else n instanceof HTMLCanvasElement||n instanceof OffscreenCanvas?(({width:i,height:o}=n),this._lastImage=n):"undefined"!=typeof VideoFrame&&n instanceof VideoFrame&&(({displayWidth:i,displayHeight:o}=n),null==(r=this._lastImage)||r.close(),this._lastImage=n);if(!this._autoResize)return!0;if(this.width===i&&this.height===o&&this.totalFrames){if(t){this.useTexture();let e=this.context.ctx;e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n)}}else{if(t){this.useTexture();let e=this.context.ctx;e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)}this.resize(i,o)}return!0}get image(){return this._image}set image(e){var t;null==(t=this._canvasRendered)||t.next(e),this._image=e}render(e){return this._render(e,!0)}render2d(e){return this._render(e,!1)}},zV=class extends KV{constructor(e,t,r){super(e,r),this._player=t,this.name="videoPlayerSource",Nx(sU(this._player,RL.PLAYER_STATE_CHANGED),CU(sU(this,"closed")),bU((e=>{let{state:t}=e;return"PLAYING"===t})),DV((()=>{this.tryVideoFrameCallback()})))}get image(){return this._player.element}},qV=class extends zV{get available(){return this._player.isPlaying&&!this.waitingFirstFrame}constructor(e,t,r){super(e,new rP({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()}},YV=class extends EL{constructor(e){super(),Bb(this,"frameRate"),Bb(this,"_canvas"),Bb(this,"log"),Bb(this,"hasAlpha",!1),Bb(this,"name"),Bb(this,"error"),this.name=e.name,this.log=e.logger.createChild({id:"vc-".concat(this.name)}),this.frameRate=e.frameRate}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 qV(this,e,{logger:this.log,name:t})}createVideoTrackDestination(e){return new WV(this,e)}createVideoImageSource(e,t){return new KV(this,t?Object.assign(t,{logger:this.log,image:e}):{logger:this.log,image:e})}createVideoPlayerSource(e,t){return new zV(this,e,t?Object.assign(t,{logger:this.log}):{logger:this.log})}get available(){return"created"===this.state}disconnect(){this.emit("disconnect")}};Bb(YV,"_ids",0);var JV={alpha:!0,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0,powerPreference:"low-power"},XV=class extends YV{constructor(){super(...arguments),Bb(this,"defaultProgam"),Bb(this,"defaultVShader"),Bb(this,"defaultFShader"),Bb(this,"ctx")}create(){if(this._canvas||(this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(YV._ids++)),this.ctx=this._canvas.getContext("webgl2",JV),!this.ctx)throw new $b({code:Jb.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 $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:4,message:"webgl context lost"}))}))}destroy(e){let t="";return e&&(t=e.message,this.error=e,mM.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}set height(e){var t;null==(t=this.ctx)||t.viewport(0,0,this.width,e),super.height=e}setSize(e,t){var r;null==(r=this.ctx)||r.viewport(0,0,e,t),super.setSize(e,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}};Bb(XV,"UNAVAILABLE","unavailable"),Fb([fL(EL.INIT,"created",{sync:!0,fail(e){this.log.error("video gl context create failed",e.cause),mM.addFailedEvent({key:512700,error:e.cause||e})},success(){this.log.info("video context created use webgl"),mM.addSuccessEvent({key:512700})}})],XV.prototype,"create",1),Fb([fL("created",EL.INIT,{ignoreError:!0,sync:!0,success(e){e&&this.emit(XV.UNAVAILABLE,e),this.removeAllListeners()}})],XV.prototype,"destroy",1);var $V=XV,QV=class extends YV{constructor(){super(...arguments),Bb(this,"ctx")}create(e){if(this.hasAlpha=e.alpha,this._canvas=document.createElement("canvas"),this._canvas.id="trtc_".concat(this.name,"_").concat(YV._ids++),this.ctx=this._canvas.getContext("2d",{alpha:e.alpha}),!this.ctx)throw new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:2,message:"2d context not supported"});this._canvas.addEventListener("contextlost",(()=>{this.log.error("2d context lost")})),this._canvas.addEventListener("contextrestored",(()=>{this.log.warn("2d context restored")}))}destroy(e){let t="";e&&(t=e.message,this.error=e,mM.addFailedEvent({key:512703,error:e})),this.disconnect(),this.log.info("video context destroy ".concat(t?": ".concat(t):"")),delete this.ctx,this._canvas&&(this._canvas.remove(),this._canvas.width=0,this._canvas.height=0,delete this._canvas),this.removeAllListeners(),mM.addSuccessEvent({key:512703})}};Fb([fL(EL.INIT,"created",{sync:!0,fail(e){this.log.error("video 2d context create failed",e.cause),mM.addFailedEvent({key:512701,error:e.cause||e})},success(){this.log.info("video context created use 2d"),mM.addSuccessEvent({key:512701})}})],QV.prototype,"create",1),Fb([fL("created",EL.INIT,{ignoreError:!0,sync:!0})],QV.prototype,"destroy",1);var ZV=class extends MV{constructor(e,t){super(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:4),Bb(this,"mediaType",4),Bb(this,"source"),Bb(this,"stat",{bytesReceived:0,packetsReceived:0,packetsLost:0,framesReceived:0,framesDecoded:0,frameWidth:0,frameHeight:0,end2EndDelay:0,jitterBufferDelay:0}),this.manager=e.videoManager,this.once("first-video-frame",(e=>{this.room.emit("first-video-frame",e)}))}play(e,t){return(aC(null==t?void 0:t.canvasRender)?t.canvasRender:17===Tk)&&!this.source&&this.useCanvasPlayer(),super.play(e,t).then((()=>{this.player.calculateStat()}))}useCanvasPlayer(){if(this.log.info("useCanvasPlayer(), has element:".concat(!!this.player.element)),!this.player.element)return;let e=new QV({frameRate:15,logger:this.log,name:this.userId});e.create({alpha:!1});let t=new HV(e,{name:"remotePlayer",logger:this.log});this.source=e.createVideoPlayerSource(this.player),this.source.connect(t),this.player.setCanvas(e._canvas),sL()||(this.updateCanvasPlayerFPS=this.updateCanvasPlayerFPS.bind(this,e),this.room.on("heartbeat-report",this.updateCanvasPlayerFPS,this))}updateCanvasPlayerFPS(e){let t=this.decodeFPS,r=(i=t,[15,30,45,60].reduce(((e,t)=>Math.abs(t-i)<Math.abs(e-i)?t:e)));var i;!nC(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),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)}onDecodeDowngradeStateChanged(e){this.emit("decode-downgrade-state-changed",e)}},eF=class extends ZV{constructor(e,t){super(e,t,2),Bb(this,"mediaType",2),Bb(this,"objectFit","contain")}get isRemotePublished(){return this.user.muteState.hasAuxiliary}},tF=new Map;function rF(e,t){let r=Pb(Lb({},t),{timestamp:Qb()});tF.has(e)?tF.get(e).push(r):tF.set(e,[r])}function iF(e){if(tF.has(e)){let t=tF.get(e).map((e=>({uint32_event_id:e.eventId,uint64_date:e.timestamp,str_userid:e.remoteUserId,uint32_param1:e.param1,uint32_param2:e.param2,uint32_video_stream_type:e.streamType})));return tF.delete(e),t}return[]}function oF(e,t,r,i){try{if(cC(e))for(let o=0;o<e.length;o++)nF.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else nF.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}catch(iO){throw Yk.error(iO),iO}}function nF(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;if(iC(r)){if(t.required)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_REQUIRED,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(iC(t.defaultValue))return;r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),rC(t.type[i])&&r instanceof t.type[i]&&(e=!0),oC(t.type[i])&&tC(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_TYPE,data:{key:i,rule:{type:t.type.map((e=>hC(e)?pC(e):oC(e)?e:tC(e)))},fnName:o,value:r},link:{className:n,fnName:o}})})}else if(!iC(t.type)&&tC(r)!==t.type)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_TYPE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!1===t.allowEmpty){let e=nC(r)&&(0===r||Number.isNaN(r)),a=oC(r)&&""===r.trim();if(e||a)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_EMPTY,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}if(t.notLessThanZero&&nC(r)&&r<0)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.CANNOT_LESS_THAN_ZERO,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!iC(t.min)&&nC(r)&&r<t.min)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_MIN,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(!iC(t.max)&&nC(r)&&r>t.max)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_MAX,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(oC(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})})}else if(rC(t.instanceOf)&&!(r instanceof t.instanceOf))throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_INSTANCE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});if(t.values&&!t.values.includes(r))throw new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.INVALID_PARAMETER_RANGE,data:{key:i,rule:t,fnName:o,value:r},link:{className:n,fnName:o}})});let{properties:a}=t;QD(a)&&sC(r)&&Object.keys(a).forEach((e=>{nF.call(this,{rule:a[e],value:r&&r[e],key:"".concat(i,".").concat(e),fnName:o,className:n})}));let{arrayItem:s}=t;QD(s)&&cC(r)&&r.forEach(((e,t)=>{nF.call(this,{rule:s,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),rC(t.validate)&&t.validate.call(this,r,i,o,n,this)}Gk.on(zk.JOIN_SUCCESS,(e=>{let{room:t}=e;rF(t.userId,{eventId:32788})})),Gk.on(zk.LEAVE_START,(e=>{let{room:t}=e;rF(t.userId,{eventId:32789})})),Gk.on(zk.LOCAL_TRACK_PUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32769;4===t.mediaType?e=32768:2===t.mediaType&&(e=32805),rF(t.room.userId,{eventId:e})}})),Gk.on(zk.LOCAL_TRACK_UNPUBLISHED,(e=>{let{track:t}=e;if(t.room){let e=32771;4===t.mediaType?e=32770:2===t.mediaType&&(e=32806),rF(t.room.userId,{eventId:e})}})),Gk.on(zk.TRACK_MUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Pw.AUDIO?rF(t.room.userId,{eventId:t.isRemote?32785:32772,remoteUserId:t.isRemote?t.userId:void 0}):rF(t.room.userId,{eventId:t.isRemote?32784:32773,remoteUserId:t.isRemote?t.userId:void 0}))})),Gk.on(zk.TRACK_UNMUTED,(e=>{let{track:t}=e;t.room&&(t.kind===Pw.AUDIO?rF(t.room.userId,{eventId:t.isRemote?32787:32774,remoteUserId:t.isRemote?t.userId:void 0}):rF(t.room.userId,{eventId:t.isRemote?32786:32775,remoteUserId:t.isRemote?t.userId:void 0}))})),Gk.on(zk.REMOTE_TRACK_SUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&rF(t.room.userId,{eventId:32777,remoteUserId:t.userId}),4===t.mediaType&&rF(t.room.userId,{eventId:32776,remoteUserId:t.userId}),8===t.mediaType&&rF(t.room.userId,{eventId:32803,remoteUserId:t.userId}))})),Gk.on(zk.REMOTE_TRACK_UNSUBSCRIBED,(e=>{let{track:t}=e;t.room&&(1===t.mediaType&&rF(t.room.userId,{eventId:32779,remoteUserId:t.userId}),4===t.mediaType&&rF(t.room.userId,{eventId:32778,remoteUserId:t.userId}),8===t.mediaType&&rF(t.room.userId,{eventId:32804,remoteUserId:t.userId}))})),Gk.on(zk.SWITCH_DEVICE_SUCCESS,(e=>{let{track:t}=e;t.room&&rF(t.room.userId,{eventId:t.kind===Pw.VIDEO?32780:32781})})),Gk.on(zk.LOCAL_TRACK_REPLACED,(e=>{let{track:t}=e;t.room&&rF(t.room.userId,{eventId:t.kind===Pw.VIDEO?32782:32783})})),Gk.on(zk.SIGNAL_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o}=e;switch(o){case"CONNECTED":t="RECONNECTING"===i?32795:32791;break;case"DISCONNECTED":t="RECONNECTING"===i?32796:32790;break;case"RECONNECTING":t=32794}t&&rF(r.userId,{eventId:t})})),Gk.on(zk.PEER_CONNECTION_STATE_CHANGED,(e=>{let t,{room:r,prevState:i,state:o,remoteUserId:n}=e,a=!!n;switch(o){case"CONNECTED":t="RECONNECTING"===i?a?32801:32798:a?32793:32792;break;case"DISCONNECTED":"RECONNECTING"===i&&(t=a?32802:32799);break;case"RECONNECTING":t=a?32800:32797}t&&rF(r.userId,{eventId:t,remoteUserId:n})})),Gk.on(zk.VIDEO_CODEC_IMPLEMENTATION_CHANGED,(e=>{let{implementation:t,userId:r,remoteUserId:i,codec:o,isHWCodec:n,prevImplementation:a,streamType:s}=e,c=n?1:0;a||(c=n?3:2);let l="h264"===o?0:2,u={eventId:4004,param1:c,param2:l,streamType:s||2};i&&(u.remoteUserId=i,u.eventId=4005),rF(r,u),mM.addEnum({key:i?514701:513701,value:c}),mM.addEnum({key:i?514700:513700,value:l})})),Gk.on(zk.LOCAL_TRACK_RECAPTURE,(e=>{let{track:t,error:r}=e;if(t.userId){let e={eventId:2003,param1:0};t.kind===Pw.AUDIO?(e.streamType=1,r&&(e.param1=2)):(e.streamType="auxiliary"===t.streamType?7:2,r&&(e.param1=8)),rF(t.userId,e)}})),Vb(jb(),1);var aF=Object.create,sF=Object.defineProperty,cF=Object.defineProperties,lF=Object.getOwnPropertyDescriptor,uF=Object.getOwnPropertyDescriptors,dF=Object.getOwnPropertyNames,hF=Object.getOwnPropertySymbols,pF=Object.getPrototypeOf,mF=Object.prototype.hasOwnProperty,fF=Object.prototype.propertyIsEnumerable,_F=(e,t,r)=>t in e?sF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gF=(e,t)=>{for(var r in t||(t={}))mF.call(t,r)&&_F(e,r,t[r]);if(hF)for(var r of hF(t))fF.call(t,r)&&_F(e,r,t[r]);return e},EF=(e,t)=>cF(e,uF(t)),vF=(e,t,r,i)=>{for(var o,n=i>1?void 0:i?lF(t,r):t,a=e.length-1;a>=0;a--)(o=e[a])&&(n=(i?o(t,r,n):o(n))||n);return i&&n&&sF(t,r,n),n},yF=(e,t,r)=>_F(e,"symbol"!=typeof t?t+"":t,r),TF=((e,t)=>function(){return t||(0,e[dF(e)[0]])((t={exports:{}}).exports,t),t.exports})({"../node_modules/.pnpm/eventemitter3@4.0.7/node_modules/eventemitter3/index.js"(e,t){var r=Object.prototype.hasOwnProperty,i="~";function o(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function a(e,t,r,o,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var s=new n(r,o||e,a),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 o:delete e._events[t]}function c(){this._events=new o,this._eventsCount=0}Object.create&&(o.prototype=Object.create(null),(new o).__proto__||(i=!1)),c.prototype.eventNames=function(){var e,t,o=[];if(0===this._eventsCount)return o;for(t in e=this._events)r.call(e,t)&&o.push(i?t.slice(1):t);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},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 o=0,n=r.length,a=new Array(n);o<n;o++)a[o]=r[o].fn;return a},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,o,n,a){var s=i?i+e:e;if(!this._events[s])return!1;var c,l,u=this._events[s],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,n),!0;case 6:return u.fn.call(u.context,t,r,o,n,a),!0}for(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,o);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}return!0},c.prototype.on=function(e,t,r){return a(this,e,t,r,!1)},c.prototype.once=function(e,t,r){return a(this,e,t,r,!0)},c.prototype.removeListener=function(e,t,r,o){var n=i?i+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var a=this._events[n];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,n);else{for(var c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||o&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[n]=1===l.length?l[0]:l:s(this,n)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&s(this,t)):(this._events=new o,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=i,c.EventEmitter=c,void 0!==t&&(t.exports=c)}}),IF=((e,t,r)=>(r=null!=e?aF(pF(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of dF(t))mF.call(e,o)||o===r||sF(e,o,{get:()=>t[o],enumerable:!(i=lF(t,o))||i.enumerable});return e})(!t&&e&&e.__esModule?r:sF(r,"default",{value:e,enumerable:!0}),e)))(TF(),1),AF=Symbol("instance"),SF=Symbol("cacheResult"),RF=class{constructor(e,t,r){this.oldState=e,this.newState=t,this.action=r,this.aborted=!1}abort(e){this.aborted=!0,NF.call(e,this.oldState,new Error("action '".concat(this.action,"' aborted")))}toString(){return"".concat(this.action,"ing")}},bF=class extends Error{constructor(e,t,r){super(t),this.state=e,this.message=t,this.cause=r}};var wF=new Map;function DF(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return(i,o,n)=>{let a=r.action||o;if(!r.context){let r=wF.get(i)||[];wF.has(i)||wF.set(i,r),r.push({from:e,to:t,action:a})}let s=n.value;n.value=function(){let i=this;for(var o=arguments.length,n=new Array(o),c=0;c<o;c++)n[c]=arguments[c];if(r.context&&(i=kF.get("function"==typeof r.context?r.context.call(this,...n):r.context)),i.state===t)return r.sync?i[SF]:Promise.resolve(i[SF]);i.state instanceof RF&&i.state.action==r.abortAction&&i.state.abort(i);let l=null;Array.isArray(e)?0==e.length?i.state instanceof RF&&i.state.abort(i):"string"==typeof i.state&&e.includes(i.state)||(l=new bF(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e.join("|")))):e!==i.state&&(l=new bF(i._state,"".concat(i.name," ").concat(a," to ").concat(t," failed: current state ").concat(i._state," not from ").concat(e)));let u=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 u(l);let d=i.state,h=new RF(d,t,a);NF.call(i,h);let p=e=>{var o;return i[SF]=e,h.aborted||(NF.call(i,t),null===(o=r.success)||void 0===o||o.call(this,i[SF])),e},m=e=>(NF.call(i,d,e),u(e));try{let e=s.apply(this,n);return function(e){return"object"==typeof e&&e&&"then"in e}(e)?e.then(p).catch(m):r.sync?p(e):Promise.resolve(p(e))}catch(sO){return m(new bF(i._state,"".concat(i.name," ").concat(a," from ").concat(e," to ").concat(t," failed: ").concat(sO),sO instanceof Error?sO:new Error(String(sO))))}}}}var CF="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 NF(e,t){let r=this._state;this._state=e;let i=e.toString();e&&this.emit(i,r),this.emit(kF.STATECHANGED,e,r,t),this.updateDevTools({value:e,old:r,err:t instanceof Error?t.message:String(t)})}var kF=class e extends IF.default{constructor(t,r,i){super(),this.name=t,this.groupName=r,this._state=e.INIT,t||(t=Date.now().toString(36)),i?Object.setPrototypeOf(this,i):i=Object.getPrototypeOf(this),r||(this.groupName=this.constructor.name);let o=i[AF];o?this.name=o.name+"-"+o.count++:i[AF]={name:this.name,count:0},this.updateDevTools({diagram:this.stateDiagram})}get stateDiagram(){let e=Object.getPrototypeOf(this),t=wF.get(e)||[],r=new Set,i=[],o=[],n=new Set,a=Object.getPrototypeOf(e);wF.has(a)&&(a.stateDiagram.forEach((e=>r.add(e))),a.allStates.forEach((e=>n.add(e)))),t.forEach((e=>{let{from:t,to:r,action:n}=e;"string"==typeof t?i.push({from:t,to:r,action:n}):t.length?t.forEach((e=>{i.push({from:e,to:r,action:n})})):o.push({to:r,action:n})})),i.forEach((e=>{let{from:t,to:i,action:o}=e;n.add(t),n.add(i),n.add(o+"ing"),r.add("".concat(t," --\x3e ").concat(o,"ing : ").concat(o)),r.add("".concat(o,"ing --\x3e ").concat(i," : ").concat(o," 🟢")),r.add("".concat(o,"ing --\x3e ").concat(t," : ").concat(o," 🔴"))})),o.forEach((e=>{let{to:t,action:i}=e;r.add("".concat(i,"ing --\x3e ").concat(t," : ").concat(i," 🟢")),n.forEach((e=>{e!==t&&r.add("".concat(e," --\x3e ").concat(i,"ing : ").concat(i))}))}));let s=[...r];return Object.defineProperties(e,{stateDiagram:{value:s},allStates:{value:n}}),s}static get(t){let r;return"string"==typeof t?(r=e.instances.get(t),r||e.instances.set(t,r=new e(t,void 0,Object.create(e.prototype)))):(r=e.instances2.get(t),r||e.instances2.set(t,r=new e(t.constructor.name,void 0,Object.create(e.prototype)))),r}static getState(t){var r;return null===(r=e.get(t))||void 0===r?void 0:r.state}updateDevTools(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};CF(e.UPDATEAFSM,Object.assign({name:this.name,group:this.groupName},t))}get state(){return this._state}set state(e){NF.call(this,e)}};kF.STATECHANGED="stateChanged",kF.UPDATEAFSM="updateAFSM",kF.INIT="[*]",kF.ON="on",kF.OFF="off",kF.instances=new Map,kF.instances2=new WeakMap;var OF=class extends kF{constructor(){super(...arguments),yF(this,"decoder"),yF(this,"config")}initialize(){return Wb(this,null,(function*(){this.decoder=new VideoDecoder({output:e=>{this.emit("videoFrame",e)},error:e=>{this.close(),this.emit("error",e)}})}))}configure(e){this.config=e,this.decoder.configure(EF(gF({},e),{codec:this.getCodec(e)}))}getCodec(e){switch(e.codec){case"hevc":return"hvc1.1.6.L0.12.34.56.78.9A.BC";case"av1":return"av01.0.05M.08";case"avc":return"avc1.420028";default:return e.codec}}decode(e){"configured"===this.decoder.state&&this.decoder.decode(new EncodedVideoChunk(e))}flush(){this.decoder.flush()}reset(){this.decoder.reset()}close(){"closed"!==this.decoder.state&&this.decoder.close()}};function MF(){var e;self.onmessage=t=>{if("init"===t.data.type){let{canvas:r,wasmScript:i,wasmBinary:o}=t.data,n=null==r?void 0:r.getContext("2d"),a=0,s=0,c={wasmBinary:o,postRun:()=>{e=new c.VideoDecoder({videoInfo(e,t){a=e,s=t,console.log("video info",e,t)},yuvData(e,t){let i=a*s,o=i>>2,l=c.HEAPU32[e>>2],u=c.HEAPU32[1+(e>>2)],d=c.HEAPU32[2+(e>>2)],h=c.HEAPU8.subarray(l,l+i),p=c.HEAPU8.subarray(u,u+o),m=c.HEAPU8.subarray(d,d+o),f=new Uint8Array(i+o+o);f.set(h),f.set(p,i),f.set(m,i+o);let _=new VideoFrame(f,{codedWidth:a,codedHeight:s,format:"I420",timestamp:t});r?(null==n||n.drawImage(_,0,0,r.width,r.height),null==n||n.commit()):self.postMessage({type:"yuvData",videoFrame:_},[_])}}),self.postMessage({type:"ready"})}};Function("var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;return "+i)()(c)}else if("decode"===t.data.type){let{packet:r}=t.data;null==e||e.decode(r.data,"key"==r.type,r.timestamp)}else if("setCodec"===t.data.type){let{codec:r,format:i,description:o}=t.data;null==e||e.setCodec(r,i,null!=o?o:"")}}}vF([DF([kF.INIT,"closed"],"initialized")],OF.prototype,"initialize",1),vF([DF("initialized","configured",{sync:!0})],OF.prototype,"configure",1),vF([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return(e,r,i)=>{let o=i.value,n=r;i.value=function(){if(!t.includes(this.state.toString()))throw new bF(this.state,"".concat(this.name," ").concat(n," failed: current state ").concat(this.state," not in ").concat(t));for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];return o.apply(this,r)}}}("configured")],OF.prototype,"decode",1),vF([DF([],kF.INIT,{sync:!0})],OF.prototype,"reset",1),vF([DF([],"closed",{ignoreError:!0,sync:!0})],OF.prototype,"close",1);var LF=class extends kF{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4];super(),this.createModule=e,this.wasmBinary=t,this.workerMode=r,this.canvas=i,this.yuvMode=o,yF(this,"worker"),yF(this,"decoder"),yF(this,"config"),yF(this,"module",{}),yF(this,"width",0),yF(this,"height",0)}initialize(e){return Wb(this,null,(function*(){var t;if(this.workerMode){let e=new RegExp("\\{(.+)\\}","s").exec(MF.toString())[1];this.worker=new Worker(URL.createObjectURL(new Blob([e],{type:"text/javascript"})));let r=null==(t=this.canvas)?void 0:t.transferControlToOffscreen(),i=yield this.wasmBinary;return console.warn("worker mode",i),this.worker.postMessage({type:"init",canvas:r,wasmScript:this.createModule.toString(),wasmBinary:i},r?[r,i]:[i]),new Promise((e=>{this.worker.onmessage=t=>{if("ready"===t.data.type)delete this.wasmBinary,e(),console.warn("worker mode initialize success");else if("yuvData"===t.data.type){let{videoFrame:e}=t.data;this.emit("videoFrame",e)}}}))}let r=this.module;return this.wasmBinary&&(r.wasmBinary=yield this.wasmBinary),r.print=e=>console.log(e),r.printErr=e=>console.log("[JS] ERROR: ".concat(e)),r.onAbort=()=>console.log("[JS] FATAL: WASM ABORTED"),new Promise((t=>{r.postRun=e=>{this.decoder=new this.module.VideoDecoder(this),console.log("video soft decoder initialize success"),t()},e&&Object.assign(r,e),this.createModule(r)}))}))}configure(e){var t,r,i;this.config=e;let o=this.config.codec.startsWith("avc")?"avc":"hevc",n=this.config.description?"avc"==o?"avcc":"hvcc":"annexb";null==(r=this.decoder)||r.setCodec(o,n,null!=(t=this.config.description)?t:""),null==(i=this.worker)||i.postMessage({type:"setCodec",codec:o,format:n,description:this.config.description})}decode(e){var t,r;null==(t=this.decoder)||t.decode(e.data,"key"==e.type,e.timestamp),"configured"===this.state&&(null==(r=this.worker)||r.postMessage({type:"decode",packet:e}))}flush(){}reset(){this.config=void 0,this.decoder&&this.decoder.clear()}close(){this.removeAllListeners(),this.decoder&&(this.decoder.clear(),this.decoder.delete())}videoInfo(e,t){this.width=e,this.height=t;let r={width:e,height:t};this.emit("videoCodecInfo",r)}yuvData(e,t){if(!this.module)return;let r=this.width*this.height,i=r>>2,o=this.module.HEAPU32[e>>2],n=this.module.HEAPU32[1+(e>>2)],a=this.module.HEAPU32[2+(e>>2)],s=this.module.HEAPU8.subarray(o,o+r),c=this.module.HEAPU8.subarray(n,n+i),l=this.module.HEAPU8.subarray(a,a+i);if(this.yuvMode)return void this.emit("videoFrame",{y:s,u:c,v:l,timestamp:t});let u=new Uint8Array(r+i+i);u.set(s),u.set(c,r),u.set(l,r+i),this.emit("videoFrame",new VideoFrame(u,{codedWidth:this.width,codedHeight:this.height,format:"I420",timestamp:t}))}errorInfo(e){let t={errMsg:e};this.emit("error",t)}};vF([DF([kF.INIT,"closed"],"initialized")],LF.prototype,"initialize",1),vF([DF("initialized","configured",{sync:!0})],LF.prototype,"configure",1),vF([DF([],kF.INIT,{sync:!0})],LF.prototype,"reset",1),vF([DF([],"closed",{sync:!0})],LF.prototype,"close",1);var PF,xF=(PF="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,i=e;i.ready=new Promise(((e,i)=>{t=e,r=i}));var o,n,a,s=Object.assign({},i),c="./this.program",l="object"==typeof window,u="function"==typeof importScripts,d=("object"==typeof process&&"object"==typeof process.versions&&process.versions.node,"");(l||u)&&(u?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),PF&&(d=PF),d=0!==d.indexOf("blob:")?d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},u&&(a=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),n=(e,t,r)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{200==i.status||0==i.status&&i.response?t(i.response):r()},i.onerror=r,i.send(null)});var h,p,m=i.print||console.log.bind(console),f=i.printErr||console.error.bind(console);Object.assign(i,s),s=null,i.arguments&&i.arguments,i.thisProgram&&(c=i.thisProgram),i.quit&&i.quit,i.wasmBinary&&(h=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&U("no native wasm support detected");var _,g,E,v,y,T,I,A,S,R,b,w,D,C=!1,N=[],k=[],O=[],M=0,L=null;function P(e){M++,i.monitorRunDependencies&&i.monitorRunDependencies(M)}function x(e){if(M--,i.monitorRunDependencies&&i.monitorRunDependencies(M),0==M&&L){var t=L;L=null,t()}}function U(e){i.onAbort&&i.onAbort(e),f(e="Aborted("+e+")"),C=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function V(e){return e.startsWith("data:application/octet-stream;base64,")}function F(e){if(e==R&&h)return new Uint8Array(h);if(a)return a(e);throw"both async and sync fetching of the wasm failed"}function B(e,t,r){return(i=e,h||!l&&!u||"function"!=typeof fetch?Promise.resolve().then((()=>F(i))):fetch(i,{credentials:"same-origin"}).then((e=>{if(!e.ok)throw"failed to load wasm binary file at '"+i+"'";return e.arrayBuffer()})).catch((()=>F(i)))).then((e=>WebAssembly.instantiate(e,t))).then((e=>e)).then(r,(e=>{f("failed to asynchronously prepare wasm: "+e),U(e)}));var i}V(R="videodec.wasm")||(b=R,R=i.locateFile?i.locateFile(b,d):d+b);var H=e=>{for(;e.length>0;)e.shift()(i)};function W(e){this.excPtr=e,this.ptr=e-24,this.set_type=function(e){T[this.ptr+4>>2]=e},this.get_type=function(){return T[this.ptr+4>>2]},this.set_destructor=function(e){T[this.ptr+8>>2]=e},this.get_destructor=function(){return T[this.ptr+8>>2]},this.set_caught=function(e){e=e?1:0,_[this.ptr+12|0]=e},this.get_caught=function(){return 0!=_[this.ptr+12|0]},this.set_rethrown=function(e){e=e?1:0,_[this.ptr+13|0]=e},this.get_rethrown=function(){return 0!=_[this.ptr+13|0]},this.init=function(e,t){this.set_adjusted_ptr(0),this.set_type(e),this.set_destructor(t)},this.set_adjusted_ptr=function(e){T[this.ptr+16>>2]=e},this.get_adjusted_ptr=function(){return T[this.ptr+16>>2]},this.get_exception_ptr=function(){if(Rt(this.get_type()))return T[this.excPtr>>2];var e=this.get_adjusted_ptr();return 0!==e?e:this.excPtr}}var j={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var r=0,i=e.length-1;i>=0;i--){var o=e[i];"."===o?e.splice(i,1):".."===o?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:e=>{var t=j.isAbs(e),r="/"===e.substr(-1);return(e=j.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=j.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=j.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return j.normalize(e.join("/"))},join2:(e,t)=>j.normalize(e+"/"+t)},G=e=>(G=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);U("initRandomDevice")})())(e),K={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:ie.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t=j.isAbs(i)}return(t?"/":"")+(e=j.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=K.resolve(e).substr(1),t=K.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),n=Math.min(i.length,o.length),a=n,s=0;s<n;s++)if(i[s]!==o[s]){a=s;break}var c=[];for(s=a;s<i.length;s++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}},z="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,q=(e,t,r)=>{for(var i=t+r,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.buffer&&z)return z.decode(e.subarray(t,o));for(var n="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var c=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|c:(7&a)<<18|s<<12|c<<6|63&e[t++])<65536)n+=String.fromCharCode(a);else{var l=a-65536;n+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else n+=String.fromCharCode((31&a)<<6|s)}else n+=String.fromCharCode(a)}return n},Y=[],J=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i<=127?t++:i<=2047?t+=2:i>=55296&&i<=57343?(t+=4,++r):t+=3}return t},X=(e,t,r,i)=>{if(!(i>0))return 0;for(var o=r,n=r+i-1,a=0;a<e.length;++a){var s=e.charCodeAt(a);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++a)),s<=127){if(r>=n)break;t[r++]=s}else if(s<=2047){if(r+1>=n)break;t[r++]=192|s>>6,t[r++]=128|63&s}else if(s<=65535){if(r+2>=n)break;t[r++]=224|s>>12,t[r++]=128|s>>6&63,t[r++]=128|63&s}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63,t[r++]=128|s>>6&63,t[r++]=128|63&s}}return t[r]=0,r-o};function $(e,t,r){var i=r>0?r:J(e)+1,o=new Array(i),n=X(e,o,0,o.length);return t&&(o.length=n),o}var Q={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){Q.ttys[e]={input:[],output:[],ops:t},ie.registerDevice(e,Q.stream_ops)},stream_ops:{open:function(e){var t=Q.ttys[e.node.rdev];if(!t)throw new ie.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.get_char)throw new ie.ErrnoError(60);for(var n=0,a=0;a<i;a++){var s;try{s=e.tty.ops.get_char(e.tty)}catch(c){throw new ie.ErrnoError(29)}if(void 0===s&&0===n)throw new ie.ErrnoError(6);if(null==s)break;n++,t[r+a]=s}return n&&(e.node.timestamp=Date.now()),n},write:function(e,t,r,i,o){if(!e.tty||!e.tty.ops.put_char)throw new ie.ErrnoError(60);try{for(var n=0;n<i;n++)e.tty.ops.put_char(e.tty,t[r+n])}catch(a){throw new ie.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),n}},default_tty_ops:{get_char:function(e){return(()=>{if(!Y.length){var e=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(e=window.prompt("Input: "))&&(e+="\n"):"function"==typeof readline&&null!==(e=readline())&&(e+="\n"),!e)return null;Y=$(e,!0)}return Y.shift()})()},put_char:function(e,t){null===t||10===t?(m(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(m(q(e.output,0)),e.output=[])},ioctl_tcgets:function(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets:function(e,t,r){return 0},ioctl_tiocgwinsz:function(e){return[24,80]}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(f(q(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(f(q(e.output,0)),e.output=[])}}},Z=e=>{U()},ee={ops_table:null,mount:e=>ee.createNode(null,"/",16895,0),createNode(e,t,r,i){if(ie.isBlkdev(r)||ie.isFIFO(r))throw new ie.ErrnoError(63);ee.ops_table||(ee.ops_table={dir:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,lookup:ee.node_ops.lookup,mknod:ee.node_ops.mknod,rename:ee.node_ops.rename,unlink:ee.node_ops.unlink,rmdir:ee.node_ops.rmdir,readdir:ee.node_ops.readdir,symlink:ee.node_ops.symlink},stream:{llseek:ee.stream_ops.llseek}},file:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:{llseek:ee.stream_ops.llseek,read:ee.stream_ops.read,write:ee.stream_ops.write,allocate:ee.stream_ops.allocate,mmap:ee.stream_ops.mmap,msync:ee.stream_ops.msync}},link:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,readlink:ee.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:ie.chrdev_stream_ops}});var o=ie.createNode(e,t,r,i);return ie.isDir(o.mode)?(o.node_ops=ee.ops_table.dir.node,o.stream_ops=ee.ops_table.dir.stream,o.contents={}):ie.isFile(o.mode)?(o.node_ops=ee.ops_table.file.node,o.stream_ops=ee.ops_table.file.stream,o.usedBytes=0,o.contents=null):ie.isLink(o.mode)?(o.node_ops=ee.ops_table.link.node,o.stream_ops=ee.ops_table.link.stream):ie.isChrdev(o.mode)&&(o.node_ops=ee.ops_table.chrdev.node,o.stream_ops=ee.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[t]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray:e=>e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0),expandFileStorage(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=ie.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ie.isDir(e.mode)?t.size=4096:ie.isFile(e.mode)?t.size=e.usedBytes:ie.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ee.resizeFileStorage(e,t.size)},lookup(e,t){throw ie.genericErrors[44]},mknod:(e,t,r,i)=>ee.createNode(e,t,r,i),rename(e,t,r){if(ie.isDir(e.mode)){var i;try{i=ie.lookupNode(t,r)}catch(n){}if(i)for(var o in i.contents)throw new ie.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir(e,t){var r=ie.lookupNode(e,t);for(var i in r.contents)throw new ie.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink(e,t,r){var i=ee.createNode(e,t,41471,0);return i.link=r,i},readlink(e){if(!ie.isLink(e.mode))throw new ie.ErrnoError(28);return e.link}},stream_ops:{read(e,t,r,i,o){var n=e.node.contents;if(o>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-o,i);if(a>8&&n.subarray)t.set(n.subarray(o,o+a),r);else for(var s=0;s<a;s++)t[r+s]=n[o+s];return a},write(e,t,r,i,o,n){if(!i)return 0;var a=e.node;if(a.timestamp=Date.now(),t.subarray&&(!a.contents||a.contents.subarray)){if(n)return a.contents=t.subarray(r,r+i),a.usedBytes=i,i;if(0===a.usedBytes&&0===o)return a.contents=t.slice(r,r+i),a.usedBytes=i,i;if(o+i<=a.usedBytes)return a.contents.set(t.subarray(r,r+i),o),i}if(ee.expandFileStorage(a,o+i),a.contents.subarray&&t.subarray)a.contents.set(t.subarray(r,r+i),o);else for(var s=0;s<i;s++)a.contents[o+s]=t[r+s];return a.usedBytes=Math.max(a.usedBytes,o+i),i},llseek(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&ie.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new ie.ErrnoError(28);return i},allocate(e,t,r){ee.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap(e,t,r,i,o){if(!ie.isFile(e.node.mode))throw new ie.ErrnoError(43);var n,a,s=e.node.contents;if(2&o||s.buffer!==_.buffer){if((r>0||r+t<s.length)&&(s=s.subarray?s.subarray(r,r+t):Array.prototype.slice.call(s,r,r+t)),a=!0,!(n=Z()))throw new ie.ErrnoError(48);_.set(s,n)}else a=!1,n=s.byteOffset;return{ptr:n,allocated:a}},msync:(e,t,r,i,o)=>(ee.stream_ops.write(e,t,0,i,r,!1),0)}},te=i.preloadPlugins||[];function re(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r}var ie={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(e=K.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ie.ErrnoError(32);for(var r=e.split("/").filter((e=>!!e)),i=ie.root,o="/",n=0;n<r.length;n++){var a=n===r.length-1;if(a&&t.parent)break;if(i=ie.lookupNode(i,r[n]),o=j.join2(o,r[n]),ie.isMountpoint(i)&&(!a||a&&t.follow_mount)&&(i=i.mounted.root),!a||t.follow)for(var s=0;ie.isLink(i.mode);){var c=ie.readlink(o);if(o=K.resolve(j.dirname(o),c),i=ie.lookupPath(o,{recurse_count:t.recurse_count+1}).node,s++>40)throw new ie.ErrnoError(32)}}return{path:o,node:i}},getPath:e=>{for(var t;;){if(ie.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?"".concat(r,"/").concat(t):r+t:r}t=t?"".concat(e.name,"/").concat(t):e.name,e=e.parent}},hashName:(e,t)=>{for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%ie.nameTable.length},hashAddNode:e=>{var t=ie.hashName(e.parent.id,e.name);e.name_next=ie.nameTable[t],ie.nameTable[t]=e},hashRemoveNode:e=>{var t=ie.hashName(e.parent.id,e.name);if(ie.nameTable[t]===e)ie.nameTable[t]=e.name_next;else for(var r=ie.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:(e,t)=>{var r=ie.mayLookup(e);if(r)throw new ie.ErrnoError(r,e);for(var i=ie.hashName(e.id,t),o=ie.nameTable[i];o;o=o.name_next){var n=o.name;if(o.parent.id===e.id&&n===t)return o}return ie.lookup(e,t)},createNode:(e,t,r,i)=>{var o=new ie.FSNode(e,t,r,i);return ie.hashAddNode(o),o},destroyNode:e=>{ie.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ie.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>ie.nodePermissions(e,"x")||(e.node_ops.lookup?0:2),mayCreate:(e,t)=>{try{return ie.lookupNode(e,t),20}catch(r){}return ie.nodePermissions(e,"wx")},mayDelete:(e,t,r)=>{var i;try{i=ie.lookupNode(e,t)}catch(n){return n.errno}var o=ie.nodePermissions(e,"wx");if(o)return o;if(r){if(!ie.isDir(i.mode))return 54;if(ie.isRoot(i)||ie.getPath(i)===ie.cwd())return 10}else if(ie.isDir(i.mode))return 31;return 0},mayOpen:(e,t)=>e?ie.isLink(e.mode)?32:ie.isDir(e.mode)&&("r"!==ie.flagsToPermissionString(t)||512&t)?31:ie.nodePermissions(e,ie.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:()=>{for(var e=0;e<=ie.MAX_OPEN_FDS;e++)if(!ie.streams[e])return e;throw new ie.ErrnoError(33)},getStreamChecked:e=>{var t=ie.getStream(e);if(!t)throw new ie.ErrnoError(8);return t},getStream:e=>ie.streams[e],createStream:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return ie.FSStream||(ie.FSStream=function(){this.shared={}},ie.FSStream.prototype={},Object.defineProperties(ie.FSStream.prototype,{object:{get(){return this.node},set(e){this.node=e}},isRead:{get(){return 1!=(2097155&this.flags)}},isWrite:{get(){return!!(2097155&this.flags)}},isAppend:{get(){return 1024&this.flags}},flags:{get(){return this.shared.flags},set(e){this.shared.flags=e}},position:{get(){return this.shared.position},set(e){this.shared.position=e}}})),e=Object.assign(new ie.FSStream,e),-1==t&&(t=ie.nextfd()),e.fd=t,ie.streams[t]=e,e},closeStream:e=>{ie.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ie.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ie.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ie.devices[e]={stream_ops:t}},getDevice:e=>ie.devices[e],getMounts:e=>{for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ie.syncFSRequests++,ie.syncFSRequests>1&&f("warning: ".concat(ie.syncFSRequests," FS.syncfs operations in flight at once, probably just doing extra work"));var r=ie.getMounts(ie.root.mount),i=0;function o(e){return ie.syncFSRequests--,t(e)}function n(e){if(e)return n.errored?void 0:(n.errored=!0,o(e));++i>=r.length&&o(null)}r.forEach((t=>{if(!t.type.syncfs)return n(null);t.type.syncfs(t,e,n)}))},mount:(e,t,r)=>{var i,o="/"===r,n=!r;if(o&&ie.root)throw new ie.ErrnoError(10);if(!o&&!n){var a=ie.lookupPath(r,{follow_mount:!1});if(r=a.path,i=a.node,ie.isMountpoint(i))throw new ie.ErrnoError(10);if(!ie.isDir(i.mode))throw new ie.ErrnoError(54)}var s={type:e,opts:t,mountpoint:r,mounts:[]},c=e.mount(s);return c.mount=s,s.root=c,o?ie.root=c:i&&(i.mounted=s,i.mount&&i.mount.mounts.push(s)),c},unmount:e=>{var t=ie.lookupPath(e,{follow_mount:!1});if(!ie.isMountpoint(t.node))throw new ie.ErrnoError(28);var r=t.node,i=r.mounted,o=ie.getMounts(i);Object.keys(ie.nameTable).forEach((e=>{for(var t=ie.nameTable[e];t;){var r=t.name_next;o.includes(t.mount)&&ie.destroyNode(t),t=r}})),r.mounted=null;var n=r.mount.mounts.indexOf(i);r.mount.mounts.splice(n,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,r)=>{var i=ie.lookupPath(e,{parent:!0}).node,o=j.basename(e);if(!o||"."===o||".."===o)throw new ie.ErrnoError(28);var n=ie.mayCreate(i,o);if(n)throw new ie.ErrnoError(n);if(!i.node_ops.mknod)throw new ie.ErrnoError(63);return i.node_ops.mknod(i,o,t,r)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ie.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ie.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var r=e.split("/"),i="",o=0;o<r.length;++o)if(r[o]){i+="/"+r[o];try{ie.mkdir(i,t)}catch(n){if(20!=n.errno)throw n}}},mkdev:(e,t,r)=>(void 0===r&&(r=t,t=438),t|=8192,ie.mknod(e,t,r)),symlink:(e,t)=>{if(!K.resolve(e))throw new ie.ErrnoError(44);var r=ie.lookupPath(t,{parent:!0}).node;if(!r)throw new ie.ErrnoError(44);var i=j.basename(t),o=ie.mayCreate(r,i);if(o)throw new ie.ErrnoError(o);if(!r.node_ops.symlink)throw new ie.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename:(e,t)=>{var r,i,o=j.dirname(e),n=j.dirname(t),a=j.basename(e),s=j.basename(t);if(r=ie.lookupPath(e,{parent:!0}).node,i=ie.lookupPath(t,{parent:!0}).node,!r||!i)throw new ie.ErrnoError(44);if(r.mount!==i.mount)throw new ie.ErrnoError(75);var c,l=ie.lookupNode(r,a),u=K.relative(e,n);if("."!==u.charAt(0))throw new ie.ErrnoError(28);if("."!==(u=K.relative(t,o)).charAt(0))throw new ie.ErrnoError(55);try{c=ie.lookupNode(i,s)}catch(p){}if(l!==c){var d=ie.isDir(l.mode),h=ie.mayDelete(r,a,d);if(h)throw new ie.ErrnoError(h);if(h=c?ie.mayDelete(i,s,d):ie.mayCreate(i,s))throw new ie.ErrnoError(h);if(!r.node_ops.rename)throw new ie.ErrnoError(63);if(ie.isMountpoint(l)||c&&ie.isMountpoint(c))throw new ie.ErrnoError(10);if(i!==r&&(h=ie.nodePermissions(r,"w")))throw new ie.ErrnoError(h);ie.hashRemoveNode(l);try{r.node_ops.rename(l,i,s)}catch(p){throw p}finally{ie.hashAddNode(l)}}},rmdir:e=>{var t=ie.lookupPath(e,{parent:!0}).node,r=j.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!0);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.rmdir)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.rmdir(t,r),ie.destroyNode(i)},readdir:e=>{var t=ie.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ie.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ie.lookupPath(e,{parent:!0}).node;if(!t)throw new ie.ErrnoError(44);var r=j.basename(e),i=ie.lookupNode(t,r),o=ie.mayDelete(t,r,!1);if(o)throw new ie.ErrnoError(o);if(!t.node_ops.unlink)throw new ie.ErrnoError(63);if(ie.isMountpoint(i))throw new ie.ErrnoError(10);t.node_ops.unlink(t,r),ie.destroyNode(i)},readlink:e=>{var t=ie.lookupPath(e).node;if(!t)throw new ie.ErrnoError(44);if(!t.node_ops.readlink)throw new ie.ErrnoError(28);return K.resolve(ie.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var r=ie.lookupPath(e,{follow:!t}).node;if(!r)throw new ie.ErrnoError(44);if(!r.node_ops.getattr)throw new ie.ErrnoError(63);return r.node_ops.getattr(r)},lstat:e=>ie.stat(e,!0),chmod:(e,t,r)=>{var i;if(!(i="string"==typeof e?ie.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ie.chmod(e,t,!0)},fchmod:(e,t)=>{var r=ie.getStreamChecked(e);ie.chmod(r.node,t)},chown:(e,t,r,i)=>{var o;if(!(o="string"==typeof e?ie.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()})},lchown:(e,t,r)=>{ie.chown(e,t,r,!0)},fchown:(e,t,r)=>{var i=ie.getStreamChecked(e);ie.chown(i.node,t,r)},truncate:(e,t)=>{if(t<0)throw new ie.ErrnoError(28);var r;if(!(r="string"==typeof e?ie.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ie.ErrnoError(63);if(ie.isDir(r.mode))throw new ie.ErrnoError(31);if(!ie.isFile(r.mode))throw new ie.ErrnoError(28);var i=ie.nodePermissions(r,"w");if(i)throw new ie.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var r=ie.getStreamChecked(e);if(!(2097155&r.flags))throw new ie.ErrnoError(28);ie.truncate(r.node,t)},utime:(e,t,r)=>{var i=ie.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open:(e,t,r)=>{if(""===e)throw new ie.ErrnoError(44);var o;if(r=void 0===r?438:r,r=64&(t="string"==typeof t?function(e){var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(void 0===t)throw new Error("Unknown file open mode: ".concat(e));return t}(t):t)?4095&r|32768:0,"object"==typeof e)o=e;else{e=j.normalize(e);try{o=ie.lookupPath(e,{follow:!(131072&t)}).node}catch(c){}}var n=!1;if(64&t)if(o){if(128&t)throw new ie.ErrnoError(20)}else o=ie.mknod(e,r,0),n=!0;if(!o)throw new ie.ErrnoError(44);if(ie.isChrdev(o.mode)&&(t&=-513),65536&t&&!ie.isDir(o.mode))throw new ie.ErrnoError(54);if(!n){var a=ie.mayOpen(o,t);if(a)throw new ie.ErrnoError(a)}512&t&&!n&&ie.truncate(o,0),t&=-131713;var s=ie.createStream({node:o,path:ie.getPath(o),flags:t,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1});return s.stream_ops.open&&s.stream_ops.open(s),!i.logReadFiles||1&t||(ie.readFiles||(ie.readFiles={}),e in ie.readFiles||(ie.readFiles[e]=1)),s},close:e=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{ie.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ie.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new ie.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:(e,t,r,i,o)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(1==(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.read)throw new ie.ErrnoError(28);var n=void 0!==o;if(n){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var a=e.stream_ops.read(e,t,r,i,o);return n||(e.position+=a),a},write:(e,t,r,i,o,n)=>{if(i<0||o<0)throw new ie.ErrnoError(28);if(ie.isClosed(e))throw new ie.ErrnoError(8);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(ie.isDir(e.node.mode))throw new ie.ErrnoError(31);if(!e.stream_ops.write)throw new ie.ErrnoError(28);e.seekable&&1024&e.flags&&ie.llseek(e,0,2);var a=void 0!==o;if(a){if(!e.seekable)throw new ie.ErrnoError(70)}else o=e.position;var s=e.stream_ops.write(e,t,r,i,o,n);return a||(e.position+=s),s},allocate:(e,t,r)=>{if(ie.isClosed(e))throw new ie.ErrnoError(8);if(t<0||r<=0)throw new ie.ErrnoError(28);if(!(2097155&e.flags))throw new ie.ErrnoError(8);if(!ie.isFile(e.node.mode)&&!ie.isDir(e.node.mode))throw new ie.ErrnoError(43);if(!e.stream_ops.allocate)throw new ie.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:(e,t,r,i,o)=>{if(2&i&&!(2&o)&&2!=(2097155&e.flags))throw new ie.ErrnoError(2);if(1==(2097155&e.flags))throw new ie.ErrnoError(2);if(!e.stream_ops.mmap)throw new ie.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,o)},msync:(e,t,r,i,o)=>e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,o):0,munmap:e=>0,ioctl:(e,t,r)=>{if(!e.stream_ops.ioctl)throw new ie.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'.concat(t.encoding,'"'));var r,i=ie.open(e,t.flags),o=ie.stat(e).size,n=new Uint8Array(o);return ie.read(i,n,0,o,0),"utf8"===t.encoding?r=q(n,0):"binary"===t.encoding&&(r=n),ie.close(i),r},writeFile:function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r.flags=r.flags||577;var i=ie.open(e,r.flags,r.mode);if("string"==typeof t){var o=new Uint8Array(J(t)+1),n=X(t,o,0,o.length);ie.write(i,o,0,n,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ie.write(i,t,0,t.byteLength,void 0,r.canOwn)}ie.close(i)},cwd:()=>ie.currentPath,chdir:e=>{var t=ie.lookupPath(e,{follow:!0});if(null===t.node)throw new ie.ErrnoError(44);if(!ie.isDir(t.node.mode))throw new ie.ErrnoError(54);var r=ie.nodePermissions(t.node,"x");if(r)throw new ie.ErrnoError(r);ie.currentPath=t.path},createDefaultDirectories:()=>{ie.mkdir("/tmp"),ie.mkdir("/home"),ie.mkdir("/home/web_user")},createDefaultDevices:()=>{ie.mkdir("/dev"),ie.registerDevice(ie.makedev(1,3),{read:()=>0,write:(e,t,r,i,o)=>i}),ie.mkdev("/dev/null",ie.makedev(1,3)),Q.register(ie.makedev(5,0),Q.default_tty_ops),Q.register(ie.makedev(6,0),Q.default_tty1_ops),ie.mkdev("/dev/tty",ie.makedev(5,0)),ie.mkdev("/dev/tty1",ie.makedev(6,0));var e=new Uint8Array(1024),t=0,r=()=>(0===t&&(t=G(e).byteLength),e[--t]);ie.createDevice("/dev","random",r),ie.createDevice("/dev","urandom",r),ie.mkdir("/dev/shm"),ie.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ie.mkdir("/proc");var e=ie.mkdir("/proc/self");ie.mkdir("/proc/self/fd"),ie.mount({mount:()=>{var t=ie.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var r=+t,i=ie.getStreamChecked(r),o={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return o.parent=o,o}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{i.stdin?ie.createDevice("/dev","stdin",i.stdin):ie.symlink("/dev/tty","/dev/stdin"),i.stdout?ie.createDevice("/dev","stdout",null,i.stdout):ie.symlink("/dev/tty","/dev/stdout"),i.stderr?ie.createDevice("/dev","stderr",null,i.stderr):ie.symlink("/dev/tty1","/dev/stderr"),ie.open("/dev/stdin",0),ie.open("/dev/stdout",1),ie.open("/dev/stderr",1)},ensureErrnoError:()=>{ie.ErrnoError||(ie.ErrnoError=function(e,t){this.name="ErrnoError",this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ie.ErrnoError.prototype=new Error,ie.ErrnoError.prototype.constructor=ie.ErrnoError,[44].forEach((e=>{ie.genericErrors[e]=new ie.ErrnoError(e),ie.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ie.ensureErrnoError(),ie.nameTable=new Array(4096),ie.mount(ee,{},"/"),ie.createDefaultDirectories(),ie.createDefaultDevices(),ie.createSpecialDirectories(),ie.filesystems={MEMFS:ee}},init:(e,t,r)=>{ie.init.initialized=!0,ie.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,ie.createStandardStreams()},quit:()=>{ie.init.initialized=!1;for(var e=0;e<ie.streams.length;e++){var t=ie.streams[e];t&&ie.close(t)}},findObject:(e,t)=>{var r=ie.analyzePath(e,t);return r.exists?r.object:null},analyzePath:(e,t)=>{try{e=(i=ie.lookupPath(e,{follow:!t})).path}catch(o){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=ie.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=j.basename(e),i=ie.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(o){r.error=o.errno}return r},createPath:(e,t,r,i)=>{e="string"==typeof e?e:ie.getPath(e);for(var o=t.split("/").reverse();o.length;){var n=o.pop();if(n){var a=j.join2(e,n);try{ie.mkdir(a)}catch(s){}e=a}}return a},createFile:(e,t,r,i,o)=>{var n=j.join2("string"==typeof e?e:ie.getPath(e),t),a=re(i,o);return ie.create(n,a)},createDataFile:(e,t,r,i,o,n)=>{var a=t;e&&(e="string"==typeof e?e:ie.getPath(e),a=t?j.join2(e,t):e);var s=re(i,o),c=ie.create(a,s);if(r){if("string"==typeof r){for(var l=new Array(r.length),u=0,d=r.length;u<d;++u)l[u]=r.charCodeAt(u);r=l}ie.chmod(c,146|s);var h=ie.open(c,577);ie.write(h,r,0,r.length,0,n),ie.close(h),ie.chmod(c,s)}return c},createDevice:(e,t,r,i)=>{var o=j.join2("string"==typeof e?e:ie.getPath(e),t),n=re(!!r,!!i);ie.createDevice.major||(ie.createDevice.major=64);var a=ie.makedev(ie.createDevice.major++,0);return ie.registerDevice(a,{open:e=>{e.seekable=!1},close:e=>{i&&i.buffer&&i.buffer.length&&i(10)},read:(e,t,i,o,n)=>{for(var a=0,s=0;s<o;s++){var c;try{c=r()}catch(l){throw new ie.ErrnoError(29)}if(void 0===c&&0===a)throw new ie.ErrnoError(6);if(null==c)break;a++,t[i+s]=c}return a&&(e.node.timestamp=Date.now()),a},write:(e,t,r,o,n)=>{for(var a=0;a<o;a++)try{i(t[r+a])}catch(s){throw new ie.ErrnoError(29)}return o&&(e.node.timestamp=Date.now()),a}}),ie.mkdev(o,n,a)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!o)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=$(o(e.url),!0),e.usedBytes=e.contents.length}catch(t){throw new ie.ErrnoError(29)}},createLazyFile:(e,t,r,i,o)=>{function n(){this.lengthKnown=!1,this.chunks=[]}if(n.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},n.prototype.setDataGetter=function(e){this.getter=e},n.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),o=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,n=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,a=1048576;o||(a=i);var s=this;s.setDataGetter((e=>{var t=e*a,o=(e+1)*a-1;if(o=Math.min(o,i-1),void 0===s.chunks[e]&&(s.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var o=new XMLHttpRequest;if(o.open("GET",r,!1),i!==a&&o.setRequestHeader("Range","bytes="+e+"-"+t),o.responseType="arraybuffer",o.overrideMimeType&&o.overrideMimeType("text/plain; charset=x-user-defined"),o.send(null),!(o.status>=200&&o.status<300||304===o.status))throw new Error("Couldn't load "+r+". Status: "+o.status);return void 0!==o.response?new Uint8Array(o.response||[]):$(o.responseText||"",!0)})(t,o)),void 0===s.chunks[e])throw new Error("doXHR failed!");return s.chunks[e]})),!n&&i||(a=i=1,i=this.getter(0).length,a=i,m("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=a,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!u)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var a=new n;Object.defineProperties(a,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var s={isDevice:!1,contents:a}}else s={isDevice:!1,url:r};var c=ie.createFile(e,t,s,i,o);s.contents?c.contents=s.contents:s.url&&(c.contents=null,c.url=s.url),Object.defineProperties(c,{usedBytes:{get:function(){return this.contents.length}}});var l={};function d(e,t,r,i,o){var n=e.node.contents;if(o>=n.length)return 0;var a=Math.min(n.length-o,i);if(n.slice)for(var s=0;s<a;s++)t[r+s]=n[o+s];else for(s=0;s<a;s++)t[r+s]=n.get(o+s);return a}return Object.keys(c.stream_ops).forEach((e=>{var t=c.stream_ops[e];l[e]=function(){return ie.forceLoadFile(c),t.apply(null,arguments)}})),l.read=(e,t,r,i,o)=>(ie.forceLoadFile(c),d(e,t,r,i,o)),l.mmap=(e,t,r,i,o)=>{ie.forceLoadFile(c);var n=Z();if(!n)throw new ie.ErrnoError(48);return d(e,_,n,t,r),{ptr:n,allocated:!0}},c.stream_ops=l,c}},oe=(e,t)=>e?q(g,e,t):"",ne={DEFAULT_POLLMASK:5,calculateAt:function(e,t,r){if(j.isAbs(t))return t;var i;if(i=-100===e?ie.cwd():ne.getStreamFromFD(e).path,0==t.length){if(!r)throw new ie.ErrnoError(44);return i}return j.join2(i,t)},doStat:function(e,t,r){try{var i=e(t)}catch(s){if(s&&s.node&&j.normalize(t)!==j.normalize(ie.getPath(s.node)))return-54;throw s}y[r>>2]=i.dev,y[r+4>>2]=i.mode,T[r+8>>2]=i.nlink,y[r+12>>2]=i.uid,y[r+16>>2]=i.gid,y[r+20>>2]=i.rdev,D=[i.size>>>0,(w=i.size,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+24>>2]=D[0],y[r+28>>2]=D[1],y[r+32>>2]=4096,y[r+36>>2]=i.blocks;var o=i.atime.getTime(),n=i.mtime.getTime(),a=i.ctime.getTime();return D=[Math.floor(o/1e3)>>>0,(w=Math.floor(o/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+40>>2]=D[0],y[r+44>>2]=D[1],T[r+48>>2]=o%1e3*1e3,D=[Math.floor(n/1e3)>>>0,(w=Math.floor(n/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+56>>2]=D[0],y[r+60>>2]=D[1],T[r+64>>2]=n%1e3*1e3,D=[Math.floor(a/1e3)>>>0,(w=Math.floor(a/1e3),+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+72>>2]=D[0],y[r+76>>2]=D[1],T[r+80>>2]=a%1e3*1e3,D=[i.ino>>>0,(w=i.ino,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[r+88>>2]=D[0],y[r+92>>2]=D[1],0},doMsync:function(e,t,r,i,o){if(!ie.isFile(t.node.mode))throw new ie.ErrnoError(43);if(2&i)return 0;var n=g.slice(e,e+r);ie.msync(t,n,o,r,i)},varargs:void 0,get:()=>(ne.varargs+=4,y[ne.varargs-4>>2]),getStr:e=>oe(e),getStreamFromFD:function(e){return ie.getStreamChecked(e)}};function ae(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: ".concat(e))}}var se=void 0;function ce(e){for(var t="",r=e;g[r];)t+=se[g[r++]];return t}var le={},ue={},de={},he=void 0;function pe(e){throw new he(e)}var me=void 0;function fe(e){throw new me(e)}function _e(e,t,r){function i(t){var i=r(t);i.length!==e.length&&fe("Mismatched type converter count");for(var o=0;o<e.length;++o)ge(e[o],i[o])}e.forEach((function(e){de[e]=t}));var o=new Array(t.length),n=[],a=0;t.forEach(((e,t)=>{ue.hasOwnProperty(e)?o[t]=ue[e]:(n.push(e),le.hasOwnProperty(e)||(le[e]=[]),le[e].push((()=>{o[t]=ue[e],++a===n.length&&i(o)})))})),0===n.length&&i(o)}function ge(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var i=t.name;if(e||pe('type "'.concat(i,'" must have a positive integer typeid pointer')),ue.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;pe("Cannot register type '".concat(i,"' twice"))}if(ue[e]=t,delete de[e],le.hasOwnProperty(e)){var o=le[e];delete le[e],o.forEach((e=>e()))}}(e,t,r)}function Ee(e){pe(e.$$.ptrType.registeredClass.name+" instance already deleted")}var ve=!1;function ye(e){}function Te(e){var t;e.count.value-=1,0===e.count.value&&((t=e).smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr))}function Ie(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var i=Ie(e,t,r.baseClass);return null===i?null:r.downcast(i)}var Ae={},Se=[];function Re(){for(;Se.length;){var e=Se.pop();e.$$.deleteScheduled=!1,e.delete()}}var be=void 0,we={};function De(e,t){return t.ptrType&&t.ptr||fe("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&fe("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Ce(Object.create(e,{$$:{value:t}}))}var Ce=function(e){return"undefined"==typeof FinalizationRegistry?(Ce=e=>e,e):(ve=new FinalizationRegistry((e=>{Te(e.$$)})),ye=e=>ve.unregister(e),(Ce=e=>{var t=e.$$;if(t.smartPtr){var r={$$:t};ve.register(e,r,e)}return e})(e))};function Ne(){}function ke(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_".concat(e):e}function Oe(e,t){return e=ke(e),{[e]:function(){return t.apply(this,arguments)}}[e]}function Me(e,t,r){if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||pe("Function '".concat(r,"' called with an invalid number of arguments (").concat(arguments.length,") - expects one of (").concat(e[t].overloadTable,")!")),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}}function Le(e,t,r,i,o,n,a,s){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=o,this.getActualType=n,this.upcast=a,this.downcast=s,this.pureVirtualFunctions=[]}function Pe(e,t,r){for(;t!==r;)t.upcast||pe("Expected null or instance of ".concat(r.name,", got an instance of ").concat(t.name)),e=t.upcast(e),t=t.baseClass;return e}function xe(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Ue(e,t){var r;if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),!this.isConst&&t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));var i=t.$$.ptrType.registeredClass;if(r=Pe(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&pe("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:pe("Cannot convert argument of type ".concat(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name," to parameter type ").concat(this.name));break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var o=t.clone();r=this.rawShare(r,et.toHandle((function(){o.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:pe("Unsupporting sharing policy")}return r}function Ve(e,t){if(null===t)return this.isReference&&pe("null is not a valid ".concat(this.name)),0;t.$$||pe('Cannot pass "'.concat(tt(t),'" as a ').concat(this.name)),t.$$.ptr||pe("Cannot pass deleted object as a pointer of type ".concat(this.name)),t.$$.ptrType.isConst&&pe("Cannot convert argument of type ".concat(t.$$.ptrType.name," to parameter type ").concat(this.name));var r=t.$$.ptrType.registeredClass;return Pe(t.$$.ptr,r,this.registeredClass)}function Fe(e){return this.fromWireType(y[e>>2])}function Be(e,t,r,i,o,n,a,s,c,l,u){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=o,this.pointeeType=n,this.sharingPolicy=a,this.rawGetPointee=s,this.rawConstructor=c,this.rawShare=l,this.rawDestructor=u,o||void 0!==t.baseClass?this.toWireType=Ue:i?(this.toWireType=xe,this.destructorFunction=null):(this.toWireType=Ve,this.destructorFunction=null)}var He=[],We=e=>{var t=He[e];return t||(e>=He.length&&(He.length=e+1),He[e]=t=S.get(e)),t};function je(e,t){var r,o,n,a=(e=ce(e)).includes("j")?(r=e,o=t,n=[],function(){return n.length=0,Object.assign(n,arguments),((e,t,r)=>{return e.includes("j")?(o=t,n=r,a=i["dynCall_"+e],n&&n.length?a.apply(null,[o].concat(n)):a.call(null,o)):We(t).apply(null,r);var o,n,a})(r,o,n)}):We(t);return"function"!=typeof a&&pe("unknown function pointer with signature ".concat(e,": ").concat(t)),a}var Ge=void 0;function Ke(e){var t=St(e),r=ce(t);return It(t),r}function ze(e,t){var r=[],i={};throw t.forEach((function e(t){i[t]||ue[t]||(de[t]?de[t].forEach(e):(r.push(t),i[t]=!0))})),new Ge("".concat(e,": ")+r.map(Ke).join([", "]))}function qe(e,t){for(var r=[],i=0;i<e;i++)r.push(T[t+4*i>>2]);return r}function Ye(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function Je(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type ".concat(typeof e," which is not a function"));var r=Oe(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,o=e.apply(i,t);return o instanceof Object?o:i}function Xe(e,t,r,i,o,n){var a=t.length;a<2&&pe("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var s=null!==t[1]&&null!==r,c=!1,l=1;l<t.length;++l)if(null!==t[l]&&void 0===t[l].destructorFunction){c=!0;break}var u="void"!==t[0].name,d="",h="";for(l=0;l<a-2;++l)d+=(0!==l?", ":"")+"arg"+l,h+=(0!==l?", ":"")+"arg"+l+"Wired";var p="\n return function ".concat(ke(e),"(").concat(d,") {\n if (arguments.length !== ").concat(a-2,") {\n throwBindingError('function ").concat(e," called with ").concat(arguments.length," arguments, expected ").concat(a-2," args!');\n }");c&&(p+="var destructors = [];\n");var m=c?"destructors":"null",f=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],_=[pe,i,o,Ye,t[0],t[1]];for(s&&(p+="var thisWired = classParam.toWireType("+m+", this);\n"),l=0;l<a-2;++l)p+="var arg"+l+"Wired = argType"+l+".toWireType("+m+", arg"+l+"); // "+t[l+2].name+"\n",f.push("argType"+l),_.push(t[l+2]);if(s&&(h="thisWired"+(h.length>0?", ":"")+h),p+=(u||n?"var rv = ":"")+"invoker(fn"+(h.length>0?", ":"")+h+");\n",c)p+="runDestructors(destructors);\n";else for(l=s?1:2;l<t.length;++l){var g=1===l?"thisWired":"arg"+(l-2)+"Wired";null!==t[l].destructorFunction&&(p+=g+"_dtor("+g+"); // "+t[l].name+"\n",f.push(g+"_dtor"),_.push(t[l].destructorFunction))}return u&&(p+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),p+="}\n",f.push(p),Je(Function,f).apply(null,_)}function $e(){this.allocated=[void 0],this.freelist=[]}var Qe=new $e;function Ze(e){e>=Qe.reserved&&0==--Qe.get(e).refcount&&Qe.free(e)}var et={toValue:e=>(e||pe("Cannot use deleted val. handle = "+e),Qe.get(e).value),toHandle:e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Qe.allocate({refcount:1,value:e})}}};function tt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function rt(e,t){switch(t){case 2:return function(e){return this.fromWireType(I[e>>2])};case 3:return function(e){return this.fromWireType(A[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function it(e,t,r){switch(t){case 0:return r?function(e){return _[e]}:function(e){return g[e]};case 1:return r?function(e){return E[e>>1]}:function(e){return v[e>>1]};case 2:return r?function(e){return y[e>>2]}:function(e){return T[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var ot,nt,at="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0,st=(e,t)=>{for(var r=e,i=r>>1,o=i+t/2;!(i>=o)&&v[i];)++i;if((r=i<<1)-e>32&&at)return at.decode(g.subarray(e,r));for(var n="",a=0;!(a>=t/2);++a){var s=E[e+2*a>>1];if(0==s)break;n+=String.fromCharCode(s)}return n},ct=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,o=(r-=2)<2*e.length?r/2:e.length,n=0;n<o;++n){var a=e.charCodeAt(n);E[t>>1]=a,t+=2}return E[t>>1]=0,t-i},lt=e=>2*e.length,ut=(e,t)=>{for(var r=0,i="";!(r>=t/4);){var o=y[e+4*r>>2];if(0==o)break;if(++r,o>=65536){var n=o-65536;i+=String.fromCharCode(55296|n>>10,56320|1023&n)}else i+=String.fromCharCode(o)}return i},dt=(e,t,r)=>{if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,o=i+r-4,n=0;n<e.length;++n){var a=e.charCodeAt(n);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++n)),y[t>>2]=a,(t+=4)+4>o)break}return y[t>>2]=0,t-i},ht=e=>{for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t},pt={},mt=[],ft=[],_t={},gt=()=>{if(!gt.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:c||"./this.program"};for(var t in _t)void 0===_t[t]?delete e[t]:e[t]=_t[t];var r=[];for(var t in e)r.push("".concat(t,"=").concat(e[t]));gt.strings=r}return gt.strings},Et=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ie.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i};Object.defineProperties(Et.prototype,{read:{get:function(){return!(365&~this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return!(146&~this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},isFolder:{get:function(){return ie.isDir(this.mode)}},isDevice:{get:function(){return ie.isChrdev(this.mode)}}}),ie.FSNode=Et,ie.createPreloadedFile=function(e,t,r,i,o,a,s,c,l,u){var d=t?K.resolve(j.join2(e,t)):e;function h(r){function n(r){u&&u(),c||ie.createDataFile(e,t,r,i,o,l),a&&a(),x()}(function(e,t,r,i){"undefined"!=typeof Browser&&Browser.init();var o=!1;return te.forEach((function(n){o||n.canHandle(t)&&(n.handle(e,t,r,i),o=!0)})),o})(r,d,n,(()=>{s&&s(),x()}))||n(r)}P(),"string"==typeof r?((e,t,r,i)=>{var o=i?"":"al ".concat(e);n(e,(r=>{var i;i='Loading data file "'.concat(e,'" failed (no arrayBuffer).'),r||U(i),t(new Uint8Array(r)),o&&x()}),(t=>{if(!r)throw'Loading data file "'.concat(e,'" failed.');r()})),o&&P()})(r,(e=>h(e)),s):h(r)},ie.staticInit(),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);se=e}(),he=i.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},me=i.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}},Ne.prototype.isAliasOf=function(e){if(!(this instanceof Ne&&e instanceof Ne))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,i=e.$$.ptrType.registeredClass,o=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)o=i.upcast(o),i=i.baseClass;return t===i&&r===o},Ne.prototype.clone=function(){if(this.$$.ptr||Ee(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Ce(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},Ne.prototype.delete=function(){this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),ye(this),Te(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},Ne.prototype.isDeleted=function(){return!this.$$.ptr},Ne.prototype.deleteLater=function(){return this.$$.ptr||Ee(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&pe("Object already scheduled for deletion"),Se.push(this),1===Se.length&&be&&be(Re),this.$$.deleteScheduled=!0,this},i.getInheritedInstanceCount=function(){return Object.keys(we).length},i.getLiveInheritedInstances=function(){var e=[];for(var t in we)we.hasOwnProperty(t)&&e.push(we[t]);return e},i.flushPendingDeletes=Re,i.setDelayFunction=function(e){be=e,Se.length&&be&&be(Re)},Be.prototype.getPointee=function(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},Be.prototype.destructor=function(e){this.rawDestructor&&this.rawDestructor(e)},Be.prototype.argPackAdvance=8,Be.prototype.readValueFromPointer=Fe,Be.prototype.deleteObject=function(e){null!==e&&e.delete()},Be.prototype.fromWireType=function(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=function(e,t){return t=function(e,t){for(void 0===t&&pe("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),we[t]}(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function o(){return this.isSmartPointer?De(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):De(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var n,a=this.registeredClass.getActualType(t),s=Ae[a];if(!s)return o.call(this);n=this.isConst?s.constPointerType:s.pointerType;var c=Ie(t,this.registeredClass,n.registeredClass);return null===c?o.call(this):this.isSmartPointer?De(n.registeredClass.instancePrototype,{ptrType:n,ptr:c,smartPtrType:this,smartPtr:e}):De(n.registeredClass.instancePrototype,{ptrType:n,ptr:c})},Ge=i.UnboundTypeError=(ot=Error,(nt=Oe("UnboundTypeError",(function(e){this.name="UnboundTypeError",this.message=e;var t=new Error(e).stack;void 0!==t&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}))).prototype=Object.create(ot.prototype),nt.prototype.constructor=nt,nt.prototype.toString=function(){return void 0===this.message?this.name:"".concat(this.name,": ").concat(this.message)},nt),Object.assign($e.prototype,{get(e){return this.allocated[e]},has(e){return void 0!==this.allocated[e]},allocate(e){var t=this.freelist.pop()||this.allocated.length;return this.allocated[t]=e,t},free(e){this.allocated[e]=void 0,this.freelist.push(e)}}),Qe.allocated.push({value:void 0},{value:null},{value:!0},{value:!1}),Qe.reserved=Qe.allocated.length,i.count_emval_handles=function(){for(var e=0,t=Qe.reserved;t<Qe.allocated.length;++t)void 0!==Qe.allocated[t]&&++e;return e};var vt,yt={p:function(e,t,r){throw new W(e).init(t,r),e},C:function(e,t,r){ne.varargs=r;try{var i=ne.getStreamFromFD(e);switch(t){case 0:return(o=ne.get())<0?-28:ie.createStream(i,o).fd;case 1:case 2:case 6:case 7:return 0;case 3:return i.flags;case 4:var o=ne.get();return i.flags|=o,0;case 5:return o=ne.get(),E[o+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return y[At()>>2]=28,-1}}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},w:function(e,t,r,i){ne.varargs=i;try{t=ne.getStr(t),t=ne.calculateAt(e,t);var o=i?ne.get():0;return ie.open(t,r,o).fd}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return-n.errno}},t:function(e,t,r,i,o){},n:function(e,t,r,i,o){var n=ae(r);ge(e,{name:t=ce(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:o},argPackAdvance:8,readValueFromPointer:function(e){var i;if(1===r)i=_;else if(2===r)i=E;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);i=y}return this.fromWireType(i[e>>n])},destructorFunction:null})},r:function(e,t,r,o,n,a,s,c,l,u,d,h,p){d=ce(d),a=je(n,a),c&&(c=je(s,c)),u&&(u=je(l,u)),p=je(h,p);var m,f,_,g=ke(d);m=g,f=function(){ze("Cannot construct ".concat(d," due to unbound types"),[o])},i.hasOwnProperty(m)?(pe("Cannot register public name '".concat(m,"' twice")),Me(i,m,m),i.hasOwnProperty(_)&&pe("Cannot register multiple overloads of a function with the same number of arguments (".concat(_,")!")),i[m].overloadTable[_]=f):i[m]=f,_e([e,t,r],o?[o]:[],(function(t){var r,n;t=t[0],n=o?(r=t.registeredClass).instancePrototype:Ne.prototype;var s=Oe(g,(function(){if(Object.getPrototypeOf(this)!==l)throw new he("Use 'new' to construct "+d);if(void 0===h.constructor_body)throw new he(d+" has no accessible constructor");var e=h.constructor_body[arguments.length];if(void 0===e)throw new he("Tried to invoke ctor of ".concat(d," with invalid number of parameters (").concat(arguments.length,") - expected (").concat(Object.keys(h.constructor_body).toString(),") parameters instead!"));return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:s}});s.prototype=l;var h=new Le(d,s,l,p,r,a,c,u);h.baseClass&&(void 0===h.baseClass.__derivedClasses&&(h.baseClass.__derivedClasses=[]),h.baseClass.__derivedClasses.push(h));var m,f,_,E=new Be(d,h,!0,!1,!1),v=new Be(d+"*",h,!1,!1,!1),y=new Be(d+" const*",h,!1,!0,!1);return Ae[e]={pointerType:v,constPointerType:y},m=g,f=s,i.hasOwnProperty(m)||fe("Replacing nonexistant public symbol"),i[m].overloadTable,i[m]=f,i[m].argCount=_,[E,v,y]}))},q:function(e,t,r,i,o,n){var a=qe(t,r);o=je(i,o),_e([],[e],(function(e){var r="constructor ".concat((e=e[0]).name);if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new he("Cannot register multiple constructors with identical number of parameters (".concat(t-1,") for class '").concat(e.name,"'! Overload resolution is currently only performed using the parameter count, not actual type info!"));return e.registeredClass.constructor_body[t-1]=()=>{ze("Cannot construct ".concat(e.name," due to unbound types"),a)},_e([],a,(function(i){return i.splice(1,0,null),e.registeredClass.constructor_body[t-1]=Xe(r,i,null,o,n),[]})),[]}))},d:function(e,t,r,i,o,n,a,s,c){var l=qe(r,i);t=ce(t),n=je(o,n),_e([],[e],(function(e){var i="".concat((e=e[0]).name,".").concat(t);function o(){ze("Cannot call ".concat(i," due to unbound types"),l)}t.startsWith("@@")&&(t=Symbol[t.substring(2)]),s&&e.registeredClass.pureVirtualFunctions.push(t);var u=e.registeredClass.instancePrototype,d=u[t];return void 0===d||void 0===d.overloadTable&&d.className!==e.name&&d.argCount===r-2?(o.argCount=r-2,o.className=e.name,u[t]=o):(Me(u,t,i),u[t].overloadTable[r-2]=o),_e([],l,(function(o){var s=Xe(i,o,e,n,a,c);return void 0===u[t].overloadTable?(s.argCount=r-2,u[t]=s):u[t].overloadTable[r-2]=s,[]})),[]}))},D:function(e,t){ge(e,{name:t=ce(t),fromWireType:function(e){var t=et.toValue(e);return Ze(e),t},toWireType:function(e,t){return et.toHandle(t)},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:null})},k:function(e,t,r){var i=ae(r);ge(e,{name:t=ce(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:rt(t,i),destructorFunction:null})},c:function(e,t,r,i,o){t=ce(t);var n=ae(r),a=e=>e;if(0===i){var s=32-8*r;a=e=>e<<s>>>s}var c=t.includes("unsigned");ge(e,{name:t,fromWireType:a,toWireType:c?function(e,t){return this.name,t>>>0}:function(e,t){return this.name,t},argPackAdvance:8,readValueFromPointer:it(t,n,0!==i),destructorFunction:null})},b:function(e,t,r){var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function o(e){var t=T,r=t[e>>=2],o=t[e+1];return new i(t.buffer,o,r)}ge(e,{name:r=ce(r),fromWireType:o,argPackAdvance:8,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},j:function(e,t){var r="std::string"===(t=ce(t));ge(e,{name:t,fromWireType:function(e){var t,i=T[e>>2],o=e+4;if(r)for(var n=o,a=0;a<=i;++a){var s=o+a;if(a==i||0==g[s]){var c=oe(n,s-n);void 0===t?t=c:(t+="\0",t+=c),n=s+1}}else{var l=new Array(i);for(a=0;a<i;++a)l[a]=String.fromCharCode(g[o+a]);t=l.join("")}return It(e),t},toWireType:function(e,t){var i;t instanceof ArrayBuffer&&(t=new Uint8Array(t));var o="string"==typeof t;o||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||pe("Cannot pass non-string to std::string"),i=r&&o?J(t):t.length;var n=Tt(4+i+1),a=n+4;if(T[n>>2]=i,r&&o)X(t,g,a,i+1);else if(o)for(var s=0;s<i;++s){var c=t.charCodeAt(s);c>255&&(It(a),pe("String has UTF-16 code units that do not fit in 8 bits")),g[a+s]=c}else for(s=0;s<i;++s)g[a+s]=t[s];return null!==e&&e.push(It,n),n},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},f:function(e,t,r){var i,o,n,a,s;r=ce(r),2===t?(i=st,o=ct,a=lt,n=()=>v,s=1):4===t&&(i=ut,o=dt,a=ht,n=()=>T,s=2),ge(e,{name:r,fromWireType:function(e){for(var r,o=T[e>>2],a=n(),c=e+4,l=0;l<=o;++l){var u=e+4+l*t;if(l==o||0==a[u>>s]){var d=i(c,u-c);void 0===r?r=d:(r+="\0",r+=d),c=u+t}}return It(e),r},toWireType:function(e,i){"string"!=typeof i&&pe("Cannot pass non-string to C++ string type ".concat(r));var n=a(i),c=Tt(4+n+t);return T[c>>2]=n>>s,o(i,c+4,n+t),null!==e&&e.push(It,c),c},argPackAdvance:8,readValueFromPointer:Fe,destructorFunction:function(e){It(e)}})},o:function(e,t){ge(e,{isVoid:!0,name:t=ce(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},g:function(e,t,r,i){var o,n;(e=mt[e])(t=et.toValue(t),r=void 0===(n=pt[o=r])?ce(o):n,null,i)},m:Ze,l:function(e,t){var r=function(e,t){for(var r,i,o,n=new Array(e),a=0;a<e;++a)n[a]=(r=T[t+4*a>>2],i="parameter "+a,void 0===(o=ue[r])&&pe(i+" has unknown type "+Ke(r)),o);return n}(e,t),i=r[0],o=i.name+"_$"+r.slice(1).map((function(e){return e.name})).join("_")+"$",n=ft[o];if(void 0!==n)return n;for(var a=["retType"],s=[i],c="",l=0;l<e-1;++l)c+=(0!==l?", ":"")+"arg"+l,a.push("argType"+l),s.push(r[1+l]);var u,d,h="return function "+ke("methodCaller_"+o)+"(handle, name, destructors, args) {\n",p=0;for(l=0;l<e-1;++l)h+=" var arg"+l+" = argType"+l+".readValueFromPointer(args"+(p?"+"+p:"")+");\n",p+=r[l+1].argPackAdvance;for(h+=" var rv = handle[name]("+c+");\n",l=0;l<e-1;++l)r[l+1].deleteObject&&(h+=" argType"+l+".deleteObject(arg"+l+");\n");return i.isVoid||(h+=" return retType.toWireType(destructors, rv);\n"),h+="};\n",a.push(h),u=Je(Function,a).apply(null,s),d=mt.length,mt.push(u),n=d,ft[o]=n,n},a:()=>{U("")},e:function(){return Date.now()},v:()=>g.length,A:(e,t,r)=>g.copyWithin(e,t,t+r),u:e=>{g.length,U("OOM")},y:(e,t)=>{var r=0;return gt().forEach((function(i,o){var n=t+r;T[e+4*o>>2]=n,((e,t)=>{for(var r=0;r<e.length;++r)_[0|t++]=e.charCodeAt(r);_[0|t]=0})(i,n),r+=i.length+1})),0},z:(e,t)=>{var r=gt();T[e>>2]=r.length;var i=0;return r.forEach((function(e){i+=e.length+1})),T[t>>2]=i,0},i:function(e){try{var t=ne.getStreamFromFD(e);return ie.close(t),0}catch(r){if(void 0===ie||"ErrnoError"!==r.name)throw r;return r.errno}},x:function(e,t){try{var r=ne.getStreamFromFD(e),i=r.tty?2:ie.isDir(r.mode)?3:ie.isLink(r.mode)?7:4;return _[0|t]=i,E[t+2>>1]=0,D=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+8>>2]=D[0],y[t+12>>2]=D[1],D=[0,(w=0,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[t+16>>2]=D[0],y[t+20>>2]=D[1],0}catch(o){if(void 0===ie||"ErrnoError"!==o.name)throw o;return o.errno}},B:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var c=ie.read(e,_,a,s,i);if(c<0)return-1;if(o+=c,c<s)break;void 0!==i&&(i+=c)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}},s:function(e,t,r,i,o){var n,a,s=(a=r)+2097152>>>0<4194305-!!(n=t)?(n>>>0)+4294967296*a:NaN;try{if(isNaN(s))return 61;var c=ne.getStreamFromFD(e);return ie.llseek(c,s,i),D=[c.position>>>0,(w=c.position,+Math.abs(w)>=1?w>0?+Math.floor(w/4294967296)>>>0:~~+Math.ceil((w-+(~~w>>>0))/4294967296)>>>0:0)],y[o>>2]=D[0],y[o+4>>2]=D[1],c.getdents&&0===s&&0===i&&(c.getdents=null),0}catch(l){if(void 0===ie||"ErrnoError"!==l.name)throw l;return l.errno}},h:function(e,t,r,i){try{var o=((e,t,r,i)=>{for(var o=0,n=0;n<r;n++){var a=T[t>>2],s=T[t+4>>2];t+=8;var c=ie.write(e,_,a,s,i);if(c<0)return-1;o+=c,void 0!==i&&(i+=c)}return o})(ne.getStreamFromFD(e),t,r);return T[i>>2]=o,0}catch(n){if(void 0===ie||"ErrnoError"!==n.name)throw n;return n.errno}}},Tt=(function(){var e,t,o,n,a={a:yt};function s(e,t){var r,o,n=e.exports;return r=(p=n).E.buffer,i.HEAP8=_=new Int8Array(r),i.HEAP16=E=new Int16Array(r),i.HEAP32=y=new Int32Array(r),i.HEAPU8=g=new Uint8Array(r),i.HEAPU16=v=new Uint16Array(r),i.HEAPU32=T=new Uint32Array(r),i.HEAPF32=I=new Float32Array(r),i.HEAPF64=A=new Float64Array(r),S=p.H,o=p.F,k.unshift(o),x(),n}if(P(),i.instantiateWasm)try{return i.instantiateWasm(a,s)}catch(c){f("Module.instantiateWasm callback failed with error: "+c),r(c)}(e=h,t=R,o=a,n=function(e){s(e.instance)},e||"function"!=typeof WebAssembly.instantiateStreaming||V(t)||"function"!=typeof fetch?B(t,o,n):fetch(t,{credentials:"same-origin"}).then((e=>WebAssembly.instantiateStreaming(e,o).then(n,(function(e){return f("wasm streaming compile failed: "+e),f("falling back to ArrayBuffer instantiation"),B(t,o,n)}))))).catch(r)}(),e=>(Tt=p.G)(e)),It=e=>(It=p.I)(e),At=()=>(At=p.J)(),St=e=>(St=p.K)(e),Rt=(i.__embind_initialize_bindings=()=>(i.__embind_initialize_bindings=p.L)(),e=>(Rt=p.M)(e));function bt(){function e(){vt||(vt=!0,i.calledRun=!0,C||(i.noFSInit||ie.init.initialized||ie.init(),ie.ignorePermissions=!1,H(k),t(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),O.unshift(e);var e;H(O)}()))}M>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)e=i.preRun.shift(),N.unshift(e);var e;H(N)}(),M>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),e()}),1)):e()))}if(i.dynCall_jiji=(e,t,r,o,n)=>(i.dynCall_jiji=p.N)(e,t,r,o,n),i._ff_h264_cabac_tables=67061,L=function e(){vt||bt(),vt||(L=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return bt(),e.ready}),UF=xF,VF=class extends LF{constructor(e){super(UF,null!=e&&e.wasmPath?fetch(null==e?void 0:e.wasmPath).then((e=>e.arrayBuffer())):void 0,null==e?void 0:e.workerMode,null==e?void 0:e.canvas,null==e?void 0:e.yuvMode)}};(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0})();var FF=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.NONE=5]="NONE",e))(FF||{});function BF(){return performance&&performance.now?Math.floor(performance.now()):Date.now()}var HF=class e{constructor(e){this.core=e,yF(this,"contextMap",new Map),yF(this,"decodeProcessorMap",new WeakMap),this.addKVReportBeforeExitRoom=this.addKVReportBeforeExitRoom.bind(this),this.createDecoder=this.createDecoder.bind(this),this.core.innerEmitter.on("51",this.addKVReportBeforeExitRoom)}getAlias(){return"videoDecoder"}getGroup(e){return null!=e&&e.track?"".concat(e.track.userId).concat(e.track.streamType):"*"}getName(){return e.Name}getValidateRule(e){return{type:this.core.enums.BASIC_TYPE.Object}}createDecoder(e,t){switch(e){case"wasm":return new VF(EF(gF({},t),{wasmPath:"".concat(this.core.assetsPath||".","/videodec.wasm")}));case"webCodecs":return new OF;case"mse":throw new Error("mse decoder not supported yet");default:throw new Error("Unsupported decoder type")}}start(e){this.decodeProcessorMap.set(e.track,this.decode(e)),this.core.room.videoManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;var i;return(null==(i=this.decodeProcessorMap.get(r))?void 0:i({frame:t,track:r}))||t},type:3})}decode(e){let{pipe:t,take:r,subscribe:i}=this.core.rx;return o=>{let{frame:n,track:a}=o;if(a!==e.track||"empty"===n.type)return n;if(this.contextMap.has(a))return this.contextMap.get(a).decode(n);let s=this.core.room.videoManager.createDecodeContext(EF(gF({},e),{createDecoder:this.createDecoder}));return t(s.trackDoneOB,r(1),i((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:a})}))),this.contextMap.set(a,s),s.decode(n)}}stop(e){if(null!=e&&e.track){let t=this.contextMap.get(e.track);t&&(t.close("stop"),this.report(t,e.track),this.contextMap.delete(e.track))}else this.contextMap.forEach(((e,t)=>{e.close("stop"),this.contextMap.delete(t)}));0===this.contextMap.size&&this.core.room.videoManager.removeDecodeProcessor({type:3})}report(e,t){if(e.isReported)return;e.isReported=!0;let r=BF()-e.startPerformanceTime,{renderFreezeTotal:i,dataFreezeTotal:o}=this.getRemoteTrackFreezeDuration(t,e);r&&this.core.kvStatManager.addNumber({key:514850,value:Math.floor(i/r*100),split:1,max:100}),r&&this.core.kvStatManager.addNumber({key:514851,value:Math.floor(o/r*100),split:1,max:100}),e.inputFrameCount&&this.core.kvStatManager.addNumber({key:514852,value:Math.floor(e.decodedFrameCount/e.inputFrameCount*100),split:1,max:100})}addKVReportBeforeExitRoom(e){let{room:t}=e;t===this.core.room&&this.contextMap.forEach(((e,t)=>{this.report(e,t)}))}update(e){let t=this.contextMap.get(e.track);t&&("mock"!==e.type?(t.close("update"),this.contextMap.set(e.track,this.core.room.videoManager.createDecodeContext(EF(gF({},e),{createDecoder:this.createDecoder})))):t.mock(this.core.enums.DECODE_FAILED_ERROR_CODE.TEST))}getRemoteTrackFreezeDuration(e,t){let r=this.core.room.badCaseDetector.getRenderFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),i=this.core.room.badCaseDetector.getDataFreezeMap().get("".concat(e.userId,"_").concat(e.streamType)),o=0;r&&r.freezeTimeline.forEach((e=>{let{startTime:r,endTime:i}=e;r>t.startPerformanceTime&&(o+=0===i?BF()-r:i-r)}));let n=0;return i&&i.durationItemList.forEach((e=>{e.startTime>t.startPerformanceTime&&(n+=e.getDuration())})),{renderFreezeTotal:o,dataFreezeTotal:n}}destroy(){this.core.innerEmitter.off("51",this.addKVReportBeforeExitRoom)}};yF(HF,"Name","TRTCVideoDecoder");var WF=HF,jF=Vb(jb());function GF(e){let{timesInSecond:t,maxSizeInSecond:r,getSize:i}=e;return JP(((e,o)=>{let n=new WeakMap;return Gk.on(zk.ROOM_DESTROY,(e=>{let{room:t}=e;return n.delete(t)})),function(){let a=n.get(this);for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];if(a||(a={callCountInSecond:0,timestamp:0,totalSizeInSecond:0},n.set(this,a)),0===a.timestamp?a.timestamp=Date.now():Date.now()-a.timestamp>1e3&&(a.timestamp=Date.now(),a.callCountInSecond=0,a.totalSizeInSecond=0),i&&(a.totalSizeInSecond+=i(...c)),0!==a.timestamp&&Date.now()-a.timestamp<1e3&&(a.callCountInSecond>=t||a.totalSizeInSecond>r))throw new $b({code:Jb.INVALID_OPERATION,message:iM({key:ZO.CALL_FREQUENCY_LIMIT,data:{isTimes:a.callCountInSecond>=t,isSize:a.totalSizeInSecond>r,name:o,timesInSecond:t,maxSizeInSecond:r}})});a.callCountInSecond++,e.call(this,...c)}}))}var KF,zF=!0,qF={SCENE_LIVE:"live",SCENE_RTC:"rtc",ROLE_ANCHOR:"anchor",ROLE_AUDIENCE:"audience",STREAM_TYPE_MAIN:"main",STREAM_TYPE_SUB:"sub",AUDIO_PROFILE_STANDARD:"standard",AUDIO_PROFILE_STANDARD_STEREO:"standard-stereo",AUDIO_PROFILE_HIGH:"high",AUDIO_PROFILE_HIGH_STEREO:"high-stereo",QOS_PREFERENCE_SMOOTH:"smooth",QOS_PREFERENCE_CLEAR:"clear",SPEAKER:"Speakerphone",HEADSET:"Headset earpiece"},YF={INVALID_PARAMETER:5e3,INVALID_OPERATION:5100,ENV_NOT_SUPPORTED:5200,DEVICE_ERROR:5300,SERVER_ERROR:5400,OPERATION_FAILED:5500,OPERATION_ABORT:5998,UNKNOWN_ERROR:5999},JF=((KF=JF||{})[KF.INVALID_PARAMETER=5e3]="INVALID_PARAMETER",KF[KF.INVALID_PARAMETER_REQUIRED=5001]="INVALID_PARAMETER_REQUIRED",KF[KF.INVALID_PARAMETER_TYPE=5002]="INVALID_PARAMETER_TYPE",KF[KF.INVALID_PARAMETER_EMPTY=5003]="INVALID_PARAMETER_EMPTY",KF[KF.INVALID_PARAMETER_INSTANCE=5004]="INVALID_PARAMETER_INSTANCE",KF[KF.INVALID_PARAMETER_RANGE=5005]="INVALID_PARAMETER_RANGE",KF[KF.INVALID_PARAMETER_LESS_THAN_ZERO=5006]="INVALID_PARAMETER_LESS_THAN_ZERO",KF[KF.INVALID_PARAMETER_MIN=5007]="INVALID_PARAMETER_MIN",KF[KF.INVALID_PARAMETER_MAX=5008]="INVALID_PARAMETER_MAX",KF[KF.INVALID_ELEMENT_ID=5009]="INVALID_ELEMENT_ID",KF[KF.INVALID_ELEMENT_ID_TYPE=5010]="INVALID_ELEMENT_ID_TYPE",KF[KF.INVALID_STREAM_ID=5011]="INVALID_STREAM_ID",KF[KF.INVALID_ROOM_ID_STRING=5012]="INVALID_ROOM_ID_STRING",KF[KF.INVALID_ROOM_ID_INTEGER=5013]="INVALID_ROOM_ID_INTEGER",KF[KF.INVALID_STREAM_TYPE=5014]="INVALID_STREAM_TYPE",KF[KF.INVALID_ROOM_ID_REQUIRED=5015]="INVALID_ROOM_ID_REQUIRED",KF[KF.INVALID_ROOM_ID_INTEGER_STRING=5016]="INVALID_ROOM_ID_INTEGER_STRING",KF[KF.INVALID_BUFFER_EMPTY=5017]="INVALID_BUFFER_EMPTY",KF[KF.INVALID_BUFFER_OVERSIZE=5018]="INVALID_BUFFER_OVERSIZE",KF[KF.INVALID_ROOM_ID_TYPE_MISMATCH=5019]="INVALID_ROOM_ID_TYPE_MISMATCH",KF[KF.INVALID_ROOM_ID_DUPLICATE=5020]="INVALID_ROOM_ID_DUPLICATE",KF[KF.INVALID_OPERATION=5100]="INVALID_OPERATION",KF[KF.INVALID_OPERATION_NOT_JOINED=5101]="INVALID_OPERATION_NOT_JOINED",KF[KF.INVALID_OPERATION_REMOTE_USER_NOT_EXIST=5102]="INVALID_OPERATION_REMOTE_USER_NOT_EXIST",KF[KF.INVALID_OPERATION_STREAM_TYPE_NOT_EXIST=5103]="INVALID_OPERATION_STREAM_TYPE_NOT_EXIST",KF[KF.INVALID_OPERATION_REPEAT_CALL=5104]="INVALID_OPERATION_REPEAT_CALL",KF[KF.INVALID_OPERATION_NEED_VIDEO=5105]="INVALID_OPERATION_NEED_VIDEO",KF[KF.INVALID_OPERATION_NEED_AUDIO=5106]="INVALID_OPERATION_NEED_AUDIO",KF[KF.INVALID_ROLE_AUDIENCE=5107]="INVALID_ROLE_AUDIENCE",KF[KF.INVALID_NOT_ENABLE_SEI=5108]="INVALID_NOT_ENABLE_SEI",KF[KF.INVALID_NEED_CALL_PUBLISHED=5109]="INVALID_NEED_CALL_PUBLISHED",KF[KF.ENV_NOT_SUPPORTED=5200]="ENV_NOT_SUPPORTED",KF[KF.NOT_SUPPORTED_HTTP=5201]="NOT_SUPPORTED_HTTP",KF[KF.NOT_SUPPORTED_WEBRTC=5202]="NOT_SUPPORTED_WEBRTC",KF[KF.NOT_SUPPORTED_H264_ENCODE=5203]="NOT_SUPPORTED_H264_ENCODE",KF[KF.NOT_SUPPORTED_H264_DECODE=5204]="NOT_SUPPORTED_H264_DECODE",KF[KF.NOT_SUPPORTED_SCREEN_SHARE=5205]="NOT_SUPPORTED_SCREEN_SHARE",KF[KF.NOT_SUPPORTED_SMALL_VIDEO=5206]="NOT_SUPPORTED_SMALL_VIDEO",KF[KF.NOT_SUPPORTED_SEI=5207]="NOT_SUPPORTED_SEI",KF[KF.NOT_SUPPORTED_WEBGL=5208]="NOT_SUPPORTED_WEBGL",KF[KF.NOT_SUPPORTED_CHROME_VERSION=5209]="NOT_SUPPORTED_CHROME_VERSION",KF[KF.NOT_SUPPORTED_PLUGIN=5210]="NOT_SUPPORTED_PLUGIN",KF[KF.DEVICE_ERROR=5300]="DEVICE_ERROR",KF[KF.DEVICE_NOT_FOUND_ERROR=5301]="DEVICE_NOT_FOUND_ERROR",KF[KF.DEVICE_NOT_ALLOWED_ERROR=5302]="DEVICE_NOT_ALLOWED_ERROR",KF[KF.DEVICE_NOT_READABLE_ERROR=5303]="DEVICE_NOT_READABLE_ERROR",KF[KF.DEVICE_OVERCONSTRAINED_ERROR=5304]="DEVICE_OVERCONSTRAINED_ERROR",KF[KF.DEVICE_INVALID_STATE_ERROR=5305]="DEVICE_INVALID_STATE_ERROR",KF[KF.DEVICE_SECURITY_ERROR=5306]="DEVICE_SECURITY_ERROR",KF[KF.DEVICE_ABORT_ERROR=5307]="DEVICE_ABORT_ERROR",KF[KF.CAMERA_RECOVER_FAILED=5308]="CAMERA_RECOVER_FAILED",KF[KF.MICROPHONE_RECOVER_FAILED=5309]="MICROPHONE_RECOVER_FAILED",KF[KF.SERVER_ERROR=5400]="SERVER_ERROR",KF[KF.NEED_TO_BUY=5401]="NEED_TO_BUY",KF[KF.ACCOUNT_NO_MONEY=-100013]="ACCOUNT_NO_MONEY",KF[KF.OPERATION_FAILED=5500]="OPERATION_FAILED",KF[KF.FIREWALL_RESTRICTION=5501]="FIREWALL_RESTRICTION",KF[KF.REJOIN_FAILED=5502]="REJOIN_FAILED",KF[KF.EVENT_HANDLER_ERROR=5503]="EVENT_HANDLER_ERROR",KF[KF.VIDEO_CONTEXT_ERROR=5504]="VIDEO_CONTEXT_ERROR",KF[KF.VIDEO_DECODE_ERROR=5505]="VIDEO_DECODE_ERROR",KF[KF.OPERATION_ABORT=5998]="OPERATION_ABORT",KF[KF.UNKNOWN_ERROR=5999]="UNKNOWN_ERROR",KF);var XF=Pb(Lb({},eM),{INVALID_PARAMETER(e){let{fnName:t}=e;return"the parameters of the '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_PARAMETER_REQUIRED(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' is a required param when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_TYPE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="";return a=Array.isArray(r.type)?r.type.join("|"):r.type,"'".concat(n,"' must be type of ").concat(a," when calling ").concat(i,"(), received type: ").concat(tC(o),".")},INVALID_PARAMETER_EMPTY(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' cannot be '").concat(o,"' when calling ").concat(i,"().")},INVALID_PARAMETER_INSTANCE(e){let{key:t,rule:r,fnName:i,value:o}=e,n="".concat(t||r.name),a="".concat(r.instanceOf.name||r.instanceOf);return"'".concat(n,"' must be instanceof ").concat(a," when calling ").concat(i,"(), received type: ").concat(tC(o),".")},INVALID_PARAMETER_RANGE(e){let{key:t,rule:r,fnName:i,value:o}=e;return"'".concat(t||r.name,"' must be one of ").concat(r.values.join("|")," when calling ").concat(i,"(), received: ").concat(o,".")},INVALID_PARAMETER_LESS_THAN_ZERO(e){let{key:t,rule:r,fnName:i}=e;return"'".concat(t||r.name,"' cannot be less than 0 when calling ").concat(i,"().")},INVALID_PARAMETER_MIN(e){let{key:t,rule:r,value:i}=e;return"the min value of ".concat(t||r.name," is ").concat(r.min,", received: ").concat(i,".")},INVALID_PARAMETER_MAX(e){let{key:t,rule:r,value:i}=e;return"the max value of ".concat(t||r.name," is ").concat(r.max,", received: ").concat(i,".")},INVALID_ELEMENT_ID(e){let{key:t,fnName:r}=e;return"'".concat(t,"' is not found in the document object when calling ").concat(r,"().")},INVALID_ELEMENT_ID_TYPE(e){let{key:t,fnName:r,type:i}=e;return"the element corresponding to '".concat(t,"' must be instanceof HTMLElement when calling ").concat(r,"(), received: ").concat(i,".")},INVALID_STREAM_ID(e){let{key:t}=e;return"'".concat(t,"' can only consist of uppercase and lowercase english letters (a-zA-Z), numbers (0-9), hyphens and underscores.")},INVALID_ROOM_ID_STRING(e){let{key:t}=e;return"'".concat(t,"' must be a valid string.")},INVALID_ROOM_ID_INTEGER(e){let{key:t}=e;return"'".concat(t,"' must be an integer between [1, 4294967294].")},INVALID_ROOM_ID_INTEGER_STRING(e){let{key:t}=e;return"'".concat(t,"' must be an integer but go a string, use 'parseInt' to convert it or use 'strRoomId' instead.")},INVALID_ROOM_ID_REQUIRED:()=>"at least one of 'roomId'(between [1, 4294967294]) and 'strRoomId'(not empty) is required.",INVALID_ROOM_ID_TYPE_MISMATCH(e){let{key:t}=e;return"The type of target roomId must match the current roomId. Current room is using '".concat(t,"', but received '").concat("strRoomId"===t?"roomId":"strRoomId","'.")},INVALID_ROOM_ID_DUPLICATE(e){let{key:t}=e;return"the target '".concat(t,"' must not be the same as the current '").concat(t,"'.")},INVALID_STREAM_TYPE:e=>{let{fnName:t}=e;return"'streamType' is required when 'userId' is not '*', calling ".concat(t,"()")},INVALID_IMAGE_URL:"The 'src' param must be filled in when the background type is image.",INVALID_OPERATION(e){let{fnName:t}=e;return"the API '".concat(t,"' you called does not meet the requirements, please check the API documentation.")},INVALID_OPERATION_NOT_JOINED(e){let{fnName:t}=e;return"cannot ".concat(t," because you are not enter room yet.")},INVALID_OPERATION_REMOTE_USER_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing stream.")},INVALID_OPERATION_STREAM_TYPE_NOT_EXIST(e){let{fnName:t,value:r}=e;return"cannot ".concat(t," because remote user(userId: ").concat(r.userId,") does not publishing ").concat(r.streamType," video.")},INVALID_OPERATION_REPEAT_CALL(e){let{fnName:t}=e;return"you are already ".concat(t,"(), cannot repeated call '").concat(t,"'.")},INVALID_OPERATION_NEED_VIDEO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the camera is not turned on.")},INVALID_OPERATION_NEED_AUDIO(e){let{fnName:t}=e;return"cannot call '".concat(t,"' because the microphone is not turned on.")},INVALID_BUFFER_EMPTY:e=>{let{key:t}=e;return"the buffer size of paramerter '".concat(t,"' cannot be empty")},INVALID_BUFFER_OVERSIZE:()=>"buffer size is over 1000 Bytes",INVALID_ROLE_AUDIENCE:()=>"role: 'audience' cannot call this api.",INVALID_NOT_ENABLE_SEI:()=>"you need to enable SEI in TRTC.create({ enableSEI: true })",INVALID_NEED_CALL_PUBLISHED:e=>{let{fnName:t}=e;return"you need to call ".concat(t,"() after publish stream.")},ENV_NOT_SUPPORTED(e){let{fnName:t}=e;return"the current browser does not support the capability of the function '".concat(t,"' you are calling, please check the API documentation.")},NOT_SUPPORTED_WEBRTC:"the current browser does not support WebRTC capability, please check the SDK documentation.",NOT_SUPPORTED_H264_ENCODE:"this browser does not support H264 encode.",NOT_SUPPORTED_H264_DECODE:"this browser does not support H264 decode.",NOT_SUPPORTED_SCREEN_SHARE:"this browser does not support screen share, please check the browser version.",NOT_SUPPORTED_SMALL_VIDEO:"this browser does not support small video, please check the browser version.",NOT_SUPPORTED_SEI:"this browser does not support SEI, please check the browser version.",NOT_SUPPORTED_WEBGL:"this browser does not support WebGL, please check the browser version.",NOT_SUPPORTED_CHROME_VERSION(e){let{fnName:t}=e;return"cannot call ".concat(t," because the browser version is too low, please upgrade to the latest version")},DEVICE_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got device exception").concat(r?", error: ".concat(r.toString(),"."):".")},DEVICE_NOT_FOUND_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"NotFoundError, no ".concat(r," detected, please check your device and the configuration on '").concat(t,"'").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_ALLOWED_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"NotAllowedError, you have disabled ".concat(r," access, please allow the current application to use the ").concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_NOT_READABLE_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"NotReadableError, the ".concat(r," maybe in use by another APP, please check if the device is pre-occupied by another APP.")},DEVICE_OVERCONSTRAINED_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"OverconstrainedError, the device ID is incorrect, please check whether the device ID passed in is correct".concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_INVALID_STATE_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"InvalidStateError, after the user clicks and interacts with the page, turn on the ".concat(r).concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_SECURITY_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"SecurityError, check whether the system security policy restricts the use of the ".concat(r,", and it is recommended to turn on the ").concat(r," after the user interacts with the page").concat(i?", error: ".concat(i.toString(),"."):".")},DEVICE_ABORT_ERROR(e){let{fnName:t,deviceType:r=$F(t),error:i}=e;return"AbortError, an unknown exception in the system makes the device unusable, recommended to change the device or browser and re-check whether the device is normal".concat(i?" error: ".concat(i.toString(),"."):".")},CAMERA_RECOVER_FAILED(e){let{error:t}=e;return"camera recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},MICROPHONE_RECOVER_FAILED(e){let{error:t}=e;return"microphone recover capture failed ".concat((null==t?void 0:t.name)||"",": ").concat((null==t?void 0:t.originMessage)||(null==t?void 0:t.message))},OPERATION_FAILED(e){let{fnName:t,error:r}=e;return"'".concat(t,"' failed, reason: ").concat(null==r?void 0:r.toString())},FIREWALL_RESTRICTION:()=>"media connection failure due to firewall restrictions, please try to change your network.",EVENT_HANDLER_ERROR(e){let{eventName:t}=e;return"an error was caught on trtc.on('".concat(t,"', handler), please check your code on 'handler'.")},VIDEO_CONTEXT_ERROR(e){let{reason:t,error:r}=e;return"video context error ".concat(t," ").concat((null==r?void 0:r.name)||""," ").concat((null==r?void 0:r.message)||"")},SERVER_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' got server error: ").concat(null==r?void 0:r.toString(),", please check the SDK documentation.")},NEED_TO_BUY(e){let{value:t,url:r}=e;return"You need to buy packages for ".concat(t,". Refer to: ").concat(r)},ACCOUNT_NO_MONEY:e=>{let{fnParams:t}=e;return"your TRTC account run out of credit, please recharge.".concat(t.sdkAppId?" SDKAppId: ".concat(t.sdkAppId):"")},OPERATION_ABORT(e){let{fnName:t}=e;return"'".concat(t,"' abort")},UNKNOWN_ERROR(e){let{fnName:t,error:r}=e;return"'".concat(t,"' throw unknown exception").concat(r?", error: ".concat(r.toString(),"."):".")}});function $F(e){if(!e)return"camera";let t=e.toLowerCase();return t.includes("screen")?"screen share":t.includes("audio")?"microphone":"camera"}var QF=class e extends Error{constructor(e){let{code:t,extraCode:r,message:i="",messageParams:o,fnName:n="",originError:a}=e;var s;let c;c=i||function(e){let t,{code:r,params:i,enableDocLink:o=!1}=e,a="",s=JF[r];try{t=XF[s]}catch(n){t=XF.UNKNOWN_ERROR}return rC(t)?a=t(i):oC(t)&&(a=t),i.fnName&&!a.includes(i.fnName)&&("."!==a[a.length-1]&&(a+="."),a+=" thrown from ".concat(i.fnName,"()")),o&&(a+=" doc:"),a}({code:t===YF.SERVER_ERROR?t:r||t,params:Lb({fnName:n,error:a},o)}),super(c),Bb(this,"name","RtcError"),Bb(this,"code"),Bb(this,"extraCode"),Bb(this,"functionName"),Bb(this,"message"),Bb(this,"handler"),Bb(this,"originError"),this.name=JF[t],this.code=t,this.extraCode=r,this.functionName=n,this.originError=a,this.message=c,5302===this.extraCode&&null!=(s=this.originError)&&s.message.includes("system")&&(this.handler=()=>{let e=document.createElement("a");WN?e.href="ms-settings:privacy-".concat({startLocalVideo:"webcam",startLocalAudio:"microphone"}[this.functionName]):jN&&(e.href="x-apple.systempreferences:com.apple.preference.security?Privacy_".concat({startLocalVideo:"Camera",startLocalAudio:"Microphone",startScreenShare:"ScreenCapture"}[this.functionName])),e.href.length>0&&e.click()})}static convertFrom(t,r,i){let o=t;if(t instanceof $b){let{stack:n}=t,a={code:YF.UNKNOWN_ERROR,fnName:r,originError:t};switch(t.getCode()){case Jb.INVALID_PARAMETER:a.code=YF.INVALID_PARAMETER,a.message=t.message;break;case Jb.INVALID_OPERATION:a.code=YF.INVALID_OPERATION;break;case Jb.NOT_SUPPORTED:case Jb.NOT_SUPPORTED_H264:a.code=YF.ENV_NOT_SUPPORTED,t.getCode()===Jb.NOT_SUPPORTED_H264&&(a.extraCode=t.message.includes(eM.NOT_SUPPORTED_H264ENCODE)?5203:5204);break;case Jb.JOIN_ROOM_FAILED:a.messageParams={fnParams:i};case Jb.SERVER_TIMEOUT:case Jb.SWITCH_ROLE_FAILED:case Jb.SWITCH_ROOM_FAILED:a.code=YF.SERVER_ERROR,a.extraCode=t.getExtraCode();break;case Jb.API_CALL_ABORTED:a.code=YF.OPERATION_ABORT;break;case Jb.DEVICE_NOT_FOUND:case Jb.DEVICE_AUTO_RECOVER_FAILED:case Jb.INITIALIZE_FAILED:a.code=5300,t.name&&(a.extraCode=function(e){let t;switch(e){case"NotFoundError":t=5301;break;case"NotAllowedError":t=5302;break;case"NotReadableError":t=5303;break;case"OverconstrainedError":t=5304;break;case"InvalidStateError":t=5305;break;case"SecurityError":t=5306;break;case"AbortError":t=5307;break;default:t=5300}return t}(t.name));break;case Jb.UNKNOWN:break;default:a.code=YF.OPERATION_FAILED}o=new e(a),n&&(o.stack+=n.substr(n.indexOf("\n")))}else{if(t instanceof e)return t;o=new e({code:YF.UNKNOWN_ERROR,fnName:r,originError:t})}return o}};var ZF=QF;function eB(e){return"sub"===e?"auxiliary":"auxiliary"===e?"sub":"main"}function tB(e){return e===qF.QOS_PREFERENCE_CLEAR?"detail":e===qF.QOS_PREFERENCE_SMOOTH?"motion":""}function rB(e,t){let r=t?Mw:Ow;return qC(e)?Lb(Lb({},r),e):kw[e]?kw[e]:r}var iB={type:"object",properties:{cameraId:{type:"string"},useFrontCamera:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:["string","boolean"],values:[!0,!1,"view","publish","both"]},small:{type:["string","object","boolean"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack}}},oB={type:"object",properties:{systemAudio:{type:"boolean"},fillMode:{type:"string",values:["contain","cover","fill"]},profile:{type:["string","object"],properties:{width:{type:"number"},height:{type:"number"},frameRate:{type:"number"},bitrate:{type:"number"}}},videoTrack:{instanceOf:MediaStreamTrack},audioTrack:{instanceOf:MediaStreamTrack}}},nB={type:["string",HTMLElement,null,"array"],arrayItem:{instanceOf:HTMLElement},validate(e,t,r){if(oC(e)&&!document.getElementById(e))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5009,fnName:r,messageParams:{key:t}})}},aB={name:"userId",required:!0,type:"string"},sB={type:"object",properties:{microphoneId:{type:"string"},audioTrack:{instanceOf:MediaStreamTrack},captureVolume:{type:"number",min:0},earMonitorVolume:{type:"number",min:0,max:100},profile:{values:[qF.AUDIO_PROFILE_STANDARD,qF.AUDIO_PROFILE_STANDARD_STEREO,qF.AUDIO_PROFILE_HIGH,qF.AUDIO_PROFILE_HIGH_STEREO]},echoCancellation:{type:"boolean"},autoGainControl:{type:"boolean"},noiseSuppression:{type:"boolean"}}};function cB(e,t){if(!e)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5101,fnName:t})}function lB(e,t,r){if(!e)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5102,fnName:t,messageParams:{value:r}})}function uB(e,t,r){if(!(/^[1-9]\d*$/.test(String(e))&&e<4294967295))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5013,fnName:t,messageParams:{key:r}})}function dB(e,t,r){if(!/^[A-Za-z\d\s!#$%&()+\-:;<=.>?@[\]^_{}|~,]{1,64}$/.test(e))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5012,fnName:t,messageParams:{key:r}})}function hB(e){var t;if(null==(t=null==e?void 0:e.option)||!t.small)return;if(!xM())return Yk.warn("small stream is not supported"),void delete e.option.small;let r=rB(e.option.profile),i=rB(e.option.small,!0);return((e,t)=>e.width*e.height>=t.width*t.height&&e.frameRate>=t.frameRate&&e.bitrate>=t.bitrate)(r,i)?void 0:(Yk.warn("small stream profile must be less than big stream profile. Big: ".concat(JSON.stringify(r),", Small: ").concat(JSON.stringify(i))),void delete e.option.small)}var pB={create:[{name:"RoomConfig",instanceOf:Function},{name:"CreateConfig",type:"object",properties:{plugins:{type:"array",arrayItem:{instanceOf:Function}}}}],enterRoom:{name:"EnterRoomConfig",type:"object",required:!0,validate(e,t,r){if(this._room.isJoined)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5104,fnName:r});if(e.roomId){if(oC(e.roomId))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5016,fnName:r,messageParams:{key:t}});uB(e.roomId,r,t)}else{if(!e.strRoomId)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5015,fnName:r});dB(e.strRoomId,r,t)}},properties:{sdkAppId:{required:!0,type:"number",allowEmpty:!1},userId:{required:!0,type:"string",allowEmpty:!1},userSig:{required:!0,type:"string",allowEmpty:!1},scene:{type:"string",values:["live","rtc"]},role:{type:"string",values:["audience","anchor"]},roomId:{type:["string","number"]},strRoomId:{type:"string"},proxy:{type:["object","string"],properties:{websocketProxy:{type:"string"},turnServer:{type:["object","array"],properties:{url:{required:!0,type:"string"},username:{type:"string"},credential:{type:"string"},credentialType:{type:"string",values:["password"]}}},loggerProxy:{type:"string"},webtransportProxy:{type:"string"}}},enableAutoPlayDialog:{type:"boolean"},userDefineRecordId:{type:"string"},latencyLevel:{type:"number"},playoutDelay:{type:"object",properties:{min:{type:"number",min:0,max:1e3},max:{type:"number",min:0,max:1e4}}}}},startLocalVideo:{name:"LocalVideoConfig",type:"object",properties:{view:nB,mute:{type:["boolean","string"]},publish:{type:"boolean"},option:iB},validate(e){var t,r;if((null==(t=null==e?void 0:e.option)||!t.videoTrack)&&IM())throw new ZF({code:YF.ENV_NOT_SUPPORTED,extraCode:5201});null!=(r=null==e?void 0:e.option)&&r.small&&hB(e)}},updateLocalVideo:{name:"updateLocalVideoConfig",type:"object",required:!0,properties:{view:Pb(Lb({},nB),{required:!1}),publish:{type:"boolean"},mute:{type:["boolean","string"]},option:iB},validate(e){var t;null!=(t=null==e?void 0:e.option)&&t.small&&hB(e)}},startLocalAudio:{name:"LocalAudioConfig",type:"object",properties:{publish:{type:"boolean"},option:sB},validate(e){var t;if((null==(t=null==e?void 0:e.option)||!t.audioTrack)&&IM())throw new ZF({code:YF.ENV_NOT_SUPPORTED,extraCode:5201})}},updateLocalAudio:{name:"updateLocalAudioConfig",type:"object",required:!0,properties:{publish:{type:"boolean"},mute:{type:"boolean"},option:sB}},startScreenShare:{name:"ScreenShareConfig",type:"object",properties:{view:nB,publish:{type:"boolean"},option:oB},validate(e,t,r,i,o){var n;if(null==(n=null==e?void 0:e.option)||!n.videoTrack){if(IM())throw new ZF({code:YF.ENV_NOT_SUPPORTED,extraCode:5201});if(!DM())throw new ZF({code:YF.ENV_NOT_SUPPORTED,fnName:r,extraCode:5205})}}},updateScreenShare:{name:"updateScreenShareConfig",type:"object",required:!0,properties:{view:nB,publish:{type:"boolean"},option:oB}},muteRemoteAudio:[aB,{name:"mute",required:!0,type:"boolean"}],setRemoteAudioVolume:[aB,{name:"volume",required:!0,type:"number",min:0}],startRemoteVideo:{name:"startRemoteVideoConfig",type:"object",required:!0,properties:{view:nB,userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){cB(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(lB(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new ZF({code:YF.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},updateRemoteVideo:{name:"updateRemoteVideoConfig",type:"object",required:!0,properties:{view:Pb(Lb({},nB),{required:!1}),userId:{type:"string",required:!0},streamType:{values:["main","sub"],required:!0},option:{type:"object",properties:{fillMode:{type:"string",values:["contain","cover","fill"]},mirror:{type:"boolean"}}}},validate(e,t,r){cB(this._room.isJoined,r);let i=this._room.remotePublishedUserMap.get(e.userId);if(lB(!!i,r,e),i&&("main"===e.streamType&&!i.muteState.videoAvailable||"sub"===e.streamType&&!i.muteState.hasAuxiliary))throw new ZF({code:YF.INVALID_OPERATION,extraCode:5103,fnName:r,messageParams:{value:e}})}},stopRemoteVideo:{name:"stopRemoteVideoConfig",type:"object",required:!0,properties:{userId:{type:"string",required:!0},streamType:{values:["main","sub"]}},validate(e,t,r){if("*"!==e.userId&&iC(e.streamType))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5014,fnName:r})}},switchRole:{name:"role",required:!0,values:["anchor","audience"],validate(e,t,r){cB(this._room.isJoining||this._room.isJoined,r)}},enableAudioVolumeEvaluation:[{name:"interval",type:"number"},{name:"enableInBackground",type:"boolean"}],sendSEIMessage:[{name:"buffer",required:!0,instanceOf:ArrayBuffer,validate(e,t,r,i){if(!QM)throw new ZF({code:YF.ENV_NOT_SUPPORTED,fnName:r,extraCode:5207});if(!this._room.enableSEI)throw new ZF({code:YF.INVALID_OPERATION,fnName:r,extraCode:5108});if(e.byteLength>1e3)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5017,messageParams:{key:t},fnName:r});cB(this._room.isJoined,r)}},{name:"options",type:"object",properties:{seiPayloadType:{type:"number",values:[5,243]},toSubStream:{type:"boolean",validate(e,t,r){if(!e&&!this._room.isMainStreamPublished||e&&!this._room.isAuxStreamPublished)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5109,messageParams:{key:t},fnName:r})}}}}],sendCustomMessage:{name:"message",required:!0,type:"object",properties:{cmdId:{type:"number",required:!0,min:1,max:10},data:{instanceOf:ArrayBuffer,required:!0,validate(e,t,r,i){if(e.byteLength>1e3)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5018,fnName:r});if(0===e.byteLength)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5017,fnName:r,messageParams:{key:t}})}}},validate(e,t,r){if(cB(this._room.isJoined,r),"live"===this._room.scene&&"audience"===this._room.role)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5107,fnName:r,messageParams:{key:t}})}},switchRoom:{name:"switchRoomConfig",type:"object",required:!0,validate(e,t,r){if(cB(this._room.isJoined,r),this._room.useStringRoomId&&e.strRoomId===this._room.roomId||!this._room.useStringRoomId&&e.roomId===Number(this._room.roomId))throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5020,fnName:r,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId&&this._room.useStringRoomId||!e.roomId&&e.strRoomId&&!this._room.useStringRoomId)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5019,fnName:r,messageParams:{key:this._room.useStringRoomId?"strRoomId":"roomId"}});if(e.roomId)uB(e.roomId,r,t);else{if(!e.strRoomId)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5015,fnName:r});dB(e.strRoomId,r,t)}},properties:{roomId:{type:"number"},strRoomId:{type:"string"},privateMapKey:{type:"string"},autoSubscribeCount:{type:"number",min:0,max:50}}}},mB={TRTC:pB},fB=class extends Error{};function _B(e,t){let r=RC(e);for(let i=0;i<t.length;i++)SC(r[i],t[i]);return r}function gB(e){this._resolve=Promise.resolve(e)}function EB(e){this._reject=Promise.reject(e)}var vB=class e{constructor(t,r){this.instance=t,this.group=r,Bb(this,"started",!1),Bb(this,"ops",[]),Bb(this,"startSame",(()=>!0)),Bb(this,"mergeUpdate",_B);let i=e.instances.get(t);i?i.set(r,this):e.instances.set(t,new Map([[r,this]]))}static get(t,r){if(!r)return;let i=e.instances.get(t);return i&&i.get(r)||new e(t,r)}static gets(t,r){let i=e.instances.get(t),o=[];return i&&i.forEach(((e,t)=>{r.test(t)&&o.push(e)})),o}action(e,t,r){let i=t=>{var r;return 0===e?this.started=!0:3===e&&(this.started=!1),this.ops.shift(),null==(r=this.currentOp)||r.action(),t},o=t=>{var r,i;throw this.ops.shift(),0===e&&2===(null==(r=this.currentOp)?void 0:r.type)&&this.ops.shift().reject(new fB("start failed")),null==(i=this.currentOp)||i.action(),t},n={type:e,action:()=>t(...n.args).then(i,o),args:r,resolve:gB,reject:EB};try{switch(this.state){case 1:if(0===e)throw new fB("already started");break;case 4:if(2===e)throw new fB("not started");break;default:return this.cacheOp(n)}}catch(oO){return Promise.reject(oO)}return this.ops.push(n),n.promise=t(...n.args).then(i,o)}cacheOp(e){if(1===this.ops.length)switch(this.state){case 0:case 2:if(0===e.type)throw new fB("already start");break;case 3:switch(e.type){case 2:throw new fB("update not allowed when stopping");case 3:return this.currentOp.promise}break;default:throw new fB("unknown state")}else switch(e.type){case 3:if(3===this.lastOpType)return this.lastOp.promise;{let e=new fB("keep stop");if(this.ops.slice(1).forEach((t=>t.reject(e))),this.ops=this.ops.slice(0,1),3===this.state)return this.currentOp.promise}break;case 2:switch(this.lastOpType){case 2:return this.lastOp.args=this.mergeUpdate(this.lastOp.args,e.args),this.lastOp.promise;case 3:throw new fB("update not allowed after stop")}break;case 0:switch(this.lastOpType){case 2:throw new fB("start not allowed after update");case 0:throw new fB("duplicate start");case 3:if(this.startSame(this.currentOp.args,e.args))throw this.ops.pop().reject(new fB("keep start")),new fB("already start")}}e.promise=new Promise(((t,r)=>{e._resolve?e._resolve.then(t):e.resolve=t,e._reject?e._reject.catch(r):e.reject=r}));let{action:t}=e;return e.action=()=>t().then(e.resolve,e.reject),this.ops.push(e),e.promise}get lastOp(){return this.ops[this.ops.length-1]}get lastOpType(){return this.lastOp.type}get currentOp(){return this.ops[0]}get state(){return this.currentOp?this.currentOp.type:this.started?1:4}};Bb(vB,"instances",new WeakMap);var yB=vB,TB=new WeakMap,IB=(e,t)=>{if(t instanceof fB){let{stack:r}=t;t=new ZF({code:YF.OPERATION_ABORT,message:"".concat(e," abort: ").concat(t.message),fnName:e}),r&&(t.stack+=r.substr(r.indexOf("\n")))}throw t};function AB(e,t){return JP(((r,i)=>function(){for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];let s=yB.get(this,"string"==typeof e?e:e.call(this,...n));return s?(t&&(s.startSame=t.bind(this)),s.action(0,r.bind(this),n).catch(IB.bind(null,i))):r.apply(this,n)}))}function SB(e,t){let{merge:r,debounce:i}=t||{};return JP(((t,o)=>function(){for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];let c=yB.get(this,"string"==typeof e?e:e.call(this,...a));if(!c)return t.apply(this,a);if(r&&(c.mergeUpdate=r.bind(this)),i&&i.isNeedToDebounce.apply(this,a)){let{delay:e,getKey:r}=i;return new Promise(((i,n)=>{var s,l;let u=null==(s=TB.get(this))?void 0:s.get(r(...a));if(u){let{timeoutId:e,resolve:t}=u;clearTimeout(e),t()}let d=setTimeout((()=>{if(3===c.state||4===c.state)return i();c.action(2,t.bind(this),a).catch(IB.bind(null,o)).then(i,n)}),e);TB.has(this)?null==(l=TB.get(this))||l.set(r(...a),{timeoutId:d,resolve:i}):TB.set(this,new Map([[r(...a),{timeoutId:d,resolve:i}]]))}))}return c.action(2,t.bind(this),a).catch(IB.bind(null,o))}))}function RB(e){return JP(((t,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a="function"==typeof e?e.call(this,...o):e;if(a instanceof RegExp)return Promise.all(yB.gets(this,a).map((e=>e.action(3,(()=>Promise.resolve()),o)))).then((()=>t.call(this,...o)));let s=yB.get(this,a);return s?s.action(3,t.bind(this),o).catch(IB.bind(null,r)):t.apply(this,o)}))}var bB={ERROR:"error",AUTOPLAY_FAILED:"autoplay-failed",KICKED_OUT:"kicked-out",REMOTE_USER_ENTER:"remote-user-enter",REMOTE_USER_EXIT:"remote-user-exit",REMOTE_AUDIO_AVAILABLE:"remote-audio-available",REMOTE_AUDIO_UNAVAILABLE:"remote-audio-unavailable",REMOTE_VIDEO_AVAILABLE:"remote-video-available",REMOTE_VIDEO_UNAVAILABLE:"remote-video-unavailable",AUDIO_VOLUME:"audio-volume",AUDIO_FRAME:"audio-frame",NETWORK_QUALITY:"network-quality",CONNECTION_STATE_CHANGED:"connection-state-changed",AUDIO_PLAY_STATE_CHANGED:"audio-play-state-changed",VIDEO_PLAY_STATE_CHANGED:"video-play-state-changed",SCREEN_SHARE_STOPPED:"screen-share-stopped",DEVICE_CHANGED:"device-changed",PUBLISH_STATE_CHANGED:"publish-state-changed",TRACK:"track",STATISTICS:"statistics",SEI_MESSAGE:"sei-message",CUSTOM_MESSAGE:"custom-message",VIDEO_DECODE_DOWNGRADE_STATE_CHANGED:"video-decode-downgrade-state-changed",LAYER_DATA:"layerData",FIRST_VIDEO_FRAME:"first-video-frame"},wB=new Set([bB.ERROR,bB.AUTOPLAY_FAILED,bB.KICKED_OUT,bB.REMOTE_USER_ENTER,bB.REMOTE_USER_EXIT,bB.REMOTE_AUDIO_AVAILABLE,bB.REMOTE_AUDIO_UNAVAILABLE,bB.REMOTE_VIDEO_AVAILABLE,bB.REMOTE_VIDEO_UNAVAILABLE,bB.CONNECTION_STATE_CHANGED,bB.PUBLISH_STATE_CHANGED,bB.SCREEN_SHARE_STOPPED,bB.DEVICE_CHANGED,bB.FIRST_VIDEO_FRAME]),DB={};Ub(DB,{bytes2ms:()=>zD,calculateScaleResolutionDownNumber:()=>BC,convertObjectNumberToInt:()=>PC,copyProperties:()=>KD,deepClone:()=>RC,deepMerge:()=>SC,delay:()=>xC,fibonacci:()=>ZD,formatedTime:()=>DC,getConstructorName:()=>pC,getContainerFromElement:()=>wC,getEnv:()=>UD,getInternalVersion:()=>EC,getLoggerUrl:()=>FD,getMediaStreamTrackInfo:()=>FC,getMuteStateFromFlag:()=>TC,getNetworkType:()=>HD,getNumNetworkType:()=>GD,getReconnectionTimeout:()=>eC,getStringByteLength:()=>kC,getTurnServer:()=>IC,getUint32Version:()=>LC,getValueType:()=>tC,getViewListFromView:()=>bC,glog:()=>XD,ipv4ToUint32:()=>AC,isArray:()=>cC,isAudioWorkletSupported:()=>mC,isBoolean:()=>aC,isConstructor:()=>hC,isEmpty:()=>yC,isFunction:()=>rC,isLangChinese:()=>$D,isMediaStreamTrack:()=>lC,isNumber:()=>nC,isObject:()=>sC,isOverseaSdkAppId:()=>VD,isPlainObject:()=>QD,isPortrait:()=>OC,isPromise:()=>dC,isRemoteTrack:()=>uC,isRotate90Or270:()=>HC,isString:()=>oC,isUndefined:()=>iC,loadImage:()=>MC,ms2bytes:()=>YD,ms2samples:()=>JD,normalizeUrl:()=>VC,performanceNow:()=>_C,promiseAny:()=>fC,samples2ms:()=>qD,setNetworkType:()=>jD,stringify:()=>CC,stringifyIncludeValue:()=>NC,throttlePromise:()=>UC});var CB={};Ub(CB,{ScheduleRequestType:()=>xB,getAbilityConfig:()=>VB,getScheduleDomain:()=>FB,isNeedToSchedule:()=>kB,scheduleProxy:()=>LB,sendScheduleRequest:()=>MB,setIsNeedToSchedule:()=>OB,setScheduleProxy:()=>PB});var NB=null,kB=!0;function OB(e){aC(e)&&e!==kB&&(kB=e,Yk.info("setIsNeedToSchedule ".concat(e)))}function MB(e){return Wb(this,arguments,(function(e){let{userId:t,sdkAppId:r,useStringRoomId:i,roomId:o,userSig:n,version:a,frameWorkType:s,role:c,latencyLevel:l}=e;return function*(){if(!kB&&NB)return{isCached:!0,result:NB};let e={delta:0,count:[1,1],msg:[],detail:[]};try{let u=new FormData;u.append("userId",String(t)),u.append("sdkAppId",String(r)),u.append("isStrGroupId",String(i)),u.append("groupId",String(o)),u.append("sdkVersion",a),u.append("userSig",String(n)),c&&u.append("role",String(c)),l&&u.append("latencyLevel",String(l)),s&&u.append("frameWorkType",String(s));let d=_C(),h=yield function(e,t,r){return new Promise(((i,o)=>{let n=null;fC([HB((e=>t.count[0]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[0]=i.message,n||(a>=1&&(s[0]=UB(r,"config",Pw.MAIN,!0)),o())}))(UB(r,"config",Pw.MAIN),e,{get timeout(){return 1e3*ZD(2+t.count[0])}}),HB((e=>t.count[1]=e+1),(e=>{let{error:i,retry:o,retriedCount:a,retryFuncArgs:s}=e;t.msg[1]=i.message,n||(a>=2&&(s[0]=UB(r,"config",Pw.BACKUP,!0)),o())}))(UB(r,"config",Pw.BACKUP),e,{get timeout(){return 1e3*ZD(2+t.count[1])}})]).then((e=>{n=e,i(n)})).catch(o)}))}(u,e,r);h.config&&(h.config.loggerDomain&&hw(h.config.loggerDomain),aC(h.config.scheduleCache)&&OB(!h.config.scheduleCache)),e.delta=_C()-d;let p=function(e,t,r){let i={totalCost:0,local:0,dns:0,tcp:0,tls:0,request:0,response:0};try{let o=performance.getEntriesByType("resource"),n=UB(e,"config",Pw.MAIN),a=UB(e,"config",Pw.BACKUP);for(let e of o)if(e.startTime>=r&&(e.name===n||e.name===a)&&e.transferSize>0){let r=e.name===n?Pw.MAIN:Pw.BACKUP,o=Math.round(e.duration),a=Math.round(e.domainLookupStart-e.startTime),s=e.redirectStart>0?Math.round(e.redirectEnd-e.redirectStart):0,c=e.fetchStart>0?Math.round(e.domainLookupStart-e.fetchStart):0,l=Math.round(e.domainLookupEnd-e.domainLookupStart),u=Math.round(e.requestStart-e.secureConnectionStart),d=Math.round(e.secureConnectionStart-e.connectStart),h=Math.round(e.responseStart-e.requestStart),p=Math.round(e.responseEnd-e.responseStart),m=[l,u,d,h,p];NL.uploadEvent({log:"stat-schedule-net:".concat(o,"(").concat(a,"(").concat(s,"->").concat(c,")->").concat(m.join("->"),") ").concat(r),userId:t}),i=Pb(Lb({},i),{totalCost:o,local:a,dns:l,tcp:d,tls:u,request:h,response:p});break}}catch(n){Yk.error("getScheduleDetailCost error",n)}return i}(Number(r),t,d);return NB=h,{isCached:!1,result:h,detailCost:p}}catch(oM){let t=cC(oM)?oM[0]:oM,r=nC(t.code)?t.code:0,i="schedule failed".concat(t.message?": ".concat(t.message):""),o=new $b({code:Jb.SCHEDULE_FAILED,extraCode:r,message:iM({key:ZO.JOIN_ROOM_FAILED,data:{error:i,code:r}})});throw Yk.error(i,r),o}}()}))}"undefined"!=typeof document&&document.head.insertAdjacentHTML("beforeend",Object.values(SD).map((e=>'<link rel="dns-prefetch" href="https://'.concat(e,'">'))).join("\r\n")),Gk.on("28",(()=>OB(!0))),Gk.on("63",(()=>OB(!0))),Gk.on("84",(()=>OB(!0))),Gk.on("201",(e=>{"RECONNECTING"===e.state&&OB(!0)})),Gk.on("202",(e=>{"RECONNECTING"===e.state&&OB(!0)}));var LB={main:"",backup:""};function PB(e){cC(e)?(LB.main=e[0],LB.backup=e[1]):LB.main=e}var xB=(e=>(e.CONFIG="config",e.TRTC_AUTO_CONF="trtcAutoConf",e.AUDIO_AI_AUTH="audioAiAuth",e))(xB||{});function UB(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Pw.MAIN,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return"https://".concat(LB[r]||FB(e,r,i),"/api/v1/").concat(t)}function VB(e,t,r){let i=UB(e,t),o=UB(e,t,Pw.BACKUP),n=new URLSearchParams(r).toString();return fC([fetch("".concat(i,"?").concat(n)).then((e=>e.json())),fetch("".concat(o,"?").concat(n)).then((e=>e.json()))])}function FB(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Pw.MAIN,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=VD(e)?i?r===Pw.MAIN?SD.MAIN_OVERSEA_BACKUP:SD.BACKUP_OVERSEA:r===Pw.MAIN?SD.MAIN_OVERSEA:SD.BACKUP_OVERSEA:r===Pw.MAIN?SD.MAIN:SD.BACKUP,t}function BB(e,t,r){return new Promise(((i,o)=>{WC({url:e,body:t,timeout:r.timeout,priority:"high"}).then((e=>{0===e.data.code?i(e.data.data):o({code:e.data.code,message:e.data.msg})})).catch(o)}))}var HB=(e,t)=>YC({retryFunction:BB,settings:{retries:3,timeout:0},onError:t,onRetrying:e});var WB=class{constructor(){Bb(this,"_log"),this._log=Yk.createLogger({id:"fd"})}download(e,t){return Wb(this,null,(function*(){let{type:r="blob"}=t||{};e=VC(e);try{let t,i=_C();if(t=rC(fetch)?yield this.downloadWithFetch(e,r):yield this.downloadWithXHR(e,r),!t||!t.data)throw new Error("data is empty");let o=_C()-i;return this._log.info("downloaded: ".concat(e,", return type: ").concat(r,", cost: ").concat(o,"ms")),mM.addSuccessEvent({key:522700,cost:_C()-i}),t.data}catch(iO){throw this._log.error("failed to download: ".concat(e,", error: ").concat(iO)),mM.addFailedEvent({key:522700,error:iO}),iO}}))}downloadWithFetch(e,t){return Wb(this,null,(function*(){this._log.info("download with fetch: ".concat(e,", return type: ").concat(t));try{let r,i=yield fetch(e);if(!i.ok)throw new Error("network response was not ok");return r="arraybuffer"===t?yield i.arrayBuffer():yield i.blob(),{data:r}}catch(lD){throw lD}}))}downloadWithXHR(e,t){return this._log.info("download with xhr: ".concat(e,", return type: ").concat(t)),new Promise(((r,i)=>{let o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType=t,o.onload=()=>{200===o.status||0===o.status&&o.response?r({data:o.response}):i(new Error("XHR failed"))},o.onerror=i,o.send(null)}))}loadWasm(e,t){return Wb(this,null,(function*(){this._log.info("loadWasm ".concat(e,", importObject: ").concat(JSON.stringify(t)));let r=_C(),i=null,o=null;if(rC(WebAssembly.instantiateStreaming)&&!(e=>e.startsWith("data:application/octet-stream;base64,"))(e)&&!(e=>e.startsWith("file://"))(e)&&rC(fetch))try{let r=fetch(e);i=(yield WebAssembly.instantiateStreaming(r,t)).instance}catch(sw){o=sw}if(!i)try{let r=yield this.download(e,{type:"arraybuffer"});i=(yield WebAssembly.instantiate(r,t)).instance}catch(sw){o=sw}if(i){let t=_C()-r;return this._log.info("loadedWasm ".concat(e,", cost: ").concat(t,"ms")),mM.addSuccessEvent({key:522701,cost:t}),i}throw this._log.error("failed to loadWasm ".concat(e,", error: ").concat(o)),mM.addFailedEvent({key:522701,error:o}),o}))}loadScript(e){this._log.info("loadScript ".concat(e));let t=_C();return new Promise(((r,i)=>{let o=document.createElement("script");o.type="text/javascript",o.onload=()=>{this._log.info("loadedScript ".concat(e,", cost: ").concat(_C()-t,"ms")),mM.addSuccessEvent({key:522702,cost:_C()-t,split:1e3}),r(o)},o.onerror=t=>{this._log.error("failed to loadScript ".concat(e,", error: ").concat(t)),mM.addFailedEvent({key:522702}),i(t)},o.crossOrigin="anonymous",o.src=e,document.head.append?document.head.append(o):document.getElementsByTagName("head")[0].appendChild(o)}))}};Fb([OL({settings:{timeout:0,retries:3},onRetrying(e){this._log.warn("download retrying: ".concat(e))}})],WB.prototype,"download",1),Fb([OL({settings:{timeout:3e3,retries:3},onRetrying(e){this._log.warn("loadScript retrying: ".concat(e))}})],WB.prototype,"loadScript",1);var jB=new WB;function GB(e){let{TRTC:t,room:r,errorModule:i,assetsPath:o}=e;return{TRTC:t,room:r,assetsPath:o,fileDownloader:jB,innerEmitter:Gk,constants:rw,environment:XC,utils:DB,eventLogger:NL,log:this.room.getLogger(),loggerManager:Yk,errorModule:i,kvStatManager:mM,rtcDectection:$k,trtc:this,rx:vx,enums:Qk,schedule:CB,clearStarted:(e,t)=>{let r=e.getAlias(),i=yB.instances.get(this);if(i)if(t){let e=i.get(r+t);if(!e)return;e.started=!1}else i.forEach(((e,t)=>{t.startsWith(r)&&(e.started=!1)}))},startGetPCM:gx,createAudioNode:gP}}var KB=new WeakMap;function zB(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return JP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{YB.call(this,t,o,r,this._name)}catch(iO){return Promise.reject(iO)}return e.apply(this,o)}))}function qB(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return JP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{YB.call(this,t,o,r,this._name)}catch(iO){throw iO}return e.apply(this,o)}))}function YB(e,t,r,i){if(cC(e))for(let o=0;o<e.length;o++)JB.call(this,{rule:e[o],value:t[o],key:e[o].name,fnName:r,className:i});else JB.call(this,{rule:e,value:t[0],key:e.name,fnName:r,className:i})}function JB(e){let{rule:t,value:r,key:i,fnName:o,className:n}=e;function a(e){return{code:YF.INVALID_PARAMETER,extraCode:e,fnName:o,messageParams:{key:i,rule:t,value:r}}}if(iC(r)){if(t.required)throw new ZF(a(5001));if(iC(t.defaultValue))return void(rC(t.validate)&&t.validate.call(this,r,i,o,n,this));r=t.defaultValue}if(Array.isArray(t.type)){let e=!1;for(let i=0;i<t.type.length;i++)null===t.type[i]&&null===r&&(e=!0),rC(t.type[i])&&r instanceof t.type[i]&&(e=!0),oC(t.type[i])&&tC(r)===t.type[i].toLowerCase()&&(e=!0);if(!e)throw new ZF({code:YF.INVALID_PARAMETER,extraCode:5002,fnName:o,messageParams:{key:i,rule:{type:t.type.map((e=>hC(e)?pC(e):oC(e)?e:tC(e)))},value:r}})}else if(!iC(t.type)&&tC(r)!==t.type)throw new ZF(a(5002));if(!1===t.allowEmpty){let e=nC(r)&&(0===r||Number.isNaN(r)),t=oC(r)&&""===r.trim();if(e||t)throw new ZF(a(5003))}if(t.notLessThanZero&&nC(r)&&r<0)throw new ZF(a(5006));if(!iC(t.min)&&nC(r)&&r<t.min)throw new ZF(a(5007));if(!iC(t.max)&&nC(r)&&r>t.max)throw new ZF(a(5008));if(oC(t.instanceOf)){if(!r||r._name!==t.instanceOf)throw new ZF(a(5004))}else if(rC(t.instanceOf)&&!(r instanceof t.instanceOf))throw new ZF(a(5004));if(Array.isArray(t.values)&&!t.values.includes(r))throw new ZF(a(5005));let{properties:s}=t;QD(s)&&sC(r)&&Object.keys(s).forEach((e=>{JB.call(this,{rule:s[e],value:r&&r[e],key:"".concat(e),fnName:o,className:n})}));let{arrayItem:c}=t;QD(c)&&cC(r)&&r.forEach(((e,t)=>{JB.call(this,{rule:c,value:e,key:"".concat(i,"[").concat(t,"]"),fnName:o,className:n})})),rC(t.validate)&&t.validate.call(this,r,i,o,n,this)}function XB(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{getRemoteId:t=()=>"",replaceArg:r,getKVReportKey:i,ignoreLog:o}=e;return JP(((e,n)=>function(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];var l,u,d;function h(e,t,i){if(i&&i.includes(e))return"hided";if(r){let e=r(...s);if(s[e.argIndex]===t)return e.value}if(t===s||e in s)return t;try{return t instanceof HTMLElement?"id: ".concat(t.id," type:").concat(tC(t)):t instanceof MediaStreamTrack?FC(t):(JSON.stringify(t),t)}catch(o){return"type:".concat(tC(t))}}let p=this._log||Yk;if(null!=o&&o(...s))return e.apply(this,s);s.length>0?p.info("".concat(n,"() ").concat(JSON.stringify(s,((e,t)=>h(e,t,["userSig","privateMapKey"]))))):p.info("".concat(n,"()"));let m=i?i(...s):cM[n];try{let r=e.apply(this,s),i=_C();if(dC(r)){let e="".concat(n.includes("Plugin")?"".concat((null==(u=(l=s[0]).getName)?void 0:u.call(l))||""," "):" ");return r.then((r=>(p.info("".concat(n,"() success ").concat(e).concat(t.call(this,...s))),mM.addSuccessEvent({key:m,cost:_C()-i}),r))).catch((r=>{var i;let o=(r=ZF.convertFrom.call(this,r,n,1===s.length?s[0]:s)).extraCode||r.code,a=null!=(i=r.message)&&i.includes(o)?"":" code:".concat(o);throw p.error("".concat(n,"() failed ").concat(e).concat(t.call(this,...s)," ").concat(r).concat(a," params: ").concat(JSON.stringify(s,h))),mM.addFailedEvent({key:m,error:r}),r}))}return mM.addSuccessEvent({key:m}),r}catch(f){let e=(f=ZF.convertFrom.call(this,f,n)).extraCode||f.code,t=null!=(d=f.message)&&d.includes(e)?"":" code:".concat(e);throw p.error("".concat(n,"() failed ").concat(f).concat(t," params: ").concat(JSON.stringify(s,h))),mM.addFailedEvent({key:m,error:f}),f}}))}var $B=e=>JP(((t,r)=>function(i,o){return Wb(this,null,(function*(){let n=this._plugins.get(i);if(!n)throw this._log.error("plugin ".concat(String(i)," is not found")),new ZF({code:YF.OPERATION_ABORT,message:"plugin ".concat(String(i)," is not found"),fnName:r});if(rC(n.constructor.isSupported)&&!n.constructor.isSupported())throw this._log.error("plugin ".concat(String(i)," is not supported")),new ZF({code:YF.ENV_NOT_SUPPORTED,message:"plugin ".concat(String(i)," is not supported"),extraCode:5210,fnName:r});return YB.call(this,n.getValidateRule(e),[o],r,"TRTC"),t.call(this,n,o)}))})),QB=0,ZB=class{constructor(e,t){Bb(this,"player"),Bb(this,"publisher"),Bb(this,"mixInput"),this.mixInput=new mP(t),e.url?(this.player=new Audio(e.url),this.player.crossOrigin="anonymous",this.publisher=new Audio(e.url),this.publisher.crossOrigin="anonymous",this.mixInput.replaceSource(this.publisher)):this.mixInput.replaceSource(e.track),this.mixInput.connect()}updateSettings(e){this.player&&(iC(e.volume)||(this.volume=e.volume),iC(e.loop)||(this.loop=e.loop),iC(e.playbackRate)||(this.playbackRate=e.playbackRate))}updateListener(e){if(this.player){if(e.onDurationChange){let{onDurationChange:t}=e;this.player.ondurationchange=e=>{t(e.target.duration)}}if(e.onTimeUpdate){let t=e.onTimeUpdate,{player:r}=this;r.ontimeupdate=()=>{t(r.currentTime,r.duration)}}e.onEnded&&(this.player.onended=e.onEnded)}}reset(){this.seek(0),this.mixInput.connect()}seek(e){this.player&&(e<0&&e>this.player.duration||(this.player.currentTime=e,this.publisher.currentTime=e))}play(){var e,t;return null==(e=this.publisher)||e.play(),null==(t=this.player)?void 0:t.play()}pause(){var e,t;null==(e=this.player)||e.pause(),null==(t=this.publisher)||t.pause()}stop(){var e;null==(e=this.player)||e.pause(),this.mixInput.disconnect()}setOperation(e){"pause"===e&&this.pause(),"resume"===e&&(this.pause(),this.play()),"stop"===e&&(this.pause(),this.seek(0))}set volume(e){!this.player||!this.publisher||(this.player.volume=e,this.publisher.volume=e)}set loop(e){!this.player||!this.publisher||(this.player.loop=e,this.publisher.loop=e)}set playbackRate(e){!this.player||!this.publisher||(this.player.playbackRate=e,this.publisher.playbackRate=e)}};function eH(e,t){if(t&&"function"!=typeof t)throw new ZF({code:YF.INVALID_PARAMETER,message:"start audioMixer plugin: param ".concat(e," should be a function.")})}var tH=class e{constructor(e){this.core=e,Bb(this,"log"),Bb(this,"mixedMusicMap",new Map),Bb(this,"cacheMusicMap",new Map),QB+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(QB)}),this.log.info("[audioMixer] created id=".concat(this.getAlias()).concat(QB))}getName(){return e.Name}getAlias(){return"ax"}getGroup(e){return null==e?void 0:e.id}getValidateRule(t){switch(t){case"start":return e.startValidateRule;case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return Wb(this,null,(function*(){let{room:t}=this.core;this.log.info("add music source, id: ".concat(e.id," url: ").concat(e.url,", track: ").concat(e.track));let{id:r,url:i}=e;if(this.mixedMusicMap.has(r))return;let o=this.cacheMusicMap.get(r);o?e.url?o.reset():(o.mixInput.replaceSource(e.track),o.mixInput.connect()):(o=new ZB(e,t.audioManager),this.cacheMusicMap.set(r,o)),o.updateListener(e),o.updateSettings(e),yield o.play(),this.mixedMusicMap.set(r,o),this.log.info("start mix audio track ".concat(r," success.")),mM.addEnum({key:502700,value:3}),this.kvUpload(e)}))}update(e){return Wb(this,null,(function*(){let{id:t,operation:r,seekFrom:i,playbackRate:o}=e;this.log.info("update music source, ".concat(JSON.stringify(e)));let n=this.mixedMusicMap.get(t);n?(n.updateSettings(e),n.updateListener(e),iC(r)||n.setOperation(r),iC(i)||n.seek(i),this.kvUpload(e)):this.log.warn("update music source failed, music id: ".concat(t," not found."))}))}stop(e){return Wb(this,arguments,(function(e){var t=this;let{id:r}=e;return function*(){var e;t.mixedMusicMap.has(r)&&(t.log.info("remove music source, music id: ".concat(r)),null==(e=t.mixedMusicMap.get(r))||e.stop(),t.mixedMusicMap.delete(r)),"*"===r&&t.destroyAllMusic()}()}))}kvUpload(e){let{track:t,loop:r,volume:i,playbackRate:o,operation:n,seekFrom:a,onTimeUpdate:s,onDurationChange:c,onEnded:l}=e;t&&mM.addCount({key:502711}),r&&mM.addCount({key:502703}),i&&mM.addCount({key:502704}),o&&mM.addCount({key:502705}),n&&mM.addCount({key:502706}),a&&mM.addCount({key:502707}),"function"!=typeof s&&mM.addCount({key:502709}),"function"!=typeof l&&mM.addCount({key:502710}),"function"!=typeof c&&mM.addCount({key:502708})}destroyAllMusic(){this.log.info("destroy all music source."),this.mixedMusicMap.forEach(((e,t)=>this.stop({id:t})))}destroyAllCache(){this.log.info("destroy all music cache."),this.cacheMusicMap.clear()}destroy(){this.log.info("destroy audio mixer plugin."),this.destroyAllMusic(),this.destroyAllCache()}};Bb(tH,"startValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},url:{type:"string",required:!1},track:{required:!1},loop:{type:"boolean"},volume:{type:"number"}},validate(e,t,r){if(e.url&&"*"!==e.url){let t=e.url.split("?")[0],i=["mp3","ogg","wav","flac"],o=t.split(".").pop(),n=i.indexOf(o)>=0,a=t.startsWith("blob"),s=t.startsWith("data");if(!(n||a||s))throw new ZF({code:YF.INVALID_PARAMETER,message:"start audioMixer plugin: music url is invalid, please check your file format.",fnName:r})}if(!e.url&&!e.track)throw new ZF({code:YF.INVALID_PARAMETER,message:"start audioMixer plugin: param url or track is required.",fnName:r});eH("onTimeUpdate",e.onTimeUpdate),eH("onEnded",e.onEnded),eH("onDurationChange",e.onDurationChange)}}),Bb(tH,"updateValidateRule",{name:"options",required:!0,type:"object",properties:{id:{type:"string",required:!0},loop:{type:"boolean"},volume:{type:"number"},seekFrom:{type:"number"},operation:{type:"string",values:["pause","resume","stop"]}},validate(e,t,r){eH("onTimeUpdate",e.onTimeUpdate),eH("onEnded",e.onEnded),eH("onDurationChange",e.onDurationChange)}}),Bb(tH,"stopValidateRule",{name:"options",type:"object",required:!0,properties:{id:{type:"string",required:!0}}}),Bb(tH,"Name","AudioMixer");var rH,iH=tH,oH=0,nH=class e{constructor(e){this.core=e,Bb(this,"log"),Bb(this,"audioContext",uP()),Bb(this,"workletNode"),oH+=1,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(oH)}),this.log.info("[audioDenoiser] created id=".concat(this.getAlias()).concat(oH)),e.assetsPath&&this.preload("".concat(e.assetsPath,"/denoiser-wasm.js")).catch((e=>{}))}static startValidateRule(e){return{name:"options",required:!0,type:"object",properties:{sdkAppId:{type:"number",required:!0},userId:{type:"string",required:!0},userSig:{type:"string",required:!0}},validate(t,r,i,o){if(!e.room.audioManager.hasAudioTrack)throw new ZF({code:YF.INVALID_OPERATION,extraCode:5106,fnName:i})}}}preload(e){return rH||(rH=this.doPreload(e)),rH}doPreload(e){return Wb(this,null,(function*(){let t=yield this.core.fileDownloader.download(e,{type:"blob"}),r=URL.createObjectURL(t);try{yield iP(this.audioContext,r)}catch(iO){throw this.log.error("load worklet failed",iO),iO}finally{URL.revokeObjectURL(r)}}))}getName(){return e.Name}getAlias(){return"ad"}getGroup(){return"AIDenoiser_".concat(Date.now())}getValidateRule(t){switch(t){case"start":return e.startValidateRule(this.core);case"update":return e.updateValidateRule;case"stop":return e.stopValidateRule}}start(e){return Wb(this,null,(function*(){let{room:t,schedule:r}=this.core;if(yield this.preload("".concat(e.assetsPath,"/denoiser-wasm.js")),!this.workletNode){let t=String(Date.now()).slice(0,-3),{auth:i,sign:o,status:n,message:a}=yield function(e,t){return Wb(this,arguments,(function(e,t){let{sdkAppId:r,userId:i,userSig:o,timestamp:a}=t;return function*(){try{let{data:{errCode:t,errMsg:n,sign:s,status:c}}=yield e.getAbilityConfig(r,e.ScheduleRequestType.AUDIO_AI_AUTH,{sdkAppId:r,userId:i,userSig:o,timestamp:a});if("1"===c)return{auth:!0,sign:s,status:c,message:n};let l=VD(r)?"https://trtc.io/document/42734?platform=web&product=rtcengine&menulabel=coresdk":"https://cloud.tencent.com/document/product/647/44247",u="Init RTCAIDenoiser failed.",d="";switch(t){case 1:d="Please check your params.";break;case 2:d="You need to buy packages. Refer to: ".concat(l);break;case 3:d="Server is invalid. Please contact our engineer. ";break;case 4:d="Your packages is not active. Refer to: ".concat(l);break;case 5:d="Your packages is expired. Refer to: ".concat(l);break;case 6:d="Your version is not supported."}return{auth:!1,status:c,message:n?"".concat(u," Reason: ").concat(n,". ").concat(d):"".concat(u,", ").concat(d)}}catch(n){return{auth:!1,status:"0",message:"Init RTCAIDenoiser failed. All requests failed. ".concat(n)}}}()}))}(r,Pb(Lb({},e),{timestamp:t}));if(!i)throw this.log.info("RTCAIDenoiser: ".concat(e.userId," auth result: ").concat(i,". Message: ").concat(a)),new ZF({code:YF.INVALID_PARAMETER,message:a});this.workletNode=new AudioWorkletNode(this.audioContext,"trtc-denoiser-processor",{numberOfInputs:1,numberOfOutputs:1}),this.workletNode.port.postMessage({type:"init",data:{sdkAppId:String(e.sdkAppId),userId:e.userId,timestamp:t,sign:o,status:n}}),this.workletNode.port.onmessage=e=>{var t;let{data:r}=e;if("cost"===r.type){let e=(null==r?void 0:r.max)>20?"warn":(null==r?void 0:r.max)>10?"info":"debug";this.log[e]("avg cost: ".concat(r.value," max: ").concat(null==r?void 0:r.max,"(").concat(ew(new Date(null==r?void 0:r.maxCostTimestamp)),") hist: ").concat(null==(t=null==r?void 0:r.hist)?void 0:t.join(" ")))}else"log"===r.type&&this.log[r.logLevel]("".concat(r.value))}}this.workletNode.port.postMessage({type:"enable"}),t.audioManager.addDenoiser(this.workletNode),t.sendAbilityStatus({ai_denoise:1})}))}update(){return Wb(this,null,(function*(){}))}stop(){return Wb(this,null,(function*(){if(!this.workletNode)return;let{room:e}=this.core;this.workletNode.port.postMessage({type:"disable"}),yield e.audioManager.removeDenoiser(this.workletNode)}))}destroy(){this.workletNode&&(this.workletNode.port.onmessage=null)}};Bb(nH,"updateValidateRule",{type:"object"}),Bb(nH,"stopValidateRule",{type:"object"}),Bb(nH,"Name","AIDenoiser");var aH=nH;var sH=Vb(jb(),1),cH=class extends sH.EventEmitter{constructor(){super(),Bb(this,"observer"),Bb(this,"state","nominal"),this.onPressureChange=this.onPressureChange.bind(this)}get stateNum(){switch(this.state){case"nominal":return 1;case"fair":return 2;case"serious":return 3;case"critical":return 4}}start(){return Wb(this,null,(function*(){if(!this.observer)try{"PressureObserver"in window&&!cN&&(this.observer=new PressureObserver(this.onPressureChange),yield this.observer.observe("cpu",{sampleInterval:2e3}))}catch(aw){NL.uploadEvent({log:"stat-pressure-detector-start-failed",error:aw})}}))}onPressureChange(e){let t=this.stateNum,r=e[e.length-1];this.state=r.state,(this.stateNum>3||t>3)&&Yk.info("".concat(r.source,": ").concat(r.state)),this.emit("state-changed",{type:r.source,state:this.state})}destroy(){var e;try{null==(e=this.observer)||e.disconnect(),this.observer=null}catch(lD){NL.uploadEvent({log:"stat-pressure-detector-destroy-failed",error:lD})}}},lH=new cH;function uH(e){let[t,r]=e,i=r.byteLength,o=parseInt(String(i/255),10),n=i%255,a=[];a.push(0,0,0,1,6,t);for(let c=0;c<o;c++)a.push(255);a.push(n);let s=new DataView(r);return a.push(...new Uint8Array(s.buffer)),a.push(128),new cx(new DataView(new Uint8Array(a).buffer),!0)}function dH(e){let{frame:t,seiMessageList:r}=e;if(!r||0===r.length||0===t.data.byteLength)return t;let i=9-function(e){let t=0,r=0,i=new DataView(e);for(let o=0;o<e.byteLength;o++)switch(i.getUint8(o)){case 0:t++;break;case 1:(2===t||3===t)&&r++,t=0;break;default:t=0}return r}(t.data);if(i<=0)return t;let o=r.splice(0,i).reverse().map(uH),n=o.reduce(((e,t)=>e+t.dataView.byteLength),0),a=new ArrayBuffer(n+t.data.byteLength),s=new DataView(a),c=new DataView(t.data),l=0;for(let u=0;u<o.length;u++)for(let e=0;e<o[u].dataView.byteLength;e++)s.setInt8(l++,o[u].dataView.getInt8(e));for(let u=0;u<t.data.byteLength;u++)s.setInt8(l++,c.getInt8(u));return t.data=a,t}function hH(e){let{frame:t,onSEI:r}=e;try{let e=new DataView(t.data);if(function(e){return"empty"===e.type||0===e.data.byteLength}(t)||!function(e){return 1===e.getInt32(0)&&6===e.getInt8(4)}(e))return t;let i=[],o=0,n=-1,a=-1;for(let r=0;r<t.data.byteLength;r++){let s=e.getUint8(r);if(0===s)o++;else if(1===s){if(2===o||3===o){let s=r-o;if(-1===n?n=s:-1===a&&(a=s,i.push(new cx(new DataView(e.buffer.slice(n,a)))),n=s,a=-1),6!==e.getUint8(r+1)){t.data=e.buffer.slice(s);break}}o=0}else o=0}null==r||r(i.reverse())}catch(aw){}return t}var pH=0,mH=class e{constructor(e){this.core=e,Bb(this,"log"),Bb(this,"_seiMessageList",[]),Bb(this,"_smallSeiMessageList",[]),Bb(this,"_subStreamSeiMessageList",[]),pH++,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(pH)}),this.log.info("[sei] created id=".concat(this.getAlias()).concat(pH)),this.encode=this.encode.bind(this),this.decode=this.decode.bind(this)}encode(e){let{frame:t,mediaType:r}=e;try{return dH({frame:t,seiMessageList:8===r?this._smallSeiMessageList:2===r?this._subStreamSeiMessageList:this._seiMessageList})}catch(lD){this.log.warn(lD)}return t}decode(e){let{frame:t,track:r}=e;return hH({frame:t,onSEI:e=>{e.forEach((e=>{this.core.trtc.emit(bB.SEI_MESSAGE,{seiPayloadType:e.seiPayloadType,data:e.seiPayload.buffer,userId:r.userId,streamType:2===r.mediaType?"sub":"main"})}))}})}destroy(){this.log.debug("destory"),this.stop(),delete this.core}getValidateRule(e){switch(e){case"start":case"update":case"stop":return{type:"object"}}}start(){this.core.room.videoManager.addEncodeProcessor({processor:XM?this.encode:dH,type:2}),this.core.room.videoManager.addDecodeProcessor({processor:XM?this.decode:hH,type:2})}stop(){this.core.room.videoManager.removeEncodeProcessor({type:2}),this.core.room.videoManager.removeDecodeProcessor({type:2})}update(e){let{buffer:t,options:r}=e;var i;let o=[r.seiPayloadType,t],n=!!r.small;r.toSubStream?this._subStreamSeiMessageList.push(o):(this._seiMessageList.push(o),n&&this._smallSeiMessageList.push(o)),null==(i=this.core.room.scriptTransformWorker)||i.postMessage({type:"sei",data:o,isMain:!r.toSubStream,small:n})}getName(){return e.Name}getAlias(){return"sei"}getGroup(){return"sei"}};Bb(mH,"autoStart",!0),Bb(mH,"Name","SEI");var fH=mH;function _H(e){let{frame:t,onDump:r}=e;return null==r||r(),t}function gH(e){let{frame:t,onDump:r}=e;return null==r||r(),t}var EH={"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=>{EH["".concat(e,"()")]={tips:"Call trtc.".concat(e),color:"blue",class:"blue",textColor:"#fff"}}));var vH,yH=0,TH=class e{constructor(e){this.core=e,Bb(this,"_core"),Bb(this,"log"),Bb(this,"dumpLocalVideoMap",{}),Bb(this,"dumpRemoteVideoMap",{}),Bb(this,"dialog"),this._core=e,this.log=e.log.createChild({id:"".concat(this.getAlias()).concat(++yH)}),this.log.info("created")}getName(){return e.Name}getAlias(){return"dm"}getGroup(){return"dm"}getValidateRule(e){switch(e){case"start":return{name:"StartDebugOptions",required:!1};case"update":return{name:"UpdateDebugOptions",required:!1};case"stop":return{name:"StopDebugOptions",required:!1}}}start(){return Wb(this,null,(function*(){var e;!new URLSearchParams(location.search).has("trtcDebug")&&"true"!==(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_ENABLE_DEBUG_PLUGIN"))||(yield this.openDebugDiaLog(),this.addVideoProcessor())}))}update(){}stop(){this.closeDebugDiaLog(),this.removeVideoProcessor()}destroy(){this.stop()}openDebugDiaLog(){return Wb(this,null,(function*(){var e;try{if(vH)yield vH;else{let t=new URLSearchParams(location.search).get("trtcDebugDialogPath")||(null==(e=window.sessionStorage)?void 0:e.getItem("TRTC_DEBUG_DIALOG_PATH"))||"https://unpkg.com/".concat("trtc-sdk-v5","@").concat(ow,"/assets/debug-dialog.js");vH=this._core.fileDownloader.loadScript(t),yield vH}this.dialog=new TRTCDebugDialog(this._core,this.log,this.dumpLocalVideoMap,this.dumpRemoteVideoMap),this._core.kvStatManager.addSuccessEvent({key:592705})}catch(aw){this._core.kvStatManager.addFailedEvent({key:592705}),this.log.error("load debug dialog script failed: ",JSON.stringify(aw))}}))}closeDebugDiaLog(){var e;null==(e=this.dialog)||e.closeDialog(),this.dialog=null}addVideoProcessor(){this._core.room.videoManager.addEncodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.encodeVideo.bind(this):_H,type:1}),this._core.room.videoManager.addDecodeProcessor({processor:this._core.rtcDectection.IS_INSERTABLE_STREAM_SUPPORTED?this.decodeVideo.bind(this):gH,type:1})}removeVideoProcessor(){this._core.room.videoManager.removeEncodeProcessor({type:1}),this._core.room.videoManager.removeDecodeProcessor({type:1})}encodeVideo(e){let{frame:t,mediaType:r}=e;return _H({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 gH({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())}})}};Bb(TH,"Name","Debug"),Bb(TH,"autoStart",!0);var IH=TH,AH=e=>{switch(e){case"webCodecs":return 504703;case"wasm":return 504704}throw new Error("decoder type not supported")},SH=class{constructor(e,t,r){Bb(this,"trackDoneOB"),Bb(this,"startOB"),Bb(this,"stopOB"),Bb(this,"inputFrameCount",0),Bb(this,"decodedFrameCount",0),Bb(this,"type","auto"),Bb(this,"config"),Bb(this,"decoder"),Bb(this,"_decodeSink");let{kvStatManager:i,trtc:o}=e;this.config=r.config,this.trackDoneOB=sU(t,EL.INIT),this.stopOB=$x(),this.startOB=$x(),"auto"===r.type?this.type="webCodecs":this.type=r.type;let n=$x();Nx(this.startOB,zx(0),aV((e=>{let r=this.pipe(t);return n.next("STARTING"),t.log.info("decoder type: ".concat(this.type)),Nx(r,CU(this.stopOB),DV((()=>{}),(r=>{t.log.error(r),i.addFailedEvent({key:AH(this.type),error:r}),e>4?this.startOB.error(r):this.startOB.next(e+1)}))),Nx(r,DU(1),RV(vU))})),CU(this.stopOB),DV((()=>{t.player.setOutput(),n.next("STARTED")}),(e=>{n.next("FAILED")}),(()=>{i.addSuccessEvent({key:AH(this.type)}),i.addSuccessEvent({key:504702})})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.startOB.next(0)}close(e){this.stopOB.next(e)}pipe(e){return Vx()((t=>Wb(this,null,(function*(){this._decodeSink=t,t.defer((()=>{var e;null==(e=this.decoder)||e.close()}));let{type:r}=this;try{if("webCodecs"===r)this.decoder=new AudioDecoder({error:r=>{e.log.error(r),t.error(4)},output:r=>{this.decodedFrameCount++,t.next(r),e.player.write(r)}});this.decoder.configure(this.config)}catch(iO){e.log.error(iO),t.error("webCodecs"===r?2:6)}}))))}decodeFrame(e){var t;this.inputFrameCount++,"configured"===(null==(t=this.decoder)?void 0:t.state)&&this.decoder.decode(new EncodedAudioChunk({data:e.data,timestamp:e.timestamp,type:"key"}))}},RH={type:"object"},bH=class e{constructor(e){this.core=e,Bb(this,"log"),Bb(this,"contextMap",new Map),Bb(this,"decodeProcessorMap",new WeakMap),this.log=e.log.createChild({id:"".concat(this.getAlias())})}getAlias(){return e.Name}getGroup(e){return e.track.userId+e.track.streamType}getName(){return e.Name}getValidateRule(e){return RH}start(e){let{track:t}=e;this.decodeProcessorMap.set(t,this.decode(e)),this.core.room.audioManager.addDecodeProcessor({processor:e=>{let{frame:t,track:r}=e;return this.decodeProcessorMap.has(r)?this.decodeProcessorMap.get(r)({frame:t,track:r}):t},type:3})}decode(e){return t=>{let{frame:r,track:i}=t;if(i!==e.track)return r;if(this.contextMap.has(i))return this.contextMap.get(i).decodeFrame(r);let o=new SH(this.core,i,e);return Nx(o.trackDoneOB,DU(1),DV((()=>{this.core.clearStarted(this,this.getGroup(e)),this.stop({track:i})}))),this.contextMap.set(i,o),o.decodeFrame(r)}}stop(e){let{track:t}=e,r=this.contextMap.get(t);r&&(r.close("stop"),this.contextMap.delete(t),0===this.contextMap.size&&this.core.room.audioManager.removeDecodeProcessor({type:3}))}update(e){let t=this.contextMap.get(e.track);if(t){if("mock"===e.type)return void t.mock(10);t.close("update"),this.contextMap.set(e.track,new SH(this.core,e.track,e))}}};Bb(bH,"Name","TRTCAudioDecoder");var wH=bH,DH=class{constructor(){Bb(this,"log"),this.log=Yk.createLogger({id:"exp"})}call(e,t){return Wb(this,null,(function*(){return rC(this[e])?this[e](t):Promise.reject(new $b({code:Jb.INVALID_PARAMETER,message:iM({key:ZO.API_NOT_EXIST,data:{name:e}})}))}))}enableAudioFrameEvent(e){return Wb(this,null,(function*(){let{trtcInstance:t,enable:r,userId:i,sampleRate:o=48e3,channelCount:n=1,port:a}=e,{audioManager:s}=t.room,{getPCMAbortCtrlMap:c,audioFrameEventConfigMap:l}=s;if(l.set(i,{enable:r,sampleRate:o,channelCount:n,port:a}),r)if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isAvailable){if(c.get(e.userId))return;let r=s.getPCM((e=>{t.emit(bB.AUDIO_FRAME,e)}),e.userId);c.set(e.userId,r)}}));else{if(c.get(i))return;let e=s.getPCM((e=>{t.emit(bB.AUDIO_FRAME,e)}),i);c.set(i,e)}else if("*"===i)t.room.remotePublishedUserMap.forEach((e=>{if(e.remoteAudioTrack.isSubscribed){let{userId:t}=e,r=c.get(t);null==r||r.abort("disable"),c.delete(t)}}));else{let e=c.get(i);null==e||e.abort("disable"),c.delete(i)}}))}};Fb([function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return JP(((e,r)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];return oF.call(this,t,o,r,this._name),e.apply(this,o)}))}({name:"options",type:"object",required:!0,properties:{enable:{required:!0,type:"boolean"},userId:{required:!0,type:"string"},sampleRate:{type:"number",values:[8e3,16e3,32e3,44100,48e3]},channelCount:{type:"number",values:[1,2]},port:{type:"messageport"}}})],DH.prototype,"enableAudioFrameEvent",1);var CH=new DH,NH=0,kH=new Set,OH=null;nw("5.10.2-wasm.3"),Xk.checkStorage(),aL();var MH={RtcError:ZF,ErrorCode:YF,ErrorCodeDictionary:JF},LH=class e extends jF.EventEmitter{constructor(t,r){super(),Bb(this,"_room"),Bb(this,"_eventListened",new Set),Bb(this,"_localVideoTrack",null),Bb(this,"_localAudioTrack",null),Bb(this,"_localScreenTrack",null),Bb(this,"_localScreenAudioTrack",null),Bb(this,"_localVideoConfig",null),Bb(this,"_localScreenConfig",null),Bb(this,"_localAudioConfig",null),Bb(this,"_remoteVideoConfigMap",new Map),Bb(this,"_remoteAudioConfigMap",new Map),Bb(this,"_remoteAudioVolumeMap",new Map),Bb(this,"_remoteAudioMuteMap",new Map),Bb(this,"_mediaTrackMap",new WeakMap),Bb(this,"_log",Yk.createLogger({id:"t".concat(++NH)})),Bb(this,"_plugins",new Map),Bb(this,"_networkQuality",null),Bb(this,"_speakerId"),Bb(this,"enterRoomParams"),this._room=new t(Lb({logger:this._log,frameWorkType:e.frameWorkType},r)),this._room.videoDecodeFallbackType=r.videoDecodeFallback,this._log.info("create() ".concat(JSON.stringify(r,((e,t)=>"plugins"===e?t.map((e=>e.Name)):t)))),Object.defineProperties(this,{dumpAudio:{enumerable:!1,value(e){return this._room.audioManager.dump(e)}}}),r.plugins&&r.plugins.forEach((e=>{this._use(e,r.assetsPath)})),this._use(iH,r.assetsPath),this._use(aH,r.assetsPath),this._use(wH,r.assetsPath||Ew),this._use(IH),r.enableSEI&&QM&&this._use(fH),this._room.on("audio-volume",(e=>{!e.find((e=>""===e.userId))&&this._localAudioTrack&&e.push({userId:"",volume:Math.floor(100*this._localAudioTrack.getAudioLevel())}),1===r.volumeType&&e.forEach((e=>{var t;let r=""===e.userId?this._localAudioTrack:null==(t=this.room.remotePublishedUserMap.get(e.userId))?void 0:t.remoteAudioTrack;r&&(e.volume=r.dbVolume)})),this.emit(bB.AUDIO_VOLUME,{result:e.sort(((e,t)=>t.volume-e.volume))})})),this._room.videoManager.on("error",(e=>{this._log.error(new ZF({code:YF.OPERATION_FAILED,extraCode:5504,message:e.message,originError:e}))})),this._listenEvents(),this._initActiveSpeaker(),((e,t)=>{let{emit:r}=e;e.emit=function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];try{return r.apply(e,o)}catch(iO){let r=iM({key:ZO.CATCH_HANDLER_ERROR,data:{name:t,event:o[0]},addDocLink:!1});return Yk.warn("".concat(r,"\n\n").concat(iO.stack)),!1}}})(this,"trtc")}static create(e){}static _create(t,r){!function(){var e;if(zF){zF=!1,5!==Yk.getLogLevel()&&(console.info("******************************************************************************"),console.info("* TRTC Web SDK"),console.info("* API Document: ".concat(gw,"/en/index.html")),console.info("* Changelog: ".concat(gw,"/en/tutorial-01-info-changelog.html")),console.info("* Report issues: https://github.com/LiteAVSDK/TRTC_Web/issues"),console.info("******************************************************************************")),Yk.info("TRTC Web SDK Version:",ow),wk||Yk.debug("Build Time:","2025-06-05 20:31:24");let t="UA: ".concat(navigator.userAgent," \nCPU core: ").concat(navigator.hardwareConcurrency,", GPU: ").concat(Pk()),r=navigator.deviceMemory;r&&(t+=", minRAM: ".concat(r,"GB")),Yk.info(t),Yk.info("URL: ".concat(location.href).concat("IFRAME"===(null==(e=self.frameElement)?void 0:e.tagName)?" in iframe":"")),Lk().then((e=>{e&&Yk.info(Mk)}))}}();let i=new e(t,r||{});return kH.add(i),i}get room(){return this._room}_listenEvents(){DL(this,this._room).add("peer-join",(e=>{let{userId:t}=e;this.emit(bB.REMOTE_USER_ENTER,{userId:t})})).add("peer-leave",(e=>{this.emit(bB.REMOTE_USER_EXIT,{userId:e}),this._remoteAudioVolumeMap.delete(e)})).add("banned",(e=>{this._exitRoom().finally((()=>{this.emit(bB.KICKED_OUT,{reason:e.reason})}))})).add("error",(e=>{this._exitRoom().finally((()=>{this.emit(bB.ERROR,ZF.convertFrom(e))}))})).add("signal-connection-state-changed",(e=>{this.emit(bB.CONNECTION_STATE_CHANGED,e)})).add("network-quality",(e=>{this._networkQuality=e;let t=Pb(Lb({},e),{uplinkRTT:Math.min(e.uplinkRTT,xD),downlinkRTT:Math.min(e.downlinkRTT,xD)});this.emit(bB.NETWORK_QUALITY,t)})).add("remote-published",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((t=>{DL(t,t).add("player-state-changed",(r=>{let i=Pb(Lb({},r),{userId:e.userId});t.kind===Pw.VIDEO&&(i.streamType=eB(t.streamType)),this.emit(t.kind===Pw.AUDIO?bB.AUDIO_PLAY_STATE_CHANGED:bB.VIDEO_PLAY_STATE_CHANGED,i)})).add("error",(e=>{e.getCode()===Jb.PLAY_NOT_ALLOWED&&this.emit(bB.AUTOPLAY_FAILED,{userId:t.userId,mediaType:t.strMediaType,resume:()=>t.player.resume()})}))}))})).add("remote-unpublished",(e=>{[e.remoteAudioTrack,e.remoteVideoTrack,e.remoteAuxiliaryTrack].forEach((e=>{CL(e)}))})).add("remote-publish-state-changed",(e=>{let{prevMuteState:t,muteState:r}=e,{userId:i}=r,o=t.audioAvailable,n=t.videoAvailable,{audioAvailable:a,videoAvailable:s}=r;a||this._remoteAudioConfigMap.delete(i),s||this._removeRemoteVideoConfig(i,"main"),r.hasAuxiliary||this._removeRemoteVideoConfig(i,"sub"),n!==s&&(s?this._onVideoAvailable({userId:i,streamType:"main"}):this._onVideoUnavailable({userId:i,streamType:"main"}),this.emit(s?bB.REMOTE_VIDEO_AVAILABLE:bB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"main"})),o!==a&&(a?this._onAudioAvailable({userId:i}):this._onAudioUnavailable({userId:i,muteState:r}),this.emit(a?bB.REMOTE_AUDIO_AVAILABLE:bB.REMOTE_AUDIO_UNAVAILABLE,{userId:i})),t.hasAuxiliary!==r.hasAuxiliary&&(r.hasAuxiliary?this._onVideoAvailable({userId:i,streamType:"sub"}):this._onVideoUnavailable({userId:i,streamType:"sub"}),this.emit(r.hasAuxiliary?bB.REMOTE_VIDEO_AVAILABLE:bB.REMOTE_VIDEO_UNAVAILABLE,{userId:i,streamType:"sub"}))})).add("sei-message",(e=>{this.emit(bB.SEI_MESSAGE,Pb(Lb({},e),{streamType:eB(e.streamType)}))})).add("firewall-restriction",(()=>{this.emit(bB.ERROR,new ZF({code:YF.OPERATION_FAILED,extraCode:5501}))})).add("heartbeat-report",(e=>{var t,r,i,o,n,a,s;let c={2:"big",3:"small",7:"sub"},l={rtt:Math.min(e.msg_up_stream_info.msg_network_status.uint32_rtt||(null==(t=e.msg_down_stream_info[0])?void 0:t.msg_network_status.uint32_rtt)||(null==(r=this._networkQuality)?void 0:r.uplinkRTT)||(null==(i=this._networkQuality)?void 0:i.downlinkRTT)||0,xD),upLoss:(null==(o=this._networkQuality)?void 0:o.uplinkLoss)||0,downLoss:(null==(n=this._networkQuality)?void 0:n.downlinkLoss)||0,bytesSent:e.bytes_sent||0,bytesReceived:e.bytes_received||0,localStatistics:{audio:{bitrate:((null==(a=e.msg_up_stream_info.msg_audio_status)?void 0:a.uint32_audio_codec_bitrate)||0)/1e3,audioLevel:((null==(s=e.msg_up_stream_info.msg_audio_status)?void 0:s.uint32_audio_level)||0)/WO},video:e.msg_up_stream_info.msg_video_status.filter((e=>c[e.uint32_video_stream_type])).map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_enc_fps,videoType:c[e.uint32_video_stream_type]})))},remoteStatistics:e.msg_down_stream_info.map((e=>({userId:e.msg_user_info.str_identifier,audio:{bitrate:(e.msg_audio_status.uint32_audio_codec_bitrate||0)/1e3,audioLevel:(e.msg_audio_status.uint32_audio_level||0)/WO,point2pointDelay:(e.msg_audio_status.uint32_audio_p2p_delay||0)+(e.msg_audio_status.uint32_audio_cache_ms||0),jitterBufferDelay:e.msg_audio_status.uint32_audio_cache_ms||0},video:e.msg_video_status.map((e=>({bitrate:(e.uint32_video_codec_bitrate||0)/1e3,width:e.uint32_video_width,height:e.uint32_video_height,frameRate:e.uint32_video_dec_fps,videoType:c[e.uint32_video_stream_type],point2pointDelay:(e.uint32_video_p2p_delay||0)+(e.uint32_video_cache_ms||0),jitterBufferDelay:e.uint32_video_cache_ms||0})))})))};this.emit(bB.STATISTICS,l)})).add("custom-message",(e=>{this.emit(bB.CUSTOM_MESSAGE,e)})).add("layerData",(e=>this.emit(bB.LAYER_DATA,e))).add("first-video-frame",(e=>{this.emit(bB.FIRST_VIDEO_FRAME,Pb(Lb({},e),{streamType:eB(e.streamType)}))})).add("audio-frame",(e=>{this.emit(bB.AUDIO_FRAME,e)})),DL(this,bP).add("audioInputAdded",(e=>{this.emit(bB.DEVICE_CHANGED,{type:"microphone",action:"add",device:e})})).add("audioInputRemoved",(e=>{this.emit(bB.DEVICE_CHANGED,{type:"microphone",action:"remove",device:e})})).add("videoInputAdded",(e=>{this.emit(bB.DEVICE_CHANGED,{type:"camera",action:"add",device:e})})).add("videoInputRemoved",(e=>{this.emit(bB.DEVICE_CHANGED,{type:"camera",action:"remove",device:e})})).add("audioOutputAdded",(e=>Wb(this,null,(function*(){if(this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"add",device:e}),OH&&OH.deviceId===CD){let e=(yield OP()).find((e=>e.deviceId===CD));e&&OH.groupId!==e.groupId&&(OH=e,this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e}))}})))).add("audioOutputRemoved",(e=>Wb(this,null,(function*(){this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"remove",device:e});let t=(yield OP())[0];if(!t||!OH||OH.groupId===t.groupId)return;let r=OH.deviceId===e.deviceId,i=OH.deviceId===CD&&OH.deviceId===t.deviceId;(r||i)&&(OH=t,this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}))}))))}use(e){let t,r;"plugin"in e?(t=e.plugin,r=e.assetsPath):t=e,this._use(t,r||Ew)}_use(t,r){if(this._plugins.get(t.Name))return void this._log.warn("duplicate install plugin",t.Name);let i=new t(GB.call(this,{TRTC:e,room:this._room,errorModule:MH,assetsPath:r}));this._plugins.set(t.Name,i),t.autoStart&&this.startPlugin(t.Name)}enterRoom(t){return Wb(this,null,(function*(){var r,i;this.enterRoomParams=t;let{scene:o="rtc",enableAutoPlayDialog:n=!0,autoReceiveAudio:a=!0,autoReceiveVideo:s=!1}=t;t.proxy&&(this._room.setProxyServer(t.proxy),!oC(t.proxy)&&t.proxy.turnServer&&(null==(i=(r=this._room).setTurnServer)||i.call(r,t.proxy.turnServer,t.proxy.iceTransportPolicy))),this._room.enableAutoPlayDialog=n,this._room.autoReceiveAudio=a,this._room.autoReceiveVideo=s,aC(t.preferHW)&&(this._room.preferHW=t.preferHW),t.playoutDelay&&(this._room.playoutDelay=t.playoutDelay),t.jitterBufferDelay&&(this._room.jitterBufferDelay=t.jitterBufferDelay);let c={sdkAppId:t.sdkAppId,userId:t.userId,userSig:t.userSig,privateMapKey:t.privateMapKey||null,latencyLevel:t.latencyLevel,role:"audience"===t.role?21:20,roomId:t.roomId||0,strRoomId:t.strRoomId||"",businessInfo:t.businessInfo||null,streamId:null,userDefineRecordId:t.userDefineRecordId||null,frameWorkType:t.frameWorkType,component:t.component,language:t.language,priority:t.priority,useVp8:t.useVp8,keepAlive:t.keepAlive};t.strRoomId&&!t.roomId?this._room.useStringRoomId=!0:this._room.useStringRoomId=!1,yield this._room.join(c,o,e.frameWorkType),this._checkTrackToPublish(),lH.start()}))}exitRoom(){return Wb(this,null,(function*(){return yield this._exitRoom()}))}switchRoom(e){return Wb(this,null,(function*(){if(this.room.isSwitchRoomSupported())yield this._room.switchRoom(e);else{yield this.exitRoom();let t=Lb(Lb({},this.enterRoomParams),e);yield this.enterRoom(t)}}))}switchRole(e,t){return Wb(this,null,(function*(){null!=t&&t.privateMapKey&&(this._room.privateMapKey=t.privateMapKey),null!=t&&t.latencyLevel&&(this._room.latencyLevel=t.latencyLevel),yield this._room.switchRole(e),"anchor"===e&&this._checkTrackToPublish()}))}destroy(){CL(this),this.removeAllListeners(),this._room.destroy(),kH.delete(this),0===kH.size&&lH.destroy(),this._localAudioTrack&&this.stopLocalAudio(),this._localVideoTrack&&this.stopLocalVideo(),this._localScreenTrack&&this.stopScreenShare(),this._plugins.forEach((e=>{var t;return null==(t=e.destroy)?void 0:t.call(e)})),this._plugins.clear(),Gk.off("102",this._onLocalTrackCaptured,this)}startLocalAudio(){return Wb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0};return function*(){if(e._localAudioTrack)return void e._log.warn("local audio is already started");let{publish:r=!0,mute:i,option:o}=t,n=new sx(e._room.audioManager),a={},s={muted:!0};o&&(iC(o.microphoneId)?iC(o.audioTrack)||(a.customSource=o.audioTrack):a.deviceId=o.microphoneId,o&&nC(o.captureVolume)&&n.setCaptureVolume(o.captureVolume),iC(o.profile)||(oC(o.profile)?Nw[o.profile]&&n.setProfile(Nw[o.profile]):n.setProfile(o.profile)),nC(o.earMonitorVolume)&&(s.muted=!(o.earMonitorVolume>0),s.volume=o.earMonitorVolume),iC(o.echoCancellation)||(n.profile.echoCancellation=o.echoCancellation),iC(o.noiseSuppression)||(n.profile.noiseSuppression=o.noiseSuppression),iC(o.autoGainControl)||(n.profile.autoGainControl=o.autoGainControl)),n.on("5",(t=>{e.emit(bB.ERROR,new ZF({code:YF.DEVICE_ERROR,extraCode:5309,messageParams:{error:t}}))})),n.on("2",(t=>{e.emit(bB.DEVICE_CHANGED,{type:"microphone",action:"active",device:t})})),n.on("4",(t=>{let r;t.error&&(r=ZF.convertFrom(t.error)),e.emit(bB.PUBLISH_STATE_CHANGED,Pb(Lb({},t),{error:r}))})),e._listenOutputTrackChanged(n),e._speakerId&&n.setAudioOutput(e._speakerId),yield n.capture(a),iC(i)||n.setMute(i),DL(n,n).add("player-state-changed",(t=>{e.emit(bB.AUDIO_PLAY_STATE_CHANGED,Pb(Lb({},t),{userId:""}))})),r&&e._room.isJoined&&e._room.publish(n).catch((()=>{})),e._localAudioTrack=n,e._localAudioConfig=Pb(Lb({},t),{publish:r}),yield e._updateAudioPlayOption({playOption:s,track:n}),Gk.emit("113",{userId:"",room:e.room})}()}))}updateLocalAudio(e){return Wb(this,null,(function*(){if(!this._localAudioTrack||!this._localAudioConfig)return;let{publish:t,mute:r,option:i}=e,o={};i&&(i.microphoneId?yield this._localAudioTrack.switchDevice(i.microphoneId):iC(i.audioTrack)||(yield this._localAudioTrack.setInputMediaStreamTrack(i.audioTrack)),iC(i.captureVolume)||this._localAudioTrack.setCaptureVolume(i.captureVolume),iC(i.earMonitorVolume)||(o.muted=!(i.earMonitorVolume>0),o.volume=i.earMonitorVolume),yield this._localAudioTrack.update3A(i)),this._room.isJoined&&!iC(t)&&(t&&!this._localAudioConfig.publish&&this._room.publish(this._localAudioTrack).catch((()=>{})),this._localAudioConfig.publish&&!t&&this._room.unpublish(this._localAudioTrack).catch((()=>{}))),iC(r)||this._localAudioTrack.setMute(r),yield this._updateAudioPlayOption({playOption:o,track:this._localAudioTrack,prevConfig:this._localAudioConfig}),SC(this._localAudioConfig,e)}))}stopLocalAudio(){return Wb(this,null,(function*(){this._localAudioTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localAudioTrack).catch((()=>{}))),Gk.emit("114",{userId:"",room:this.room}),this._localAudioTrack.stop(),this._localAudioTrack.close(),this._room.audioManager.removeInput(this._localAudioTrack),CL(this._localAudioTrack),this._localAudioTrack=null,this._localAudioConfig=null)}))}startLocalVideo(){return Wb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null,capture:!0};return function*(){var r;if(e._localVideoTrack)return void e._log.warn("local video is already started");let{view:i,publish:o=!0,capture:n=!0,mute:a,option:s}=t,c=new dx(e._room.videoManager),l={},u={};aC(null==s?void 0:s.avoidCropping)&&(c.avoidCropping=s.avoidCropping),s&&(s.cameraId?l.deviceId=s.cameraId:iC(s.useFrontCamera)?iC(s.videoTrack)||(l.customSource=s.videoTrack):l.facingMode=s.useFrontCamera?Pw.FACING_MODE_USER:Pw.FACING_MODE_ENVIRONMENT,iC(s.retryWhenExactFailed)||(l.retryWhenExactFailed=s.retryWhenExactFailed),s.qosPreference&&(l.contentHint=tB(s.qosPreference)),iC(s.profile)||(oC(s.profile)?kw[s.profile]&&c.setProfile(kw[s.profile]):c.setProfile(s.profile)),iC(s.fillMode)||(u.objectFit=s.fillMode),iC(s.mirror)||(u.mirror=s.mirror),iC(s.small)||(iC(s.smallMode)||(e._room.smallMode=s.smallMode),aC(s.small)&&!1===s.small?c.stopSmall():c.updateSmallConfig(rB(s.small,!0))),iC(s.rotation)||c.setRotation(s.rotation)),c.once("first-video-frame",(t=>{e.emit(bB.FIRST_VIDEO_FRAME,Pb(Lb({},t),{streamType:eB(t.streamType)}))})),c.on("5",(t=>{e.emit(bB.ERROR,new ZF({code:YF.DEVICE_ERROR,extraCode:5308,messageParams:{error:t}}))})),c.on("2",(t=>{e.emit(bB.DEVICE_CHANGED,{type:"camera",action:"active",device:t})})),c.on("4",(t=>{let r;t.error&&(r=ZF.convertFrom(t.error)),e.emit(bB.PUBLISH_STATE_CHANGED,Pb(Lb({},t),{error:r}))})),e._listenOutputTrackChanged(c),n?yield c.capture(l):null==(r=c.manager)||r.changeInput(c),iC(a)||(yield c.setMute(a)),DL(c,c).add("player-state-changed",(t=>{e.emit(bB.VIDEO_PLAY_STATE_CHANGED,Pb(Lb({},t),{userId:"",streamType:"main"}))})),o&&e._room.isJoined&&e._room.publish(c).catch((()=>{})),e._localVideoTrack=c,e._localVideoConfig=Pb(Lb({},t),{view:i,publish:o,capture:n}),yield e._updateVideoPlayOption({view:i,playOption:u,track:c})}()}))}updateLocalVideo(e){return Wb(this,null,(function*(){var t,r,i;if(!this._localVideoTrack||!this._localVideoConfig)return;let{view:o,publish:n,mute:a,capture:s,option:c}=e,l={};if(this._localVideoConfig.capture)!1!==s?null!=c&&c.cameraId?yield this._localVideoTrack.switchDevice(null==c?void 0:c.cameraId):iC(null==c?void 0:c.useFrontCamera)?iC(null==c?void 0:c.videoTrack)||(yield this._localVideoTrack.setInputMediaStreamTrack(null==c?void 0:c.videoTrack)):yield this._localVideoTrack.switchDevice(null!=c&&c.useFrontCamera?Pw.FACING_MODE_USER:Pw.FACING_MODE_ENVIRONMENT):this._localVideoTrack.stopCapture();else if(s){let e={};e.deviceId=(null==c?void 0:c.cameraId)||(null==(t=this._localVideoConfig.option)?void 0:t.cameraId),e.facingMode=null!=c&&c.useFrontCamera||null!=(r=this._localVideoConfig.option)&&r.useFrontCamera?Pw.FACING_MODE_USER:Pw.FACING_MODE_ENVIRONMENT,e.customSource=(null==c?void 0:c.videoTrack)||(null==(i=this._localVideoConfig.option)?void 0:i.videoTrack),yield this._localVideoTrack.capture(e)}c&&(iC(c.profile)||(oC(c.profile)?kw[c.profile]&&this._localVideoTrack.setProfile(kw[c.profile]):this._localVideoTrack.setProfile(c.profile),(!c.cameraId||!this._localVideoTrack.isNeedToSwitchDevice(c.cameraId))&&iC(c.useFrontCamera)&&(yield this._localVideoTrack.applyProfile())),iC(c.fillMode)||(l.objectFit=c.fillMode),iC(c.mirror)||(l.mirror=c.mirror),iC(c.rotation)||this._localVideoTrack.setRotation(c.rotation),c.qosPreference&&this._localVideoTrack.mediaTrack&&this._localVideoTrack.setContentHint(tB(c.qosPreference)),iC(c.small)||(aC(c.small)&&!c.small?this._localVideoTrack.stopSmall():this._localVideoTrack.updateSmallConfig(rB(c.small,!0)))),this._room.isJoined&&iC(n)&&this._localVideoConfig.publish&&s&&!this._localVideoConfig.capture&&this._room.publish(this._localVideoTrack).catch((()=>{})),this._room.isJoined&&((null!=n?n:this._localVideoConfig.publish)?this._room.publish(this._localVideoTrack).catch((()=>{})):this._room.unpublish(this._localVideoTrack).catch((()=>{}))),iC(a)||(yield this._localVideoTrack.setMute(a)),yield this._updateVideoPlayOption({view:o,playOption:l,track:this._localVideoTrack,prevConfig:this._localVideoConfig}),SC(this._localVideoConfig,e)}))}stopLocalVideo(){return Wb(this,null,(function*(){this._localVideoTrack&&(this._room.isJoined&&(yield this._room.unpublish(this._localVideoTrack).catch((()=>{}))),this._localVideoTrack.stop(),this._localVideoTrack.close(),CL(this._localVideoTrack),this._localVideoTrack=null,this._localVideoConfig=null)}))}startScreenShare(){return Wb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{publish:!0,view:null};return function*(){if(e._localScreenTrack)return void e._log.warn("screen share is already started");let{view:r=null,publish:i=!0,option:o}=t,n=new mx(e._room.videoManager);n.on("4",(t=>{let r;t.error&&(r=ZF.convertFrom(t.error)),e.emit(bB.PUBLISH_STATE_CHANGED,Pb(Lb({},t),{error:r}))})),n.once("first-video-frame",(t=>{e.emit(bB.FIRST_VIDEO_FRAME,Pb(Lb({},t),{streamType:eB(t.streamType)}))})),e._listenOutputTrackChanged(n),"main"===t.streamType&&(n.mediaType=4);let a=null,s={},c={};o&&(iC(o.profile)||(oC(o.profile)?Lw[o.profile]&&n.setProfile(Lw[o.profile]):n.setProfile(o.profile)),o.systemAudio&&(s.systemAudio=!0,s.echoCancellation=o.echoCancellation,s.noiseSuppression=o.noiseSuppression,s.autoGainControl=o.autoGainControl),iC(o.fillMode)||(c.objectFit=o.fillMode),o.videoTrack&&(s.videoTrack=o.videoTrack),o.audioTrack&&(s.audioTrack=o.audioTrack),o.captureElement&&(s.captureElement=o.captureElement),o.preferDisplaySurface&&(s.preferDisplaySurface=o.preferDisplaySurface),o.qosPreference&&(s.contentHint=tB(o.qosPreference)));let l=yield n.capture(s);if(n.mediaTrack.addEventListener(Pw.ENDED,(()=>{e._stopScreenShare(),e.emit(bB.SCREEN_SHARE_STOPPED)})),l.getAudioTracks()[0]&&(a=new _x(e._room.audioManager),yield a.setInputMediaStreamTrack(l.getAudioTracks()[0]),e._speakerId&&a.setAudioOutput(e._speakerId)),DL(n,n).add("player-state-changed",(t=>{e.emit(bB.VIDEO_PLAY_STATE_CHANGED,Pb(Lb({},t),{userId:"",streamType:"sub"}))})),i&&e._room.isJoined){let t=[n];a&&t.push(a),e._room.publish(...t).catch((()=>{}))}e._localScreenTrack=n,e._localScreenAudioTrack=a,e._localScreenConfig=Pb(Lb({},t),{view:r,publish:i}),yield e._updateVideoPlayOption({view:r,playOption:c,track:n})}()}))}updateScreenShare(e){return Wb(this,null,(function*(){if(!this._localScreenTrack||!this._localScreenConfig)return;let{view:t,publish:r,option:i}=e,o={};if(i&&(iC(i.fillMode)||(o.objectFit=i.fillMode),i.qosPreference)){let e=tB(i.qosPreference);this._localScreenTrack.setContentHint(e)}this._room.isJoined&&!iC(r)&&(r&&!this._localScreenConfig.publish&&(this._room.publish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.publish(this._localScreenAudioTrack).catch((()=>{}))),this._localScreenConfig.publish&&!r&&(this._room.unpublish(this._localScreenTrack).catch((()=>{})),this._localScreenAudioTrack&&this._room.unpublish(this._localScreenAudioTrack).catch((()=>{})))),yield this._updateVideoPlayOption({view:t,playOption:o,track:this._localScreenTrack,prevConfig:this._localScreenConfig}),SC(this._localScreenConfig,e)}))}stopScreenShare(){return Wb(this,null,(function*(){return yield this._stopScreenShare()}))}startRemoteVideo(e){return Wb(this,null,(function*(){let{view:t,userId:r,streamType:i,option:o}=e,n="".concat(r,"_").concat(i);if(this._remoteVideoConfigMap.has(n))return void this._log.warn("remote video has already started. userId:".concat(r,", streamType:").concat(i));let a=this._room.remotePublishedUserMap.get(r);if(!a)return;let s={},c="main"===i?a.remoteVideoTrack:a.remoteAuxiliaryTrack;this._listenOutputTrackChanged(c),o&&(iC(o.fillMode)||(s.objectFit=o.fillMode),iC(o.mirror)||(s.mirror=o.mirror),iC(o.poster)||(s.poster=o.poster),s.canvasRender=o.canvasRender,"main"===i&&!iC(o.small)&&(!a.remoteVideoTrack.isSubscribing&&!a.remoteVideoTrack.isSubscribed&&a.remoteVideoTrack.setMediaType(o.small?8:4),this._room.changeType(o.small,c.user))),yield this._room.subscribe(c),yield this._enableVideoDecodeFallback(c,i),yield this._updateVideoPlayOption({view:t,playOption:s,track:c}),this._emitTrackEvent(c),this._remoteVideoConfigMap.set(n,{config:e}),o&&!iC(o.receiveWhenViewVisible)&&this._observeView({remoteTrack:c,view:t,receiveWhenViewVisible:o.receiveWhenViewVisible,viewRoot:null==o?void 0:o.viewRoot})}))}updateRemoteVideo(e){return Wb(this,null,(function*(){var t,r;let{view:i,userId:o,streamType:n,option:a}=e,s="".concat(o,"_").concat(n),c=this._remoteVideoConfigMap.get(s);if(!c||!this._room.remotePublishedUserMap.has(o))return;let l={};a&&(iC(a.fillMode)||(l.objectFit=a.fillMode),iC(a.mirror)||(l.mirror=a.mirror));let u=null,d=this._room.remotePublishedUserMap.get(o);if("main"===n&&null!=d&&d.muteState.hasVideo&&(u=d.remoteVideoTrack),"sub"===n&&null!=d&&d.muteState.hasAuxiliary&&(u=d.remoteAuxiliaryTrack),!u)return;let{config:h}=c;"main"===n&&a&&!iC(a.small)&&this._room.changeType(a.small,u.user),yield this._updateVideoPlayOption({view:i,playOption:l,track:u,prevConfig:h}),SC(h,e);let p=iC(null==a?void 0:a.receiveWhenViewVisible)?null==(t=h.option)?void 0:t.receiveWhenViewVisible:a.receiveWhenViewVisible,m=iC(i)?h.view:i,f=iC(null==a?void 0:a.viewRoot)?null==(r=h.option)?void 0:r.viewRoot:a.viewRoot;this._observeView({remoteTrack:u,view:m,receiveWhenViewVisible:p,viewRoot:f})}))}stopRemoteVideo(e){return Wb(this,null,(function*(){return this._stopRemoteVideo(e)}))}_stopRemoteVideo(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Wb(this,null,(function*(){let r=[],i=this._room.remotePublishedUserMap.get(e.userId);if(i){let{muteState:t,remoteVideoTrack:o,remoteAuxiliaryTrack:n}=i;"main"===e.streamType&&(o.stop(),t.hasVideo&&r.push(o)),"sub"===e.streamType&&(n.stop(),t.hasAuxiliary&&r.push(n))}for(let e of r)t&&(yield this._room.unsubscribe(e),this._mediaTrackMap.delete(e.outMediaTrack));this._removeRemoteVideoConfig(e.userId,e.streamType)}))}_removeRemoteVideoConfig(e,t){let r="".concat(e,"_").concat(t),i=this._remoteVideoConfigMap.get(r);i&&i.observer&&i.observer.disconnect(),this._remoteVideoConfigMap.delete(r)}muteRemoteAudio(e,t){return Wb(this,null,(function*(){this._remoteAudioMuteMap.set(e,t);try{if("*"===e)if(t)yield this._stopRemoteAudio({userId:e});else{let e=[...this._room.remotePublishedUserMap.values()];for(let t of e)t.muteState.hasAudio&&!this._remoteAudioConfigMap.has(t.userId)&&(yield this._startRemoteAudio({userId:t.userId}))}else t?yield this._stopRemoteAudio({userId:e}):this._remoteAudioConfigMap.has(e)||(yield this._startRemoteAudio({userId:e}))}catch(iO){throw this._remoteAudioMuteMap.delete(e),iO}}))}setRemoteAudioVolume(e,t){if("*"===e){let e=[...this._room.remotePublishedUserMap.values()];for(let r of e)this._remoteAudioVolumeMap.set(r.userId,t),r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}else if(e){let r=this._room.remotePublishedUserMap.get(e);this._remoteAudioVolumeMap.set(e,t),r&&r.remoteAudioTrack.isSubscribed&&this._updateAudioPlayOption({playOption:{volume:t},track:r.remoteAudioTrack})}}startPlugin(e,t){return Wb(this,null,(function*(){return e.start(t)}))}updatePlugin(e,t){return Wb(this,null,(function*(){return e.update(t)}))}stopPlugin(e,t){return Wb(this,null,(function*(){return e.stop(t)}))}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._room.enableAudioVolumeEvaluation(e,t)}on(e,t,r){if(this.listeners(e).includes(t))return this;if(this._log.debug("on",e),super.on(e,t,r),this._eventListened.add(e),this.listeners(bB.AUDIO_FRAME).length>0){let{audioFrameEventConfigMap:e}=this.room.audioManager;e.get("")||e.set("",{enable:!0}),this._localAudioTrack&&this.room.audioManager.handleLocalTrackStarted({userId:"",room:this.room})}return this}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];try{wB.has(e)&&this._log.debug("emit ".concat(e," ").concat(JSON.stringify(r)))}catch(iO){}return super.emit(e,...r)}off(t,r,i){if(this._log.debug("off",t),"*"===t?(this._eventListened.clear(),this.removeAllListeners()):super.off(t,r,i),(t===e.EVENT.AUDIO_FRAME||"*"===t)&&0===this.listeners(e.EVENT.AUDIO_FRAME).length){let{getPCMAbortCtrlMap:e}=this.room.audioManager;e.forEach((e=>{null==e||e.abort("off")})),e.clear()}return this}getAudioTrack(){let e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},r=null,i="main",o=!1;if(oC(t)?e=t:(e=t.userId,o=!0===t.processed,t.streamType&&(i=t.streamType)),e){let t=this._room.remotePublishedUserMap.get(e);t&&(r=t.remoteAudioTrack)}else r="sub"===i?this._localScreenAudioTrack:this._localAudioTrack;return r?o&&r.outMediaTrack&&r.outMediaTrack!==r.mediaTrack?r.outMediaTrack.clone():r.mediaTrack:null}getVideoTrack(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{userId:"",streamType:"main"},{userId:t="",streamType:r="main",processed:i=!1}=e,o=null;if(""===t)"main"===r&&this._localVideoTrack&&(o=this._localVideoTrack),"sub"===r&&this._localScreenTrack&&(o=this._localScreenTrack);else{let e=this._room.remotePublishedUserMap.get(t);e&&(o="main"===r?e.remoteVideoTrack:e.remoteAuxiliaryTrack)}return o?i&&o.outMediaTrack&&o.outMediaTrack!==o.mediaTrack?o.outMediaTrack.clone():o.mediaTrack:null}getVideoSnapshot(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{userId:t,streamType:r="main"}=e;if(t){let e=this._room.remotePublishedUserMap.get(t);if("main"===r&&null!=e&&e.muteState.hasVideo)return e.remoteVideoTrack.getVideoFrame();if("sub"===r&&null!=e&&e.muteState.hasAuxiliary)return e.remoteAuxiliaryTrack.getVideoFrame()}else{if("main"===r&&this._localVideoTrack)return this._localVideoTrack.getVideoFrame();if("sub"===r&&this._localScreenTrack)return this._localScreenTrack.getVideoFrame()}return""}_setCurrentSpeaker(e){var t,r;this._speakerId=e,null==(t=this._localAudioTrack)||t.setAudioOutput(e),null==(r=this._localScreenAudioTrack)||r.setAudioOutput(e),this._room.remotePublishedUserMap.forEach((t=>t.remoteAudioTrack.setAudioOutput(e)))}setCurrentSpeaker(e){return Wb(this,null,(function*(){(yield OP()).forEach((t=>{t.deviceId===e&&(this._setCurrentSpeaker(e),this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:t}),OH=t)})),this._log.warn('the "setCurrentSpeaker" method of the instance will be deprecated in the future, please use "TRTC.setCurrentSpeaker" instead. For more information, please visit: https://web.sdk.qcloud.com/trtc/webrtc/v5/doc/en/TRTC.html#.setCurrentSpeaker')}))}_startRemoteAudio(e){return this._doStartRemoteAudio(e)}_doStartRemoteAudio(e){return Wb(this,null,(function*(){let{userId:t}=e;if(this._remoteAudioConfigMap.has(t))return void this._log.warn("remote audio has already started. userId:".concat(t));let r=this._room.remotePublishedUserMap.get(t);if(!r)return;let i={},o=r.remoteAudioTrack;this._listenOutputTrackChanged(o),this._speakerId&&o.setAudioOutput(this._speakerId);try{let r=this._remoteAudioVolumeMap.get(t),n=nC(r)?r:100;i.volume=n,this._remoteAudioConfigMap.set(t,e),yield this._room.subscribe(o),Nx(sU(o,"decode-failed"),CU(sU(o,EL.INIT)),DV((()=>{this.startPlugin(wH.Name,{track:o,type:"auto",config:{codec:"opus",sampleRate:48e3,numberOfChannels:1}})}))),yield this._updateAudioPlayOption({playOption:i,track:o}),Gk.emit("115",{userId:t,room:this.room})}catch(oO){throw this._remoteAudioConfigMap.delete(t),oO}this._emitTrackEvent(o)}))}_stopRemoteAudio(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Wb(this,null,(function*(){let r=this._room.remotePublishedUserMap.get(e.userId);r&&(r.remoteAudioTrack.stop(),r.muteState.hasAudio&&t&&(yield this._room.unsubscribe(r.remoteAudioTrack)),this._mediaTrackMap.delete(r.remoteAudioTrack.outMediaTrack)),this._remoteAudioConfigMap.delete("".concat(e.userId)),Gk.emit("116",{userId:e.userId,room:this.room})}))}_enableVideoDecodeFallback(e,t){let r,i=this._room.videoDecodeFallbackType;i&&this._plugins.has("TRTCVideoDecoder")&&(e.log.debug("remote video will fall back when decode failed",e.id),Nx(sU(e,"decode-failed"),CU(sU(e,EL.INIT)),CV((()=>{this.startPlugin("TRTCVideoDecoder",{type:"auto",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:i})})),cV(sU(e,"decode-downgrade-state-changed")),DV((i=>{r=i.state,this.emit(bB.VIDEO_DECODE_DOWNGRADE_STATE_CHANGED,Pb(Lb({},i),{streamType:t,userId:e.userId}))}),(t=>{e.log.error("fallback",t)}),(()=>{"STARTED"===r&&e.log.info("fallback complete")}))))}_updateVideoPlayOption(e){return Wb(this,arguments,(function(e){let{view:t,playOption:r,track:i,prevConfig:o}=e;return function*(){if(i.setMirror(r.mirror),iC(t)&&o&&o.view&&!yC(r)){let e=bC(o.view);e.length>0&&(yield i.play(e,r))}if(!iC(t)){let e=bC(t);e.length>0?yield i.play(e,r):i.stop()}}()}))}_updateAudioPlayOption(e){return Wb(this,arguments,(function(e){let{playOption:t={},track:r,prevConfig:i}=e;return function*(){if(!r.isPlayCalled)try{yield r.play(null,t)}catch(sw){}iC(t.muted)||r.setPlayerMute(t.muted),iC(t.volume)||r.setAudioVolume(t.volume/100)}()}))}_listenOutputTrackChanged(e){0===e.listeners("output-media-track-changed").length&&e.on("output-media-track-changed",(()=>this._emitTrackEvent(e,!1)))}_emitTrackEvent(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=e.isRemote?e.userId:"";e.outMediaTrack&&(t&&this._mediaTrackMap.get(e.outMediaTrack)===r||(this._mediaTrackMap.set(e.outMediaTrack,r),this.emit(bB.TRACK,{userId:r,streamType:eB(e.streamType),track:e.outMediaTrack,sourceTrack:e.mediaTrack})))}_checkTrackToPublish(){var e,t,r;let i=[];if(null!=(e=this._localAudioConfig)&&e.publish&&this._localAudioTrack&&i.push(this._localAudioTrack),null!=(t=this._localVideoConfig)&&t.publish&&this._localVideoTrack&&i.push(this._localVideoTrack),null!=(r=this._localScreenConfig)&&r.publish&&(this._localScreenTrack&&i.push(this._localScreenTrack),this._localScreenAudioTrack&&i.push(this._localScreenAudioTrack)),0!==i.length)return this._room.publish(...i).catch((()=>{}))}_observeView(e){let{remoteTrack:t,view:r,receiveWhenViewVisible:i=!1,viewRoot:o}=e;if(iC(r))return;let n=this._remoteVideoConfigMap.get("".concat(t.userId,"_").concat(eB(t.streamType)));if(!n)return;let a=n.observer||void 0;if(null===r||cC(r)&&0===r.length||!i)return null==a||a.disconnect(),void(t.isSubscribed||this._room.subscribe(t).catch((()=>{})));let s=n.visibleViewMap||new Map,c=-1;(!a||a.root!==o)&&(null==a||a.disconnect(),s.clear(),a=new IntersectionObserver((e=>{e.forEach((e=>{s.set(e.target,e.isIntersecting),t.log.info("view ".concat(e.target.id," is").concat(e.isIntersecting?"":" not"," visible"))})),clearTimeout(c),c=window.setTimeout((()=>{[...s.values()].find((e=>e))?t.isSubscribed||this._room.subscribe(t).catch((()=>{})):t.isSubscribed&&this._room.unsubscribe(t).catch((()=>{}))}),200)}),{root:o}));let l=new Set(bC(r));s.forEach(((e,t)=>{l.has(t)||(a.unobserve(t),s.delete(t))})),l.forEach((e=>{s.set(e,!0),a.observe(e)})),a.takeRecords().forEach((e=>{s.set(e.target,e.isIntersecting)})),n.visibleViewMap=s,n.observer=a}_exitRoom(){return Wb(this,null,(function*(){this._room.isJoined&&(yield this._room.leave()),new Set([...this._remoteAudioConfigMap.keys(),...this._remoteAudioMuteMap.keys()]).forEach((e=>{this._stopRemoteAudio({userId:e}).catch()})),[...this._remoteVideoConfigMap.keys()].forEach((e=>{let t=e.includes("main")?"main":"sub",r=e.split("_".concat(t))[0];r&&this._stopRemoteVideo({userId:r,streamType:t}).catch()})),this._remoteVideoConfigMap.clear(),this._remoteAudioConfigMap.clear(),this._remoteAudioMuteMap.clear(),this._remoteAudioVolumeMap.clear(),function(e){let t=KB.get(e);t&&(t.forEach((e=>clearTimeout(e))),KB.delete(e))}(this),this._room.remotePublishedUserMap.forEach((e=>{CL(e.remoteAudioTrack),CL(e.remoteVideoTrack),CL(e.remoteAuxiliaryTrack)}))}))}_stopScreenShare(){return Wb(this,null,(function*(){var e;if(this._localScreenTrack){if(this._room.isJoined){let t=[this._localScreenTrack];this._localScreenAudioTrack&&t.push(this._localScreenAudioTrack),yield null==(e=this._room)?void 0:e.unpublish(...t).catch((()=>{}))}this._localScreenTrack.stop(),this._localScreenTrack.close(),this._localScreenAudioTrack&&(this._localScreenAudioTrack.stop(),this._localScreenAudioTrack.close(),this._room.audioManager.removeInput(this._localScreenAudioTrack),this._localScreenAudioTrack=null),CL(this._localScreenTrack),this._localScreenTrack=null,this._localScreenConfig=null}}))}_onLocalTrackCaptured(e){let{track:t}=e;"audio"===t.kind&&(!OH||wP(OH))&&(this._initActiveSpeaker(),Gk.off("102",this._onLocalTrackCaptured,this))}_initActiveSpeaker(){return Wb(this,null,(function*(){if(OH&&!wP(OH))this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:OH});else{let e=yield OP();e[0]&&!wP(e[0])?(OH=e[0],this.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e[0]})):Gk.on("102",this._onLocalTrackCaptured,this)}}))}_onAudioAvailable(e){let{userId:t}=e,r=this._remoteAudioMuteMap.has(t)?this._remoteAudioMuteMap.get(t):this._remoteAudioMuteMap.get("*");(!1===r||this._room.autoReceiveAudio&&!r)&&this._doStartRemoteAudio({userId:t}).catch((()=>{}))}_onVideoAvailable(e){let{userId:t,streamType:r}=e;if(!this._room.autoReceiveVideo)return;let i=this._room.remotePublishedUserMap.get(t);if(i){let e="main"===r?i.remoteVideoTrack:i.remoteAuxiliaryTrack,t=[e];this._room.autoReceiveAudio&&i.remoteAudioTrack.isAvailable&&t.push(i.remoteAudioTrack),this._room.subscribe(...t).then((()=>{this._emitTrackEvent(e)})).catch((()=>{}))}}_onAudioUnavailable(e){let{userId:t,muteState:r}=e;r.hasAudio&&r.audioMuted||this._stopRemoteAudio({userId:t},!1).catch((()=>{}))}_onVideoUnavailable(e){let{userId:t,streamType:r}=e;this._stopRemoteVideo({userId:t,streamType:r},!1).catch((()=>{}))}sendSEIMessage(e,t){var r;let i=this._plugins.get("SEI");i&&(i.update({buffer:e,options:Pb(Lb({seiPayloadType:243},t),{small:!(null==(r=this._localVideoTrack)||!r.small)})}),mM.addCount({key:5e5,useUV:!0}))}sendCustomMessage(e){var t,r;null==(r=(t=this._room).sendCustomMessage)||r.call(t,e),mM.addCount({key:500001,useUV:!0})}callExperimentalAPI(e,t){return Wb(this,null,(function*(){return this._log.info("callExperimentalAPI(".concat(e,", ").concat(JSON.stringify(t),")")),CH.call(e,Lb({trtcInstance:this},t))}))}static setLogLevel(e,t){Yk.setLogLevel(e),iC(t)||(t?Yk.enableUploadLog():Yk.disableUploadLog())}static isSupported(){return bM()}static getCameraList(){return NP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getMicrophoneList(){return CP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static getSpeakerList(){return OP(!(arguments.length>0&&void 0!==arguments[0])||arguments[0])}static setCurrentSpeaker(t){return Wb(this,null,(function*(){if(!cN||t!==qF.SPEAKER&&t!==qF.HEADSET)(yield OP()).forEach((e=>{e.deviceId===t&&(kH.forEach((r=>{r._setCurrentSpeaker(t),r.emit(bB.DEVICE_CHANGED,{type:"speaker",action:"active",device:e})})),OH=e)}));else{let r=yield e.getMicrophoneList(),i="";if(r.forEach((e=>{e.label===t&&(i=e.deviceId)})),!i)return;kH.forEach((e=>Wb(this,null,(function*(){e._localAudioTrack&&(yield e.updateLocalAudio({option:{microphoneId:i}}))}))))}}))}static _addKVStat(e){let{type:t,key:r,value:i,base:o,useUV:n,version:a,max:s}=e;switch(a&&(pM.version=a),t){case"count":pM.addCount({key:r,useUV:n});break;case"enum":pM.addEnum({key:r,value:i,useUV:n});break;case"number":pM.addNumber({key:r,value:i,split:o,max:s})}}};Bb(LH,"_loggerManager",Yk),Bb(LH,"EVENT",bB),Bb(LH,"ERROR_CODE",YF),Bb(LH,"TYPE",qF),Bb(LH,"frameWorkType",30),Fb([XB({replaceArg:e=>({argIndex:0,value:{name:"plugin"in e?e.plugin.Name:e.Name,assetsPath:"assetsPath"in e?null==e?void 0:e.assetsPath:"default"}})})],LH.prototype,"use",1),Fb([zB(mB.TRTC.enterRoom),AB("room",((e,t)=>{let[r]=e,[i]=t;return(r.roomId||r.strRoomId)===(i.roomId||i.strRoomId)&&r.userId===i.userId&&r.sdkAppId===i.sdkAppId})),JP((e=>function(t){return this._log.setUserId(t.userId),this._log.setSdkAppId(t.sdkAppId),e.call(this,t)})),XB()],LH.prototype,"enterRoom",1),Fb([XB()],LH.prototype,"exitRoom",1),Fb([zB(mB.TRTC.switchRoom),XB(),tx()],LH.prototype,"switchRoom",1),Fb([zB(mB.TRTC.switchRole),SB("room",{merge:(e,t)=>t}),XB()],LH.prototype,"switchRole",1),Fb([XB()],LH.prototype,"destroy",1),Fb([zB(mB.TRTC.startLocalAudio),AB("audio",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.microphoneId)===(null==(n=null==i?void 0:i.option)?void 0:n.microphoneId)})),XB()],LH.prototype,"startLocalAudio",1),Fb([zB(mB.TRTC.updateLocalAudio),SB("audio",{debounce:{delay:200,getKey:()=>"".concat(NH,"-localAudio"),isNeedToDebounce:e=>{var t;return!iC(null==(t=e.option)?void 0:t.captureVolume)}}}),XB()],LH.prototype,"updateLocalAudio",1),Fb([RB("audio"),XB()],LH.prototype,"stopLocalAudio",1),Fb([zB(mB.TRTC.startLocalVideo),AB("video",((e,t)=>{let[r]=e,[i]=t;var o,n;return(null==(o=null==r?void 0:r.option)?void 0:o.cameraId)===(null==(n=null==i?void 0:i.option)?void 0:n.cameraId)})),XB()],LH.prototype,"startLocalVideo",1),Fb([zB(mB.TRTC.updateLocalVideo),SB("video"),XB()],LH.prototype,"updateLocalVideo",1),Fb([RB("video"),XB()],LH.prototype,"stopLocalVideo",1),Fb([zB(mB.TRTC.startScreenShare),AB("screen",(()=>!0)),XB()],LH.prototype,"startScreenShare",1),Fb([zB(mB.TRTC.updateScreenShare),SB("screen"),XB()],LH.prototype,"updateScreenShare",1),Fb([XB()],LH.prototype,"stopScreenShare",1),Fb([zB(mB.TRTC.startRemoteVideo),AB((e=>"v".concat(e.userId).concat(e.streamType)),(()=>!0)),XB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],LH.prototype,"startRemoteVideo",1),Fb([zB(mB.TRTC.updateRemoteVideo),SB((e=>"v".concat(e.userId).concat(e.streamType))),XB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],LH.prototype,"updateRemoteVideo",1),Fb([zB(mB.TRTC.stopRemoteVideo),JP((e=>function(t){return Wb(this,null,(function*(){if("*"===t.userId){let e=[];return this._room.remotePublishedUserMap.forEach((t=>{this._remoteVideoConfigMap.has("".concat(t.userId,"_main"))&&e.push(this.stopRemoteVideo({streamType:"main",userId:t.userId}).catch((()=>{}))),this._remoteVideoConfigMap.has("".concat(t.userId,"_sub"))&&e.push(this.stopRemoteVideo({streamType:"sub",userId:t.userId}).catch((()=>{})))})),Promise.all(e)}return e.call(this,t)}))})),XB({getRemoteId:e=>"".concat(e.userId,"_").concat(e.streamType)})],LH.prototype,"stopRemoteVideo",1),Fb([RB((e=>"v".concat(e.userId).concat(e.streamType)))],LH.prototype,"_stopRemoteVideo",1),Fb([zB(...mB.TRTC.muteRemoteAudio),XB({getRemoteId:e=>e})],LH.prototype,"muteRemoteAudio",1),Fb([qB(...mB.TRTC.setRemoteAudioVolume),function(e,t){return JP(((r,i)=>function(){for(var i=arguments.length,o=new Array(i),n=0;n<i;n++)o[n]=arguments[n];let a=KB.get(this);a||(a=new Map,KB.set(this,a));let s=t(...o),c=a.get(s);if(!c||c<=0){r.apply(this,o);let t=setTimeout((()=>{var e;null==(e=KB.get(this))||e.delete(s)}),e);a.set(s,t)}else{clearTimeout(c);let t=window.setTimeout((()=>{var e;r.apply(this,o),null==(e=KB.get(this))||e.delete(s)}),e);a.set(s,t)}}))}(200,(e=>e)),XB({getRemoteId:e=>e})],LH.prototype,"setRemoteAudioVolume",1),Fb([$B("start"),YP((e=>{var t;return null==(t=e.afterStart)?void 0:t.call(e)})),AB(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),XB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>lM[e.getName()],ignoreLog:e=>"Debug"===e.getName()})],LH.prototype,"startPlugin",1),Fb([$B("update"),SB(((e,t)=>e.disableRandomCall?null:e.getAlias()+e.getGroup(t))),XB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>uM[e.getName()]})],LH.prototype,"updatePlugin",1),Fb([$B("stop"),RB(((e,t)=>{if(e.disableRandomCall)return null;let r=e.getGroup(t),i=e.getAlias();return"*"===r?new RegExp("".concat(i,".*")):i+r})),XB({replaceArg:e=>({argIndex:0,value:e.getName()}),getKVReportKey:e=>dM[e.getName()]})],LH.prototype,"stopPlugin",1),Fb([qB(...mB.TRTC.enableAudioVolumeEvaluation)],LH.prototype,"enableAudioVolumeEvaluation",1),Fb([XB()],LH.prototype,"getVideoSnapshot",1),Fb([XB()],LH.prototype,"_setCurrentSpeaker",1),Fb([AB((e=>"a".concat(e.userId)),(()=>!0))],LH.prototype,"_startRemoteAudio",1),Fb([JP((e=>function(t){return Wb(this,null,(function*(){return"*"===t.userId?Promise.all([...this._room.remotePublishedUserMap.values()].map((e=>this._stopRemoteAudio(Pb(Lb({},t),{userId:e.userId})).catch((()=>{}))))):e.call(this,t)}))})),RB((e=>"a".concat(e.userId)))],LH.prototype,"_stopRemoteAudio",1),Fb([RB("room")],LH.prototype,"_exitRoom",1),Fb([RB("screen")],LH.prototype,"_stopScreenShare",1),Fb([zB(...mB.TRTC.sendSEIMessage),GF({timesInSecond:30,maxSizeInSecond:8e3,getSize:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].byteLength}})],LH.prototype,"sendSEIMessage",1),Fb([zB(mB.TRTC.sendCustomMessage),GF({timesInSecond:30,maxSizeInSecond:8e3,getSize:e=>e.data.byteLength})],LH.prototype,"sendCustomMessage",1),Fb([zB(mB.TRTC.create)],LH,"_create",1);var PH=LH,xH=class{constructor(e,t){Bb(this,"_flag"),Bb(this,"terminalType"),Bb(this,"userId"),Bb(this,"tinyId"),Bb(this,"role"),Bb(this,"remoteAudioTrack"),Bb(this,"remoteVideoTrack"),Bb(this,"remoteAuxiliaryTrack"),this.userId=t.userId||"",this.tinyId=t.tinyId||"",this.role=t.role||"audience",this.terminalType=t.terminalType,this.remoteAudioTrack=new LV(e,this),this.remoteVideoTrack=new ZV(e,this),this.remoteAuxiliaryTrack=new eF(e,this),this.flag=t.flag||0}get subscribeState(){let e={audio:!1,video:!1,auxiliary:!1,smallVideo:!1};return this.remoteVideoTrack.isSubscribed&&(8&this.remoteVideoTrack.mediaType?e.smallVideo=!0:e.video=!0),this.remoteAudioTrack.isSubscribed&&(e.audio=!0),this.remoteAuxiliaryTrack.isSubscribed&&(e.auxiliary=!0),e}get muteState(){return TC(this.flag,this.userId)}get flag(){return this._flag}set flag(e){if(e===this._flag)return;let t,r=this.muteState;this._flag=e;let i=this.muteState;for(t in i)r[t]!=i[t]&&console.log(this.userId,t,r[t],"->",i[t]);this.remoteAudioTrack.onFlagChanged(),this.remoteVideoTrack.onFlagChanged(),this.remoteAuxiliaryTrack.onFlagChanged()}},UH=class{constructor(){Bb(this,"_set",new Set),Gk.on(zk.LEAVE_SUCCESS,this.delete,this),Gk.on(zk.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess,this)}add(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,r||t.roomId,t.sdkAppId,t.useStringRoomId);this._set.add(i)}delete(e){let{room:t,roomId:r}=e;if("rtc"===t.scene)return;let i=this.getKey(t.userId,t.roomId||r,t.sdkAppId,t.useStringRoomId);this._set.delete(i)}getKey(e,t,r,i){return"".concat(r,"_").concat(t,"_").concat(e,"_").concat(i)}isJoined(e){let{userId:t,roomId:r,sdkAppId:i,room:o}=e;return"rtc"!==o.scene&&this._set.has(this.getKey(t,r,i,o.useStringRoomId))}handleSwitchRoomSuccess(e){let{room:t,currentRoomId:r,targetRoomId:i}=e;"rtc"!==t.scene&&(this._set.delete(this.getKey(t.userId,r,t.sdkAppId,t.useStringRoomId)),this._set.add(this.getKey(t.userId,i,t.sdkAppId,t.useStringRoomId)))}};function VH(){return Wb(this,null,(function*(){let e,t;try{let t=yield CP();e=t&&t.length}catch(oM){}try{let e=yield NP();t=e&&e.length}catch(oM){}let r={microphone:e,camera:t},{isH264EncodeSupported:i,isVp8EncodeSupported:o,isH264DecodeSupported:n,isVp8DecodeSupported:a}=this.checkSystemResult.detail,s=$k.basis(),c={webRTC:s.isWebRTCSupported,getUserMedia:s.isGetUserMediaSupported,webSocket:s.isWebSocketsSupported,screenShare:s.isScreenShareSupported,webAudio:s.isWebAudioSupported,h264Encode:i,h264Decode:n,vp8Encode:o,vp8Decode:a},l={browser:s.browser,os:s.os,trtc:c,devices:r},u={isWebCodecSupported:s.isWebCodecSupported,isMediaSessionSupported:s.isMediaSessionSupported,isWebTransportSupported:s.isWebTransportSupported};NL.uploadEvent({log:"trtcstats-".concat(JSON.stringify(l)),userId:this.userId}),this._log.info("TrtcStats-".concat(JSON.stringify(l))),NL.uploadEvent({log:"trtcadvancedstats-".concat(JSON.stringify(u)),userId:this.userId})}))}var FH=class{constructor(e){Bb(this,"_frameWorkType"),Bb(this,"_component"),Bb(this,"_language"),Bb(this,"connectionType"),Bb(this,"_room"),Bb(this,"_signalInfo",{tinyId:void 0,clientIp:"",signalIp:"",relayIp:"",relayInnerIp:"",relayPort:0,endReportExtend:void 0}),Bb(this,"_keyPrefix"),Bb(this,"_log"),Bb(this,"_intervalId"),Bb(this,"_firstPublishedUserList"),Bb(this,"_networkQuality"),Bb(this,"_basicInfo"),Bb(this,"_pathJoinRoom"),Bb(this,"_pathLeaveRoom"),Bb(this,"_pathMainVideoMap"),Bb(this,"_pathMainAudioMap"),Bb(this,"_pathAuxiliaryMap"),Bb(this,"_remoteStreamStatMap"),Bb(this,"_localStreamStat"),Bb(this,"_eventMap",new Map),Bb(this,"_captureCostSum",0),Bb(this,"_captureCostCount",0),Bb(this,"isDestroyed",!1),this._frameWorkType=e.frameWorkType||30,this._component=e.component||0,this.connectionType=e.connectionType||1,this._language=e.language||0,this._room=e.room,this._keyPrefix="key_point",this._log=Yk.createLogger({id:"kpm",userId:this._room.userId,sdkAppId:this._room.sdkAppId}),Object.getOwnPropertyNames(this.__proto__).forEach((e=>{e.startsWith("handle")&&rC(this[e])&&(this[e]=function(e){let{fn:t,context:r}=e;return function(){try{for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];let n=t.apply(r,i);return dC(n)?n.catch((e=>Yk.error("".concat(t.name,"() error observed ").concat(e)))):n}catch(lD){Yk.error("".concat(t.name,"() error observed ").concat(lD))}}}({fn:this[e],context:this}))})),this.initData(),this.installEvents()}initData(){this._firstPublishedUserList=[],this._networkQuality={totalUplinkRTT:0,totalUplinkLoss:0,count:0,totalDownlinkRTTAndLossMap:new Map},this._basicInfo={string_sdk_version:ow,uint32_os_type:15,string_device_name:"",string_http_user_agent:navigator.userAgent,string_os_version:"",uint32_avg_rtt:0,uint32_avg_up_loss:0,uint32_scene:"live"===this._room.scene?1:0,uint32_joining_duration:0,uint32_networkType:0,uint32_framework:this._frameWorkType,uint32_component:this._component,uint32_connection_type:this.connectionType,uint32_caller_coding_language:this._language,string_domain:location.hostname},this._pathJoinRoom={uint64_start_time:0,uint64_send_request_acc_ip_cmd_start_time:0,uint64_send_request_acc_ip_cmd_end_time:0,uint64_send_request_enter_room_cmd_start_time:0,uint64_send_request_enter_room_cmd_end_time:0,uint64_send_first_video_frame_time:0,uint64_recv_userlist_time:0,uint64_end_time:0,int32_send_request_acc_ip_cmd_ret:0,int32_send_request_enter_room_cmd_ret:0,int32_end_ret:0},this._pathLeaveRoom={uint64_start_time:0,uint64_send_request_exit_room_cmd_start_time:0,uint64_send_request_exit_room_cmd_end_time:0,uint64_end_time:0,int32_send_request_exit_room_cmd_ret:0,int32_end_ret:0},this._localStreamStat={totalVideoBitrate:0,totalVideoFPS:0,totalVideoHeight:0,totalVideoWidth:0,totalAudioLevel:0,videoCount:0,audioLevelCount:0,publishStartTime:0,statsToReport:{uint32_audio_capture_db:0,uint32_video_big_capture_fps:0,uint32_video_big_bitrate:0,uint32_video_big_resolution:0}},this._pathMainVideoMap=new Map,this._pathMainAudioMap=new Map,this._pathAuxiliaryMap=new Map,this._remoteStreamStatMap=new Map,Lk().then((e=>{this._basicInfo.string_os_version=Bk(),this._basicInfo.string_device_name=e&&e.mobile?e.model:this._basicInfo.string_os_version}))}addEvent(e,t){return this._eventMap.set(e,t),Gk.on(e,t),this}installEvents(){this.handleUnload=this.handleUnload.bind(this),window.addEventListener("pagehide",this.handleUnload),this._room.once("banned",(()=>this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId}))),this.addEvent(zk.JOIN_START,this.handleJoinStart).addEvent(zk.JOIN_SCHEDULE_SUCCESS,this.handleJoinScheduleSuccess).addEvent(zk.JOIN_SIGNAL_CONNECTION_START,this.handleSignalConnectionStart).addEvent(zk.JOIN_SIGNAL_CONNECTION_END,this.handleSignalConnectionEnd).addEvent(zk.JOIN_SEND_CMD,this.handleJoinSendCMD).addEvent(zk.JOIN_RECEIVED_CMD_RES,this.handleJoinReceivedCMDResponce).addEvent(zk.JOIN_SUCCESS,this.handleJoinSuccess).addEvent(zk.JOIN_FAILED,this.handleJoinFailed).addEvent(zk.LEAVE_START,this.handleLeaveStart).addEvent(zk.LEAVE_SUCCESS,this.handleLeaveSuccess).addEvent(zk.LEAVE_SEND_CMD,this.handleLeaveSendCMD).addEvent(zk.LOCAL_TRACK_CAPTURE_START,this.handleTrackCaptureStart).addEvent(zk.LOCAL_TRACK_CAPTURE_SUCCESS,this.handleTrackCaptureSuccess).addEvent(zk.LOCAL_TRACK_CAPTURE_FAILED,this.handleTrackCaptureFailed).addEvent(zk.PUBLISH_START,this.handlePublishStart).addEvent(zk.SEND_FIRST_VIDEO_FRAME,this.handleSendFirstVideoFrame).addEvent(zk.SUBSCRIBE_START,this.handleSubscribeStart).addEvent(zk.SUBSCRIBE_SUCCESS,this.handleSubscribed).addEvent(zk.PLAY_TRACK_START,this.handlePlayStart).addEvent(zk.VIDEO_LOADED_DATA,this.handleVideoLoadedData).addEvent(zk.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,type:i}=e;!t.isRemote||!this.hitTest(t.room)||"PLAYING"===r&&(i===Pw.AUDIO?this.handleAudioPlaying(t):this.handleVideoPlaying(t))})).addEvent(zk.SWITCH_ROOM_START,this.handleSwitchRoomStart).addEvent(zk.SWITCH_ROOM_SUCCESS,this.handleSwitchRoomSuccess).addEvent(zk.SWITCH_ROOM_FAILED,this.handleSwitchRoomFailed).addEvent(zk.NETWORK_QUALITY,this.handleNetworkQuality).addEvent(zk.HEARTBEAT_REPORT,this.handleHeartbeatStats).addEvent(zk.RECEIVED_PUBLISHED_USER_LIST,this.handleReceivedPublishUserList).addEvent(zk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let o=r.hasAudio||r.hasVideo||r.hasSmall,n=r.hasAuxiliary,a=i.hasAudio||i.hasVideo||i.hasSmall,s=i.hasAuxiliary;!o&&a&&this.handleRemoteStreamAdded(i.userId,"main"),!n&&s&&this.handleRemoteStreamAdded(i.userId,"auxiliary")})).addEvent(zk.SINGLE_CONNECTION_STAT,(e=>{let{room:t,stat:r}=e;this.hitTest(t)&&(this._pathJoinRoom.int32_ice_cost=r.ice,this._pathJoinRoom.int32_dtls_cost=r.dtls,this._pathJoinRoom.int32_peer_connection_cost=r.peerConnection)}))}uninstallEvents(){window.removeEventListener("pagehide",this.handleUnload),this._eventMap.forEach(((e,t)=>Gk.off(t,e))),this._eventMap.clear()}destroy(){this.uninstallEvents(),SL.clearTask(this._intervalId),0===this._pathJoinRoom.uint64_start_time&&(this._room=null),this.isDestroyed=!0}handleUnload(){this._room.isJoined&&this.handleLeaveSuccess({room:this._room,roomId:this._room.roomId})}handleJoinStart(e){this.hitTest(e.room)&&(0===this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_start_time=Date.now()),e.params&&(iC(e.params.frameWorkType)||(this._frameWorkType=e.params.frameWorkType,this._basicInfo.uint32_framework=this._frameWorkType),iC(e.params.component)||(this._component=e.params.component,this._basicInfo.uint32_component=this._component),iC(e.params.language)||(this._language=e.params.language,this._basicInfo.uint32_caller_coding_language=this._language)))}handleJoinScheduleSuccess(e){let{room:t,detailCost:r}=e;if(this.hitTest(t)&&r){let{totalCost:e,local:t,dns:i,tcp:o,tls:n,request:a,response:s}=r;this._pathJoinRoom.int32_schedule_cost=e,this._pathJoinRoom.int32_schedule_local=t,this._pathJoinRoom.int32_schedule_dns=i,this._pathJoinRoom.int32_schedule_tcp=o,this._pathJoinRoom.int32_schedule_tls=n,this._pathJoinRoom.int32_schedule_request=a,this._pathJoinRoom.int32_schedule_response=s}}handleSignalConnectionStart(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_start_time=Date.now())}handleSignalConnectionEnd(e){let{room:t,error:r}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_acc_ip_cmd_end_time=Date.now(),r&&(this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret=r instanceof $b?Number(r.getExtraCode()||r.getCode()):Jb.UNKNOWN,this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret))}handleJoinSendCMD(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=Date.now())}handleJoinReceivedCMDResponce(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time&&(this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=Date.now(),this._pathJoinRoom.int32_send_request_enter_room_cmd_ret=e.code,0!==e.code&&(this._pathJoinRoom.int32_end_ret=this._pathJoinRoom.int32_send_request_enter_room_cmd_ret))}handleJoinSuccess(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_end_time&&(this._pathJoinRoom.uint64_end_time=Date.now(),this._pathJoinRoom.int32_end_ret=0,this._signalInfo=e.room.getSignalInfo())}handleJoinFailed(e){let{room:t,error:r}=e;this.hitTest(t)&&(this._pathJoinRoom.uint64_end_time=Date.now(),0===this._pathJoinRoom.int32_end_ret&&(this._pathJoinRoom.int32_end_ret=r.code||this._pathJoinRoom.int32_send_request_enter_room_cmd_ret||this._pathJoinRoom.int32_send_request_acc_ip_cmd_ret),setTimeout((()=>{this.report()})))}handleReceivedPublishUserList(e){this.hitTest(e.room)&&0===this._pathJoinRoom.uint64_recv_userlist_time&&(this._pathJoinRoom.uint64_recv_userlist_time=Date.now(),this._firstPublishedUserList=e.publishedUserList||[])}handleSendFirstVideoFrame(e){let{room:t}=e;this.hitTest(t)&&0===this._pathJoinRoom.uint64_send_first_video_frame_time&&0!==this._pathJoinRoom.uint64_start_time&&(this._pathJoinRoom.uint64_send_first_video_frame_time=Date.now())}handleLeaveStart(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_start_time=Date.now())}handleLeaveSuccess(e){this.hitTest(e.room)&&0===this._pathLeaveRoom.uint64_end_time&&(this._pathLeaveRoom.uint64_end_time=Date.now(),0!==this._pathJoinRoom.uint64_end_time?this._basicInfo.uint32_joining_duration=this._pathLeaveRoom.uint64_end_time-this._pathJoinRoom.uint64_end_time:this._log.warn("pathJoinRoom endTime is 0"),this.report())}handleLeaveSendCMD(e){this.hitTest(e.room)&&(this._pathLeaveRoom.uint64_send_request_exit_room_cmd_start_time=Date.now(),this._pathLeaveRoom.uint64_send_request_exit_room_cmd_end_time=Date.now())}handleSwitchRoomStart(e){if(this.hitTest(e.room)){let e=Date.now();this.report().then((()=>{this._pathJoinRoom.uint64_start_time=e,this._pathJoinRoom.uint64_send_request_enter_room_cmd_start_time=e}))}}handleSwitchRoomSuccess(e){let{room:t}=e;if(this.hitTest(t)&&0===this._pathJoinRoom.uint64_end_time){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,this._pathJoinRoom.int32_end_ret}}handleSwitchRoomFailed(e){let{room:t,error:r}=e;if(this.hitTest(t)){let e=Date.now();this._pathJoinRoom.uint64_send_request_enter_room_cmd_end_time=e,this._pathJoinRoom.uint64_end_time=e,r&&(this._pathJoinRoom.int32_end_ret=r instanceof $b?Number(r.getExtraCode()||r.getCode()):Jb.UNKNOWN)}}handleRemoteStreamAdded(e,t){var r;let i="".concat(e,"_").concat(t);if(!this._remoteStreamStatMap.has(i)){let o={userId:e,totalVideoFPS:0,totalVideoBitrate:0,totalAudioLevel:0,totalAudioBitrate:0,totalLoss:0,audioCount:0,audioLevelCount:0,videoCount:0,networkQualityCount:0,streamAddedTime:Date.now(),subscribeStartTime:0,subscribedTime:0,playStreamTime:0,statsToReport:Pb(Lb({},HH),{msg_user_info:new WH({userId:e,tinyId:null==(r=this._room.remotePublishedUserMap.get(e))?void 0:r.tinyId,role:20})})};o.statsToReport.uint32_stream_type="main"===t?2:7,this._remoteStreamStatMap.set(i,o)}}handleSubscribeStart(e){let{room:t,remotePublishedUser:r,streamType:i,subscribeState:o}=e;if(!this.hitTest(t))return;let{userId:n,tinyId:a,role:s}=r,c=new WH({userId:n,tinyId:a,role:"anchor"===s?20:21}),l=Date.now(),u="".concat(n,"_").concat(i),d=this._remoteStreamStatMap.get(u);d&&0===d.subscribeStartTime&&(d.subscribeStartTime=l),"main"===i?(r.muteState.hasVideo&&(o.video||o.smallVideo)&&!this._pathMainVideoMap.has(u)&&this._pathMainVideoMap.set(u,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_render_first_frame_time:0,uint64_combine_first_frame_time:0},userId:n,sendSubscribeCMDTime:l}),r.muteState.hasAudio&&o.audio&&!this._pathMainAudioMap.has(u)&&this._pathMainAudioMap.set(u,{statsToReport:{msg_user_info:c,uint64_start_enter_time:this._pathJoinRoom.uint64_start_time,uint64_play_first_frame_time:0},userId:n,sendSubscribeCMDTime:l})):r.muteState.hasAuxiliary&&o.auxiliary&&!this._pathAuxiliaryMap.has(u)&&this._pathAuxiliaryMap.set(u,{sendSubscribeCMDTime:l})}handleSubscribed(e){let{room:t,remotePublishedUser:r,streamType:i}=e;if(this.hitTest(t)){let e="".concat(r.userId,"_").concat(i),t=this._remoteStreamStatMap.get(e);t&&0===t.subscribedTime&&(t.subscribedTime=Date.now())}}handlePlayStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._remoteStreamStatMap.get(r);0===(null==i?void 0:i.playStreamTime)&&(i.playStreamTime=Date.now())}handleVideoLoadedData(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room))return;let r="".concat(t.userId,"_").concat(t.streamType),i=this._pathMainVideoMap.get(r);i&&0===i.statsToReport.uint64_combine_first_frame_time&&(i.statsToReport.uint64_combine_first_frame_time=Date.now())}handleVideoPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=Date.now(),i=this._pathMainVideoMap.get(t),o=this._remoteStreamStatMap.get(t);if(o){let{statsToReport:t}=o;if(t.uint32_video_render_first||"main"!==e.streamType?this.hasAuxFlag(e.userId):this.hasVideoFlag(e.userId)){let e=r-this._pathJoinRoom.uint64_start_time;t.uint32_video_render_first=e,mM.addNumber({key:516820,value:e})}}0===(null==i?void 0:i.statsToReport.uint64_render_first_frame_time)&&(i.statsToReport.uint64_render_first_frame_time=r)}handleAudioPlaying(e){let t="".concat(e.userId,"_").concat(e.streamType),r=this._pathMainAudioMap.get(t);r&&0===r.statsToReport.uint64_play_first_frame_time&&(r.statsToReport.uint64_play_first_frame_time=Date.now())}handleNetworkQuality(e){this.hitTest(e.room)&&(this._networkQuality.totalUplinkLoss+=e.uplink.loss,this._networkQuality.totalUplinkRTT+=e.uplink.rtt,this._networkQuality.count++,e.downlinks.forEach((e=>{let{rtt:t,loss:r,userId:i,videoDelay:o,audioDelay:n}=e,a=this._networkQuality.totalDownlinkRTTAndLossMap.get(i);if(a)a.totalRTT+=t,a.totalLoss+=r,o&&(a.totalVideoDelay=(a.totalVideoDelay||0)+o,a.videoDelayCount=(a.videoDelayCount||0)+1),n&&(a.totalAudioDelay=(a.totalAudioDelay||0)+n,a.audioDelayCount=(a.audioDelayCount||0)+1),a.count++;else{let e,a,s,c;o&&(a=o,s=1),n&&(e=n,c=1),this._networkQuality.totalDownlinkRTTAndLossMap.set(i,{totalRTT:t,totalLoss:r,count:1,totalAudioDelay:e,totalVideoDelay:a,audioDelayCount:c,videoDelayCount:s})}})))}handleHeartbeatStats(e){if(this.hitTest(e.room)){let{msg_device_info:t,msg_up_stream_info:r,msg_down_stream_info:i}=e.report;if(r.msg_video_status[0]){let{uint32_video_codec_bitrate:e,uint32_video_enc_fps:t,uint32_video_width:i,uint32_video_height:o}=r.msg_video_status[0];this._localStreamStat.totalVideoBitrate+=e,this._localStreamStat.totalVideoFPS+=t,this._localStreamStat.totalVideoWidth+=i,this._localStreamStat.totalVideoHeight+=o,this._localStreamStat.videoCount++}if(r.msg_audio_status){let{uint32_audio_level:e}=r.msg_audio_status;Math.floor(e/WO*100)>0&&(this._localStreamStat.totalAudioLevel+=e/WO,this._localStreamStat.audioLevelCount++)}i.forEach((e=>{let{msg_user_info:t,msg_audio_status:r,msg_video_status:i}=e,o=t.str_identifier,n=this._room.remotePublishedUserMap.get(o);if(i.forEach((e=>{let t=2===e.uint32_video_stream_type,r=7===e.uint32_video_stream_type,i="".concat(o,"_").concat(t?"main":"auxiliary"),a=this._remoteStreamStatMap.get(i);if(a&&(t&&null!=n&&n.remoteVideoTrack.isSubscribed||r&&null!=n&&n.remoteAuxiliaryTrack)){a.totalVideoFPS+=e.uint32_video_receive_fps,a.totalVideoBitrate+=e.uint32_video_codec_bitrate,a.videoCount++,0===a.statsToReport.uint32_video_width&&(a.statsToReport.uint32_video_width=e.uint32_video_width),0===a.statsToReport.uint32_video_height&&(a.statsToReport.uint32_video_height=e.uint32_video_height);let r=t?n.remoteVideoTrack:n.remoteAuxiliaryTrack;r.stat.jitterBufferDelay&&(a.videoJitterBufferDelay=r.stat.jitterBufferDelay),r.stat.framesReceived&&(a.statsToReport.uint32_video_consume_render_rate=Math.floor(r.stat.framesDecoded/r.stat.framesReceived*Ob(10,6)))}})),!yC(r)){let e="".concat(o,"_main"),t=this._remoteStreamStatMap.get(e);this._remoteStreamStatMap.has(e)&&t&&null!=n&&n.remoteAudioTrack.isSubscribed&&(t.totalAudioBitrate+=r.uint32_audio_codec_bitrate,t.audioCount++,n.remoteAudioTrack.stat.jitterBufferDelay&&(t.audioJitterBufferDelay=n.remoteAudioTrack.stat.jitterBufferDelay),Math.floor(r.uint32_audio_level/WO*100)>0&&(t.totalAudioLevel+=r.uint32_audio_level/WO,t.audioLevelCount++))}})),t.uint32_audio_capture_cost&&(this._captureCostSum+=t.uint32_audio_capture_cost,this._captureCostCount+=1,this._captureCostCount>=100&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0))}}handlePublishStart(e){let{room:t}=e;this.hitTest(t)&&0===this._localStreamStat.publishStartTime&&(this._localStreamStat.publishStartTime=Date.now())}handleTrackCaptureStart(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_start_time&&(this._pathJoinRoom.uint64_init_audio_start_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_start_time&&(this._pathJoinRoom.uint64_init_camera_start_time=Date.now())}handleTrackCaptureSuccess(e){let{track:t}=e;1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=0,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=0,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}handleTrackCaptureFailed(e){let{track:t,error:r}=e,i={NotFoundError:1,NotAllowedError:2,NotReadableError:3,OverConstrainedError:4,AbortError:5,InvalidStateError:6,SecurityError:7,TypeError:8}[r.name]||(r instanceof $b?r.getExtraCode()||r.getCode():Jb.UNKNOWN);1===t.mediaType&&!this._pathJoinRoom.uint64_init_audio_end_time&&(this._pathJoinRoom.int32_init_audio_ret=i,this._pathJoinRoom.uint64_init_audio_end_time=Date.now()),4===t.mediaType&&!this._pathJoinRoom.uint64_init_camera_end_time&&(this._pathJoinRoom.int32_init_camera_ret=i,this._pathJoinRoom.uint64_init_camera_end_time=Date.now())}hasVideoFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Fw))>=0}hasAudioFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Ww))>=0}hasAuxFlag(e){return this._firstPublishedUserList.findIndex((t=>t.userId===e&&t.flag&Hw))>=0}hitTest(e){return e===this._room}prepareReport(){if(this._captureCostCount>0&&!this._basicInfo.uint32_audio_capture_cost&&(this._basicInfo.uint32_audio_capture_cost=Math.floor(this._captureCostSum/this._captureCostCount),this._captureCostSum=0,this._captureCostCount=0),this._networkQuality.count>0&&(this._basicInfo.uint32_avg_rtt=Math.floor(this._networkQuality.totalUplinkRTT/this._networkQuality.count),this._basicInfo.uint32_avg_up_loss=Math.floor(this._networkQuality.totalUplinkLoss/this._networkQuality.count)),this._localStreamStat.videoCount>0){this._localStreamStat.statsToReport.uint32_video_big_capture_fps=Math.floor(this._localStreamStat.totalVideoFPS/this._localStreamStat.videoCount),this._localStreamStat.statsToReport.uint32_video_big_bitrate=Math.floor(this._localStreamStat.totalVideoBitrate/this._localStreamStat.videoCount);let e=Math.floor(this._localStreamStat.totalVideoWidth/this._localStreamStat.videoCount),t=Math.floor(this._localStreamStat.totalVideoHeight/this._localStreamStat.videoCount);this._localStreamStat.statsToReport.uint32_video_big_resolution=e<<16|t}this._localStreamStat.audioLevelCount>0&&(this._localStreamStat.statsToReport.uint32_audio_capture_db=Math.floor(this._localStreamStat.totalAudioLevel/this._localStreamStat.audioLevelCount*100)),this._remoteStreamStatMap.forEach(((e,t)=>{let{userId:r}=e,i=this._networkQuality.totalDownlinkRTTAndLossMap.get(r);if(i){let{totalLoss:t,count:r,audioDelayCount:o,videoDelayCount:n,totalAudioDelay:a,totalVideoDelay:s}=i;e.statsToReport.uint32_avg_down_loss=Math.floor(t/r),o&&a&&(e.statsToReport.uint32_audio_network_p2p_delay=Math.floor(a/o),e.audioJitterBufferDelay&&(e.statsToReport.uint32_p2p_delay=Math.floor(e.statsToReport.uint32_audio_network_p2p_delay+e.audioJitterBufferDelay))),n&&s&&(e.statsToReport.uint32_video_network_p2p_delay=Math.floor(s/n))}e.videoCount>0&&(e.statsToReport.uint32_video_avg_fps=Math.floor(e.totalVideoFPS/e.videoCount),e.statsToReport.uint32_video_avg_bitrate=Math.floor(e.totalVideoBitrate/e.videoCount)),e.audioCount>0&&(e.statsToReport.uint32_audio_recv_bitrate=e.statsToReport.uint32_audio_bitrate=Math.floor(e.totalAudioBitrate/e.audioCount)),e.audioLevelCount>0&&(e.statsToReport.uint32_audio_play_db=Math.floor(e.totalAudioLevel/e.audioLevelCount*100));let{callDurationCalculator:o}=this._room;o&&(e.statsToReport.uint32_audio_play_time=o.getDuration(t,Pw.AUDIO),e.statsToReport.uint32_video_play_time=o.getDuration(t,Pw.VIDEO)),e.statsToReport.uint32_video_render_first&&(e.statsToReport.uint32_video_render_first=Math.min(e.statsToReport.uint32_video_render_first,BH));let{badCaseDetector:n}=this._room,{dataFreeze:a,count:s}=n.getDataFreezeDuration(t),{renderFreeze:c}=n.getRenderFreezeDuration(t);e.statsToReport.uint32_video_block_count=s,e.statsToReport.uint32_video_block_time=Math.min(a,e.statsToReport.uint32_video_play_time),e.statsToReport.uint32_video_external_block_time=Math.min(c,e.statsToReport.uint32_video_play_time),n.isBlackStream(t)&&0===e.statsToReport.uint32_video_avg_fps?e.statsToReport.uint32_video_black_screen_subjective=1:e.statsToReport.uint32_video_black_screen_subjective=0})),this._pathMainAudioMap.forEach(((e,t)=>{this.hasAudioFlag(e.userId)?e.statsToReport.uint64_play_first_frame_time-e.statsToReport.uint64_start_enter_time>BH&&(e.statsToReport.uint64_play_first_frame_time=e.statsToReport.uint64_start_enter_time+BH):this._pathMainAudioMap.delete(t)})),this._pathMainVideoMap.forEach(((e,t)=>{this.hasVideoFlag(e.userId)?e.statsToReport.uint64_render_first_frame_time-e.statsToReport.uint64_start_enter_time>BH&&(e.statsToReport.uint64_render_first_frame_time=e.statsToReport.uint64_start_enter_time+BH):this._pathMainVideoMap.delete(t)})),this._pathJoinRoom.uint64_end_time-this._pathJoinRoom.uint64_start_time>BH&&(this._pathJoinRoom.uint64_end_time=this._pathJoinRoom.uint64_start_time+BH)}getReportData(){this._basicInfo.uint32_networkType=GD();let e={uint32_sdk_app_id:Number(this._room.sdkAppId),msg_user_info:new WH({userId:this._room.userId,tinyId:this._room.tinyId,role:"anchor"===this._room.role?20:21}),msg_basic_info:this._basicInfo,uint32_acc_ip:AC(this._signalInfo.relayIp),uint32_client_ip:AC(this._signalInfo.clientIp,!1),uint32_acc_port:this._signalInfo.relayPort||0,uint64_timestamp:Date.now(),uint32_seq:Math.floor(Math.random()*Ob(2,31)),msg_path_enter_room:this._pathJoinRoom,msg_path_exit_room:this._pathLeaveRoom,msg_path_recv_video:[...this._pathMainVideoMap.values()].map((e=>e.statsToReport)),msg_quality_statistics:[...this._remoteStreamStatMap.values()].map((e=>e.statsToReport)),str_room_name:String(this._room.roomId||0),msg_path_recv_audio:[...this._pathMainAudioMap.values()].map((e=>e.statsToReport)),uint32_info_client_ip:AC(this._signalInfo.clientIp,!1),error_code:[],msg_local_statistics:this._localStreamStat.statsToReport,bytes_report_buf_from_0x1:this._signalInfo.endReportExtend};return PC(e),e}report(){return Wb(this,null,(function*(){try{this.prepareReport();let e=this.getReportData();yield this.upload(e),this.initData()}catch(rO){this._log.warn(rO)}finally{this.isDestroyed&&(this._room=null)}}))}upload(e){return Wb(this,null,(function*(){if(0===e.msg_path_enter_room.uint64_start_time)return;let t=Number(this._room.sdkAppId),r=yield jC(e),i=r instanceof ArrayBuffer,o="".concat(FD(t,Aw.KEY_POINT),"&gzip=").concat(+i),n=!1;navigator.sendBeacon&&(n=navigator.sendBeacon(o,r));let a=[this.uploadKVStat(mM),this.uploadKVStat(pM)];n||a.push(WC({url:o,body:r,priority:"low"})),yield Promise.all(a)}))}setConnectionType(e){this.connectionType=e,this._basicInfo.uint32_connection_type=e}uploadKVStat(e){return Wb(this,null,(function*(){let t=e.getReportData();if(0===t.stats_count.length&&0===t.stats_distribution.length)return;t.msg_sdk_basic_info=Pb(Lb({},t.msg_sdk_basic_info),{bytes_device_name:this._basicInfo.string_device_name||"",bytes_os_version:this._basicInfo.string_os_version||"",uint32_framework:this._frameWorkType,uint32_network_type:this._basicInfo.uint32_networkType||0}),this._log.debug(t);let r=yield jC(t),i="".concat(FD(+this._room.sdkAppId,Aw.KV_STAT),"&gzip=").concat(+(r instanceof ArrayBuffer)),o=!1;navigator.sendBeacon&&(o=navigator.sendBeacon(i,r)),o||WC({url:i,body:r})}))}};Fb([OL({settings:{timeout:500,retries:3}})],FH.prototype,"upload",1);var BH=5e3,HH={msg_user_info:null,uint32_video_avg_fps:0,uint32_video_width:0,uint32_video_height:0,uint32_video_avg_bitrate:0,uint32_video_block_time:0,uint32_video_play_time:0,uint32_audio_block_time:0,uint32_audio_play_time:0,uint32_audio_play_db:0,uint32_avg_down_loss:0,uint32_stream_type:0,uint32_video_block_count:0,uint32_audio_block_count:0,uint32_audio_bitrate:0,uint32_video_black_screen_subjective:0,uint32_audio_recv_bitrate:0,uint32_video_external_block_time:0,uint32_video_consume_render_rate:0},WH=class{constructor(e){Bb(this,"str_identifier"),Bb(this,"str_tinyid"),Bb(this,"uint32_role"),this.str_identifier=String(e.userId),this.str_tinyid=String(e.tinyId||0),this.uint32_role=e.role}},jH=FH,GH=class{constructor(){Bb(this,"_startTime"),Bb(this,"_endTime"),this._startTime=0,this._endTime=0,this.start()}start(){0===this._startTime&&(this._startTime=_C())}stop(){0===this._endTime&&(this._endTime=_C())}getDuration(){return 0===this._endTime?_C()-this._startTime:this._endTime-this._startTime}get startTime(){return this._startTime}get endTime(){return this._endTime}},KH=class{constructor(e){Bb(this,"_room",null),Bb(this,"_durationMap"),Bb(this,"_eventMap",new Map),this._room=e.room,this._durationMap=new Map,this.installEvents()}installEvents(){this._eventMap.set(zk.REMOTE_TRACK_SUBSCRIBED,this.handleSubscribed).set(zk.REMOTE_TRACK_UNSUBSCRIBED,this.handleUnsubscribed).set(zk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;var o;let{userId:n}=i;if(!this.hitTest(t))return;r.hasAudio&&!i.hasAudio&&this.stopDurationItem("".concat(n,"_main"),Pw.AUDIO),r.hasVideo&&!i.hasVideo&&this.stopDurationItem("".concat(n,"_main"),Pw.VIDEO),r.hasAuxiliary&&!i.hasAuxiliary&&this.stopDurationItem("".concat(n,"_auxiliary"),Pw.VIDEO);let a=null==(o=this._room)?void 0:o.remotePublishedUserMap.get(n);a&&(!r.hasAudio&&i.hasAudio&&a.remoteAudioTrack.isSubscribed&&this.addDuractionItem(n,Pw.AUDIO,"main"),!r.hasVideo&&i.hasVideo&&a.remoteVideoTrack.isSubscribed&&this.addDuractionItem(n,Pw.VIDEO,"main"),!r.hasAuxiliary&&i.hasAuxiliary&&a.remoteAuxiliaryTrack.isSubscribed&&this.addDuractionItem(n,Pw.VIDEO,"auxiliary"))})),this._eventMap.forEach(((e,t)=>Gk.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>Gk.off(t,e,this))),this._eventMap.clear()}handleSubscribed(e){let{track:t}=e;if(!this.hitTest(t.room))return;let{userId:r,streamType:i,kind:o}=t;t.isSubscribed?this.addDuractionItem(r,o,i):this.stopDurationItem("".concat(r,"_").concat(i),o)}handleUnsubscribed(e){let{track:t}=e;this.hitTest(t.room)&&this.stopDurationItem("".concat(t.userId,"_").concat(t.streamType),t.kind)}isRecording(e){return e.findIndex((e=>0===e.endTime))>=0}addDuractionItem(e,t,r){let i="".concat(e,"_").concat(r),o=new GH,n=this._durationMap.get(i);n?this.isRecording(n[t])||n[t].push(o):this._durationMap.set(i,{userId:e,type:r,audio:t===Pw.AUDIO?[o]:[],video:t===Pw.AUDIO?[]:[o]})}stopDurationItem(e,t){if(this._durationMap.has(e)){let r=this._durationMap.get(e)[t].find((e=>0===e.endTime));r&&r.stop()}}hitTest(e){return this._room===e}getDuration(e,t){return this._durationMap.has(e)?this._durationMap.get(e)[t].reduce(((e,t)=>e+t.getDuration()),0):0}getDurationMap(){return this._durationMap}reset(){this._durationMap.clear()}destroy(){this._room=null,this.uninstallEvents()}},zH=class{constructor(e){Bb(this,"_room"),Bb(this,"_renderFreezeMap",new Map),Bb(this,"_isVideoPlayingEventFiredMap",new Map),Bb(this,"_dataFreezeMap",new Map),Bb(this,"_monitorFreezeData",new Map),Bb(this,"_eventMap",new Map),this._room=e.room,this.installEvents()}getRenderFreezeMap(){return this._renderFreezeMap}getDataFreezeMap(){return this._dataFreezeMap}installEvents(){this._eventMap.set(zk.LEAVE_SUCCESS,(e=>{let{room:t}=e;this.hitTest(t)&&this.stop()})).set(zk.PLAY_TRACK_START,this.onPlayTrackStart).set(zk.UNSUBSCRIBE_SUCCESS,(e=>{let{room:t,streamType:r,remotePublishedUser:i}=e;if(!this.hitTest(t))return;let{userId:o}=i,n="".concat(o,"_").concat(r);this.stopDataFreeze({key:n,userId:o,type:r})})).set(zk.REMOTE_PUBLISH_STATE_CHANGED,(e=>{let{room:t,prevMuteState:r,muteState:i}=e;if(!this.hitTest(t))return;let{userId:o}=i;if(r.hasVideo&&!i.hasVideo){let e="main",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}if(r.hasAuxiliary&&!i.hasAuxiliary){let e="auxiliary",t="".concat(i.userId,"_").concat(e);this.stopDataFreeze({key:t,userId:o,type:e})}})).set(zk.PLAYER_STATE_CHANGED,(e=>{let{track:t,state:r,reason:i,type:o}=e;if(t.isRemote&&t.room&&this.hitTest(t.room)&&o===Pw.VIDEO){if("PLAYING"===r){let e="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.set(e,!0)}i===Pw.MUTE?this.onVideoTrackMuted(t):i===Pw.UNMUTE&&this.onVideoTrackUnmuted(t)}})).set(zk.HEARTBEAT_REPORT,this.onHearBeatReport),this._eventMap.forEach(((e,t)=>Gk.on(t,e,this)))}uninstallEvents(){this._eventMap.forEach(((e,t)=>Gk.off(t,e,this))),this._eventMap.clear()}stop(){this._renderFreezeMap.clear(),this._dataFreezeMap.clear(),this._isVideoPlayingEventFiredMap.clear()}onVideoTrackMuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r),o=this._dataFreezeMap.get(i),n=new GH;o?o.durationItemList.push(n):this._dataFreezeMap.set(i,{userId:t,type:r,durationItemList:[n],isFreezing(){let e=this.durationItemList[this.durationItemList.length-1];return e&&0===e.endTime}})}onVideoTrackUnmuted(e){if(!e.isSubscribed)return;let{userId:t,streamType:r}=e,i="".concat(t,"_").concat(r);this.stopDataFreeze({key:i,userId:t,type:r})}onHearBeatReport(e){let{room:t,report:r}=e;this.hitTest(t)&&r.msg_down_stream_info.forEach((e=>{let t=this._room.remotePublishedUserMap.get(e.msg_user_info.str_identifier);if(!t)return;let{userId:r,muteState:i}=t;e.msg_video_status.forEach((e=>{2===e.uint32_video_stream_type&&i.hasVideo&&!i.videoMuted&&t.remoteVideoTrack.isSubscribed&&this.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"main"}),7===e.uint32_video_stream_type&&i.hasAuxiliary&&t.remoteAuxiliaryTrack.isSubscribed&&this.handleRenderFreeze({userId:r,fps:e.uint32_video_dec_fps,type:"auxiliary"})}))}))}stopDataFreeze(e){let{key:t,userId:r,type:i}=e,o=this._dataFreezeMap.get(t);if(!o||!o.isFreezing())return;let n=o.durationItemList[o.durationItemList.length-1];n.stop();let a=n.getDuration();a>vD?this._monitorFreezeData.set(t,{userId:r,type:i,duration:a}):o.durationItemList.pop()}getTotalDuration(e){return e.reduce(((e,t)=>{let r=t.getDuration();return e+Math.min(r,5e3)}),0)}handleRenderFreeze(e){return Wb(this,arguments,(function(e){var t=this;let{userId:r,fps:i,type:o}=e;return function*(){let e="".concat(r,"_").concat(o),n=t._renderFreezeMap.get(e);if(i<=2){let i=_C();n&&!n.isFreeze&&(n.freezeTimeline.push({startTime:i,endTime:0}),n.isFreeze=!0),n||t._renderFreezeMap.set(e,{userId:r,type:o,isFreeze:!0,freezeTimeline:[{startTime:i,endTime:0}],renderFreezeTotal:0})}else if(n&&n.isFreeze){n.isFreeze=!1;let e=n.freezeTimeline.pop();if(e){e.endTime=_C();let t=e.endTime-e.startTime;n.freezeTimeline.push(e),n.renderFreezeTotal+=Math.min(5e3,t)}}}()}))}onPlayTrackStart(e){let{track:t}=e;if(!t.isRemote||!this.hitTest(t.room)||t.kind!==Pw.VIDEO||!t.isRemotePublished)return;let r="".concat(t.userId,"_").concat(t.streamType);this._isVideoPlayingEventFiredMap.has(r)||this._isVideoPlayingEventFiredMap.set(r,!1)}getDataFreezeDuration(e){let t={dataFreeze:0,count:0},r=this._dataFreezeMap.get(e);if(r){if(r.isFreezing()){let e=r.durationItemList[r.durationItemList.length-1];e.stop(),e.getDuration()<vD&&r.durationItemList.pop()}t.dataFreeze=this.getTotalDuration(r.durationItemList),t.count=r.durationItemList.length}return t}getRenderFreezeDuration(e){let t=this._renderFreezeMap.get(e),r=0,i=0;if(t)if(t.isFreeze){let e=_C()-t.freezeTimeline[t.freezeTimeline.length-1].startTime;r=t.renderFreezeTotal+Math.min(e,5e3),i=t.freezeTimeline.length}else r=t.renderFreezeTotal;return{renderFreeze:r,count:i}}getMonitorFreeze(){return this._monitorFreezeData}isBlackStream(e){return!!this._isVideoPlayingEventFiredMap.has(e)&&!this._isVideoPlayingEventFiredMap.get(e)}resetMonitor(){this._monitorFreezeData.clear()}hitTest(e){return e===this._room}destroy(){this.uninstallEvents()}},qH=Vb(jb(),1),YH=[1,0,0,0,1,1,0,1],JH=class extends UV{constructor(e,t,r,i){if(super(e,{useDefaultProgram:!0,useFbo:!0,create2d:!0,name:"transform",logger:t}),Bb(this,"mirror",!1),Bb(this,"rotation",0),r&&(this.mirror=r),i&&(this.rotation=i),e instanceof $V)try{this.setTexBuffer(YH)}catch(sw){e.destroy(new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:3,message:"create video node ".concat(this.name," error ").concat(sw.message||sw)}))}}draw2d(e,t,r,i,o){if(this.ctx2d){this.ctx2d.save(),this.mirror&&(this.ctx2d.scale(-1,1),this.ctx2d.translate(-this.width,0)),90===this.rotation?(this.ctx2d.translate(i,0),this.ctx2d.rotate(Math.PI/2),this.ctx2d.scale(o/i,i/o)):180===this.rotation?(this.ctx2d.translate(this.width,this.height),this.ctx2d.rotate(Math.PI)):270===this.rotation&&(this.ctx2d.translate(0,o),this.ctx2d.rotate(3*Math.PI/2),this.ctx2d.scale(o/i,i/o));let n=super.draw2d(e,t,r,i,o);return this.ctx2d.restore(),n}return!1}render(e){var t;return!(null==(t=this.input)||!t.requestFrame(e))&&(this.useProgram(),this.useBufferFrame(),this.useInputTexture(),this.draw(),!0)}},XH=class{constructor(e,t){this.node=e,this.layout=t,Bb(this,"positionBuffer")}get x(){return this.layout.x||this.node.x}get y(){return this.layout.y||this.node.y}get width(){return this.layout.width||this.node.width}get height(){return this.layout.height||this.node.height}get right(){return this.x+this.width}get bottom(){return this.y+this.height}},$H=class extends UV{constructor(e,t){super(e,{useDefaultProgram:!0,useFbo:!0,name:"mix",create2d:!0,matchInputSize:!1,logger:t}),Bb(this,"inputs",[])}addInput(e,t){if(this.inputs[t.zIndex])throw new Error("input already exists");let r=new XH(e,t);this.inputs[t.zIndex]=r}changeInputLayout(e,t){let r=this.inputs.findIndex((t=>!!t&&t.node===e));r<0||Object.entries(t).forEach((e=>{let[t,i]=e;iC(i)||(this.inputs[r].layout[t]=i)}))}resize(e,t){if(!this.matchInputSize)return void super.resize(e,t);let r=this.inputs.reduce(((e,t)=>t?Object.assign(e,{width:Math.max(e.width,t.right),height:Math.max(e.height,t.bottom)}):e),{width:0,height:0});super.resize(r.width,r.height),this.context instanceof $V&&this.inputs.forEach((e=>{if(e){let t=this.layout2texCoords(e);e.positionBuffer?this.changeBufferData(e.positionBuffer,t):e.positionBuffer=this.createBuffer(t)}}))}connect(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return super.connect(e,...r),this.matchInputSize&&this.resize(0,0),e}removeInput(e){this.inputs[this.inputs.findIndex((t=>(null==t?void 0:t.node)===e))]=void 0}render(e){let t=this.context.ctx;if(t.clearColor(0,0,0,0),this.inputs.reduce(((t,r)=>(null==r?void 0:r.node.requestFrame(e))||t),!1)&&t){this.useProgram(),t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.useBufferFrame();for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&(t.node.useTexture(),this.draw(t.positionBuffer))}return!0}return!1}render2d(e){if(this.inputs.reduce(((t,r)=>(null==r?void 0:r.node.requestFrame(e))||t),!1)&&this.ctx2d){this.ctx2d.fillStyle="black",this.ctx2d.fillRect(0,0,this.width,this.height);for(let e=0;e<this.inputs.length;e++){let t=this.inputs[e];t&&this.draw2d(t.node.image,t.x,t.y,t.width,t.height)}return!0}return!1}getInfo(){let{totalFrames:e,x:t,y:r,width:i,height:o,name:n}=this,a=Date.now(),s=(e-this.lastInfo.totalFrames)/((a-this.lastInfo.timestamp)/1e3)|0;return this.lastInfo={totalFrames:e,x:t,y:r,width:i,height:o,timestamp:a,fps:s,name:n},Lb({parent:this.inputs.filter((e=>e)).map((e=>e.node.getInfo()))},this.lastInfo)}close(){super.close(),this.inputs.forEach((e=>{var t,r;if(e&&(null==(t=e.node)||t.disconnect(),e.positionBuffer&&this.context instanceof $V))try{null==(r=this.context.ctx)||r.deleteBuffer(e.positionBuffer)}catch(aO){}}))}},QH=class{constructor(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4/3;this.vbMode=e,this.faceDetector=t,this.logger=r,Bb(this,"animationState"),Bb(this,"originalAspect"),Bb(this,"totalOffsetX",0),Bb(this,"totalOffsetY",0),Bb(this,"defaultScaleRatio",.1),Bb(this,"isRecovering",!1),Bb(this,"boundaryY",280),Bb(this,"lastActionTime",0),Bb(this,"restTime",1e3),this.animationState={current:null,target:null,animating:!1,debounceTimer:null,startTime:0,duration:3e3,debounceTime:150,movementThreshold:30,debounceThreshold:15},this.addEvent(this.vbMode,!!this.faceDetector),this.originalAspect=i||4/3}addEvent(e,t,r){let i=[{key:570704,error:null!=r?r:t?void 0:11},{key:570705,error:null!=r?r:t?void 0:22}][e-1];i&&(t?mM.addSuccessEvent({key:i.key}):mM.addFailedEvent({key:i.key,error:i.error}))}actionCentering(e){let t=Date.now();if(this.animation(),!this.faceDetector||t-this.lastActionTime<this.restTime||this.animationState.animating)return;let{videoWidth:r,videoHeight:i}=e;this.animationState.debounceThreshold=r/30,this.animationState.movementThreshold=r/20;try{let t=this.faceDetector.detectForVideo(e,Date.now());if(t.detections.length<=0)return void this.recoverOriginal(r,i);let o=t.detections[0].boundingBox,n=o.originX,a=o.originY,s=o.width,c=o.height;1===this.vbMode?this.dualStageCropping(r,i,n,a,s,c):2===this.vbMode&&this.movingPortrait(r,i,n,a,s,c)}catch(aO){this.logger.error(aO)}this.lastActionTime=t}calculateBoundary(e,t,r,i){let o,n;return e>t/2?(o=t-r-i,n=r-o):(o=r,n=0),{min:o,offset:n}}calculateTargetPosition(e,t,r,i,o,n){let a,s,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.4,l=e+r/2,u=t+i/2,{min:d,offset:h}=this.calculateBoundary(l,o,e,r),{min:p,offset:m}=this.calculateBoundary(u,n,t,i);return a=2*d+r,s=2*p+i,a/s>this.originalAspect?(a=s*this.originalAspect,h=l-a/2):(s=a/this.originalAspect,m=u-s/2),r/o>c&&(h=0,m=0,a=o,s=n),h=Math.max(0,Math.min(h,o-a)),m=Math.max(0,Math.min(m,n-s)),{sx:h,sy:m,cropWidth:a,cropHeight:s,timestamp:Date.now()}}processFacePositionCrop(e,t){if(!this.animationState.current||!this.animationState.target)return this.animationState.current=Lb({},e),void(this.animationState.target=Lb({},e));let r=this.positionDistance(this.animationState.target,e),i=this.positionDistance(this.animationState.current,e),o=this.animationState.current.cropWidth/t;r>this.animationState.debounceThreshold*o&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&i>this.animationState.movementThreshold*o&&(this.animationState.target=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}processFacePositionPortrait(e){if(!this.animationState.current||!this.animationState.target)return this.animationState.current=Lb({},e),void(this.animationState.target=Lb({},e));let t=this.positionDistance(this.animationState.current,e),r=this.positionDistance(this.animationState.target,e);t>this.animationState.debounceThreshold&&(clearTimeout(this.animationState.debounceTimer),this.animationState.animating=!1),!this.animationState.animating&&r>this.animationState.movementThreshold&&(this.animationState.current=e,this.animationState.debounceTimer=setTimeout((()=>{this.animationState.startTime=Date.now(),this.animationState.animating=!0}),this.animationState.debounceTime))}animation(){if(!this.animationState.animating)return;let e=Date.now()-this.animationState.startTime,t=Math.min(e/this.animationState.duration,1),r=e=>e<.5?2*e*e:(4-2*e)*e-1;if(this.animationState.current&&this.animationState.target){let e=(this.animationState.target.sx-this.animationState.current.sx)*r(t);this.animationState.current.sx+=e,this.totalOffsetX+=e;let i=(this.animationState.target.sy-this.animationState.current.sy)*r(t);if(this.animationState.current.sy+=i,this.totalOffsetY+=i,this.animationState.current.cropWidth+=(this.animationState.target.cropWidth-this.animationState.current.cropWidth)*r(t),this.animationState.current.cropHeight+=(this.animationState.target.cropHeight-this.animationState.current.cropHeight)*r(t),this.animationState.current.scaleRatio&&this.animationState.target.scaleRatio&&(this.animationState.current.scaleRatio+=(this.animationState.target.scaleRatio-this.animationState.current.scaleRatio)*r(t)),nC(this.animationState.current.scaleOffsetX)&&nC(this.animationState.target.scaleOffsetX)&&nC(this.animationState.current.scaleOffsetY)&&nC(this.animationState.target.scaleOffsetY)){let e=(this.animationState.target.scaleOffsetX-this.animationState.current.scaleOffsetX)*r(t);this.animationState.current.scaleOffsetX+=e;let i=(this.animationState.target.scaleOffsetY-this.animationState.current.scaleOffsetY)*r(t);this.animationState.current.scaleOffsetY+=i}}t>=1&&(this.animationState.animating=!1,this.animationState.current=this.animationState.target,this.isRecovering=!1)}positionDistance(e,t){return Math.sqrt(Ob(e.sx-t.sx,2)+Ob(e.sy-t.sy,2))}recoverOriginal(e,t){this.animationState.target={sx:0,sy:0,cropWidth:e,cropHeight:t,timestamp:Date.now()},this.animationState.animating=!0,this.animationState.startTime=Date.now(),this.isRecovering=!0}dualStageCropping(e,t,r,i,o,n){let a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:.55;if(this.isRecovering)return;let s=this.calculateTargetPosition(r,i,o,n,e,t,a);this.processFacePositionCrop(s,e),o/s.cropWidth>a&&this.recoverOriginal(e,t)}movingPortrait(e,t,r,i,o,n){var a,s,c,l,u,d,h,p,m,f,_,g;let E={sx:r+o/2+this.totalOffsetX,sy:i+n/2+this.totalOffsetY,cropWidth:e,cropHeight:t,scaleRatio:null!=(s=null==(a=this.animationState.current)?void 0:a.scaleRatio)?s:1,scaleOffsetX:null!=(l=null==(c=this.animationState.current)?void 0:c.scaleOffsetX)?l:0,scaleOffsetY:null!=(d=null==(u=this.animationState.current)?void 0:u.scaleOffsetY)?d:0,timestamp:Date.now()};this.animationState.target={sx:e/2,sy:i+n/2,cropWidth:e,cropHeight:t,scaleRatio:null!=(p=null==(h=this.animationState.target)?void 0:h.scaleRatio)?p:1,scaleOffsetX:null!=(f=null==(m=this.animationState.target)?void 0:m.scaleOffsetX)?f:0,scaleOffsetY:null!=(g=null==(_=this.animationState.target)?void 0:_.scaleOffsetY)?g:0,timestamp:Date.now()},this.animationState.animating||(this.animationState.target.scaleRatio=Math.sqrt(o*n/e/t/this.defaultScaleRatio),this.animationState.target.scaleOffsetX=-this.animationState.target.scaleRatio/2+.5,this.animationState.target.scaleOffsetY=1-this.animationState.target.scaleRatio,(this.animationState.target.sy-this.animationState.target.scaleOffsetY*this.animationState.target.cropHeight)/this.animationState.target.scaleRatio<this.boundaryY&&(this.animationState.target.scaleOffsetY=(this.animationState.target.sy-this.boundaryY*this.animationState.target.scaleRatio)/this.animationState.target.cropHeight)),this.processFacePositionPortrait(E)}set aspectRatio(e){this.originalAspect=e}get current(){return this.animationState.current}get offset(){return{offsetX:this.totalOffsetX,offsetY:this.totalOffsetY}}get targetCrop(){return this.animationState.target}},ZH=class extends qV{constructor(e,t){super(e,t.input,{name:"vb",create2d:!1,useDefaultProgram:!1,useFbo:!1,createTexture:!0,width:t.width,height:t.height,logger:e.log}),Bb(this,"_bgTexture"),Bb(this,"_waterMarkTexture"),Bb(this,"_lastMaskTexture"),Bb(this,"_lastMaskFbo"),Bb(this,"_textureValid",!1),Bb(this,"_selfieTextureValid",!1),Bb(this,"_selfieSegmentation"),Bb(this,"wasm"),Bb(this,"_prePrograme"),Bb(this,"_segmentationMask"),Bb(this,"_weixin",!1),Bb(this,"_centerFace"),Bb(this,"_textureMatrixLocation"),Bb(this,"_offsetMatrixLocation"),Bb(this,"_enableFaceCentering",!1),Bb(this,"_mat4"),t.selfieSegmentation&&(this._selfieSegmentation=t.selfieSegmentation,this._selfieSegmentation.onResults=this.onPredict.bind(this));try{this.init(t)}catch(iO){e.log.error(iO),e.destroy(new $b({code:Jb.VIDEO_MANAGER_ERROR,extraCode:6,message:"init vb node error ".concat(iO.message||iO)}))}}init(e){var t;let r=e.Wasm,i=this.context.ctx;if(this._mat4=e.mat4,this.wasm=new r.AllIn1(i),this.wasm.blurRadius=e.blurRadius||3,this.wasm.mirror=!!e.mirror,this.wasm.rotation=e.rotation||0,this.wasm.vbMode="blur"===e.bg?1:e.bg instanceof HTMLImageElement?2:"green"===e.bg?3:0,this._enableFaceCentering=null!=(t=e.enableFaceCentering)&&t,e.waterMark){let{x:t,y:r,width:i,height:o}=e.waterMark;this.wasm.setWaterMark(t,r,i,o)}if(e.beautyParams){let{beauty:t,brightness:r,ruddy:i}=e.beautyParams;this.wasm.setBeauty(t,r,i,null==e?void 0:e.width,null==e?void 0:e.height)}if(this.program=this.wasm.init(),this.useProgram(),this.setAttributes(this.positionBuffer,this.texCoordBuffer),i.uniform1i(i.getUniformLocation(this.program,"mask"),1),e.bg instanceof HTMLImageElement&&(i.uniform1i(i.getUniformLocation(this.program,"bg"),2),this._bgTexture=this.createTexture(e.bg)),e.waterMark&&(i.uniform1i(i.getUniformLocation(this.program,"waterMark"),3),this._waterMarkTexture=this.createTexture(e.waterMark.image)),this._textureMatrixLocation=i.getUniformLocation(this.program,"u_textureMatrix"),i.uniformMatrix4fv(this._textureMatrixLocation,!1,this._mat4.create()),this._offsetMatrixLocation=i.getUniformLocation(this.program,"u_offsetMatrix"),i.uniformMatrix4fv(this._offsetMatrixLocation,!1,this._mat4.create()),i.uniform1i(i.getUniformLocation(this.program,"lastMask"),4),this._weixin){let e=this.context.createShader(i.FRAGMENT_SHADER,"#version 300 es\nprecision highp float;\nuniform sampler2D u_texture;\nuniform sampler2D mask;\n\nin vec2 v_texCoord;\nout vec4 outColor;\nvoid main() {\n outColor = vec4(texture(u_texture, v_texCoord).rgb, texture(mask, v_texCoord).a);\n}"),t=this.context.createShader(i.VERTEX_SHADER,"#version 300 es\nin vec2 a_position;\nin vec2 a_texCoord;\nout vec2 v_texCoord;\nvoid main() {\n gl_Position = vec4(a_position.x, a_position.y, 0, 1);\n v_texCoord = a_texCoord;\n}");this._prePrograme=this.context.createProgram(t,e),i.useProgram(this._prePrograme),this.setAttributes(this.positionBuffer,this.texCoordBuffer),i.uniform1i(i.getUniformLocation(this._prePrograme,"mask"),1)}this._enableFaceCentering&&(this._centerFace=new QH(this.wasm.vbMode,e.faceDetector,this.context.log))}onPredict(e){var t;let r=this.context.ctx;this._weixin&&(this._lastMaskTexture||(this._lastMaskTexture=this.createTexture(this.image),this._lastMaskFbo=this.createFramebuffer(this._lastMaskTexture))),this.useProgram(),this._weixin?this.useTexture():null==this||this._selfieSegmentation.bindTexture(),r.activeTexture(r.TEXTURE1),null==(t=this._selfieSegmentation)||t.bindTexture2d(e),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this._bgTexture||null),r.activeTexture(r.TEXTURE3),r.bindTexture(r.TEXTURE_2D,this._waterMarkTexture||null),this.useBufferFrame(),this._segmentationMask=e,this.totalFrames++,this.centerFace(),r.drawArrays(r.TRIANGLE_STRIP,0,4)}onFirstFrame(){this.waitingFirstFrame=!1;let e=this.context.ctx;this.useTexture(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,this.image)}render(e){var t,r,i,o;let n=this.context.ctx,{image:a}=this;this.tryVideoFrameCallback();let{videoWidth:s,videoHeight:c}=a;if(HC(this.wasm.rotation)&&([s,c]=[c,s]),0===s||0===c||!this.available)return!1;a.width=s,a.height=c;let l=!1;if(this.totalFrames)this._weixin?this.useTexture():null==(t=this._selfieSegmentation)||t.bindTexture(),l=this._selfieTextureValid,this._selfieTextureValid=!0;else{if(!this.program)return!1;this.useTexture(),l=this._textureValid,this._textureValid=!0}return this.width===s&&this.height===c&&l?n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,a):(this.resize(s,c),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,a)),this._weixin&&(n.useProgram(this._prePrograme),this.useTexture(),this._segmentationMask&&(n.activeTexture(n.TEXTURE1),null==(r=this._selfieSegmentation)||r.bindTexture2d(this._segmentationMask),n.bindFramebuffer(n.FRAMEBUFFER,this._lastMaskFbo||null)),n.drawArrays(n.TRIANGLE_STRIP,0,4),null==(i=this._selfieSegmentation)||i.bindTexture(),this._segmentationMask?n.copyTexSubImage2D(n.TEXTURE_2D,0,0,0,0,0,s,c):n.copyTexImage2D(n.TEXTURE_2D,0,n.RGBA,0,0,s,c,0)),this.wasm.vbMode&&(null==(o=this._selfieSegmentation)||o.send(s,c)),this.totalFrames||(n.activeTexture(n.TEXTURE2),n.bindTexture(n.TEXTURE_2D,this._bgTexture||null),n.activeTexture(n.TEXTURE3),n.bindTexture(n.TEXTURE_2D,this._waterMarkTexture||null),n.drawArrays(n.TRIANGLE_STRIP,0,4)),!1}centerFace(){if(!this._centerFace||!this._enableFaceCentering)return;let e=this.context.ctx;this._centerFace.aspectRatio=e.canvas.width/e.canvas.height,this._centerFace.actionCentering(this.image);let{current:t,offset:r}=this._centerFace;if(t&&(1===this.wasm.vbMode&&this.drawImage(e.canvas.width,e.canvas.height,t.sx,t.sy,t.cropWidth,t.cropHeight),r&&2===this.wasm.vbMode)){let i=this._mat4.create(),{scaleRatio:o=1,scaleOffsetX:n=0,scaleOffsetY:a=0}=t;this._mat4.fromTranslation(i,[-r.offsetX/e.canvas.width+n,a,0]),this._mat4.scale(i,i,[o,o,1]),e.uniformMatrix4fv(this._offsetMatrixLocation,!1,i)}}drawImage(e,t,r,i,o,n){let a=this.context.ctx,s=this._mat4.create();this._mat4.fromTranslation(s,[r/e,1-(i+n)/t,0]),this._mat4.scale(s,s,[o/e,n/t,1]),a.uniformMatrix4fv(this._textureMatrixLocation,!1,s)}close(){var e;super.close();let t=this.context.ctx;this._bgTexture&&t.deleteTexture(this._bgTexture),this._waterMarkTexture&&t.deleteTexture(this._waterMarkTexture),this._lastMaskTexture&&t.deleteTexture(this._lastMaskTexture),this._lastMaskFbo&&t.deleteFramebuffer(this._lastMaskFbo),this._prePrograme&&t.deleteProgram(this._prePrograme),null==(e=this.wasm)||e.close()}},eW=class extends UV{constructor(e){super(e,{name:"yuv-source",useDefaultProgram:!1,create2d:!1,useFbo:!1,createTexture:!1,logger:e.log,fragmentShaderSource:"\n precision highp float;\n uniform sampler2D ySampler;\n uniform sampler2D uSampler;\n uniform sampler2D vSampler;\n varying highp vec2 textureCoord;\n const mat4 YUV2RGB = mat4(\n 1.1643828125, 0, 1.59602734375, -.87078515625,\n 1.1643828125, -.39176171875, -.81296875, .52959375,\n 1.1643828125, 2.017234375, 0, -1.081390625,\n 0, 0, 0, 1);\n void main() {\n vec3 yuv;\n yuv.r = texture2D(ySampler, textureCoord).r;\n yuv.g = texture2D(uSampler, textureCoord).r;\n yuv.b = texture2D(vSampler, textureCoord).r;\n gl_FragColor = vec4(yuv,1) * YUV2RGB;\n }\n ",vertexShaderSource:"\n attribute vec4 vertexPos;\n attribute vec2 texturePos;\n varying vec2 textureCoord;\n void main() {\n gl_Position = vertexPos;\n textureCoord = texturePos;\n }"}),Bb(this,"yTextureRef"),Bb(this,"uTextureRef"),Bb(this,"vTextureRef"),Bb(this,"Y"),Bb(this,"U"),Bb(this,"V"),this.useProgram();let t=this.context.ctx;t.pixelStorei(t.PACK_ALIGNMENT,1),t.pixelStorei(t.UNPACK_ALIGNMENT,1),this.setTexBuffer([0,1,1,1,0,0,1,0]),this.yTextureRef=this._initTexture("ySampler",0),this.uTextureRef=this._initTexture("uSampler",1),this.vTextureRef=this._initTexture("vSampler",2),this._canvas=e._canvas}_initTexture(e,t){let r=this.context.ctx,i=r.createTexture();return r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null),r.uniform1i(r.getUniformLocation(this.program,e),t),i}render(e){let t=this.context.ctx,r=this.width,i=this.height;return this.useProgram(),t.viewport(0,0,r,i),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,this.yTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r,i,t.LUMINANCE,t.UNSIGNED_BYTE,this.Y),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this.uTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.U),t.activeTexture(t.TEXTURE2),t.bindTexture(t.TEXTURE_2D,this.vTextureRef),t.texSubImage2D(t.TEXTURE_2D,0,0,0,r/2,i/2,t.LUMINANCE,t.UNSIGNED_BYTE,this.V),this.draw(),!0}resize(e,t){super.resize(e,t);let r=this.context.ctx;r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,this.yTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e,t,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,this.uTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null),r.activeTexture(r.TEXTURE2),r.bindTexture(r.TEXTURE_2D,this.vTextureRef),r.texImage2D(r.TEXTURE_2D,0,r.LUMINANCE,e/2,t/2,0,r.LUMINANCE,r.UNSIGNED_BYTE,null)}},tW=[e=>{e.codec="avc1.42e01f"},e=>{delete e.hardwareAcceleration}],rW=(e,t)=>{switch(e){case"webCodecs":return"videoFrame"===t?514705:514706;case"wasm":return"webgl"===t?514707:"videoFrame"===t?514708:514709}throw new Error("decoder type not supported")};var iW=0,oW=class{constructor(e){Bb(this,"id",iW++),Bb(this,"trackDoneOB"),Bb(this,"startOB"),Bb(this,"stopOB"),Bb(this,"decoder"),Bb(this,"videoContext"),Bb(this,"gop",0),Bb(this,"gop_helper",0),Bb(this,"waitFirstKeyFrame",!0),Bb(this,"startTimestamp",0),Bb(this,"startTime",0),Bb(this,"startPerformanceTime",0),Bb(this,"inputFrameCount",0),Bb(this,"decodedFrameCount",0),Bb(this,"decodeFrameCount",0),Bb(this,"downgradeLevel",0),Bb(this,"lastDowngradeTime",0),Bb(this,"lastFrameDiff",0),Bb(this,"lastDecodeFrameTimestamp",0),Bb(this,"config"),Bb(this,"gop_before_configure",[]),Bb(this,"videoElement"),Bb(this,"type","wasm"),Bb(this,"goodType"),Bb(this,"renderer","2d"),Bb(this,"wasmOption"),Bb(this,"createDecoder"),Bb(this,"_decodeSink"),Bb(this,"isReported",!1),Bb(this,"track"),Bb(this,"stateChangeOB"),Bb(this,"failedReason");let{track:t,createDecoder:r}=e;if(this.stateChangeOB=$x(),this.track=t,this.createDecoder=r,this.wasmOption={yuvMode:"webgl"===e.renderer,wasmPath:e.wasmPath,workerMode:e.workerMode,canvas:e.canvas},this.config=e.config,this.videoElement=e.videoElement,this.renderer=e.renderer,this.trackDoneOB=sU(t.availableState,EL.OFF),this.stopOB=$x(),"auto"===e.type){switch(e.fallback){case"wasm":this.type="wasm",this.renderer="webgl";break;case"wasm_2d":this.type="wasm",this.renderer="2d";break;case"wasm_video":this.type="wasm",this.renderer="videoFrame";break;default:this.type="webCodecs"}this.wasmOption.yuvMode="webgl"===this.renderer}else this.type=e.type;this.changeRenderer(this.renderer),Nx(this.stateChangeOB,$U(((e,r)=>(e!==r&&t.onDecodeDowngradeStateChanged({type:this.type,renderer:this.renderer,reason:this.failedReason,prevState:e,state:r}),r)),"INITIALIZED"),CU(this.stopOB),DV()),this.start()}start(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.waitFirstKeyFrame=!0,this.stateChangeOB.next("STARTING");let t=Nx(this.pipe(this.track),CU(this.stopOB),Vx());Nx(t,DV((()=>{this.track.stat.framesDecoded++}),(t=>{if(this.track.log.error("".concat(this.id," play failed: ").concat(t," retryCount: ").concat(e)),mM.addFailedEvent({key:rW(this.type,this.renderer),error:t}),e>4)this.failedReason=t,this.stateChangeOB.next("FAILED");else{if(this.goodType)return void this.start(e);switch(this.type){case"webCodecs":this.type="wasm",this.changeRenderer("webgl");break;case"wasm":if("webgl"===this.renderer)this.changeRenderer("videoFrame")}this.start(e+1)}}),(()=>{this.track.log.warn("".concat(this.id," decoderOB completed")),mM.addSuccessEvent({key:rW(this.type,this.renderer)}),mM.addSuccessEvent({key:514704})}))),Nx(t,DU(1),DV((()=>{this.track.player.handlePlaying("canvas"),this.goodType=this.type,this.stateChangeOB.next("STARTED")})))}mock(e){this._decodeSink?this._decodeSink.error(e):this.start()}close(e){this.stopOB.next(e)}changeRenderer(e){this.renderer=e,"videoFrame"===this.renderer&&!AM()&&(this.renderer="2d"),this.wasmOption.yuvMode="webgl"===this.renderer}decode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r,i;if(this.failedReason)return;this.inputFrameCount++;let o=new Uint8Array(e.data);if(!function(e){return 0===e[0]&&0===e[1]&&0===e[2]&&1===e[3]}(o)||o.length<5)return this.stateChangeOB.next("FAILED"),this.close("not h26x frame ".concat(o.subarray(0,5))),e;let n=!1;switch(31&o[4]){case 5:case 7:n=!0}if("configured"!==(null==(r=this.decoder)?void 0:r.state))return this.track.log.debug("not configured ".concat(this.inputFrameCount)),n&&(this.gop_before_configure=[]),this.gop_before_configure.push({data:e.data,timestamp:e.timestamp,type:e.type}),e;this.gop_before_configure.length>0&&!t&&(this.gop_before_configure.forEach((e=>this.decode(e,!0))),this.gop_before_configure=[]);let{timestamp:a}=e;if(n?(this.gop=this.gop_helper,this.gop_helper=0):this.gop_helper++,this.decoder){if(this.waitFirstKeyFrame){if(!n)return void this.track.log.debug("wait first key frame ".concat(this.inputFrameCount," ").concat(o.subarray(0,5).join(" ")));this.waitFirstKeyFrame=!1,this.startTimestamp=a,this.startTime=Date.now(),this.startPerformanceTime=_C()}switch(this.downgradeLevel){case 0:case 1:break;case 2:if(this.gop_helper>this.gop>>1)return;break;case 3:if(this.gop_helper>0)return;break;default:return}return(this.decodeFrameCount<10||this.decodeFrameCount%500==0)&&this.track.log.debug("decode ".concat(this.decodeFrameCount," gop: ").concat(this.gop," ").concat(a," ").concat(null==(i=e.getMetadata)?void 0:i.call(e).rtpTimestamp)),this.decodeFrameCount++,this.lastDecodeFrameTimestamp=a,void this.decoder.decode({data:e.data,type:e.type,timestamp:this.lastDecodeFrameTimestamp})}return e}checkDowngradeByFrameDiff(){let e=this.downgradeLevel,t=this.decodeFrameCount-this.decodedFrameCount;t>this.lastFrameDiff?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):t<=this.lastFrameDiff&&this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==e&&this.track.log.debug("downgrade level ".concat(e," to ").concat(this.downgradeLevel," ").concat(this.decodeFrameCount," frameDiff: ").concat(t,", lastFrameDiff: ").concat(this.lastFrameDiff)),this.lastFrameDiff=t,this.lastDowngradeTime=Date.now()}checkDowngradeByTimestampDiff(e){let t=this.downgradeLevel;this.lastDecodeFrameTimestamp-e>9e4?(this.downgradeLevel++,this.downgradeLevel>4&&(this.downgradeLevel=4)):this.downgradeLevel>0&&this.downgradeLevel--,this.downgradeLevel!==t&&this.track.log.debug("downgrade level ".concat(t," to ").concat(this.downgradeLevel))}pipe(e){return t=>Wb(this,null,(function*(){this._decodeSink=t;let r,i=e.mediaTrack;t.defer((()=>{var t;i&&(e.player.setCanvas(),e.setInputMediaStreamTrack(i)),null==r||r.close(),null==(t=this.videoContext)||t.destroy(),delete this._decodeSink}));let{renderer:o,type:n}=this;e.log.info("decoder type: ".concat(this.type," renderer: ").concat(this.renderer));try{switch(n){case"wasm":r=this.createDecoder(n,this.wasmOption);break;case"webCodecs":for(let e=0;e<=tW.length;e++){let{supported:r}=yield VideoDecoder.isConfigSupported(this.config);if(r)break;if(e===tW.length)return void t.error(3);tW[e](this.config)}r=this.createDecoder(n);break;default:throw new Error("not supported yet")}let i=0;if(r.on("videoFrame",(r=>{this.decodedFrameCount++,i++,(i<=10||i%500==0)&&e.log.debug("frame ".concat(i," ").concat(this.decodedFrameCount,"/").concat(this.decodeFrameCount," decoded ").concat(r.timestamp)),Date.now()-this.lastDowngradeTime>5e3&&("webCodecs"===this.type?this.checkDowngradeByFrameDiff():"wasm"===this.type&&this.checkDowngradeByTimestampDiff(r.timestamp)),t.next(r)})),r.on("error",(r=>{e.log.error(r),t.error("webCodecs"===n?4:8)})),yield r.initialize(this.videoElement),!this._decodeSink)return;if(r.configure(this.config),"wasm"===n&&"webgl"===o){this.videoContext=new $V({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create(),this.videoContext.on($V.UNAVAILABLE,(r=>{e.log.error(r),t.error(7)}));let i=new eW(this.videoContext);r.on("videoCodecInfo",(e=>i.resize(e.width,e.height))),r.on("videoFrame",(e=>{({y:i.Y,u:i.U,v:i.V}=e),1===this.downgradeLevel?this.decodedFrameCount%2==0&&i.render(this.decodedFrameCount):i.render(this.decodedFrameCount)})),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}else if("videoFrame"===o){e.player.setCanvas();let t=new MediaStreamTrackGenerator({kind:"video"}),i=t.writable.getWriter();e.setInputMediaStreamTrack(t),r.on("videoFrame",(e=>i.write(e)))}else{this.videoContext=new QV({frameRate:15,logger:e.log,name:e.userId}),this.videoContext.create({alpha:!1});let i=this.videoContext.createVideoImageSource();r.on("videoFrame",(r=>{try{i.image=r,i.update()}catch(oM){delete this.goodType,e.log.error(oM),t.error(11)}}));let o=new HV(this.videoContext,{name:"remotePlayer",logger:e.log});i.connect(o),e.source=i,e.player.setCanvas(this.videoContext._canvas,2)}this.decoder=r}catch(oO){e.log.error(oO),t.error("webCodecs"===n?2:6)}}))}},nW=class extends qH.EventEmitter{constructor(e){super(),this.room=e,Bb(this,"videoContext"),Bb(this,"_glVideoContext"),Bb(this,"_2dVideoContext"),Bb(this,"destination"),Bb(this,"smallVideoContext"),Bb(this,"smallDestination"),Bb(this,"smallTrackSource"),Bb(this,"smallImageSource"),Bb(this,"_isMirror",!1),Bb(this,"_rotation",0),Bb(this,"cameraTrack"),Bb(this,"cameraNode"),Bb(this,"transformNode"),Bb(this,"mixNode"),Bb(this,"screenTrack"),Bb(this,"screenNode"),Bb(this,"selfModel",!1),Bb(this,"blurRadius",3),Bb(this,"arTrack"),Bb(this,"_enableFaceCentering",!1),Bb(this,"Wasm"),Bb(this,"waterMarkNode"),Bb(this,"_waterMarkOption"),Bb(this,"watermarkImageList",[]),Bb(this,"_beautyParams"),Bb(this,"isUsingArTrack",!1),Bb(this,"_isMixScreen",!1),Bb(this,"_mixScreenOption",{}),Bb(this,"_virtualBackground"),Bb(this,"_virtualBackgroundAbortCallback"),Bb(this,"virtualBackgroundInstance"),Bb(this,"_bgAssetPath"),Bb(this,"log",Yk.createLogger({id:"vm"})),Bb(this,"_faceDetector"),Bb(this,"_mat4"),Bb(this,"_checkId",0),Bb(this,"_use2d",!1),Bb(this,"_autoSwitchRenderMode",!0),Bb(this,"_selfieSegmentation"),Bb(this,"encodePipeline",[]),Bb(this,"decodePipeline",[]),e&&(this.log.setUserId(e.userId),this.log.setSdkAppId(e.sdkAppId)),this.smallVideoContext=new QV({frameRate:15,logger:this.log,name:"s"}),this.enablePrintDetail()}get smallMode(){var e;return(null==(e=this.room)?void 0:e.smallMode)||"canvas"}get _hasVirtualBg(){return!!this._virtualBackground}get _hasWaterMark(){return this.watermarkImageList.length>0}get _isRotate(){return 0!==this._rotation}get _isTransform(){return this._isMirror||this._isRotate}get renderMode(){return this._autoSwitchRenderMode?"auto":this._use2d?"2d":"webgl"}set renderMode(e){if(this._autoSwitchRenderMode="auto"===e,this._autoSwitchRenderMode)return;let t="2d"===e;this._use2d!==t&&(this._use2d=t,this.clear(),this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.update())}get cameraResolution(){var e;let{width:t,height:r}=(null==(e=this.cameraTrack)?void 0:e.settings)||{};return HC(this._rotation)?{width:r,height:t}:{width:t,height:r}}get2dVideoContext(){return this._2dVideoContext?this._2dVideoContext.destroy():this._2dVideoContext=new QV({frameRate:15,logger:this.log,name:"m"}),this._2dVideoContext.create({alpha:this._hasWaterMark||this._hasVirtualBg}),this._2dVideoContext}getGlVideoContext(){if(this._glVideoContext){if(this._glVideoContext.available)return this._glVideoContext}else this._glVideoContext=new $V({frameRate:15,logger:this.log,name:"m"});return this.initializeGlVideoContext(),this._glVideoContext}initializeGlVideoContext(){try{this._glVideoContext.create(),this._glVideoContext.on($V.UNAVAILABLE,(e=>{var t;this.emit("error",e),this.log.warn("video context unavailable",e),null==(t=this._virtualBackgroundAbortCallback)||t.call(this,e),this.update().catch((e=>{this.log.error(e)}))}))}catch(aw){this.emit("error",aw)}}enablePrintDetail(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this._checkId=SL.run("interval",(()=>{this.destination&&this.log.debug(this.destination.getInfo())}),{delay:e})}destroy(){var e,t;null==(e=this._2dVideoContext)||e.destroy(),null==(t=this._glVideoContext)||t.destroy(),this.smallVideoContext.destroy(),SL.clearTask(this._checkId)}get needAlpha(){return this._hasWaterMark||this._hasVirtualBg}get active(){return(_k||this._isMixScreen||this._isTransform||this._hasWaterMark||this._hasVirtualBg||this._beautyParams)&&this.checkOrCreateVideoContext()}sendCreateResult(){let e=arguments.length>1?arguments[1]:void 0,t="videoCtxGl"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"videoCtxGl")?512700:512701;e?mM.addFailedEvent({key:t,error:e}):mM.addSuccessEvent({key:t})}checkOrCreateVideoContext(){let e=this._use2d;if(this._autoSwitchRenderMode&&(this._use2d=!this._hasVirtualBg),this.videoContext)if(this.videoContext.available){let t=!this.videoContext.hasAlpha&&this.needAlpha;if(this._autoSwitchRenderMode&&e===this._hasVirtualBg)this.clear();else{if(!t)return!0;if(!this._use2d)return!0;this.clear()}}else{if(this._glVideoContext=new $V({frameRate:15,logger:this.log,name:"m"}),this.initializeGlVideoContext(),this._glVideoContext.available)return this.videoContext=this._glVideoContext,this.videoContext.available;this.log.warn("webgl is still not available"),this.clear(),this._use2d=!0}return this.videoContext=this._use2d?this.get2dVideoContext():this.getGlVideoContext(),this.videoContext.available}get smallTrack(){var e;return null==(e=this.smallDestination)?void 0:e.videoTrack}get hasSmall(){return!!this.smallTrack}get initialTrack(){var e;return null==(e=this.cameraTrack)?void 0:e.mediaTrack}initVirtualBackground(e,t,r){return this._selfieSegmentation=e,this._faceDetector=t,this._mat4=r,this._selfieSegmentation.changeModel()}setSmallVideo(e,t){if("api"!==this.smallMode)if(e){if(!this.smallVideoContext.available){if(this.smallVideoContext.create({alpha:!1}),!this.smallVideoContext.available)return;this.smallDestination=new GV(this.smallVideoContext,e,this.log),this.smallVideoContext.on($V.UNAVAILABLE,(e=>{this.log.warn("small video context lost",e)}))}if(this.smallVideoContext.frameRate=e.frameRate,this.smallDestination.resolution=e,t)this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource),this.smallImageSource?this.smallImageSource.image=t:(this.smallImageSource=this.smallVideoContext.createVideoImageSource(t),this.smallImageSource.resize(t.width,t.height),this.smallImageSource.connect(this.smallDestination));else if(this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource)this.smallTrackSource.replaceTrack(this.initialTrack);else{this.smallTrackSource=this.smallVideoContext.createVideoTrackSource(this.initialTrack,"smallTrackSource");let{width:e,height:t}=this.cameraTrack.settings;this.smallTrackSource.resize(e,t),this.smallTrackSource.connect(this.smallDestination)}}else this.smallVideoContext.available&&(this.smallVideoContext.destroy(),delete this.smallDestination,delete this.smallTrackSource,delete this.smallImageSource)}_setMainOutput(e){var t;try{let r=this.cameraTrack,{small:i,player:o}=r;_k&&o.setCanvas(e);let n=e&&(null==(t=this.destination)?void 0:t.videoTrack)||this.initialTrack;return this.isUsingArTrack&&this.arTrack&&(this.emit("output-track-changed"),n=this.arTrack),this._selfieSegmentation&&e&&!this._use2d&&(this._selfieSegmentation._glName||this._selfieSegmentation.setCanvas(e)),this.log.info("set main output ".concat(n?n.label:"no output track")),this.setSmallVideo(i,e),r.setOutputMediaStreamTrack(n)}catch(iO){this.log.error("set main output failed",iO)}}update(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return Wb(this,null,(function*(){var t;if(!this.cameraTrack)return;if(!this.initialTrack)return this.updateWithoutCamera();if(!this.active)return this.cameraNode&&this.clear(),this._setMainOutput();let{settings:r,profile:i}=this.cameraTrack;if(this._use2d||!this._virtualBackground&&!this._beautyParams)this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log})),16===Tk?this.initialTrack instanceof CanvasCaptureMediaStreamTrack?(this.cameraNode&&(this.cameraNode instanceof qV?(this.cameraNode.close(),delete this.cameraNode):this.cameraNode.image=this.initialTrack.canvas),this.cameraNode||(this.cameraNode=this.videoContext.createVideoImageSource(this.initialTrack.canvas,{name:"cameraCanvasSource",logger:this.log}))):(this.cameraNode&&(this.cameraNode instanceof qV?this.cameraNode.replaceTrack(this.initialTrack):(this.cameraNode.close(),delete this.cameraNode)),this.cameraNode||(this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraTrackSource"))):this.cameraNode?this.cameraNode.replaceTrack(this.initialTrack):this.cameraNode=this.videoContext.createVideoTrackSource(this.initialTrack,"cameraNodeSource"),this.cameraNode.resize(r.width,r.height);else if(e&&this.cameraNode&&this.destination)this.cameraNode.replaceTrack(this.initialTrack);else{this.cameraNode&&this.cameraNode.close(),this.destination?this.destination.disableCheckMute():this.destination=new jV(this.videoContext,{name:"mainDestination",logger:this.log});let{width:e,height:t}=this.cameraResolution,r=yield this.getWatermarkImage(e,t);this._waterMarkOption={x:0,y:0,width:r.width,height:r.height,image:r},this.cameraNode=new ZH(this.videoContext,{input:this.initialTrack,width:e,height:t,mirror:this._isMirror,rotation:this._rotation,bg:this._virtualBackground,selfModel:this.selfModel,waterMark:this._waterMarkOption,beautyParams:this._beautyParams,useTflite:!0,blurRadius:this.blurRadius,assetPath:this._bgAssetPath,selfieSegmentation:this._selfieSegmentation,Wasm:this.Wasm,enableFaceCentering:this._enableFaceCentering,faceDetector:this._faceDetector,mat4:this._mat4}),this.cameraNode.connect(this.destination),this.destination.enableCheckMute()}if(this.videoContext.frameRate=i.frameRate,this._use2d){let e=this.cameraNode;if(e.disconnect(),this._isTransform&&(this.transformNode?(this.transformNode.mirror=this._isMirror,this.transformNode.rotation=this._rotation):this.transformNode=new JH(this.videoContext,this.log,this._isMirror,this._rotation),e=e.connect(this.transformNode),e.disconnect(),HC(this._rotation)&&this.transformNode.resize(r.height,r.width),this.log.info("start ".concat(this._isMirror?"mirror":"").concat(this._isRotate?", rotate ".concat(this.rotation):""))),this.mixNode&&this.mixNode.close(),delete this.mixNode,this._isMixScreen||this._hasWaterMark){if(this.mixNode=new $H(this.videoContext,this.log),this.mixNode.resize(r.width,r.height),e.connect(this.mixNode,{zIndex:1}),this._hasWaterMark&&!this.waterMarkNode&&this._waterMarkOption)this.waterMarkNode=this.videoContext.createVideoImageSource(this._waterMarkOption.image,{autoResize:!1,logger:this.log}),this.waterMarkNode.resize(this._waterMarkOption.width,this._waterMarkOption.height),this.waterMarkNode.x=this._waterMarkOption.x,this.waterMarkNode.y=this._waterMarkOption.y;else if(this.waterMarkNode){let{width:e,height:t}=this.cameraResolution;this.waterMarkNode.image=yield this.getWatermarkImage(e,t),e&&t&&this.waterMarkNode.resize(e,t)}null==(t=this.waterMarkNode)||t.connect(this.mixNode,{zIndex:2}),this._isMixScreen&&this.screenTrack&&(this.screenNode||(this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource"),this.screenNode.resize(this.screenTrack.settings.width,this.screenTrack.settings.height)),this.screenNode.shouldUpdate=!1,this.screenNode.connect(this.mixNode,{zIndex:0})),this.changeMixLayout(this._mixScreenOption),e=this.mixNode,this.log.info("start mix","".concat(this.mixNode.width,"x").concat(this.mixNode.height))}e.connect(this.destination)}return this.log.info("update ".concat(this._use2d?"2d":"webgl")),this._setMainOutput(this.videoContext._canvas)}))}clearLastFrame(){var e;this.destination&&(null==(e=this.destination.ctx2d)||e.clearRect(0,0,this.destination.width,this.destination.height))}updateWithoutCamera(){return Wb(this,null,(function*(){var e;if(!this._isMixScreen)return;if(!this.screenTrack||!this.screenTrack.mediaTrack)return void this.clearLastFrame();if(this.checkOrCreateVideoContext(),!this._use2d)return;this.destination||(this.destination=this.videoContext.createVideoTrackDestination({name:"mainDestination2d",logger:this.log}));let{settings:t,profile:r}=this.screenTrack;return this.videoContext.frameRate=(null==(e=this.cameraTrack)?void 0:e.profile.frameRate)||r.frameRate,this.mixNode&&this.mixNode.close(),this.mixNode=new $H(this.videoContext,this.log),this.screenNode=this.videoContext.createVideoTrackSource(this.screenTrack.mediaTrack,"screenNodeSource"),this.screenNode.shouldUpdate=!0,this.screenNode.resize(t.width,t.height),this.screenNode.connect(this.mixNode,{zIndex:0}),this.changeMixLayout(this._mixScreenOption),this.mixNode.connect(this.destination),this.log.info("mix without camera"),this._setMainOutput(this.videoContext._canvas)}))}changeInput(e){var t,r,i,o;if(e instanceof mx)return this.log.info("change screen input",null==(t=e.mediaTrack)?void 0:t.label),this.setScreenTrack(e);if(e instanceof dx)return this.log.info("change video input",null==(r=e.mediaTrack)?void 0:r.label),this.setCameraTrack(e);if(e instanceof ZV){this.log.info("change remote input",null==(i=e.mediaTrack)?void 0:i.label);let t=e.mediaTrack;return e.setOutputMediaStreamTrack(t)}this.log.warn("change unknown input",null==(o=e.mediaTrack)?void 0:o.label)}removeInput(e){var t;e instanceof mx?(null==(t=this.screenNode)||t.close(),delete this.screenNode,delete this.screenTrack,this.update()):e instanceof dx?this._isMixScreen?(delete this.cameraNode,this.cameraTrack._inputTrack=null,this.update()):(this.clear(),delete this.cameraTrack,this.smallImageSource&&(this.smallImageSource.close(),delete this.smallImageSource),this.smallTrackSource&&(this.smallTrackSource.close(),delete this.smallTrackSource)):e instanceof ZV&&e.source&&e.source.context.destroy()}setCameraTrack(e){return Wb(this,null,(function*(){this.cameraTrack=e,this.update(!0)}))}setScreenTrack(e){return this.screenTrack=e,this._isMixScreen&&(this.screenNode?this.screenNode.replaceTrack(e.mediaTrack):this.update()),e.setOutputMediaStreamTrack(e.mediaTrack)}getWatermarkImage(e,t){return Wb(this,null,(function*(){let r=document.createElement("canvas");t&&e&&(r.height=t,r.width=e);let i=r.getContext("2d");if(!i)throw new $b({code:Jb.NOT_SUPPORTED,message:"Make image failed because of canvas context is null"});return this.watermarkImageList.sort(((e,t)=>e.zIndex-t.zIndex)),this.watermarkImageList.forEach((e=>{let{image:t,x:r,y:o,width:n,height:a}=e;i.drawImage(t,r,o,n,a)})),MC(r.toDataURL())}))}pushWaterMarkImageList(e){let{type:t}=e;this.watermarkImageList.some((t=>t.imageUrl===e.imageUrl&&t.height===e.height&&t.width===e.width&&t.x===e.x&&t.y===e.y&&t.type===e.type&&t.zIndex===e.zIndex))||(("mute"===t||"watermark"===t)&&(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==t))),this.watermarkImageList.push(e))}setBeautyParams(e){return Wb(this,null,(function*(){this._beautyParams=e,this.update()}))}stopBeauty(){return Wb(this,null,(function*(){this._beautyParams=void 0,this.update()}))}setVideoMixer(e){this._isMixScreen=!0,this._mixScreenOption=e,this.update()}updateVideoMixer(e){this.changeMixLayout(e),SC(this._mixScreenOption,e)}changeMixLayout(e){if(!this._isMixScreen||!this.mixNode)return;let{camera:t,screen:r,container:i}=e;if(this.cameraNode&&t){let{width:e,height:r}=this.cameraNode,{x:i,y:o,width:n,height:a}=t;n&&!a?a=n*r/e:!n&&a&&(n=a*e/r),this.mixNode.changeInputLayout(this.cameraNode,{x:i,y:o,width:n,height:a})}if(this.screenNode&&r){let{width:e,height:t}=this.screenNode,{x:i,y:o,width:n,height:a}=r;n&&!a?a=n*t/e:!n&&a&&(n=a*e/t),this.mixNode.changeInputLayout(this.screenNode,{x:i,y:o,width:n,height:a})}i&&this.mixNode.resize(i.width,i.height)}deleteVideoMixer(){var e;this._isMixScreen=!1,this._mixScreenOption={},null==(e=this.screenNode)||e.close(),delete this.screenNode,this.update(),this.log.info("delete screenMixer")}setWatermark(e){return Wb(this,null,(function*(){let t;try{t=yield MC((null==e?void 0:e.imageElement)||e.imageUrl)}catch(oM){throw new $b({code:Jb.INVALID_PARAMETER,message:"load image failed, url: ".concat(e.imageUrl)})}let{x:r=0,y:i=0,width:o=t.width,height:n=t.height,type:a="watermark",zIndex:s=2}=e;this.watermarkImageList.some((e=>e.type===a))?(this.watermarkImageList=this.watermarkImageList.filter((e=>e.type!==a)),this.pushWaterMarkImageList({x:r,y:i,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl}),t=yield this.getWatermarkImage(this.cameraResolution.width,this.cameraResolution.height),this._waterMarkOption={x:0,y:0,width:t.width,height:t.height,image:t},this.waterMarkNode?(this.waterMarkNode.x=0,this.waterMarkNode.y=0,this.waterMarkNode.resize(t.width,t.height),this.waterMarkNode.image=t):this.update()):(this.pushWaterMarkImageList({x:r,y:i,width:o,height:n,image:t,zIndex:s,type:a,imageUrl:e.imageUrl}),yield this.freshWatermark()),this.log.info("set watermark",JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t)))}))}deleteWatermark(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"watermark";return Wb(this,null,(function*(){this.watermarkImageList=this.watermarkImageList.filter((t=>t.type!==e)),this.log.info("delete watermark",e,JSON.stringify(this.watermarkImageList,((e,t)=>"imageUrl"===e?void 0:t))),yield this.freshWatermark()}))}freshWatermark(){return Wb(this,null,(function*(){var e;null==(e=this.waterMarkNode)||e.close(),delete this.waterMarkNode,delete this._waterMarkOption;let{width:t,height:r}=this.cameraResolution,i=yield this.getWatermarkImage(t,r);this._waterMarkOption={x:0,y:0,width:i.width,height:i.height,image:i},this.update()}))}setVirtualBackground(e){return Wb(this,null,(function*(){var t;if(e){if(e.onAbort&&(this._virtualBackgroundAbortCallback=e.onAbort),this._use2d&&!this._autoSwitchRenderMode)return Promise.reject(new Error("not support virtual background in 2d mode"));this._bgAssetPath=e.assetPath,"image"===e.type?this._virtualBackground=yield MC(e.imageUrl):(this.blurRadius=e.blurLevel||this.blurRadius||3,this._virtualBackground=e.type),this._enableFaceCentering=null!=(t=e.enableFaceCentering)?t:this._enableFaceCentering}else delete this._virtualBackground,delete this._virtualBackgroundAbortCallback;if(this.log.info("".concat(this._virtualBackground?"start":"stop"," virtual background, ").concat((null==e?void 0:e.type)||"",", ").concat(this.blurRadius||"")),yield this.update(),this._virtualBackground&&!this._glVideoContext.available)throw new $b({code:Jb.INVALID_OPERATION,message:"webgl context create failed, ".concat(this._glVideoContext.error)})}))}get mixScreen(){return this._isMixScreen}set mixScreen(e){var t;this._isMixScreen=e,this._isMixScreen||(null==(t=this.screenNode)||t.close(),delete this.screenNode),this.update()}set mirror(e){var t;this._isMirror!==e&&(this._isMirror=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get mirror(){return this._isMirror}set rotation(e){var t;this._rotation!==e&&(this._rotation=e,this._isTransform||(null==(t=this.transformNode)||t.close(),delete this.transformNode),this.update())}get rotation(){return this._rotation}enableAr(e){this.arTrack=e,this.isUsingArTrack=!0,this.update()}updateAr(){return Wb(this,null,(function*(){var e;null!=(e=this.cameraTrack)&&e.mediaTrack&&(yield this.virtualBackgroundInstance.ar.updateInputTrack(this.cameraTrack.mediaTrack.clone()))}))}disableAr(){var e;this.isUsingArTrack=!1,null==(e=this.arTrack)||e.stop(),this.arTrack=void 0,this.update()}createDecodeContext(e){return new oW(e)}clear(){var e;null==(e=this.videoContext)||e.disconnect(),delete this.destination,delete this.cameraNode,delete this.transformNode,delete this.screenNode,delete this.waterMarkNode}addEncodeProcessor(e){let{processor:t,type:r}=e;var i;this.encodePipeline.includes(t)||(this.encodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}addDecodeProcessor(e){let{processor:t,type:r}=e;var i;this.decodePipeline.includes(t)||(this.decodePipeline[r]=t,null==(i=this.room)||i.enableInsertableStreams())}removeEncodeProcessor(e){let{type:t}=e;this.encodePipeline[t]=void 0}removeDecodeProcessor(e){let{type:t}=e;this.decodePipeline[t]=void 0}};Fb([function(e){return JP(((t,r)=>function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return Wb(this,null,(function*(){try{return yield t.apply(this,i)}catch(iO){e.call(this,iO)}}))}))}((function(e){this.log.error("update failed",e)}))],nW.prototype,"update",1);var aW=0,sW=class extends EL{constructor(e){super("room"),Bb(this,"seq",++aW),Bb(this,"sdkAppId"),Bb(this,"userId"),Bb(this,"userSig"),Bb(this,"privateMapKey"),Bb(this,"latencyLevel"),Bb(this,"tinyId"),Bb(this,"scene"),Bb(this,"roomId"),Bb(this,"useStringRoomId"),Bb(this,"role","anchor"),Bb(this,"joinParams",null),Bb(this,"localTracks",new Set),Bb(this,"enableAutoPlayDialog",!0),Bb(this,"autoReceiveAudio",!0),Bb(this,"autoReceiveVideo",!0),Bb(this,"proxy_ws"),Bb(this,"proxy_wt"),Bb(this,"proxy_unified"),Bb(this,"checkSystemResult",{result:!0,detail:{isBrowserSupported:!0,isWebRTCSupported:!0,isWebCodecsSupported:!0,isMediaDevicesSupported:!0,isScreenShareSupported:!0,isSmallStreamSupported:!0,isH264EncodeSupported:!0,isVp8EncodeSupported:!0,isH264DecodeSupported:!0,isVp8DecodeSupported:!0}}),Bb(this,"keyPointManager"),Bb(this,"audioManager"),Bb(this,"videoManager"),Bb(this,"callDurationCalculator"),Bb(this,"badCaseDetector"),Bb(this,"scheduleResult",{domains:null,iceServers:null,iceTransportPolicy:null,trtcAutoConf:null}),Bb(this,"videoDecodeFallbackType"),Bb(this,"smallMode","canvas"),Bb(this,"_isUsingCachedSchedule",!1),Bb(this,"_log",Yk.createLogger({id:"r".concat(this.seq)})),Bb(this,"_joinedTimestamp",0),Bb(this,"_sdkType"),Bb(this,"heartbeatReport"),Bb(this,"quality"),Bb(this,"enableSEI"),Bb(this,"isDestroyed",!1),this.useStringRoomId=!!e.useStringRoomId,aC(e.autoReceiveAudio)&&(this.autoReceiveAudio=e.autoReceiveAudio),aC(e.autoReceiveVideo)&&(this.autoReceiveVideo=e.autoReceiveVideo),aC(e.enableAutoPlayDialog)&&(this.enableAutoPlayDialog=e.enableAutoPlayDialog),this._sdkType=e.sdkType,this.keyPointManager=new jH({room:this,frameWorkType:e.frameWorkType,component:e.component,language:e.language}),this.callDurationCalculator=new KH({room:this}),this.badCaseDetector=new zH({room:this}),this.audioManager=new Ex(this),this.videoManager=new nW(this)}get scriptTransformWorker(){}get isMainStreamPublished(){for(let e of this.localTracks)if(4&e.mediaType)return!0;return!1}get isAuxStreamPublished(){for(let e of this.localTracks)if(2&e.mediaType)return!0;return!1}get hasAuxStream(){for(let e of this.remotePublishedUserMap.values())if(e.muteState.hasAuxiliary)return!0;return this.isAuxStreamPublished}get localMainVideoTrack(){for(let e of this.localTracks)if(4&e.mediaType)return e;return null}get localAuxVideoTrack(){for(let e of this.localTracks)if(2&e.mediaType)return e;return null}getLogger(){return this._log}get isJoining(){return"joining"===this.state.toString()}get isJoined(){return"joined"===this.state}get isLeft(){return"left"===this.state}addTrack(e){return Wb(this,null,(function*(){return this.publish(e)}))}removeTrack(e){return Wb(this,null,(function*(){return this.unpublish(e)}))}replaceTrack(e){return Wb(this,null,(function*(){}))}setEncodedDataProcessingListener(e){throw new Error("Method not implemented.")}enableAIVoice(e){throw new Error("Method not implemented.")}setProxyServer(e){if(oC(e))e.startsWith("wss://")?this.proxy_ws=e:e.startsWith("https://")&&(this.proxy_wt=e);else if(QD(e)){let{websocketProxy:t,webtransportProxy:r,loggerProxy:i,scheduleProxy:o,unifiedProxy:n}=e;this.proxy_ws=t,this.proxy_wt=r,this.proxy_unified=n,n?(PB([n,n]),hw("https://".concat(n))):(i&&hw(i),o&&PB(o))}Gk.once(zk.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({sched_domain:LB.main,sched_back_domain:LB.backup,signal_domain:this.proxy_ws||this.proxy_wt||""})))}getRemoteAudioStats(){return Wb(this,null,(function*(){let e={};return this.remotePublishedUserMap.forEach((t=>{e[t.userId]=t.remoteAudioTrack.stat})),e}))}getTransportStats(){return Wb(this,null,(function*(){var e;let t={rtt:(null==(e=this.quality)?void 0:e.uplinkRTT)||0,downlinksRTT:{}};if(this.quality)for(let r of this.quality.downlinkInfo)t.downlinksRTT[r.userId]=r.rtt;return t}))}getRemoteVideoStats(){return Wb(this,arguments,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"main";return function*(){let r={};return e.remotePublishedUserMap.forEach((e=>{let i="auxiliary"===t?e.remoteAuxiliaryTrack:e.remoteVideoTrack;r[e.userId]=i.stat})),r}()}))}checkDestroy(){if(this.isDestroyed)throw new $b({code:Jb.INVALID_OPERATION,message:iM({key:ZO.CLIENT_DESTROYED,data:{funName:"join"}})})}destroy(){if(this.isJoined)throw this._log.warn(eM.INVALID_DESTROY),new $b({code:Jb.INVALID_OPERATION,message:iM({key:ZO.INVALID_DESTROY})});this._log.info("destroy room"),this.audioManager.destroy(),this.videoManager.destroy(),this.keyPointManager.destroy(),this.callDurationCalculator.destroy(),this.badCaseDetector.destroy(),this.isDestroyed=!0,Gk.emit(zk.ROOM_DESTROY,{room:this})}schedule(e,t){return Wb(this,null,(function*(){var r,i,o,n;let a=_C();try{let{isCached:s,result:c,detailCost:l}=yield MB({userId:this.userId,sdkAppId:this.sdkAppId,roomId:this.useStringRoomId?e.strRoomId:e.roomId,useStringRoomId:this.useStringRoomId,version:ow,userSig:this.userSig,role:"live"===this.scene?e.role:void 0,frameWorkType:t,latencyLevel:e.latencyLevel});this._isUsingCachedSchedule=s,this._log.info("schedule cache:".concat(+s," ").concat(CC(c,{keysToExclude:["username","credential"]}))),s&&Gk.once(zk.JOIN_RECEIVED_CMD_RES,(()=>this.sendAbilityStatus({scheduleCache:1}))),this.scheduleResult=Lb(Lb({},this.scheduleResult),c),nC(null==(r=c.config)?void 0:r.retryCount)&&sD(c.config.retryCount),oC(null==(i=c.config)?void 0:i.loggerDomain)&&hw(c.config.loggerDomain),this.videoDecodeFallbackType=(null==(o=c.config)?void 0:o.videoDecodeFallback)||this.videoDecodeFallbackType,this.smallMode=(null==(n=c.config)?void 0:n.smallMode)||this.smallMode,Gk.emit(zk.JOIN_SCHEDULE_SUCCESS,{room:this,schedule:this.scheduleResult,detailCost:l}),mM.addSuccessEvent({key:521700,cost:_C()-a})}catch(eO){throw mM.addFailedEvent({key:521700,error:eO}),eO}}))}sendAbilityStatus(e){}enableInsertableStreams(){return Promise.resolve()}switchRoom(e){return Promise.reject()}isSwitchRoomSupported(){return!1}};var cW={useWt:!0,useAINS:!0,useHardDecoder:"prefer-software",useHardEncoder:"prefer-software",unreliable:!1,debug:!1,assetsPath:"",enableUpload:!0},lW="__INLINE__WORKER__",uW="__INLINE__WASM__",{debug:dW}=console;cW.debug||(console.debug=()=>{});var hW,pW=!lW.startsWith("__"),mW=!uW.startsWith("__");function fW(){let e=VC("".concat(cW.assetsPath?"".concat(cW.assetsPath,"/"):"","worker.js"));return pW?URL.createObjectURL(new Blob([atob(lW)],{type:"application/javascript"})):e.startsWith("http")?fetch(e).then((e=>e.blob().then((e=>URL.createObjectURL(e))))):e}function _W(){return Wb(this,null,(function*(){let e=cW.assetsPath?"".concat(cW.assetsPath,"/"):"";return hW||(hW=mW?(new TextEncoder).encode(atob(uW)).buffer:yield fetch(VC("".concat(e,"av_processing.wasm"))).then((e=>e.arrayBuffer())),hW)}))}var gW=new class{constructor(){Bb(this,"playPort"),Bb(this,"playPortSent",!1),Bb(this,"worklet"),Bb(this,"workletPromise")}init(){return this.workletPromise||(this.workletPromise=this._init()),this.workletPromise}_init(){return Wb(this,null,(function*(){let e=uP(),t=fW();try{yield e.audioWorklet.addModule("string"==typeof t?t:yield t),Yk.info("global audio player worklet addModule success",t)}catch(lD){throw Yk.error("global audio player worklet addModule failed:",lD),lD}return this.worklet=new AudioWorkletNode(e,"global-audio-player",{processorOptions:{wasm:yield _W(),flag:cW},numberOfInputs:2}),Yk.info("global audio player worklet created",e.state),this.worklet.connect(e.destination),this.playPort=this.worklet.port,this.playPort}))}playAudio(e){return Wb(this,null,(function*(){this.playPortSent||(this.playPortSent=!0,e(yield this.init()))}))}},EW="undefined"!=typeof self&&(!("top"in self)||self===top)&&"showOpenFilePicker"in self&&"showOpenFilePicker";EW?Promise.resolve().then((function(){return IW})):Promise.resolve().then((function(){return DW})),EW?Promise.resolve().then((function(){return bW})):Promise.resolve().then((function(){return CW}));var vW=EW?Promise.resolve().then((function(){return wW})):Promise.resolve().then((function(){return NW}));function yW(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(this,null,(function*(){return(yield vW).default(...t)}))}var TW=e=>Wb(void 0,null,(function*(){let t=yield e.getFile();return t.handle=e,t})),IW={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){Array.isArray(e)||(e=[e]);let t=[];e.forEach(((e,r)=>{t[r]={description:e.description||"Files",accept:{}},e.mimeTypes?e.mimeTypes.map((i=>{t[r].accept[i]=e.extensions||[]})):t[r].accept["*/*"]=e.extensions||[]}));let r=yield window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),i=yield Promise.all(r.map(TW));return e[0].multiple?i:i[0]}()}))}};function AW(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then((function(e){return{value:e,done:t}}))}return AW=function(e){this.s=e,this.n=e.next},AW.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AW(e)}var SW,RW=function(e,t){for(var r=arguments.length,i=new Array(r>2?r-2:0),o=2;o<r;o++)i[o-2]=arguments[o];return Wb(void 0,[e,t,...i],(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.name,i=arguments.length>3?arguments[3]:void 0;return function*(){let o=[],n=[];var a,s=!1,c=!1;try{for(var l,u=function(e){var t,r,i,o=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,i=Symbol.iterator);o--;){if(r&&null!=(t=e[r]))return t.call(e);if(i&&null!=(t=e[i]))return new AW(t.call(e));r="@@asyncIterator",i="@@iterator"}throw new TypeError("Object is not async iterable")}(e.values());s=!(l=yield u.next()).done;s=!1){let a=l.value,s="".concat(r,"/").concat(a.name);"file"===a.kind?n.push(a.getFile().then((t=>(t.directoryHandle=e,t.handle=a,Object.defineProperty(t,"webkitRelativePath",{configurable:!0,enumerable:!0,get:()=>s}))))):"directory"!==a.kind||!t||i&&i(a)||o.push(RW(a,t,s,i))}}catch(d){c=!0,a=d}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(c)throw a}}return[...(yield Promise.all(o)).flat(),...yield Promise.all(n)]}()}))},bW={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function*(){e.recursive=e.recursive||!1,e.mode=e.mode||"read";let t=yield window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return RW(t,e.recursive,void 0,e.skipDirectory)}()}))}},wW={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Wb(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[{}],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;return function*(){Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";let n=[],a=null;if(e instanceof Blob&&e.type?a=e.type:e.headers&&e.headers.get("content-type")&&(a=e.headers.get("content-type")),t.forEach(((e,t)=>{n[t]={description:e.description||"Files",accept:{}},e.mimeTypes?(0===t&&a&&e.mimeTypes.push(a),e.mimeTypes.map((r=>{n[t].accept[r]=e.extensions||[]}))):a?n[t].accept[a]=e.extensions||[]:n[t].accept["*/*"]=e.extensions||[]})),r)try{yield r.getFile()}catch(oM){if(r=null,i)throw oM}let s=r||(yield window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:n,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1}));!r&&o&&o(s);let c=yield s.createWritable();return"stream"in e?(yield e.stream().pipeTo(c),s):"body"in e?(yield e.body.pipeTo(c),s):(yield c.write(yield e),yield c.close(),s)}()}))}},DW={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),new Promise(((t,r)=>{let i=document.createElement("input");i.type="file";let o=[...e.map((e=>e.mimeTypes||[])),...e.map((e=>e.extensions||[]))].join();i.multiple=e[0].multiple||!1,i.accept=o||"",i.style.display="none",document.body.append(i);let n=e=>{"function"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(n,(()=>a(r)),i),s=()=>{window.removeEventListener("focus",s),i.remove()};i.addEventListener("click",(()=>{window.addEventListener("focus",s)})),i.addEventListener("change",(()=>{window.removeEventListener("focus",s),i.remove(),n(i.multiple?Array.from(i.files):i.files[0])})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},CW={__proto__:null,default:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(void 0,[...t],(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[{}];return function*(){return Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise(((t,r)=>{let i=document.createElement("input");i.type="file",i.webkitdirectory=!0;let o=e=>{"function"==typeof n&&n(),t(e)},n=e[0].legacySetup&&e[0].legacySetup(o,(()=>n(r)),i);i.addEventListener("change",(()=>{let t=Array.from(i.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter((t=>t.webkitRelativePath.split("/").every((t=>!e[0].skipDirectory({name:t,kind:"directory"})))))):t=t.filter((e=>2===e.webkitRelativePath.split("/").length)),o(t)})),"showPicker"in HTMLInputElement.prototype?i.showPicker():i.click()}))}()}))}},NW={__proto__:null,default:function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return Wb(void 0,[e,...r],(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function*(){Array.isArray(t)&&(t=t[0]);let r=document.createElement("a"),i=e;"body"in e&&(i=yield function(e,t){return Wb(this,null,(function*(){let r=e.getReader(),i=new ReadableStream({start:e=>function t(){return Wb(this,null,(function*(){return r.read().then((r=>{let{done:i,value:o}=r;if(!i)return e.enqueue(o),t();e.close()}))}))}()}),o=new Response(i),n=yield o.blob();return r.releaseLock(),new Blob([n],{type:t})}))}(e.body,e.headers.get("content-type"))),r.download=t.fileName||"Untitled",r.href=URL.createObjectURL(yield i);let o=()=>{"function"==typeof n&&n()},n=t.legacySetup&&t.legacySetup(o,(()=>n()),r);return r.addEventListener("click",(()=>{setTimeout((()=>URL.revokeObjectURL(r.href)),3e4),o()})),r.click(),null}()}))}},kW=class{constructor(e){this.name=e,Bb(this,"ready"),Bb(this,"worker"),Bb(this,"ports"),Bb(this,"ids",1),Bb(this,"transactions",new Map),Bb(this,"log"),Bb(this,"addTransaction",(e=>(this.transactions.set(++this.ids,e),this.ids)))}postMessage(e,t){var r;null==(r=this.worker)||r.postMessage(e,t)}create(e){return Wb(this,null,(function*(){if(this.ready)return this.ready;e||(e=this.name),console.time("createWorker_".concat(e));let t=fW(),r=new Worker("string"==typeof t?t:yield t,{name:e});return this.worker=r,this.ready=new Promise(((t,i)=>Wb(this,null,(function*(){r.onmessage=r=>{let{data:{id:o,type:n,payload:a}}=r;var s;if(o)null==(s=this.transactions.get(o))||s(a),this.transactions.delete(o);else switch(n){case"error":console.timeEnd("createWorker_".concat(e)),console.warn("worker error:",a),i(a);break;case"ready":console.timeEnd("createWorker_".concat(e)),t(this);break;case"updateAFSM":if(a.value){let e="string"==typeof a.old?a.old:"".concat(a.old.action,"ing"),t="string"==typeof a.value?a.value:"".concat(a.value.action,"ing");console.log(DC(),a.group,a.name,e,"👉",t)}break;case"log":console.log(a);break;case"glog":window.dispatchEvent(new CustomEvent(n,{detail:a}))}},r.postMessage({wasm:yield _W(),flag:cW},this.ports)}))))}))}destroy(){var e;console.log("destroy worker",this.name),delete this.ready,null==(e=this.worker)||e.terminate()}},OW=class{constructor(e,t,r){this.worker=e,Bb(this,"channel",new MessageChannel),Bb(this,"ready"),this.ready=new Promise(((e,r)=>{this.worker.postMessage({id:this.worker.addTransaction(e),payload:t},[this.channel.port2])})).then((e=>(0===e.err&&(this.worker.sessionCount++,this.channel.port1.onmessage=r),e)))}postMessage(){this.channel.port1.postMessage(...arguments)}destroy(){0==--this.worker.sessionCount&&this.worker.destroy()}},MW=new class e extends kW{constructor(){super("main"),Bb(this,"switchValue",new Map),Bb(this,"extendChannel"),Bb(this,"sessionCount",0)}setSwitchValue(e,t){var r;this.switchValue.set(e,t),null==(r=this.extendChannel)||r.port1.postMessage([e,t])}create(){return Wb(this,null,(function*(){return this.ready?this.ready:(this.extendChannel=new MessageChannel,this.ports=[this.extendChannel.port2],yield Hb(e.prototype,this,"create").call(this),this.switchValue.forEach(((e,t)=>{this.extendChannel.port1.postMessage([t,e])})),this)}))}};function LW(e){return Wb(this,null,(function*(){yield MW.create(),Gk.emit(zk.JOIN_SEND_CMD,{room:this});let t=new OW(MW,e,(e=>{let r=e.data;if("string"==typeof r)this.onWorkerEvent(r);else if(null==r)this.onWorkerEvent("client-banned",0),t.destroy();else{let{cmd:e,payload:t}=r;this.onWorkerEvent(e,t)}})),{err:r,data:i}=yield t.ready;if("number"==typeof r){if(Gk.emit(zk.JOIN_RECEIVED_CMD_RES,{room:this,code:r}),0===r)return Object.assign(this,i,{session:t});throw new $b({code:Jb.JOIN_ROOM_FAILED,extraCode:Number(r),message:iM({key:ZO.SIGNAL_CHANNEL_SETUP_FAILED,data:{errorCode:r,errorMsg:""}})})}throw r}))}function PW(e){return Wb(this,null,(function*(){MW.setSwitchValue("useAINS",e)}))}function xW(e){return Wb(this,null,(function*(){MW.setSwitchValue("useV2",e)}))}function UW(e){let t=new MediaStreamTrackGenerator({kind:"audio"});e.setInputMediaStreamTrack(t),this.postMessage({cmd:"pullAudio",payload:{tinyId:e.tinyId,writable:t.writable}},[t.writable])}function VW(e){return Wb(this,null,(function*(){var t;this._log.info("pull video",e);let r=Date.now(),i=0,o=new MessageChannel;this.postMessage({cmd:"pullVideo",payload:{mediaType:e.mediaType,tinyId:e.tinyId}},[o.port1]),(t=e.stat).framesReceived||(t.framesReceived=0),Nx(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=Object.defineProperties($x(),{postMessage:{value:e.postMessage.bind(e)},port:{get:()=>e,set(t){e.onmessage=yx,e.onmessageerror=yx,e=t,i()}}});function i(){e.onmessage=i=>{i.data?i.ports.length||t?r.next(i):r.next(i.data):(r.complete(),e.close())},e.onmessageerror=t=>{r.error(t),e.close()}}return i(),r}(o.port2),CU(sU(e,EL.INIT)),DV((t=>{let{data:o,packetsReceived:n}=t;e.stat.packetsReceived=n,e.stat.framesReceived++,i++;let a,s=31&o[4];if(i<=10){let e=Array.from(o.slice(0,10)).map((e=>e.toString(16).padStart(2,"0"))).join(" ");this._log.info("Frame ".concat(i," - Size: ").concat(o.length," bytes, Type: ").concat(s,", Timestamp: ").concat(Date.now()-r,"ms First 10 bytes: ").concat(e))}switch(s){case 5:case 7:a="key";break;default:a="delta"}e.isAvailable?e.decodeFrame({data:o.buffer,type:a,timestamp:1e3*(Date.now()-r)}):console.warn("track is not available")}),(()=>{}),(()=>{o.port2.postMessage(null),o.port2.close()})))}))}Object.defineProperties(window,{useAINS:{set:PW},useWt:{set:function(e){return Wb(this,null,(function*(){MW.setSwitchValue("useWt",e)}))}},enableDebug:{set(e){console.debug=e?dW:()=>{},MW.setSwitchValue("enableDebug",e)}},useV2:{set:xW},dump:{value(){if(SW||(console.warn("dump audio will be activated at next time join room"),SW=[]),!SW.length)return void console.warn("no audio data to dump,try it later");let e=[];return SW.forEach((t=>{e.push(new Uint16Array([t.length])),e.push(t)})),yW(new Blob(e),{fileName:"audio dump hex",extensions:[".hex"]})}},dumpAudio:{value(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"audio",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,r=[],i=new Promise((i=>{let o=new MessageChannel;MW.extendChannel.port1.postMessage(["dump",e],[o.port1]),o.port2.onmessage=n=>{let{data:a}=n;console.log(a),r.push(a),r.length>t&&(o.port2.onmessage=null,MW.extendChannel.port1.postMessage(["dump",e]),o.port2.close(),i(new Blob(r)))}}));return yW(i,{fileName:e,extensions:[".pcm"]})}},hardDec:{set(e){switch(e){case!0:cW.useHardDecoder="prefer-hardware";break;case!1:cW.useHardDecoder="prefer-software";break;default:cW.useHardDecoder="no-preference"}}}});var FW=[];function BW(e){var t;let r=$x();if("joined"!==this.state)throw new Error("Room is not joined");if("publish"===e.state)return;for(let l=0;l<=FW.length;l++)if(!FW[l]){FW[l]=this,this.index=l;break}let i=e.profile;this._log.info("start push audio",this.index,i);let o=new MessageChannel,n=e.enableEncodeFrame?new MessageChannel:null;null==(t=this.session)||t.postMessage({cmd:"pushAudio",payload:Lb({index:this.index},i)},n?[o.port2,n.port2]:[o.port2]),o.port1.onmessage=t=>{null==t.data||("number"==typeof t.data?r.next(t.data):n&&n.port1.postMessage(Pb(Lb({},t.data),{data:new Uint8Array(e.encodeFrame({data:t.data.data.buffer,timestamp:t.data.timestamp}).data)})))};let a,s=new MediaStream,c=e=>{let t=s.getAudioTracks()[0];t&&(a.disconnect(),s.removeTrack(t)),s.addTrack(e),this._log.info("push audio track:",e.readyState,e.getSettings().deviceId),a=uP().createMediaStreamSource(s),a.connect(gW.worklet,0,this.index)};Nx(sU(e,"output-media-track-changed"),CU(sU(e,"ready")),DV(c,console.error,(()=>{this._log.info("stop push audio",i),e.volume=0,a.disconnect(),FW[this.index]=null,n&&n.port1.postMessage(null),o.port1.postMessage(null)}))),Nx(r,CV((t=>e.volume=t)),cV(FV(1e3)),DV((()=>{e.volume=0}))),c(e.outMediaTrack)}var HW=class{constructor(e,t,r,i){this.localTrack=e,this.type=t,this.config=r,this.port=i,Bb(this,"track"),Bb(this,"label"),Bb(this,"insertKeyFrame",!0),Bb(this,"encoder"),Bb(this,"tsMap",new Map),e._log.info("create Video Encoder",r)}trans(e,t,r){return Wb(this,null,(function*(){yield this.recreate(r),t.signal.addEventListener("abort",(()=>{this.encoder.close()}));let i=0;return e.pipeThrough(new TransformStream({transform:(e,t)=>{"configured"===this.encoder.state&&(this.tsMap.set(i,Date.now()),this.encode(e),i++,t.enqueue(e))}}),t)}))}encode(e){this.encoder.encode(e,{keyFrame:this.insertKeyFrame}),this.insertKeyFrame=!1}start(e,t,r){return Wb(this,null,(function*(){yield this.recreate(r);let i=0;e.pipeTo(new WritableStream({write:e=>{"configured"===this.encoder.state&&(i<10&&this.localTrack.log.info("capture ".concat(this.label," track frame:"),i,Date.now(),e.timestamp,e.displayWidth,e.displayHeight),(e.displayWidth!==this.config.width||e.displayHeight!==this.config.height)&&(this.localTrack.log.info("resize video track frame:",e.displayWidth,e.displayHeight,this.config.width,this.config.height),this.configure({width:e.displayWidth,height:e.displayHeight})),this.tsMap.set(i,Date.now()),this.encode(e),i<10&&this.localTrack.log.info("encode ".concat(this.label," track frame:"),i),i++,e.close())}}),t).catch((e=>{var t;this.localTrack.log.warn(e),null==(t=this.encoder)||t.close()}))}))}recreate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Wb(this,null,(function*(){let r=0,i=new VideoEncoder({output:i=>{let o=this.tsMap.get(r);if(this.tsMap.delete(i.timestamp),r<10&&(0===r&&0===t&&Gk.emit(zk.SEND_FIRST_VIDEO_FRAME,{room:e}),this.localTrack.log.info("encoded ".concat(this.label," track frame:"),r,Date.now(),i.timestamp)),r++,!1===this.track.enabled)return;let n=null;if(this.localTrack.enableEncodeFrame){n=new Uint8Array(i.byteLength),i.copyTo(n);let e=this.localTrack.encodeFrame({data:n.buffer},3===this.type);n=new Uint8Array(e.data)}n?(this.localTrack.stat.bytesSent+=n.length,this.port.postMessage({chunk:{type:i.type,timestamp:i.timestamp,data:n,duration:i.duration},timestamp:o},[n.buffer])):(this.localTrack.stat.bytesSent+=i.byteLength,this.port.postMessage({chunk:i,timestamp:o}))},error:r=>{this.localTrack.log.warn(r,this.config),setTimeout((()=>this.recreate(e,t+1)),100)}});return this.encoder=i,yield this.configure({},0===r?t:0),i}))}configure(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return Wb(this,null,(function*(){var r;if(Object.assign(this.config,e),0===t)for(let e=0;e<=tW.length;e++){let{supported:t}=yield VideoDecoder.isConfigSupported(this.config);if(t)break;if(e===tW.length)return;tW[e](this.config)}else t<=tW.length&&tW[t-1](this.config);null==(r=this.encoder)||r.configure(this.config)}))}close(){this.port.postMessage(null),this.port.close()}};function WW(e,t){return Wb(this,null,(function*(){let r=2===e.mediaType,i=r?"screen":"video",o={codec:"avc1.640028",latencyMode:"realtime",avc:{format:"annexb"},hardwareAcceleration:cW.useHardEncoder,width:t.profile.width,height:t.profile.height,framerate:t.profile.frameRate,bitrate:1e3*t.profile.bitrate},n=new MessageChannel;this.postMessage({cmd:"pushVideo",payload:t},[n.port1]);let a=new HW(e,t.type,o,n.port2);return n.port2.onmessage=e=>{if(260===e.data)a.insertKeyFrame=!0;else if(!r){let{bitrate:t}=e.data;XD({configureBr:[e.data.bitrate,t]}),a.configure({bitrate:t})}},this._log.info("start push",i,t),a}))}function jW(e){return Wb(this,null,(function*(){var t;let r=2===e.mediaType,i=r?"screen":"video",o={type:r?7:2,profile:e.profile,trackType:r?"screen":"camera",crypto:!(null==(t=e.manager)||!t.encodePipeline[0])};!r&&e.outMediaTrack instanceof CanvasCaptureMediaStreamTrack&&(o.trackType="canvas");let{trackType:n}=o,{width:a,height:s}=e.outMediaTrack.getSettings();o.profile.width=a,o.profile.height=s;let c=yield WW.call(this,e,o);this._log.info("VideoEncoder created",o);let l,u=t=>Wb(this,null,(function*(){if(null==l||l.abort("track changed"),!t)return;l=new AbortController;let{width:r,height:o,displaySurface:a}=t.getSettings();r&&(c.config.width=r),o&&(c.config.height=o);let s,u=$C.match(/Chrome\/(\d+)/);"114"===(null==u?void 0:u[1])&&"browser"===a&&delete c.config.hardwareAcceleration,this._log.info("push",i,"track:",t.readyState,t.getSettings()),s="undefined"!=typeof MediaStreamTrackProcessor?new MediaStreamTrackProcessor({track:t}).readable:new ReadableStream({pull(t){return Wb(this,null,(function*(){if(sL())return new Promise((r=>{var i;null==(i=e.player.element)||i.requestVideoFrameCallback(((i,o)=>{let n=new VideoFrame(e.player.element);t.enqueue(n),r()}))}))}))}});let d="small"in e&&e.small;return d?(this.smallEncoder||(this.smallEncoder=yield WW.call(this,e,{profile:d,type:3,trackType:n})),this.smallEncoder.track=t,this.smallEncoder.label="small",s=yield this.smallEncoder.trans(s,l,this)):this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder),c.track=t,c.label=i,c.start(s,l,this)}));return Nx(sU(e,"output-media-track-changed"),CU(sU(e,"ready")),DV(u,console.error,(()=>{var e;this._log.info("stop push",i,o),l.abort("unpublish"),c.close(),null==(e=this.smallEncoder)||e.close()}))),u(e.outMediaTrack)}))}var GW=class e extends EL{constructor(t){var r,i;super(null!=(i=null==(r=t.roomid)?void 0:r.toString())?i:t.name,"volumeEvaluation"),this.room=t,Bb(this,"enableInBackground",!1),Bb(this,"interval",400),t.on("joined",(()=>{this.emit(e.INTERVALCHANGED,this.interval)})),Nx(sU(this,e.INTERVALCHANGED),aV((e=>"joined"===this.room.state?this.room.fromWorker("getAudioEnergy",e):Nx((e=>t=>{let r=0,i=performance.now();Nx(VV,eV((t=>(t-i)/e|0)),bU((e=>e!=r&&(r=e,!0))))(t)})(e),eV((()=>[]))))),DV((e=>{e.forEach((e=>{this.room.remotePublishedUserMap.has(e.userId)&&(this.room.remotePublishedUserMap.get(e.userId).remoteAudioTrack.volume=e.volume)})),(!document.hidden||this.enableInBackground)&&this.state==EL.ON&&this.room.emit("audio-volume",e)})))}start(t,r){this.interval=t,this.enableInBackground=r,this.emit(e.INTERVALCHANGED,this.interval)}stop(){}};Bb(GW,"INTERVALCHANGED","intervalChanged"),Fb([fL([EL.INIT,EL.OFF],EL.ON)],GW.prototype,"start",1),Fb([fL([],EL.OFF)],GW.prototype,"stop",1);var KW=GW,zW=class extends sW{constructor(e){super(e),Bb(this,"index",0),Bb(this,"session"),Bb(this,"tinyid"),Bb(this,"roomid"),Bb(this,"openid"),Bb(this,"socketid"),Bb(this,"relayip"),Bb(this,"clientip"),Bb(this,"remotePublishedUserMap",new Map),Bb(this,"bussinessInfo"),Bb(this,"token"),Bb(this,"audioVolumeEvalution",new KW(this)),Bb(this,"enableAIVoice",PW),Bb(this,"AbilityOption",{AVLimit:{EncVideoCodec:"H265",EncVideoWidth:0,EncVideoHeight:0,EncVideoBr:"0",EncVideoFps:0,EncAudioCodec:"opus",EncAudioFS:0,EncAudioCh:0,EncAudioBr:"0"},GeneralLimit:{CPULimit:{uint32_CPU_num:navigator.hardwareConcurrency||0,str_CPU_name:navigator.platform,uint32_CPU_maxfreq:0,model:"",uint32_total_memory:0},uint32_terminal_type:Hk(),uint32_device_type:0,str_os_verion:Wk(),uint32_link_type:1,str_client_version:ow,uint32_net_type:Dw[tw.getNetworkType()],ua:navigator.userAgent,version:""}}),Bb(this,"joinAbortController",new AbortController),Bb(this,"smallAbortCtrl"),Bb(this,"smallEncoder"),e.tinyId&&(this.tinyId=e.tinyId,xW(!0)),this._log||(this._log=e.logger),this.bussinessInfo=e.bussinessInfo,e.encodedDataProcessingListener&&this.setEncodedDataProcessingListener(e.encodedDataProcessingListener)}replaceTrack(e){return Wb(this,null,(function*(){}))}getLogger(){return this._log}postMessage(e,t){this.session&&(e?"string"==typeof e?this.session.postMessage({cmd:e,payload:t}):this.session.postMessage(e,t):this.session.postMessage(null))}sendMessage(e,t){return new Promise(((r,i)=>{"joined"!=this.state&&i("join room first");let o=new MessageChannel;this.postMessage({cmd:e,payload:t},[o.port1]),o.port2.onmessageerror=i,o.port2.onmessage=e=>{o.port2.close(),r(e.data)}}))}fromWorker(e,t){if("joined"!=this.state)throw"join room first";return r=>{var i;let o=new MessageChannel;o.port2.onmessage=e=>{e.data?r.next(e.data):r.complete()},o.port2.onmessageerror=e=>r.error(e),r.defer((()=>{o.port2.postMessage(null),o.port2.close()})),null==(i=this.session)||i.postMessage({cmd:e,payload:t},[o.port1])}}switchRole(e){return Wb(this,null,(function*(){if(e!==this.role)return this._log.info("switchRole() => switch role to: ".concat(e)),"audience"==e&&this.unpublish(...this.localTracks),this.sendMessage("switchRole","audience"==e?21:20).then((t=>{this.role=e}))}))}join(e,t,r){return Wb(this,null,(function*(){var i,o,n;let a=tw.getEnv(),s=gM(),c={isH264EncodeSupported:this.checkSystemResult.detail.isH264EncodeSupported,isVp8EncodeSupported:this.checkSystemResult.detail.isVp8EncodeSupported,frameWorkType:r,params:e,proxy_wt:null==(i=this.proxy_wt)?void 0:i.replace("https://",""),proxy_ws:null==(o=this.proxy_ws)?void 0:o.replace("wss://",""),proxy_cloud:null!=(n=this.scheduleResult.iceServers)&&n.length?this.scheduleResult.iceServers[0].urls:[],proxy_unified:this.proxy_unified,domains:this.scheduleResult.domains,env:a,osName:Vk(),browserInfo:gM(),tinyId:this.tinyId,joinReq:{useStrRoomid:!!this.useStringRoomId,roomid:String(e.roomId||e.strRoomId),sdkAppID:String(e.sdkAppId),userSig:e.userSig,privMapEncrypt:e.privateMapKey||"",privMap:"",pstnBizType:0,role:"user",jsSdkVersion:ow,browserVersion:s.browserName+s.browserVersion,closeLocalMedia:!0,trtcscene:"live"===t?2:1,trtcrole:e.role,bussinessInfo:e.businessInfo||this.bussinessInfo||"",isAuxUser:0,autoSubscribe:this.autoReceiveAudio&&this.autoReceiveVideo,AbilityOption:this.AbilityOption}};yield LW.call(this,c),console.log(this),gW.playAudio((e=>this.postMessage({cmd:"setAudioWorkletPort"},[e]))),this.checkDestroy()}))}leave(){return Wb(this,null,(function*(){this.remotePublishedUserMap.forEach((e=>{e.remoteAudioTrack.close(),e.remoteAuxiliaryTrack.close(),e.remoteVideoTrack.close()})),this.postMessage(null),this.remotePublishedUserMap.clear(),this.localTracks.forEach(((e,t)=>t.unpublish()))}))}getSignalInfo(){return{tinyId:this.tinyid,clientIp:this.clientip,signalIp:"",relayIp:this.relayip,relayInnerIp:"",relayPort:0}}enableAudioVolumeEvaluation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e<=0?this.audioVolumeEvalution.stop():this.audioVolumeEvalution.start(e,t)}getLocalAudioStats(){return this.sendMessage("getLocalAudioStats")}getLocalVideoStats(){return this.sendMessage("getLocalVideoStats")}afterJoin(){return Wb(this,null,(function*(){Nx((e=>Wb(this,null,(function*(){let t=new MessageChannel;t.port2.onmessage=r=>{r.data?e.next({data:r.data,port:t.port2}):e.complete()},t.port2.onmessageerror=t=>e.error(t),e.defer((()=>{t.port2.postMessage(null),t.port2.close()})),this.postMessage({cmd:"decodeAudio",payload:!!this.audioManager.decodePipeline[0]},[t.port1])}))),CU(sU(this,"left")),DV((e=>{let{data:t,port:r}=e,i=this.audioManager.decodePipeline[0]({frame:{data:t.data.buffer}});r.postMessage(Pb(Lb({},t),{data:new Uint8Array(i.data)}),[i.data])})))}))}onWorkerEvent(e,t){switch("network-quality"!==e&&console.info(this.userId,"onWorkerEvent",e,JSON.stringify(t)),e){case zk.RECEIVED_PUBLISHED_USER_LIST:return void Gk.emit(e,Lb({room:this},t));case"1":if(t.userId===this.userId)return;return void this.emit("peer-join",t);case"2":return void this.emit("peer-leave",t);case"3":let r=new xH(this,t);return this.remotePublishedUserMap.set(t.userId,r),void this.emit("remote-published",r);case"5":{let e=t,r=this.remotePublishedUserMap.get(e);r&&(r.remoteVideoTrack.close(),r.remoteAuxiliaryTrack.close(),r.remoteAudioTrack.close(),this.remotePublishedUserMap.delete(e),this.emit("remote-unpublished",r))}return;case"banned":switch(t){case 8:return void this.emit("banned",{reason:"kick",message:""});case 2:case 6:case 4:return void this.emit("banned",{reason:"banned",message:""});case 7:case 5:return void this.emit("banned",{reason:"room_disband",message:""})}break;case"6":{let{prevMuteState:e,muteState:r,flag:i}=t,o=this.remotePublishedUserMap.get(r.userId);if(!o)return void this.emit("remote-publish-state-changed",t);o.flag=i}return Gk.emit(zk.REMOTE_PUBLISH_STATE_CHANGED,Lb({room:this},t)),void this.emit("remote-publish-state-changed",t);case"network-quality":this.quality=Lb({},t);let{uplinkLoss:i,uplinkRTT:o,uplinkInfo:n,downlinkInfo:a,msg_down_stream_info:s}=t,c={str_sdk_version:ow,uint64_datetime:Date.now(),msg_user_info:{str_identifier:this.userId,uint64_tinyid:this.tinyid},msg_device_info:{uint32_terminal_type:15,str_device_name:navigator.platform,str_os_version:"",uint32_net_type:Dw[HD()]},msg_event_msg:iF(this.userId),str_acc_ip:this.relayip,str_client_ip:this.clientip,msg_up_stream_info:n,msg_down_stream_info:s};Gk.emit(zk.HEARTBEAT_REPORT,{room:this,report:c}),this.emit("heartbeat-report",c),Gk.emit(zk.NETWORK_QUALITY,{room:this,uplink:{rtt:o,loss:i},downlinks:a}),delete t.downlinkInfo;break;case"signal-connection-state-changed":return void Gk.emit(zk.SIGNAL_CONNECTION_STATE_CHANGED,Lb({room:this},t))}this.emit(e,t)}sendStartPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("publishCdn",e)}sendStopPublishCDN(e,t){return e.roomid=this.roomId,e.sdkAppID=String(this.sdkAppId),e.socketid=this.socketid,t&&(e.request_time=e.pushRequestTime),this.sendMessage("stopPublishCdn",e)}sendStartMixTranscode(e){return this.sendMessage("startMcuMix",e)}sendStopMixTranscode(e){return this.sendMessage("stopMcuMix",e)}publish(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),r=this.sendMessage("publish",e).then((e=>0!==e.err?Promise.reject(e.err):e)),i=0;yield Promise.all(t.map((e=>Wb(this,null,(function*(){if(1===(yield r,e.muted&&(i|=e.mediaType),DL(e,e).add("mute",(()=>{this.postMessage("mute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,remove:!0})})).add("unmute",(()=>{this.postMessage("unmute",{mediaType:e.mediaType,userId:this.userId,srctinyid:this.tinyid,add:!0})})),e.mediaType))BW.call(this,e);else yield jW.call(this,e)}))))),i&&this.postMessage("mute",{mediaType:i,srctinyid:this.tinyid,userId:this.openid,remove:!0})}))}unpublish(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(this,null,(function*(){t.forEach(CL)}))}subscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(this,null,(function*(){let e=t.reduce(((e,t)=>t.mediaType|e),0),{userId:r,tinyId:i,streamType:o}=t[0],n=this.remotePublishedUserMap.get(r),a=Lb({},n.subscribeState),s=Object.assign(new jO,a);s.mediaType|=e,Gk.emit(zk.SUBSCRIBE_START,{room:this,streamType:o,remotePublishedUser:n,subscribeState:s});let c=yield this.sendMessage("subscribe",{mediaType:s.mediaType,userId:r,srctinyid:i,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8,2].filter((e=>s.mediaType&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}});console.dir("subscribe",c),yield Promise.all(t.filter((e=>!e.isSubscribed)).map((e=>1===e.mediaType?UW.call(this,e):VW.call(this,e)))),Gk.emit(zk.SUBSCRIBE_SUCCESS,{room:this,streamType:o,remotePublishedUser:n})}))}unsubscribe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wb(this,null,(function*(){let e=0;for(let r of t)e|=r.mediaType;if(t.length){let{userId:r,streamType:i,tinyId:o}=t[0];yield this.sendMessage("unSubscribe",{mediaType:e,srctinyid:o,userId:r});for(let e of t)e.unsubscribe();Gk.emit(zk.UNSUBSCRIBE_SUCCESS,{room:this,streamType:i,remotePublishedUser:this.remotePublishedUserMap.get(r)})}}))}enableSmall(e){return Wb(this,null,(function*(){var t;if(e){if(this.videoManager.smallTrack){let e=this.videoManager.cameraTrack;this.smallEncoder=yield WW.call(this,e,{profile:e.small,type:3,trackType:"camera"});let t=new MediaStreamTrackProcessor({track:this.videoManager.smallTrack}).readable;this.smallEncoder.track=this.videoManager.smallTrack,this.smallEncoder.label="small",this.smallAbortCtrl=new AbortController,this.smallEncoder.start(t,this.smallAbortCtrl,this),this._log.info("push small")}}else null==(t=this.smallAbortCtrl)||t.abort("stop"),this.smallEncoder&&(this.smallEncoder.close(),delete this.smallEncoder)}))}changeType(e,t){let r=this.remotePublishedUserMap.get(t.userId);if(!r)return;let i=e?8:4;if(r.remoteVideoTrack.mediaType===i)return;let o={srctinyid:r.tinyId,mediaType:i,userId:t.userId,mediaDescription:{audioParam:{mediaType:1,payloadFmtps:[{payloadType:111,fmtp:"minptime=10;useinbandfec=1"}]},videoParam:[4,8].filter((e=>i&e)).map((e=>({mediaType:e,payloadFmtps:[{payloadType:100,fmtp:"packetization-mode=1;profile-level-id=42e01f"}]})))}};r.remoteVideoTrack.mediaType=o.mediaType,this.postMessage("changetype",o)}destroy(){this.isDestroyed||(super.destroy(),this.isDestroyed=!0,this.joinAbortController.abort("destroy"))}};Fb([YP(zW.prototype.afterJoin),fL(["left",EL.INIT],"joined"),JP((e=>{let t=new UH;return function(r,i,o){return Wb(this,null,(function*(){let n=String(r.roomId||r.strRoomId);if(this.userId=r.userId,this.sdkAppId=r.sdkAppId,this.userSig=r.userSig,this._log.setSdkAppId(this.sdkAppId),this._log.setUserId(this.userId),this.scene=i,r.privateMapKey=r.privateMapKey||"",this.isJoined)throw new $b({code:Jb.INVALID_OPERATION,message:iM({key:ZO.INVALID_JOIN})});if(this.checkDestroy(),t.isJoined({userId:this.userId,roomId:n,sdkAppId:this.sdkAppId,room:this}))throw new $b({code:Jb.INVALID_OPERATION,message:iM({key:ZO.REPEAT_JOIN,data:this.userId})});t.add({room:this,roomId:n}),this.role=21===r.role?"audience":"anchor",this._log.info("Join() => joining room: ".concat(n," useStringRoomId: ").concat(this.useStringRoomId," scene: ").concat(this.scene," role: ").concat(this.role)),Gk.emit(zk.JOIN_START,{room:this,roomId:n,params:r});let a=tw.getEnv();a||(a=Sw.QCLOUD,this.proxy_ws&&(this.proxy_ws.startsWith(Uw.OLD_CLOUD_LADDER)?a=Sw.OLD_CLOUD_LADDER:this.proxy_ws.startsWith(Uw.WEBRTC)&&(a=Sw.WEBRTC))),NL.setConfig({env:a,sdkAppId:String(this.sdkAppId),userId:this.userId,roomId:n}),$k.checkSystemRequirementsInternal().then((e=>{this.checkSystemResult=e,VH.call(this)}));try{!this.proxy_ws&&!this.proxy_wt&&!this.scheduleResult.domains&&!tw.getEnv()&&(yield this.schedule(r,o));let t=yield e.call(this,r,i,o);return this.roomId=n,this._joinedTimestamp=tw.performanceNow(),Gk.emit(zk.JOIN_SUCCESS,{room:this}),30===o&&!r.component&&NL.uploadEvent({log:"stat-conv-".concat(Number(wk),"-").concat(location.hostname),userId:this.userId}),t}catch(oO){throw t.delete({room:this,roomId:n}),Gk.emit(zk.JOIN_FAILED,{room:this,error:oO}),oO}}))}}))],zW.prototype,"join",1),Fb([fL("joined","left",{ignoreError:!0}),JP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Wb(this,null,(function*(){Gk.emit(zk.LEAVE_START,{room:this}),yield e.call(this,...r),Gk.emit(zk.LEAVE_SUCCESS,{room:this,roomId:this.roomId})}))}))],zW.prototype,"leave",1),Fb([rx((function(){return 0})),JP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return Wb(this,null,(function*(){if("live"===this.scene&&"anchor"!==this.role||(r=r.filter((e=>e.outMediaTrack&&"ready"===e.state)),!r.length))return;Gk.emit("61",{room:this});let t=e.apply(this,r);return r.forEach((e=>e.publish(this,t))),t}))}))],zW.prototype,"publish",1),Fb([rx((function(){return 0})),JP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>e.unpublish())),o}))],zW.prototype,"unpublish",1),Fb([rx((function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0].userId})),JP((e=>function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];let o=e.apply(this,r);return r.forEach((e=>!e.isSubscribed&&e.subscribe(o))),o}))],zW.prototype,"subscribe",1);var qW=zW;return PH.frameWorkType=37,PH.create=function(e){let t=PH._create.call(this,qW,e);return t._use(WF,null==e?void 0:e.assetsPath),null!=e&&e.assetsPath&&(cW.assetsPath=null==e?void 0:e.assetsPath),console.log("trtc wasm sdk:",ow,"created",cW),t},Object.assign(PH.prototype,{_setCurrentSpeaker(e){let t=uP();return null!=t&&t.setSinkId?t.setSinkId(e):Promise.reject("not support")},_enableVideoDecodeFallback(e,t){return Wb(this,null,(function*(){return this.startPlugin(WF.Name,{type:"webCodecs",renderer:"videoFrame",track:e,config:{codec:"avc1.420028"},fallback:"wasm"}),new Promise(((t,r)=>{Nx(sU(e,"decode-downgrade-state-changed"),bU((e=>"STARTED"===e.state)),DU(1),NV(1e4),CU(sU(e,EL.INIT)),DV(t,r))}))}))}}),PH}));
|