@agora-js/media 4.19.2 → 4.20.0
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/AgoraRTC_N-media.esm.mjs +2 -2
- package/AgoraRTC_N-media.js +2 -2
- package/media.d.ts +16 -224
- package/package.json +4 -4
- package/rtc-sdk-media_en.d.ts +8 -154
package/AgoraRTC_N-media.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AgoraWebSDK_N-v4.
|
|
2
|
+
* AgoraWebSDK_N-v4.20.0-0-g334e514b-dirty Copyright AgoraInc.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@agora-js/shared"),require("@agora-js/report"),require("axios"),require("webrtc-adapter"),require("pako")):"function"==typeof define&&define.amd?define(["exports","@agora-js/shared","@agora-js/report","axios","webrtc-adapter","pako"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AgoraRTCMedia={},e.shared$8,e.report,e.Axios,null,e.pako)}(this,(function(e,t,r,i,o,n){"use strict";var a;e.AUDIO_CONTEXT_EVENT=void 0,(a=e.AUDIO_CONTEXT_EVENT||(e.AUDIO_CONTEXT_EVENT={})).IOS_15_16_INTERRUPTION_START="ios15_16-interruption-start",a.IOS_15_16_INTERRUPTION_END="ios15_16-interruption-end",a.IOS_INTERRUPTION_START="ios-interruption-start",a.IOS_INTERRUPTION_END="ios-interruption-end",a.STATE_CHANGE="state-change";var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var d=function(e){try{return!!e()}catch(e){return!0}},u=!d((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),l=u,h=Function.prototype,p=h.call,g=l&&h.bind.bind(p,p),m=l?g:function(e){return function(){return p.apply(e,arguments)}},f=m({}.isPrototypeOf),E=function(e){return e&&e.Math==Math&&e},T=E("object"==typeof globalThis&&globalThis)||E("object"==typeof window&&window)||E("object"==typeof self&&self)||E("object"==typeof s&&s)||function(){return this}()||s||Function("return this")(),v=u,_=Function.prototype,y=_.apply,S=_.call,A="object"==typeof Reflect&&Reflect.apply||(v?S.bind(y):function(){return S.apply(y,arguments)}),b=m,I=b({}.toString),k=b("".slice),C=function(e){return k(I(e),8,-1)},O=C,R=m,N=function(e){if("Function"===O(e))return R(e)},w="object"==typeof document&&document.all,D={all:w,IS_HTMLDDA:void 0===w&&void 0!==w},P=D.all,M=D.IS_HTMLDDA?function(e){return"function"==typeof e||e===P}:function(e){return"function"==typeof e},L={},V=!d((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),x=u,U=Function.prototype.call,B=x?U.bind(U):function(){return U.apply(U,arguments)},F={},j={}.propertyIsEnumerable,H=Object.getOwnPropertyDescriptor,G=H&&!j.call({1:2},1);F.f=G?function(e){var t=H(this,e);return!!t&&t.enumerable}:j;var W,K,z=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},X=d,q=C,J=Object,Y=m("".split),Q=X((function(){return!J("z").propertyIsEnumerable(0)}))?function(e){return"String"==q(e)?Y(e,""):J(e)}:J,Z=function(e){return null==e},$=Z,ee=TypeError,te=function(e){if($(e))throw ee("Can't call method on "+e);return e},re=Q,ie=te,oe=function(e){return re(ie(e))},ne=M,ae=D.all,se=D.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ne(e)||e===ae}:function(e){return"object"==typeof e?null!==e:ne(e)},ce={},de=ce,ue=T,le=M,he=function(e){return le(e)?e:void 0},pe=function(e,t){return arguments.length<2?he(de[e])||he(ue[e]):de[e]&&de[e][t]||ue[e]&&ue[e][t]},ge="undefined"!=typeof navigator&&String(navigator.userAgent)||"",me=T,fe=ge,Ee=me.process,Te=me.Deno,ve=Ee&&Ee.versions||Te&&Te.version,_e=ve&&ve.v8;_e&&(K=(W=_e.split("."))[0]>0&&W[0]<4?1:+(W[0]+W[1])),!K&&fe&&(!(W=fe.match(/Edge\/(\d+)/))||W[1]>=74)&&(W=fe.match(/Chrome\/(\d+)/))&&(K=+W[1]);var ye=K,Se=ye,Ae=d,be=T.String,Ie=!!Object.getOwnPropertySymbols&&!Ae((function(){var e=Symbol();return!be(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Se&&Se<41})),ke=Ie&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ce=pe,Oe=M,Re=f,Ne=Object,we=ke?function(e){return"symbol"==typeof e}:function(e){var t=Ce("Symbol");return Oe(t)&&Re(t.prototype,Ne(e))},De=String,Pe=function(e){try{return De(e)}catch(e){return"Object"}},Me=M,Le=Pe,Ve=TypeError,xe=function(e){if(Me(e))return e;throw Ve(Le(e)+" is not a function")},Ue=xe,Be=Z,Fe=function(e,t){var r=e[t];return Be(r)?void 0:Ue(r)},je=B,He=M,Ge=se,We=TypeError,Ke={exports:{}},ze=T,Xe=Object.defineProperty,qe=function(e,t){try{Xe(ze,e,{value:t,configurable:!0,writable:!0})}catch(r){ze[e]=t}return t},Je="__core-js_shared__",Ye=T[Je]||qe(Je,{}),Qe=Ye;(Ke.exports=function(e,t){return Qe[e]||(Qe[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.31.1",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ze=Ke.exports,$e=te,et=Object,tt=function(e){return et($e(e))},rt=tt,it=m({}.hasOwnProperty),ot=Object.hasOwn||function(e,t){return it(rt(e),t)},nt=m,at=0,st=Math.random(),ct=nt(1..toString),dt=function(e){return"Symbol("+(void 0===e?"":e)+")_"+ct(++at+st,36)},ut=Ze,lt=ot,ht=dt,pt=Ie,gt=ke,mt=T.Symbol,ft=ut("wks"),Et=gt?mt.for||mt:mt&&mt.withoutSetter||ht,Tt=function(e){return lt(ft,e)||(ft[e]=pt&<(mt,e)?mt[e]:Et("Symbol."+e)),ft[e]},vt=B,_t=se,yt=we,St=Fe,At=function(e,t){var r,i;if("string"===t&&He(r=e.toString)&&!Ge(i=je(r,e)))return i;if(He(r=e.valueOf)&&!Ge(i=je(r,e)))return i;if("string"!==t&&He(r=e.toString)&&!Ge(i=je(r,e)))return i;throw We("Can't convert object to primitive value")},bt=TypeError,It=Tt("toPrimitive"),kt=function(e,t){if(!_t(e)||yt(e))return e;var r,i=St(e,It);if(i){if(void 0===t&&(t="default"),r=vt(i,e,t),!_t(r)||yt(r))return r;throw bt("Can't convert object to primitive value")}return void 0===t&&(t="number"),At(e,t)},Ct=we,Ot=function(e){var t=kt(e,"string");return Ct(t)?t:t+""},Rt=se,Nt=T.document,wt=Rt(Nt)&&Rt(Nt.createElement),Dt=function(e){return wt?Nt.createElement(e):{}},Pt=Dt,Mt=!V&&!d((function(){return 7!=Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a})),Lt=V,Vt=B,xt=F,Ut=z,Bt=oe,Ft=Ot,jt=ot,Ht=Mt,Gt=Object.getOwnPropertyDescriptor;L.f=Lt?Gt:function(e,t){if(e=Bt(e),t=Ft(t),Ht)try{return Gt(e,t)}catch(e){}if(jt(e,t))return Ut(!Vt(xt.f,e,t),e[t])};var Wt=d,Kt=M,zt=/#|\.prototype\./,Xt=function(e,t){var r=Jt[qt(e)];return r==Qt||r!=Yt&&(Kt(t)?Wt(t):!!t)},qt=Xt.normalize=function(e){return String(e).replace(zt,".").toLowerCase()},Jt=Xt.data={},Yt=Xt.NATIVE="N",Qt=Xt.POLYFILL="P",Zt=Xt,$t=xe,er=u,tr=N(N.bind),rr=function(e,t){return $t(e),void 0===t?e:er?tr(e,t):function(){return e.apply(t,arguments)}},ir={},or=V&&d((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),nr=se,ar=String,sr=TypeError,cr=function(e){if(nr(e))return e;throw sr(ar(e)+" is not an object")},dr=V,ur=Mt,lr=or,hr=cr,pr=Ot,gr=TypeError,mr=Object.defineProperty,fr=Object.getOwnPropertyDescriptor,Er="enumerable",Tr="configurable",vr="writable";ir.f=dr?lr?function(e,t,r){if(hr(e),t=pr(t),hr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&vr in r&&!r[vr]){var i=fr(e,t);i&&i[vr]&&(e[t]=r.value,r={configurable:Tr in r?r[Tr]:i[Tr],enumerable:Er in r?r[Er]:i[Er],writable:!1})}return mr(e,t,r)}:mr:function(e,t,r){if(hr(e),t=pr(t),hr(r),ur)try{return mr(e,t,r)}catch(e){}if("get"in r||"set"in r)throw gr("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var _r=ir,yr=z,Sr=V?function(e,t,r){return _r.f(e,t,yr(1,r))}:function(e,t,r){return e[t]=r,e},Ar=T,br=A,Ir=N,kr=M,Cr=L.f,Or=Zt,Rr=ce,Nr=rr,wr=Sr,Dr=ot,Pr=function(e){var t=function(r,i,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,o)}return br(e,this,arguments)};return t.prototype=e.prototype,t},Mr=function(e,t){var r,i,o,n,a,s,c,d,u,l=e.target,h=e.global,p=e.stat,g=e.proto,m=h?Ar:p?Ar[l]:(Ar[l]||{}).prototype,f=h?Rr:Rr[l]||wr(Rr,l,{})[l],E=f.prototype;for(n in t)i=!(r=Or(h?n:l+(p?".":"#")+n,e.forced))&&m&&Dr(m,n),s=f[n],i&&(c=e.dontCallGetSet?(u=Cr(m,n))&&u.value:m[n]),a=i&&c?c:t[n],i&&typeof s==typeof a||(d=e.bind&&i?Nr(a,Ar):e.wrap&&i?Pr(a):g&&kr(a)?Ir(a):a,(e.sham||a&&a.sham||s&&s.sham)&&wr(d,"sham",!0),wr(f,n,d),g&&(Dr(Rr,o=l+"Prototype")||wr(Rr,o,{}),wr(Rr[o],n,a),e.real&&E&&(r||!E[n])&&wr(E,n,a)))},Lr=Math.ceil,Vr=Math.floor,xr=Math.trunc||function(e){var t=+e;return(t>0?Vr:Lr)(t)},Ur=function(e){var t=+e;return t!=t||0===t?0:xr(t)},Br=Ur,Fr=Math.max,jr=Math.min,Hr=function(e,t){var r=Br(e);return r<0?Fr(r+t,0):jr(r,t)},Gr=Ur,Wr=Math.min,Kr=function(e){return e>0?Wr(Gr(e),9007199254740991):0},zr=function(e){return Kr(e.length)},Xr=oe,qr=Hr,Jr=zr,Yr=function(e){return function(t,r,i){var o,n=Xr(t),a=Jr(n),s=qr(i,a);if(e&&r!=r){for(;a>s;)if((o=n[s++])!=o)return!0}else for(;a>s;s++)if((e||s in n)&&n[s]===r)return e||s||0;return!e&&-1}},Qr={includes:Yr(!0),indexOf:Yr(!1)},Zr=Qr.includes;Mr({target:"Array",proto:!0,forced:d((function(){return!Array(1).includes()}))},{includes:function(e){return Zr(this,e,arguments.length>1?arguments[1]:void 0)}});var $r=ce,ei=function(e){return $r[e+"Prototype"]},ti=ei("Array").includes,ri=se,ii=C,oi=Tt("match"),ni=function(e){var t;return ri(e)&&(void 0!==(t=e[oi])?!!t:"RegExp"==ii(e))},ai=TypeError,si={};si[Tt("toStringTag")]="z";var ci="[object z]"===String(si),di=ci,ui=M,li=C,hi=Tt("toStringTag"),pi=Object,gi="Arguments"==li(function(){return arguments}()),mi=di?li: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(e){}}(t=pi(e),hi))?r:gi?li(t):"Object"==(i=li(t))&&ui(t.callee)?"Arguments":i},fi=mi,Ei=String,Ti=function(e){if("Symbol"===fi(e))throw TypeError("Cannot convert a Symbol value to a string");return Ei(e)},vi=Tt("match"),_i=Mr,yi=function(e){if(ni(e))throw ai("The method doesn't accept regular expressions");return e},Si=te,Ai=Ti,bi=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[vi]=!1,"/./"[e](t)}catch(e){}}return!1},Ii=m("".indexOf);_i({target:"String",proto:!0,forced:!bi("includes")},{includes:function(e){return!!~Ii(Ai(Si(this)),Ai(yi(e)),arguments.length>1?arguments[1]:void 0)}});var ki=ei("String").includes,Ci=f,Oi=ti,Ri=ki,Ni=Array.prototype,wi=String.prototype,Di=c((function(e){var t=e.includes;return e===Ni||Ci(Ni,e)&&t===Ni.includes?Oi:"string"==typeof e||e===wi||Ci(wi,e)&&t===wi.includes?Ri:t}));function Pi(e,t,r){return{sampleRate:e,stereo:t,bitrate:r}}function Mi(e,t,r,i,o){return{width:e,height:t,frameRate:r,bitrateMin:i,bitrateMax:o}}function Li(e,t,r,i,o){return{width:{max:e},height:{max:t},frameRate:r,bitrateMin:i,bitrateMax:o}}function Vi(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const xi={"90p":Mi(160,90),"90p_1":Mi(160,90),"120p":Mi(160,120,15,30,65),"120p_1":Mi(160,120,15,30,65),"120p_3":Mi(120,120,15,30,50),"120p_4":Mi(212,120),"180p":Mi(320,180,15,30,140),"180p_1":Mi(320,180,15,30,140),"180p_3":Mi(180,180,15,30,100),"180p_4":Mi(240,180,15,30,120),"240p":Mi(320,240,15,40,200),"240p_1":Mi(320,240,15,40,200),"240p_3":Mi(240,240,15,40,140),"240p_4":Mi(424,240,15,40,220),"360p":Mi(640,360,15,80,400),"360p_1":Mi(640,360,15,80,400),"360p_3":Mi(360,360,15,80,260),"360p_4":Mi(640,360,30,80,600),"360p_6":Mi(360,360,30,80,400),"360p_7":Mi(480,360,15,80,320),"360p_8":Mi(480,360,30,80,490),"360p_9":Mi(640,360,15,80,800),"360p_10":Mi(640,360,24,80,800),"360p_11":Mi(640,360,24,80,1e3),"480p":Mi(640,480,15,100,500),"480p_1":Mi(640,480,15,100,500),"480p_2":Mi(640,480,30,100,1e3),"480p_3":Mi(480,480,15,100,400),"480p_4":Mi(640,480,30,100,750),"480p_6":Mi(480,480,30,100,600),"480p_8":Mi(848,480,15,100,610),"480p_9":Mi(848,480,30,100,930),"480p_10":Mi(640,480,10,100,400),"720p":Mi(1280,720,15,120,1130),"720p_auto":Mi(1280,720,30,900,3e3),"720p_1":Mi(1280,720,15,120,1130),"720p_2":Mi(1280,720,30,120,2e3),"720p_3":Mi(1280,720,30,120,1710),"720p_5":Mi(960,720,15,120,910),"720p_6":Mi(960,720,30,120,1380),"1080p":Mi(1920,1080,15,120,2080),"1080p_1":Mi(1920,1080,15,120,2080),"1080p_2":Mi(1920,1080,30,120,3e3),"1080p_3":Mi(1920,1080,30,120,3150),"1080p_5":Mi(1920,1080,60,120,4780),"1440p":Mi(2560,1440,30,120,4850),"1440p_1":Mi(2560,1440,30,120,4850),"1440p_2":Mi(2560,1440,60,120,7350),"4k":Mi(3840,2160,30,120,8910),"4k_1":Mi(3840,2160,30,120,8910),"4k_3":Mi(3840,2160,60,120,13500)},Ui=[{scaleResolutionDownBy:2,width:1280,height:720,frameRate:30,bitrateMin:300,bitrateMax:900},{scaleResolutionDownBy:1.333333,width:1280,height:720,frameRate:30,bitrateMin:600,bitrateMax:2e3},{scaleResolutionDownBy:1,width:1280,height:720,frameRate:30,bitrateMin:900,bitrateMax:3e3}],Bi={"480p":Li(640,480,5),"480p_1":Li(640,480,5),"480p_2":Li(640,480,30),"480p_3":Li(640,480,15),"720p":Li(1280,720,5),"720p_auto":Mi(1280,720,30,900,3e3),"720p_1":Li(1280,720,5),"720p_2":Li(1280,720,30),"720p_3":Li(1280,720,15),"1080p":Li(1920,1080,5),"1080p_1":Li(1920,1080,5),"1080p_2":Li(1920,1080,30),"1080p_3":Li(1920,1080,15)},Fi={"1SL1TL":Vi(1,1),"3SL3TL":Vi(3,3),"2SL3TL":Vi(2,3)};function ji(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},xi[e]):e}function Hi(e){return"string"==typeof e?Object.assign({},Bi[e]):e}function Gi(e){return"string"==typeof e?Object.assign({},Fi[e]):e}const Wi={speech_low_quality:Pi(16e3,!1),speech_standard:Pi(32e3,!1,18),music_standard:Pi(48e3,!1),standard_stereo:Pi(48e3,!0,56),high_quality:Pi(48e3,!1,128),high_quality_stereo:Pi(48e3,!0,192)};function Ki(e){return"string"==typeof e?Object.assign({},Wi[e]):e}const zi=[];function Xi(e){Di(zi).call(zi,e)||zi.push(e)}function qi(e){const t=zi.indexOf(e);-1!==t&&zi.splice(t,1)}function Ji(e){return t.checkValidConstrainLong(e.width,"config.width"),t.checkValidConstrainLong(e.height,"config.height"),void 0!==e.frameRate&&t.checkValidConstrainLong(e.frameRate,"config.frameRate"),void 0!==e.bitrateMax&&t.checkValidNumber(e.bitrateMax,"config.bitrateMax"),void 0!==e.bitrateMin&&t.checkValidNumber(e.bitrateMin,"config.bitrateMin"),!0}function Yi(e){return void 0!==e.sampleRate&&t.checkValidNumber(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&t.checkValidNumber(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&t.checkValidBoolean(e.stereo,"config.stereo"),void 0!==e.bitrate&&t.checkValidNumber(e.bitrate,"config.bitrate",0,1e4,!1),!0}function Qi(e){return t.checkValidEnum(e,"mediaSource",["screen","window","application"]),!0}var Zi,$i,eo,to,ro,io,oo,no;e.TrackInternalEvent=void 0,(Zi=e.TrackInternalEvent||(e.TrackInternalEvent={})).NEED_RENEGOTIATE="@need_renegotiate",Zi.NEED_REPLACE_TRACK="@need_replace_track",Zi.NEED_CLOSE="@need_close",Zi.NEED_ENABLE_TRACK="@need_enable_track",Zi.NEED_DISABLE_TRACK="@need_disable_track",Zi.NEED_SESSION_ID="@need_sid",Zi.SET_OPTIMIZATION_MODE="@set_optimization_mode",Zi.GET_STATS="@get_stats",Zi.GET_RTC_STATS="@get_rtc_stats",Zi.GET_LOW_VIDEO_TRACK="@get_low_video_track",Zi.NEED_RESET_REMOTE_SDP="@need_reset_remote_sdp",Zi.NEED_UPDATE_VIDEO_ENCODER="@need_update_video_encoder",Zi.NEED_MUTE_TRACK="@need_mute_track",Zi.NEED_UNMUTE_TRACK="@need_unmute_track",e.TrackHint=void 0,($i=e.TrackHint||(e.TrackHint={})).SCREEN_TRACK="screen_track",$i.CUSTOM_TRACK="custome_track",$i.LOW_STREAM="low_stream",e.StreamType=void 0,(eo=e.StreamType||(e.StreamType={}))[eo.HIGH_STREAM=0]="HIGH_STREAM",eo[eo.LOW_STREAM=1]="LOW_STREAM",e.RemoteStreamType=void 0,(to=e.RemoteStreamType||(e.RemoteStreamType={}))[to.HIGH_STREAM=0]="HIGH_STREAM",to[to.LOW_STREAM=1]="LOW_STREAM",e.RemoteStreamFallbackType=void 0,(ro=e.RemoteStreamFallbackType||(e.RemoteStreamFallbackType={}))[ro.DISABLE=0]="DISABLE",ro[ro.LOW_STREAM=1]="LOW_STREAM",ro[ro.AUDIO_ONLY=2]="AUDIO_ONLY",e.TrackEvents=void 0,(e.TrackEvents||(e.TrackEvents={})).TRANSCEIVER_UPDATED="transceiver-updated",e.LocalTrackEvents=void 0,(io=e.LocalTrackEvents||(e.LocalTrackEvents={})).SOURCE_STATE_CHANGE="source-state-change",io.TRACK_ENDED="track-ended",io.BEAUTY_EFFECT_OVERLOAD="beauty-effect-overload",io.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",io.CLOSED="closed",e.RemoteTrackEvents=void 0,(oo=e.RemoteTrackEvents||(e.RemoteTrackEvents={})).FIRST_FRAME_DECODED="first-frame-decoded",oo.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.AudioSourceEvents=void 0,(no=e.AudioSourceEvents||(e.AudioSourceEvents={})).AUDIO_SOURCE_STATE_CHANGE="audio_source_state_change",no.RECEIVE_TRACK_BUFFER="receive_track_buffer",no.ON_AUDIO_BUFFER="on_audio_buffer",no.UPDATE_SOURCE="update_source",e.AUDIO_TRACK_EVENT=void 0,(e.AUDIO_TRACK_EVENT||(e.AUDIO_TRACK_EVENT={})).UPDATE_TRACK_SOURCE="update-track-source";const ao={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},so={sendBytes:0,sendBitrate:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,sendResolutionHeight:0,sendResolutionWidth:0,captureResolutionHeight:0,captureResolutionWidth:0,targetSendBitrate:0,totalDuration:0,totalFreezeTime:0,currentPacketLossRate:0},co={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveLevel:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1},uo={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,receiveResolutionHeight:0,receiveResolutionWidth:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1};var lo,ho,po,go,mo;e.PROCESSOR_DESTINATION_EVENTS=void 0,(lo=e.PROCESSOR_DESTINATION_EVENTS||(e.PROCESSOR_DESTINATION_EVENTS={})).ON_TRACK="on_track",lo.ON_NODE="on_node",e.PROCESSOR_CONTEXT_EVENTS=void 0,(ho=e.PROCESSOR_CONTEXT_EVENTS||(e.PROCESSOR_CONTEXT_EVENTS={})).REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",ho.REQUEST_CONSTRAINTS="request_constraints",e.DeviceManagerState=void 0,(po=e.DeviceManagerState||(e.DeviceManagerState={})).IDLE="IDLE",po.INITING="INITING",po.INITEND="INITEND",e.DeviceManagerEvent=void 0,(go=e.DeviceManagerEvent||(e.DeviceManagerEvent={})).STATE_CHANGE="state_change",go.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",go.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",go.CAMERA_DEVICE_CHANGED="cameraDeviceChanged",e.MediaElementStatus=void 0,(mo=e.MediaElementStatus||(e.MediaElementStatus={})).NONE="none",mo.INIT="init",mo.CANPLAY="canplay",mo.PLAYING="playing",mo.PAUSED="paused",mo.SUSPEND="suspend",mo.STALLED="stalled",mo.WAITING="waiting",mo.ERROR="error",mo.DESTROYED="destroyed",mo.ABORT="abort",mo.ENDED="ended",mo.EMPTIED="emptied",mo.LOADEDDATA="loadeddata";var fo;e.DataChannelEvents=void 0,(fo=e.DataChannelEvents||(e.DataChannelEvents={})).OPEN="open",fo.MESSAGE="message",fo.CLOSE="close",fo.CLOSING="closing",fo.ERROR="error";var Eo={exports:{}},To=Mr,vo=V,_o=ir.f;To({target:"Object",stat:!0,forced:Object.defineProperty!==_o,sham:!vo},{defineProperty:_o});var yo=ce.Object,So=Eo.exports=function(e,t,r){return yo.defineProperty(e,t,r)};yo.defineProperty.sham&&(So.sham=!0);var Ao=c(Eo.exports),bo=C,Io=Array.isArray||function(e){return"Array"==bo(e)},ko=TypeError,Co=Ot,Oo=ir,Ro=z,No=function(e,t,r){var i=Co(t);i in e?Oo.f(e,i,Ro(0,r)):e[i]=r},wo=M,Do=Ye,Po=m(Function.toString);wo(Do.inspectSource)||(Do.inspectSource=function(e){return Po(e)});var Mo=Do.inspectSource,Lo=m,Vo=d,xo=M,Uo=mi,Bo=Mo,Fo=function(){},jo=[],Ho=pe("Reflect","construct"),Go=/^\s*(?:class|function)\b/,Wo=Lo(Go.exec),Ko=!Go.exec(Fo),zo=function(e){if(!xo(e))return!1;try{return Ho(Fo,jo,e),!0}catch(e){return!1}},Xo=function(e){if(!xo(e))return!1;switch(Uo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return Ko||!!Wo(Go,Bo(e))}catch(e){return!0}};Xo.sham=!0;var qo=!Ho||Vo((function(){var e;return zo(zo.call)||!zo(Object)||!zo((function(){e=!0}))||e}))?Xo:zo,Jo=Io,Yo=qo,Qo=se,Zo=Tt("species"),$o=Array,en=function(e){var t;return Jo(e)&&(t=e.constructor,(Yo(t)&&(t===$o||Jo(t.prototype))||Qo(t)&&null===(t=t[Zo]))&&(t=void 0)),void 0===t?$o:t},tn=function(e,t){return new(en(e))(0===t?0:t)},rn=d,on=ye,nn=Tt("species"),an=Mr,sn=d,cn=Io,dn=se,un=tt,ln=zr,hn=function(e){if(e>9007199254740991)throw ko("Maximum allowed index exceeded");return e},pn=No,gn=tn,mn=function(e){return on>=51||!rn((function(){var t=[];return(t.constructor={})[nn]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},fn=ye,En=Tt("isConcatSpreadable"),Tn=fn>=51||!sn((function(){var e=[];return e[En]=!1,e.concat()[0]!==e})),vn=function(e){if(!dn(e))return!1;var t=e[En];return void 0!==t?!!t:cn(e)};an({target:"Array",proto:!0,arity:1,forced:!Tn||!mn("concat")},{concat:function(e){var t,r,i,o,n,a=un(this),s=gn(a,0),c=0;for(t=-1,i=arguments.length;t<i;t++)if(vn(n=-1===t?a:arguments[t]))for(o=ln(n),hn(c+o),r=0;r<o;r++,c++)r in n&&pn(s,c,n[r]);else hn(c+1),pn(s,c++,n);return s.length=c,s}});var _n={},yn={},Sn=ot,An=oe,bn=Qr.indexOf,In=yn,kn=m([].push),Cn=function(e,t){var r,i=An(e),o=0,n=[];for(r in i)!Sn(In,r)&&Sn(i,r)&&kn(n,r);for(;t.length>o;)Sn(i,r=t[o++])&&(~bn(n,r)||kn(n,r));return n},On=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Rn=Cn,Nn=On,wn=Object.keys||function(e){return Rn(e,Nn)},Dn=V,Pn=or,Mn=ir,Ln=cr,Vn=oe,xn=wn;_n.f=Dn&&!Pn?Object.defineProperties:function(e,t){Ln(e);for(var r,i=Vn(t),o=xn(t),n=o.length,a=0;n>a;)Mn.f(e,r=o[a++],i[r]);return e};var Un,Bn=pe("document","documentElement"),Fn=dt,jn=Ze("keys"),Hn=function(e){return jn[e]||(jn[e]=Fn(e))},Gn=cr,Wn=_n,Kn=On,zn=yn,Xn=Bn,qn=Dt,Jn="prototype",Yn="script",Qn=Hn("IE_PROTO"),Zn=function(){},$n=function(e){return"<"+Yn+">"+e+"</"+Yn+">"},ea=function(e){e.write($n("")),e.close();var t=e.parentWindow.Object;return e=null,t},ta=function(){try{Un=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;ta="undefined"!=typeof document?document.domain&&Un?ea(Un):(t=qn("iframe"),r="java"+Yn+":",t.style.display="none",Xn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write($n("document.F=Object")),e.close(),e.F):ea(Un);for(var i=Kn.length;i--;)delete ta[Jn][Kn[i]];return ta()};zn[Qn]=!0;var ra=Object.create||function(e,t){var r;return null!==e?(Zn[Jn]=Gn(e),r=new Zn,Zn[Jn]=null,r[Qn]=e):r=ta(),void 0===t?r:Wn.f(r,t)},ia={},oa=Cn,na=On.concat("length","prototype");ia.f=Object.getOwnPropertyNames||function(e){return oa(e,na)};var aa={},sa=Hr,ca=zr,da=No,ua=Array,la=Math.max,ha=C,pa=oe,ga=ia.f,ma=function(e,t,r){for(var i=ca(e),o=sa(t,i),n=sa(void 0===r?i:r,i),a=ua(la(n-o,0)),s=0;o<n;o++,s++)da(a,s,e[o]);return a.length=s,a},fa="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];aa.f=function(e){return fa&&"Window"==ha(e)?function(e){try{return ga(e)}catch(e){return ma(fa)}}(e):ga(pa(e))};var Ea={};Ea.f=Object.getOwnPropertySymbols;var Ta=Sr,va=function(e,t,r,i){return i&&i.enumerable?e[t]=r:Ta(e,t,r),e},_a=ir,ya=function(e,t,r){return _a.f(e,t,r)},Sa={},Aa=Tt;Sa.f=Aa;var ba,Ia,ka,Ca=ce,Oa=ot,Ra=Sa,Na=ir.f,wa=function(e){var t=Ca.Symbol||(Ca.Symbol={});Oa(t,e)||Na(t,e,{value:Ra.f(e)})},Da=B,Pa=pe,Ma=Tt,La=va,Va=function(){var e=Pa("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=Ma("toPrimitive");t&&!t[i]&&La(t,i,(function(e){return Da(r,this)}),{arity:1})},xa=mi,Ua=ci?{}.toString:function(){return"[object "+xa(this)+"]"},Ba=ci,Fa=ir.f,ja=Sr,Ha=ot,Ga=Ua,Wa=Tt("toStringTag"),Ka=function(e,t,r,i){if(e){var o=r?e:e.prototype;Ha(o,Wa)||Fa(o,Wa,{configurable:!0,value:t}),i&&!Ba&&ja(o,"toString",Ga)}},za=M,Xa=T.WeakMap,qa=za(Xa)&&/native code/.test(String(Xa)),Ja=T,Ya=se,Qa=Sr,Za=ot,$a=Ye,es=Hn,ts=yn,rs="Object already initialized",is=Ja.TypeError,os=Ja.WeakMap;if(qa||$a.state){var ns=$a.state||($a.state=new os);ns.get=ns.get,ns.has=ns.has,ns.set=ns.set,ba=function(e,t){if(ns.has(e))throw is(rs);return t.facade=e,ns.set(e,t),t},Ia=function(e){return ns.get(e)||{}},ka=function(e){return ns.has(e)}}else{var as=es("state");ts[as]=!0,ba=function(e,t){if(Za(e,as))throw is(rs);return t.facade=e,Qa(e,as,t),t},Ia=function(e){return Za(e,as)?e[as]:{}},ka=function(e){return Za(e,as)}}var ss={set:ba,get:Ia,has:ka,enforce:function(e){return ka(e)?Ia(e):ba(e,{})},getterFor:function(e){return function(t){var r;if(!Ya(t)||(r=Ia(t)).type!==e)throw is("Incompatible receiver, "+e+" required");return r}}},cs=rr,ds=Q,us=tt,ls=zr,hs=tn,ps=m([].push),gs=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,d,u,l){for(var h,p,g=us(c),m=ds(g),f=cs(d,u),E=ls(m),T=0,v=l||hs,_=t?v(c,E):r||a?v(c,0):void 0;E>T;T++)if((s||T in m)&&(p=f(h=m[T],T,g),e))if(t)_[T]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return T;case 2:ps(_,h)}else switch(e){case 4:return!1;case 7:ps(_,h)}return n?-1:i||o?o:_}},ms={forEach:gs(0),map:gs(1),filter:gs(2),some:gs(3),every:gs(4),find:gs(5),findIndex:gs(6),filterReject:gs(7)},fs=Mr,Es=T,Ts=B,vs=m,_s=V,ys=Ie,Ss=d,As=ot,bs=f,Is=cr,ks=oe,Cs=Ot,Os=Ti,Rs=z,Ns=ra,ws=wn,Ds=ia,Ps=aa,Ms=Ea,Ls=L,Vs=ir,xs=_n,Us=F,Bs=va,Fs=ya,js=Ze,Hs=yn,Gs=dt,Ws=Tt,Ks=Sa,zs=wa,Xs=Va,qs=Ka,Js=ss,Ys=ms.forEach,Qs=Hn("hidden"),Zs="Symbol",$s="prototype",ec=Js.set,tc=Js.getterFor(Zs),rc=Object[$s],ic=Es.Symbol,oc=ic&&ic[$s],nc=Es.TypeError,ac=Es.QObject,sc=Ls.f,cc=Vs.f,dc=Ps.f,uc=Us.f,lc=vs([].push),hc=js("symbols"),pc=js("op-symbols"),gc=js("wks"),mc=!ac||!ac[$s]||!ac[$s].findChild,fc=_s&&Ss((function(){return 7!=Ns(cc({},"a",{get:function(){return cc(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=sc(rc,t);i&&delete rc[t],cc(e,t,r),i&&e!==rc&&cc(rc,t,i)}:cc,Ec=function(e,t){var r=hc[e]=Ns(oc);return ec(r,{type:Zs,tag:e,description:t}),_s||(r.description=t),r},Tc=function(e,t,r){e===rc&&Tc(pc,t,r),Is(e);var i=Cs(t);return Is(r),As(hc,i)?(r.enumerable?(As(e,Qs)&&e[Qs][i]&&(e[Qs][i]=!1),r=Ns(r,{enumerable:Rs(0,!1)})):(As(e,Qs)||cc(e,Qs,Rs(1,{})),e[Qs][i]=!0),fc(e,i,r)):cc(e,i,r)},vc=function(e,t){Is(e);var r=ks(t),i=ws(r).concat(Ac(r));return Ys(i,(function(t){_s&&!Ts(_c,r,t)||Tc(e,t,r[t])})),e},_c=function(e){var t=Cs(e),r=Ts(uc,this,t);return!(this===rc&&As(hc,t)&&!As(pc,t))&&(!(r||!As(this,t)||!As(hc,t)||As(this,Qs)&&this[Qs][t])||r)},yc=function(e,t){var r=ks(e),i=Cs(t);if(r!==rc||!As(hc,i)||As(pc,i)){var o=sc(r,i);return!o||!As(hc,i)||As(r,Qs)&&r[Qs][i]||(o.enumerable=!0),o}},Sc=function(e){var t=dc(ks(e)),r=[];return Ys(t,(function(e){As(hc,e)||As(Hs,e)||lc(r,e)})),r},Ac=function(e){var t=e===rc,r=dc(t?pc:ks(e)),i=[];return Ys(r,(function(e){!As(hc,e)||t&&!As(rc,e)||lc(i,hc[e])})),i};ys||(ic=function(){if(bs(oc,this))throw nc("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Os(arguments[0]):void 0,t=Gs(e),r=function(e){this===rc&&Ts(r,pc,e),As(this,Qs)&&As(this[Qs],t)&&(this[Qs][t]=!1),fc(this,t,Rs(1,e))};return _s&&mc&&fc(rc,t,{configurable:!0,set:r}),Ec(t,e)},Bs(oc=ic[$s],"toString",(function(){return tc(this).tag})),Bs(ic,"withoutSetter",(function(e){return Ec(Gs(e),e)})),Us.f=_c,Vs.f=Tc,xs.f=vc,Ls.f=yc,Ds.f=Ps.f=Sc,Ms.f=Ac,Ks.f=function(e){return Ec(Ws(e),e)},_s&&Fs(oc,"description",{configurable:!0,get:function(){return tc(this).description}})),fs({global:!0,constructor:!0,wrap:!0,forced:!ys,sham:!ys},{Symbol:ic}),Ys(ws(gc),(function(e){zs(e)})),fs({target:Zs,stat:!0,forced:!ys},{useSetter:function(){mc=!0},useSimple:function(){mc=!1}}),fs({target:"Object",stat:!0,forced:!ys,sham:!_s},{create:function(e,t){return void 0===t?Ns(e):vc(Ns(e),t)},defineProperty:Tc,defineProperties:vc,getOwnPropertyDescriptor:yc}),fs({target:"Object",stat:!0,forced:!ys},{getOwnPropertyNames:Sc}),Xs(),qs(ic,Zs),Hs[Qs]=!0;var bc=Ie&&!!Symbol.for&&!!Symbol.keyFor,Ic=Mr,kc=pe,Cc=ot,Oc=Ti,Rc=Ze,Nc=bc,wc=Rc("string-to-symbol-registry"),Dc=Rc("symbol-to-string-registry");Ic({target:"Symbol",stat:!0,forced:!Nc},{for:function(e){var t=Oc(e);if(Cc(wc,t))return wc[t];var r=kc("Symbol")(t);return wc[t]=r,Dc[r]=t,r}});var Pc=Mr,Mc=ot,Lc=we,Vc=Pe,xc=bc,Uc=Ze("symbol-to-string-registry");Pc({target:"Symbol",stat:!0,forced:!xc},{keyFor:function(e){if(!Lc(e))throw TypeError(Vc(e)+" is not a symbol");if(Mc(Uc,e))return Uc[e]}});var Bc=m([].slice),Fc=Io,jc=M,Hc=C,Gc=Ti,Wc=m([].push),Kc=Mr,zc=pe,Xc=A,qc=B,Jc=m,Yc=d,Qc=M,Zc=we,$c=Bc,ed=function(e){if(jc(e))return e;if(Fc(e)){for(var t=e.length,r=[],i=0;i<t;i++){var o=e[i];"string"==typeof o?Wc(r,o):"number"!=typeof o&&"Number"!=Hc(o)&&"String"!=Hc(o)||Wc(r,Gc(o))}var n=r.length,a=!0;return function(e,t){if(a)return a=!1,t;if(Fc(this))return t;for(var i=0;i<n;i++)if(r[i]===e)return t}}},td=Ie,rd=String,id=zc("JSON","stringify"),od=Jc(/./.exec),nd=Jc("".charAt),ad=Jc("".charCodeAt),sd=Jc("".replace),cd=Jc(1..toString),dd=/[\uD800-\uDFFF]/g,ud=/^[\uD800-\uDBFF]$/,ld=/^[\uDC00-\uDFFF]$/,hd=!td||Yc((function(){var e=zc("Symbol")();return"[null]"!=id([e])||"{}"!=id({a:e})||"{}"!=id(Object(e))})),pd=Yc((function(){return'"\\udf06\\ud834"'!==id("\udf06\ud834")||'"\\udead"'!==id("\udead")})),gd=function(e,t){var r=$c(arguments),i=ed(t);if(Qc(i)||void 0!==e&&!Zc(e))return r[1]=function(e,t){if(Qc(i)&&(t=qc(i,this,rd(e),t)),!Zc(t))return t},Xc(id,null,r)},md=function(e,t,r){var i=nd(r,t-1),o=nd(r,t+1);return od(ud,e)&&!od(ld,o)||od(ld,e)&&!od(ud,i)?"\\u"+cd(ad(e,0),16):e};id&&Kc({target:"JSON",stat:!0,arity:3,forced:hd||pd},{stringify:function(e,t,r){var i=$c(arguments),o=Xc(hd?gd:id,null,i);return pd&&"string"==typeof o?sd(o,dd,md):o}});var fd=Ea,Ed=tt;Mr({target:"Object",stat:!0,forced:!Ie||d((function(){fd.f(1)}))},{getOwnPropertySymbols:function(e){var t=fd.f;return t?t(Ed(e)):[]}}),wa("asyncIterator"),wa("hasInstance"),wa("isConcatSpreadable"),wa("iterator"),wa("match"),wa("matchAll"),wa("replace"),wa("search"),wa("species"),wa("split");var Td=Va;wa("toPrimitive"),Td();var vd=pe,_d=Ka;wa("toStringTag"),_d(vd("Symbol"),"Symbol"),wa("unscopables"),Ka(T.JSON,"JSON",!0);var yd,Sd,Ad,bd=ce.Symbol,Id={},kd=V,Cd=ot,Od=Function.prototype,Rd=kd&&Object.getOwnPropertyDescriptor,Nd=Cd(Od,"name"),wd={EXISTS:Nd,PROPER:Nd&&"something"===function(){}.name,CONFIGURABLE:Nd&&(!kd||kd&&Rd(Od,"name").configurable)},Dd=!d((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Pd=ot,Md=M,Ld=tt,Vd=Dd,xd=Hn("IE_PROTO"),Ud=Object,Bd=Ud.prototype,Fd=Vd?Ud.getPrototypeOf:function(e){var t=Ld(e);if(Pd(t,xd))return t[xd];var r=t.constructor;return Md(r)&&t instanceof r?r.prototype:t instanceof Ud?Bd:null},jd=d,Hd=M,Gd=se,Wd=ra,Kd=Fd,zd=va,Xd=Tt("iterator"),qd=!1;[].keys&&("next"in(Ad=[].keys())?(Sd=Kd(Kd(Ad)))!==Object.prototype&&(yd=Sd):qd=!0);var Jd=!Gd(yd)||jd((function(){var e={};return yd[Xd].call(e)!==e}));Hd((yd=Jd?{}:Wd(yd))[Xd])||zd(yd,Xd,(function(){return this}));var Yd={IteratorPrototype:yd,BUGGY_SAFARI_ITERATORS:qd},Qd=Yd.IteratorPrototype,Zd=ra,$d=z,eu=Ka,tu=Id,ru=function(){return this},iu=m,ou=xe,nu=M,au=String,su=TypeError,cu=function(e,t,r){try{return iu(ou(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}},du=cr,uu=function(e){if("object"==typeof e||nu(e))return e;throw su("Can't set "+au(e)+" as a prototype")},lu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=cu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(e){}return function(r,i){return du(r),uu(i),t?e(r,i):r.__proto__=i,r}}():void 0),hu=Mr,pu=B,gu=wd,mu=function(e,t,r,i){var o=t+" Iterator";return e.prototype=Zd(Qd,{next:$d(+!i,r)}),eu(e,o,!1,!0),tu[o]=ru,e},fu=Fd,Eu=Ka,Tu=va,vu=Id,_u=Yd,yu=gu.PROPER,Su=_u.BUGGY_SAFARI_ITERATORS,Au=Tt("iterator"),bu="keys",Iu="values",ku="entries",Cu=function(){return this},Ou=function(e,t,r,i,o,n,a){mu(r,t,i);var s,c,d,u=function(e){if(e===o&&m)return m;if(!Su&&e in p)return p[e];switch(e){case bu:case Iu:case ku:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,g=p[Au]||p["@@iterator"]||o&&p[o],m=!Su&&g||u(o),f="Array"==t&&p.entries||g;if(f&&(s=fu(f.call(new e)))!==Object.prototype&&s.next&&(Eu(s,l,!0,!0),vu[l]=Cu),yu&&o==Iu&&g&&g.name!==Iu&&(h=!0,m=function(){return pu(g,this)}),o)if(c={values:u(Iu),keys:n?m:u(bu),entries:u(ku)},a)for(d in c)(Su||h||!(d in p))&&Tu(p,d,c[d]);else hu({target:t,proto:!0,forced:Su||h},c);return a&&p[Au]!==m&&Tu(p,Au,m,{name:o}),vu[t]=m,c},Ru=function(e,t){return{value:e,done:t}},Nu=oe,wu=Id,Du=ss;ir.f;var Pu=Ou,Mu=Ru,Lu="Array Iterator",Vu=Du.set,xu=Du.getterFor(Lu);Pu(Array,"Array",(function(e,t){Vu(this,{type:Lu,target:Nu(e),index:0,kind:t})}),(function(){var e=xu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,Mu(void 0,!0)):Mu("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),wu.Arguments=wu.Array;var Uu={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},Bu=T,Fu=mi,ju=Sr,Hu=Id,Gu=Tt("toStringTag");for(var Wu in Uu){var Ku=Bu[Wu],zu=Ku&&Ku.prototype;zu&&Fu(zu)!==Gu&&ju(zu,Gu,Wu),Hu[Wu]=Hu.Array}var Xu=bd,qu=Tt,Ju=ir.f,Yu=qu("metadata"),Qu=Function.prototype;void 0===Qu[Yu]&&Ju(Qu,Yu,{value:null}),wa("dispose"),wa("metadata");var Zu=Xu;wa("asyncDispose");var $u=m,el=pe("Symbol"),tl=el.keyFor,rl=$u(el.prototype.valueOf),il=el.isRegisteredSymbol||function(e){try{return void 0!==tl(rl(e))}catch(e){return!1}};Mr({target:"Symbol",stat:!0},{isRegisteredSymbol:il});for(var ol=Ze,nl=pe,al=m,sl=we,cl=Tt,dl=nl("Symbol"),ul=dl.isWellKnownSymbol,ll=nl("Object","getOwnPropertyNames"),hl=al(dl.prototype.valueOf),pl=ol("wks"),gl=0,ml=ll(dl),fl=ml.length;gl<fl;gl++)try{var El=ml[gl];sl(dl[El])&&cl(El)}catch(e){}var Tl=function(e){if(ul&&ul(e))return!0;try{for(var t=hl(e),r=0,i=ll(pl),o=i.length;r<o;r++)if(pl[i[r]]==t)return!0}catch(e){}return!1};Mr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Tl}),wa("matcher"),wa("observable"),Mr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:il}),Mr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Tl}),wa("metadataKey"),wa("patternMatch"),wa("replaceAll");var vl=c(Zu),_l=m,yl=Ur,Sl=Ti,Al=te,bl=_l("".charAt),Il=_l("".charCodeAt),kl=_l("".slice),Cl=function(e){return function(t,r){var i,o,n=Sl(Al(t)),a=yl(r),s=n.length;return a<0||a>=s?e?"":void 0:(i=Il(n,a))<55296||i>56319||a+1===s||(o=Il(n,a+1))<56320||o>57343?e?bl(n,a):i:e?kl(n,a,a+2):o-56320+(i-55296<<10)+65536}},Ol={codeAt:Cl(!1),charAt:Cl(!0)}.charAt,Rl=Ti,Nl=ss,wl=Ou,Dl=Ru,Pl="String Iterator",Ml=Nl.set,Ll=Nl.getterFor(Pl);wl(String,"String",(function(e){Ml(this,{type:Pl,string:Rl(e),index:0})}),(function(){var e,t=Ll(this),r=t.string,i=t.index;return i>=r.length?Dl(void 0,!0):(e=Ol(r,i),t.index+=e.length,Dl(e,!1))}));var Vl=c(Sa.f("iterator"));function xl(e){return xl="function"==typeof vl&&"symbol"==typeof Vl?function(e){return typeof e}:function(e){return e&&"function"==typeof vl&&e.constructor===vl&&e!==vl.prototype?"symbol":typeof e},xl(e)}var Ul=c(Sa.f("toPrimitive"));function Bl(e){var t=function(e,t){if("object"!==xl(e)||null===e)return e;var r=e[Ul];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==xl(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===xl(t)?t:String(t)}function Fl(e,t,r){return(t=Bl(t))in e?Ao(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var jl=pe,Hl=ia,Gl=Ea,Wl=cr,Kl=m([].concat),zl=jl("Reflect","ownKeys")||function(e){var t=Hl.f(Wl(e)),r=Gl.f;return r?Kl(t,r(e)):t},Xl=ot,ql=zl,Jl=L,Yl=ir,Ql=se,Zl=Sr,$l=Error,eh=m("".replace),th=String($l("zxcasd").stack),rh=/\n\s*at [^:]*:[^\n]*/,ih=rh.test(th),oh=z,nh=!d((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",oh(1,7)),7!==e.stack)})),ah=Sr,sh=function(e,t){if(ih&&"string"==typeof e&&!$l.prepareStackTrace)for(;t--;)e=eh(e,rh,"");return e},ch=nh,dh=Error.captureStackTrace,uh=Id,lh=Tt("iterator"),hh=Array.prototype,ph=mi,gh=Fe,mh=Z,fh=Id,Eh=Tt("iterator"),Th=function(e){if(!mh(e))return gh(e,Eh)||gh(e,"@@iterator")||fh[ph(e)]},vh=B,_h=xe,yh=cr,Sh=Pe,Ah=Th,bh=TypeError,Ih=B,kh=cr,Ch=Fe,Oh=rr,Rh=B,Nh=cr,wh=Pe,Dh=function(e){return void 0!==e&&(uh.Array===e||hh[lh]===e)},Ph=zr,Mh=f,Lh=function(e,t){var r=arguments.length<2?Ah(e):t;if(_h(r))return yh(vh(r,e));throw bh(Sh(e)+" is not iterable")},Vh=Th,xh=function(e,t,r){var i,o;kh(e);try{if(!(i=Ch(e,"return"))){if("throw"===t)throw r;return r}i=Ih(i,e)}catch(e){o=!0,i=e}if("throw"===t)throw r;if(o)throw i;return kh(i),r},Uh=TypeError,Bh=function(e,t){this.stopped=e,this.result=t},Fh=Bh.prototype,jh=function(e,t,r){var i,o,n,a,s,c,d,u=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),g=!(!r||!r.INTERRUPTED),m=Oh(t,u),f=function(e){return i&&xh(i,"normal",e),new Bh(!0,e)},E=function(e){return l?(Nh(e),g?m(e[0],e[1],f):m(e[0],e[1])):g?m(e,f):m(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(o=Vh(e)))throw Uh(wh(e)+" is not iterable");if(Dh(o)){for(n=0,a=Ph(e);a>n;n++)if((s=E(e[n]))&&Mh(Fh,s))return s;return new Bh(!1)}i=Lh(e,o)}for(c=h?e.next:i.next;!(d=Rh(c,i)).done;){try{s=E(d.value)}catch(e){xh(i,"throw",e)}if("object"==typeof s&&s&&Mh(Fh,s))return s}return new Bh(!1)},Hh=Ti,Gh=Mr,Wh=f,Kh=Fd,zh=lu,Xh=function(e,t,r){for(var i=ql(t),o=Yl.f,n=Jl.f,a=0;a<i.length;a++){var s=i[a];Xl(e,s)||r&&Xl(r,s)||o(e,s,n(t,s))}},qh=ra,Jh=Sr,Yh=z,Qh=function(e,t){Ql(t)&&"cause"in t&&Zl(e,"cause",t.cause)},Zh=function(e,t,r,i){ch&&(dh?dh(e,t):ah(e,"stack",sh(r,i)))},$h=jh,ep=function(e,t){return void 0===e?arguments.length<2?"":t:Hh(e)},tp=Tt("toStringTag"),rp=Error,ip=[].push,op=function(e,t){var r,i=Wh(np,this);zh?r=zh(rp(),i?Kh(this):np):(r=i?this:qh(np),Jh(r,tp,"Error")),void 0!==t&&Jh(r,"message",ep(t)),Zh(r,op,r.stack,1),arguments.length>2&&Qh(r,arguments[2]);var o=[];return $h(e,ip,{that:o}),Jh(r,"errors",o),r};zh?zh(op,rp):Xh(op,rp,{name:!0});var np=op.prototype=qh(rp.prototype,{constructor:Yh(1,op),message:Yh(1,""),name:Yh(1,"AggregateError")});Gh({global:!0,constructor:!0,arity:2},{AggregateError:op});var ap,sp,cp,dp,up="undefined"!=typeof process&&"process"==C(process),lp=pe,hp=ya,pp=V,gp=Tt("species"),mp=f,fp=TypeError,Ep=qo,Tp=Pe,vp=TypeError,_p=cr,yp=function(e){if(Ep(e))return e;throw vp(Tp(e)+" is not a constructor")},Sp=Z,Ap=Tt("species"),bp=function(e,t){var r,i=_p(e).constructor;return void 0===i||Sp(r=_p(i)[Ap])?t:yp(r)},Ip=TypeError,kp=/(?:ipad|iphone|ipod).*applewebkit/i.test(ge),Cp=T,Op=A,Rp=rr,Np=M,wp=ot,Dp=d,Pp=Bn,Mp=Bc,Lp=Dt,Vp=function(e,t){if(e<t)throw Ip("Not enough arguments");return e},xp=kp,Up=up,Bp=Cp.setImmediate,Fp=Cp.clearImmediate,jp=Cp.process,Hp=Cp.Dispatch,Gp=Cp.Function,Wp=Cp.MessageChannel,Kp=Cp.String,zp=0,Xp={},qp="onreadystatechange";Dp((function(){ap=Cp.location}));var Jp=function(e){if(wp(Xp,e)){var t=Xp[e];delete Xp[e],t()}},Yp=function(e){return function(){Jp(e)}},Qp=function(e){Jp(e.data)},Zp=function(e){Cp.postMessage(Kp(e),ap.protocol+"//"+ap.host)};Bp&&Fp||(Bp=function(e){Vp(arguments.length,1);var t=Np(e)?e:Gp(e),r=Mp(arguments,1);return Xp[++zp]=function(){Op(t,void 0,r)},sp(zp),zp},Fp=function(e){delete Xp[e]},Up?sp=function(e){jp.nextTick(Yp(e))}:Hp&&Hp.now?sp=function(e){Hp.now(Yp(e))}:Wp&&!xp?(dp=(cp=new Wp).port2,cp.port1.onmessage=Qp,sp=Rp(dp.postMessage,dp)):Cp.addEventListener&&Np(Cp.postMessage)&&!Cp.importScripts&&ap&&"file:"!==ap.protocol&&!Dp(Zp)?(sp=Zp,Cp.addEventListener("message",Qp,!1)):sp=qp in Lp("script")?function(e){Pp.appendChild(Lp("script"))[qp]=function(){Pp.removeChild(this),Jp(e)}}:function(e){setTimeout(Yp(e),0)});var $p={set:Bp,clear:Fp},eg=function(){this.head=null,this.tail=null};eg.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 tg,rg,ig,og,ng,ag=eg,sg=/ipad|iphone|ipod/i.test(ge)&&"undefined"!=typeof Pebble,cg=/web0s(?!.*chrome)/i.test(ge),dg=T,ug=rr,lg=L.f,hg=$p.set,pg=ag,gg=kp,mg=sg,fg=cg,Eg=up,Tg=dg.MutationObserver||dg.WebKitMutationObserver,vg=dg.document,_g=dg.process,yg=dg.Promise,Sg=lg(dg,"queueMicrotask"),Ag=Sg&&Sg.value;if(!Ag){var bg=new pg,Ig=function(){var e,t;for(Eg&&(e=_g.domain)&&e.exit();t=bg.get();)try{t()}catch(e){throw bg.head&&tg(),e}e&&e.enter()};gg||Eg||fg||!Tg||!vg?!mg&&yg&&yg.resolve?((og=yg.resolve(void 0)).constructor=yg,ng=ug(og.then,og),tg=function(){ng(Ig)}):Eg?tg=function(){_g.nextTick(Ig)}:(hg=ug(hg,dg),tg=function(){hg(Ig)}):(rg=!0,ig=vg.createTextNode(""),new Tg(Ig).observe(ig,{characterData:!0}),tg=function(){ig.data=rg=!rg}),Ag=function(e){bg.head||tg(),bg.add(e)}}var kg=Ag,Cg=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Og=T.Promise,Rg="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Ng=!Rg&&!up&&"object"==typeof window&&"object"==typeof document,wg=T,Dg=Og,Pg=M,Mg=Zt,Lg=Mo,Vg=Tt,xg=Ng,Ug=Rg,Bg=ye,Fg=Dg&&Dg.prototype,jg=Vg("species"),Hg=!1,Gg=Pg(wg.PromiseRejectionEvent),Wg=Mg("Promise",(function(){var e=Lg(Dg),t=e!==String(Dg);if(!t&&66===Bg)return!0;if(!Fg.catch||!Fg.finally)return!0;if(!Bg||Bg<51||!/native code/.test(e)){var r=new Dg((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[jg]=i,!(Hg=r.then((function(){}))instanceof i))return!0}return!t&&(xg||Ug)&&!Gg})),Kg={CONSTRUCTOR:Wg,REJECTION_EVENT:Gg,SUBCLASSING:Hg},zg={},Xg=xe,qg=TypeError,Jg=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw qg("Bad Promise constructor");t=e,r=i})),this.resolve=Xg(t),this.reject=Xg(r)};zg.f=function(e){return new Jg(e)};var Yg,Qg,Zg=Mr,$g=up,em=T,tm=B,rm=va,im=Ka,om=function(e){var t=lp(e);pp&&t&&!t[gp]&&hp(t,gp,{configurable:!0,get:function(){return this}})},nm=xe,am=M,sm=se,cm=function(e,t){if(mp(t,e))return e;throw fp("Incorrect invocation")},dm=bp,um=$p.set,lm=kg,hm=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},pm=Cg,gm=ag,mm=ss,fm=Og,Em=Kg,Tm=zg,vm="Promise",_m=Em.CONSTRUCTOR,ym=Em.REJECTION_EVENT,Sm=mm.getterFor(vm),Am=mm.set,bm=fm&&fm.prototype,Im=fm,km=bm,Cm=em.TypeError,Om=em.document,Rm=em.process,Nm=Tm.f,wm=Nm,Dm=!!(Om&&Om.createEvent&&em.dispatchEvent),Pm="unhandledrejection",Mm=function(e){var t;return!(!sm(e)||!am(t=e.then))&&t},Lm=function(e,t){var r,i,o,n=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,d=e.reject,u=e.domain;try{s?(a||(2===t.rejection&&Fm(t),t.rejection=1),!0===s?r=n:(u&&u.enter(),r=s(n),u&&(u.exit(),o=!0)),r===e.promise?d(Cm("Promise-chain cycle")):(i=Mm(r))?tm(i,r,c,d):c(r)):d(n)}catch(e){u&&!o&&u.exit(),d(e)}},Vm=function(e,t){e.notified||(e.notified=!0,lm((function(){for(var r,i=e.reactions;r=i.get();)Lm(r,e);e.notified=!1,t&&!e.rejection&&Um(e)})))},xm=function(e,t,r){var i,o;Dm?((i=Om.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),em.dispatchEvent(i)):i={promise:t,reason:r},!ym&&(o=em["on"+e])?o(i):e===Pm&&hm("Unhandled promise rejection",r)},Um=function(e){tm(um,em,(function(){var t,r=e.facade,i=e.value;if(Bm(e)&&(t=pm((function(){$g?Rm.emit("unhandledRejection",i,r):xm(Pm,r,i)})),e.rejection=$g||Bm(e)?2:1,t.error))throw t.value}))},Bm=function(e){return 1!==e.rejection&&!e.parent},Fm=function(e){tm(um,em,(function(){var t=e.facade;$g?Rm.emit("rejectionHandled",t):xm("rejectionhandled",t,e.value)}))},jm=function(e,t,r){return function(i){e(t,i,r)}},Hm=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Vm(e,!0))},Gm=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Cm("Promise can't be resolved itself");var i=Mm(t);i?lm((function(){var r={done:!1};try{tm(i,t,jm(Gm,r,e),jm(Hm,r,e))}catch(t){Hm(r,t,e)}})):(e.value=t,e.state=1,Vm(e,!1))}catch(t){Hm({done:!1},t,e)}}};_m&&(km=(Im=function(e){cm(this,km),nm(e),tm(Yg,this);var t=Sm(this);try{e(jm(Gm,t),jm(Hm,t))}catch(e){Hm(t,e)}}).prototype,(Yg=function(e){Am(this,{type:vm,done:!1,notified:!1,parent:!1,reactions:new gm,rejection:!1,state:0,value:void 0})}).prototype=rm(km,"then",(function(e,t){var r=Sm(this),i=Nm(dm(this,Im));return r.parent=!0,i.ok=!am(e)||e,i.fail=am(t)&&t,i.domain=$g?Rm.domain:void 0,0==r.state?r.reactions.add(i):lm((function(){Lm(i,r)})),i.promise})),Qg=function(){var e=new Yg,t=Sm(e);this.promise=e,this.resolve=jm(Gm,t),this.reject=jm(Hm,t)},Tm.f=Nm=function(e){return e===Im||undefined===e?new Qg(e):wm(e)}),Zg({global:!0,constructor:!0,wrap:!0,forced:_m},{Promise:Im}),im(Im,vm,!1,!0),om(vm);var Wm=Tt("iterator"),Km=!1;try{var zm=0,Xm={next:function(){return{done:!!zm++}},return:function(){Km=!0}};Xm[Wm]=function(){return this},Array.from(Xm,(function(){throw 2}))}catch(e){}var qm=Og,Jm=function(e,t){if(!t&&!Km)return!1;var r=!1;try{var i={};i[Wm]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(e){}return r},Ym=Kg.CONSTRUCTOR||!Jm((function(e){qm.all(e).then(void 0,(function(){}))})),Qm=B,Zm=xe,$m=zg,ef=Cg,tf=jh;Mr({target:"Promise",stat:!0,forced:Ym},{all:function(e){var t=this,r=$m.f(t),i=r.resolve,o=r.reject,n=ef((function(){var r=Zm(t.resolve),n=[],a=0,s=1;tf(e,(function(e){var c=a++,d=!1;s++,Qm(r,t,e).then((function(e){d||(d=!0,n[c]=e,--s||i(n))}),o)})),--s||i(n)}));return n.error&&o(n.value),r.promise}});var rf=Mr,of=Kg.CONSTRUCTOR;Og&&Og.prototype,rf({target:"Promise",proto:!0,forced:of,real:!0},{catch:function(e){return this.then(void 0,e)}});var nf=B,af=xe,sf=zg,cf=Cg,df=jh;Mr({target:"Promise",stat:!0,forced:Ym},{race:function(e){var t=this,r=sf.f(t),i=r.reject,o=cf((function(){var o=af(t.resolve);df(e,(function(e){nf(o,t,e).then(r.resolve,i)}))}));return o.error&&i(o.value),r.promise}});var uf=B,lf=zg;Mr({target:"Promise",stat:!0,forced:Kg.CONSTRUCTOR},{reject:function(e){var t=lf.f(this);return uf(t.reject,void 0,e),t.promise}});var hf=cr,pf=se,gf=zg,mf=function(e,t){if(hf(e),pf(t)&&t.constructor===e)return t;var r=gf.f(e);return(0,r.resolve)(t),r.promise},ff=Mr,Ef=Og,Tf=Kg.CONSTRUCTOR,vf=mf,_f=pe("Promise"),yf=!Tf;ff({target:"Promise",stat:!0,forced:true},{resolve:function(e){return vf(yf&&this===_f?Ef:this,e)}});var Sf=B,Af=xe,bf=zg,If=Cg,kf=jh;Mr({target:"Promise",stat:!0,forced:Ym},{allSettled:function(e){var t=this,r=bf.f(t),i=r.resolve,o=r.reject,n=If((function(){var r=Af(t.resolve),o=[],n=0,a=1;kf(e,(function(e){var s=n++,c=!1;a++,Sf(r,t,e).then((function(e){c||(c=!0,o[s]={status:"fulfilled",value:e},--a||i(o))}),(function(e){c||(c=!0,o[s]={status:"rejected",reason:e},--a||i(o))}))})),--a||i(o)}));return n.error&&o(n.value),r.promise}});var Cf=B,Of=xe,Rf=pe,Nf=zg,wf=Cg,Df=jh,Pf="No one promise resolved";Mr({target:"Promise",stat:!0,forced:Ym},{any:function(e){var t=this,r=Rf("AggregateError"),i=Nf.f(t),o=i.resolve,n=i.reject,a=wf((function(){var i=Of(t.resolve),a=[],s=0,c=1,d=!1;Df(e,(function(e){var u=s++,l=!1;c++,Cf(i,t,e).then((function(e){l||d||(d=!0,o(e))}),(function(e){l||d||(l=!0,a[u]=e,--c||n(new r(a,Pf)))}))})),--c||n(new r(a,Pf))}));return a.error&&n(a.value),i.promise}});var Mf=Mr,Lf=Og,Vf=d,xf=pe,Uf=M,Bf=bp,Ff=mf,jf=Lf&&Lf.prototype;Mf({target:"Promise",proto:!0,real:!0,forced:!!Lf&&Vf((function(){jf.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Bf(this,xf("Promise")),r=Uf(e);return this.then(r?function(r){return Ff(t,e()).then((function(){return r}))}:e,r?function(r){return Ff(t,e()).then((function(){throw r}))}:e)}});var Hf=c(ce.Promise);function Gf(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}function Wf(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class Kf extends t.EventEmitter{constructor(e,r){super(),this._ID=void 0,this._rtpTransceiver=void 0,this._lowRtpTransceiver=void 0,this._hints=[],this._isClosed=!1,this._originMediaStreamTrack=void 0,this._mediaStreamTrack=void 0,this._external={},this._ID=r||t.getRandomString(8,"track-"),this._originMediaStreamTrack=e,this._mediaStreamTrack=e,Xi(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){if(!e){const e=r.report.reportApiInvoke(null,{name:t.AgoraAPIName.GET_MEDIA_STREAM_TRACK,options:[],tag:t.AgoraAPITag.TRACER});this._mediaStreamTrack&&"string"==typeof this._mediaStreamTrack.label?e.onSuccess(this._mediaStreamTrack.label):e.onSuccess("")}return this._mediaStreamTrack}getRTCRtpTransceiver(t){return t===e.StreamType.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,qi(this),this.emit(e.LocalTrackEvents.CLOSED)}_updateRtpTransceiver(t,r){if(r===e.StreamType.LOW_STREAM){if(this._lowRtpTransceiver===t)return;this._lowRtpTransceiver=t}else{if(this._rtpTransceiver===t)return;this._rtpTransceiver=t}this.emit(e.TrackEvents.TRANSCEIVER_UPDATED,t,r)}}class zf extends Kf{get isExternalTrack(){return this._isExternalTrack}get muted(){return this._muted}get enabled(){return this._enabled}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}constructor(e,r){super(e,r),this._enabled=!0,this._muted=!1,this._isExternalTrack=!1,this._isClosed=!1,this._enabledMutex=void 0,this.processor=void 0,this._handleTrackEnded=()=>{this.onTrackEnded()},this._enabledMutex=new t.PromiseMutex("".concat(this.getTrackId())),e.addEventListener("ended",this._handleTrackEnded)}getTrackLabel(){var e,t;return null!==(e=null===(t=this._originMediaStreamTrack)||void 0===t?void 0:t.label)&&void 0!==e?e:""}close(){this._isClosed||(this.stop(),this._originMediaStreamTrack.stop(),this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack.stop(),this._mediaStreamTrack=null),this._originMediaStreamTrack=null,this._enabledMutex=null,r.logger.debug("[".concat(this.getTrackId(),"] close")),this.emit(e.TrackInternalEvent.NEED_CLOSE),super.close())}async _updateOriginMediaStreamTrack(r,i){let o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._isExternalTrack=o,r!==this._originMediaStreamTrack&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),i&&this._originMediaStreamTrack.stop()),r.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=r,this._muted&&(this._originMediaStreamTrack.enabled=!1),this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){r.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}stateCheck(e,i){if(r.logger.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(i,"]")),t.checkValidBoolean(i,e),this._enabled&&this._muted&&"enabled"===e&&!1===i)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",r.logger);if(!this._enabled&&!this._muted&&"muted"===e&&!0===i)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",r.logger)}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}function Xf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}const qf=window.AudioContext||window.webkitAudioContext;let Jf=null;class Yf extends t.EventEmitter{constructor(){super(...arguments),this.prevState=void 0,this.curState=void 0,this.currentTime=void 0,this.currentTimeStuckAt=void 0,this.interruptDetectorTrack=void 0,this.onLocalAudioTrackMute=()=>{r.logger.info("ios15-interruption-start"),this.emit(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_START)},this.onLocalAudioTrackUnmute=async()=>{r.logger.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?r.logger.info("ios15-interruption-end-canceled"):(Jf&&await Jf.suspend(),this.emit(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END))}}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){r.logger.debug("webaudio bindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack||(this.interruptDetectorTrack=e,this.interruptDetectorTrack._mediaStreamTrack.onmute=this.onLocalAudioTrackMute,this.interruptDetectorTrack._mediaStreamTrack.onunmute=this.onLocalAudioTrackUnmute)}unbindInterruptDetectorTrack(e){r.logger.debug("webaudio unbindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack&&this.interruptDetectorTrack===e&&(this.interruptDetectorTrack._mediaStreamTrack&&(this.interruptDetectorTrack._mediaStreamTrack.onmute=null,this.interruptDetectorTrack._mediaStreamTrack.onunmute=null),this.interruptDetectorTrack=void 0)}}const Qf=new Yf;function Zf(){if(!qf)return void r.logger.error("your browser is not support web audio");r.logger.info("create audio context");const i=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xf(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xf(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},t.getParameter("WEBAUDIO_INIT_OPTIONS"));r.logger.debug("audio context init option:",JSON.stringify(i)),Jf=new qf(i),Qf.curState=Jf.state,Jf.onstatechange=()=>{Qf.prevState=Qf.curState,Qf.curState=Jf?Jf.state:void 0;const{prevState:i,curState:o}=Qf,n="running"===o,a="interrupted"===o,s="running"===i,c="suspended"===i,d="interrupted"===i,u=t.getBrowserInfo().osVersion;(t.isIOS()||t.isIpadOS())&&s&&a&&(r.logger.info("ios".concat(u,"-interruption-start")),Qf.emit(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_START)),(t.isIOS()||t.isIpadOS())&&(c||d)&&n&&(r.logger.info("ios".concat(u,"-interruption-end")),Qf.emit(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END)),i!==o&&(r.logger.debug("AudioContext State Change","".concat(i,"=>").concat(o)),Qf.emit(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE))},setInterval((()=>{var e;const i=null===(e=Jf)||void 0===e?void 0:e.currentTime;if(Qf.currentTime!==i)Qf.currentTimeStuckAt&&(r.logger.debug("AudioContext current time resume at ".concat(i)),Qf.currentTimeStuckAt=void 0),Qf.currentTime=i;else{if(i!==Qf.currentTimeStuckAt){r.report.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:i},tag:t.AgoraAPITag.TRACER}).onSuccess(),r.logger.warning("AudioContext current time stuck at ".concat(i))}Qf.currentTimeStuckAt=i}}),5e3),async function(r){const i=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","touchend","keydown","keyup"];let o,n=!1,a=!1,s=!1;function c(e){"running"===r.state?d(!1):t.isIOS()||t.isIpadOS()?"suspended"===r.state&&(d(!0),e&&r.resume().then(l,l)):"closed"!==r.state&&(d(!0),e&&r.resume().then(l,l))}function d(e){if(n!==e){n=e;for(let t=0,r=i;t<r.length;t+=1){const i=r[t];e?window.addEventListener(i,h,{capture:!0,passive:!0}):window.removeEventListener(i,h,{capture:!0,passive:!0})}}}function u(){c(!0)}function l(){c(!1)}function h(){c(!0)}function p(e){if(!s)if(o.paused)if(e){let e;g(!1),s=!0;try{e=o.play(),e?e.then(m,m):(o.addEventListener("playing",m),o.addEventListener("abort",m),o.addEventListener("error",m))}catch(e){m()}}else g(!0);else g(!1)}function g(e){if(a!==e){a=e;for(let t=0,r=i;t<r.length;t++){const i=r[t];e?window.addEventListener(i,f,{capture:!0,passive:!0}):window.removeEventListener(i,f,{capture:!0,passive:!0})}}}function m(){o.removeEventListener("playing",m),o.removeEventListener("abort",m),o.removeEventListener("error",m),s=!1,p(!1)}function f(){p(!0)}if(t.isIOS()){const e=r.createMediaStreamDestination(),t=document.createElement("div");t.innerHTML="<audio x-webkit-airplay='deny'></audio>",o=t.children.item(0),o.controls=!1,o.disableRemotePlayback=!0,o.preload="auto",o.srcObject=e.stream,p(!0)}Qf.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,u),c(!1)}(Jf)}function $f(){if(!Jf){if(Zf(),!Jf)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create audio context");return Jf}return Jf}function eE(){return!!Jf}function tE(e){if(function(){if(null!==iE)return iE;const e=$f(),t=e.createBufferSource(),r=e.createGain(),i=e.createGain();t.connect(r),t.connect(i),t.disconnect(r);let o=!1;try{t.disconnect(r)}catch(e){o=!0}return t.disconnect(),iE=o,o}())return;const r=e.connect,i=e.disconnect;e.connect=(t,i,o)=>{var n;return e._inputNodes||(e._inputNodes=[]),Di(n=e._inputNodes).call(n,t)||(t instanceof AudioNode?(e._inputNodes.push(t),r.call(e,t,i,o)):r.call(e,t,i)),e},e.disconnect=(o,n,a)=>{i.call(e),o?t.removeItemFromList(e._inputNodes,o):e._inputNodes=[];for(const t of e._inputNodes)r.call(e,t)}}function rE(e){const r=$f();return new Hf(((i,o)=>{r.decodeAudioData(e,(e=>{i(e)}),(e=>{o(new t.AgoraRTCError(t.AgoraRTCErrorCode.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let iE=null;let oE=null;function nE(e){for(let t=0;t<e.outputBuffer.numberOfChannels;t+=1){const r=e.outputBuffer.getChannelData(t);for(let e=0;e<r.length;e+=1)r[e]=0}return e.inputBuffer}const aE={getDisplayMedia:!1,getStreamFromExtension:!1,supportUnifiedPlan:!1,supportMinBitrate:!1,supportSetRtpSenderParameters:!1,supportDualStream:!0,webAudioMediaStreamDest:!1,supportReplaceTrack:!1,supportWebGL:!1,webAudioWithAEC:!1,supportRequestFrame:!1,supportShareAudio:!1,supportDualStreamEncoding:!1,supportDataChannel:!1,supportPCSetConfiguration:!1,supportWebRTCEncodedTransform:!1,supportWebRTCInsertableStream:!1};function sE(){return aE}var cE=xe,dE=tt,uE=Q,lE=zr,hE=TypeError,pE=function(e){return function(t,r,i,o){cE(r);var n=dE(t),a=uE(n),s=lE(n),c=e?s-1:0,d=e?-1:1;if(i<2)for(;;){if(c in a){o=a[c],c+=d;break}if(c+=d,e?c<0:s<=c)throw hE("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=d)c in a&&(o=r(o,a[c],c,n));return o}},gE={left:pE(!1),right:pE(!0)},mE=d,fE=gE.left,EE=function(e,t){var r=[][e];return!!r&&mE((function(){r.call(null,t||function(){return 1},1)}))};Mr({target:"Array",proto:!0,forced:!up&&ye>79&&ye<83||!EE("reduce")},{reduce:function(e){var t=arguments.length;return fE(this,e,t,t>1?arguments[1]:void 0)}});var TE=ei("Array").reduce,vE=f,_E=TE,yE=Array.prototype,SE=c((function(e){var t=e.reduce;return e===yE||vE(yE,e)&&t===yE.reduce?_E:t}));class AE{constructor(){this.context=void 0,this.analyserNode=void 0,this.sourceNode=void 0,this.context=$f(),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4}updateSource(e){if(e!==this.sourceNode){if(this.sourceNode)try{this.sourceNode.disconnect(this.analyserNode)}catch(e){}this.sourceNode=e,null==e||e.connect(this.analyserNode)}}getVolumeLevel(){if(!this.sourceNode)return 0;if(!this.context||t.isIOS()||t.isIpadOS()||"running"!==this.context.state&&this.context.resume(),!this.analyserNode)return 0;const e=new Float32Array(this.analyserNode.fftSize);if(this.analyserNode.getFloatTimeDomainData)this.analyserNode.getFloatTimeDomainData(e);else{const t=new Uint8Array(this.analyserNode.fftSize);this.analyserNode.getByteTimeDomainData(t);for(let r=0;r<e.length;++r)e[r]=t[r]/128-1}const r=SE(e).call(e,((e,t)=>e+t*t),0)/e.length;return Math.max(10*Math.log10(r)+100,0)/100}getAnalyserNode(){return this.analyserNode}rebuildAnalyser(){try{var e,t;null===(e=this.sourceNode)||void 0===e||e.disconnect(this.analyserNode),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4,null===(t=this.sourceNode)||void 0===t||t.connect(this.analyserNode)}catch(e){r.logger.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class bE extends t.EventEmitter{get processSourceNode(){return this.sourceNode}set processedNode(e){var t;if(!this.isDestroyed&&this._processedNode!==e){try{var r;null===(r=this.sourceNode)||void 0===r||r.disconnect(this.outputNode)}catch(e){}null===(t=this._processedNode)||void 0===t||t.disconnect(),this._processedNode=e,this.connect()}}get processedNode(){return this._processedNode}constructor(){super(),this.outputNode=void 0,this.outputTrack=void 0,this.isPlayed=!1,this.context=void 0,this.audioBufferNode=void 0,this.destNode=void 0,this.audioOutputLevel=0,this.volumeLevelAnalyser=void 0,this._processedNode=void 0,this.playNode=void 0,this.isDestroyed=!1,this.onNoAudioInput=void 0,this.isNoAudioInput=!1,this._noAudioInputCount=0,this.context=$f(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),tE(this.outputNode),this.volumeLevelAnalyser=new AE}startGetAudioBuffer(t){this.audioBufferNode||(this.audioBufferNode=this.context.createScriptProcessor(t),this.outputNode.connect(this.audioBufferNode),this.audioBufferNode.connect(this.context.destination),this.audioBufferNode.onaudioprocess=t=>{this.emit(e.AudioSourceEvents.ON_AUDIO_BUFFER,nE(t))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!sE().webAudioMediaStreamDest)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser is not support audio processor");return this.destNode&&this.outputTrack||(this.destNode=this.context.createMediaStreamDestination(),this.outputNode.connect(this.destNode),this.outputTrack=this.destNode.stream.getAudioTracks()[0]),this.outputTrack}play(e){"running"!==this.context.state&&t.nextTick((()=>{Qf.emit("autoplay-failed")})),this.isPlayed=!0,this.playNode=e||this.context.destination,this.outputNode.connect(this.playNode)}stop(){if(this.isPlayed)try{this.outputNode.disconnect(this.playNode)}catch(e){}this.isPlayed=!1}getAccurateVolumeLevel(){return this.volumeLevelAnalyser.getVolumeLevel()}async checkHasAudioInput(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(e>5)return this.isNoAudioInput=!0,this.onNoAudioInput&&this.onNoAudioInput(),!1;t.isIOS()||t.isIpadOS()?"suspended"===this.context.state&&this.context.resume():"running"!==this.context.state&&this.context.resume();const r=this.volumeLevelAnalyser.getAnalyserNode();let i;r.getFloatTimeDomainData?(i=new Float32Array(r.fftSize),r.getFloatTimeDomainData(i)):(i=new Uint8Array(r.fftSize),r.getByteTimeDomainData(i));let o=!1;for(let e=0;e<i.length;e++)0!==i[e]&&(o=!0);return o?(this.isNoAudioInput=!1,!0):(await t.wait(200),await this.checkHasAudioInput(e?e+1:1)&&o)}getAudioVolume(){return this.outputNode.gain.value}setVolume(e){this.outputNode.gain.setValueAtTime(e,this.context.currentTime)}destroy(){this.disconnect(),this.stop(),this.isDestroyed=!0,this.onNoAudioInput=void 0}disconnect(){var e,t;null===(e=this.processedNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.outputNode&&this.outputNode.disconnect()}connect(){var e;this.processedNode?null===(e=this.processedNode)||void 0===e||e.connect(this.outputNode):this.sourceNode&&this.sourceNode.connect(this.outputNode);this.volumeLevelAnalyser.updateSource(this.outputNode)}}class IE extends bE{get isFreeze(){return!1}constructor(i,o,n){var a;if(super(),this.sourceNode=void 0,this.track=void 0,this.clonedTrack=void 0,this.audioElement=void 0,this.isCurrentTrackCloned=!1,this.isRemoteTrack=!1,this.originVolumeLevelAnalyser=void 0,this.rebuildWebAudio=async()=>{if(r.logger.debug("ready to rebuild web audio, state:",this.context.state),this.isNoAudioInput&&await this.checkHasAudioInput(),!this.isNoAudioInput||this.isDestroyed)return document.body.removeEventListener("click",this.rebuildWebAudio,!0),void r.logger.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>r.logger.info("resume success"))),r.logger.debug("rebuild web audio because of ios 12 bugs"),this.disconnect();const t=this.track;this.track=this.track.clone(),this.isCurrentTrackCloned?t.stop():this.isCurrentTrackCloned=!0;const i=new MediaStream([this.track]);this.sourceNode=this.context.createMediaStreamSource(i),tE(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const o=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(o,this.context.currentTime),tE(this.outputNode),this.emit(e.AudioSourceEvents.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=i,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()},"audio"!==i.kind)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR);this.track=i;const s=new MediaStream([this.track]);if(this.isRemoteTrack=!!o,this.sourceNode=this.context.createMediaStreamSource(s),tE(this.sourceNode),n){const e=n.clone();e.enabled=!0,this.clonedTrack=e,r.logger.debug("create an unmuted track ".concat(e.id," from the original track ").concat(n.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));tE(t),this.originVolumeLevelAnalyser=new AE,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=s;const c=t.getBrowserInfo();o&&c.os===t.BrowserOS.IOS&&Number(null===(a=c.osVersion)||void 0===a?void 0:a.split(".")[0])<15&&(Qf.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,(()=>{"suspended"===this.context.state?document.body.addEventListener("click",this.rebuildWebAudio,!0):"running"===this.context.state&&this.rebuildWebAudio()})),this.checkHasAudioInput().then((e=>{e||document.body.addEventListener("click",this.rebuildWebAudio,!0)})))}updateTrack(t){this.sourceNode.disconnect(),this.track=t,this.isCurrentTrackCloned=!1;const r=new MediaStream([t]);this.sourceNode=this.context.createMediaStreamSource(r),tE(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(e.AudioSourceEvents.UPDATE_SOURCE),this.audioElement.srcObject=r}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),Qf.off("state-change",this.rebuildWebAudio),null===(e=this.originVolumeLevelAnalyser)||void 0===e||e.destroy(),this.clonedTrack=void 0,super.destroy()}createMediaStreamSourceNode(e){return this.context.createMediaStreamSource(new MediaStream([e]))}updateOriginTrack(e){const t=e.clone();t.enabled=!0,this.clonedTrack&&(this.clonedTrack.stop(),this.clonedTrack=t),r.logger.debug("create an unmuted track ".concat(t.id," from the original track ").concat(e.id," to get the volume"));const i=this.context.createMediaStreamSource(new MediaStream([t]));tE(i),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(i)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function kE(e,t,r){const i=(e,t)=>e?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t,o={audio:!!r&&{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:i(t.height,1080),maxWidth:i(t.width,1920)}}};return t.frameRate&&"number"!=typeof t.frameRate?(o.video.mandatory.maxFrameRate=t.frameRate.max,o.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(o.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(o)}async function CE(e,r){const i=await OE(e.mediaSource),{sourceId:o,audio:n}=await t.showElectronSelectSourceWindow(i,r);return await kE(o,e,n)}async function OE(e){let r=["window","screen"];"application"!==e&&"window"!==e||(r=["window"]),"screen"===e&&(r=["screen"]);const i=t.getElectronInstance();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new t.AgoraRTCError(t.AgoraRTCErrorCode.ELECTRON_IS_NULL);let o=null;try{var n;o=(null===(n=i.desktopCapturer)||void 0===n?void 0:n.getSources({types:r}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:r})}catch(e){o=null}o&&o.then||(o=new Hf(((e,t)=>{i.desktopCapturer.getSources({types:r},((r,i)=>{r?t(r):e(i)}))})));try{return await o}catch(e){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}function RE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}const NE=new t.PromiseMutex("safari");async function wE(e,i){let o=0,n=null;for(;o<2;)try{n=await DE(e,i,o>0);break}catch(e){if(e instanceof t.AgoraRTCError)throw r.logger.error("[".concat(i,"] ").concat(e.toString())),e;const n=PE(e.name||e.code||e,e.message);if(n.code===t.AgoraRTCErrorCode.MEDIA_OPTION_INVALID){r.logger.debug("[".concat(i,"] detect media option invalid, retry")),o+=1,await t.wait(500);continue}throw r.logger.error("[".concat(i,"] ").concat(n.toString())),n}if(!n)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return n}async function DE(i,o,n){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not find getUserMedia");n&&(i.video&&(delete i.video.width,delete i.video.height),i.screen&&(delete i.screen.width,delete i.screen.height));const a=sE(),s=new MediaStream;if(i.audioSource&&s.addTrack(i.audioSource),i.videoSource&&s.addTrack(i.videoSource),!i.audio&&!i.video&&!i.screen)return r.logger.debug("Using Video Source/ Audio Source"),s;if(i.screen)if(t.isElectron())if(i.screen.sourceId){ME(s,await kE(i.screen.sourceId,i.screen,i.screenAudio))}else{ME(s,await CE(i.screen,i.screenAudio))}else if(t.isChrome()&&i.screen.extensionId&&i.screen.mandatory){if(!a.getStreamFromExtension)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"This browser does not support screen sharing");r.logger.debug("[".concat(o,'] Screen access on chrome stable, looking for extension"'));const e=await(d=i.screen.extensionId,u=o,new Hf(((e,i)=>{try{chrome.runtime.sendMessage(d,{getStream:!0},(o=>{if(!o||!o.streamId)return r.logger.error("[".concat(u,"] No response from Chrome Plugin. Plugin not installed properly"),o),void i(new t.AgoraRTCError(t.AgoraRTCErrorCode.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(o.streamId)}))}catch(e){r.logger.error("[".concat(u,"] AgoraRTC screensharing plugin is not accessible(").concat(d,")"),e.toString()),i(new t.AgoraRTCError(t.AgoraRTCErrorCode.CHROME_PLUGIN_NOT_INSTALL))}})));i.screen.mandatory.chromeMediaSourceId=e;ME(s,await navigator.mediaDevices.getUserMedia({video:{mandatory:i.screen.mandatory}}))}else if(a.getDisplayMedia){var c;i.screen.mediaSource&&Qi(i.screen.mediaSource);const e={width:i.screen.width,height:i.screen.height,frameRate:i.screen.frameRate,displaySurface:null!==(c=i.screen.displaySurface)&&void 0!==c?c:"screen"===i.screen.mediaSource?"monitor":i.screen.mediaSource},{selfBrowserSurface:t,surfaceSwitching:n,systemAudio:a}=i.screen,d={selfBrowserSurface:t,surfaceSwitching:n,systemAudio:a};!t&&delete d.selfBrowserSurface,!n&&delete d.surfaceSwitching,!a&&delete d.systemAudio,r.logger.debug("[".concat(o,"] getDisplayMedia:"),JSON.stringify({video:e,audio:!!i.screenAudio,controls:d}));const u=await navigator.mediaDevices.getDisplayMedia(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?RE(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):RE(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({video:e,audio:!!i.screenAudio},d));ME(s,u)}else{if(!t.isFirefox())throw r.logger.error("[".concat(o,"] This browser does not support screenSharing")),new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"This browser does not support screen sharing");{i.screen.mediaSource&&Qi(i.screen.mediaSource);const e={video:{mediaSource:i.screen.mediaSource,width:i.screen.width,height:i.screen.height,frameRate:i.screen.frameRate}};r.logger.debug("[".concat(o,"] getUserMedia: ").concat(JSON.stringify(e)));ME(s,await navigator.mediaDevices.getUserMedia(e))}}var d,u;if(!i.video&&!i.audio)return s;let l={video:i.video,audio:i.audio},h=t.getParameter("MEDIA_DEVICE_CONSTRAINTS");if(h)try{"string"==typeof h&&(h=JSON.parse(h)),l=t.recursiveMerge(l,h)}catch(e){}r.logger.debug("[".concat(o,"] GetUserMedia"),JSON.stringify(l)),t.getBrowserInfo();let p,g=null;(t.isSafari()||t.isIOS()||t.isWkWebview())&&(g=await NE.lock());try{p=await navigator.mediaDevices.getUserMedia(l)}catch(e){throw g&&g(),e}return l.audio&&(e.HAS_GUM_AUDIO=!0),l.video&&(e.HAS_GUM_VIDEO=!0),ME(s,p),g&&g(),s}function PE(e,i){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(i));case"NotFoundError":case"DevicesNotFoundError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.DEVICE_NOT_FOUND,"".concat(e,": ").concat(i));case"NotSupportedError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"".concat(e,": ").concat(i));case"NotReadableError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_READABLE,"".concat(e,": ").concat(i));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.PERMISSION_DENIED,"".concat(e,": ").concat(i));case"ConstraintNotSatisfiedError":return new t.AgoraRTCError(t.AgoraRTCErrorCode.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(i));default:return r.logger.error("getUserMedia unexpected error",e),new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"".concat(e,": ").concat(i))}}function ME(e,t){const r=e.getVideoTracks()[0],i=e.getAudioTracks()[0],o=t.getVideoTracks()[0],n=t.getAudioTracks()[0];n&&(i&&e.removeTrack(i),e.addTrack(n)),o&&(r&&e.removeTrack(r),e.addTrack(o))}e.HAS_GUM_AUDIO=!1,e.HAS_GUM_VIDEO=!1;class LE extends t.EventEmitter{get state(){return this._state}set state(t){t!==this._state&&(this.emit(e.DeviceManagerEvent.STATE_CHANGE,t),this._state=t)}constructor(){super(),this._state=e.DeviceManagerState.IDLE,this.isAccessMicrophonePermission=!1,this.isAccessCameraPermission=!1,this.lastAccessMicrophonePermission=!1,this.lastAccessCameraPermission=!1,this.checkdeviceMatched=!1,this.deviceInfoMap=new Map,this.init().then((()=>{navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",this.updateDevicesInfo.bind(this)),window.setInterval((()=>{(t.getParameter("ENUMERATE_DEVICES_INTERVAL")||(t.isAndroid()||t.isHarmonyOS())&&t.isChromeKernel())&&this.updateDevicesInfo()}),t.getParameter("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>r.logger.error(e.toString())))}async enumerateDevices(i,o){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){return new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const a=await navigator.mediaDevices.enumerateDevices(),s=this.checkMediaDeviceInfoIsOk(a);let c=!this.isAccessMicrophonePermission&&i,d=!this.isAccessCameraPermission&&o;s.audio&&(c=!1),s.video&&(d=!1);let u=null,l=null,h=null;if(!n&&(c||d)){if(NE.isLocked){r.logger.debug("[device manager] wait GUM lock");(await NE.lock())(),r.logger.debug("[device manager] GUM unlock")}if(e.HAS_GUM_AUDIO&&(c=!1,this.isAccessMicrophonePermission=!0),e.HAS_GUM_VIDEO&&(d=!1,this.isAccessCameraPermission=!0),r.logger.debug("[device manager] check media device permissions",i,o,c,d),c&&d){try{h=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const i=PE(e.name||e.code||e,e.message);if(i.code===t.AgoraRTCErrorCode.PERMISSION_DENIED)throw i;r.logger.warning("getUserMedia failed in getDevices",i)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(c){try{u=await navigator.mediaDevices.getUserMedia({audio:i})}catch(e){const i=PE(e.name||e.code||e,e.message);if(i.code===t.AgoraRTCErrorCode.PERMISSION_DENIED)throw i;r.logger.warning("getUserMedia failed in getDevices",i)}this.isAccessMicrophonePermission=!0}else if(d){try{l=await navigator.mediaDevices.getUserMedia({video:o})}catch(e){const i=PE(e.name||e.code||e,e.message);if(i.code===t.AgoraRTCErrorCode.PERMISSION_DENIED)throw i;r.logger.warning("getUserMedia failed in getDevices",i)}this.isAccessCameraPermission=!0}r.logger.debug("[device manager] mic permission",i,"cam permission",o)}try{const e=await navigator.mediaDevices.enumerateDevices();return u&&u.getTracks().forEach((e=>e.stop())),l&&l.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),u=null,l=null,h=null,e}catch(e){u&&u.getTracks().forEach((e=>e.stop())),l&&l.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),u=null,l=null,h=null;return new t.AgoraRTCError(t.AgoraRTCErrorCode.ENUMERATE_DEVICES_FAILED,e.toString()).throw()}}async getRecordingDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audioinput"===e.kind))}async getCamerasDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!1,!0,e)).filter((e=>"videoinput"===e.kind))}async getSpeakers(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audiooutput"===e.kind))}searchDeviceIdByName(e){let t=null;return this.deviceInfoMap.forEach((r=>{r.device.label===e&&(t=r.device.deviceId)})),t}async getDeviceById(e){const r=(await this.enumerateDevices(!0,!0,!0)).find((t=>t.deviceId===e));if(!r)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return r}async init(){this.state=e.DeviceManagerState.INITING;try{await this.updateDevicesInfo(),this.state=e.DeviceManagerState.INITEND}catch(i){if(r.logger.warning("Device Detection functionality cannot start properly.",i.toString()),this.state=e.DeviceManagerState.IDLE,!t.detectSecureContext()){new t.AgoraRTCError(t.AgoraRTCErrorCode.WEB_SECURITY_RESTRICT,"Your context is limited by web security, please try using https protocol or localhost.").throw()}throw i}}async updateDevicesInfo(){const t=await this.enumerateDevices(!0,!0,!0),i=Date.now(),o=[];if(t[0]&&t[0].label&&!1===this.checkdeviceMatched){this.checkdeviceMatched=!0;const e=t.find((e=>"audioinput"===e.kind&&"default"===e.deviceId)),i=t.find((e=>"audiooutput"===e.kind&&"default"===e.deviceId));e&&i?i.groupId===e.groupId?r.logger.debug("[device-check] default input ".concat(e.label," and output ").concat(i.label," is the same group")):r.logger.warning("[device-check] default input ".concat(e.label," and output ").concat(i.label," is not the same group")):r.logger.debug("[device-check] default input or output not found")}const n=this.checkMediaDeviceInfoIsOk(t);if(t.forEach((e=>{if(!e.deviceId)return;const t=this.deviceInfoMap.get("".concat(e.kind,"_").concat(e.deviceId));if("ACTIVE"!==(t?t.state:"INACTIVE")){const t={initAt:i,updateAt:i,device:e,state:"ACTIVE"};this.deviceInfoMap.set("".concat(e.kind,"_").concat(e.deviceId),t),o.push(t)}t&&(t.updateAt=i)})),this.deviceInfoMap.forEach(((e,t)=>{"ACTIVE"===e.state&&e.updateAt!==i&&(e.state="INACTIVE",o.push(e))})),this.state!==e.DeviceManagerState.INITEND)return n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),void(n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0));o.forEach((t=>{switch(t.device.kind){case"audioinput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(e.DeviceManagerEvent.RECORDING_DEVICE_CHANGED,t);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(e.DeviceManagerEvent.CAMERA_DEVICE_CHANGED,t);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(e.DeviceManagerEvent.PLAYOUT_DEVICE_CHANGED,t)}})),n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0)}checkMediaDeviceInfoIsOk(e){const t=e.filter((e=>"audioinput"===e.kind)),r=e.filter((e=>"videoinput"===e.kind)),i={audio:!1,video:!1};for(const e of t)if(e.label&&e.deviceId){i.audio=!0;break}for(const e of r)if(e.label&&e.deviceId){i.video=!0;break}return i}}const VE=new LE;class xE extends t.EventEmitter{constructor(){super(...arguments),this.onAutoplayFailed=void 0,this.onAudioAutoplayFailed=void 0}}let UE=!1;const BE=new xE;function FE(){if(t.getBrowserInfo(),!UE){const e=r=>{r.preventDefault(),UE=!1,t.isAndroidChromium()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};UE=!0,t.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),r.logger.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),BE.onAutoplayFailed?BE.onAutoplayFailed():BE.onAudioAutoplayFailed?r.logger.warning("AgoraRTC.onAudioAutoplayFailed has been deprecated in favor of AgoraRTC.onAutoplayFailed.\n\n Please refer to the Agora document to migrate the newer API, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."):r.logger.warning("We have detected a media autoplay failed event, and found out that you haven't implemented AgoraRTC.onAutoplayFailed callback yet.\n\n It will cause audio/video element not playing automatically on some browsers without user interaction, possibly hurting user experiences.\n\n Please refer to the Agora document to properly handle autoplay failed event, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."),BE.emit("autoplay-failed")}}function jE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function HE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?jE(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):jE(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function GE(e,t,i,o){if(!e)return;const n=r.report.getBaseInfoBySessionId(e);if(!n)return;const a=n.info,s=Date.now(),c=HE(HE({},a),{},{vid:void 0===a.vid?0:Number(a.vid),lts:s,elapse:s-n.startTime,cbRegistered:BE.onAutoplayFailed||BE.onAudioAutoplayFailed?1:-1,errorMsg:i,mediaType:t,trackId:o,extend:void 0});r.report.send({type:r.AgoraRTCEventUploadType.AUTOPLAY_FAILED,data:c},!0)}const WE=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],KE=new class{constructor(){this.onAutoplayFailed=void 0,this.elementMap=new Map,this.elementStateMap=new Map,this.elementsNeedToResume=[],this.sinkIdMap=new Map,this.autoResumeAfterInterruption=()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[i,o]=e;const n=this.elementStateMap.get(i),a=o.srcObject.getAudioTracks()[0];t.isIOS15()?a&&"live"===a.readyState&&"running"===Qf.curState&&(r.logger.debug("auto resume after interruption for iOS 15"),o.pause(),o.play()):n&&"paused"===n&&a&&"live"===a.readyState&&"running"===Qf.curState&&(r.logger.debug("auto resume after interruption for iOS"),o.play())}))},this.autoResumeAfterInterruptionOnIOS15_16=()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[t,i]=e;const o=i.srcObject.getAudioTracks()[0];o&&"live"===o.readyState&&(r.logger.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))},this.autoResumeAudioElement(),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),Qf.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,(()=>{t.isIOS()&&"suspended"===Qf.prevState&&"running"===Qf.curState&&this.autoResumeAfterInterruption()}))}async setSinkID(e,r){const i=this.elementMap.get(e);if(this.sinkIdMap.set(e,r),i)try{await i.setSinkId(r)}catch(e){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(i,o,n,a){if(this.elementMap.has(o))return;const s=document.createElement("audio");s.autoplay=!0,s.srcObject=new MediaStream([i]),this.bindAudioElementEvents(o,s),this.elementMap.set(o,s),this.elementStateMap.set(o,e.MediaElementStatus.INIT),this.setVolume(o,n);const c=this.sinkIdMap.get(o);if(c)try{s.setSinkId(c).catch((e=>{r.logger.warning("[".concat(o,"] set sink id failed"),e.toString())}))}catch(e){r.logger.warning("[".concat(o,"] set sink id failed"),e.toString())}const d=s.play();d&&d.then&&d.catch((e=>{a&&GE(a,"audio",e.message,o),r.logger.warning("audio element play warning",e.toString()),this.elementMap.has(o)&&"NotAllowedError"===e.name&&(r.logger.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(s),t.nextTick((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),FE()})))}))}updateTrack(e,t){const r=this.elementMap.get(e);r&&(r.srcObject=new MediaStream([t]))}isPlaying(e){return this.elementMap.has(e)&&"playing"===this.elementStateMap.get(e)}setVolume(e,t){const r=this.elementMap.get(e);r&&(t=Math.max(0,Math.min(100,t)),r.volume=t/100)}stop(e){const t=this.elementMap.get(e);if(this.sinkIdMap.delete(e),!t)return;const r=this.elementsNeedToResume.indexOf(t);this.elementsNeedToResume.splice(r,1),t.srcObject=null,t.remove(),this.elementMap.delete(e),this.elementStateMap.delete(e)}bindAudioElementEvents(e,t){WE.forEach((i=>{t.addEventListener(i,(i=>{const o=this.elementStateMap.get(e),n="pause"===i.type?"paused":i.type;if(r.logger.debug("[".concat(e,"] audio-element-status change ").concat(o," => ").concat(n)),"error"===i.type){const i=null==t?void 0:t.error;i&&r.logger.error("[".concat(e,"] media error, code: ").concat(i.code,", message: ").concat(i.message))}this.elementStateMap.set(e,n)}))}))}getPlayerState(e){return this.elementStateMap.get(e)||"uninit"}autoResumeAudioElement(){const e=()=>{this.elementsNeedToResume.forEach((e=>{e.play().then((e=>{r.logger.debug("Auto resume audio element success")})).catch((e=>{r.logger.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};t.domLoadedPromise().then((()=>{t.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function zE(){return function(e,i,o){const n=o.value;return"function"==typeof n&&(o.value=function(){this._isClosed&&new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",r.logger);for(var e=arguments.length,i=new Array(e),o=0;o<e;o++)i[o]=arguments[o];const a=n.apply(this,i);return a instanceof Hf?new Hf(((e,t)=>{a.then(e).catch(t)})):a}),o}}var XE=ei("Array").values,qE=mi,JE=ot,YE=f,QE=XE,ZE=Array.prototype,$E={DOMTokenList:!0,NodeList:!0},eT=c((function(e){var t=e.values;return e===ZE||YE(ZE,e)&&t===ZE.values||JE($E,qE(e))?QE:t}));function tT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function rT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?tT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class iT extends t.EventEmitter{constructor(e){super(),this.name="VideoProcessorDestination",this.ID="0",this._source=void 0,this.videoContext=void 0,this.inputTrack=void 0,this.videoContext=e}get kind(){return"video"}get enabled(){return!0}pipe(){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"VideoProcessor cannot unpipe to any other Processor")}enable(){}disable(){}updateInput(t){if(t.context!==this.videoContext)throw new Error("ProcessorContext passed to VideoTrack.processorDestination doesn't match it's belonging VideoTrack's context.\nProbably you are making pipeline like this:\nvideoTrack1.pipe(processor).pipe(videoTrack2.processorDestination).");t.track&&t.track!==this.inputTrack&&(this.videoContext.chained=!0,this.inputTrack=t.track,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,t.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,void 0)}}class oT extends t.EventEmitter{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t){super(),this.constraintsMap=new Map,this.statsRegistry=[],this.usageRegistry=[],this.trackId=void 0,this.direction=void 0,this._chained=!1,this.trackId=e,this.direction=t}async getConstraints(){return await t.emitAsPromise(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}async requestApplyConstraints(i,o){var n;return r.logger.info("processor ".concat(o.name," requestApplyConstraints for ").concat(this.trackId)),i&&this.constraintsMap.set(o,i),t.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(eT(n=this.constraintsMap).call(n)))}async requestRevertConstraints(i){var o;if(this.constraintsMap.has(i))return r.logger.info("processor ".concat(i.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(i),t.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(eT(o=this.constraintsMap).call(o)))}registerStats(e,t,r){this.statsRegistry.find((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:r})}unregisterStats(e,t){const r=this.statsRegistry.findIndex((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t));-1!==r&&this.statsRegistry.splice(r,1)}gatherStats(){const e=[];for(const{processorID:i,processorName:o,type:n,cb:a}of this.statsRegistry)try{const t=a();e.push({processorID:i,processorName:o,type:n,stats:t})}catch(e){r.logger.error(new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let r=t();r instanceof Hf&&(r=await r),e.push(rT(rT({},r),{},{direction:this.direction}))}catch(e){r.logger.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class nT extends t.EventEmitter{constructor(e){super(),this.name="AudioProcessorDestination",this.ID="0",this.inputTrack=void 0,this.inputNode=void 0,this.audioProcessorContext=void 0,this._source=void 0,this.audioProcessorContext=e}get kind(){return"audio"}get enabled(){return!0}pipe(){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"AudioProcessor cannot unpipe to any other Processor")}enable(){}disable(){}reset(){this.inputTrack=void 0,this.inputNode=void 0,this.audioProcessorContext.chained=!1,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,void 0),this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,void 0)}updateInput(t){if(t.context!==this.audioProcessorContext)throw new Error("ProcessorContext passed to AudioTrack.processorDestination doesn't match it's belonging AudioTrack's context.\n Probably you are making pipeline like this: audioTrack1.pipe(processor).pipe(audioTrack2.processorDestination).");t.track&&this.inputTrack!==t.track&&(this.audioProcessorContext.chained=!0,this.inputTrack=t.track,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,this.inputTrack)),t.node&&this.inputNode!==t.node&&(this.audioProcessorContext.chained=!0,this.inputNode=t.node,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,this.inputNode))}}class aT extends t.EventEmitter{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t,r){super(),this.constraintsMap=new Map,this.statsRegistry=[],this.audioContext=void 0,this.trackId=void 0,this.direction=void 0,this.usageRegistry=[],this._chained=!1,this.audioContext=e,this.trackId=t,this.direction=r}async getConstraints(){return t.emitAsPromise(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(i,o){var n;return r.logger.info("processor ".concat(o.name," requestApplyConstraints for ").concat(this.trackId)),i&&this.constraintsMap.set(o,i),t.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(eT(n=this.constraintsMap).call(n)))}async requestRevertConstraints(r){var i;if(this.constraintsMap.has(r))return this.constraintsMap.delete(r),t.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(eT(i=this.constraintsMap).call(i)))}registerStats(e,t,r){this.statsRegistry.find((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:r})}unregisterStats(e,t){const r=this.statsRegistry.findIndex((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t));-1!==r&&this.statsRegistry.splice(r,1)}gatherStats(){const e=[];for(const{processorID:i,processorName:o,type:n,cb:a}of this.statsRegistry)try{const t=a();e.push({processorID:i,processorName:o,type:n,stats:t})}catch(e){r.logger.error(new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let r=t();r instanceof Hf&&(r=await r),e.push(rT(rT({},r),{},{direction:this.direction}))}catch(e){r.logger.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class sT extends t.EventEmitter{get isPlayed(){return!0}get isFreeze(){return!1}constructor(){super(),this.context=void 0,this.processSourceNode=void 0,this.outputTrack=void 0,this.processedNode=void 0,this.clonedTrack=void 0,this.outputNode=void 0,this.outputNode=new cT}setVolume(){}createOutputTrack(){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create output MediaStreamTrack when WebAudio disabled")}getOriginVolumeLevel(){return 0}getAccurateVolumeLevel(){return 0}stopGetAudioBuffer(){}startGetAudioBuffer(){}play(){}stop(){}destroy(){}updateTrack(){}updateOriginTrack(){}createMediaStreamSourceNode(){}}class cT{disconnect(){}connect(){}}let dT=null;class uT{constructor(){this.state="open",this.trigger=void 0,this.tasks=[],r.logger.debug("[macro-task-queue] is created."),this.trigger=window.setTimeout((()=>{this.state="closed",r.logger.debug("[macro-task-queue] will be closed, all remaining tasks will execute. [".concat(this.tasks.map((e=>e.key)),"]")),this.trigger=void 0,this.tasks.forEach((e=>{let{func:t}=e;return t()})),this.tasks.length=0,r.logger.debug("[macro-task-queue] is closed.")}))}enqueue(e,t){"closed"!==this.state&&(this.tasks.push({key:e,func:t}),r.logger.debug("[macro-task-queue] is queued, current queue ".concat(this.tasks.length,". ").concat("string"==typeof e?e:"")))}runTask(e){if("closed"===this.state)return;const t=this.tasks.findIndex((t=>t.key===e));if(-1!==t){const i=this.tasks.splice(t,1);r.logger.debug("[macro-task-queue] is unqueued, current queue ".concat(this.tasks.length,". ").concat("string"==typeof e?e:"")),i[0].func()}}release(){this.trigger&&(this.state="closed",clearTimeout(this.trigger),this.trigger=void 0,this.tasks.length=0,r.logger.debug("[macro-task-queue] is closed."))}}function lT(e){return function(t,r,i){var o;const n=null!==(o=i.value)&&void 0!==o?o:i.get,a=function(){dT&&"open"===dT.state&&dT.runTask(e);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return null==n?void 0:n.apply(this,...r)};return i.value?i.value=a:i.get=a,i}}function hT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function pT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?hT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class gT extends zf{get _source(){return this._trackSource}set _source(e){this._trackSource=e}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get processorDestination(){return this._processorDestination}set processorDestination(e){this._processorDestination=e}get isPlaying(){return this._useAudioElement?KE.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"LocalAudioTrack"}constructor(r,i,o,n,a){super(r,o),this.trackMediaType="audio",this._encoderConfig=void 0,this._trackSource=void 0,this._enabled=!0,this._volume=100,this._useAudioElement=!1,this._bypassWebAudio=!1,this.processor=void 0,this._processorContext=void 0,this._processorDestination=void 0,this._getOriginVolumeLevel=void 0,this._encoderConfig=i,this._getOriginVolumeLevel=!!n;const s=()=>{this.processorContext=new aT(this._source.context,this.getTrackId(),"local"),this.processorDestination=new nT(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(e.AudioSourceEvents.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))},c=a&&t.isSafari()&&!eE();if(t.getParameter("DISABLE_WEBAUDIO")?(this._source=new sT,this._useAudioElement=!0,this._bypassWebAudio=!0):c?this._source=new sT:(this._source=new IE(r,!1,this._getOriginVolumeLevel?r:void 0),t.getParameter("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0)),s(),!t.getParameter("DISABLE_WEBAUDIO")&&c){(dT||(dT=new uT),dT).enqueue("INIT_WEBAUDIO",(()=>{this._source=new IE(r,!1,this._getOriginVolumeLevel?r:void 0),t.getParameter("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0),s(),this.emit(e.AUDIO_TRACK_EVENT.UPDATE_TRACK_SOURCE)}))}}setVolume(i){t.checkValidNumber(i,"volume",0,1e3),this._volume=i,this._source.setVolume(i/100),this._useAudioElement&&KE.setVolume(this.getTrackId(),i);try{if(this._bypassWebAudio)return void r.logger.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const i=this._source.createOutputTrack();this._mediaStreamTrack!==i&&(this._mediaStreamTrack=i,t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this).then((()=>{r.logger.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{r.logger.warning("[".concat(this.getTrackId(),"] replace web audio track failed"),e)})))}catch(e){}}getVolumeLevel(){return this._muted&&this.enabled&&this._getOriginVolumeLevel?this._source.getOriginVolumeLevel():this._source.getAccurateVolumeLevel()}async setPlaybackDevice(e){if(!this._useAudioElement)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser does not support setting the audio output device");await KE.setSinkID(this.getTrackId(),e)}async setEnabled(e,t,r){return this._setEnabled(e,t,r)}async _setEnabled(i,o,n){if(!n){if(i===this._enabled)return;this.stateCheck("enabled",i)}if(r.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),i),i){this._originMediaStreamTrack.enabled=!0;try{n||(this._enabled=!0),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this),r.logger.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(i," success"))}catch(e){throw n||(this._enabled=!1),r.logger.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,n||(this._enabled=!1);try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw n||(this._enabled=!0),r.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}}}async setMuted(i){i!==this._muted&&(this.stateCheck("muted",i),this._muted=i,this._originMediaStreamTrack.enabled=!i,r.logger.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(i)),i?await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_MUTE_TRACK,this):await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UNMUTE_TRACK,this))}getStats(){t.runOnce((()=>{r.logger.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const i=t.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS);return i||pT({},ao)}setAudioFrameCallback(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!t)return this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(r),this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),this._source.on(e.AudioSourceEvents.ON_AUDIO_BUFFER,(e=>t(e)))}play(){r.logger.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(r.logger.debug("[".concat(this.getTrackId(),"] start audio playback in element")),KE.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){r.logger.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?KE.stop(this.getTrackId()):this._source.stop()}close(){super.close(),this.unbindProcessorDestinationEvents(),this.unbindProcessorContextEvents(),this.unpipe(),this.processorDestination._source&&this.processorDestination._source.unpipe(),this._source.destroy()}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];r.logger.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&KE.updateTrack(this.getTrackId(),this._mediaStreamTrack)}async _updateOriginMediaStreamTrack(r,i){this._originMediaStreamTrack!==r&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),i&&this._originMediaStreamTrack.stop()),r.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=r,this._muted&&(this._originMediaStreamTrack.enabled=!1),this.processor&&this.processor.updateInput({track:r,context:this.processorContext}),this._mediaStreamTrack!==this._source.outputTrack?(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(r))}renewMediaStreamTrack(e){return Hf.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(!this.processor)return;const t=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,t.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async r=>{r?r!==this._mediaStreamTrack&&(this._mediaStreamTrack=r,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(r),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this))})),this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK),this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}}Gf([lT("INIT_WEBAUDIO"),Wf("design:type",Object),Wf("design:paramtypes",[Object])],gT.prototype,"_source",null),Gf([lT("INIT_WEBAUDIO"),Wf("design:type",aT),Wf("design:paramtypes",[aT])],gT.prototype,"processorContext",null),Gf([lT("INIT_WEBAUDIO"),Wf("design:type",nT),Wf("design:paramtypes",[nT])],gT.prototype,"processorDestination",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),Wf("design:type",Function),Wf("design:paramtypes",[Number]),Wf("design:returntype",void 0)],gT.prototype,"setVolume",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[String]),Wf("design:returntype",Hf)],gT.prototype,"setPlaybackDevice",null),Gf([t.atom("LocalAudioTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean,Object,Boolean]),Wf("design:returntype",Hf)],gT.prototype,"setEnabled",null),Gf([t.atom("LocalAudioTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean]),Wf("design:returntype",Hf)],gT.prototype,"setMuted",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",Object)],gT.prototype,"getStats",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object,Number]),Wf("design:returntype",void 0)],gT.prototype,"setAudioFrameCallback",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],gT.prototype,"play",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],gT.prototype,"stop",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],gT.prototype,"close",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Object)],gT.prototype,"pipe",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],gT.prototype,"unpipe",null);class mT extends gT{get __className__(){return"MicrophoneAudioTrack"}constructor(r,i,o,n){super(r,i.encoderConfig?Ki(i.encoderConfig):{},n,t.getParameter("GET_VOLUME_OF_MUTED_AUDIO_TRACK"),!0),this._config=void 0,this._deviceName="default",this._constraints=void 0,this._originalConstraints=void 0,this._enabled=!0,this._config=i,this._constraints=o,this._originalConstraints=o,this._deviceName=r.label,"boolean"==typeof i.bypassWebAudio&&(this._bypassWebAudio=i.bypassWebAudio),(t.isIOS15()||t.isIOS16())&&Qf.bindInterruptDetectorTrack(this),this.on(e.AUDIO_TRACK_EVENT.UPDATE_TRACK_SOURCE,(()=>{this.bindProcessorContextEvents()})),eE()&&this.bindProcessorContextEvents()}async setDevice(e){if(r.logger.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await VE.getDeviceById(e),i={};i.audio=pT({},this._constraints),i.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let o=null;try{o=await wE(i,this.getTrackId())}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),o=await wE({audio:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(o.getAudioTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(o.getAudioTracks()[0],!1),this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await VE.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(i,o,n){if(o)return r.logger.debug("[".concat(this.getTrackId(),"] setEnabled false (do not close microphone)")),await super._setEnabled(i);if(!n){if(i===this._enabled)return;this.stateCheck("enabled",i)}if(r.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),i),!i){var a;this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop(),null===(a=this._source.clonedTrack)||void 0===a||a.stop(),n||(this._enabled=!1);try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const s=pT({},this._constraints),c=VE.searchDeviceIdByName(this._deviceName);c&&!s.deviceId&&(s.deviceId=c);try{n||(this._enabled=!0);const r=await wE({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(r.getAudioTracks()[0],!1),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw n||(this._enabled=!1),r.logger.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(t.isIOS15()||t.isIOS16())&&Qf.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((t.isIOS()||t.isIpadOS())&&this._enabled&&!this._isClosed&&Qf.duringInterruption){const t=async()=>{Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t),this._enabled&&!this._isClosed&&(r.logger.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t)}else r.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,r=VE.searchDeviceIdByName(this._deviceName);if(r&&!t.deviceId&&(t.deviceId=r),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await wE({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(){this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,r)=>{try{const r=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(r),t()}catch(e){r(e)}})),this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[String]),Wf("design:returntype",Hf)],mT.prototype,"setDevice",null),Gf([t.atom("MicrophoneAudioTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t,r]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean,Boolean,Boolean]),Wf("design:returntype",Hf)],mT.prototype,"setEnabled",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],mT.prototype,"close",null);class fT extends gT{get __className__(){return"BufferSourceAudioTrack"}constructor(t,r,i,o){super(r.createOutputTrack(),i,o),this.source=void 0,this._bufferSource=void 0,this.source=t,this._bufferSource=r,this._bufferSource.on(e.AudioSourceEvents.AUDIO_SOURCE_STATE_CHANGE,(t=>{this.safeEmit(e.LocalTrackEvents.SOURCE_STATE_CHANGE,t)}));try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}}get currentState(){return this._bufferSource.currentState}get duration(){return this._bufferSource.duration}get playbackSpeed(){return this._bufferSource.playbackSpeed}getCurrentTime(){return this._bufferSource.currentTime}startProcessAudioBuffer(e){e&&this._bufferSource.updateOptions(e),this._bufferSource.startProcessAudioBuffer()}pauseProcessAudioBuffer(){this._bufferSource.pauseProcessAudioBuffer()}seekAudioBuffer(e){this._bufferSource.seekAudioBuffer(e)}resumeProcessAudioBuffer(){this._bufferSource.resumeProcessAudioBuffer()}stopProcessAudioBuffer(){this._bufferSource.stopProcessAudioBuffer()}close(){this.source=null,this._bufferSource.destroy(),super.close()}setAudioBufferPlaybackSpeed(e){t.checkValidNumber(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",void 0)],fT.prototype,"startProcessAudioBuffer",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],fT.prototype,"pauseProcessAudioBuffer",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Number]),Wf("design:returntype",void 0)],fT.prototype,"seekAudioBuffer",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],fT.prototype,"resumeProcessAudioBuffer",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],fT.prototype,"stopProcessAudioBuffer",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],fT.prototype,"close",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Number]),Wf("design:returntype",void 0)],fT.prototype,"setAudioBufferPlaybackSpeed",null);class ET extends gT{get __className__(){return"MixingAudioTrack"}get isActive(){for(const e of this.trackList)if(e._enabled&&!e._isClosed&&!e.muted)return!0;return!1}constructor(){const e=$f().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,t.getRandomString(8,"track-mix-")),this.trackList=void 0,this.destNode=void 0;try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}this.destNode=e,this.trackList=[]}hasAudioTrack(e){return-1!==this.trackList.indexOf(e)}addAudioTrack(e){-1===this.trackList.indexOf(e)?(r.logger.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):r.logger.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){r.logger.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}t.removeItemFromList(this.trackList,e),this.updateEncoderConfig()}}updateEncoderConfig(){const e={};this.trackList.forEach((t=>{t._encoderConfig&&((t._encoderConfig.bitrate||0)>(e.bitrate||0)&&(e.bitrate=t._encoderConfig.bitrate),(t._encoderConfig.sampleRate||0)>(e.sampleRate||0)&&(e.sampleRate=t._encoderConfig.sampleRate),(t._encoderConfig.sampleSize||0)>(e.sampleSize||0)&&(e.sampleSize=t._encoderConfig.sampleSize),t._encoderConfig.stereo&&(e.stereo=!0))})),this._encoderConfig=e}_updateRtpTransceiver(t){this._rtpTransceiver!==t&&(this._rtpTransceiver=t,this.trackList.forEach((r=>{r instanceof ET?r.emit(e.TrackEvents.TRANSCEIVER_UPDATED,t):r._updateRtpTransceiver(t)})))}}function TT(e){const r={};e.facingMode&&(r.facingMode=e.facingMode),e.cameraId&&(r.deviceId={exact:e.cameraId});const i=ji(e.encoderConfig);return null!=i.width&&(r.width=i.width),null!=i.height&&(r.height=i.height),!t.isLegacyChrome()&&i.frameRate&&(r.frameRate=i.frameRate),t.isEdge()&&"object"==typeof r.frameRate&&(r.frameRate.max=60),t.isFirefox()&&(r.frameRate={ideal:30,max:30}),r}function vT(e){const r={};e.screenSourceType&&(r.mediaSource=e.screenSourceType),e.extensionId&&t.isChrome()&&(r.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:o,surfaceSwitching:n,systemAudio:a}=e;(t.isAboveChrome(107)||t.isAboveEdge(107)||t.isAboveOpera(93))&&(i&&(t.checkValidEnum(i,"displaySurface",["browser","window","monitor"]),r.displaySurface=i),o?(t.checkValidEnum(o,"selfBrowserSurface",["exclude","include"]),r.selfBrowserSurface=o):r.selfBrowserSurface="include",n&&(t.checkValidEnum(n,"surfaceSwitching",["exclude","include"]),r.surfaceSwitching=n)),(t.isAboveChrome(105)||t.isAboveEdge(105)||t.isAboveOpera(91))&&a&&(t.checkValidEnum(a,"systemAudio",["exclude","include"]),r.systemAudio=a),e.electronScreenSourceId&&(r.sourceId=e.electronScreenSourceId);const s=e.encoderConfig?Hi(e.encoderConfig):null;return r.mandatory={chromeMediaSource:"desktop",maxWidth:s?s.width:void 0,maxHeight:s?s.height:void 0},s&&(s.frameRate&&("number"==typeof s.frameRate?(r.mandatory.maxFrameRate=s.frameRate,r.mandatory.minFrameRate=s.frameRate):(r.mandatory.maxFrameRate=s.frameRate.max||s.frameRate.ideal||s.frameRate.exact||void 0,r.mandatory.minFrameRate=s.frameRate.min||s.frameRate.ideal||s.frameRate.exact||void 0),r.frameRate=s.frameRate),s.width&&(r.width=s.width),s.height&&(r.height=s.height)),r}function _T(e){const r={};if(t.isLegacyChrome()||(void 0!==e.AGC&&(r.autoGainControl=e.AGC),void 0!==e.AEC&&(r.echoCancellation=e.AEC),void 0!==e.ANS&&(r.noiseSuppression=e.ANS,t.isChrome()&&e.ANS&&(r.googHighpassFilter=e.ANS))),e.encoderConfig){const t=Ki(e.encoderConfig);r.channelCount=t.stereo?2:1,r.sampleRate=t.sampleRate,r.sampleSize=t.sampleSize}return e.microphoneId&&(r.deviceId={exact:e.microphoneId}),t.isAndroid()&&(r.sampleRate=void 0),r}class yT extends bE{set currentState(t){t!==this._currentState&&(this._currentState=t,this.safeEmit(e.AudioSourceEvents.AUDIO_SOURCE_STATE_CHANGE,this._currentState))}get currentState(){return this._currentState}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.audioBuffer=void 0,this.sourceNode=void 0,this.startPlayTime=0,this.startPlayOffset=0,this.pausePlayTime=0,this.options=void 0,this.currentLoopCount=0,this.currentPlaybackSpeed=100,this._currentState="stopped",this.audioBuffer=e,this.options=t,this.startPlayOffset=this.options.startPlayTime||0}createWebAudioDiagram(){return this.context.createGain()}get duration(){return this.audioBuffer?this.audioBuffer.duration:0}get playbackSpeed(){return this.currentPlaybackSpeed}get currentTime(){return this.audioBuffer?"stopped"===this.currentState?0:"paused"===this.currentState?this.pausePlayTime:((this.context.currentTime-this.startPlayTime)*(this.playbackSpeed/100)+this.startPlayOffset)%this.audioBuffer.duration:0}updateOptions(e){"stopped"===this.currentState?(this.options=e,this.startPlayOffset=this.options.startPlayTime||0):r.logger.warning("can not set audio source options")}startProcessAudioBuffer(){this.sourceNode&&this.stopProcessAudioBuffer(),this.sourceNode=this.createSourceNode(),this.startSourceNode(),this.currentState="playing"}pauseProcessAudioBuffer(){this.sourceNode&&"playing"===this.currentState&&(this.pausePlayTime=this.currentTime,this.sourceNode.onended=null,this.sourceNode.stop(),this.sourceNode.buffer=null,this.sourceNode=this.createSourceNode(),this.currentState="paused")}seekAudioBuffer(e){this.sourceNode&&(this.sourceNode.onended=null,"playing"===this.currentState&&this.sourceNode.stop(),this.sourceNode=this.createSourceNode(),"playing"===this.currentState?(this.startPlayOffset=e,this.startSourceNode()):"paused"===this.currentState&&(this.pausePlayTime=e))}resumeProcessAudioBuffer(){"paused"===this.currentState&&this.sourceNode&&(this.startPlayOffset=this.pausePlayTime,this.pausePlayTime=0,this.startSourceNode(),this.currentState="playing")}stopProcessAudioBuffer(){if(this.sourceNode){this.sourceNode.onended=null;try{this.sourceNode.stop()}catch(e){}this.reset()}}destroy(){this.audioBuffer=null,super.destroy()}setAudioBufferPlaybackSpeed(e){this.sourceNode&&("playing"===this.currentState&&(this.startPlayOffset=this.currentTime,this.startPlayTime=this.context.currentTime),this.sourceNode.playbackRate.value=e/100),this.currentPlaybackSpeed=e}startSourceNode(){this.sourceNode&&this.sourceNode.buffer&&(this.sourceNode.start(0,this.startPlayOffset),this.startPlayTime=this.context.currentTime,this.sourceNode.onended=this.handleSourceNodeEnded.bind(this))}createSourceNode(){const e=this.context.createBufferSource();return e.buffer=this.audioBuffer,e.loop=!!this.options.loop,e.connect(this.outputNode),e.playbackRate.value=this.currentPlaybackSpeed/100,e}handleSourceNodeEnded(){if(this.currentLoopCount+=1,this.options.cycle&&this.options.cycle>this.currentLoopCount)return this.startPlayOffset=0,this.sourceNode=void 0,void this.startProcessAudioBuffer();this.reset()}reset(){this.startPlayOffset=this.options.startPlayTime||0,this.currentState="stopped",this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=void 0),this.currentLoopCount=0}}const ST=new Map;const AT=e=>{const r=document.createElement("canvas");return r.width=2,r.height=2,new Hf(((i,o)=>{r.toBlob((async e=>{if(r.remove(),e){const t=await bT(e);i({buffer:t,width:r.width,height:r.height})}else o(new t.AgoraRTCError(t.AgoraRTCErrorCode.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},bT=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};class IT extends t.EventEmitter{get visibility(){return document.visibilityState}get lastHiddenTime(){return this._lastHiddenTime}get lastVisibleTime(){return this._lastVisibleTime}constructor(){super(),this._lastHiddenTime=0,this._lastVisibleTime=0,document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState?this._lastHiddenTime=performance.now():this._lastVisibleTime=performance.now(),r.logger.debug("document visibility went ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}}const kT=new IT;function CT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function OT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?CT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):CT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class RT{get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(r.logger.debug("[".concat(this.trackId,"] video-element-status change ").concat(this._videoElementStatus," => ").concat(e)),this._videoElementStatus=e)}constructor(i){this.trackId=void 0,this.config=void 0,this.onFirstVideoFrameDecoded=void 0,this.freezeTimeCounterList=[],this.renderFreezeAccTime=0,this.isKeepLastFrame=!1,this.timeUpdatedCount=0,this.freezeTime=0,this.playbackTime=0,this.lastTimeUpdatedTime=0,this.autoplayFailed=!1,this.videoTrack=void 0,this.videoElement=void 0,this.cacheVideoElement=void 0,this.videoElementCheckInterval=void 0,this._videoElementStatus=e.MediaElementStatus.NONE,this.isGettingVideoDimensions=!1,this.startGetVideoDimensions=()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return r.logger.debug("[".concat(this.trackId,"] current video dimensions:"),this.videoElement.videoWidth,this.videoElement.videoHeight),void(this.isGettingVideoDimensions=!1);setTimeout(e,500)};!this.isGettingVideoDimensions&&e()},this.autoResumeAfterInterruption=()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&"running"===Qf.curState&&(r.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(t.getOSWithVersion())),t.isAboveIOS15_1()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.handleVideoEvents=i=>{switch(i.type){case"play":case"playing":this.startGetVideoDimensions(),this.videoElementStatus=e.MediaElementStatus.PLAYING;break;case"loadeddata":if(this.onFirstVideoFrameDecoded&&this.onFirstVideoFrameDecoded(),this.cacheVideoElement){try{this.cacheVideoElement.srcObject=null,this.cacheVideoElement.remove()}catch(e){}this.cacheVideoElement=void 0}break;case"canplay":this.videoElementStatus=e.MediaElementStatus.CANPLAY;break;case"stalled":this.videoElementStatus=e.MediaElementStatus.STALLED;break;case"suspend":this.videoElementStatus=e.MediaElementStatus.SUSPEND;break;case"pause":this.videoElementStatus=e.MediaElementStatus.PAUSED,t.isIOS()||t.isIpadOS()||t.isSafari()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(r.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=e.MediaElementStatus.WAITING;break;case"abort":this.videoElementStatus=e.MediaElementStatus.ABORT;break;case"ended":this.videoElementStatus=e.MediaElementStatus.ENDED;break;case"emptied":this.videoElementStatus=e.MediaElementStatus.EMPTIED;break;case"error":{this.videoElementStatus=e.MediaElementStatus.ERROR;const t=this.videoElement.error;t&&r.logger.error("[".concat(this.trackId,"] media error, code: ").concat(t.code,", message: ").concat(t.message));break}case"timeupdate":{const e=performance.now();if(this.timeUpdatedCount+=1,this.timeUpdatedCount<10)return void(this.lastTimeUpdatedTime=e);const r=e-this.lastTimeUpdatedTime,i=this.lastTimeUpdatedTime;if(this.lastTimeUpdatedTime=e,kT.lastVisibleTime<kT.lastHiddenTime||i<kT.lastHiddenTime||i<kT.lastVisibleTime)return;for(r>t.getParameter("VIDEO_FREEZE_DURATION")&&(this.freezeTime+=r),this.playbackTime+=r;this.playbackTime>=6e3;){this.playbackTime-=6e3;const e=Math.min(6e3,this.freezeTime);this.freezeTimeCounterList.push(e),this.freezeTime=Math.max(0,this.freezeTime-6e3)}break}}},this.autoResumeAfterInterruptionOnIOS15_16=()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&(r.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(t.getOSWithVersion())),t.isAboveIOS15_1()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.trackId=i.trackId,this.config=i,i.element instanceof HTMLVideoElement?this.videoElement=i.element:this.videoElement=document.createElement("video"),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16)}getVideoElement(){return this.videoElement}getContainerElement(){var e;return null!==(e=this.videoElement.parentElement)&&void 0!==e?e:void 0}updateConfig(e){this.config=e,this.trackId=e.trackId,e.element!==this.videoElement&&(this.destroy(),this.videoElement=e.element),this.videoTrack&&this.initVideoElement()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.initVideoElement())}play(e){const i=this.videoElement.play();i&&i.catch&&i.catch((t=>{e&&GE(e,"video",t.message,this.trackId),"NotAllowedError"===t.name?(r.logger.warning("detected video element autoplay failed",t),this.autoplayFailed=!0,this.handleAutoPlayFailed()):r.logger.warning("[".concat(this.trackId,"] play warning: "),t)}));const o=t.getBrowserInfo();if(("Safari"===o.name&&15===Number(o.version)||t.isIOS15())&&i&&i.then){const e=()=>{this.config.mirror&&(this.videoElement.style.transform="rotateY(180deg)")};i.then(e).catch(e)}}getCurrentFrame(){const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight;const t=e.getContext("2d");if(!t)return r.logger.error("create canvas context failed!"),new ImageData(2,2);t.drawImage(this.videoElement,0,0,e.width,e.height);const i=t.getImageData(0,0,e.width,e.height);return e.remove(),i}async getCurrentFrameToUint8Array(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=document.createElement("canvas");i.width=this.videoElement.videoWidth,i.height=this.videoElement.videoHeight;const o=i.getContext("2d");return o?(o.drawImage(this.videoElement,0,0,i.width,i.height),new Hf(((o,n)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await bT(e);o({buffer:t,width:i.width,height:i.height})}else n(new t.AgoraRTCError(t.AgoraRTCErrorCode.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,r<0?.1:r>1?1:r)}))):await AT(e)}destroy(){Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[]}initVideoElement(){if(this.videoElementStatus=e.MediaElementStatus.INIT,!this.videoElementCheckInterval&&(NT.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{t.isInPage(this.videoElement)||(this.videoElementStatus=e.MediaElementStatus.DESTROYED)}),1e3),t.getParameter("ENABLE_VIDEO_FRAME_CALLBACK"))){var i,o;let r;const n=(i,o)=>{if(this.videoElementStatus===e.MediaElementStatus.PLAYING){if(r){const e=o.presentationTime-r.presentationTime;e>t.getParameter("VIDEO_FREEZE_DURATION")&&kT.lastVisibleTime>=kT.lastHiddenTime&&r.timestamp>kT.lastVisibleTime&&r.timestamp>kT.lastHiddenTime&&(this.renderFreezeAccTime+=e)}r=OT(OT({},o),{},{timestamp:i})}var a,s;t.getParameter("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(a=(s=this.videoElement).requestVideoFrameCallback)||void 0===a||a.call(s,n))};null===(i=(o=this.videoElement).requestVideoFrameCallback)||void 0===i||i.call(o,n)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),t.isAndroid()&&(this.videoElement.poster="noposter");const n=t.getBrowserInfo();if("Safari"===n.name&&15===Number(n.version)||t.isIOS15()||!this.config.mirror||(this.videoElement.style.transform="rotateY(180deg)"),this.config.fit?this.videoElement.style.objectFit=this.config.fit:this.videoElement.style.objectFit="cover",this.videoElement.setAttribute("muted",""),this.videoElement.muted=!0,this.videoElement.srcObject&&this.videoElement.srcObject instanceof MediaStream){this.videoElement.srcObject.getVideoTracks()[0]!==this.videoTrack&&(this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,t.isFirefox()&&this.videoElement.load())}else this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,t.isFirefox()&&this.videoElement.load();const a=this.videoElement.play();void 0!==a&&a.catch((e=>{r.logger.debug("[".concat(this.trackId,"] playback interrupted"),e.toString())}))}resetVideoElement(){NT.forEach((e=>{this.videoElement&&this.videoElement.removeEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval&&(window.clearInterval(this.videoElementCheckInterval),this.videoElementCheckInterval=void 0),this.videoElementStatus=e.MediaElementStatus.NONE}handleAutoPlayFailed(){const e=i=>{i.preventDefault(),this.videoElement.play().then((()=>{r.logger.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{r.logger.error(e)})),this.autoplayFailed=!1,t.isAndroidChromium()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};t.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),FE()}}const NT=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class wT extends RT{constructor(e){super(e),this.container=void 0,this.slot=void 0,this.slot=e.element,this.updateConfig(e)}updateConfig(e){this.config=e,this.trackId=e.trackId;const t=e.element;t!==this.slot&&(this.destroy(),this.slot=t),this.createElements()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.createElements())}play(e){var t;null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)&&super.play(e)}getCurrentFrame(){var e;return null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)?super.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameToUint8Array(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)?await super.getCurrentFrameToUint8Array(e,r):await AT(e)}destroy(){if(super.destroy(),this.videoElement.remove(),this.videoElement=document.createElement("video"),this.container){try{this.container.remove(),this.slot.removeChild(this.container)}catch(e){}this.container=void 0}}createElements(){this.container||(this.container=document.createElement("div")),this.container.id="agora-video-player-".concat(this.trackId),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.overflow="hidden",this.videoTrack?(this.container.style.backgroundColor="black",t.getParameter("KEEP_LAST_FRAME")&&this.isKeepLastFrame&&this.videoElement.paused&&this.resetVideoElement(),this.mountedVideoElement()):this.unmountedVideoElement(),this.slot.appendChild(this.container)}mountedVideoElement(){var e;!this.container||null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)||this.container.appendChild(this.videoElement),super.initVideoElement(),this.videoElement.id="video_".concat(this.trackId),this.videoElement.className="agora_video_player",this.videoElement.style.width="100%",this.videoElement.style.height="100%",this.videoElement.style.position="absolute",this.videoElement.style.left="0",this.videoElement.style.top="0"}unmountedVideoElement(){var e;if(null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)){super.resetVideoElement();try{this.container&&this.container.removeChild(this.videoElement)}catch(e){}this.videoElement=document.createElement("video")}}resetVideoElement(){var e;null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)&&(super.resetVideoElement(),this.cacheVideoElement=this.videoElement,this.videoElement=document.createElement("video"))}getContainerElement(){return this.container}}function DT(e){return new Hf(((r,i)=>{let o=!1;const n=document.createElement("video");n.setAttribute("autoplay",""),n.setAttribute("muted",""),n.muted=!0,n.autoplay=!0,n.setAttribute("playsinline",""),n.setAttribute("style","position: fixed; top: 0; left: 0; width: 1px; height: 1px"),document.body.appendChild(n);const a=t.isIOS()?"canplay":"playing";n.addEventListener(a,(()=>{const e=n.videoWidth,i=n.videoHeight;!e&&t.isFirefox()||(o=!0,n.srcObject=null,n.remove(),r([e,i]))})),n.srcObject=new MediaStream([e]),n.play().catch(t.noop),setTimeout((()=>{o||(n.srcObject=null,n.remove(),r([n.videoWidth,n.videoHeight]))}),4e3)}))}function PT(e,t,r,i){let o;const n=200*Math.pow(r/15,.6)*Math.pow(e*t/640/360,.75),a=n;if("STANDARD_BITRATE"===i)o=4*n;else{if("COMPATIABLE_BITRATE"!==i)return;o=2*n}return[Math.floor(o),Math.floor(a)]}function MT(e,t){if("VideoFrame"in window&&"TransformStream"in window&&sE().supportWebRTCInsertableStream){const r=new MediaStreamTrackProcessor(e),i=new MediaStreamTrackGenerator({kind:"video"});let o,n,a=Date.now();const s=()=>{c&&(clearInterval(c),c=void 0),o&&(o.close(),o=void 0),e.stop(),n=void 0,i.removeEventListener("ended",s)};let c=window.setInterval((()=>{if(n&&o&&Date.now()-a>(null!=t?t:1e3))try{"live"===i.readyState?n.enqueue(o.clone()):s()}catch(e){s()}}),null!=t?t:1e3);const d=new TransformStream({transform:(e,t)=>{"live"===i.readyState?(n=t,a=Date.now(),void 0===o?(o=e,t.enqueue(e.clone())):(t.enqueue(o),o=e)):e.close()}});return i.addEventListener("ended",s),r.readable.pipeThrough(d).pipeTo(i.writable),i}}function LT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function VT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?LT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):LT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class xT extends zf{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==e.MediaElementStatus.PLAYING)}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(i,o,n,a,s,c){if(super(i,s),this.trackMediaType="video",this._player=void 0,this.isUseScaleResolutionDownBy=!1,this._videoVisibleTimer=null,this._statsTimer=null,this._previousVideoVisibleStatus=void 0,this._clearPreviousVideoVisibleStatus=()=>this._previousVideoVisibleStatus=void 0,this._encoderConfig=void 0,this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1},this._optimizationMode=void 0,this._videoHeight=void 0,this._videoWidth=void 0,this._forceBitrateLimit=void 0,this._enabled=!0,this.processorDestination=void 0,this._processorContext=void 0,t.isSafari()){const{width:e,height:t}=i.getSettings();this._videoWidth=e,this._videoHeight=t}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=o,this._scalabilityMode=n,this._optimizationMode=a,this._hints=c||[],-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK))this.updateBitrateFromProfile();else if(t.isBetweenBrowser(t.BrowserName.CHROME,115)&&t.isWindows()){const e=MT(i);e&&(r.logger.info("local screen video track begin to inject frame"),this._mediaStreamTrack=e)}o&&-1!==this._hints.indexOf(e.TrackHint.CUSTOM_TRACK)&&this.setEncoderConfiguration(o),this.processorContext=new oT(this.getTrackId(),"local"),this.processorDestination=new iT(this.processorContext),this.bindProcessorDestinationEvents()}play(i){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof i){const e=document.getElementById(i);e?i=e:(r.logger.warning("[".concat(this.getTrackId(),'] can not find "#').concat(i,'" element, use document.body')),i=document.body)}r.logger.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(i instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(o));const n=VT(VT(VT({},this._getDefaultPlayerConfig()),o),{},{trackId:this.getTrackId(),element:i});this._player?this._player.updateConfig(n):(i instanceof HTMLVideoElement?this._player=new RT(n):this._player=new wT(n),this._player.updateVideoTrack(this._mediaStreamTrack)),this._player.play(),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const t=this.getVideoElementVisibleStatus();this.safeEmit(e.LocalTrackEvents.VIDEO_ELEMENT_VISIBLE_STATUS,t)}catch(e){}}),t.getParameter("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._statsTimer&&(this.isUseScaleResolutionDownBy=!1,window.clearInterval(this._statsTimer),this._statsTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,r.logger.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(i,o){if(!o){if(i===this._enabled)return;this.stateCheck("enabled",i)}if(r.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),i),!i){this._originMediaStreamTrack.enabled=!1;try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return o||(this._enabled=!1),void r.logger.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] setEnabled to true success")),o||(this._enabled=!0)}async setMuted(i){i!==this._muted&&(this.stateCheck("muted",i),this._muted=i,this._originMediaStreamTrack.enabled=!i,r.logger.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(i)),i?await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_MUTE_TRACK,this):await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(i,o){if(!this._enabled)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");if("720p_auto"===i?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),i=ji(i),this._forceBitrateLimit&&(i.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:i.bitrateMax,i.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:i.bitrateMin),i.width||i.height||i.frameRate){const e=TT({encoderConfig:i});(t.isSafari()||t.isIOS()||t.isIpadOS())&&(e.deviceId=void 0),r.logger.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(i),JSON.stringify(e));try{await this._originMediaStreamTrack.applyConstraints(e),this.updateMediaStreamTrackResolution()}catch(e){const i=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.toString());throw r.logger.error("[".concat(this.getTrackId(),"] applyConstraints error"),i.toString()),i}}this._encoderConfig=i,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(r.logger)}}getStats(){t.runOnce((()=>{r.logger.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const i=t.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS);return i||VT({},so)}async setBeautyEffect(e){r.logger.error("LocalVideoTrack.setBeautyEffect was deprecated, please migrate to agora-extension-beauty-effect")}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameImage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._player?this._player.getCurrentFrameToUint8Array(e,t):await AT(e)}async setBitrateLimit(i){if(r.logger.debug("[".concat(this.getTrackId(),"] set bitrate limit, ").concat(JSON.stringify(i))),i){this._forceBitrateLimit=i,this._encoderConfig&&(this._encoderConfig.bitrateMax?this._encoderConfig.bitrateMax=this._encoderConfig.bitrateMax<i.max_bitrate?this._encoderConfig.bitrateMax:i.max_bitrate:this._encoderConfig.bitrateMax=i.max_bitrate,this._encoderConfig.bitrateMin,this._encoderConfig.bitrateMin=i.min_bitrate);try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(r.logger)}}}async setOptimizationMode(i){if("motion"!==i&&"detail"!==i&&"balanced"!==i)return void r.logger.error(t.AgoraRTCErrorCode.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const o=this._optimizationMode;try{this._optimizationMode=i,await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.SET_OPTIMIZATION_MODE,this)}catch(e){throw this._optimizationMode=o,r.logger.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(i,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return r.logger.error(t.AgoraRTCErrorCode.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,r.logger.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){DT(this._originMediaStreamTrack).then((e=>{let[t,r]=e;this._videoHeight=r,this._videoWidth=t})).catch(t.noop)}_updatePlayerSource(){this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}_getDefaultPlayerConfig(){return{fit:"contain"}}async setSenderConfiguration(i){if(!this._enabled)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");r.logger.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(i)),i=ji(i),this._forceBitrateLimit&&(i.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:i.bitrateMax,i.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:i.bitrateMin),this._encoderConfig=i,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(r.logger)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:i,frameRate:o}=this.getMediaStreamTrackSettings();if(!e||!i||!o)return;const[n,a]=PT(e,i,o,t.getParameter("BITRATE_ADAPTER_TYPE"))||[void 0,void 0];this._encoderConfig.bitrateMin||this._encoderConfig.bitrateMax||(this._encoderConfig.bitrateMin=a,this._encoderConfig.bitrateMax=n,r.logger.debug("[".concat(this.getTrackId(),"] update bitrate from profile, [w: ").concat(e,", h: ").concat(i,", fps: ").concat(o,"] => [brMax: ").concat(n,", brMin: ").concat(a,"]")))}getVideoElementVisibleStatus(){try{var e,i;const o=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(i=this._player)||void 0===i?void 0:i.getVideoElement(),slot:null==o?void 0:o.parentElement},{element:a,slot:s}=n;if(this.isPlaying&&a instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=t.elementVisibleChecker.checkOneElementVisible(a),i=Object.assign({},e);if(i.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=i.visible;const e=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.LOCAL_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});i.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(i.reason))}return i}return}catch(e){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}close(){super.close(),this.unbindProcessorDestinationEvents(),this.unbindProcessorContextEvents(),this.unpipe(),this.processorDestination._source&&this.processorDestination._source.unpipe()}clone(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this._encoderConfig;e&&(o=VT(VT({},o),ji(e))),o=t.safeCloneJson(o);const n=t.getRandomString(8,"track-video-cloned-"),a=new xT(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,o,t.safeCloneJson(this._scalabilityMode),this._optimizationMode,n,t.safeCloneJson(this._hints));return e&&o&&a.setEncoderConfiguration(o),r.logger.debug("clone video track from ".concat(this.getTrackId()," to ").concat(n,", clone ").concat(i)),a}async replaceTrack(e,r){if(!(e instanceof MediaStreamTrack))throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,r,!0),this.updateMediaStreamTrackResolution()}startMonitorStats(){if(!t.isSafari()&&!t.isIOS())return;this._statsTimer&&window.clearInterval(this._statsTimer);let i=2,o=Ui[i];let n=-1;let a=Date.now();const s=e=>{e>2||e<0||(a=Date.now(),o=Ui[e],this.setSenderConfiguration(o))};this.isUseScaleResolutionDownBy=!0,this._statsTimer=window.setInterval((()=>{const c=this.getStats(),d=t.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_RTC_STATS);if(c.sendPackets>0&&d){-1===n&&(n=Date.now());const e=Date.now();if(e-n<1e3||e-a<t.getParameter("PROFILE_SWITCH_INTERVAL"))return;const u=c.sendFrameRate,l=.6*o.frameRate,h=.9*o.frameRate;"number"==typeof u&&u>0&&u<l?i>0&&(i--,s(i),r.logger.debug("[".concat(this.getTrackId(),"] step down for fps ").concat(u,", switchProfile to ").concat(i))):d.OutgoingAvailableBandwidth<o.bitrateMin?i>0&&(i--,s(i),r.logger.debug("[".concat(this.getTrackId(),"] step down for OutgoingAvailableBandwidth ").concat(d.OutgoingAvailableBandwidth,", bitrateMin ").concat(o.bitrateMin,", switchProfile to ").concat(i))):"number"==typeof u&&u>h&&i<Ui.length-1&&d.OutgoingAvailableBandwidth>1.2*Ui[i+1].bitrateMin&&(i++,s(i),r.logger.debug("[".concat(this.getTrackId(),"] step up for fps ").concat(u,", OutgoingAvailableBandwidth ").concat(d.OutgoingAvailableBandwidth,", switchProfile to ").concat(i)))}}),t.getParameter("CHECK_LOCAL_STATS_INTERVAL"))}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async r=>{r?r!==this._mediaStreamTrack&&(this._mediaStreamTrack=r,this._updatePlayerSource(),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}}Gf([r.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",r]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object,Object]),Wf("design:returntype",void 0)],xT.prototype,"play",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],xT.prototype,"stop",null),Gf([t.atom("LocalVideoTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean,Boolean]),Wf("design:returntype",Hf)],xT.prototype,"setEnabled",null),Gf([t.atom("LocalVideoTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean]),Wf("design:returntype",Hf)],xT.prototype,"setMuted",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object,Boolean]),Wf("design:returntype",Hf)],xT.prototype,"setEncoderConfiguration",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",Object)],xT.prototype,"getStats",null),Gf([r.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t,r]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean,Object]),Wf("design:returntype",Hf)],xT.prototype,"setBeautyEffect",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",ImageData)],xT.prototype,"getCurrentFrameData",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[String,Number]),Wf("design:returntype",Hf)],xT.prototype,"getCurrentFrameImage",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Hf)],xT.prototype,"setBitrateLimit",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[String]),Wf("design:returntype",Hf)],xT.prototype,"setOptimizationMode",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",void 0)],xT.prototype,"setScalabiltyMode",null),Gf([zE(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],xT.prototype,"updateMediaStreamTrackResolution",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Object)],xT.prototype,"pipe",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],xT.prototype,"unpipe",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],xT.prototype,"close",null),Gf([r.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t.label,r]}),Wf("design:type",Function),Wf("design:paramtypes",[MediaStreamTrack,Boolean]),Wf("design:returntype",Hf)],xT.prototype,"replaceTrack",null),Gf([r.apiInvoke(),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],xT.prototype,"startMonitorStats",null);class UT extends xT{get __className__(){return"CameraVideoTrack"}constructor(i,o,n,a,s,c){super(i,ji(o.encoderConfig),a,s,c),this._config=void 0,this._originalConstraints=void 0,this._constraints=void 0,this._enabled=!0,this._deviceName="default",this.tryResumeVideoForIOS15_16WeChat=async()=>{(t.isIOS15()||t.isIOS16())&&!t.isAboveIOS15_2()&&t.isWechatBrowser()&&this._enabled&&!this._isClosed&&(r.logger.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS 15 device on WeChat.")),await this.renewMediaStreamTrack())},this._config=o,this._originalConstraints=n,this._constraints=n,this._deviceName=i.label,this._encoderConfig=ji(this._config.encoderConfig),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),this.bindProcessorContextEvents()}async setDevice(e){return"string"==typeof e?this._setDeviceById(e):e.deviceId?this._setDeviceById(e.deviceId):e.facingMode?this._setDeviceByFacingModel(e.facingMode):void 0}async _setDeviceById(e){if(r.logger.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await VE.getDeviceById(e),i={};i.video=VT({},this._constraints),i.video.deviceId={exact:e},i.video.facingMode=void 0,this._originMediaStreamTrack.stop();let o=null;try{o=await wE(i,this.getTrackId())}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),o=await wE({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(o.getVideoTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(o.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution(),this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await VE.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){r.logger.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:VT(VT({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await wE(t,this.getTrackId())}catch(t){throw r.logger.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await wE({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),t}await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution()}this._deviceName="",this._config.facingMode=e,this._config.cameraId=void 0,this._constraints=VT({},t.video),r.logger.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(i,o){if(!o){if(i===this._enabled)return;this.stateCheck("enabled",i)}if(r.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),i),i){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await wE({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),r.logger.info("[".concat(this.getTrackId(),"] setEnabled to true success")),o||(this._enabled=!0)}else{this.isExternalTrack?this._originMediaStreamTrack.enabled=!1:(this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop()),o||(this._enabled=!1);try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw r.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}r.logger.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(i,o){if(!this._enabled)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");"720p_auto"===i?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),i=ji(i),this._forceBitrateLimit&&(i.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:i.bitrateMax,i.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:i.bitrateMin);const n=t.jsonClone(this._config);n.encoderConfig=i;const a=TT(n);(t.isSafari()||t.isIOS()||t.isIpadOS())&&(a.deviceId=void 0),r.logger.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(i),JSON.stringify(a));try{await this._originMediaStreamTrack.applyConstraints(a),this.updateMediaStreamTrackResolution()}catch(e){const i=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.toString());throw r.logger.error("[".concat(this.getTrackId(),"] applyConstraints error"),i.toString()),i}this._config=n,this._constraints=a,this._originalConstraints=a,this._encoderConfig=i,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await t.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(r.logger)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((t.isIOS()||t.isIpadOS())&&this._enabled&&!this._isClosed&&Qf.duringInterruption){const t=async()=>{Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t),this._enabled&&!this._isClosed&&(r.logger.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};Qf.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t)}else r.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,r=VE.searchDeviceIdByName(this._deviceName);if(r&&!t.deviceId&&(t.deviceId={exact:r}),this._enabled){const e=await wE({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),Qf.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(e){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this._encoderConfig;e&&(o=VT(VT({},o),ji(e))),o=t.safeCloneJson(o);const n=t.getRandomString(8,"track-cam-cloned-"),a=new UT(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,t.safeCloneJson(VT(VT({},this._config),{},{encoderConfig:o})),t.safeCloneJson(this._constraints),t.safeCloneJson(this._scalabilityMode),this._optimizationMode,n);return e&&o&&a.setEncoderConfiguration(o),r.logger.debug("clone track from ".concat(this.getTrackId()," to ").concat(n,", clone ").concat(i)),a}bindProcessorContextEvents(){this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,r)=>{try{const r=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(r),t()}catch(e){r(e)}})),this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}function BT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function FT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?BT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):BT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function jT(e,t,i,o){i.optimizationMode&&(o&&o.width&&o.height?(i.encoderConfig=FT(FT({},o),{},{bitrateMin:o.bitrateMin,bitrateMax:o.bitrateMax}),"motion"!==i.optimizationMode&&"detail"!==i.optimizationMode||(t.contentHint=i.optimizationMode,t.contentHint===i.optimizationMode?r.logger.debug("[".concat(e,"] set content hint to"),i.optimizationMode):r.logger.debug("[".concat(e,"] set content hint failed")))):r.logger.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}function HT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function GT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?HT(Object(r),!0).forEach((function(t){Fl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):HT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Hf)],UT.prototype,"setDevice",null),Gf([t.atom("CameraVideoTrack","_enabledMutex"),r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Boolean,Boolean]),Wf("design:returntype",Hf)],UT.prototype,"setEnabled",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),zE(),Wf("design:type",Function),Wf("design:paramtypes",[Object,Boolean]),Wf("design:returntype",Hf)],UT.prototype,"setEncoderConfiguration",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],UT.prototype,"close",null);class WT extends Kf{getUserId(){return this._userId}constructor(e,r,i,o){super(e,"track-".concat(e.kind,"-").concat(r,"-").concat(o.clientId,"_").concat(t.getRandomString(5,""))),this._userId=void 0,this._uintId=void 0,this._isDestroyed=!1,this.store=void 0,this.processor=void 0,this._userId=r,this._uintId=i,this.store=o}_updateOriginMediaStreamTrack(e){this._originMediaStreamTrack=e,this._mediaStreamTrack=e,this._updatePlayerSource(),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext})}_destroy(){this._isDestroyed=!0,r.logger.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}class KT extends WT{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==e.MediaElementStatus.PLAYING)}get __className__(){return"RemoteVideoTrack"}constructor(e,t,r,i){super(e,t,r,i),this._videoVisibleTimer=null,this._previousVideoVisibleStatus=void 0,this._clearPreviousVideoVisibleStatus=()=>this._previousVideoVisibleStatus=void 0,this.trackMediaType="video",this._videoWidth=void 0,this._videoHeight=void 0,this._player=void 0,this.processorDestination=void 0,this.processorContext=void 0,this.updateMediaStreamTrackResolution(),this.processorContext=new oT(this.getTrackId(),"remote"),this.processorDestination=new iT(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){t.runOnce((()=>{r.logger.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return t.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS)||GT({},uo)}play(i){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof i){const e=document.getElementById(i);e?i=e:(r.logger.warning("[".concat(this.getTrackId(),'] can not find "#').concat(i,'" element, use document.body')),i=document.body)}r.logger.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(i instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(o));const n=GT(GT({fit:"cover"},o),{},{trackId:this.getTrackId(),element:i});this._player?this._player.updateConfig(n):(i instanceof HTMLVideoElement?this._player=new RT(n):this._player=new wT(n),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(e.RemoteTrackEvents.FIRST_FRAME_DECODED)}),this._player.play(this.store.sessionId||void 0),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const t=this.getVideoElementVisibleStatus();this.safeEmit(e.RemoteTrackEvents.VIDEO_ELEMENT_VISIBLE_STATUS,t)}catch(e){}}),t.getParameter("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,r.logger.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){DT(this._originMediaStreamTrack).then((e=>{let[t,r]=e;this._videoHeight=r,this._videoWidth=t})).catch(t.noop)}_updatePlayerSource(){r.logger.debug("[".concat(this.getTrackId(),"] update player source track")),this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}getVideoElementVisibleStatus(){try{var e,i;const o=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(i=this._player)||void 0===i?void 0:i.getVideoElement(),slot:null==o?void 0:o.parentElement},{element:a,slot:s}=n;if(this.isPlaying&&a instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=t.elementVisibleChecker.checkOneElementVisible(a),i=Object.assign({},e);if(i.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=i.visible;const e=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.REMOTE_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});i.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(i.reason))}return i}return}catch(e){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource()):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}}Gf([r.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",r]}),Wf("design:type",Function),Wf("design:paramtypes",[Object,Object]),Wf("design:returntype",void 0)],KT.prototype,"play",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],KT.prototype,"stop",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Object)],KT.prototype,"pipe",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],KT.prototype,"unpipe",null);class zT extends WT{get isPlaying(){return this._useAudioElement?KE.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"RemoteAudioTrack"}constructor(r,i,o,n){super(r,i,o,n),this.trackMediaType="audio",this._source=void 0,this._useAudioElement=!0,this._volume=100,this.processorContext=void 0,this.processorDestination=void 0,this._played=!1,this._bypassWebAudio=!1,t.getParameter("DISABLE_WEBAUDIO")?(this._source=new sT,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new IE(r,!0),t.getParameter("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(e.AudioSourceEvents.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(e.RemoteTrackEvents.FIRST_FRAME_DECODED)})),this.processorContext=new aT(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new nT(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(e.AudioSourceEvents.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))}setAudioFrameCallback(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!t)return this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(r),this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),this._source.on(e.AudioSourceEvents.ON_AUDIO_BUFFER,(e=>t(e)))}setVolume(e){this._volume=e,this._useAudioElement?KE.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser does not support setting the audio output device");await KE.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){t.runOnce((()=>{r.logger.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return t.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS)||GT({},co)}play(){r.logger.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(r.logger.debug("[".concat(this.getTrackId(),"] use audio element to play")),KE.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){r.logger.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?KE.stop(this.getTrackId()):this._source.stop()}_destroy(){super._destroy(),this._played=!1,this.unbindProcessorDestinationEvents(),this._source.destroy()}_isFreeze(){return this._source.isFreeze}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];r.logger.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&KE.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(this._bypassWebAudio)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not unpipe extension when WebAudio disabled");if(!this.processor)return;const r=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,r.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())})),this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,(e=>{this._source.processedNode=e;const t=!e;this._useAudioElement!==t&&(this._played?(this.stop(),this._useAudioElement=t,this.play()):this._useAudioElement=t)}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK),this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE)}}var XT;Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),Wf("design:type",Function),Wf("design:paramtypes",[Number]),Wf("design:returntype",void 0)],zT.prototype,"setVolume",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),Wf("design:type",Function),Wf("design:paramtypes",[String]),Wf("design:returntype",Hf)],zT.prototype,"setPlaybackDevice",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],zT.prototype,"play",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],zT.prototype,"stop",null),Gf([r.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Wf("design:type",Function),Wf("design:paramtypes",[Object]),Wf("design:returntype",Object)],zT.prototype,"pipe",null),Gf([r.apiInvoke({argsMap:e=>[e.getTrackId()]}),Wf("design:type",Function),Wf("design:paramtypes",[]),Wf("design:returntype",void 0)],zT.prototype,"unpipe",null),function(e){e[e.ONE_BYTE=0]="ONE_BYTE",e[e.TWO_BYTE=1]="TWO_BYTE"}(XT||(XT={}));class qT{constructor(){this._sequence=0,this._startTime=Date.now(),this.isUseOneByte=!0}get startTime(){const e=Date.now()-this._startTime;return e<Math.pow(2,16)?e:(this._startTime+=Math.pow(2,16),this.startTime)}get sequence(){return this._sequence<Math.pow(2,32)?this._sequence++:(this._sequence-=Math.pow(2,32),this.sequence)}serialize(e){const t={commonPacketHeader:{length:0,reserved:0,extension:0,sequence:this.sequence},commonStreamHeader:this.startTime,extension:void 0,payload:e};if(e.byteLength>128){const r=new Uint8Array(4);r.set([1,0,0,0]);const i={id:0,length:4,data:r.buffer},o={profile:this.isUseOneByte?0:1,length:this.isUseOneByte?5:6,datas:[i]};t.commonPacketHeader.extension=1,t.extension=o,t.payload=this.compress(e),t.commonPacketHeader.length=8+(t.extension.length+2)+t.payload.byteLength}else t.commonPacketHeader.length=8+t.payload.byteLength;const r=new ArrayBuffer(t.commonPacketHeader.length),i=new Uint8Array(r),o=new DataView(r);let n=0;if(o.setUint16(n,t.commonPacketHeader.extension<<15|t.commonPacketHeader.reserved<<14|t.commonPacketHeader.length,!0),n+=2,o.setUint32(n,t.commonPacketHeader.sequence,!0),n+=4,o.setUint16(n,t.commonStreamHeader,!0),n+=2,t.extension){const e=this.serializeExtension(t.extension);i.set(new Uint8Array(e),n),n+=e.byteLength}if(i.set(new Uint8Array(t.payload),n),n+=t.payload.byteLength,n!==t.commonPacketHeader.length)throw Error("serialize error!");return r}deserialize(e){if(e.byteLength<4)return new ArrayBuffer(0);const t=new DataView(e);let r=0;const i=t.getUint16(r,!0);r+=2;const o=(32768&i)>>15;t.getUint16(r+2,!0),t.getUint16(r,!0);let n,a;if(r+=4,t.getUint16(r,!0),r+=2,o){a=this.deserializeExtension(e.slice(r)),r+=2+a.length,n=e.slice(r);let t=!1;if(a.datas.length>0){const e=a.datas.find((e=>0===e.id));if(e){t=1==(1&new DataView(e.data).getUint32(0,!0))}}n=t?this.decompress(n):n}else n=e.slice(8);return n}serializeExtension(e){const{profile:t,length:r,datas:i}=e,o=new ArrayBuffer(r+2),n=new Uint8Array(o),a=new DataView(o);let s=0;if(a.setUint8(s++,t),a.setUint8(s++,r),i.forEach((e=>{t?(a.setUint8(s++,e.id),a.setUint8(s++,e.length),n.set(new Uint8Array(e.data),s),s+=e.data.byteLength):(a.setUint8(s++,e.id|e.length<<4),n.set(new Uint8Array(e.data),s),s+=e.data.byteLength)})),s!==r+2)throw Error("serialize extension error, is ".concat(s,"!==").concat(r+2));return o}deserializeExtension(e){const t=new DataView(e);let r=0;const i=t.getUint8(r);r++;const o=t.getUint8(r);r++;const n=i===XT.TWO_BYTE,a=[],s=new DataView(e,2);let c=0;for(;c<o;){let e=0,t=0,r=new ArrayBuffer(0);n?(e=s.getUint8(c),c++,t=s.getUint8(c),c++):(e=15&s.getUint8(c),t=s.getUint8(c)>>4,c++),t>0&&(r=s.buffer.slice(c+2,c+2+t),c+=r.byteLength),a.push({id:e,length:t,data:r})}if(c!==o)throw Error("parse error");return{profile:i,length:o,datas:a}}decompress(e){return n.inflate(new Uint8Array(e))}compress(e){return n.deflate(new Uint8Array(e))}}class JT extends t.EventEmitter{constructor(e,t){super(),this._version=1,this._type=3,this._config=void 0,this._originDataChannel=void 0,this._dataStreamPacketHeader=new ArrayBuffer(4),this._dataStreamPacketHandler=void 0,this._datachannelEventMap=new Map,this._config=e,t&&(this._originDataChannel=t,this._bandDataChannelEvents(t)),this._initPacketHeader(),this._dataStreamPacketHandler=new qT}get id(){return this._config.id}get ordered(){return this._config.ordered}get maxRetransmits(){return t.getParameter("DATASTREAM_MAX_RETRANSMITS")}get metadata(){return this._config.metadata}get readyState(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.readyState)&&void 0!==e?e:"connecting"}get _originDataChannelId(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.id)&&void 0!==e?e:null}getChannelId(){return this.id}getConfig(){return this._config}_close(){this._originDataChannel&&(this._unbindDataChannelEvents(this._originDataChannel),this._originDataChannel=void 0)}async _waitTillOpen(){return new Hf(((e,r)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;r(new t.AgoraRTCError(t.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT,"Cannot create datachannel, id: ".concat(null===(e=this._originDataChannel)||void 0===e?void 0:e.id)))}),1e4);this._originDataChannel.onopen=()=>{clearTimeout(i),this._originDataChannel&&this._bandDataChannelEvents(this._originDataChannel),e()},this._originDataChannel.onerror=()=>{throw clearTimeout(i),new t.AgoraRTCError(t.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT)}}else r(new t.AgoraRTCError(t.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT,"cannot find dataChannel"))}))}_updateOriginDataChannel(e){this._originDataChannel=e,this._bandDataChannelEvents(e)}_initPacketHeader(){const e=new DataView(this._dataStreamPacketHeader);e.setUint16(0,this._version),e.setUint8(2,this._type),e.setUint8(3,this._config.id)}_bandDataChannelEvents(t){this._unbindDataChannelEvents(t),[e.DataChannelEvents.OPEN,e.DataChannelEvents.CLOSE,e.DataChannelEvents.ERROR].forEach((e=>{const r=()=>{this.emit(e)};this._datachannelEventMap.set(e,r),t.addEventListener(e,r)}))}_unbindDataChannelEvents(e){Array.from(this._datachannelEventMap.entries()).forEach((t=>{let[r,i]=t;e.removeEventListener(r,i)})),this._datachannelEventMap.clear()}}Object.defineProperty(e,"isElectron",{enumerable:!0,get:function(){return t.isElectron}}),e.AUDIO_ENCODER_CONFIG_SETTINGS=Wi,e.AudioProcessorContext=aT,e.AudioProcessorDestination=nT,e.BufferSourceAudioTrack=fT,e.CameraVideoTrack=UT,e.DEFAULT_LOCAL_AUDIO_TRACK_STATS=ao,e.DEFAULT_LOCAL_VIDEO_TRACK_STATS=so,e.DEFAULT_NETWORK_QUALITY_STATS={uplinkNetworkQuality:0,downlinkNetworkQuality:0},e.DEFAULT_REMOTE_AUDIO_TRACK_STATS=co,e.DEFAULT_REMOTE_VIDEO_TRACK_STATS=uo,e.DataChannel=JT,e.DeviceManager=LE,e.LocalAudioTrack=gT,e.LocalDataChannel=class extends JT{send(e){if(this._originDataChannel){let t=e;t=this._dataStreamPacketHandler.serialize(e);const r=new Uint8Array(this._dataStreamPacketHeader.byteLength+t.byteLength);r.set(new Uint8Array(this._dataStreamPacketHeader),0),r.set(new Uint8Array(t),this._dataStreamPacketHeader.byteLength),this._originDataChannel.send(r.buffer)}}},e.LocalTrack=zf,e.LocalVideoTrack=xT,e.MediaElementNumStatus={uninit:100,none:110,init:120,loadeddata:130,canplay:200,playing:210,paused:220,suspend:300,stalled:310,waiting:320,error:330,destroyed:340,abort:350,ended:360,emptied:370},e.MicrophoneAudioTrack=mT,e.MixingAudioTrack=ET,e.RemoteAudioTrack=zT,e.RemoteDataChannel=class extends JT{constructor(t){super(t),this._messageListener=void 0,this._messageListener=t=>{if(t.data.byteLength<this._dataStreamPacketHeader.byteLength)throw Error("invalid byteLength: the byte length must exceed "+this._dataStreamPacketHeader.byteLength);const r=t.data.slice(0,this._dataStreamPacketHeader.byteLength);if(new DataView(r).getUint8(3)!==this.id)return;let i=t.data.slice(this._dataStreamPacketHeader.byteLength);i=this._dataStreamPacketHandler.deserialize(i),this.emit(e.DataChannelEvents.MESSAGE,i)}}_updateOriginDataChannel(e){super._updateOriginDataChannel(e),this._bandRemoteDataChannelEvents()}_close(){this._originDataChannel&&(this._originDataChannel.removeEventListener("message",this._messageListener),super._close())}_bandRemoteDataChannelEvents(){this._originDataChannel&&this._originDataChannel.addEventListener("message",this._messageListener)}},e.RemoteTrack=WT,e.RemoteVideoTrack=KT,e.SAFARI_GLOBAL_GUM_LOCK=NE,e.SUPPORT_720P_AUTO_CONFIG_LIST=Ui,e.SUPPORT_SCREEN_ENCODER_CONFIG_LIST=Bi,e.SUPPORT_SVC_CONFIG_LIST=Fi,e.SUPPORT_VIDEO_ENCODER_CONFIG_LIST=xi,e.Track=Kf,e.VideoProcessorContext=oT,e.VideoProcessorDestination=iT,e.__TRACK_LIST__=zi,e.addTrack=Xi,e.audioContextState=Qf,e.audioElementPlayCenter=KE,e.audioTimerLoop=function(e,r){let i=!1;const o=1/r;if(t.getParameter("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*o)}else{const t=$f();let r=t.createGain();r.gain.value=0,r.connect(t.destination);const n=()=>{if(i)return void(r=null);const a=t.createOscillator();a.onended=n,a.connect(r),a.start(0),a.stop(t.currentTime+o),e(t.currentTime)};n()}return()=>{i=!0}},e.autoPlayGestureEventEmitter=BE,e.blob2Uint8Array=bT,e.checkMediaStreamTrackResolution=DT,e.checkTrackState=zE,e.createBufferSourceAudioTrack=async function(e){var o;const{cacheOnlineFile:n,encoderConfig:a}=e;let{source:s}=e;const c={source:s instanceof AudioBuffer?"AudioBuffer":s instanceof File?null!==(o=File.name)&&void 0!==o?o:"File":s,cacheOnlineFile:n,encoderConfig:a},d=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_BUFFER_AUDIO_TRACK,options:[c]});if(t.getParameter("DISABLE_WEBAUDIO"))throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const u=t.getRandomString(8,"track-buf-");r.logger.info("start create buffer source audio track with config",JSON.stringify(c),"trackId",u);const l=s;if(!(s instanceof AudioBuffer))try{s=await async function(e,o){let n=null;if("string"==typeof e){const o=ST.get(e);if(o)return r.logger.debug("use cached audio resource: ",e),o;try{n=(await t.retryable((()=>i.get(e,{responseType:"arraybuffer"})),void 0,void 0,{maxRetryCount:3})).data}catch(e){throw new t.AgoraRTCError(t.AgoraRTCErrorCode.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const r=new Hf(((r,i)=>{const o=new FileReader;o.onload=e=>{e.target?r(e.target.result):i(new t.AgoraRTCError(t.AgoraRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR))},o.onerror=()=>{i(new t.AgoraRTCError(t.AgoraRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR))},o.readAsArrayBuffer(e)}));n=await r}const a=await rE(n);return"string"==typeof e&&o&&ST.set(e,a),a}(s,n)}catch(e){return d.onError(e),e.throw(r.logger)}const h=new yT(s),p=new fT(l,h,a?Ki(a):{},u);return r.logger.info("create buffer source audio track success, trackId:",u),d.onSuccess(p.getTrackId()),p},e.createCameraVideoTrack=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_CAM_VIDEO_TRACK,options:[FT({},e)]}),o=TT(e),n=t.getRandomString(8,"track-cam-");let a=null;const s="720p_auto"===e.encoderConfig;r.logger.info("start create camera video track with config",JSON.stringify(e),"trackId",n);try{a=(await wE({video:o},n)).getVideoTracks()[0]||null}catch(e){throw i.onError(e),e}if(!a){const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(r.logger)}e.optimizationMode&&jT(n,a,e,ji(e.encoderConfig));const c=new UT(a,e,o,e.scalabiltyMode?Gi(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,n);return s&&c.startMonitorStats(),i.onSuccess(c.getTrackId()),r.logger.info("create camera video success, trackId:",n),c},e.createCustomAudioTrack=function(e){const i=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),o=new gT(e.mediaStreamTrack,e.encoderConfig?Ki(e.encoderConfig):{},t.getRandomString(8,"track-cus-"),!1,!0);return r.logger.info("create custom audio track success with config",e,"trackId",o.getTrackId()),i.onSuccess(o.getTrackId()),o},e.createCustomVideoTrack=function(i){const o=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_CUSTOM_VIDEO_TRACK,options:[i]}),n=new xT(i.mediaStreamTrack,{width:i.width,height:i.height,frameRate:i.frameRate,bitrateMax:i.bitrateMax,bitrateMin:i.bitrateMin},i.scalabiltyMode?Gi(i.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},i.optimizationMode,t.getRandomString(8,"track-cus-"),[e.TrackHint.CUSTOM_TRACK]);return o.onSuccess(n.getTrackId()),r.logger.info("create custom video track success with config",i,"trackId",n.getTrackId()),n},e.createMicrophoneAndCameraTracks=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_MIC_AND_CAM_TRACKS,options:[e,i]}),n="720p_auto"===i.encoderConfig,a=TT(i),s=_T(e),c=t.getRandomString(8,"track-mic-"),d=t.getRandomString(8,"track-cam-");let u=null,l=null;r.logger.info("start create camera video track(".concat(d,") and microphone audio track(").concat(c,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(i)));try{const e=await wE({audio:s,video:a},"".concat(c,"-").concat(d));u=e.getAudioTracks()[0],l=e.getVideoTracks()[0]}catch(e){throw o.onError(e),e}if(!u||!l){const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find tracks in media stream");return o.onError(e),e.throw(r.logger)}i.optimizationMode&&jT(d,l,i,ji(i.encoderConfig));const h=new mT(u,e,s,c),p=new UT(l,i,a,i.scalabiltyMode?Gi(i.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},i.optimizationMode,d);return n&&p.startMonitorStats(),o.onSuccess([h.getTrackId(),p.getTrackId()]),r.logger.info("create camera video track(".concat(d,") and microphone audio track(").concat(c,") success")),[h,p]},e.createMicrophoneAudioTrack=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const i=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_MIC_AUDIO_TRACK,options:[e]}),o=_T(e),n=t.getRandomString(8,"track-mic-");let a=null;r.logger.info("start create microphone audio track with config",JSON.stringify(e),"trackId",n);try{a=(await wE({audio:o},n)).getAudioTracks()[0]||null}catch(e){throw i.onError(e),e}if(!a){const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(r.logger)}const s=new mT(a,e,o,n);return i.onSuccess(s.getTrackId()),r.logger.info("create microphone audio track success, trackId:",n),s},e.createMixingAudioTrack=function(e){const t=new ET;return e.forEach((e=>t.addAudioTrack(e))),t},e.createScreenVideoTrack=async function(){let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const n=r.report.reportApiInvoke(null,{tag:t.AgoraAPITag.TRACER,name:t.AgoraAPIName.CREATE_SCREEN_VIDEO_TRACK,options:[FT({},i),o]}),a="720p_auto"===i.encoderConfig;i.encoderConfig?"string"==typeof i.encoderConfig||i.encoderConfig.width&&i.encoderConfig.height||(i.encoderConfig.width={max:1920},i.encoderConfig.height={max:1080}):i.encoderConfig="1080p_2";const s=vT(i),c=t.getRandomString(8,"track-scr-v-");let d=null,u=null;const l=sE();if(!l.supportShareAudio&&"enable"===o){const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return n.onError(e),e.throw(r.logger)}r.logger.info("start create screen video track with config",i,"withAudio",o,"trackId",c);try{const e=await wE({screen:s,screenAudio:"auto"===o?l.supportShareAudio:"enable"===o},c);d=e.getVideoTracks()[0]||null,u=e.getAudioTracks()[0]||null}catch(e){throw n.onError(e),e}if(!d){const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return n.onError(e),e.throw(r.logger)}if(!u&&"enable"===o){d&&d.stop();const e=new t.AgoraRTCError(t.AgoraRTCErrorCode.SHARE_AUDIO_NOT_ALLOWED);return n.onError(e),e.throw(r.logger)}if(i.optimizationMode||(i.optimizationMode="detail"),i.optimizationMode){jT(c,d,i,i.encoderConfig&&Hi(i.encoderConfig)||void 0),i.encoderConfig&&"string"!=typeof i.encoderConfig&&(i.encoderConfig.bitrateMin=i.encoderConfig.bitrateMax)}const h=new xT(d,i.encoderConfig?Hi(i.encoderConfig):{},i.scalabiltyMode?Gi(i.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},i.optimizationMode,c,[e.TrackHint.SCREEN_TRACK]);if(a&&h.startMonitorStats(),!u)return n.onSuccess(h.getTrackId()),r.logger.info("create screen video track success","video:",h.getTrackId()),h;const p=new gT(u,void 0,t.getRandomString(8,"track-scr-a-"),!1,!0);return n.onSuccess([h.getTrackId(),p.getTrackId()]),r.logger.info("create screen video track success","video:",h.getTrackId(),"audio:",p.getTrackId()),[h,p]},e.decodeAudioData=rE,e.deviceManager=VE,e.emptyImage2TypedArray=AT,e.frameData2CryptoBuffer=async(e,r,i)=>await(async(e,r,i)=>{const o=""+r+i,n=t.hexToBytes(t.md5(o)).slice(0,16),a=n.slice(0,12),s=await window.crypto.subtle.importKey("raw",n,"AES-GCM",!0,["encrypt"]);return new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:a},s,e))})(e.buffer,r,i),e.getAudioContext=$f,e.getAudioEncoderConfiguration=Ki,e.getBitrateFromResAndFps=PT,e.getCompatibility=sE,e.getConstraintsFromCameraConfig=TT,e.getConstraintsFromMicrophoneConfig=_T,e.getConstraintsFromScreenConfig=vT,e.getElectronScreenSources=OE,e.getElectronScreenStream=kE,e.getElectronScreenStreamByUserSelect=CE,e.getLocalStream=wE,e.getScalabilityConfiguration=Gi,e.getScreenEncoderConfiguration=Hi,e.getSilenceAudioTrack=function(){if(oE)return oE;const e=$f();if(!e.createMediaStreamDestination)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create silence audio track");const r=e.createBufferSource(),i=e.createBuffer(1,44100,44100);r.loop=!0,r.buffer=i;const o=e.createMediaStreamDestination();return r.connect(o),oE=o.stream.getAudioTracks()[0],oE},e.getSilenceSamplesDuration=function(e){const t=e.getChannelData(0);let r=0,i=0;for(let e=0;e<t.length;e+=1)0===t[e]?(r+=1,r>i&&(i=r)):r=0;return i/t.length*e.duration},e.getStaticTrackStream=MT,e.getVideoEncoderConfiguration=ji,e.handleGetUserMediaError=PE,e.hasAudioContext=eE,e.isAudioEncoderConfiguration=Yi,e.isAudioEncoderConfigurationOrPreset=function(e){return"string"==typeof e?t.checkValidEnum(e,"profile",Object.keys(Wi)):Yi(e),!0},e.isBeautyEffectOptions=function(e){return void 0!==e.smoothnessLevel&&t.checkValidNumber(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&t.checkValidNumber(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&t.checkValidNumber(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&t.checkValidEnum(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0},e.isLowStreamParameter=function(e){if(!e)throw new t.AgoraRTCError(t.AgoraRTCErrorCode.INVALID_PARAMS);return t.isEmpty(e.width)||t.checkValidConstrainLong(e.width,"streamParameter.width"),t.isEmpty(e.height)||t.checkValidConstrainLong(e.height,"streamParameter.height"),t.isEmpty(e.framerate)||t.checkValidConstrainLong(e.framerate,"streamParameter.framerate"),t.isEmpty(e.bitrate)||t.checkValidNumber(e.bitrate,"streamParameter.bitrate"),!0},e.isScreenSourceType=Qi,e.isVideoEncoderConfiguration=Ji,e.isVideoEncoderConfigurationOrPreset=function(e){return"string"==typeof e?t.checkValidEnum(e,"profile",Object.keys(xi)):Ji(e),!0},e.polyfillAudioNode=tE,e.removeTrack=qi,e.requestAutoplayGesture=FE,e.silenceScriptProcessHandler=nE,e.updateAgoraRTCCompatibility=function(){const e=t.getBrowserInfo();aE.getDisplayMedia=function(e){if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return!0;return!1}(),aE.getStreamFromExtension=e.name===t.BrowserName.CHROME&&Number(e.version)>34,aE.supportUnifiedPlan=function(){if(!window.RTCRtpTransceiver)return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;const e=new RTCPeerConnection;let t=!1;try{e.addTransceiver("audio"),t=!0}catch(e){}return e.close(),t}(),aE.supportMinBitrate=e.name===t.BrowserName.CHROME||e.name===t.BrowserName.EDGE,aE.supportSetRtpSenderParameters=function(){const e=t.getBrowserInfo();if(!window.RTCRtpSender||!window.RTCRtpSender.prototype.setParameters||!window.RTCRtpSender.prototype.getParameters)return!1;return!!t.isChromeKernel()||(!(!t.isSafari()&&!t.isWkWebview())||e.name===t.BrowserName.FIREFOX&&Number(e.version)>=64)}(),e.name===t.BrowserName.SAFARI&&(Number(e.version)>=14?aE.supportDualStream=!0:aE.supportDualStream=!1),aE.webAudioMediaStreamDest=function(){const e=t.getBrowserInfo();if(e.name===t.BrowserName.SAFARI&&Number(e.version)<12)return!1;return!0}(),aE.supportReplaceTrack=function(){if(!window.RTCRtpSender)return!1;if("function"==typeof RTCRtpSender.prototype.replaceTrack)return!0;return!1}(),aE.supportWebGL="undefined"!=typeof WebGLRenderingContext,aE.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,t.isChromeKernel()||(aE.webAudioWithAEC=!0),aE.supportShareAudio=function(){const e=t.getBrowserInfo();if((e.os===t.BrowserOS.WIN_10||e.os===t.BrowserOS.WIN_81||e.os===t.BrowserOS.WIN_7||e.os===t.BrowserOS.LINUX||e.os===t.BrowserOS.MAC_OS)&&e.name===t.BrowserName.CHROME&&Number(e.version)>=74)return!0;return!1}(),aE.supportDataChannel=function(){if(t.isAboveChrome(76)||t.isAboveFirefox(68)||t.isAboveSafari(14))return!0;return!1}(),aE.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!t.isFirefox()&&!!e&&e.prototype.setConfiguration instanceof Function}(),aE.supportWebRTCEncodedTransform=function(){const e=t.getBrowserInfo();return"Chrome"===e.name&&Number(e.version)>=86}(),aE.supportWebRTCInsertableStream=function(){const e=t.getBrowserInfo();return(e.name===t.BrowserName.CHROME||e.name===t.BrowserName.EDGE)&&Number(e.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),t.nextTick((()=>{aE.supportDualStreamEncoding=function(){const e=t.getBrowserInfo();if(t.getParameter("DISABLE_WEBAUDIO"))return!0;return"Safari"===e.name&&Number(e.version)>=14||!!("Chrome"===e.name&&/Windows/i.test(e.os||"")&&Number(e.version)>=100&&t.getParameter("CHROME_DUAL_STREAM_USE_ENCODING"))}(),r.logger.info("browser compatibility",JSON.stringify(aE),JSON.stringify(e))}))},e.visibilityWatcher=kT}));
|
|
5
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("webrtc-adapter"),require("@agora-js/shared"),require("@agora-js/report"),require("axios"),require("pako")):"function"==typeof define&&define.amd?define(["exports","webrtc-adapter","@agora-js/shared","@agora-js/report","axios","pako"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AgoraRTCMedia={},null,e.shared$8,e.report,e.Axios,e.pako)}(this,(function(e,t,r,i,o,n){"use strict";const a={getDisplayMedia:!1,getStreamFromExtension:!1,supportUnifiedPlan:!1,supportMinBitrate:!1,supportSetRtpSenderParameters:!1,supportDualStream:!0,webAudioMediaStreamDest:!1,supportReplaceTrack:!1,supportWebGL:!1,webAudioWithAEC:!1,supportRequestFrame:!1,supportShareAudio:!1,supportDualStreamEncoding:!1,supportDataChannel:!1,supportPCSetConfiguration:!1,supportWebRTCEncodedTransform:!1,supportWebRTCInsertableStream:!1};function s(){const e=r.getBrowserInfo();a.getDisplayMedia=function(e){if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return!0;return!1}(),a.getStreamFromExtension=e.name===r.BrowserName.CHROME&&Number(e.version)>34,a.supportUnifiedPlan=function(){if(!window.RTCRtpTransceiver)return!1;if(!("currentDirection"in RTCRtpTransceiver.prototype))return!1;const e=new RTCPeerConnection;let t=!1;try{e.addTransceiver("audio"),t=!0}catch(e){}return e.close(),t}(),a.supportMinBitrate=e.name===r.BrowserName.CHROME||e.name===r.BrowserName.EDGE,a.supportSetRtpSenderParameters=function(){const e=r.getBrowserInfo();if(!window.RTCRtpSender||!window.RTCRtpSender.prototype.setParameters||!window.RTCRtpSender.prototype.getParameters)return!1;return!!r.isChromeKernel()||(!(!r.isSafari()&&!r.isWkWebview())||e.name===r.BrowserName.FIREFOX&&Number(e.version)>=64)}(),e.name===r.BrowserName.SAFARI&&(Number(e.version)>=14?a.supportDualStream=!0:a.supportDualStream=!1),a.webAudioMediaStreamDest=function(){const e=r.getBrowserInfo();if(e.name===r.BrowserName.SAFARI&&Number(e.version)<12)return!1;return!0}(),a.supportReplaceTrack=function(){if(!window.RTCRtpSender)return!1;if("function"==typeof RTCRtpSender.prototype.replaceTrack)return!0;return!1}(),a.supportWebGL="undefined"!=typeof WebGLRenderingContext,a.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,r.isChromeKernel()||(a.webAudioWithAEC=!0),a.supportShareAudio=function(){const e=r.getBrowserInfo();if((e.os===r.BrowserOS.WIN_10||e.os===r.BrowserOS.WIN_81||e.os===r.BrowserOS.WIN_7||e.os===r.BrowserOS.LINUX||e.os===r.BrowserOS.MAC_OS||e.os===r.BrowserOS.CHROMIUM_OS)&&e.name===r.BrowserName.CHROME&&Number(e.version)>=74)return!0;return!1}(),a.supportDataChannel=function(){if(r.isAboveChrome(76)||r.isAboveFirefox(68)||r.isAboveSafari(14))return!0;return!1}(),a.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!r.isFirefox()&&!!e&&e.prototype.setConfiguration instanceof Function}(),a.supportWebRTCEncodedTransform=function(){const e=r.getBrowserInfo();return"Chrome"===e.name&&Number(e.version)>=86}(),a.supportWebRTCInsertableStream=function(){const e=r.getBrowserInfo();return(e.name===r.BrowserName.CHROME||e.name===r.BrowserName.EDGE)&&Number(e.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),r.nextTick((()=>{a.supportDualStreamEncoding=function(){const e=r.getBrowserInfo();if(r.getParameter("DISABLE_WEBAUDIO"))return!0;return"Safari"===e.name&&Number(e.version)>=14||!!("Chrome"===e.name&&/Windows/i.test(e.os||"")&&Number(e.version)>=100&&r.getParameter("CHROME_DUAL_STREAM_USE_ENCODING"))}(),i.logger.info("browser compatibility",JSON.stringify(a),JSON.stringify(e))}))}function c(){return a}var d;e.AUDIO_CONTEXT_EVENT=void 0,(d=e.AUDIO_CONTEXT_EVENT||(e.AUDIO_CONTEXT_EVENT={})).IOS_15_16_INTERRUPTION_START="ios15_16-interruption-start",d.IOS_15_16_INTERRUPTION_END="ios15_16-interruption-end",d.IOS_INTERRUPTION_START="ios-interruption-start",d.IOS_INTERRUPTION_END="ios-interruption-end",d.STATE_CHANGE="state-change";var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h=function(e){try{return!!e()}catch(e){return!0}},p=!h((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),g=p,m=Function.prototype,f=m.call,E=g&&m.bind.bind(f,f),T=g?E:function(e){return function(){return f.apply(e,arguments)}},v=T({}.isPrototypeOf),_=function(e){return e&&e.Math==Math&&e},y=_("object"==typeof globalThis&&globalThis)||_("object"==typeof window&&window)||_("object"==typeof self&&self)||_("object"==typeof u&&u)||function(){return this}()||u||Function("return this")(),S=p,A=Function.prototype,b=A.apply,I=A.call,k="object"==typeof Reflect&&Reflect.apply||(S?I.bind(b):function(){return I.apply(b,arguments)}),C=T,O=C({}.toString),R=C("".slice),N=function(e){return R(O(e),8,-1)},w=N,D=T,P=function(e){if("Function"===w(e))return D(e)},M="object"==typeof document&&document.all,L={all:M,IS_HTMLDDA:void 0===M&&void 0!==M},V=L.all,x=L.IS_HTMLDDA?function(e){return"function"==typeof e||e===V}:function(e){return"function"==typeof e},U={},B=!h((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),F=p,j=Function.prototype.call,H=F?j.bind(j):function(){return j.apply(j,arguments)},G={},W={}.propertyIsEnumerable,K=Object.getOwnPropertyDescriptor,z=K&&!W.call({1:2},1);G.f=z?function(e){var t=K(this,e);return!!t&&t.enumerable}:W;var X,q,J=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},Y=h,Q=N,Z=Object,$=T("".split),ee=Y((function(){return!Z("z").propertyIsEnumerable(0)}))?function(e){return"String"==Q(e)?$(e,""):Z(e)}:Z,te=function(e){return null==e},re=te,ie=TypeError,oe=function(e){if(re(e))throw ie("Can't call method on "+e);return e},ne=ee,ae=oe,se=function(e){return ne(ae(e))},ce=x,de=L.all,ue=L.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:ce(e)||e===de}:function(e){return"object"==typeof e?null!==e:ce(e)},le={},he=le,pe=y,ge=x,me=function(e){return ge(e)?e:void 0},fe=function(e,t){return arguments.length<2?me(he[e])||me(pe[e]):he[e]&&he[e][t]||pe[e]&&pe[e][t]},Ee="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Te=y,ve=Ee,_e=Te.process,ye=Te.Deno,Se=_e&&_e.versions||ye&&ye.version,Ae=Se&&Se.v8;Ae&&(q=(X=Ae.split("."))[0]>0&&X[0]<4?1:+(X[0]+X[1])),!q&&ve&&(!(X=ve.match(/Edge\/(\d+)/))||X[1]>=74)&&(X=ve.match(/Chrome\/(\d+)/))&&(q=+X[1]);var be=q,Ie=be,ke=h,Ce=y.String,Oe=!!Object.getOwnPropertySymbols&&!ke((function(){var e=Symbol();return!Ce(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Ie&&Ie<41})),Re=Oe&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ne=fe,we=x,De=v,Pe=Object,Me=Re?function(e){return"symbol"==typeof e}:function(e){var t=Ne("Symbol");return we(t)&&De(t.prototype,Pe(e))},Le=String,Ve=function(e){try{return Le(e)}catch(e){return"Object"}},xe=x,Ue=Ve,Be=TypeError,Fe=function(e){if(xe(e))return e;throw Be(Ue(e)+" is not a function")},je=Fe,He=te,Ge=function(e,t){var r=e[t];return He(r)?void 0:je(r)},We=H,Ke=x,ze=ue,Xe=TypeError,qe={exports:{}},Je=y,Ye=Object.defineProperty,Qe=function(e,t){try{Ye(Je,e,{value:t,configurable:!0,writable:!0})}catch(r){Je[e]=t}return t},Ze="__core-js_shared__",$e=y[Ze]||Qe(Ze,{}),et=$e;(qe.exports=function(e,t){return et[e]||(et[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.31.1",mode:"pure",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.31.1/LICENSE",source:"https://github.com/zloirock/core-js"});var tt=qe.exports,rt=oe,it=Object,ot=function(e){return it(rt(e))},nt=ot,at=T({}.hasOwnProperty),st=Object.hasOwn||function(e,t){return at(nt(e),t)},ct=T,dt=0,ut=Math.random(),lt=ct(1..toString),ht=function(e){return"Symbol("+(void 0===e?"":e)+")_"+lt(++dt+ut,36)},pt=tt,gt=st,mt=ht,ft=Oe,Et=Re,Tt=y.Symbol,vt=pt("wks"),_t=Et?Tt.for||Tt:Tt&&Tt.withoutSetter||mt,yt=function(e){return gt(vt,e)||(vt[e]=ft&>(Tt,e)?Tt[e]:_t("Symbol."+e)),vt[e]},St=H,At=ue,bt=Me,It=Ge,kt=function(e,t){var r,i;if("string"===t&&Ke(r=e.toString)&&!ze(i=We(r,e)))return i;if(Ke(r=e.valueOf)&&!ze(i=We(r,e)))return i;if("string"!==t&&Ke(r=e.toString)&&!ze(i=We(r,e)))return i;throw Xe("Can't convert object to primitive value")},Ct=TypeError,Ot=yt("toPrimitive"),Rt=function(e,t){if(!At(e)||bt(e))return e;var r,i=It(e,Ot);if(i){if(void 0===t&&(t="default"),r=St(i,e,t),!At(r)||bt(r))return r;throw Ct("Can't convert object to primitive value")}return void 0===t&&(t="number"),kt(e,t)},Nt=Me,wt=function(e){var t=Rt(e,"string");return Nt(t)?t:t+""},Dt=ue,Pt=y.document,Mt=Dt(Pt)&&Dt(Pt.createElement),Lt=function(e){return Mt?Pt.createElement(e):{}},Vt=Lt,xt=!B&&!h((function(){return 7!=Object.defineProperty(Vt("div"),"a",{get:function(){return 7}}).a})),Ut=B,Bt=H,Ft=G,jt=J,Ht=se,Gt=wt,Wt=st,Kt=xt,zt=Object.getOwnPropertyDescriptor;U.f=Ut?zt:function(e,t){if(e=Ht(e),t=Gt(t),Kt)try{return zt(e,t)}catch(e){}if(Wt(e,t))return jt(!Bt(Ft.f,e,t),e[t])};var Xt=h,qt=x,Jt=/#|\.prototype\./,Yt=function(e,t){var r=Zt[Qt(e)];return r==er||r!=$t&&(qt(t)?Xt(t):!!t)},Qt=Yt.normalize=function(e){return String(e).replace(Jt,".").toLowerCase()},Zt=Yt.data={},$t=Yt.NATIVE="N",er=Yt.POLYFILL="P",tr=Yt,rr=Fe,ir=p,or=P(P.bind),nr=function(e,t){return rr(e),void 0===t?e:ir?or(e,t):function(){return e.apply(t,arguments)}},ar={},sr=B&&h((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),cr=ue,dr=String,ur=TypeError,lr=function(e){if(cr(e))return e;throw ur(dr(e)+" is not an object")},hr=B,pr=xt,gr=sr,mr=lr,fr=wt,Er=TypeError,Tr=Object.defineProperty,vr=Object.getOwnPropertyDescriptor,_r="enumerable",yr="configurable",Sr="writable";ar.f=hr?gr?function(e,t,r){if(mr(e),t=fr(t),mr(r),"function"==typeof e&&"prototype"===t&&"value"in r&&Sr in r&&!r[Sr]){var i=vr(e,t);i&&i[Sr]&&(e[t]=r.value,r={configurable:yr in r?r[yr]:i[yr],enumerable:_r in r?r[_r]:i[_r],writable:!1})}return Tr(e,t,r)}:Tr:function(e,t,r){if(mr(e),t=fr(t),mr(r),pr)try{return Tr(e,t,r)}catch(e){}if("get"in r||"set"in r)throw Er("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Ar=ar,br=J,Ir=B?function(e,t,r){return Ar.f(e,t,br(1,r))}:function(e,t,r){return e[t]=r,e},kr=y,Cr=k,Or=P,Rr=x,Nr=U.f,wr=tr,Dr=le,Pr=nr,Mr=Ir,Lr=st,Vr=function(e){var t=function(r,i,o){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(r);case 2:return new e(r,i)}return new e(r,i,o)}return Cr(e,this,arguments)};return t.prototype=e.prototype,t},xr=function(e,t){var r,i,o,n,a,s,c,d,u,l=e.target,h=e.global,p=e.stat,g=e.proto,m=h?kr:p?kr[l]:(kr[l]||{}).prototype,f=h?Dr:Dr[l]||Mr(Dr,l,{})[l],E=f.prototype;for(n in t)i=!(r=wr(h?n:l+(p?".":"#")+n,e.forced))&&m&&Lr(m,n),s=f[n],i&&(c=e.dontCallGetSet?(u=Nr(m,n))&&u.value:m[n]),a=i&&c?c:t[n],i&&typeof s==typeof a||(d=e.bind&&i?Pr(a,kr):e.wrap&&i?Vr(a):g&&Rr(a)?Or(a):a,(e.sham||a&&a.sham||s&&s.sham)&&Mr(d,"sham",!0),Mr(f,n,d),g&&(Lr(Dr,o=l+"Prototype")||Mr(Dr,o,{}),Mr(Dr[o],n,a),e.real&&E&&(r||!E[n])&&Mr(E,n,a)))},Ur=Math.ceil,Br=Math.floor,Fr=Math.trunc||function(e){var t=+e;return(t>0?Br:Ur)(t)},jr=function(e){var t=+e;return t!=t||0===t?0:Fr(t)},Hr=jr,Gr=Math.max,Wr=Math.min,Kr=function(e,t){var r=Hr(e);return r<0?Gr(r+t,0):Wr(r,t)},zr=jr,Xr=Math.min,qr=function(e){return e>0?Xr(zr(e),9007199254740991):0},Jr=function(e){return qr(e.length)},Yr=se,Qr=Kr,Zr=Jr,$r=function(e){return function(t,r,i){var o,n=Yr(t),a=Zr(n),s=Qr(i,a);if(e&&r!=r){for(;a>s;)if((o=n[s++])!=o)return!0}else for(;a>s;s++)if((e||s in n)&&n[s]===r)return e||s||0;return!e&&-1}},ei={includes:$r(!0),indexOf:$r(!1)},ti=ei.includes;xr({target:"Array",proto:!0,forced:h((function(){return!Array(1).includes()}))},{includes:function(e){return ti(this,e,arguments.length>1?arguments[1]:void 0)}});var ri=le,ii=function(e){return ri[e+"Prototype"]},oi=ii("Array").includes,ni=ue,ai=N,si=yt("match"),ci=function(e){var t;return ni(e)&&(void 0!==(t=e[si])?!!t:"RegExp"==ai(e))},di=TypeError,ui={};ui[yt("toStringTag")]="z";var li="[object z]"===String(ui),hi=li,pi=x,gi=N,mi=yt("toStringTag"),fi=Object,Ei="Arguments"==gi(function(){return arguments}()),Ti=hi?gi: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(e){}}(t=fi(e),mi))?r:Ei?gi(t):"Object"==(i=gi(t))&&pi(t.callee)?"Arguments":i},vi=Ti,_i=String,yi=function(e){if("Symbol"===vi(e))throw TypeError("Cannot convert a Symbol value to a string");return _i(e)},Si=yt("match"),Ai=xr,bi=function(e){if(ci(e))throw di("The method doesn't accept regular expressions");return e},Ii=oe,ki=yi,Ci=function(e){var t=/./;try{"/./"[e](t)}catch(r){try{return t[Si]=!1,"/./"[e](t)}catch(e){}}return!1},Oi=T("".indexOf);Ai({target:"String",proto:!0,forced:!Ci("includes")},{includes:function(e){return!!~Oi(ki(Ii(this)),ki(bi(e)),arguments.length>1?arguments[1]:void 0)}});var Ri=ii("String").includes,Ni=v,wi=oi,Di=Ri,Pi=Array.prototype,Mi=String.prototype,Li=l((function(e){var t=e.includes;return e===Pi||Ni(Pi,e)&&t===Pi.includes?wi:"string"==typeof e||e===Mi||Ni(Mi,e)&&t===Mi.includes?Di:t}));function Vi(e,t,r){return{sampleRate:e,stereo:t,bitrate:r}}function xi(e,t,r,i,o){return{width:e,height:t,frameRate:r,bitrateMin:i,bitrateMax:o}}function Ui(e,t,r,i,o){return{width:{max:e},height:{max:t},frameRate:r,bitrateMin:i,bitrateMax:o}}function Bi(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const Fi={"90p":xi(160,90),"90p_1":xi(160,90),"120p":xi(160,120,15,30,65),"120p_1":xi(160,120,15,30,65),"120p_3":xi(120,120,15,30,50),"120p_4":xi(212,120),"180p":xi(320,180,15,30,140),"180p_1":xi(320,180,15,30,140),"180p_3":xi(180,180,15,30,100),"180p_4":xi(240,180,15,30,120),"240p":xi(320,240,15,40,200),"240p_1":xi(320,240,15,40,200),"240p_3":xi(240,240,15,40,140),"240p_4":xi(424,240,15,40,220),"360p":xi(640,360,15,80,400),"360p_1":xi(640,360,15,80,400),"360p_3":xi(360,360,15,80,260),"360p_4":xi(640,360,30,80,600),"360p_6":xi(360,360,30,80,400),"360p_7":xi(480,360,15,80,320),"360p_8":xi(480,360,30,80,490),"360p_9":xi(640,360,15,80,800),"360p_10":xi(640,360,24,80,800),"360p_11":xi(640,360,24,80,1e3),"480p":xi(640,480,15,100,500),"480p_1":xi(640,480,15,100,500),"480p_2":xi(640,480,30,100,1e3),"480p_3":xi(480,480,15,100,400),"480p_4":xi(640,480,30,100,750),"480p_6":xi(480,480,30,100,600),"480p_8":xi(848,480,15,100,610),"480p_9":xi(848,480,30,100,930),"480p_10":xi(640,480,10,100,400),"720p":xi(1280,720,15,120,1130),"720p_auto":xi(1280,720,30,900,3e3),"720p_1":xi(1280,720,15,120,1130),"720p_2":xi(1280,720,30,120,2e3),"720p_3":xi(1280,720,30,120,1710),"720p_5":xi(960,720,15,120,910),"720p_6":xi(960,720,30,120,1380),"1080p":xi(1920,1080,15,120,2080),"1080p_1":xi(1920,1080,15,120,2080),"1080p_2":xi(1920,1080,30,120,3e3),"1080p_3":xi(1920,1080,30,120,3150),"1080p_5":xi(1920,1080,60,120,4780),"1440p":xi(2560,1440,30,120,4850),"1440p_1":xi(2560,1440,30,120,4850),"1440p_2":xi(2560,1440,60,120,7350),"4k":xi(3840,2160,30,120,8910),"4k_1":xi(3840,2160,30,120,8910),"4k_3":xi(3840,2160,60,120,13500)},ji=[{scaleResolutionDownBy:2,width:1280,height:720,frameRate:30,bitrateMin:300,bitrateMax:900},{scaleResolutionDownBy:1.333333,width:1280,height:720,frameRate:30,bitrateMin:600,bitrateMax:2e3},{scaleResolutionDownBy:1,width:1280,height:720,frameRate:30,bitrateMin:900,bitrateMax:3e3}],Hi={"480p":Ui(640,480,5),"480p_1":Ui(640,480,5),"480p_2":Ui(640,480,30),"480p_3":Ui(640,480,15),"720p":Ui(1280,720,5),"720p_auto":xi(1280,720,30,900,3e3),"720p_1":Ui(1280,720,5),"720p_2":Ui(1280,720,30),"720p_3":Ui(1280,720,15),"1080p":Ui(1920,1080,5),"1080p_1":Ui(1920,1080,5),"1080p_2":Ui(1920,1080,30),"1080p_3":Ui(1920,1080,15)},Gi={"1SL1TL":Bi(1,1),"3SL3TL":Bi(3,3),"2SL3TL":Bi(2,3)};function Wi(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},Fi[e]):e}function Ki(e){return"string"==typeof e?Object.assign({},Hi[e]):e}function zi(e){return"string"==typeof e?Object.assign({},Gi[e]):e}const Xi={speech_low_quality:Vi(16e3,!1),speech_standard:Vi(32e3,!1,18),music_standard:Vi(48e3,!1),standard_stereo:Vi(48e3,!0,56),high_quality:Vi(48e3,!1,128),high_quality_stereo:Vi(48e3,!0,192)};function qi(e){return"string"==typeof e?Object.assign({},Xi[e]):e}const Ji=[];function Yi(e){Li(Ji).call(Ji,e)||Ji.push(e)}function Qi(e){const t=Ji.indexOf(e);-1!==t&&Ji.splice(t,1)}function Zi(e){return r.checkValidConstrainLong(e.width,"config.width"),r.checkValidConstrainLong(e.height,"config.height"),void 0!==e.frameRate&&r.checkValidConstrainLong(e.frameRate,"config.frameRate"),void 0!==e.bitrateMax&&r.checkValidNumber(e.bitrateMax,"config.bitrateMax"),void 0!==e.bitrateMin&&r.checkValidNumber(e.bitrateMin,"config.bitrateMin"),!0}function $i(e){return void 0!==e.sampleRate&&r.checkValidNumber(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&r.checkValidNumber(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&r.checkValidBoolean(e.stereo,"config.stereo"),void 0!==e.bitrate&&r.checkValidNumber(e.bitrate,"config.bitrate",0,1e4,!1),!0}function eo(e){return r.checkValidEnum(e,"mediaSource",["screen","window","application"]),!0}var to,ro,io,oo,no,ao,so,co;e.TrackInternalEvent=void 0,(to=e.TrackInternalEvent||(e.TrackInternalEvent={})).NEED_RENEGOTIATE="@need_renegotiate",to.NEED_REPLACE_TRACK="@need_replace_track",to.NEED_CLOSE="@need_close",to.NEED_ENABLE_TRACK="@need_enable_track",to.NEED_DISABLE_TRACK="@need_disable_track",to.NEED_SESSION_ID="@need_sid",to.SET_OPTIMIZATION_MODE="@set_optimization_mode",to.GET_STATS="@get_stats",to.GET_RTC_STATS="@get_rtc_stats",to.GET_LOW_VIDEO_TRACK="@get_low_video_track",to.NEED_RESET_REMOTE_SDP="@need_reset_remote_sdp",to.NEED_UPDATE_VIDEO_ENCODER="@need_update_video_encoder",to.NEED_MUTE_TRACK="@need_mute_track",to.NEED_UNMUTE_TRACK="@need_unmute_track",e.TrackHint=void 0,(ro=e.TrackHint||(e.TrackHint={})).SCREEN_TRACK="screen_track",ro.CUSTOM_TRACK="custome_track",ro.LOW_STREAM="low_stream",e.StreamType=void 0,(io=e.StreamType||(e.StreamType={}))[io.HIGH_STREAM=0]="HIGH_STREAM",io[io.LOW_STREAM=1]="LOW_STREAM",e.RemoteStreamType=void 0,(oo=e.RemoteStreamType||(e.RemoteStreamType={}))[oo.HIGH_STREAM=0]="HIGH_STREAM",oo[oo.LOW_STREAM=1]="LOW_STREAM",e.RemoteStreamFallbackType=void 0,(no=e.RemoteStreamFallbackType||(e.RemoteStreamFallbackType={}))[no.DISABLE=0]="DISABLE",no[no.LOW_STREAM=1]="LOW_STREAM",no[no.AUDIO_ONLY=2]="AUDIO_ONLY",e.TrackEvents=void 0,(e.TrackEvents||(e.TrackEvents={})).TRANSCEIVER_UPDATED="transceiver-updated",e.LocalTrackEvents=void 0,(ao=e.LocalTrackEvents||(e.LocalTrackEvents={})).SOURCE_STATE_CHANGE="source-state-change",ao.TRACK_ENDED="track-ended",ao.BEAUTY_EFFECT_OVERLOAD="beauty-effect-overload",ao.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",ao.CLOSED="closed",e.RemoteTrackEvents=void 0,(so=e.RemoteTrackEvents||(e.RemoteTrackEvents={})).FIRST_FRAME_DECODED="first-frame-decoded",so.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.AudioSourceEvents=void 0,(co=e.AudioSourceEvents||(e.AudioSourceEvents={})).AUDIO_SOURCE_STATE_CHANGE="audio_source_state_change",co.RECEIVE_TRACK_BUFFER="receive_track_buffer",co.ON_AUDIO_BUFFER="on_audio_buffer",co.UPDATE_SOURCE="update_source",e.AUDIO_TRACK_EVENT=void 0,(e.AUDIO_TRACK_EVENT||(e.AUDIO_TRACK_EVENT={})).UPDATE_TRACK_SOURCE="update-track-source";const uo={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},lo={sendBytes:0,sendBitrate:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,sendResolutionHeight:0,sendResolutionWidth:0,captureResolutionHeight:0,captureResolutionWidth:0,targetSendBitrate:0,totalDuration:0,totalFreezeTime:0,currentPacketLossRate:0},ho={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveLevel:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1},po={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,receiveResolutionHeight:0,receiveResolutionWidth:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1};var go,mo,fo,Eo,To;e.PROCESSOR_DESTINATION_EVENTS=void 0,(go=e.PROCESSOR_DESTINATION_EVENTS||(e.PROCESSOR_DESTINATION_EVENTS={})).ON_TRACK="on_track",go.ON_NODE="on_node",e.PROCESSOR_CONTEXT_EVENTS=void 0,(mo=e.PROCESSOR_CONTEXT_EVENTS||(e.PROCESSOR_CONTEXT_EVENTS={})).REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",mo.REQUEST_CONSTRAINTS="request_constraints",e.DeviceManagerState=void 0,(fo=e.DeviceManagerState||(e.DeviceManagerState={})).IDLE="IDLE",fo.INITING="INITING",fo.INITEND="INITEND",e.DeviceManagerEvent=void 0,(Eo=e.DeviceManagerEvent||(e.DeviceManagerEvent={})).STATE_CHANGE="state_change",Eo.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",Eo.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",Eo.CAMERA_DEVICE_CHANGED="cameraDeviceChanged",e.MediaElementStatus=void 0,(To=e.MediaElementStatus||(e.MediaElementStatus={})).NONE="none",To.INIT="init",To.CANPLAY="canplay",To.PLAYING="playing",To.PAUSED="paused",To.SUSPEND="suspend",To.STALLED="stalled",To.WAITING="waiting",To.ERROR="error",To.DESTROYED="destroyed",To.ABORT="abort",To.ENDED="ended",To.EMPTIED="emptied",To.LOADEDDATA="loadeddata";var vo;e.DataChannelEvents=void 0,(vo=e.DataChannelEvents||(e.DataChannelEvents={})).OPEN="open",vo.MESSAGE="message",vo.CLOSE="close",vo.CLOSING="closing",vo.ERROR="error";var _o={exports:{}},yo=xr,So=B,Ao=ar.f;yo({target:"Object",stat:!0,forced:Object.defineProperty!==Ao,sham:!So},{defineProperty:Ao});var bo=le.Object,Io=_o.exports=function(e,t,r){return bo.defineProperty(e,t,r)};bo.defineProperty.sham&&(Io.sham=!0);var ko=l(_o.exports),Co=N,Oo=Array.isArray||function(e){return"Array"==Co(e)},Ro=TypeError,No=wt,wo=ar,Do=J,Po=function(e,t,r){var i=No(t);i in e?wo.f(e,i,Do(0,r)):e[i]=r},Mo=x,Lo=$e,Vo=T(Function.toString);Mo(Lo.inspectSource)||(Lo.inspectSource=function(e){return Vo(e)});var xo=Lo.inspectSource,Uo=T,Bo=h,Fo=x,jo=Ti,Ho=xo,Go=function(){},Wo=[],Ko=fe("Reflect","construct"),zo=/^\s*(?:class|function)\b/,Xo=Uo(zo.exec),qo=!zo.exec(Go),Jo=function(e){if(!Fo(e))return!1;try{return Ko(Go,Wo,e),!0}catch(e){return!1}},Yo=function(e){if(!Fo(e))return!1;switch(jo(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return qo||!!Xo(zo,Ho(e))}catch(e){return!0}};Yo.sham=!0;var Qo=!Ko||Bo((function(){var e;return Jo(Jo.call)||!Jo(Object)||!Jo((function(){e=!0}))||e}))?Yo:Jo,Zo=Oo,$o=Qo,en=ue,tn=yt("species"),rn=Array,on=function(e){var t;return Zo(e)&&(t=e.constructor,($o(t)&&(t===rn||Zo(t.prototype))||en(t)&&null===(t=t[tn]))&&(t=void 0)),void 0===t?rn:t},nn=function(e,t){return new(on(e))(0===t?0:t)},an=h,sn=be,cn=yt("species"),dn=xr,un=h,ln=Oo,hn=ue,pn=ot,gn=Jr,mn=function(e){if(e>9007199254740991)throw Ro("Maximum allowed index exceeded");return e},fn=Po,En=nn,Tn=function(e){return sn>=51||!an((function(){var t=[];return(t.constructor={})[cn]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},vn=be,_n=yt("isConcatSpreadable"),yn=vn>=51||!un((function(){var e=[];return e[_n]=!1,e.concat()[0]!==e})),Sn=function(e){if(!hn(e))return!1;var t=e[_n];return void 0!==t?!!t:ln(e)};dn({target:"Array",proto:!0,arity:1,forced:!yn||!Tn("concat")},{concat:function(e){var t,r,i,o,n,a=pn(this),s=En(a,0),c=0;for(t=-1,i=arguments.length;t<i;t++)if(Sn(n=-1===t?a:arguments[t]))for(o=gn(n),mn(c+o),r=0;r<o;r++,c++)r in n&&fn(s,c,n[r]);else mn(c+1),fn(s,c++,n);return s.length=c,s}});var An={},bn={},In=st,kn=se,Cn=ei.indexOf,On=bn,Rn=T([].push),Nn=function(e,t){var r,i=kn(e),o=0,n=[];for(r in i)!In(On,r)&&In(i,r)&&Rn(n,r);for(;t.length>o;)In(i,r=t[o++])&&(~Cn(n,r)||Rn(n,r));return n},wn=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Dn=Nn,Pn=wn,Mn=Object.keys||function(e){return Dn(e,Pn)},Ln=B,Vn=sr,xn=ar,Un=lr,Bn=se,Fn=Mn;An.f=Ln&&!Vn?Object.defineProperties:function(e,t){Un(e);for(var r,i=Bn(t),o=Fn(t),n=o.length,a=0;n>a;)xn.f(e,r=o[a++],i[r]);return e};var jn,Hn=fe("document","documentElement"),Gn=ht,Wn=tt("keys"),Kn=function(e){return Wn[e]||(Wn[e]=Gn(e))},zn=lr,Xn=An,qn=wn,Jn=bn,Yn=Hn,Qn=Lt,Zn="prototype",$n="script",ea=Kn("IE_PROTO"),ta=function(){},ra=function(e){return"<"+$n+">"+e+"</"+$n+">"},ia=function(e){e.write(ra("")),e.close();var t=e.parentWindow.Object;return e=null,t},oa=function(){try{jn=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;oa="undefined"!=typeof document?document.domain&&jn?ia(jn):(t=Qn("iframe"),r="java"+$n+":",t.style.display="none",Yn.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(ra("document.F=Object")),e.close(),e.F):ia(jn);for(var i=qn.length;i--;)delete oa[Zn][qn[i]];return oa()};Jn[ea]=!0;var na=Object.create||function(e,t){var r;return null!==e?(ta[Zn]=zn(e),r=new ta,ta[Zn]=null,r[ea]=e):r=oa(),void 0===t?r:Xn.f(r,t)},aa={},sa=Nn,ca=wn.concat("length","prototype");aa.f=Object.getOwnPropertyNames||function(e){return sa(e,ca)};var da={},ua=Kr,la=Jr,ha=Po,pa=Array,ga=Math.max,ma=N,fa=se,Ea=aa.f,Ta=function(e,t,r){for(var i=la(e),o=ua(t,i),n=ua(void 0===r?i:r,i),a=pa(ga(n-o,0)),s=0;o<n;o++,s++)ha(a,s,e[o]);return a.length=s,a},va="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];da.f=function(e){return va&&"Window"==ma(e)?function(e){try{return Ea(e)}catch(e){return Ta(va)}}(e):Ea(fa(e))};var _a={};_a.f=Object.getOwnPropertySymbols;var ya=Ir,Sa=function(e,t,r,i){return i&&i.enumerable?e[t]=r:ya(e,t,r),e},Aa=ar,ba=function(e,t,r){return Aa.f(e,t,r)},Ia={},ka=yt;Ia.f=ka;var Ca,Oa,Ra,Na=le,wa=st,Da=Ia,Pa=ar.f,Ma=function(e){var t=Na.Symbol||(Na.Symbol={});wa(t,e)||Pa(t,e,{value:Da.f(e)})},La=H,Va=fe,xa=yt,Ua=Sa,Ba=function(){var e=Va("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,i=xa("toPrimitive");t&&!t[i]&&Ua(t,i,(function(e){return La(r,this)}),{arity:1})},Fa=Ti,ja=li?{}.toString:function(){return"[object "+Fa(this)+"]"},Ha=li,Ga=ar.f,Wa=Ir,Ka=st,za=ja,Xa=yt("toStringTag"),qa=function(e,t,r,i){if(e){var o=r?e:e.prototype;Ka(o,Xa)||Ga(o,Xa,{configurable:!0,value:t}),i&&!Ha&&Wa(o,"toString",za)}},Ja=x,Ya=y.WeakMap,Qa=Ja(Ya)&&/native code/.test(String(Ya)),Za=y,$a=ue,es=Ir,ts=st,rs=$e,is=Kn,os=bn,ns="Object already initialized",as=Za.TypeError,ss=Za.WeakMap;if(Qa||rs.state){var cs=rs.state||(rs.state=new ss);cs.get=cs.get,cs.has=cs.has,cs.set=cs.set,Ca=function(e,t){if(cs.has(e))throw as(ns);return t.facade=e,cs.set(e,t),t},Oa=function(e){return cs.get(e)||{}},Ra=function(e){return cs.has(e)}}else{var ds=is("state");os[ds]=!0,Ca=function(e,t){if(ts(e,ds))throw as(ns);return t.facade=e,es(e,ds,t),t},Oa=function(e){return ts(e,ds)?e[ds]:{}},Ra=function(e){return ts(e,ds)}}var us={set:Ca,get:Oa,has:Ra,enforce:function(e){return Ra(e)?Oa(e):Ca(e,{})},getterFor:function(e){return function(t){var r;if(!$a(t)||(r=Oa(t)).type!==e)throw as("Incompatible receiver, "+e+" required");return r}}},ls=nr,hs=ee,ps=ot,gs=Jr,ms=nn,fs=T([].push),Es=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,d,u,l){for(var h,p,g=ps(c),m=hs(g),f=ls(d,u),E=gs(m),T=0,v=l||ms,_=t?v(c,E):r||a?v(c,0):void 0;E>T;T++)if((s||T in m)&&(p=f(h=m[T],T,g),e))if(t)_[T]=p;else if(p)switch(e){case 3:return!0;case 5:return h;case 6:return T;case 2:fs(_,h)}else switch(e){case 4:return!1;case 7:fs(_,h)}return n?-1:i||o?o:_}},Ts={forEach:Es(0),map:Es(1),filter:Es(2),some:Es(3),every:Es(4),find:Es(5),findIndex:Es(6),filterReject:Es(7)},vs=xr,_s=y,ys=H,Ss=T,As=B,bs=Oe,Is=h,ks=st,Cs=v,Os=lr,Rs=se,Ns=wt,ws=yi,Ds=J,Ps=na,Ms=Mn,Ls=aa,Vs=da,xs=_a,Us=U,Bs=ar,Fs=An,js=G,Hs=Sa,Gs=ba,Ws=tt,Ks=bn,zs=ht,Xs=yt,qs=Ia,Js=Ma,Ys=Ba,Qs=qa,Zs=us,$s=Ts.forEach,ec=Kn("hidden"),tc="Symbol",rc="prototype",ic=Zs.set,oc=Zs.getterFor(tc),nc=Object[rc],ac=_s.Symbol,sc=ac&&ac[rc],cc=_s.TypeError,dc=_s.QObject,uc=Us.f,lc=Bs.f,hc=Vs.f,pc=js.f,gc=Ss([].push),mc=Ws("symbols"),fc=Ws("op-symbols"),Ec=Ws("wks"),Tc=!dc||!dc[rc]||!dc[rc].findChild,vc=As&&Is((function(){return 7!=Ps(lc({},"a",{get:function(){return lc(this,"a",{value:7}).a}})).a}))?function(e,t,r){var i=uc(nc,t);i&&delete nc[t],lc(e,t,r),i&&e!==nc&&lc(nc,t,i)}:lc,_c=function(e,t){var r=mc[e]=Ps(sc);return ic(r,{type:tc,tag:e,description:t}),As||(r.description=t),r},yc=function(e,t,r){e===nc&&yc(fc,t,r),Os(e);var i=Ns(t);return Os(r),ks(mc,i)?(r.enumerable?(ks(e,ec)&&e[ec][i]&&(e[ec][i]=!1),r=Ps(r,{enumerable:Ds(0,!1)})):(ks(e,ec)||lc(e,ec,Ds(1,{})),e[ec][i]=!0),vc(e,i,r)):lc(e,i,r)},Sc=function(e,t){Os(e);var r=Rs(t),i=Ms(r).concat(kc(r));return $s(i,(function(t){As&&!ys(Ac,r,t)||yc(e,t,r[t])})),e},Ac=function(e){var t=Ns(e),r=ys(pc,this,t);return!(this===nc&&ks(mc,t)&&!ks(fc,t))&&(!(r||!ks(this,t)||!ks(mc,t)||ks(this,ec)&&this[ec][t])||r)},bc=function(e,t){var r=Rs(e),i=Ns(t);if(r!==nc||!ks(mc,i)||ks(fc,i)){var o=uc(r,i);return!o||!ks(mc,i)||ks(r,ec)&&r[ec][i]||(o.enumerable=!0),o}},Ic=function(e){var t=hc(Rs(e)),r=[];return $s(t,(function(e){ks(mc,e)||ks(Ks,e)||gc(r,e)})),r},kc=function(e){var t=e===nc,r=hc(t?fc:Rs(e)),i=[];return $s(r,(function(e){!ks(mc,e)||t&&!ks(nc,e)||gc(i,mc[e])})),i};bs||(ac=function(){if(Cs(sc,this))throw cc("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?ws(arguments[0]):void 0,t=zs(e),r=function(e){this===nc&&ys(r,fc,e),ks(this,ec)&&ks(this[ec],t)&&(this[ec][t]=!1),vc(this,t,Ds(1,e))};return As&&Tc&&vc(nc,t,{configurable:!0,set:r}),_c(t,e)},Hs(sc=ac[rc],"toString",(function(){return oc(this).tag})),Hs(ac,"withoutSetter",(function(e){return _c(zs(e),e)})),js.f=Ac,Bs.f=yc,Fs.f=Sc,Us.f=bc,Ls.f=Vs.f=Ic,xs.f=kc,qs.f=function(e){return _c(Xs(e),e)},As&&Gs(sc,"description",{configurable:!0,get:function(){return oc(this).description}})),vs({global:!0,constructor:!0,wrap:!0,forced:!bs,sham:!bs},{Symbol:ac}),$s(Ms(Ec),(function(e){Js(e)})),vs({target:tc,stat:!0,forced:!bs},{useSetter:function(){Tc=!0},useSimple:function(){Tc=!1}}),vs({target:"Object",stat:!0,forced:!bs,sham:!As},{create:function(e,t){return void 0===t?Ps(e):Sc(Ps(e),t)},defineProperty:yc,defineProperties:Sc,getOwnPropertyDescriptor:bc}),vs({target:"Object",stat:!0,forced:!bs},{getOwnPropertyNames:Ic}),Ys(),Qs(ac,tc),Ks[ec]=!0;var Cc=Oe&&!!Symbol.for&&!!Symbol.keyFor,Oc=xr,Rc=fe,Nc=st,wc=yi,Dc=tt,Pc=Cc,Mc=Dc("string-to-symbol-registry"),Lc=Dc("symbol-to-string-registry");Oc({target:"Symbol",stat:!0,forced:!Pc},{for:function(e){var t=wc(e);if(Nc(Mc,t))return Mc[t];var r=Rc("Symbol")(t);return Mc[t]=r,Lc[r]=t,r}});var Vc=xr,xc=st,Uc=Me,Bc=Ve,Fc=Cc,jc=tt("symbol-to-string-registry");Vc({target:"Symbol",stat:!0,forced:!Fc},{keyFor:function(e){if(!Uc(e))throw TypeError(Bc(e)+" is not a symbol");if(xc(jc,e))return jc[e]}});var Hc=T([].slice),Gc=Oo,Wc=x,Kc=N,zc=yi,Xc=T([].push),qc=xr,Jc=fe,Yc=k,Qc=H,Zc=T,$c=h,ed=x,td=Me,rd=Hc,id=function(e){if(Wc(e))return e;if(Gc(e)){for(var t=e.length,r=[],i=0;i<t;i++){var o=e[i];"string"==typeof o?Xc(r,o):"number"!=typeof o&&"Number"!=Kc(o)&&"String"!=Kc(o)||Xc(r,zc(o))}var n=r.length,a=!0;return function(e,t){if(a)return a=!1,t;if(Gc(this))return t;for(var i=0;i<n;i++)if(r[i]===e)return t}}},od=Oe,nd=String,ad=Jc("JSON","stringify"),sd=Zc(/./.exec),cd=Zc("".charAt),dd=Zc("".charCodeAt),ud=Zc("".replace),ld=Zc(1..toString),hd=/[\uD800-\uDFFF]/g,pd=/^[\uD800-\uDBFF]$/,gd=/^[\uDC00-\uDFFF]$/,md=!od||$c((function(){var e=Jc("Symbol")();return"[null]"!=ad([e])||"{}"!=ad({a:e})||"{}"!=ad(Object(e))})),fd=$c((function(){return'"\\udf06\\ud834"'!==ad("\udf06\ud834")||'"\\udead"'!==ad("\udead")})),Ed=function(e,t){var r=rd(arguments),i=id(t);if(ed(i)||void 0!==e&&!td(e))return r[1]=function(e,t){if(ed(i)&&(t=Qc(i,this,nd(e),t)),!td(t))return t},Yc(ad,null,r)},Td=function(e,t,r){var i=cd(r,t-1),o=cd(r,t+1);return sd(pd,e)&&!sd(gd,o)||sd(gd,e)&&!sd(pd,i)?"\\u"+ld(dd(e,0),16):e};ad&&qc({target:"JSON",stat:!0,arity:3,forced:md||fd},{stringify:function(e,t,r){var i=rd(arguments),o=Yc(md?Ed:ad,null,i);return fd&&"string"==typeof o?ud(o,hd,Td):o}});var vd=_a,_d=ot;xr({target:"Object",stat:!0,forced:!Oe||h((function(){vd.f(1)}))},{getOwnPropertySymbols:function(e){var t=vd.f;return t?t(_d(e)):[]}}),Ma("asyncIterator"),Ma("hasInstance"),Ma("isConcatSpreadable"),Ma("iterator"),Ma("match"),Ma("matchAll"),Ma("replace"),Ma("search"),Ma("species"),Ma("split");var yd=Ba;Ma("toPrimitive"),yd();var Sd=fe,Ad=qa;Ma("toStringTag"),Ad(Sd("Symbol"),"Symbol"),Ma("unscopables"),qa(y.JSON,"JSON",!0);var bd,Id,kd,Cd=le.Symbol,Od={},Rd=B,Nd=st,wd=Function.prototype,Dd=Rd&&Object.getOwnPropertyDescriptor,Pd=Nd(wd,"name"),Md={EXISTS:Pd,PROPER:Pd&&"something"===function(){}.name,CONFIGURABLE:Pd&&(!Rd||Rd&&Dd(wd,"name").configurable)},Ld=!h((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Vd=st,xd=x,Ud=ot,Bd=Ld,Fd=Kn("IE_PROTO"),jd=Object,Hd=jd.prototype,Gd=Bd?jd.getPrototypeOf:function(e){var t=Ud(e);if(Vd(t,Fd))return t[Fd];var r=t.constructor;return xd(r)&&t instanceof r?r.prototype:t instanceof jd?Hd:null},Wd=h,Kd=x,zd=ue,Xd=na,qd=Gd,Jd=Sa,Yd=yt("iterator"),Qd=!1;[].keys&&("next"in(kd=[].keys())?(Id=qd(qd(kd)))!==Object.prototype&&(bd=Id):Qd=!0);var Zd=!zd(bd)||Wd((function(){var e={};return bd[Yd].call(e)!==e}));Kd((bd=Zd?{}:Xd(bd))[Yd])||Jd(bd,Yd,(function(){return this}));var $d={IteratorPrototype:bd,BUGGY_SAFARI_ITERATORS:Qd},eu=$d.IteratorPrototype,tu=na,ru=J,iu=qa,ou=Od,nu=function(){return this},au=T,su=Fe,cu=x,du=String,uu=TypeError,lu=function(e,t,r){try{return au(su(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(e){}},hu=lr,pu=function(e){if("object"==typeof e||cu(e))return e;throw uu("Can't set "+du(e)+" as a prototype")},gu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=lu(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(e){}return function(r,i){return hu(r),pu(i),t?e(r,i):r.__proto__=i,r}}():void 0),mu=xr,fu=H,Eu=Md,Tu=function(e,t,r,i){var o=t+" Iterator";return e.prototype=tu(eu,{next:ru(+!i,r)}),iu(e,o,!1,!0),ou[o]=nu,e},vu=Gd,_u=qa,yu=Sa,Su=Od,Au=$d,bu=Eu.PROPER,Iu=Au.BUGGY_SAFARI_ITERATORS,ku=yt("iterator"),Cu="keys",Ou="values",Ru="entries",Nu=function(){return this},wu=function(e,t,r,i,o,n,a){Tu(r,t,i);var s,c,d,u=function(e){if(e===o&&m)return m;if(!Iu&&e in p)return p[e];switch(e){case Cu:case Ou:case Ru:return function(){return new r(this,e)}}return function(){return new r(this)}},l=t+" Iterator",h=!1,p=e.prototype,g=p[ku]||p["@@iterator"]||o&&p[o],m=!Iu&&g||u(o),f="Array"==t&&p.entries||g;if(f&&(s=vu(f.call(new e)))!==Object.prototype&&s.next&&(_u(s,l,!0,!0),Su[l]=Nu),bu&&o==Ou&&g&&g.name!==Ou&&(h=!0,m=function(){return fu(g,this)}),o)if(c={values:u(Ou),keys:n?m:u(Cu),entries:u(Ru)},a)for(d in c)(Iu||h||!(d in p))&&yu(p,d,c[d]);else mu({target:t,proto:!0,forced:Iu||h},c);return a&&p[ku]!==m&&yu(p,ku,m,{name:o}),Su[t]=m,c},Du=function(e,t){return{value:e,done:t}},Pu=se,Mu=Od,Lu=us;ar.f;var Vu=wu,xu=Du,Uu="Array Iterator",Bu=Lu.set,Fu=Lu.getterFor(Uu);Vu(Array,"Array",(function(e,t){Bu(this,{type:Uu,target:Pu(e),index:0,kind:t})}),(function(){var e=Fu(this),t=e.target,r=e.kind,i=e.index++;return!t||i>=t.length?(e.target=void 0,xu(void 0,!0)):xu("keys"==r?i:"values"==r?t[i]:[i,t[i]],!1)}),"values"),Mu.Arguments=Mu.Array;var ju={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},Hu=y,Gu=Ti,Wu=Ir,Ku=Od,zu=yt("toStringTag");for(var Xu in ju){var qu=Hu[Xu],Ju=qu&&qu.prototype;Ju&&Gu(Ju)!==zu&&Wu(Ju,zu,Xu),Ku[Xu]=Ku.Array}var Yu=Cd,Qu=yt,Zu=ar.f,$u=Qu("metadata"),el=Function.prototype;void 0===el[$u]&&Zu(el,$u,{value:null}),Ma("dispose"),Ma("metadata");var tl=Yu;Ma("asyncDispose");var rl=T,il=fe("Symbol"),ol=il.keyFor,nl=rl(il.prototype.valueOf),al=il.isRegisteredSymbol||function(e){try{return void 0!==ol(nl(e))}catch(e){return!1}};xr({target:"Symbol",stat:!0},{isRegisteredSymbol:al});for(var sl=tt,cl=fe,dl=T,ul=Me,ll=yt,hl=cl("Symbol"),pl=hl.isWellKnownSymbol,gl=cl("Object","getOwnPropertyNames"),ml=dl(hl.prototype.valueOf),fl=sl("wks"),El=0,Tl=gl(hl),vl=Tl.length;El<vl;El++)try{var _l=Tl[El];ul(hl[_l])&&ll(_l)}catch(e){}var yl=function(e){if(pl&&pl(e))return!0;try{for(var t=ml(e),r=0,i=gl(fl),o=i.length;r<o;r++)if(fl[i[r]]==t)return!0}catch(e){}return!1};xr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:yl}),Ma("matcher"),Ma("observable"),xr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:al}),xr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:yl}),Ma("metadataKey"),Ma("patternMatch"),Ma("replaceAll");var Sl=l(tl),Al=T,bl=jr,Il=yi,kl=oe,Cl=Al("".charAt),Ol=Al("".charCodeAt),Rl=Al("".slice),Nl=function(e){return function(t,r){var i,o,n=Il(kl(t)),a=bl(r),s=n.length;return a<0||a>=s?e?"":void 0:(i=Ol(n,a))<55296||i>56319||a+1===s||(o=Ol(n,a+1))<56320||o>57343?e?Cl(n,a):i:e?Rl(n,a,a+2):o-56320+(i-55296<<10)+65536}},wl={codeAt:Nl(!1),charAt:Nl(!0)}.charAt,Dl=yi,Pl=us,Ml=wu,Ll=Du,Vl="String Iterator",xl=Pl.set,Ul=Pl.getterFor(Vl);Ml(String,"String",(function(e){xl(this,{type:Vl,string:Dl(e),index:0})}),(function(){var e,t=Ul(this),r=t.string,i=t.index;return i>=r.length?Ll(void 0,!0):(e=wl(r,i),t.index+=e.length,Ll(e,!1))}));var Bl=l(Ia.f("iterator"));function Fl(e){return Fl="function"==typeof Sl&&"symbol"==typeof Bl?function(e){return typeof e}:function(e){return e&&"function"==typeof Sl&&e.constructor===Sl&&e!==Sl.prototype?"symbol":typeof e},Fl(e)}var jl=l(Ia.f("toPrimitive"));function Hl(e){var t=function(e,t){if("object"!==Fl(e)||null===e)return e;var r=e[jl];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==Fl(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Fl(t)?t:String(t)}function Gl(e,t,r){return(t=Hl(t))in e?ko(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Wl=fe,Kl=aa,zl=_a,Xl=lr,ql=T([].concat),Jl=Wl("Reflect","ownKeys")||function(e){var t=Kl.f(Xl(e)),r=zl.f;return r?ql(t,r(e)):t},Yl=st,Ql=Jl,Zl=U,$l=ar,eh=ue,th=Ir,rh=Error,ih=T("".replace),oh=String(rh("zxcasd").stack),nh=/\n\s*at [^:]*:[^\n]*/,ah=nh.test(oh),sh=J,ch=!h((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",sh(1,7)),7!==e.stack)})),dh=Ir,uh=function(e,t){if(ah&&"string"==typeof e&&!rh.prepareStackTrace)for(;t--;)e=ih(e,nh,"");return e},lh=ch,hh=Error.captureStackTrace,ph=Od,gh=yt("iterator"),mh=Array.prototype,fh=Ti,Eh=Ge,Th=te,vh=Od,_h=yt("iterator"),yh=function(e){if(!Th(e))return Eh(e,_h)||Eh(e,"@@iterator")||vh[fh(e)]},Sh=H,Ah=Fe,bh=lr,Ih=Ve,kh=yh,Ch=TypeError,Oh=H,Rh=lr,Nh=Ge,wh=nr,Dh=H,Ph=lr,Mh=Ve,Lh=function(e){return void 0!==e&&(ph.Array===e||mh[gh]===e)},Vh=Jr,xh=v,Uh=function(e,t){var r=arguments.length<2?kh(e):t;if(Ah(r))return bh(Sh(r,e));throw Ch(Ih(e)+" is not iterable")},Bh=yh,Fh=function(e,t,r){var i,o;Rh(e);try{if(!(i=Nh(e,"return"))){if("throw"===t)throw r;return r}i=Oh(i,e)}catch(e){o=!0,i=e}if("throw"===t)throw r;if(o)throw i;return Rh(i),r},jh=TypeError,Hh=function(e,t){this.stopped=e,this.result=t},Gh=Hh.prototype,Wh=function(e,t,r){var i,o,n,a,s,c,d,u=r&&r.that,l=!(!r||!r.AS_ENTRIES),h=!(!r||!r.IS_RECORD),p=!(!r||!r.IS_ITERATOR),g=!(!r||!r.INTERRUPTED),m=wh(t,u),f=function(e){return i&&Fh(i,"normal",e),new Hh(!0,e)},E=function(e){return l?(Ph(e),g?m(e[0],e[1],f):m(e[0],e[1])):g?m(e,f):m(e)};if(h)i=e.iterator;else if(p)i=e;else{if(!(o=Bh(e)))throw jh(Mh(e)+" is not iterable");if(Lh(o)){for(n=0,a=Vh(e);a>n;n++)if((s=E(e[n]))&&xh(Gh,s))return s;return new Hh(!1)}i=Uh(e,o)}for(c=h?e.next:i.next;!(d=Dh(c,i)).done;){try{s=E(d.value)}catch(e){Fh(i,"throw",e)}if("object"==typeof s&&s&&xh(Gh,s))return s}return new Hh(!1)},Kh=yi,zh=xr,Xh=v,qh=Gd,Jh=gu,Yh=function(e,t,r){for(var i=Ql(t),o=$l.f,n=Zl.f,a=0;a<i.length;a++){var s=i[a];Yl(e,s)||r&&Yl(r,s)||o(e,s,n(t,s))}},Qh=na,Zh=Ir,$h=J,ep=function(e,t){eh(t)&&"cause"in t&&th(e,"cause",t.cause)},tp=function(e,t,r,i){lh&&(hh?hh(e,t):dh(e,"stack",uh(r,i)))},rp=Wh,ip=function(e,t){return void 0===e?arguments.length<2?"":t:Kh(e)},op=yt("toStringTag"),np=Error,ap=[].push,sp=function(e,t){var r,i=Xh(cp,this);Jh?r=Jh(np(),i?qh(this):cp):(r=i?this:Qh(cp),Zh(r,op,"Error")),void 0!==t&&Zh(r,"message",ip(t)),tp(r,sp,r.stack,1),arguments.length>2&&ep(r,arguments[2]);var o=[];return rp(e,ap,{that:o}),Zh(r,"errors",o),r};Jh?Jh(sp,np):Yh(sp,np,{name:!0});var cp=sp.prototype=Qh(np.prototype,{constructor:$h(1,sp),message:$h(1,""),name:$h(1,"AggregateError")});zh({global:!0,constructor:!0,arity:2},{AggregateError:sp});var dp,up,lp,hp,pp="undefined"!=typeof process&&"process"==N(process),gp=fe,mp=ba,fp=B,Ep=yt("species"),Tp=v,vp=TypeError,_p=Qo,yp=Ve,Sp=TypeError,Ap=lr,bp=function(e){if(_p(e))return e;throw Sp(yp(e)+" is not a constructor")},Ip=te,kp=yt("species"),Cp=function(e,t){var r,i=Ap(e).constructor;return void 0===i||Ip(r=Ap(i)[kp])?t:bp(r)},Op=TypeError,Rp=/(?:ipad|iphone|ipod).*applewebkit/i.test(Ee),Np=y,wp=k,Dp=nr,Pp=x,Mp=st,Lp=h,Vp=Hn,xp=Hc,Up=Lt,Bp=function(e,t){if(e<t)throw Op("Not enough arguments");return e},Fp=Rp,jp=pp,Hp=Np.setImmediate,Gp=Np.clearImmediate,Wp=Np.process,Kp=Np.Dispatch,zp=Np.Function,Xp=Np.MessageChannel,qp=Np.String,Jp=0,Yp={},Qp="onreadystatechange";Lp((function(){dp=Np.location}));var Zp=function(e){if(Mp(Yp,e)){var t=Yp[e];delete Yp[e],t()}},$p=function(e){return function(){Zp(e)}},eg=function(e){Zp(e.data)},tg=function(e){Np.postMessage(qp(e),dp.protocol+"//"+dp.host)};Hp&&Gp||(Hp=function(e){Bp(arguments.length,1);var t=Pp(e)?e:zp(e),r=xp(arguments,1);return Yp[++Jp]=function(){wp(t,void 0,r)},up(Jp),Jp},Gp=function(e){delete Yp[e]},jp?up=function(e){Wp.nextTick($p(e))}:Kp&&Kp.now?up=function(e){Kp.now($p(e))}:Xp&&!Fp?(hp=(lp=new Xp).port2,lp.port1.onmessage=eg,up=Dp(hp.postMessage,hp)):Np.addEventListener&&Pp(Np.postMessage)&&!Np.importScripts&&dp&&"file:"!==dp.protocol&&!Lp(tg)?(up=tg,Np.addEventListener("message",eg,!1)):up=Qp in Up("script")?function(e){Vp.appendChild(Up("script"))[Qp]=function(){Vp.removeChild(this),Zp(e)}}:function(e){setTimeout($p(e),0)});var rg={set:Hp,clear:Gp},ig=function(){this.head=null,this.tail=null};ig.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 og,ng,ag,sg,cg,dg=ig,ug=/ipad|iphone|ipod/i.test(Ee)&&"undefined"!=typeof Pebble,lg=/web0s(?!.*chrome)/i.test(Ee),hg=y,pg=nr,gg=U.f,mg=rg.set,fg=dg,Eg=Rp,Tg=ug,vg=lg,_g=pp,yg=hg.MutationObserver||hg.WebKitMutationObserver,Sg=hg.document,Ag=hg.process,bg=hg.Promise,Ig=gg(hg,"queueMicrotask"),kg=Ig&&Ig.value;if(!kg){var Cg=new fg,Og=function(){var e,t;for(_g&&(e=Ag.domain)&&e.exit();t=Cg.get();)try{t()}catch(e){throw Cg.head&&og(),e}e&&e.enter()};Eg||_g||vg||!yg||!Sg?!Tg&&bg&&bg.resolve?((sg=bg.resolve(void 0)).constructor=bg,cg=pg(sg.then,sg),og=function(){cg(Og)}):_g?og=function(){Ag.nextTick(Og)}:(mg=pg(mg,hg),og=function(){mg(Og)}):(ng=!0,ag=Sg.createTextNode(""),new yg(Og).observe(ag,{characterData:!0}),og=function(){ag.data=ng=!ng}),kg=function(e){Cg.head||og(),Cg.add(e)}}var Rg=kg,Ng=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},wg=y.Promise,Dg="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Pg=!Dg&&!pp&&"object"==typeof window&&"object"==typeof document,Mg=y,Lg=wg,Vg=x,xg=tr,Ug=xo,Bg=yt,Fg=Pg,jg=Dg,Hg=be,Gg=Lg&&Lg.prototype,Wg=Bg("species"),Kg=!1,zg=Vg(Mg.PromiseRejectionEvent),Xg=xg("Promise",(function(){var e=Ug(Lg),t=e!==String(Lg);if(!t&&66===Hg)return!0;if(!Gg.catch||!Gg.finally)return!0;if(!Hg||Hg<51||!/native code/.test(e)){var r=new Lg((function(e){e(1)})),i=function(e){e((function(){}),(function(){}))};if((r.constructor={})[Wg]=i,!(Kg=r.then((function(){}))instanceof i))return!0}return!t&&(Fg||jg)&&!zg})),qg={CONSTRUCTOR:Xg,REJECTION_EVENT:zg,SUBCLASSING:Kg},Jg={},Yg=Fe,Qg=TypeError,Zg=function(e){var t,r;this.promise=new e((function(e,i){if(void 0!==t||void 0!==r)throw Qg("Bad Promise constructor");t=e,r=i})),this.resolve=Yg(t),this.reject=Yg(r)};Jg.f=function(e){return new Zg(e)};var $g,em,tm=xr,rm=pp,im=y,om=H,nm=Sa,am=qa,sm=function(e){var t=gp(e);fp&&t&&!t[Ep]&&mp(t,Ep,{configurable:!0,get:function(){return this}})},cm=Fe,dm=x,um=ue,lm=function(e,t){if(Tp(t,e))return e;throw vp("Incorrect invocation")},hm=Cp,pm=rg.set,gm=Rg,mm=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},fm=Ng,Em=dg,Tm=us,vm=wg,_m=qg,ym=Jg,Sm="Promise",Am=_m.CONSTRUCTOR,bm=_m.REJECTION_EVENT,Im=Tm.getterFor(Sm),km=Tm.set,Cm=vm&&vm.prototype,Om=vm,Rm=Cm,Nm=im.TypeError,wm=im.document,Dm=im.process,Pm=ym.f,Mm=Pm,Lm=!!(wm&&wm.createEvent&&im.dispatchEvent),Vm="unhandledrejection",xm=function(e){var t;return!(!um(e)||!dm(t=e.then))&&t},Um=function(e,t){var r,i,o,n=t.value,a=1==t.state,s=a?e.ok:e.fail,c=e.resolve,d=e.reject,u=e.domain;try{s?(a||(2===t.rejection&&Gm(t),t.rejection=1),!0===s?r=n:(u&&u.enter(),r=s(n),u&&(u.exit(),o=!0)),r===e.promise?d(Nm("Promise-chain cycle")):(i=xm(r))?om(i,r,c,d):c(r)):d(n)}catch(e){u&&!o&&u.exit(),d(e)}},Bm=function(e,t){e.notified||(e.notified=!0,gm((function(){for(var r,i=e.reactions;r=i.get();)Um(r,e);e.notified=!1,t&&!e.rejection&&jm(e)})))},Fm=function(e,t,r){var i,o;Lm?((i=wm.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),im.dispatchEvent(i)):i={promise:t,reason:r},!bm&&(o=im["on"+e])?o(i):e===Vm&&mm("Unhandled promise rejection",r)},jm=function(e){om(pm,im,(function(){var t,r=e.facade,i=e.value;if(Hm(e)&&(t=fm((function(){rm?Dm.emit("unhandledRejection",i,r):Fm(Vm,r,i)})),e.rejection=rm||Hm(e)?2:1,t.error))throw t.value}))},Hm=function(e){return 1!==e.rejection&&!e.parent},Gm=function(e){om(pm,im,(function(){var t=e.facade;rm?Dm.emit("rejectionHandled",t):Fm("rejectionhandled",t,e.value)}))},Wm=function(e,t,r){return function(i){e(t,i,r)}},Km=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Bm(e,!0))},zm=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw Nm("Promise can't be resolved itself");var i=xm(t);i?gm((function(){var r={done:!1};try{om(i,t,Wm(zm,r,e),Wm(Km,r,e))}catch(t){Km(r,t,e)}})):(e.value=t,e.state=1,Bm(e,!1))}catch(t){Km({done:!1},t,e)}}};Am&&(Rm=(Om=function(e){lm(this,Rm),cm(e),om($g,this);var t=Im(this);try{e(Wm(zm,t),Wm(Km,t))}catch(e){Km(t,e)}}).prototype,($g=function(e){km(this,{type:Sm,done:!1,notified:!1,parent:!1,reactions:new Em,rejection:!1,state:0,value:void 0})}).prototype=nm(Rm,"then",(function(e,t){var r=Im(this),i=Pm(hm(this,Om));return r.parent=!0,i.ok=!dm(e)||e,i.fail=dm(t)&&t,i.domain=rm?Dm.domain:void 0,0==r.state?r.reactions.add(i):gm((function(){Um(i,r)})),i.promise})),em=function(){var e=new $g,t=Im(e);this.promise=e,this.resolve=Wm(zm,t),this.reject=Wm(Km,t)},ym.f=Pm=function(e){return e===Om||undefined===e?new em(e):Mm(e)}),tm({global:!0,constructor:!0,wrap:!0,forced:Am},{Promise:Om}),am(Om,Sm,!1,!0),sm(Sm);var Xm=yt("iterator"),qm=!1;try{var Jm=0,Ym={next:function(){return{done:!!Jm++}},return:function(){qm=!0}};Ym[Xm]=function(){return this},Array.from(Ym,(function(){throw 2}))}catch(e){}var Qm=wg,Zm=function(e,t){if(!t&&!qm)return!1;var r=!1;try{var i={};i[Xm]=function(){return{next:function(){return{done:r=!0}}}},e(i)}catch(e){}return r},$m=qg.CONSTRUCTOR||!Zm((function(e){Qm.all(e).then(void 0,(function(){}))})),ef=H,tf=Fe,rf=Jg,of=Ng,nf=Wh;xr({target:"Promise",stat:!0,forced:$m},{all:function(e){var t=this,r=rf.f(t),i=r.resolve,o=r.reject,n=of((function(){var r=tf(t.resolve),n=[],a=0,s=1;nf(e,(function(e){var c=a++,d=!1;s++,ef(r,t,e).then((function(e){d||(d=!0,n[c]=e,--s||i(n))}),o)})),--s||i(n)}));return n.error&&o(n.value),r.promise}});var af=xr,sf=qg.CONSTRUCTOR;wg&&wg.prototype,af({target:"Promise",proto:!0,forced:sf,real:!0},{catch:function(e){return this.then(void 0,e)}});var cf=H,df=Fe,uf=Jg,lf=Ng,hf=Wh;xr({target:"Promise",stat:!0,forced:$m},{race:function(e){var t=this,r=uf.f(t),i=r.reject,o=lf((function(){var o=df(t.resolve);hf(e,(function(e){cf(o,t,e).then(r.resolve,i)}))}));return o.error&&i(o.value),r.promise}});var pf=H,gf=Jg;xr({target:"Promise",stat:!0,forced:qg.CONSTRUCTOR},{reject:function(e){var t=gf.f(this);return pf(t.reject,void 0,e),t.promise}});var mf=lr,ff=ue,Ef=Jg,Tf=function(e,t){if(mf(e),ff(t)&&t.constructor===e)return t;var r=Ef.f(e);return(0,r.resolve)(t),r.promise},vf=xr,_f=wg,yf=qg.CONSTRUCTOR,Sf=Tf,Af=fe("Promise"),bf=!yf;vf({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Sf(bf&&this===Af?_f:this,e)}});var If=H,kf=Fe,Cf=Jg,Of=Ng,Rf=Wh;xr({target:"Promise",stat:!0,forced:$m},{allSettled:function(e){var t=this,r=Cf.f(t),i=r.resolve,o=r.reject,n=Of((function(){var r=kf(t.resolve),o=[],n=0,a=1;Rf(e,(function(e){var s=n++,c=!1;a++,If(r,t,e).then((function(e){c||(c=!0,o[s]={status:"fulfilled",value:e},--a||i(o))}),(function(e){c||(c=!0,o[s]={status:"rejected",reason:e},--a||i(o))}))})),--a||i(o)}));return n.error&&o(n.value),r.promise}});var Nf=H,wf=Fe,Df=fe,Pf=Jg,Mf=Ng,Lf=Wh,Vf="No one promise resolved";xr({target:"Promise",stat:!0,forced:$m},{any:function(e){var t=this,r=Df("AggregateError"),i=Pf.f(t),o=i.resolve,n=i.reject,a=Mf((function(){var i=wf(t.resolve),a=[],s=0,c=1,d=!1;Lf(e,(function(e){var u=s++,l=!1;c++,Nf(i,t,e).then((function(e){l||d||(d=!0,o(e))}),(function(e){l||d||(l=!0,a[u]=e,--c||n(new r(a,Vf)))}))})),--c||n(new r(a,Vf))}));return a.error&&n(a.value),i.promise}});var xf=xr,Uf=wg,Bf=h,Ff=fe,jf=x,Hf=Cp,Gf=Tf,Wf=Uf&&Uf.prototype;xf({target:"Promise",proto:!0,real:!0,forced:!!Uf&&Bf((function(){Wf.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=Hf(this,Ff("Promise")),r=jf(e);return this.then(r?function(r){return Gf(t,e()).then((function(){return r}))}:e,r?function(r){return Gf(t,e()).then((function(){throw r}))}:e)}});var Kf=l(le.Promise);function zf(e,t,r,i){var o,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(n<3?o(a):n>3?o(t,r,a):o(t,r))||a);return n>3&&a&&Object.defineProperty(t,r,a),a}function Xf(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class qf extends r.EventEmitter{constructor(e,t){super(),this._ID=void 0,this._rtpTransceiver=void 0,this._lowRtpTransceiver=void 0,this._hints=[],this._isClosed=!1,this._originMediaStreamTrack=void 0,this._mediaStreamTrack=void 0,this._external={},this._ID=t||r.getRandomString(8,"track-"),this._originMediaStreamTrack=e,this._mediaStreamTrack=e,Yi(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){if(!e){const e=i.report.reportApiInvoke(null,{name:r.AgoraAPIName.GET_MEDIA_STREAM_TRACK,options:[],tag:r.AgoraAPITag.TRACER});this._mediaStreamTrack&&"string"==typeof this._mediaStreamTrack.label?e.onSuccess(this._mediaStreamTrack.label):e.onSuccess("")}return this._mediaStreamTrack}getRTCRtpTransceiver(t){return t===e.StreamType.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,Qi(this),this.emit(e.LocalTrackEvents.CLOSED)}_updateRtpTransceiver(t,r){if(r===e.StreamType.LOW_STREAM){if(this._lowRtpTransceiver===t)return;this._lowRtpTransceiver=t}else{if(this._rtpTransceiver===t)return;this._rtpTransceiver=t}this.emit(e.TrackEvents.TRANSCEIVER_UPDATED,t,r)}}class Jf extends qf{get isExternalTrack(){return this._isExternalTrack}get muted(){return this._muted}get enabled(){return this._enabled}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}constructor(e,t){super(e,t),this._enabled=!0,this._muted=!1,this._isExternalTrack=!1,this._isClosed=!1,this._enabledMutex=void 0,this.processor=void 0,this._handleTrackEnded=()=>{this.onTrackEnded()},this._enabledMutex=new r.PromiseMutex("".concat(this.getTrackId())),e.addEventListener("ended",this._handleTrackEnded)}getTrackLabel(){var e,t;return null!==(e=null===(t=this._originMediaStreamTrack)||void 0===t?void 0:t.label)&&void 0!==e?e:""}close(){this._isClosed||(this.stop(),this._originMediaStreamTrack.stop(),this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack.stop(),this._mediaStreamTrack=null),this._originMediaStreamTrack=null,this._enabledMutex=null,i.logger.debug("[".concat(this.getTrackId(),"] close")),this.emit(e.TrackInternalEvent.NEED_CLOSE),super.close())}async _updateOriginMediaStreamTrack(t,i){let o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._isExternalTrack=o,t!==this._originMediaStreamTrack&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),i&&this._originMediaStreamTrack.stop()),t.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=t,this._muted&&(this._originMediaStreamTrack.enabled=!1),this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){i.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}stateCheck(e,t){if(i.logger.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),r.checkValidBoolean(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",i.logger);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",i.logger)}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}function Yf(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}const Qf=window.AudioContext||window.webkitAudioContext;let Zf=null;class $f extends r.EventEmitter{constructor(){super(...arguments),this.prevState=void 0,this.curState=void 0,this.currentTime=void 0,this.currentTimeStuckAt=void 0,this.interruptDetectorTrack=void 0,this.onLocalAudioTrackMute=()=>{i.logger.info("ios15-interruption-start"),this.emit(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_START)},this.onLocalAudioTrackUnmute=async()=>{i.logger.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?i.logger.info("ios15-interruption-end-canceled"):(Zf&&await Zf.suspend(),this.emit(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END))}}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){i.logger.debug("webaudio bindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack||(this.interruptDetectorTrack=e,this.interruptDetectorTrack._mediaStreamTrack.onmute=this.onLocalAudioTrackMute,this.interruptDetectorTrack._mediaStreamTrack.onunmute=this.onLocalAudioTrackUnmute)}unbindInterruptDetectorTrack(e){i.logger.debug("webaudio unbindInterruptDetectorTrack ".concat(e.getTrackId())),this.interruptDetectorTrack&&this.interruptDetectorTrack===e&&(this.interruptDetectorTrack._mediaStreamTrack&&(this.interruptDetectorTrack._mediaStreamTrack.onmute=null,this.interruptDetectorTrack._mediaStreamTrack.onunmute=null),this.interruptDetectorTrack=void 0)}}const eE=new $f;function tE(){if(!Qf)return void i.logger.error("your browser is not support web audio");i.logger.info("create audio context");const t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Yf(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Yf(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},r.getParameter("WEBAUDIO_INIT_OPTIONS"));i.logger.debug("audio context init option:",JSON.stringify(t)),Zf=new Qf(t),eE.curState=Zf.state,Zf.onstatechange=()=>{eE.prevState=eE.curState,eE.curState=Zf?Zf.state:void 0;const{prevState:t,curState:o}=eE,n="running"===o,a="interrupted"===o,s="running"===t,c="suspended"===t,d="interrupted"===t,u=r.getBrowserInfo().osVersion;(r.isIOS()||r.isIpadOS())&&s&&a&&(i.logger.info("ios".concat(u,"-interruption-start")),eE.emit(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_START)),(r.isIOS()||r.isIpadOS())&&(c||d)&&n&&(i.logger.info("ios".concat(u,"-interruption-end")),eE.emit(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END)),t!==o&&eE.emit(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,o,t)},setInterval((()=>{var e;const t=null===(e=Zf)||void 0===e?void 0:e.currentTime;if(eE.currentTime!==t)eE.currentTimeStuckAt&&(i.logger.debug("AudioContext current time resume at ".concat(t)),eE.currentTimeStuckAt=void 0),eE.currentTime=t;else{if(t!==eE.currentTimeStuckAt){i.report.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:r.AgoraAPITag.TRACER}).onSuccess(),i.logger.warning("AudioContext current time stuck at ".concat(t))}eE.currentTimeStuckAt=t}}),5e3),async function(t){const i=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","touchend","keydown","keyup"];let o,n=!1,a=!1,s=!1;function c(e){"running"===t.state?d(!1):r.isIOS()||r.isIpadOS()?"suspended"===t.state&&(d(!0),e&&t.resume().then(l,l)):"closed"!==t.state&&(d(!0),e&&t.resume().then(l,l))}function d(e){if(n!==e){n=e;for(let t=0,r=i;t<r.length;t+=1){const i=r[t];e?window.addEventListener(i,h,{capture:!0,passive:!0}):window.removeEventListener(i,h,{capture:!0,passive:!0})}}}function u(){c(!0)}function l(){c(!1)}function h(){c(!0)}function p(e){if(!s)if(o.paused)if(e){let e;g(!1),s=!0;try{e=o.play(),e?e.then(m,m):(o.addEventListener("playing",m),o.addEventListener("abort",m),o.addEventListener("error",m))}catch(e){m()}}else g(!0);else g(!1)}function g(e){if(a!==e){a=e;for(let t=0,r=i;t<r.length;t++){const i=r[t];e?window.addEventListener(i,f,{capture:!0,passive:!0}):window.removeEventListener(i,f,{capture:!0,passive:!0})}}}function m(){o.removeEventListener("playing",m),o.removeEventListener("abort",m),o.removeEventListener("error",m),s=!1,p(!1)}function f(){p(!0)}if(r.isIOS()){const e=t.createMediaStreamDestination(),r=document.createElement("div");r.innerHTML="<audio x-webkit-airplay='deny'></audio>",o=r.children.item(0),o.controls=!1,o.disableRemotePlayback=!0,o.preload="auto",o.srcObject=e.stream,p(!0)}eE.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,u),c(!1)}(Zf)}function rE(){if(!Zf){if(tE(),!Zf)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create audio context");return Zf}return Zf}function iE(){return!!Zf}function oE(e){if(function(){if(null!==aE)return aE;const e=rE(),t=e.createBufferSource(),r=e.createGain(),i=e.createGain();t.connect(r),t.connect(i),t.disconnect(r);let o=!1;try{t.disconnect(r)}catch(e){o=!0}return t.disconnect(),aE=o,o}())return;const t=e.connect,i=e.disconnect;e.connect=(r,i,o)=>{var n;return e._inputNodes||(e._inputNodes=[]),Li(n=e._inputNodes).call(n,r)||(r instanceof AudioNode?(e._inputNodes.push(r),t.call(e,r,i,o)):t.call(e,r,i)),e},e.disconnect=(o,n,a)=>{i.call(e),o?r.removeItemFromList(e._inputNodes,o):e._inputNodes=[];for(const r of e._inputNodes)t.call(e,r)}}function nE(e){const t=rE();return new Kf(((i,o)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{o(new r.AgoraRTCError(r.AgoraRTCErrorCode.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let aE=null;let sE=null;function cE(e){for(let t=0;t<e.outputBuffer.numberOfChannels;t+=1){const r=e.outputBuffer.getChannelData(t);for(let e=0;e<r.length;e+=1)r[e]=0}return e.inputBuffer}var dE=Fe,uE=ot,lE=ee,hE=Jr,pE=TypeError,gE=function(e){return function(t,r,i,o){dE(r);var n=uE(t),a=lE(n),s=hE(n),c=e?s-1:0,d=e?-1:1;if(i<2)for(;;){if(c in a){o=a[c],c+=d;break}if(c+=d,e?c<0:s<=c)throw pE("Reduce of empty array with no initial value")}for(;e?c>=0:s>c;c+=d)c in a&&(o=r(o,a[c],c,n));return o}},mE={left:gE(!1),right:gE(!0)},fE=h,EE=mE.left,TE=function(e,t){var r=[][e];return!!r&&fE((function(){r.call(null,t||function(){return 1},1)}))};xr({target:"Array",proto:!0,forced:!pp&&be>79&&be<83||!TE("reduce")},{reduce:function(e){var t=arguments.length;return EE(this,e,t,t>1?arguments[1]:void 0)}});var vE=ii("Array").reduce,_E=v,yE=vE,SE=Array.prototype,AE=l((function(e){var t=e.reduce;return e===SE||_E(SE,e)&&t===SE.reduce?yE:t}));class bE{constructor(){this.context=void 0,this.analyserNode=void 0,this.sourceNode=void 0,this.context=rE(),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4}updateSource(e){if(e!==this.sourceNode){if(this.sourceNode)try{this.sourceNode.disconnect(this.analyserNode)}catch(e){}this.sourceNode=e,null==e||e.connect(this.analyserNode)}}getVolumeLevel(){if(!this.sourceNode)return 0;if(!this.context||r.isIOS()||r.isIpadOS()||"running"!==this.context.state&&this.context.resume(),!this.analyserNode)return 0;const e=new Float32Array(this.analyserNode.fftSize);if(this.analyserNode.getFloatTimeDomainData)this.analyserNode.getFloatTimeDomainData(e);else{const t=new Uint8Array(this.analyserNode.fftSize);this.analyserNode.getByteTimeDomainData(t);for(let r=0;r<e.length;++r)e[r]=t[r]/128-1}const t=AE(e).call(e,((e,t)=>e+t*t),0)/e.length;return Math.max(10*Math.log10(t)+100,0)/100}getAnalyserNode(){return this.analyserNode}rebuildAnalyser(){try{var e,t;null===(e=this.sourceNode)||void 0===e||e.disconnect(this.analyserNode),this.analyserNode=this.context.createAnalyser(),this.analyserNode.fftSize=2048,this.analyserNode.smoothingTimeConstant=.4,null===(t=this.sourceNode)||void 0===t||t.connect(this.analyserNode)}catch(e){i.logger.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class IE extends r.EventEmitter{get processSourceNode(){return this.sourceNode}set processedNode(e){var t;if(!this.isDestroyed&&this._processedNode!==e){try{var r;null===(r=this.sourceNode)||void 0===r||r.disconnect(this.outputNode)}catch(e){}null===(t=this._processedNode)||void 0===t||t.disconnect(),this._processedNode=e,this.connect()}}get processedNode(){return this._processedNode}constructor(){super(),this.outputNode=void 0,this.outputTrack=void 0,this.isPlayed=!1,this.context=void 0,this.audioBufferNode=void 0,this.destNode=void 0,this.audioOutputLevel=0,this.volumeLevelAnalyser=void 0,this._processedNode=void 0,this.playNode=void 0,this.isDestroyed=!1,this.onNoAudioInput=void 0,this.isNoAudioInput=!1,this._noAudioInputCount=0,this.context=rE(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),oE(this.outputNode),this.volumeLevelAnalyser=new bE}startGetAudioBuffer(t){this.audioBufferNode||(this.audioBufferNode=this.context.createScriptProcessor(t),this.outputNode.connect(this.audioBufferNode),this.audioBufferNode.connect(this.context.destination),this.audioBufferNode.onaudioprocess=t=>{this.emit(e.AudioSourceEvents.ON_AUDIO_BUFFER,cE(t))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!c().webAudioMediaStreamDest)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser is not support audio processor");return this.destNode&&this.outputTrack||(this.destNode=this.context.createMediaStreamDestination(),this.outputNode.connect(this.destNode),this.outputTrack=this.destNode.stream.getAudioTracks()[0]),this.outputTrack}play(e){"running"!==this.context.state&&r.nextTick((()=>{eE.emit("autoplay-failed")})),this.isPlayed=!0,this.playNode=e||this.context.destination,this.outputNode.connect(this.playNode)}stop(){if(this.isPlayed)try{this.outputNode.disconnect(this.playNode)}catch(e){}this.isPlayed=!1}getAccurateVolumeLevel(){return this.volumeLevelAnalyser.getVolumeLevel()}async checkHasAudioInput(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(e>5)return this.isNoAudioInput=!0,this.onNoAudioInput&&this.onNoAudioInput(),!1;r.isIOS()||r.isIpadOS()?"suspended"===this.context.state&&this.context.resume():"running"!==this.context.state&&this.context.resume();const t=this.volumeLevelAnalyser.getAnalyserNode();let i;t.getFloatTimeDomainData?(i=new Float32Array(t.fftSize),t.getFloatTimeDomainData(i)):(i=new Uint8Array(t.fftSize),t.getByteTimeDomainData(i));let o=!1;for(let e=0;e<i.length;e++)0!==i[e]&&(o=!0);return o?(this.isNoAudioInput=!1,!0):(await r.wait(200),await this.checkHasAudioInput(e?e+1:1)&&o)}getAudioVolume(){return this.outputNode.gain.value}setVolume(e){this.outputNode.gain.setValueAtTime(e,this.context.currentTime)}destroy(){this.disconnect(),this.stop(),this.isDestroyed=!0,this.onNoAudioInput=void 0}disconnect(){var e,t;null===(e=this.processedNode)||void 0===e||e.disconnect(),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.outputNode&&this.outputNode.disconnect()}connect(){var e;this.processedNode?null===(e=this.processedNode)||void 0===e||e.connect(this.outputNode):this.sourceNode&&this.sourceNode.connect(this.outputNode);this.volumeLevelAnalyser.updateSource(this.outputNode)}}class kE extends IE{get isFreeze(){return!1}constructor(t,o,n){var a;if(super(),this.sourceNode=void 0,this.track=void 0,this.clonedTrack=void 0,this.audioElement=void 0,this.isCurrentTrackCloned=!1,this.isRemoteTrack=!1,this.originVolumeLevelAnalyser=void 0,this.rebuildWebAudio=async()=>{if(i.logger.debug("ready to rebuild web audio, state:",this.context.state),this.isNoAudioInput&&await this.checkHasAudioInput(),!this.isNoAudioInput||this.isDestroyed)return document.body.removeEventListener("click",this.rebuildWebAudio,!0),void i.logger.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>i.logger.info("resume success"))),i.logger.debug("rebuild web audio because of ios 12 bugs"),this.disconnect();const t=this.track;this.track=this.track.clone(),this.isCurrentTrackCloned?t.stop():this.isCurrentTrackCloned=!0;const r=new MediaStream([this.track]);this.sourceNode=this.context.createMediaStreamSource(r),oE(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const o=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(o,this.context.currentTime),oE(this.outputNode),this.emit(e.AudioSourceEvents.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=r,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()},"audio"!==t.kind)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR);this.track=t;const s=new MediaStream([this.track]);if(this.isRemoteTrack=!!o,this.sourceNode=this.context.createMediaStreamSource(s),oE(this.sourceNode),n){const e=n.clone();e.enabled=!0,this.clonedTrack=e,i.logger.debug("create an unmuted track ".concat(e.id," from the original track ").concat(n.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));oE(t),this.originVolumeLevelAnalyser=new bE,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=s;const c=r.getBrowserInfo();o&&c.os===r.BrowserOS.IOS&&Number(null===(a=c.osVersion)||void 0===a?void 0:a.split(".")[0])<15&&(eE.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,(()=>{"suspended"===this.context.state?document.body.addEventListener("click",this.rebuildWebAudio,!0):"running"===this.context.state&&this.rebuildWebAudio()})),this.checkHasAudioInput().then((e=>{e||document.body.addEventListener("click",this.rebuildWebAudio,!0)})))}updateTrack(t){this.sourceNode.disconnect(),this.track=t,this.isCurrentTrackCloned=!1;const r=new MediaStream([t]);this.sourceNode=this.context.createMediaStreamSource(r),oE(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(e.AudioSourceEvents.UPDATE_SOURCE),this.audioElement.srcObject=r}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),eE.off("state-change",this.rebuildWebAudio),null===(e=this.originVolumeLevelAnalyser)||void 0===e||e.destroy(),this.clonedTrack=void 0,super.destroy()}createMediaStreamSourceNode(e){return this.context.createMediaStreamSource(new MediaStream([e]))}updateOriginTrack(e){const t=e.clone();t.enabled=!0,this.clonedTrack&&(this.clonedTrack.stop(),this.clonedTrack=t),i.logger.debug("create an unmuted track ".concat(t.id," from the original track ").concat(e.id," to get the volume"));const r=this.context.createMediaStreamSource(new MediaStream([t]));oE(r),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(r)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function CE(e,t,r){const i=(e,t)=>e?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t,o={audio:!!r&&{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:i(t.height,1080),maxWidth:i(t.width,1920)}}};return t.frameRate&&"number"!=typeof t.frameRate?(o.video.mandatory.maxFrameRate=t.frameRate.max,o.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(o.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(o)}async function OE(e,t){const i=await RE(e.mediaSource),{sourceId:o,audio:n}=await r.showElectronSelectSourceWindow(i,t);return await CE(o,e,n)}async function RE(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);const i=r.getElectronInstance();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new r.AgoraRTCError(r.AgoraRTCErrorCode.ELECTRON_IS_NULL);let o=null;try{var n;o=(null===(n=i.desktopCapturer)||void 0===n?void 0:n.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){o=null}o&&o.then||(o=new Kf(((e,r)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?r(t):e(i)}))})));try{return await o}catch(e){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}function NE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}const wE=new r.PromiseMutex("safari");async function DE(e,t){let o=0,n=null;for(;o<2;)try{n=await PE(e,t,o>0);break}catch(e){if(e instanceof r.AgoraRTCError)throw i.logger.error("[".concat(t,"] ").concat(e.toString())),e;const n=ME(e.name||e.code||e,e.message);if(n.code===r.AgoraRTCErrorCode.MEDIA_OPTION_INVALID){i.logger.debug("[".concat(t,"] detect media option invalid, retry")),o+=1,await r.wait(500);continue}throw i.logger.error("[".concat(t,"] ").concat(n.toString())),n}if(!n)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return n}async function PE(t,o,n){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not find getUserMedia");n&&(t.video&&(delete t.video.width,delete t.video.height),t.screen&&(delete t.screen.width,delete t.screen.height));const a=c(),s=new MediaStream;if(t.audioSource&&s.addTrack(t.audioSource),t.videoSource&&s.addTrack(t.videoSource),!t.audio&&!t.video&&!t.screen)return i.logger.debug("Using Video Source/ Audio Source"),s;if(t.screen)if(r.isElectron())if(t.screen.sourceId){LE(s,await CE(t.screen.sourceId,t.screen,t.screenAudio))}else{LE(s,await OE(t.screen,t.screenAudio))}else if(r.isChrome()&&t.screen.extensionId&&t.screen.mandatory){if(!a.getStreamFromExtension)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"This browser does not support screen sharing");i.logger.debug("[".concat(o,'] Screen access on chrome stable, looking for extension"'));const e=await(u=t.screen.extensionId,l=o,new Kf(((e,t)=>{try{chrome.runtime.sendMessage(u,{getStream:!0},(o=>{if(!o||!o.streamId)return i.logger.error("[".concat(l,"] No response from Chrome Plugin. Plugin not installed properly"),o),void t(new r.AgoraRTCError(r.AgoraRTCErrorCode.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(o.streamId)}))}catch(e){i.logger.error("[".concat(l,"] AgoraRTC screensharing plugin is not accessible(").concat(u,")"),e.toString()),t(new r.AgoraRTCError(r.AgoraRTCErrorCode.CHROME_PLUGIN_NOT_INSTALL))}})));t.screen.mandatory.chromeMediaSourceId=e;LE(s,await navigator.mediaDevices.getUserMedia({video:{mandatory:t.screen.mandatory}}))}else if(a.getDisplayMedia){var d;t.screen.mediaSource&&eo(t.screen.mediaSource);const e={width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate,displaySurface:null!==(d=t.screen.displaySurface)&&void 0!==d?d:"screen"===t.screen.mediaSource?"monitor":t.screen.mediaSource},{selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a}=t.screen,c={selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a};!r&&delete c.selfBrowserSurface,!n&&delete c.surfaceSwitching,!a&&delete c.systemAudio,i.logger.debug("[".concat(o,"] getDisplayMedia:"),JSON.stringify({video:e,audio:!!t.screenAudio,controls:c}));const u=await navigator.mediaDevices.getDisplayMedia(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?NE(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NE(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({video:e,audio:!!t.screenAudio},c));LE(s,u)}else{if(!r.isFirefox())throw i.logger.error("[".concat(o,"] This browser does not support screenSharing")),new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"This browser does not support screen sharing");{t.screen.mediaSource&&eo(t.screen.mediaSource);const e={video:{mediaSource:t.screen.mediaSource,width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate}};i.logger.debug("[".concat(o,"] getUserMedia: ").concat(JSON.stringify(e)));LE(s,await navigator.mediaDevices.getUserMedia(e))}}var u,l;if(!t.video&&!t.audio)return s;let h={video:t.video,audio:t.audio},p=r.getParameter("MEDIA_DEVICE_CONSTRAINTS");if(p)try{"string"==typeof p&&(p=JSON.parse(p)),h=r.recursiveMerge(h,p)}catch(e){}i.logger.debug("[".concat(o,"] GetUserMedia"),JSON.stringify(h)),r.getBrowserInfo();let g,m=null;(r.isSafari()||r.isIOS()||r.isWkWebview())&&(m=await wE.lock());try{g=await navigator.mediaDevices.getUserMedia(h)}catch(e){throw m&&m(),e}return h.audio&&(e.HAS_GUM_AUDIO=!0),h.video&&(e.HAS_GUM_VIDEO=!0),LE(s,g),m&&m(),s}function ME(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new r.AgoraRTCError(r.AgoraRTCErrorCode.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return i.logger.error("getUserMedia unexpected error",e),new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"".concat(e,": ").concat(t))}}function LE(e,t){const r=e.getVideoTracks()[0],i=e.getAudioTracks()[0],o=t.getVideoTracks()[0],n=t.getAudioTracks()[0];n&&(i&&e.removeTrack(i),e.addTrack(n)),o&&(r&&e.removeTrack(r),e.addTrack(o))}e.HAS_GUM_AUDIO=!1,e.HAS_GUM_VIDEO=!1;class VE extends r.EventEmitter{get state(){return this._state}set state(t){t!==this._state&&(this.emit(e.DeviceManagerEvent.STATE_CHANGE,t),this._state=t)}constructor(){super(),this._state=e.DeviceManagerState.IDLE,this.isAccessMicrophonePermission=!1,this.isAccessCameraPermission=!1,this.lastAccessMicrophonePermission=!1,this.lastAccessCameraPermission=!1,this.checkdeviceMatched=!1,this.deviceInfoMap=new Map,this.init().then((()=>{navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",this.updateDevicesInfo.bind(this)),window.setInterval((()=>{(r.getParameter("ENUMERATE_DEVICES_INTERVAL")||(r.isAndroid()||r.isHarmonyOS())&&r.isChromeKernel())&&this.updateDevicesInfo()}),r.getParameter("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>i.logger.error(e.toString())))}async enumerateDevices(t,o){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){return new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const a=await navigator.mediaDevices.enumerateDevices(),s=this.checkMediaDeviceInfoIsOk(a);let c=!this.isAccessMicrophonePermission&&t,d=!this.isAccessCameraPermission&&o;s.audio&&(c=!1),s.video&&(d=!1);let u=null,l=null,h=null;if(!n&&(c||d)){if(wE.isLocked){i.logger.debug("[device manager] wait GUM lock");(await wE.lock())(),i.logger.debug("[device manager] GUM unlock")}if(e.HAS_GUM_AUDIO&&(c=!1,this.isAccessMicrophonePermission=!0),e.HAS_GUM_VIDEO&&(d=!1,this.isAccessCameraPermission=!0),i.logger.debug("[device manager] check media device permissions",t,o,c,d),c&&d){try{h=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=ME(e.name||e.code||e,e.message);if(t.code===r.AgoraRTCErrorCode.PERMISSION_DENIED)throw t;i.logger.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(c){try{u=await navigator.mediaDevices.getUserMedia({audio:t})}catch(e){const t=ME(e.name||e.code||e,e.message);if(t.code===r.AgoraRTCErrorCode.PERMISSION_DENIED)throw t;i.logger.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(d){try{l=await navigator.mediaDevices.getUserMedia({video:o})}catch(e){const t=ME(e.name||e.code||e,e.message);if(t.code===r.AgoraRTCErrorCode.PERMISSION_DENIED)throw t;i.logger.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}i.logger.debug("[device manager] mic permission",t,"cam permission",o)}try{const e=await navigator.mediaDevices.enumerateDevices();return u&&u.getTracks().forEach((e=>e.stop())),l&&l.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),u=null,l=null,h=null,e}catch(e){u&&u.getTracks().forEach((e=>e.stop())),l&&l.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),u=null,l=null,h=null;return new r.AgoraRTCError(r.AgoraRTCErrorCode.ENUMERATE_DEVICES_FAILED,e.toString()).throw()}}async getRecordingDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audioinput"===e.kind))}async getCamerasDevices(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!1,!0,e)).filter((e=>"videoinput"===e.kind))}async getSpeakers(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.enumerateDevices(!0,!1,e)).filter((e=>"audiooutput"===e.kind))}searchDeviceIdByName(e){let t=null;return this.deviceInfoMap.forEach((r=>{r.device.label===e&&(t=r.device.deviceId)})),t}async getDeviceById(e){const t=(await this.enumerateDevices(!0,!0,!0)).find((t=>t.deviceId===e));if(!t)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=e.DeviceManagerState.INITING;try{await this.updateDevicesInfo(),this.state=e.DeviceManagerState.INITEND}catch(t){if(i.logger.warning("Device Detection functionality cannot start properly.",t.toString()),this.state=e.DeviceManagerState.IDLE,!r.detectSecureContext()){new r.AgoraRTCError(r.AgoraRTCErrorCode.WEB_SECURITY_RESTRICT,"Your context is limited by web security, please try using https protocol or localhost.").throw()}throw t}}async updateDevicesInfo(){const t=await this.enumerateDevices(!0,!0,!0),r=Date.now(),o=[];if(t[0]&&t[0].label&&!1===this.checkdeviceMatched){this.checkdeviceMatched=!0;const e=t.find((e=>"audioinput"===e.kind&&"default"===e.deviceId)),r=t.find((e=>"audiooutput"===e.kind&&"default"===e.deviceId));e&&r?r.groupId===e.groupId?i.logger.debug("[device-check] default input ".concat(e.label," and output ").concat(r.label," is the same group")):i.logger.warning("[device-check] default input ".concat(e.label," and output ").concat(r.label," is not the same group")):i.logger.debug("[device-check] default input or output not found")}const n=this.checkMediaDeviceInfoIsOk(t);if(t.forEach((e=>{if(!e.deviceId)return;const t=this.deviceInfoMap.get("".concat(e.kind,"_").concat(e.deviceId));if("ACTIVE"!==(t?t.state:"INACTIVE")){const t={initAt:r,updateAt:r,device:e,state:"ACTIVE"};this.deviceInfoMap.set("".concat(e.kind,"_").concat(e.deviceId),t),o.push(t)}t&&(t.updateAt=r)})),this.deviceInfoMap.forEach(((e,t)=>{"ACTIVE"===e.state&&e.updateAt!==r&&(e.state="INACTIVE",o.push(e))})),this.state!==e.DeviceManagerState.INITEND)return n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),void(n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0));o.forEach((t=>{switch(t.device.kind){case"audioinput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(e.DeviceManagerEvent.RECORDING_DEVICE_CHANGED,t);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(e.DeviceManagerEvent.CAMERA_DEVICE_CHANGED,t);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(e.DeviceManagerEvent.PLAYOUT_DEVICE_CHANGED,t)}})),n.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),n.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0)}checkMediaDeviceInfoIsOk(e){const t=e.filter((e=>"audioinput"===e.kind)),r=e.filter((e=>"videoinput"===e.kind)),i={audio:!1,video:!1};for(const e of t)if(e.label&&e.deviceId){i.audio=!0;break}for(const e of r)if(e.label&&e.deviceId){i.video=!0;break}return i}}const xE=new VE;class UE extends r.EventEmitter{constructor(){super(...arguments),this.onAutoplayFailed=void 0,this.onAudioAutoplayFailed=void 0}}let BE=!1;const FE=new UE;function jE(){if(r.getBrowserInfo(),!BE){const e=t=>{t.preventDefault(),BE=!1,r.isAndroidChromium()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};BE=!0,r.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),i.logger.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),FE.onAutoplayFailed?FE.onAutoplayFailed():FE.onAudioAutoplayFailed?i.logger.warning("AgoraRTC.onAudioAutoplayFailed has been deprecated in favor of AgoraRTC.onAutoplayFailed.\n\n Please refer to the Agora document to migrate the newer API, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."):i.logger.warning("We have detected a media autoplay failed event, and found out that you haven't implemented AgoraRTC.onAutoplayFailed callback yet.\n\n It will cause audio/video element not playing automatically on some browsers without user interaction, possibly hurting user experiences.\n\n Please refer to the Agora document to properly handle autoplay failed event, https://docs.agora.io/en/Voice/autoplay_policy_web_ng?platform=Web ."),FE.emit("autoplay-failed")}}function HE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function GE(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?HE(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):HE(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function WE(e,t,r,o){if(!e)return;const n=i.report.getBaseInfoBySessionId(e);if(!n)return;const a=n.info,s=Date.now(),c=GE(GE({},a),{},{vid:void 0===a.vid?0:Number(a.vid),lts:s,elapse:s-n.startTime,cbRegistered:FE.onAutoplayFailed||FE.onAudioAutoplayFailed?1:-1,errorMsg:r,mediaType:t,trackId:o,extend:void 0});i.report.send({type:i.AgoraRTCEventUploadType.AUTOPLAY_FAILED,data:c},!0)}const KE=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],zE=new class{constructor(){this.onAutoplayFailed=void 0,this.elementMap=new Map,this.elementStateMap=new Map,this.elementsNeedToResume=[],this.sinkIdMap=new Map,this.autoResumeAfterInterruption=e=>{Array.from(this.elementMap.entries()).forEach((t=>{let[o,n]=t;const a=this.elementStateMap.get(o),s=n.srcObject.getAudioTracks()[0],c=s&&s.readyState;if(i.logger.debug("resume after interrupted, ele: ".concat(a," audio: ").concat(c," ").concat(e)),"live"===c){if(e)return n.pause(),void n.play();if("running"===eE.curState)return r.isIOS15()?(n.pause(),void n.play()):void(a&&"paused"===a&&n.play())}}))},this.autoResumeAfterInterruptionOnIOS15_16=()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[t,r]=e;const o=r.srcObject.getAudioTracks()[0];o&&"live"===o.readyState&&(i.logger.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),r.pause(),r.play())}))},this.autoResumeAudioElement(),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),eE.on(e.AUDIO_CONTEXT_EVENT.STATE_CHANGE,(()=>{r.isIOS()&&"suspended"===eE.prevState&&"running"===eE.curState&&this.autoResumeAfterInterruption()}))}async setSinkID(e,t){const i=this.elementMap.get(e);if(this.sinkIdMap.set(e,t),i)try{await i.setSinkId(t)}catch(e){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(t,o,n,a){if(this.elementMap.has(o))return;const s=document.createElement("audio");s.autoplay=!0,s.srcObject=new MediaStream([t]),this.bindAudioElementEvents(o,s),this.elementMap.set(o,s),this.elementStateMap.set(o,e.MediaElementStatus.INIT),this.setVolume(o,n);const c=this.sinkIdMap.get(o);if(c)try{s.setSinkId(c).catch((e=>{i.logger.warning("[".concat(o,"] set sink id failed"),e.toString())}))}catch(e){i.logger.warning("[".concat(o,"] set sink id failed"),e.toString())}const d=s.play();d&&d.then&&d.catch((e=>{a&&WE(a,"audio",e.message,o),i.logger.warning("audio element play warning",e.toString()),this.elementMap.has(o)&&"NotAllowedError"===e.name&&(i.logger.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(s),r.nextTick((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),jE()})))}))}updateTrack(e,t){const r=this.elementMap.get(e);r&&(r.srcObject=new MediaStream([t]))}isPlaying(e){return this.elementMap.has(e)&&"playing"===this.elementStateMap.get(e)}setVolume(e,t){const r=this.elementMap.get(e);r&&(t=Math.max(0,Math.min(100,t)),r.volume=t/100)}stop(e){const t=this.elementMap.get(e);if(this.sinkIdMap.delete(e),!t)return;const r=this.elementsNeedToResume.indexOf(t);this.elementsNeedToResume.splice(r,1),t.srcObject=null,t.remove(),this.elementMap.delete(e),this.elementStateMap.delete(e)}bindAudioElementEvents(e,t){KE.forEach((r=>{t.addEventListener(r,(r=>{const o=this.elementStateMap.get(e),n="pause"===r.type?"paused":r.type;if(i.logger.debug("[".concat(e,"] audio-element-status change ").concat(o," => ").concat(n)),"error"===r.type){const r=null==t?void 0:t.error;r&&i.logger.error("[".concat(e,"] media error, code: ").concat(r.code,", message: ").concat(r.message))}this.elementStateMap.set(e,n)}))}))}getPlayerState(e){return this.elementStateMap.get(e)||"uninit"}autoResumeAudioElement(){const e=()=>{this.elementsNeedToResume.forEach((e=>{e.play().then((e=>{i.logger.debug("Auto resume audio element success")})).catch((e=>{i.logger.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};r.domLoadedPromise().then((()=>{r.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function XE(){return function(e,t,o){const n=o.value;return"function"==typeof n&&(o.value=function(){this._isClosed&&new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",i.logger);for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];const a=n.apply(this,t);return a instanceof Kf?new Kf(((e,t)=>{a.then(e).catch(t)})):a}),o}}var qE=ii("Array").values,JE=Ti,YE=st,QE=v,ZE=qE,$E=Array.prototype,eT={DOMTokenList:!0,NodeList:!0},tT=l((function(e){var t=e.values;return e===$E||QE($E,e)&&t===$E.values||YE(eT,JE(e))?ZE:t}));function rT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function iT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?rT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):rT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class oT extends r.EventEmitter{constructor(e){super(),this.name="VideoProcessorDestination",this.ID="0",this._source=void 0,this.videoContext=void 0,this.inputTrack=void 0,this.videoContext=e}get kind(){return"video"}get enabled(){return!0}pipe(){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"VideoProcessor cannot unpipe to any other Processor")}enable(){}disable(){}updateInput(t){if(t.context!==this.videoContext)throw new Error("ProcessorContext passed to VideoTrack.processorDestination doesn't match it's belonging VideoTrack's context.\nProbably you are making pipeline like this:\nvideoTrack1.pipe(processor).pipe(videoTrack2.processorDestination).");t.track&&t.track!==this.inputTrack&&(this.videoContext.chained=!0,this.inputTrack=t.track,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,t.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,void 0)}}class nT extends r.EventEmitter{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t){super(),this.constraintsMap=new Map,this.statsRegistry=[],this.usageRegistry=[],this.trackId=void 0,this.direction=void 0,this._chained=!1,this.trackId=e,this.direction=t}async getConstraints(){return await r.emitAsPromise(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}async requestApplyConstraints(t,o){var n;return i.logger.info("processor ".concat(o.name," requestApplyConstraints for ").concat(this.trackId)),t&&this.constraintsMap.set(o,t),r.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(tT(n=this.constraintsMap).call(n)))}async requestRevertConstraints(t){var o;if(this.constraintsMap.has(t))return i.logger.info("processor ".concat(t.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(t),r.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(tT(o=this.constraintsMap).call(o)))}registerStats(e,t,r){this.statsRegistry.find((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:r})}unregisterStats(e,t){const r=this.statsRegistry.findIndex((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t));-1!==r&&this.statsRegistry.splice(r,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:o,type:n,cb:a}of this.statsRegistry)try{const r=a();e.push({processorID:t,processorName:o,type:n,stats:r})}catch(e){i.logger.error(new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let r=t();r instanceof Kf&&(r=await r),e.push(iT(iT({},r),{},{direction:this.direction}))}catch(e){i.logger.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class aT extends r.EventEmitter{constructor(e){super(),this.name="AudioProcessorDestination",this.ID="0",this.inputTrack=void 0,this.inputNode=void 0,this.audioProcessorContext=void 0,this._source=void 0,this.audioProcessorContext=e}get kind(){return"audio"}get enabled(){return!0}pipe(){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"AudioProcessor cannot unpipe to any other Processor")}enable(){}disable(){}reset(){this.inputTrack=void 0,this.inputNode=void 0,this.audioProcessorContext.chained=!1,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,void 0),this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,void 0)}updateInput(t){if(t.context!==this.audioProcessorContext)throw new Error("ProcessorContext passed to AudioTrack.processorDestination doesn't match it's belonging AudioTrack's context.\n Probably you are making pipeline like this: audioTrack1.pipe(processor).pipe(audioTrack2.processorDestination).");t.track&&this.inputTrack!==t.track&&(this.audioProcessorContext.chained=!0,this.inputTrack=t.track,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,this.inputTrack)),t.node&&this.inputNode!==t.node&&(this.audioProcessorContext.chained=!0,this.inputNode=t.node,this.emit(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,this.inputNode))}}class sT extends r.EventEmitter{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t,r){super(),this.constraintsMap=new Map,this.statsRegistry=[],this.audioContext=void 0,this.trackId=void 0,this.direction=void 0,this.usageRegistry=[],this._chained=!1,this.audioContext=e,this.trackId=t,this.direction=r}async getConstraints(){return r.emitAsPromise(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(t,o){var n;return i.logger.info("processor ".concat(o.name," requestApplyConstraints for ").concat(this.trackId)),t&&this.constraintsMap.set(o,t),r.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(tT(n=this.constraintsMap).call(n)))}async requestRevertConstraints(t){var i;if(this.constraintsMap.has(t))return this.constraintsMap.delete(t),r.emitAsPromiseNoResponse(this,e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,Array.from(tT(i=this.constraintsMap).call(i)))}registerStats(e,t,r){this.statsRegistry.find((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:r})}unregisterStats(e,t){const r=this.statsRegistry.findIndex((r=>r.processorID===e.ID&&r.processorName===e.name&&r.type===t));-1!==r&&this.statsRegistry.splice(r,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:o,type:n,cb:a}of this.statsRegistry)try{const r=a();e.push({processorID:t,processorName:o,type:n,stats:r})}catch(e){i.logger.error(new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.message))}return e}registerUsage(e,t){this.usageRegistry.find((t=>t.processorID===e.ID&&t.processorName===e.name))||this.usageRegistry.push({processorID:e.ID,processorName:e.name,cb:t})}unregisterUsage(e){const t=this.usageRegistry.findIndex((t=>t.processorID===e.ID&&t.processorName===e.name));-1!==t&&this.usageRegistry.splice(t,1)}async gatherUsage(){const e=[];if(!this.chained)return[];for(const{cb:t}of this.usageRegistry)try{let r=t();r instanceof Kf&&(r=await r),e.push(iT(iT({},r),{},{direction:this.direction}))}catch(e){i.logger.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class cT extends r.EventEmitter{get isPlayed(){return!0}get isFreeze(){return!1}constructor(){super(),this.context=void 0,this.processSourceNode=void 0,this.outputTrack=void 0,this.processedNode=void 0,this.clonedTrack=void 0,this.outputNode=void 0,this.outputNode=new dT}setVolume(){}createOutputTrack(){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create output MediaStreamTrack when WebAudio disabled")}getOriginVolumeLevel(){return 0}getAccurateVolumeLevel(){return 0}stopGetAudioBuffer(){}startGetAudioBuffer(){}play(){}stop(){}destroy(){}updateTrack(){}updateOriginTrack(){}createMediaStreamSourceNode(){}}class dT{disconnect(){}connect(){}}let uT=null;class lT{constructor(){this.state="open",this.trigger=void 0,this.tasks=[],i.logger.debug("[macro-task-queue] is created."),this.trigger=window.setTimeout((()=>{this.state="closed",i.logger.debug("[macro-task-queue] will be closed, all remaining tasks will execute. [".concat(this.tasks.map((e=>e.key)),"]")),this.trigger=void 0,this.tasks.forEach((e=>{let{func:t}=e;return t()})),this.tasks.length=0,i.logger.debug("[macro-task-queue] is closed.")}))}enqueue(e,t){"closed"!==this.state&&(this.tasks.push({key:e,func:t}),i.logger.debug("[macro-task-queue] is queued, current queue ".concat(this.tasks.length,". ").concat("string"==typeof e?e:"")))}runTask(e){if("closed"===this.state)return;const t=this.tasks.findIndex((t=>t.key===e));if(-1!==t){const r=this.tasks.splice(t,1);i.logger.debug("[macro-task-queue] is unqueued, current queue ".concat(this.tasks.length,". ").concat("string"==typeof e?e:"")),r[0].func()}}release(){this.trigger&&(this.state="closed",clearTimeout(this.trigger),this.trigger=void 0,this.tasks.length=0,i.logger.debug("[macro-task-queue] is closed."))}}function hT(e){return function(t,r,i){var o;const n=null!==(o=i.value)&&void 0!==o?o:i.get,a=function(){uT&&"open"===uT.state&&uT.runTask(e);for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return null==n?void 0:n.apply(this,...r)};return i.value?i.value=a:i.get=a,i}}function pT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function gT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?pT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class mT extends Jf{get _source(){return this._trackSource}set _source(e){this._trackSource=e}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get processorDestination(){return this._processorDestination}set processorDestination(e){this._processorDestination=e}get isPlaying(){return this._useAudioElement?zE.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"LocalAudioTrack"}constructor(t,i,o,n,a){super(t,o),this.trackMediaType="audio",this._encoderConfig=void 0,this._trackSource=void 0,this._enabled=!0,this._volume=100,this._useAudioElement=!1,this._bypassWebAudio=!1,this.processor=void 0,this._processorContext=void 0,this._processorDestination=void 0,this._getOriginVolumeLevel=void 0,this._encoderConfig=i,this._getOriginVolumeLevel=!!n;const s=()=>{this.processorContext=new sT(this._source.context,this.getTrackId(),"local"),this.processorDestination=new aT(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(e.AudioSourceEvents.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))},c=a&&r.isSafari()&&!iE();if(r.getParameter("DISABLE_WEBAUDIO")?(this._source=new cT,this._useAudioElement=!0,this._bypassWebAudio=!0):c?this._source=new cT:(this._source=new kE(t,!1,this._getOriginVolumeLevel?t:void 0),r.getParameter("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0)),s(),!r.getParameter("DISABLE_WEBAUDIO")&&c){(uT||(uT=new lT),uT).enqueue("INIT_WEBAUDIO",(()=>{this._source=new kE(t,!1,this._getOriginVolumeLevel?t:void 0),r.getParameter("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0),s(),this.emit(e.AUDIO_TRACK_EVENT.UPDATE_TRACK_SOURCE)}))}}setVolume(t){r.checkValidNumber(t,"volume",0,1e3),this._volume=t,this._source.setVolume(t/100),this._useAudioElement&&zE.setVolume(this.getTrackId(),t);try{if(this._bypassWebAudio)return void i.logger.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const t=this._source.createOutputTrack();this._mediaStreamTrack!==t&&(this._mediaStreamTrack=t,r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this).then((()=>{i.logger.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{i.logger.warning("[".concat(this.getTrackId(),"] replace web audio track failed"),e)})))}catch(e){}}getVolumeLevel(){return this._muted&&this.enabled&&this._getOriginVolumeLevel?this._source.getOriginVolumeLevel():this._source.getAccurateVolumeLevel()}async setPlaybackDevice(e){if(!this._useAudioElement||!r.isChrome()&&r.getParameter("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser does not support setting the audio output device");await zE.setSinkID(this.getTrackId(),e)}async setEnabled(e,t,r){return this._setEnabled(e,t,r)}async _setEnabled(t,o,n){if(!n){if(t===this._enabled)return;this.stateCheck("enabled",t)}if(i.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),t),t){this._originMediaStreamTrack.enabled=!0;try{n||(this._enabled=!0),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this),i.logger.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(t," success"))}catch(e){throw n||(this._enabled=!1),i.logger.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,n||(this._enabled=!1);try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw n||(this._enabled=!0),i.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}}}async setMuted(t){t!==this._muted&&(this.stateCheck("muted",t),this._muted=t,this._originMediaStreamTrack.enabled=!t,i.logger.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(t)),t?await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_MUTE_TRACK,this):await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UNMUTE_TRACK,this))}getStats(){r.runOnce((()=>{i.logger.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const t=r.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS);return t||gT({},uo)}setAudioFrameCallback(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!t)return this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(r),this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),this._source.on(e.AudioSourceEvents.ON_AUDIO_BUFFER,(e=>t(e)))}play(){i.logger.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(i.logger.debug("[".concat(this.getTrackId(),"] start audio playback in element")),zE.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){i.logger.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?zE.stop(this.getTrackId()):this._source.stop()}close(){super.close(),this.unbindProcessorDestinationEvents(),this.unbindProcessorContextEvents(),this.unpipe(),this.processorDestination._source&&this.processorDestination._source.unpipe(),this._source.destroy()}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];i.logger.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&zE.updateTrack(this.getTrackId(),this._mediaStreamTrack)}async _updateOriginMediaStreamTrack(t,i){this._originMediaStreamTrack!==t&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),i&&this._originMediaStreamTrack.stop()),t.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=t,this._muted&&(this._originMediaStreamTrack.enabled=!1),this.processor&&this.processor.updateInput({track:t,context:this.processorContext}),this._mediaStreamTrack!==this._source.outputTrack?(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(t))}renewMediaStreamTrack(e){return Kf.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(!this.processor)return;const t=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,t.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async t=>{t?t!==this._mediaStreamTrack&&(this._mediaStreamTrack=t,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(t),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this))})),this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK),this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}}zf([hT("INIT_WEBAUDIO"),Xf("design:type",Object),Xf("design:paramtypes",[Object])],mT.prototype,"_source",null),zf([hT("INIT_WEBAUDIO"),Xf("design:type",sT),Xf("design:paramtypes",[sT])],mT.prototype,"processorContext",null),zf([hT("INIT_WEBAUDIO"),Xf("design:type",aT),Xf("design:paramtypes",[aT])],mT.prototype,"processorDestination",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),Xf("design:type",Function),Xf("design:paramtypes",[Number]),Xf("design:returntype",void 0)],mT.prototype,"setVolume",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",Kf)],mT.prototype,"setPlaybackDevice",null),zf([r.atom("LocalAudioTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean,Object,Boolean]),Xf("design:returntype",Kf)],mT.prototype,"setEnabled",null),zf([r.atom("LocalAudioTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean]),Xf("design:returntype",Kf)],mT.prototype,"setMuted",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Object)],mT.prototype,"getStats",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object,Number]),Xf("design:returntype",void 0)],mT.prototype,"setAudioFrameCallback",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],mT.prototype,"play",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],mT.prototype,"stop",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],mT.prototype,"close",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Object)],mT.prototype,"pipe",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],mT.prototype,"unpipe",null);class fT extends mT{get __className__(){return"MicrophoneAudioTrack"}constructor(t,i,o,n){super(t,i.encoderConfig?qi(i.encoderConfig):{},n,r.getParameter("GET_VOLUME_OF_MUTED_AUDIO_TRACK"),!0),this._config=void 0,this._deviceName="default",this._constraints=void 0,this._originalConstraints=void 0,this._enabled=!0,this._config=i,this._constraints=o,this._originalConstraints=o,this._deviceName=t.label,"boolean"==typeof i.bypassWebAudio&&(this._bypassWebAudio=i.bypassWebAudio),(r.isIOS15()||r.isIOS16())&&eE.bindInterruptDetectorTrack(this),this.on(e.AUDIO_TRACK_EVENT.UPDATE_TRACK_SOURCE,(()=>{this.bindProcessorContextEvents()})),iE()&&this.bindProcessorContextEvents()}async setDevice(e){if(i.logger.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await xE.getDeviceById(e),r={};r.audio=gT({},this._constraints),r.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let o=null;try{o=await DE(r,this.getTrackId())}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),o=await DE({audio:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(o.getAudioTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(o.getAudioTracks()[0],!1),this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await xE.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(t,o,n){if(o)return i.logger.debug("[".concat(this.getTrackId(),"] setEnabled false (do not close microphone)")),await super._setEnabled(t);if(!n){if(t===this._enabled)return;this.stateCheck("enabled",t)}if(i.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),t),!t){var a;this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop(),null===(a=this._source.clonedTrack)||void 0===a||a.stop(),n||(this._enabled=!1);try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const s=gT({},this._constraints),c=xE.searchDeviceIdByName(this._deviceName);c&&!s.deviceId&&(s.deviceId=c);try{n||(this._enabled=!0);const t=await DE({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(t.getAudioTracks()[0],!1),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw n||(this._enabled=!1),i.logger.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(r.isIOS15()||r.isIOS16())&&eE.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((r.isIOS()||r.isIpadOS())&&this._enabled&&!this._isClosed&&eE.duringInterruption){const t=async()=>{eE.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t),this._enabled&&!this._isClosed&&(i.logger.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};eE.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t)}else i.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,r=xE.searchDeviceIdByName(this._deviceName);if(r&&!t.deviceId&&(t.deviceId=r),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await DE({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(){this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,r)=>{try{const r=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(r),t()}catch(e){r(e)}})),this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",Kf)],fT.prototype,"setDevice",null),zf([r.atom("MicrophoneAudioTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t,r]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean,Boolean,Boolean]),Xf("design:returntype",Kf)],fT.prototype,"setEnabled",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],fT.prototype,"close",null);class ET extends mT{get __className__(){return"BufferSourceAudioTrack"}constructor(t,r,i,o){super(r.createOutputTrack(),i,o),this.source=void 0,this._bufferSource=void 0,this.source=t,this._bufferSource=r,this._bufferSource.on(e.AudioSourceEvents.AUDIO_SOURCE_STATE_CHANGE,(t=>{this.safeEmit(e.LocalTrackEvents.SOURCE_STATE_CHANGE,t)}));try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}}get currentState(){return this._bufferSource.currentState}get duration(){return this._bufferSource.duration}get playbackSpeed(){return this._bufferSource.playbackSpeed}getCurrentTime(){return this._bufferSource.currentTime}startProcessAudioBuffer(e){e&&this._bufferSource.updateOptions(e),this._bufferSource.startProcessAudioBuffer()}pauseProcessAudioBuffer(){this._bufferSource.pauseProcessAudioBuffer()}seekAudioBuffer(e){this._bufferSource.seekAudioBuffer(e)}resumeProcessAudioBuffer(){this._bufferSource.resumeProcessAudioBuffer()}stopProcessAudioBuffer(){this._bufferSource.stopProcessAudioBuffer()}close(){this.source=null,this._bufferSource.destroy(),super.close()}setAudioBufferPlaybackSpeed(e){r.checkValidNumber(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",void 0)],ET.prototype,"startProcessAudioBuffer",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],ET.prototype,"pauseProcessAudioBuffer",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Number]),Xf("design:returntype",void 0)],ET.prototype,"seekAudioBuffer",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],ET.prototype,"resumeProcessAudioBuffer",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],ET.prototype,"stopProcessAudioBuffer",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],ET.prototype,"close",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Number]),Xf("design:returntype",void 0)],ET.prototype,"setAudioBufferPlaybackSpeed",null);class TT extends mT{get __className__(){return"MixingAudioTrack"}get isActive(){for(const e of this.trackList)if(e._enabled&&!e._isClosed&&!e.muted)return!0;return!1}constructor(){const e=rE().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,r.getRandomString(8,"track-mix-")),this.trackList=void 0,this.destNode=void 0;try{this._mediaStreamTrack=this._source.createOutputTrack()}catch(e){}this.destNode=e,this.trackList=[]}hasAudioTrack(e){return-1!==this.trackList.indexOf(e)}addAudioTrack(e){-1===this.trackList.indexOf(e)?(i.logger.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):i.logger.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){i.logger.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}r.removeItemFromList(this.trackList,e),this.updateEncoderConfig()}}updateEncoderConfig(){const e={};this.trackList.forEach((t=>{t._encoderConfig&&((t._encoderConfig.bitrate||0)>(e.bitrate||0)&&(e.bitrate=t._encoderConfig.bitrate),(t._encoderConfig.sampleRate||0)>(e.sampleRate||0)&&(e.sampleRate=t._encoderConfig.sampleRate),(t._encoderConfig.sampleSize||0)>(e.sampleSize||0)&&(e.sampleSize=t._encoderConfig.sampleSize),t._encoderConfig.stereo&&(e.stereo=!0))})),this._encoderConfig=e}_updateRtpTransceiver(t){this._rtpTransceiver!==t&&(this._rtpTransceiver=t,this.trackList.forEach((r=>{r instanceof TT?r.emit(e.TrackEvents.TRANSCEIVER_UPDATED,t):r._updateRtpTransceiver(t)})))}}function vT(e){const t={};e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId});const i=Wi(e.encoderConfig);return null!=i.width&&(t.width=i.width),null!=i.height&&(t.height=i.height),!r.isLegacyChrome()&&i.frameRate&&(t.frameRate=i.frameRate),r.isEdge()&&"object"==typeof t.frameRate&&(t.frameRate.max=60),r.isFirefox()&&(t.frameRate={ideal:30,max:30}),t}function _T(e){const t={};e.screenSourceType&&(t.mediaSource=e.screenSourceType),e.extensionId&&r.isChrome()&&(t.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:o,surfaceSwitching:n,systemAudio:a}=e;(r.isAboveChrome(107)||r.isAboveEdge(107)||r.isAboveOpera(93))&&(i&&(r.checkValidEnum(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),o?(r.checkValidEnum(o,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=o):t.selfBrowserSurface="include",n&&(r.checkValidEnum(n,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=n)),(r.isAboveChrome(105)||r.isAboveEdge(105)||r.isAboveOpera(91))&&a&&(r.checkValidEnum(a,"systemAudio",["exclude","include"]),t.systemAudio=a),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const s=e.encoderConfig?Ki(e.encoderConfig):null;return t.mandatory={chromeMediaSource:"desktop",maxWidth:s?s.width:void 0,maxHeight:s?s.height:void 0},s&&(s.frameRate&&("number"==typeof s.frameRate?(t.mandatory.maxFrameRate=s.frameRate,t.mandatory.minFrameRate=s.frameRate):(t.mandatory.maxFrameRate=s.frameRate.max||s.frameRate.ideal||s.frameRate.exact||void 0,t.mandatory.minFrameRate=s.frameRate.min||s.frameRate.ideal||s.frameRate.exact||void 0),t.frameRate=s.frameRate),s.width&&(t.width=s.width),s.height&&(t.height=s.height)),t}function yT(e){const t={};if(r.isLegacyChrome()||(void 0!==e.AGC&&(t.autoGainControl=e.AGC),void 0!==e.AEC&&(t.echoCancellation=e.AEC),void 0!==e.ANS&&(t.noiseSuppression=e.ANS,r.isChrome()&&e.ANS&&(t.googHighpassFilter=e.ANS))),e.encoderConfig){const r=qi(e.encoderConfig);t.channelCount=r.stereo?2:1,t.sampleRate=r.sampleRate,t.sampleSize=r.sampleSize}return e.microphoneId&&(t.deviceId={exact:e.microphoneId}),r.isAndroid()&&(t.sampleRate=void 0),t}class ST extends IE{set currentState(t){t!==this._currentState&&(this._currentState=t,this.safeEmit(e.AudioSourceEvents.AUDIO_SOURCE_STATE_CHANGE,this._currentState))}get currentState(){return this._currentState}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.audioBuffer=void 0,this.sourceNode=void 0,this.startPlayTime=0,this.startPlayOffset=0,this.pausePlayTime=0,this.options=void 0,this.currentLoopCount=0,this.currentPlaybackSpeed=100,this._currentState="stopped",this.audioBuffer=e,this.options=t,this.startPlayOffset=this.options.startPlayTime||0}createWebAudioDiagram(){return this.context.createGain()}get duration(){return this.audioBuffer?this.audioBuffer.duration:0}get playbackSpeed(){return this.currentPlaybackSpeed}get currentTime(){return this.audioBuffer?"stopped"===this.currentState?0:"paused"===this.currentState?this.pausePlayTime:((this.context.currentTime-this.startPlayTime)*(this.playbackSpeed/100)+this.startPlayOffset)%this.audioBuffer.duration:0}updateOptions(e){"stopped"===this.currentState?(this.options=e,this.startPlayOffset=this.options.startPlayTime||0):i.logger.warning("can not set audio source options")}startProcessAudioBuffer(){this.sourceNode&&this.stopProcessAudioBuffer(),this.sourceNode=this.createSourceNode(),this.startSourceNode(),this.currentState="playing"}pauseProcessAudioBuffer(){this.sourceNode&&"playing"===this.currentState&&(this.pausePlayTime=this.currentTime,this.sourceNode.onended=null,this.sourceNode.stop(),this.sourceNode.buffer=null,this.sourceNode=this.createSourceNode(),this.currentState="paused")}seekAudioBuffer(e){this.sourceNode&&(this.sourceNode.onended=null,"playing"===this.currentState&&this.sourceNode.stop(),this.sourceNode=this.createSourceNode(),"playing"===this.currentState?(this.startPlayOffset=e,this.startSourceNode()):"paused"===this.currentState&&(this.pausePlayTime=e))}resumeProcessAudioBuffer(){"paused"===this.currentState&&this.sourceNode&&(this.startPlayOffset=this.pausePlayTime,this.pausePlayTime=0,this.startSourceNode(),this.currentState="playing")}stopProcessAudioBuffer(){if(this.sourceNode){this.sourceNode.onended=null;try{this.sourceNode.stop()}catch(e){}this.reset()}}destroy(){this.audioBuffer=null,super.destroy()}setAudioBufferPlaybackSpeed(e){this.sourceNode&&("playing"===this.currentState&&(this.startPlayOffset=this.currentTime,this.startPlayTime=this.context.currentTime),this.sourceNode.playbackRate.value=e/100),this.currentPlaybackSpeed=e}startSourceNode(){this.sourceNode&&this.sourceNode.buffer&&(this.sourceNode.start(0,this.startPlayOffset),this.startPlayTime=this.context.currentTime,this.sourceNode.onended=this.handleSourceNodeEnded.bind(this))}createSourceNode(){const e=this.context.createBufferSource();return e.buffer=this.audioBuffer,e.loop=!!this.options.loop,e.connect(this.outputNode),e.playbackRate.value=this.currentPlaybackSpeed/100,e}handleSourceNodeEnded(){if(this.currentLoopCount+=1,this.options.cycle&&this.options.cycle>this.currentLoopCount)return this.startPlayOffset=0,this.sourceNode=void 0,void this.startProcessAudioBuffer();this.reset()}reset(){this.startPlayOffset=this.options.startPlayTime||0,this.currentState="stopped",this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=void 0),this.currentLoopCount=0}}const AT=new Map;const bT=e=>{const t=document.createElement("canvas");return t.width=2,t.height=2,new Kf(((i,o)=>{t.toBlob((async e=>{if(t.remove(),e){const r=await IT(e);i({buffer:r,width:t.width,height:t.height})}else o(new r.AgoraRTCError(r.AgoraRTCErrorCode.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},IT=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};class kT extends r.EventEmitter{get visibility(){return document.visibilityState}get lastHiddenTime(){return this._lastHiddenTime}get lastVisibleTime(){return this._lastVisibleTime}constructor(){super(),this._lastHiddenTime=0,this._lastVisibleTime=0,document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState?this._lastHiddenTime=performance.now():this._lastVisibleTime=performance.now(),i.logger.debug("document visibility went ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}}const CT=new kT;function OT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function RT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?OT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):OT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class NT{get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(i.logger.debug("[".concat(this.trackId,"] video-element-status change ").concat(this._videoElementStatus," => ").concat(e)),this._videoElementStatus=e)}constructor(t){this.trackId=void 0,this.config=void 0,this.onFirstVideoFrameDecoded=void 0,this.freezeTimeCounterList=[],this.renderFreezeAccTime=0,this.isKeepLastFrame=!1,this.timeUpdatedCount=0,this.freezeTime=0,this.playbackTime=0,this.lastTimeUpdatedTime=0,this.autoplayFailed=!1,this.videoTrack=void 0,this.videoElement=void 0,this.cacheVideoElement=void 0,this.videoElementCheckInterval=void 0,this._videoElementStatus=e.MediaElementStatus.NONE,this.isGettingVideoDimensions=!1,this.startGetVideoDimensions=()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return i.logger.debug("[".concat(this.trackId,"] current video dimensions:"),this.videoElement.videoWidth,this.videoElement.videoHeight),void(this.isGettingVideoDimensions=!1);setTimeout(e,500)};!this.isGettingVideoDimensions&&e()},this.autoResumeAfterInterruption=()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&"running"===eE.curState&&(i.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(r.getOSWithVersion())),r.isAboveIOS15_1()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.handleVideoEvents=t=>{switch(t.type){case"play":case"playing":this.startGetVideoDimensions(),this.videoElementStatus=e.MediaElementStatus.PLAYING;break;case"loadeddata":if(this.onFirstVideoFrameDecoded&&this.onFirstVideoFrameDecoded(),this.cacheVideoElement){try{this.cacheVideoElement.srcObject=null,this.cacheVideoElement.remove()}catch(e){}this.cacheVideoElement=void 0}break;case"canplay":this.videoElementStatus=e.MediaElementStatus.CANPLAY;break;case"stalled":this.videoElementStatus=e.MediaElementStatus.STALLED;break;case"suspend":this.videoElementStatus=e.MediaElementStatus.SUSPEND;break;case"pause":this.videoElementStatus=e.MediaElementStatus.PAUSED,r.isIOS()||r.isIpadOS()||r.isSafari()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(i.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=e.MediaElementStatus.WAITING;break;case"abort":this.videoElementStatus=e.MediaElementStatus.ABORT;break;case"ended":this.videoElementStatus=e.MediaElementStatus.ENDED;break;case"emptied":this.videoElementStatus=e.MediaElementStatus.EMPTIED;break;case"error":{this.videoElementStatus=e.MediaElementStatus.ERROR;const t=this.videoElement.error;t&&i.logger.error("[".concat(this.trackId,"] media error, code: ").concat(t.code,", message: ").concat(t.message));break}case"timeupdate":{const e=performance.now();if(this.timeUpdatedCount+=1,this.timeUpdatedCount<10)return void(this.lastTimeUpdatedTime=e);const t=e-this.lastTimeUpdatedTime,i=this.lastTimeUpdatedTime;if(this.lastTimeUpdatedTime=e,CT.lastVisibleTime<CT.lastHiddenTime||i<CT.lastHiddenTime||i<CT.lastVisibleTime)return;for(t>r.getParameter("VIDEO_FREEZE_DURATION")&&(this.freezeTime+=t),this.playbackTime+=t;this.playbackTime>=6e3;){this.playbackTime-=6e3;const e=Math.min(6e3,this.freezeTime);this.freezeTimeCounterList.push(e),this.freezeTime=Math.max(0,this.freezeTime-6e3)}break}}},this.autoResumeAfterInterruptionOnIOS15_16=()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&(i.logger.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(r.getOSWithVersion())),r.isAboveIOS15_1()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.trackId=t.trackId,this.config=t,t.element instanceof HTMLVideoElement?this.videoElement=t.element:this.videoElement=document.createElement("video"),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16)}getVideoElement(){return this.videoElement}getContainerElement(){var e;return null!==(e=this.videoElement.parentElement)&&void 0!==e?e:void 0}updateConfig(e){this.config=e,this.trackId=e.trackId,e.element!==this.videoElement&&(this.destroy(),this.videoElement=e.element),this.videoTrack&&this.initVideoElement()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.initVideoElement())}play(e){const t=this.videoElement.play();t&&t.catch&&t.catch((t=>{e&&WE(e,"video",t.message,this.trackId),"NotAllowedError"===t.name?(i.logger.warning("detected video element autoplay failed",t),this.autoplayFailed=!0,this.handleAutoPlayFailed()):i.logger.warning("[".concat(this.trackId,"] play warning: "),t)}));const o=r.getBrowserInfo();if(("Safari"===o.name&&15===Number(o.version)||r.isIOS15())&&t&&t.then){const e=()=>{this.config.mirror&&(this.videoElement.style.transform="rotateY(180deg)")};t.then(e).catch(e)}}getCurrentFrame(){const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight;const t=e.getContext("2d");if(!t)return i.logger.error("create canvas context failed!"),new ImageData(2,2);t.drawImage(this.videoElement,0,0,e.width,e.height);const r=t.getImageData(0,0,e.width,e.height);return e.remove(),r}async getCurrentFrameToUint8Array(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;const i=document.createElement("canvas");i.width=this.videoElement.videoWidth,i.height=this.videoElement.videoHeight;const o=i.getContext("2d");return o?(o.drawImage(this.videoElement,0,0,i.width,i.height),new Kf(((o,n)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await IT(e);o({buffer:t,width:i.width,height:i.height})}else n(new r.AgoraRTCError(r.AgoraRTCErrorCode.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await bT(e)}destroy(){eE.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),eE.off(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[]}initVideoElement(){if(this.videoElementStatus=e.MediaElementStatus.INIT,!this.videoElementCheckInterval&&(wT.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{r.isInPage(this.videoElement)||(this.videoElementStatus=e.MediaElementStatus.DESTROYED)}),1e3),r.getParameter("ENABLE_VIDEO_FRAME_CALLBACK"))){var t,o;let i;const n=(t,o)=>{if(this.videoElementStatus===e.MediaElementStatus.PLAYING){if(i){const e=o.presentationTime-i.presentationTime;e>r.getParameter("VIDEO_FREEZE_DURATION")&&CT.lastVisibleTime>=CT.lastHiddenTime&&i.timestamp>CT.lastVisibleTime&&i.timestamp>CT.lastHiddenTime&&(this.renderFreezeAccTime+=e)}i=RT(RT({},o),{},{timestamp:t})}var a,s;r.getParameter("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(a=(s=this.videoElement).requestVideoFrameCallback)||void 0===a||a.call(s,n))};null===(t=(o=this.videoElement).requestVideoFrameCallback)||void 0===t||t.call(o,n)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),r.isAndroid()&&(this.videoElement.poster="noposter");const n=r.getBrowserInfo();if("Safari"===n.name&&15===Number(n.version)||r.isIOS15()||!this.config.mirror||(this.videoElement.style.transform="rotateY(180deg)"),this.config.fit?this.videoElement.style.objectFit=this.config.fit:this.videoElement.style.objectFit="cover",this.videoElement.setAttribute("muted",""),this.videoElement.muted=!0,this.videoElement.srcObject&&this.videoElement.srcObject instanceof MediaStream){this.videoElement.srcObject.getVideoTracks()[0]!==this.videoTrack&&(this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,r.isFirefox()&&this.videoElement.load())}else this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,r.isFirefox()&&this.videoElement.load();const a=this.videoElement.play();void 0!==a&&a.catch((e=>{i.logger.debug("[".concat(this.trackId,"] playback interrupted"),e.toString())}))}resetVideoElement(){wT.forEach((e=>{this.videoElement&&this.videoElement.removeEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval&&(window.clearInterval(this.videoElementCheckInterval),this.videoElementCheckInterval=void 0),this.videoElementStatus=e.MediaElementStatus.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{i.logger.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{i.logger.error(e)})),this.autoplayFailed=!1,r.isAndroidChromium()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};r.isAndroidChromium()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),jE()}}const wT=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class DT extends NT{constructor(e){super(e),this.container=void 0,this.slot=void 0,this.slot=e.element,this.updateConfig(e)}updateConfig(e){this.config=e,this.trackId=e.trackId;const t=e.element;t!==this.slot&&(this.destroy(),this.slot=t),this.createElements()}updateVideoTrack(e){this.videoTrack!==e&&(this.videoTrack=e,this.createElements())}play(e){var t;null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)&&super.play(e)}getCurrentFrame(){var e;return null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)?super.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameToUint8Array(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return null!==(t=this.container)&&void 0!==t&&t.contains(this.videoElement)?await super.getCurrentFrameToUint8Array(e,r):await bT(e)}destroy(){if(super.destroy(),this.videoElement.remove(),this.videoElement=document.createElement("video"),this.container){try{this.container.remove(),this.slot.removeChild(this.container)}catch(e){}this.container=void 0}}createElements(){this.container||(this.container=document.createElement("div")),this.container.id="agora-video-player-".concat(this.trackId),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="relative",this.container.style.overflow="hidden",this.videoTrack?(this.container.style.backgroundColor="black",r.getParameter("KEEP_LAST_FRAME")&&this.isKeepLastFrame&&this.videoElement.paused&&this.resetVideoElement(),this.mountedVideoElement()):this.unmountedVideoElement(),this.slot.appendChild(this.container)}mountedVideoElement(){var e;!this.container||null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)||this.container.appendChild(this.videoElement),super.initVideoElement(),this.videoElement.id="video_".concat(this.trackId),this.videoElement.className="agora_video_player",this.videoElement.style.width="100%",this.videoElement.style.height="100%",this.videoElement.style.position="absolute",this.videoElement.style.left="0",this.videoElement.style.top="0"}unmountedVideoElement(){var e;if(null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)){super.resetVideoElement();try{this.container&&this.container.removeChild(this.videoElement)}catch(e){}this.videoElement=document.createElement("video")}}resetVideoElement(){var e;null!==(e=this.container)&&void 0!==e&&e.contains(this.videoElement)&&(super.resetVideoElement(),this.cacheVideoElement=this.videoElement,this.videoElement=document.createElement("video"))}getContainerElement(){return this.container}}function PT(e){return new Kf(((t,i)=>{let o=!1;const n=document.createElement("video");n.setAttribute("autoplay",""),n.setAttribute("muted",""),n.muted=!0,n.autoplay=!0,n.setAttribute("playsinline",""),n.setAttribute("style","position: fixed; top: 0; left: 0; width: 1px; height: 1px"),document.body.appendChild(n);const a=r.isIOS()?"canplay":"playing";n.addEventListener(a,(()=>{const e=n.videoWidth,i=n.videoHeight;!e&&r.isFirefox()||(o=!0,n.srcObject=null,n.remove(),t([e,i]))})),n.srcObject=new MediaStream([e]),n.play().catch(r.noop),setTimeout((()=>{o||(n.srcObject=null,n.remove(),t([n.videoWidth,n.videoHeight]))}),4e3)}))}function MT(e,t,r,i){let o;const n=200*Math.pow(r/15,.6)*Math.pow(e*t/640/360,.75),a=n;if("STANDARD_BITRATE"===i)o=4*n;else{if("COMPATIABLE_BITRATE"!==i)return;o=2*n}return[Math.floor(o),Math.floor(a)]}function LT(e,t){if("VideoFrame"in window&&"TransformStream"in window&&c().supportWebRTCInsertableStream){const r=new MediaStreamTrackProcessor(e),i=new MediaStreamTrackGenerator({kind:"video"});let o,n,a=Date.now();const s=()=>{c&&(clearInterval(c),c=void 0),o&&(o.close(),o=void 0),e.stop(),n=void 0,i.removeEventListener("ended",s)};let c=window.setInterval((()=>{if(n&&o&&Date.now()-a>(null!=t?t:1e3))try{"live"===i.readyState?n.enqueue(o.clone()):s()}catch(e){s()}}),null!=t?t:1e3);const d=new TransformStream({transform:(e,t)=>{"live"===i.readyState?(n=t,a=Date.now(),void 0===o?(o=e,t.enqueue(e.clone())):(t.enqueue(o),o=e)):e.close()}});return i.addEventListener("ended",s),r.readable.pipeThrough(d).pipeTo(i.writable),i}}function VT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function xT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?VT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):VT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}class UT extends Jf{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==e.MediaElementStatus.PLAYING)}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(t,o,n,a,s,c){if(super(t,s),this.trackMediaType="video",this._player=void 0,this.isUseScaleResolutionDownBy=!1,this._videoVisibleTimer=null,this._statsTimer=null,this._previousVideoVisibleStatus=void 0,this._clearPreviousVideoVisibleStatus=()=>this._previousVideoVisibleStatus=void 0,this._encoderConfig=void 0,this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1},this._optimizationMode=void 0,this._videoHeight=void 0,this._videoWidth=void 0,this._forceBitrateLimit=void 0,this._enabled=!0,this.processorDestination=void 0,this._processorContext=void 0,r.isSafari()){const{width:e,height:r}=t.getSettings();this._videoWidth=e,this._videoHeight=r}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=o,this._scalabilityMode=n,this._optimizationMode=a,this._hints=c||[],-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK))this.updateBitrateFromProfile();else if(r.isBetweenBrowser(r.BrowserName.CHROME,115)&&r.isWindows()){const e=LT(t);e&&(i.logger.info("local screen video track begin to inject frame"),this._mediaStreamTrack=e)}o&&-1!==this._hints.indexOf(e.TrackHint.CUSTOM_TRACK)&&this.setEncoderConfiguration(o),this.processorContext=new nT(this.getTrackId(),"local"),this.processorDestination=new oT(this.processorContext),this.bindProcessorDestinationEvents()}play(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t){const e=document.getElementById(t);e?t=e:(i.logger.warning("[".concat(this.getTrackId(),'] can not find "#').concat(t,'" element, use document.body')),t=document.body)}i.logger.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(o));const n=xT(xT(xT({},this._getDefaultPlayerConfig()),o),{},{trackId:this.getTrackId(),element:t});this._player?this._player.updateConfig(n):(t instanceof HTMLVideoElement?this._player=new NT(n):this._player=new DT(n),this._player.updateVideoTrack(this._mediaStreamTrack)),this._player.play(),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const t=this.getVideoElementVisibleStatus();this.safeEmit(e.LocalTrackEvents.VIDEO_ELEMENT_VISIBLE_STATUS,t)}catch(e){}}),r.getParameter("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._statsTimer&&(this.isUseScaleResolutionDownBy=!1,window.clearInterval(this._statsTimer),this._statsTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,i.logger.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(t,o){if(!o){if(t===this._enabled)return;this.stateCheck("enabled",t)}if(i.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),t),!t){this._originMediaStreamTrack.enabled=!1;try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return o||(this._enabled=!1),void i.logger.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] setEnabled to true success")),o||(this._enabled=!0)}async setMuted(t){t!==this._muted&&(this.stateCheck("muted",t),this._muted=t,this._originMediaStreamTrack.enabled=!t,i.logger.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(t)),t?await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_MUTE_TRACK,this):await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(t,o){if(!this._enabled)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");if("720p_auto"===t?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),t=Wi(t),this._forceBitrateLimit&&(t.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:t.bitrateMax,t.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:t.bitrateMin),t.width||t.height||t.frameRate){const e=vT({encoderConfig:t});(r.isSafari()||r.isIOS()||r.isIpadOS())&&(e.deviceId=void 0),i.logger.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(t),JSON.stringify(e));try{await this._originMediaStreamTrack.applyConstraints(e),this.updateMediaStreamTrackResolution()}catch(e){const t=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.toString());throw i.logger.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=t,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(i.logger)}}getStats(){r.runOnce((()=>{i.logger.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const t=r.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS);return t||xT({},lo)}async setBeautyEffect(e){i.logger.error("LocalVideoTrack.setBeautyEffect was deprecated, please migrate to agora-extension-beauty-effect")}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}async getCurrentFrameImage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this._player?this._player.getCurrentFrameToUint8Array(e,t):await bT(e)}async setBitrateLimit(t){if(i.logger.debug("[".concat(this.getTrackId(),"] set bitrate limit, ").concat(JSON.stringify(t))),t){this._forceBitrateLimit=t,this._encoderConfig&&(this._encoderConfig.bitrateMax?this._encoderConfig.bitrateMax=this._encoderConfig.bitrateMax<t.max_bitrate?this._encoderConfig.bitrateMax:t.max_bitrate:this._encoderConfig.bitrateMax=t.max_bitrate,this._encoderConfig.bitrateMin,this._encoderConfig.bitrateMin=t.min_bitrate);try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(i.logger)}}}async setOptimizationMode(t){if("motion"!==t&&"detail"!==t&&"balanced"!==t)return void i.logger.error(r.AgoraRTCErrorCode.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const o=this._optimizationMode;try{this._optimizationMode=t,await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.SET_OPTIMIZATION_MODE,this)}catch(e){throw this._optimizationMode=o,i.logger.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(t,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return i.logger.error(r.AgoraRTCErrorCode.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,i.logger.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){PT(this._originMediaStreamTrack).then((e=>{let[t,r]=e;this._videoHeight=r,this._videoWidth=t})).catch(r.noop)}_updatePlayerSource(){this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}_getDefaultPlayerConfig(){return{fit:"contain"}}async setSenderConfiguration(t){if(!this._enabled)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");i.logger.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(t)),t=Wi(t),this._forceBitrateLimit&&(t.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:t.bitrateMax,t.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:t.bitrateMin),this._encoderConfig=t,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(i.logger)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:t,frameRate:o}=this.getMediaStreamTrackSettings();if(!e||!t||!o)return;const[n,a]=MT(e,t,o,r.getParameter("BITRATE_ADAPTER_TYPE"))||[void 0,void 0];this._encoderConfig.bitrateMin||this._encoderConfig.bitrateMax||(this._encoderConfig.bitrateMin=a,this._encoderConfig.bitrateMax=n,i.logger.debug("[".concat(this.getTrackId(),"] update bitrate from profile, [w: ").concat(e,", h: ").concat(t,", fps: ").concat(o,"] => [brMax: ").concat(n,", brMin: ").concat(a,"]")))}getVideoElementVisibleStatus(){try{var e,t;const o=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==o?void 0:o.parentElement},{element:a,slot:s}=n;if(this.isPlaying&&a instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=r.elementVisibleChecker.checkOneElementVisible(a),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.LOCAL_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});t.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(t.reason))}return t}return}catch(e){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}close(){super.close(),this.unbindProcessorDestinationEvents(),this.unbindProcessorContextEvents(),this.unpipe(),this.processorDestination._source&&this.processorDestination._source.unpipe()}clone(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this._encoderConfig;e&&(o=xT(xT({},o),Wi(e))),o=r.safeCloneJson(o);const n=r.getRandomString(8,"track-video-cloned-"),a=new UT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,o,r.safeCloneJson(this._scalabilityMode),this._optimizationMode,n,r.safeCloneJson(this._hints));return e&&o&&a.setEncoderConfiguration(o),i.logger.debug("clone video track from ".concat(this.getTrackId()," to ").concat(n,", clone ").concat(t)),a}async replaceTrack(e,t){if(!(e instanceof MediaStreamTrack))throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}startMonitorStats(){if(!r.isSafari()&&!r.isIOS())return;this._statsTimer&&window.clearInterval(this._statsTimer);let t=2,o=ji[t];let n=-1;let a=Date.now();const s=e=>{e>2||e<0||(a=Date.now(),o=ji[e],this.setSenderConfiguration(o))};this.isUseScaleResolutionDownBy=!0,this._statsTimer=window.setInterval((()=>{const c=this.getStats(),d=r.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_RTC_STATS);if(c.sendPackets>0&&d){-1===n&&(n=Date.now());const e=Date.now();if(e-n<1e3||e-a<r.getParameter("PROFILE_SWITCH_INTERVAL"))return;const u=c.sendFrameRate,l=.6*o.frameRate,h=.9*o.frameRate;"number"==typeof u&&u>0&&u<l?t>0&&(t--,s(t),i.logger.debug("[".concat(this.getTrackId(),"] step down for fps ").concat(u,", switchProfile to ").concat(t))):d.OutgoingAvailableBandwidth<o.bitrateMin?t>0&&(t--,s(t),i.logger.debug("[".concat(this.getTrackId(),"] step down for OutgoingAvailableBandwidth ").concat(d.OutgoingAvailableBandwidth,", bitrateMin ").concat(o.bitrateMin,", switchProfile to ").concat(t))):"number"==typeof u&&u>h&&t<ji.length-1&&d.OutgoingAvailableBandwidth>1.2*ji[t+1].bitrateMin&&(t++,s(t),i.logger.debug("[".concat(this.getTrackId(),"] step up for fps ").concat(u,", OutgoingAvailableBandwidth ").concat(d.OutgoingAvailableBandwidth,", switchProfile to ").concat(t)))}}),r.getParameter("CHECK_LOCAL_STATS_INTERVAL"))}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async t=>{t?t!==this._mediaStreamTrack&&(this._mediaStreamTrack=t,this._updatePlayerSource(),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS)}}zf([i.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",r]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object,Object]),Xf("design:returntype",void 0)],UT.prototype,"play",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],UT.prototype,"stop",null),zf([r.atom("LocalVideoTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean,Boolean]),Xf("design:returntype",Kf)],UT.prototype,"setEnabled",null),zf([r.atom("LocalVideoTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean]),Xf("design:returntype",Kf)],UT.prototype,"setMuted",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object,Boolean]),Xf("design:returntype",Kf)],UT.prototype,"setEncoderConfiguration",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",Object)],UT.prototype,"getStats",null),zf([i.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t,r]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean,Object]),Xf("design:returntype",Kf)],UT.prototype,"setBeautyEffect",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",ImageData)],UT.prototype,"getCurrentFrameData",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[String,Number]),Xf("design:returntype",Kf)],UT.prototype,"getCurrentFrameImage",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Kf)],UT.prototype,"setBitrateLimit",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",Kf)],UT.prototype,"setOptimizationMode",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",void 0)],UT.prototype,"setScalabiltyMode",null),zf([XE(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],UT.prototype,"updateMediaStreamTrackResolution",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Object)],UT.prototype,"pipe",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],UT.prototype,"unpipe",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],UT.prototype,"close",null),zf([i.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),t.label,r]}),Xf("design:type",Function),Xf("design:paramtypes",[MediaStreamTrack,Boolean]),Xf("design:returntype",Kf)],UT.prototype,"replaceTrack",null),zf([i.apiInvoke(),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],UT.prototype,"startMonitorStats",null);class BT extends UT{get __className__(){return"CameraVideoTrack"}constructor(t,o,n,a,s,c){super(t,Wi(o.encoderConfig),a,s,c),this._config=void 0,this._originalConstraints=void 0,this._constraints=void 0,this._enabled=!0,this._deviceName="default",this.tryResumeVideoForIOS15_16WeChat=async()=>{(r.isIOS15()||r.isIOS16())&&!r.isAboveIOS15_2()&&r.isWechatBrowser()&&this._enabled&&!this._isClosed&&(i.logger.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS 15 device on WeChat.")),await this.renewMediaStreamTrack())},this._config=o,this._originalConstraints=n,this._constraints=n,this._deviceName=t.label,this._encoderConfig=Wi(this._config.encoderConfig),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),eE.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),this.bindProcessorContextEvents()}async setDevice(e){return"string"==typeof e?this._setDeviceById(e):e.deviceId?this._setDeviceById(e.deviceId):e.facingMode?this._setDeviceByFacingModel(e.facingMode):void 0}async _setDeviceById(e){if(i.logger.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await xE.getDeviceById(e),r={};r.video=xT({},this._constraints),r.video.deviceId={exact:e},r.video.facingMode=void 0,this._originMediaStreamTrack.stop();let o=null;try{o=await DE(r,this.getTrackId())}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),o=await DE({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(o.getVideoTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(o.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution(),this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await xE.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){i.logger.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:xT(xT({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await DE(t,this.getTrackId())}catch(t){throw i.logger.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await DE({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),t}await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution()}this._deviceName="",this._config.facingMode=e,this._config.cameraId=void 0,this._constraints=xT({},t.video),i.logger.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(t,o){if(!o){if(t===this._enabled)return;this.stateCheck("enabled",t)}if(i.logger.info("[".concat(this.getTrackId(),"] start setEnabled"),t),t){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await DE({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_ENABLE_TRACK,this)}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),i.logger.info("[".concat(this.getTrackId(),"] setEnabled to true success")),o||(this._enabled=!0)}else{this.isExternalTrack?this._originMediaStreamTrack.enabled=!1:(this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop()),o||(this._enabled=!1);try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_DISABLE_TRACK,this)}catch(e){throw i.logger.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}i.logger.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(t,o){if(!this._enabled)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");"720p_auto"===t?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),t=Wi(t),this._forceBitrateLimit&&(t.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:t.bitrateMax,t.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:t.bitrateMin);const n=r.jsonClone(this._config);n.encoderConfig=t;const a=vT(n);(r.isSafari()||r.isIOS()||r.isIpadOS())&&(a.deviceId=void 0),i.logger.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(t),JSON.stringify(a));try{await this._originMediaStreamTrack.applyConstraints(a),this.updateMediaStreamTrackResolution()}catch(e){const t=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,e.toString());throw i.logger.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}this._config=n,this._constraints=a,this._originalConstraints=a,this._encoderConfig=t,-1===this._hints.indexOf(e.TrackHint.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await r.emitAsPromiseNoResponse(this,e.TrackInternalEvent.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(i.logger)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((r.isIOS()||r.isIpadOS())&&this._enabled&&!this._isClosed&&eE.duringInterruption){const t=async()=>{eE.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t),this._enabled&&!this._isClosed&&(i.logger.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};eE.on(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,t)}else i.logger.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(e.LocalTrackEvents.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,r=xE.searchDeviceIdByName(this._deviceName);if(r&&!t.deviceId&&(t.deviceId={exact:r}),this._enabled){const e=await DE({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),eE.off(e.AUDIO_CONTEXT_EVENT.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),eE.off(e.AUDIO_CONTEXT_EVENT.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=this._encoderConfig;e&&(o=xT(xT({},o),Wi(e))),o=r.safeCloneJson(o);const n=r.getRandomString(8,"track-cam-cloned-"),a=new BT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,r.safeCloneJson(xT(xT({},this._config),{},{encoderConfig:o})),r.safeCloneJson(this._constraints),r.safeCloneJson(this._scalabilityMode),this._optimizationMode,n);return e&&o&&a.setEncoderConfiguration(o),i.logger.debug("clone track from ".concat(this.getTrackId()," to ").concat(n,", clone ").concat(t)),a}bindProcessorContextEvents(){this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,r)=>{try{const r=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(r),t()}catch(e){r(e)}})),this.processorContext.on(e.PROCESSOR_CONTEXT_EVENTS.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}function FT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function jT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?FT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):FT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function HT(e,t,r,o){r.optimizationMode&&(o&&o.width&&o.height?(r.encoderConfig=jT(jT({},o),{},{bitrateMin:o.bitrateMin,bitrateMax:o.bitrateMax}),"motion"!==r.optimizationMode&&"detail"!==r.optimizationMode||(t.contentHint=r.optimizationMode,t.contentHint===r.optimizationMode?i.logger.debug("[".concat(e,"] set content hint to"),r.optimizationMode):i.logger.debug("[".concat(e,"] set content hint failed")))):i.logger.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}function GT(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function WT(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?GT(Object(r),!0).forEach((function(t){Gl(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):GT(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Kf)],BT.prototype,"setDevice",null),zf([r.atom("CameraVideoTrack","_enabledMutex"),i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Boolean,Boolean]),Xf("design:returntype",Kf)],BT.prototype,"setEnabled",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),XE(),Xf("design:type",Function),Xf("design:paramtypes",[Object,Boolean]),Xf("design:returntype",Kf)],BT.prototype,"setEncoderConfiguration",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],BT.prototype,"close",null);class KT extends qf{getUserId(){return this._userId}constructor(e,t,i,o){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(o.clientId,"_").concat(r.getRandomString(5,""))),this._userId=void 0,this._uintId=void 0,this._isDestroyed=!1,this.store=void 0,this.processor=void 0,this._userId=t,this._uintId=i,this.store=o}_updateOriginMediaStreamTrack(e){this._originMediaStreamTrack=e,this._mediaStreamTrack=e,this._updatePlayerSource(),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext})}_destroy(){this._isDestroyed=!0,i.logger.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}class zT extends KT{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==e.MediaElementStatus.PLAYING)}get __className__(){return"RemoteVideoTrack"}constructor(e,t,r,i){super(e,t,r,i),this._videoVisibleTimer=null,this._previousVideoVisibleStatus=void 0,this._clearPreviousVideoVisibleStatus=()=>this._previousVideoVisibleStatus=void 0,this.trackMediaType="video",this._videoWidth=void 0,this._videoHeight=void 0,this._player=void 0,this.processorDestination=void 0,this.processorContext=void 0,this.updateMediaStreamTrackResolution(),this.processorContext=new nT(this.getTrackId(),"remote"),this.processorDestination=new oT(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){r.runOnce((()=>{i.logger.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return r.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS)||WT({},po)}play(t){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof t){const e=document.getElementById(t);e?t=e:(i.logger.warning("[".concat(this.getTrackId(),'] can not find "#').concat(t,'" element, use document.body')),t=document.body)}i.logger.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(o));const n=WT(WT({fit:"cover"},o),{},{trackId:this.getTrackId(),element:t});this._player?this._player.updateConfig(n):(t instanceof HTMLVideoElement?this._player=new NT(n):this._player=new DT(n),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(e.RemoteTrackEvents.FIRST_FRAME_DECODED)}),this._player.play(this.store.sessionId||void 0),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const t=this.getVideoElementVisibleStatus();this.safeEmit(e.RemoteTrackEvents.VIDEO_ELEMENT_VISIBLE_STATUS,t)}catch(e){}}),r.getParameter("CHECK_VIDEO_VISIBLE_INTERVAL"))}stop(){this._player&&(this._videoVisibleTimer&&(window.clearInterval(this._videoVisibleTimer),this._videoVisibleTimer=null),this._clearPreviousVideoVisibleStatus(),this._player.destroy(),this._player=void 0,i.logger.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){PT(this._originMediaStreamTrack).then((e=>{let[t,r]=e;this._videoHeight=r,this._videoWidth=t})).catch(r.noop)}_updatePlayerSource(){i.logger.debug("[".concat(this.getTrackId(),"] update player source track")),this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}getVideoElementVisibleStatus(){try{var e,t;const o=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),n={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==o?void 0:o.parentElement},{element:a,slot:s}=n;if(this.isPlaying&&a instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=r.elementVisibleChecker.checkOneElementVisible(a),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.REMOTE_VIDEO_TRACK_GET_VIDEO_VISIBLE,options:[this.getTrackId()]});t.visible?e.onSuccess("Video is visible"):e.onSuccess("Invisible because of ".concat(t.reason))}return t}return}catch(e){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}),e}unpipe(){if(!this.processor)return;const e=this.processor;this.processor._source=void 0,this.processor=void 0,e.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource()):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}}zf([i.apiInvoke({argsMap:(e,t,r)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",r]}),Xf("design:type",Function),Xf("design:paramtypes",[Object,Object]),Xf("design:returntype",void 0)],zT.prototype,"play",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],zT.prototype,"stop",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Object)],zT.prototype,"pipe",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],zT.prototype,"unpipe",null);class XT extends KT{get isPlaying(){return this._useAudioElement?zE.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"RemoteAudioTrack"}constructor(t,i,o,n){super(t,i,o,n),this.trackMediaType="audio",this._source=void 0,this._useAudioElement=!0,this._volume=100,this.processorContext=void 0,this.processorDestination=void 0,this._played=!1,this._bypassWebAudio=!1,r.getParameter("DISABLE_WEBAUDIO")?(this._source=new cT,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new kE(t,!0),r.getParameter("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(e.AudioSourceEvents.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(e.RemoteTrackEvents.FIRST_FRAME_DECODED)})),this.processorContext=new sT(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new aT(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(e.AudioSourceEvents.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))}setAudioFrameCallback(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!t)return this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(r),this._source.removeAllListeners(e.AudioSourceEvents.ON_AUDIO_BUFFER),this._source.on(e.AudioSourceEvents.ON_AUDIO_BUFFER,(e=>t(e)))}setVolume(e){this._volume=e,this._useAudioElement?zE.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement||!r.isChrome()&&r.getParameter("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser does not support setting the audio output device");await zE.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){r.runOnce((()=>{i.logger.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return r.emitAsInvokerNoResponse(this,e.TrackInternalEvent.GET_STATS)||WT({},ho)}play(){i.logger.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(i.logger.debug("[".concat(this.getTrackId(),"] use audio element to play")),zE.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){i.logger.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?zE.stop(this.getTrackId()):this._source.stop()}_destroy(){super._destroy(),this._played=!1,this.unbindProcessorDestinationEvents(),this._source.destroy()}_isFreeze(){return this._source.isFreeze}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];i.logger.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&zE.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_OPERATION,"Processor ".concat(e.name," already piped, please call unpipe beforehand."));return this.unpipe(),this.processor=e,this.processor._source=this,e.updateInput({track:this._originMediaStreamTrack,node:this._source.processSourceNode,context:this.processorContext}),e}unpipe(){var e;if(this._bypassWebAudio)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not unpipe extension when WebAudio disabled");if(!this.processor)return;const t=this.processor;null===(e=this._source.processSourceNode)||void 0===e||e.disconnect(),this.processor._source=!1,this.processor=void 0,t.reset()}bindProcessorDestinationEvents(){this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource())})),this.processorDestination.on(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE,(e=>{this._source.processedNode=e;const t=!e;this._useAudioElement!==t&&(this._played?(this.stop(),this._useAudioElement=t,this.play()):this._useAudioElement=t)}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_TRACK),this.processorDestination.removeAllListeners(e.PROCESSOR_DESTINATION_EVENTS.ON_NODE)}}var qT;zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),Xf("design:type",Function),Xf("design:paramtypes",[Number]),Xf("design:returntype",void 0)],XT.prototype,"setVolume",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t]}),Xf("design:type",Function),Xf("design:paramtypes",[String]),Xf("design:returntype",Kf)],XT.prototype,"setPlaybackDevice",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],XT.prototype,"play",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],XT.prototype,"stop",null),zf([i.apiInvoke({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Xf("design:type",Function),Xf("design:paramtypes",[Object]),Xf("design:returntype",Object)],XT.prototype,"pipe",null),zf([i.apiInvoke({argsMap:e=>[e.getTrackId()]}),Xf("design:type",Function),Xf("design:paramtypes",[]),Xf("design:returntype",void 0)],XT.prototype,"unpipe",null),function(e){e[e.ONE_BYTE=0]="ONE_BYTE",e[e.TWO_BYTE=1]="TWO_BYTE"}(qT||(qT={}));class JT{constructor(){this._sequence=0,this._startTime=Date.now(),this.isUseOneByte=!0}get startTime(){const e=Date.now()-this._startTime;return e<Math.pow(2,16)?e:(this._startTime+=Math.pow(2,16),this.startTime)}get sequence(){return this._sequence<Math.pow(2,32)?this._sequence++:(this._sequence-=Math.pow(2,32),this.sequence)}serialize(e){const t={commonPacketHeader:{length:0,reserved:0,extension:0,sequence:this.sequence},commonStreamHeader:this.startTime,extension:void 0,payload:e};if(e.byteLength>128){const r=new Uint8Array(4);r.set([1,0,0,0]);const i={id:0,length:4,data:r.buffer},o={profile:this.isUseOneByte?0:1,length:this.isUseOneByte?5:6,datas:[i]};t.commonPacketHeader.extension=1,t.extension=o,t.payload=this.compress(e),t.commonPacketHeader.length=8+(t.extension.length+2)+t.payload.byteLength}else t.commonPacketHeader.length=8+t.payload.byteLength;r.getParameter("SHOW_DATASTREAM2_LOG")&&i.logger.debug("send data header: ".concat(JSON.stringify(t.commonPacketHeader)));const o=new ArrayBuffer(t.commonPacketHeader.length),n=new Uint8Array(o),a=new DataView(o);let s=0;if(a.setUint16(s,t.commonPacketHeader.extension<<15|t.commonPacketHeader.reserved<<14|t.commonPacketHeader.length,!0),s+=2,a.setUint32(s,t.commonPacketHeader.sequence,!0),s+=4,a.setUint16(s,t.commonStreamHeader,!0),s+=2,t.extension){const e=this.serializeExtension(t.extension);n.set(new Uint8Array(e),s),s+=e.byteLength}if(n.set(new Uint8Array(t.payload),s),s+=t.payload.byteLength,s!==t.commonPacketHeader.length)throw Error("serialize error!");return o}deserialize(e){if(e.byteLength<4)return new ArrayBuffer(0);const t=new DataView(e);let o=0;const n=t.getUint16(o,!0);o+=2;const a={length:16383&n,reserved:(16384&n)>>14,extension:(32768&n)>>15,sequence:t.getUint16(o+2,!0)<<16|t.getUint16(o,!0)};let s,c;if(o+=4,r.getParameter("SHOW_DATASTREAM2_LOG")&&i.logger.debug("receive data header: ".concat(JSON.stringify(a))),t.getUint16(o,!0),o+=2,a.extension){c=this.deserializeExtension(e.slice(o)),o+=2+c.length,s=e.slice(o);let t=!1;if(c.datas.length>0){const e=c.datas.find((e=>0===e.id));if(e){t=1==(1&new DataView(e.data).getUint32(0,!0))}}s=t?this.decompress(s):s}else s=e.slice(8);return s}serializeExtension(e){const{profile:t,length:r,datas:i}=e,o=new ArrayBuffer(r+2),n=new Uint8Array(o),a=new DataView(o);let s=0;if(a.setUint8(s++,t),a.setUint8(s++,r),i.forEach((e=>{t?(a.setUint8(s++,e.id),a.setUint8(s++,e.length),n.set(new Uint8Array(e.data),s),s+=e.data.byteLength):(a.setUint8(s++,e.id|e.length<<4),n.set(new Uint8Array(e.data),s),s+=e.data.byteLength)})),s!==r+2)throw Error("serialize extension error, is ".concat(s,"!==").concat(r+2));return o}deserializeExtension(e){const t=new DataView(e);let r=0;const i=t.getUint8(r);r++;const o=t.getUint8(r);r++;const n=i===qT.TWO_BYTE,a=[],s=new DataView(e,2);let c=0;for(;c<o;){let e=0,t=0,r=new ArrayBuffer(0);n?(e=s.getUint8(c),c++,t=s.getUint8(c),c++):(e=15&s.getUint8(c),t=s.getUint8(c)>>4,c++),t>0&&(r=s.buffer.slice(c+2,c+2+t),c+=r.byteLength),a.push({id:e,length:t,data:r})}if(c!==o)throw Error("parse error");return{profile:i,length:o,datas:a}}decompress(e){return n.inflate(new Uint8Array(e))}compress(e){return n.deflate(new Uint8Array(e))}}class YT extends r.EventEmitter{constructor(e,t){super(),this._version=1,this._type=3,this._config=void 0,this._originDataChannel=void 0,this._dataStreamPacketHeader=new ArrayBuffer(4),this._dataStreamPacketHandler=void 0,this._datachannelEventMap=new Map,this._config=e,t&&(this._originDataChannel=t,this._bandDataChannelEvents(t)),this._initPacketHeader(),this._dataStreamPacketHandler=new JT}get id(){return this._config.id}get ordered(){return this._config.ordered}get maxRetransmits(){return r.getParameter("DATASTREAM_MAX_RETRANSMITS")}get metadata(){return this._config.metadata}get readyState(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.readyState)&&void 0!==e?e:"connecting"}get _originDataChannelId(){var e,t;return null!==(e=null===(t=this._originDataChannel)||void 0===t?void 0:t.id)&&void 0!==e?e:null}getChannelId(){return this.id}getConfig(){return this._config}_close(){this._originDataChannel&&(this._unbindDataChannelEvents(this._originDataChannel),this._originDataChannel=void 0)}async _waitTillOpen(){return new Kf(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new r.AgoraRTCError(r.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT,"Cannot create datachannel, id: ".concat(null===(e=this._originDataChannel)||void 0===e?void 0:e.id)))}),1e4);this._originDataChannel.onopen=()=>{clearTimeout(i),this._originDataChannel&&this._bandDataChannelEvents(this._originDataChannel),e()},this._originDataChannel.onerror=()=>{throw clearTimeout(i),new r.AgoraRTCError(r.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new r.AgoraRTCError(r.AgoraRTCErrorCode.DATACHANNEL_CONNECTION_TIMEOUT,"cannot find dataChannel"))}))}_updateOriginDataChannel(e){this._originDataChannel=e,this._bandDataChannelEvents(e)}_initPacketHeader(){const e=new DataView(this._dataStreamPacketHeader);e.setUint16(0,this._version),e.setUint8(2,this._type),e.setUint8(3,this._config.id)}_bandDataChannelEvents(t){this._unbindDataChannelEvents(t),[e.DataChannelEvents.OPEN,e.DataChannelEvents.CLOSE,e.DataChannelEvents.ERROR].forEach((e=>{const r=()=>{this.emit(e)};this._datachannelEventMap.set(e,r),t.addEventListener(e,r)}))}_unbindDataChannelEvents(e){Array.from(this._datachannelEventMap.entries()).forEach((t=>{let[r,i]=t;e.removeEventListener(r,i)})),this._datachannelEventMap.clear()}}s(),Object.defineProperty(e,"isElectron",{enumerable:!0,get:function(){return r.isElectron}}),e.AUDIO_ENCODER_CONFIG_SETTINGS=Xi,e.AudioProcessorContext=sT,e.AudioProcessorDestination=aT,e.BufferSourceAudioTrack=ET,e.CameraVideoTrack=BT,e.DEFAULT_LOCAL_AUDIO_TRACK_STATS=uo,e.DEFAULT_LOCAL_VIDEO_TRACK_STATS=lo,e.DEFAULT_NETWORK_QUALITY_STATS={uplinkNetworkQuality:0,downlinkNetworkQuality:0},e.DEFAULT_REMOTE_AUDIO_TRACK_STATS=ho,e.DEFAULT_REMOTE_VIDEO_TRACK_STATS=po,e.DataChannel=YT,e.DeviceManager=VE,e.LocalAudioTrack=mT,e.LocalDataChannel=class extends YT{send(e){if(this._originDataChannel){let t=e;t=this._dataStreamPacketHandler.serialize(e);const r=new Uint8Array(this._dataStreamPacketHeader.byteLength+t.byteLength);r.set(new Uint8Array(this._dataStreamPacketHeader),0),r.set(new Uint8Array(t),this._dataStreamPacketHeader.byteLength),this._originDataChannel.send(r.buffer)}}},e.LocalTrack=Jf,e.LocalVideoTrack=UT,e.MediaElementNumStatus={uninit:100,none:110,init:120,loadeddata:130,canplay:200,playing:210,paused:220,suspend:300,stalled:310,waiting:320,error:330,destroyed:340,abort:350,ended:360,emptied:370},e.MicrophoneAudioTrack=fT,e.MixingAudioTrack=TT,e.RemoteAudioTrack=XT,e.RemoteDataChannel=class extends YT{constructor(t){super(t),this._messageListener=void 0,this._messageListener=t=>{if(t.data.byteLength<this._dataStreamPacketHeader.byteLength)throw Error("invalid byteLength: the byte length must exceed "+this._dataStreamPacketHeader.byteLength);const o=t.data.slice(0,this._dataStreamPacketHeader.byteLength),n=new DataView(o).getUint8(3);if(n!==this.id)return void(r.getParameter("SHOW_DATASTREAM2_LOG")&&i.logger.debug("invalid datachannel id: ".concat(n," !== ").concat(this.id)));let a=t.data.slice(this._dataStreamPacketHeader.byteLength);a=this._dataStreamPacketHandler.deserialize(a),this.emit(e.DataChannelEvents.MESSAGE,a)}}_updateOriginDataChannel(e){super._updateOriginDataChannel(e),this._bandRemoteDataChannelEvents()}_close(){this._originDataChannel&&(this._originDataChannel.removeEventListener("message",this._messageListener),super._close())}_bandRemoteDataChannelEvents(){this._originDataChannel&&this._originDataChannel.addEventListener("message",this._messageListener)}},e.RemoteTrack=KT,e.RemoteVideoTrack=zT,e.SAFARI_GLOBAL_GUM_LOCK=wE,e.SUPPORT_720P_AUTO_CONFIG_LIST=ji,e.SUPPORT_SCREEN_ENCODER_CONFIG_LIST=Hi,e.SUPPORT_SVC_CONFIG_LIST=Gi,e.SUPPORT_VIDEO_ENCODER_CONFIG_LIST=Fi,e.Track=qf,e.VideoProcessorContext=nT,e.VideoProcessorDestination=oT,e.__TRACK_LIST__=Ji,e.addTrack=Yi,e.audioContextState=eE,e.audioElementPlayCenter=zE,e.audioTimerLoop=function(e,t){let i=!1;const o=1/t;if(r.getParameter("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*o)}else{const t=rE();let r=t.createGain();r.gain.value=0,r.connect(t.destination);const n=()=>{if(i)return void(r=null);const a=t.createOscillator();a.onended=n,a.connect(r),a.start(0),a.stop(t.currentTime+o),e(t.currentTime)};n()}return()=>{i=!0}},e.autoPlayGestureEventEmitter=FE,e.blob2Uint8Array=IT,e.checkMediaStreamTrackResolution=PT,e.checkTrackState=XE,e.createBufferSourceAudioTrack=async function(e){var t;const{cacheOnlineFile:n,encoderConfig:a}=e;let{source:s}=e;const c={source:s instanceof AudioBuffer?"AudioBuffer":s instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":s,cacheOnlineFile:n,encoderConfig:a},d=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_BUFFER_AUDIO_TRACK,options:[c]});if(r.getParameter("DISABLE_WEBAUDIO"))throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const u=r.getRandomString(8,"track-buf-");i.logger.info("start create buffer source audio track with config",JSON.stringify(c),"trackId",u);const l=s;if(!(s instanceof AudioBuffer))try{s=await async function(e,t){let n=null;if("string"==typeof e){const t=AT.get(e);if(t)return i.logger.debug("use cached audio resource: ",e),t;try{n=(await r.retryable((()=>o.get(e,{responseType:"arraybuffer"})),void 0,void 0,{maxRetryCount:3})).data}catch(e){throw new r.AgoraRTCError(r.AgoraRTCErrorCode.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new Kf(((t,i)=>{const o=new FileReader;o.onload=e=>{e.target?t(e.target.result):i(new r.AgoraRTCError(r.AgoraRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR))},o.onerror=()=>{i(new r.AgoraRTCError(r.AgoraRTCErrorCode.READ_LOCAL_AUDIO_FILE_ERROR))},o.readAsArrayBuffer(e)}));n=await t}const a=await nE(n);return"string"==typeof e&&t&&AT.set(e,a),a}(s,n)}catch(e){return d.onError(e),e.throw(i.logger)}const h=new ST(s),p=new ET(l,h,a?qi(a):{},u);return i.logger.info("create buffer source audio track success, trackId:",u),d.onSuccess(p.getTrackId()),p},e.createCameraVideoTrack=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_CAM_VIDEO_TRACK,options:[jT({},e)]}),o=vT(e),n=r.getRandomString(8,"track-cam-");let a=null;const s="720p_auto"===e.encoderConfig;i.logger.info("start create camera video track with config",JSON.stringify(e),"trackId",n);try{a=(await DE({video:o},n)).getVideoTracks()[0]||null}catch(e){throw t.onError(e),e}if(!a){const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(i.logger)}e.optimizationMode&&HT(n,a,e,Wi(e.encoderConfig));const c=new BT(a,e,o,e.scalabiltyMode?zi(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,n);return s&&c.startMonitorStats(),t.onSuccess(c.getTrackId()),i.logger.info("create camera video success, trackId:",n),c},e.createCustomAudioTrack=function(e){const t=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),o=new mT(e.mediaStreamTrack,e.encoderConfig?qi(e.encoderConfig):{},r.getRandomString(8,"track-cus-"),!1,!0);return i.logger.info("create custom audio track success with config",e,"trackId",o.getTrackId()),t.onSuccess(o.getTrackId()),o},e.createCustomVideoTrack=function(t){const o=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_CUSTOM_VIDEO_TRACK,options:[t]}),n=new UT(t.mediaStreamTrack,{width:t.width,height:t.height,frameRate:t.frameRate,bitrateMax:t.bitrateMax,bitrateMin:t.bitrateMin},t.scalabiltyMode?zi(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,r.getRandomString(8,"track-cus-"),[e.TrackHint.CUSTOM_TRACK]);return o.onSuccess(n.getTrackId()),i.logger.info("create custom video track success with config",t,"trackId",n.getTrackId()),n},e.createMicrophoneAndCameraTracks=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_MIC_AND_CAM_TRACKS,options:[e,t]}),n="720p_auto"===t.encoderConfig,a=vT(t),s=yT(e),c=r.getRandomString(8,"track-mic-"),d=r.getRandomString(8,"track-cam-");let u=null,l=null;i.logger.info("start create camera video track(".concat(d,") and microphone audio track(").concat(c,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await DE({audio:s,video:a},"".concat(c,"-").concat(d));u=e.getAudioTracks()[0],l=e.getVideoTracks()[0]}catch(e){throw o.onError(e),e}if(!u||!l){const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find tracks in media stream");return o.onError(e),e.throw(i.logger)}t.optimizationMode&&HT(d,l,t,Wi(t.encoderConfig));const h=new fT(u,e,s,c),p=new BT(l,t,a,t.scalabiltyMode?zi(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,d);return n&&p.startMonitorStats(),o.onSuccess([h.getTrackId(),p.getTrackId()]),i.logger.info("create camera video track(".concat(d,") and microphone audio track(").concat(c,") success")),[h,p]},e.createMicrophoneAudioTrack=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_MIC_AUDIO_TRACK,options:[e]}),o=yT(e),n=r.getRandomString(8,"track-mic-");let a=null;i.logger.info("start create microphone audio track with config",JSON.stringify(e),"trackId",n);try{a=(await DE({audio:o},n)).getAudioTracks()[0]||null}catch(e){throw t.onError(e),e}if(!a){const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(i.logger)}const s=new fT(a,e,o,n);return t.onSuccess(s.getTrackId()),i.logger.info("create microphone audio track success, trackId:",n),s},e.createMixingAudioTrack=function(e){const t=new TT;return e.forEach((e=>t.addAudioTrack(e))),t},e.createScreenVideoTrack=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const n=i.report.reportApiInvoke(null,{tag:r.AgoraAPITag.TRACER,name:r.AgoraAPIName.CREATE_SCREEN_VIDEO_TRACK,options:[jT({},t),o]}),a="720p_auto"===t.encoderConfig;t.encoderConfig?"string"==typeof t.encoderConfig||t.encoderConfig.width&&t.encoderConfig.height||(t.encoderConfig.width={max:1920},t.encoderConfig.height={max:1080}):t.encoderConfig="1080p_2";const s=_T(t),d=r.getRandomString(8,"track-scr-v-");let u=null,l=null;const h=c();if(!h.supportShareAudio&&"enable"===o){const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return n.onError(e),e.throw(i.logger)}i.logger.info("start create screen video track with config",t,"withAudio",o,"trackId",d);try{const e=await DE({screen:s,screenAudio:"auto"===o?h.supportShareAudio:"enable"===o},d);u=e.getVideoTracks()[0]||null,l=e.getAudioTracks()[0]||null}catch(e){throw n.onError(e),e}if(!u){const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.UNEXPECTED_ERROR,"can not find track in media stream");return n.onError(e),e.throw(i.logger)}if(!l&&"enable"===o){u&&u.stop();const e=new r.AgoraRTCError(r.AgoraRTCErrorCode.SHARE_AUDIO_NOT_ALLOWED);return n.onError(e),e.throw(i.logger)}if(t.optimizationMode||(t.optimizationMode="detail"),t.optimizationMode){HT(d,u,t,t.encoderConfig&&Ki(t.encoderConfig)||void 0),t.encoderConfig&&"string"!=typeof t.encoderConfig&&(t.encoderConfig.bitrateMin=t.encoderConfig.bitrateMax)}const p=new UT(u,t.encoderConfig?Ki(t.encoderConfig):{},t.scalabiltyMode?zi(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,d,[e.TrackHint.SCREEN_TRACK]);if(a&&p.startMonitorStats(),!l)return n.onSuccess(p.getTrackId()),i.logger.info("create screen video track success","video:",p.getTrackId()),p;const g=new mT(l,void 0,r.getRandomString(8,"track-scr-a-"),!1,!0);return n.onSuccess([p.getTrackId(),g.getTrackId()]),i.logger.info("create screen video track success","video:",p.getTrackId(),"audio:",g.getTrackId()),[p,g]},e.decodeAudioData=nE,e.deviceManager=xE,e.emptyImage2TypedArray=bT,e.frameData2CryptoBuffer=async(e,t,i)=>await(async(e,t,i)=>{const o=""+t+i,n=r.hexToBytes(r.md5(o)).slice(0,16),a=n.slice(0,12),s=await window.crypto.subtle.importKey("raw",n,"AES-GCM",!0,["encrypt"]);return new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:a},s,e))})(e.buffer,t,i),e.getAudioContext=rE,e.getAudioEncoderConfiguration=qi,e.getBitrateFromResAndFps=MT,e.getCompatibility=c,e.getConstraintsFromCameraConfig=vT,e.getConstraintsFromMicrophoneConfig=yT,e.getConstraintsFromScreenConfig=_T,e.getElectronScreenSources=RE,e.getElectronScreenStream=CE,e.getElectronScreenStreamByUserSelect=OE,e.getLocalStream=DE,e.getScalabilityConfiguration=zi,e.getScreenEncoderConfiguration=Ki,e.getSilenceAudioTrack=function(){if(sE)return sE;const e=rE();if(!e.createMediaStreamDestination)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.NOT_SUPPORTED,"can not create silence audio track");const t=e.createBufferSource(),i=e.createBuffer(1,44100,44100);t.loop=!0,t.buffer=i;const o=e.createMediaStreamDestination();return t.connect(o),sE=o.stream.getAudioTracks()[0],sE},e.getSilenceSamplesDuration=function(e){const t=e.getChannelData(0);let r=0,i=0;for(let e=0;e<t.length;e+=1)0===t[e]?(r+=1,r>i&&(i=r)):r=0;return i/t.length*e.duration},e.getStaticTrackStream=LT,e.getVideoEncoderConfiguration=Wi,e.handleGetUserMediaError=ME,e.hasAudioContext=iE,e.isAudioEncoderConfiguration=$i,e.isAudioEncoderConfigurationOrPreset=function(e){return"string"==typeof e?r.checkValidEnum(e,"profile",Object.keys(Xi)):$i(e),!0},e.isBeautyEffectOptions=function(e){return void 0!==e.smoothnessLevel&&r.checkValidNumber(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&r.checkValidNumber(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&r.checkValidNumber(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&r.checkValidEnum(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0},e.isLowStreamParameter=function(e){if(!e)throw new r.AgoraRTCError(r.AgoraRTCErrorCode.INVALID_PARAMS);return r.isEmpty(e.width)||r.checkValidConstrainLong(e.width,"streamParameter.width"),r.isEmpty(e.height)||r.checkValidConstrainLong(e.height,"streamParameter.height"),r.isEmpty(e.framerate)||r.checkValidConstrainLong(e.framerate,"streamParameter.framerate"),r.isEmpty(e.bitrate)||r.checkValidNumber(e.bitrate,"streamParameter.bitrate"),!0},e.isScreenSourceType=eo,e.isVideoEncoderConfiguration=Zi,e.isVideoEncoderConfigurationOrPreset=function(e){return"string"==typeof e?r.checkValidEnum(e,"profile",Object.keys(Fi)):Zi(e),!0},e.polyfillAudioNode=oE,e.removeTrack=Qi,e.requestAutoplayGesture=jE,e.silenceScriptProcessHandler=cE,e.updateAgoraRTCCompatibility=s,e.visibilityWatcher=CT}));
|