@agora-js/media 4.19.2 → 4.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AgoraRTC_N-media.esm.mjs +1 -1
- package/AgoraRTC_N-media.js +1 -1
- package/package.json +3 -3
package/AgoraRTC_N-media.esm.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AgoraWebSDK_N-v4.19.
|
|
2
|
+
* AgoraWebSDK_N-v4.19.3-0-gb2ca8ca7 Copyright AgoraInc.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import{checkValidConstrainLong as e,checkValidNumber as t,checkValidBoolean as i,checkValidEnum as r,AgoraRTCError as n,AgoraRTCErrorCode as o,isEmpty as s,EventEmitter as a,getRandomString as c,AgoraAPIName as d,AgoraAPITag as u,PromiseMutex as h,emitAsPromiseNoResponse as l,removeItemFromList as p,getParameter as f,getBrowserInfo as m,isIOS as g,isIpadOS as v,BrowserName as _,isChromeKernel as y,nextTick as T,isAboveChrome as E,isAboveFirefox as b,isAboveSafari as S,BrowserOS as k,isSafari as I,isWkWebview as w,isFirefox as A,wait as O,showElectronSelectSourceWindow as D,getElectronInstance as C,isElectron as N,isChrome as R,recursiveMerge as M,isAndroid as P,isHarmonyOS as L,detectSecureContext as x,isAndroidChromium as U,isIOS15 as V,domLoadedPromise as j,emitAsPromise as B,atom as F,runOnce as H,emitAsInvokerNoResponse as G,isIOS16 as W,isLegacyChrome as K,isEdge as z,isAboveEdge as q,isAboveOpera as Y,retryable as J,getOSWithVersion as Q,isAboveIOS15_1 as X,isInPage as Z,noop as $,hexToBytes as ee,md5 as te,isBetweenBrowser as ie,isWindows as re,elementVisibleChecker as ne,safeCloneJson as oe,isAboveIOS15_2 as se,isWechatBrowser as ae,jsonClone as ce}from"@agora-js/shared";export{isElectron}from"@agora-js/shared";import{report as de,logger as ue,AgoraRTCEventUploadType as he,apiInvoke as le}from"@agora-js/report";import pe from"axios";import"webrtc-adapter";import{inflate as fe,deflate as me}from"pako";var ge;!function(e){e.IOS_15_16_INTERRUPTION_START="ios15_16-interruption-start",e.IOS_15_16_INTERRUPTION_END="ios15_16-interruption-end",e.IOS_INTERRUPTION_START="ios-interruption-start",e.IOS_INTERRUPTION_END="ios-interruption-end",e.STATE_CHANGE="state-change"}(ge||(ge={}));var ve="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ye=function(e){try{return!!e()}catch(e){return!0}},Te=!ye((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),Ee=Te,be=Function.prototype,Se=be.call,ke=Ee&&be.bind.bind(Se,Se),Ie=Ee?ke:function(e){return function(){return Se.apply(e,arguments)}},we=Ie({}.isPrototypeOf),Ae=function(e){return e&&e.Math==Math&&e},Oe=Ae("object"==typeof globalThis&&globalThis)||Ae("object"==typeof window&&window)||Ae("object"==typeof self&&self)||Ae("object"==typeof ve&&ve)||function(){return this}()||ve||Function("return this")(),De=Te,Ce=Function.prototype,Ne=Ce.apply,Re=Ce.call,Me="object"==typeof Reflect&&Reflect.apply||(De?Re.bind(Ne):function(){return Re.apply(Ne,arguments)}),Pe=Ie,Le=Pe({}.toString),xe=Pe("".slice),Ue=function(e){return xe(Le(e),8,-1)},Ve=Ue,je=Ie,Be=function(e){if("Function"===Ve(e))return je(e)},Fe="object"==typeof document&&document.all,He={all:Fe,IS_HTMLDDA:void 0===Fe&&void 0!==Fe},Ge=He.all,We=He.IS_HTMLDDA?function(e){return"function"==typeof e||e===Ge}:function(e){return"function"==typeof e},Ke={},ze=!ye((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),qe=Te,Ye=Function.prototype.call,Je=qe?Ye.bind(Ye):function(){return Ye.apply(Ye,arguments)},Qe={},Xe={}.propertyIsEnumerable,Ze=Object.getOwnPropertyDescriptor,$e=Ze&&!Xe.call({1:2},1);Qe.f=$e?function(e){var t=Ze(this,e);return!!t&&t.enumerable}:Xe;var et,tt,it=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},rt=ye,nt=Ue,ot=Object,st=Ie("".split),at=rt((function(){return!ot("z").propertyIsEnumerable(0)}))?function(e){return"String"==nt(e)?st(e,""):ot(e)}:ot,ct=function(e){return null==e},dt=ct,ut=TypeError,ht=function(e){if(dt(e))throw ut("Can't call method on "+e);return e},lt=at,pt=ht,ft=function(e){return lt(pt(e))},mt=We,gt=He.all,vt=He.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:mt(e)||e===gt}:function(e){return"object"==typeof e?null!==e:mt(e)},_t={},yt=_t,Tt=Oe,Et=We,bt=function(e){return Et(e)?e:void 0},St=function(e,t){return arguments.length<2?bt(yt[e])||bt(Tt[e]):yt[e]&&yt[e][t]||Tt[e]&&Tt[e][t]},kt="undefined"!=typeof navigator&&String(navigator.userAgent)||"",It=Oe,wt=kt,At=It.process,Ot=It.Deno,Dt=At&&At.versions||Ot&&Ot.version,Ct=Dt&&Dt.v8;Ct&&(tt=(et=Ct.split("."))[0]>0&&et[0]<4?1:+(et[0]+et[1])),!tt&&wt&&(!(et=wt.match(/Edge\/(\d+)/))||et[1]>=74)&&(et=wt.match(/Chrome\/(\d+)/))&&(tt=+et[1]);var Nt=tt,Rt=Nt,Mt=ye,Pt=Oe.String,Lt=!!Object.getOwnPropertySymbols&&!Mt((function(){var e=Symbol();return!Pt(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Rt&&Rt<41})),xt=Lt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ut=St,Vt=We,jt=we,Bt=Object,Ft=xt?function(e){return"symbol"==typeof e}:function(e){var t=Ut("Symbol");return Vt(t)&&jt(t.prototype,Bt(e))},Ht=String,Gt=function(e){try{return Ht(e)}catch(e){return"Object"}},Wt=We,Kt=Gt,zt=TypeError,qt=function(e){if(Wt(e))return e;throw zt(Kt(e)+" is not a function")},Yt=qt,Jt=ct,Qt=function(e,t){var i=e[t];return Jt(i)?void 0:Yt(i)},Xt=Je,Zt=We,$t=vt,ei=TypeError,ti={exports:{}},ii=Oe,ri=Object.defineProperty,ni=function(e,t){try{ri(ii,e,{value:t,configurable:!0,writable:!0})}catch(i){ii[e]=t}return t},oi="__core-js_shared__",si=Oe[oi]||ni(oi,{}),ai=si;(ti.exports=function(e,t){return ai[e]||(ai[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 ci=ti.exports,di=ht,ui=Object,hi=function(e){return ui(di(e))},li=hi,pi=Ie({}.hasOwnProperty),fi=Object.hasOwn||function(e,t){return pi(li(e),t)},mi=Ie,gi=0,vi=Math.random(),_i=mi(1..toString),yi=function(e){return"Symbol("+(void 0===e?"":e)+")_"+_i(++gi+vi,36)},Ti=ci,Ei=fi,bi=yi,Si=Lt,ki=xt,Ii=Oe.Symbol,wi=Ti("wks"),Ai=ki?Ii.for||Ii:Ii&&Ii.withoutSetter||bi,Oi=function(e){return Ei(wi,e)||(wi[e]=Si&&Ei(Ii,e)?Ii[e]:Ai("Symbol."+e)),wi[e]},Di=Je,Ci=vt,Ni=Ft,Ri=Qt,Mi=function(e,t){var i,r;if("string"===t&&Zt(i=e.toString)&&!$t(r=Xt(i,e)))return r;if(Zt(i=e.valueOf)&&!$t(r=Xt(i,e)))return r;if("string"!==t&&Zt(i=e.toString)&&!$t(r=Xt(i,e)))return r;throw ei("Can't convert object to primitive value")},Pi=TypeError,Li=Oi("toPrimitive"),xi=function(e,t){if(!Ci(e)||Ni(e))return e;var i,r=Ri(e,Li);if(r){if(void 0===t&&(t="default"),i=Di(r,e,t),!Ci(i)||Ni(i))return i;throw Pi("Can't convert object to primitive value")}return void 0===t&&(t="number"),Mi(e,t)},Ui=Ft,Vi=function(e){var t=xi(e,"string");return Ui(t)?t:t+""},ji=vt,Bi=Oe.document,Fi=ji(Bi)&&ji(Bi.createElement),Hi=function(e){return Fi?Bi.createElement(e):{}},Gi=Hi,Wi=!ze&&!ye((function(){return 7!=Object.defineProperty(Gi("div"),"a",{get:function(){return 7}}).a})),Ki=ze,zi=Je,qi=Qe,Yi=it,Ji=ft,Qi=Vi,Xi=fi,Zi=Wi,$i=Object.getOwnPropertyDescriptor;Ke.f=Ki?$i:function(e,t){if(e=Ji(e),t=Qi(t),Zi)try{return $i(e,t)}catch(e){}if(Xi(e,t))return Yi(!zi(qi.f,e,t),e[t])};var er=ye,tr=We,ir=/#|\.prototype\./,rr=function(e,t){var i=or[nr(e)];return i==ar||i!=sr&&(tr(t)?er(t):!!t)},nr=rr.normalize=function(e){return String(e).replace(ir,".").toLowerCase()},or=rr.data={},sr=rr.NATIVE="N",ar=rr.POLYFILL="P",cr=rr,dr=qt,ur=Te,hr=Be(Be.bind),lr=function(e,t){return dr(e),void 0===t?e:ur?hr(e,t):function(){return e.apply(t,arguments)}},pr={},fr=ze&&ye((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),mr=vt,gr=String,vr=TypeError,_r=function(e){if(mr(e))return e;throw vr(gr(e)+" is not an object")},yr=ze,Tr=Wi,Er=fr,br=_r,Sr=Vi,kr=TypeError,Ir=Object.defineProperty,wr=Object.getOwnPropertyDescriptor,Ar="enumerable",Or="configurable",Dr="writable";pr.f=yr?Er?function(e,t,i){if(br(e),t=Sr(t),br(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Dr in i&&!i[Dr]){var r=wr(e,t);r&&r[Dr]&&(e[t]=i.value,i={configurable:Or in i?i[Or]:r[Or],enumerable:Ar in i?i[Ar]:r[Ar],writable:!1})}return Ir(e,t,i)}:Ir:function(e,t,i){if(br(e),t=Sr(t),br(i),Tr)try{return Ir(e,t,i)}catch(e){}if("get"in i||"set"in i)throw kr("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Cr=pr,Nr=it,Rr=ze?function(e,t,i){return Cr.f(e,t,Nr(1,i))}:function(e,t,i){return e[t]=i,e},Mr=Oe,Pr=Me,Lr=Be,xr=We,Ur=Ke.f,Vr=cr,jr=_t,Br=lr,Fr=Rr,Hr=fi,Gr=function(e){var t=function(i,r,n){if(this instanceof t){switch(arguments.length){case 0:return new e;case 1:return new e(i);case 2:return new e(i,r)}return new e(i,r,n)}return Pr(e,this,arguments)};return t.prototype=e.prototype,t},Wr=function(e,t){var i,r,n,o,s,a,c,d,u,h=e.target,l=e.global,p=e.stat,f=e.proto,m=l?Mr:p?Mr[h]:(Mr[h]||{}).prototype,g=l?jr:jr[h]||Fr(jr,h,{})[h],v=g.prototype;for(o in t)r=!(i=Vr(l?o:h+(p?".":"#")+o,e.forced))&&m&&Hr(m,o),a=g[o],r&&(c=e.dontCallGetSet?(u=Ur(m,o))&&u.value:m[o]),s=r&&c?c:t[o],r&&typeof a==typeof s||(d=e.bind&&r?Br(s,Mr):e.wrap&&r?Gr(s):f&&xr(s)?Lr(s):s,(e.sham||s&&s.sham||a&&a.sham)&&Fr(d,"sham",!0),Fr(g,o,d),f&&(Hr(jr,n=h+"Prototype")||Fr(jr,n,{}),Fr(jr[n],o,s),e.real&&v&&(i||!v[o])&&Fr(v,o,s)))},Kr=Math.ceil,zr=Math.floor,qr=Math.trunc||function(e){var t=+e;return(t>0?zr:Kr)(t)},Yr=function(e){var t=+e;return t!=t||0===t?0:qr(t)},Jr=Yr,Qr=Math.max,Xr=Math.min,Zr=function(e,t){var i=Jr(e);return i<0?Qr(i+t,0):Xr(i,t)},$r=Yr,en=Math.min,tn=function(e){return e>0?en($r(e),9007199254740991):0},rn=function(e){return tn(e.length)},nn=ft,on=Zr,sn=rn,an=function(e){return function(t,i,r){var n,o=nn(t),s=sn(o),a=on(r,s);if(e&&i!=i){for(;s>a;)if((n=o[a++])!=n)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},cn={includes:an(!0),indexOf:an(!1)},dn=cn.includes;Wr({target:"Array",proto:!0,forced:ye((function(){return!Array(1).includes()}))},{includes:function(e){return dn(this,e,arguments.length>1?arguments[1]:void 0)}});var un=_t,hn=function(e){return un[e+"Prototype"]},ln=hn("Array").includes,pn=vt,fn=Ue,mn=Oi("match"),gn=function(e){var t;return pn(e)&&(void 0!==(t=e[mn])?!!t:"RegExp"==fn(e))},vn=TypeError,_n={};_n[Oi("toStringTag")]="z";var yn="[object z]"===String(_n),Tn=yn,En=We,bn=Ue,Sn=Oi("toStringTag"),kn=Object,In="Arguments"==bn(function(){return arguments}()),wn=Tn?bn:function(e){var t,i,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(i=function(e,t){try{return e[t]}catch(e){}}(t=kn(e),Sn))?i:In?bn(t):"Object"==(r=bn(t))&&En(t.callee)?"Arguments":r},An=wn,On=String,Dn=function(e){if("Symbol"===An(e))throw TypeError("Cannot convert a Symbol value to a string");return On(e)},Cn=Oi("match"),Nn=Wr,Rn=function(e){if(gn(e))throw vn("The method doesn't accept regular expressions");return e},Mn=ht,Pn=Dn,Ln=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[Cn]=!1,"/./"[e](t)}catch(e){}}return!1},xn=Ie("".indexOf);Nn({target:"String",proto:!0,forced:!Ln("includes")},{includes:function(e){return!!~xn(Pn(Mn(this)),Pn(Rn(e)),arguments.length>1?arguments[1]:void 0)}});var Un=hn("String").includes,Vn=we,jn=ln,Bn=Un,Fn=Array.prototype,Hn=String.prototype,Gn=_e((function(e){var t=e.includes;return e===Fn||Vn(Fn,e)&&t===Fn.includes?jn:"string"==typeof e||e===Hn||Vn(Hn,e)&&t===Hn.includes?Bn:t}));function Wn(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function Kn(e,t,i,r,n){return{width:e,height:t,frameRate:i,bitrateMin:r,bitrateMax:n}}function zn(e,t,i,r,n){return{width:{max:e},height:{max:t},frameRate:i,bitrateMin:r,bitrateMax:n}}function qn(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const Yn={"90p":Kn(160,90),"90p_1":Kn(160,90),"120p":Kn(160,120,15,30,65),"120p_1":Kn(160,120,15,30,65),"120p_3":Kn(120,120,15,30,50),"120p_4":Kn(212,120),"180p":Kn(320,180,15,30,140),"180p_1":Kn(320,180,15,30,140),"180p_3":Kn(180,180,15,30,100),"180p_4":Kn(240,180,15,30,120),"240p":Kn(320,240,15,40,200),"240p_1":Kn(320,240,15,40,200),"240p_3":Kn(240,240,15,40,140),"240p_4":Kn(424,240,15,40,220),"360p":Kn(640,360,15,80,400),"360p_1":Kn(640,360,15,80,400),"360p_3":Kn(360,360,15,80,260),"360p_4":Kn(640,360,30,80,600),"360p_6":Kn(360,360,30,80,400),"360p_7":Kn(480,360,15,80,320),"360p_8":Kn(480,360,30,80,490),"360p_9":Kn(640,360,15,80,800),"360p_10":Kn(640,360,24,80,800),"360p_11":Kn(640,360,24,80,1e3),"480p":Kn(640,480,15,100,500),"480p_1":Kn(640,480,15,100,500),"480p_2":Kn(640,480,30,100,1e3),"480p_3":Kn(480,480,15,100,400),"480p_4":Kn(640,480,30,100,750),"480p_6":Kn(480,480,30,100,600),"480p_8":Kn(848,480,15,100,610),"480p_9":Kn(848,480,30,100,930),"480p_10":Kn(640,480,10,100,400),"720p":Kn(1280,720,15,120,1130),"720p_auto":Kn(1280,720,30,900,3e3),"720p_1":Kn(1280,720,15,120,1130),"720p_2":Kn(1280,720,30,120,2e3),"720p_3":Kn(1280,720,30,120,1710),"720p_5":Kn(960,720,15,120,910),"720p_6":Kn(960,720,30,120,1380),"1080p":Kn(1920,1080,15,120,2080),"1080p_1":Kn(1920,1080,15,120,2080),"1080p_2":Kn(1920,1080,30,120,3e3),"1080p_3":Kn(1920,1080,30,120,3150),"1080p_5":Kn(1920,1080,60,120,4780),"1440p":Kn(2560,1440,30,120,4850),"1440p_1":Kn(2560,1440,30,120,4850),"1440p_2":Kn(2560,1440,60,120,7350),"4k":Kn(3840,2160,30,120,8910),"4k_1":Kn(3840,2160,30,120,8910),"4k_3":Kn(3840,2160,60,120,13500)},Jn=[{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}],Qn={"480p":zn(640,480,5),"480p_1":zn(640,480,5),"480p_2":zn(640,480,30),"480p_3":zn(640,480,15),"720p":zn(1280,720,5),"720p_auto":Kn(1280,720,30,900,3e3),"720p_1":zn(1280,720,5),"720p_2":zn(1280,720,30),"720p_3":zn(1280,720,15),"1080p":zn(1920,1080,5),"1080p_1":zn(1920,1080,5),"1080p_2":zn(1920,1080,30),"1080p_3":zn(1920,1080,15)},Xn={"1SL1TL":qn(1,1),"3SL3TL":qn(3,3),"2SL3TL":qn(2,3)};function Zn(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},Yn[e]):e}function $n(e){return"string"==typeof e?Object.assign({},Qn[e]):e}function eo(e){return"string"==typeof e?Object.assign({},Xn[e]):e}const to={speech_low_quality:Wn(16e3,!1),speech_standard:Wn(32e3,!1,18),music_standard:Wn(48e3,!1),standard_stereo:Wn(48e3,!0,56),high_quality:Wn(48e3,!1,128),high_quality_stereo:Wn(48e3,!0,192)};function io(e){return"string"==typeof e?Object.assign({},to[e]):e}const ro=[];function no(e){Gn(ro).call(ro,e)||ro.push(e)}function oo(e){const t=ro.indexOf(e);-1!==t&&ro.splice(t,1)}function so(i){return e(i.width,"config.width"),e(i.height,"config.height"),void 0!==i.frameRate&&e(i.frameRate,"config.frameRate"),void 0!==i.bitrateMax&&t(i.bitrateMax,"config.bitrateMax"),void 0!==i.bitrateMin&&t(i.bitrateMin,"config.bitrateMin"),!0}function ao(e){return void 0!==e.sampleRate&&t(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&t(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&i(e.stereo,"config.stereo"),void 0!==e.bitrate&&t(e.bitrate,"config.bitrate",0,1e4,!1),!0}function co(e){return"string"==typeof e?r(e,"profile",Object.keys(Yn)):so(e),!0}function uo(e){return"string"==typeof e?r(e,"profile",Object.keys(to)):ao(e),!0}function ho(e){return r(e,"mediaSource",["screen","window","application"]),!0}var lo,po,fo,mo,go,vo,_o,yo,To,Eo;function bo(i){if(!i)throw new n(o.INVALID_PARAMS);return s(i.width)||e(i.width,"streamParameter.width"),s(i.height)||e(i.height,"streamParameter.height"),s(i.framerate)||e(i.framerate,"streamParameter.framerate"),s(i.bitrate)||t(i.bitrate,"streamParameter.bitrate"),!0}!function(e){e.NEED_RENEGOTIATE="@need_renegotiate",e.NEED_REPLACE_TRACK="@need_replace_track",e.NEED_CLOSE="@need_close",e.NEED_ENABLE_TRACK="@need_enable_track",e.NEED_DISABLE_TRACK="@need_disable_track",e.NEED_SESSION_ID="@need_sid",e.SET_OPTIMIZATION_MODE="@set_optimization_mode",e.GET_STATS="@get_stats",e.GET_RTC_STATS="@get_rtc_stats",e.GET_LOW_VIDEO_TRACK="@get_low_video_track",e.NEED_RESET_REMOTE_SDP="@need_reset_remote_sdp",e.NEED_UPDATE_VIDEO_ENCODER="@need_update_video_encoder",e.NEED_MUTE_TRACK="@need_mute_track",e.NEED_UNMUTE_TRACK="@need_unmute_track"}(lo||(lo={})),function(e){e.SCREEN_TRACK="screen_track",e.CUSTOM_TRACK="custome_track",e.LOW_STREAM="low_stream"}(po||(po={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(fo||(fo={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(mo||(mo={})),function(e){e[e.DISABLE=0]="DISABLE",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.AUDIO_ONLY=2]="AUDIO_ONLY"}(go||(go={})),function(e){e.TRANSCEIVER_UPDATED="transceiver-updated"}(vo||(vo={})),function(e){e.SOURCE_STATE_CHANGE="source-state-change",e.TRACK_ENDED="track-ended",e.BEAUTY_EFFECT_OVERLOAD="beauty-effect-overload",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.CLOSED="closed"}(_o||(_o={})),function(e){e.FIRST_FRAME_DECODED="first-frame-decoded",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status"}(yo||(yo={})),function(e){e.AUDIO_SOURCE_STATE_CHANGE="audio_source_state_change",e.RECEIVE_TRACK_BUFFER="receive_track_buffer",e.ON_AUDIO_BUFFER="on_audio_buffer",e.UPDATE_SOURCE="update_source"}(To||(To={})),function(e){e.UPDATE_TRACK_SOURCE="update-track-source"}(Eo||(Eo={}));const So={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},ko={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},Io={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},wo={uplinkNetworkQuality:0,downlinkNetworkQuality:0},Ao={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 Oo,Do,Co,No,Ro;function Mo(e){return void 0!==e.smoothnessLevel&&t(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&t(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&t(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&r(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0}!function(e){e.ON_TRACK="on_track",e.ON_NODE="on_node"}(Oo||(Oo={})),function(e){e.REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",e.REQUEST_CONSTRAINTS="request_constraints"}(Do||(Do={})),function(e){e.IDLE="IDLE",e.INITING="INITING",e.INITEND="INITEND"}(Co||(Co={})),function(e){e.STATE_CHANGE="state_change",e.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",e.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",e.CAMERA_DEVICE_CHANGED="cameraDeviceChanged"}(No||(No={})),function(e){e.NONE="none",e.INIT="init",e.CANPLAY="canplay",e.PLAYING="playing",e.PAUSED="paused",e.SUSPEND="suspend",e.STALLED="stalled",e.WAITING="waiting",e.ERROR="error",e.DESTROYED="destroyed",e.ABORT="abort",e.ENDED="ended",e.EMPTIED="emptied",e.LOADEDDATA="loadeddata"}(Ro||(Ro={}));const Po={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};var Lo;!function(e){e.OPEN="open",e.MESSAGE="message",e.CLOSE="close",e.CLOSING="closing",e.ERROR="error"}(Lo||(Lo={}));var xo={exports:{}},Uo=Wr,Vo=ze,jo=pr.f;Uo({target:"Object",stat:!0,forced:Object.defineProperty!==jo,sham:!Vo},{defineProperty:jo});var Bo=_t.Object,Fo=xo.exports=function(e,t,i){return Bo.defineProperty(e,t,i)};Bo.defineProperty.sham&&(Fo.sham=!0);var Ho=_e(xo.exports),Go=Ue,Wo=Array.isArray||function(e){return"Array"==Go(e)},Ko=TypeError,zo=Vi,qo=pr,Yo=it,Jo=function(e,t,i){var r=zo(t);r in e?qo.f(e,r,Yo(0,i)):e[r]=i},Qo=We,Xo=si,Zo=Ie(Function.toString);Qo(Xo.inspectSource)||(Xo.inspectSource=function(e){return Zo(e)});var $o=Xo.inspectSource,es=Ie,ts=ye,is=We,rs=wn,ns=$o,os=function(){},ss=[],as=St("Reflect","construct"),cs=/^\s*(?:class|function)\b/,ds=es(cs.exec),us=!cs.exec(os),hs=function(e){if(!is(e))return!1;try{return as(os,ss,e),!0}catch(e){return!1}},ls=function(e){if(!is(e))return!1;switch(rs(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return us||!!ds(cs,ns(e))}catch(e){return!0}};ls.sham=!0;var ps=!as||ts((function(){var e;return hs(hs.call)||!hs(Object)||!hs((function(){e=!0}))||e}))?ls:hs,fs=Wo,ms=ps,gs=vt,vs=Oi("species"),_s=Array,ys=function(e){var t;return fs(e)&&(t=e.constructor,(ms(t)&&(t===_s||fs(t.prototype))||gs(t)&&null===(t=t[vs]))&&(t=void 0)),void 0===t?_s:t},Ts=function(e,t){return new(ys(e))(0===t?0:t)},Es=ye,bs=Nt,Ss=Oi("species"),ks=Wr,Is=ye,ws=Wo,As=vt,Os=hi,Ds=rn,Cs=function(e){if(e>9007199254740991)throw Ko("Maximum allowed index exceeded");return e},Ns=Jo,Rs=Ts,Ms=function(e){return bs>=51||!Es((function(){var t=[];return(t.constructor={})[Ss]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Ps=Nt,Ls=Oi("isConcatSpreadable"),xs=Ps>=51||!Is((function(){var e=[];return e[Ls]=!1,e.concat()[0]!==e})),Us=function(e){if(!As(e))return!1;var t=e[Ls];return void 0!==t?!!t:ws(e)};ks({target:"Array",proto:!0,arity:1,forced:!xs||!Ms("concat")},{concat:function(e){var t,i,r,n,o,s=Os(this),a=Rs(s,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(Us(o=-1===t?s:arguments[t]))for(n=Ds(o),Cs(c+n),i=0;i<n;i++,c++)i in o&&Ns(a,c,o[i]);else Cs(c+1),Ns(a,c++,o);return a.length=c,a}});var Vs={},js={},Bs=fi,Fs=ft,Hs=cn.indexOf,Gs=js,Ws=Ie([].push),Ks=function(e,t){var i,r=Fs(e),n=0,o=[];for(i in r)!Bs(Gs,i)&&Bs(r,i)&&Ws(o,i);for(;t.length>n;)Bs(r,i=t[n++])&&(~Hs(o,i)||Ws(o,i));return o},zs=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],qs=Ks,Ys=zs,Js=Object.keys||function(e){return qs(e,Ys)},Qs=ze,Xs=fr,Zs=pr,$s=_r,ea=ft,ta=Js;Vs.f=Qs&&!Xs?Object.defineProperties:function(e,t){$s(e);for(var i,r=ea(t),n=ta(t),o=n.length,s=0;o>s;)Zs.f(e,i=n[s++],r[i]);return e};var ia,ra=St("document","documentElement"),na=yi,oa=ci("keys"),sa=function(e){return oa[e]||(oa[e]=na(e))},aa=_r,ca=Vs,da=zs,ua=js,ha=ra,la=Hi,pa="prototype",fa="script",ma=sa("IE_PROTO"),ga=function(){},va=function(e){return"<"+fa+">"+e+"</"+fa+">"},_a=function(e){e.write(va("")),e.close();var t=e.parentWindow.Object;return e=null,t},ya=function(){try{ia=new ActiveXObject("htmlfile")}catch(e){}var e,t,i;ya="undefined"!=typeof document?document.domain&&ia?_a(ia):(t=la("iframe"),i="java"+fa+":",t.style.display="none",ha.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(va("document.F=Object")),e.close(),e.F):_a(ia);for(var r=da.length;r--;)delete ya[pa][da[r]];return ya()};ua[ma]=!0;var Ta=Object.create||function(e,t){var i;return null!==e?(ga[pa]=aa(e),i=new ga,ga[pa]=null,i[ma]=e):i=ya(),void 0===t?i:ca.f(i,t)},Ea={},ba=Ks,Sa=zs.concat("length","prototype");Ea.f=Object.getOwnPropertyNames||function(e){return ba(e,Sa)};var ka={},Ia=Zr,wa=rn,Aa=Jo,Oa=Array,Da=Math.max,Ca=Ue,Na=ft,Ra=Ea.f,Ma=function(e,t,i){for(var r=wa(e),n=Ia(t,r),o=Ia(void 0===i?r:i,r),s=Oa(Da(o-n,0)),a=0;n<o;n++,a++)Aa(s,a,e[n]);return s.length=a,s},Pa="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];ka.f=function(e){return Pa&&"Window"==Ca(e)?function(e){try{return Ra(e)}catch(e){return Ma(Pa)}}(e):Ra(Na(e))};var La={};La.f=Object.getOwnPropertySymbols;var xa=Rr,Ua=function(e,t,i,r){return r&&r.enumerable?e[t]=i:xa(e,t,i),e},Va=pr,ja=function(e,t,i){return Va.f(e,t,i)},Ba={},Fa=Oi;Ba.f=Fa;var Ha,Ga,Wa,Ka=_t,za=fi,qa=Ba,Ya=pr.f,Ja=function(e){var t=Ka.Symbol||(Ka.Symbol={});za(t,e)||Ya(t,e,{value:qa.f(e)})},Qa=Je,Xa=St,Za=Oi,$a=Ua,ec=function(){var e=Xa("Symbol"),t=e&&e.prototype,i=t&&t.valueOf,r=Za("toPrimitive");t&&!t[r]&&$a(t,r,(function(e){return Qa(i,this)}),{arity:1})},tc=wn,ic=yn?{}.toString:function(){return"[object "+tc(this)+"]"},rc=yn,nc=pr.f,oc=Rr,sc=fi,ac=ic,cc=Oi("toStringTag"),dc=function(e,t,i,r){if(e){var n=i?e:e.prototype;sc(n,cc)||nc(n,cc,{configurable:!0,value:t}),r&&!rc&&oc(n,"toString",ac)}},uc=We,hc=Oe.WeakMap,lc=uc(hc)&&/native code/.test(String(hc)),pc=Oe,fc=vt,mc=Rr,gc=fi,vc=si,_c=sa,yc=js,Tc="Object already initialized",Ec=pc.TypeError,bc=pc.WeakMap;if(lc||vc.state){var Sc=vc.state||(vc.state=new bc);Sc.get=Sc.get,Sc.has=Sc.has,Sc.set=Sc.set,Ha=function(e,t){if(Sc.has(e))throw Ec(Tc);return t.facade=e,Sc.set(e,t),t},Ga=function(e){return Sc.get(e)||{}},Wa=function(e){return Sc.has(e)}}else{var kc=_c("state");yc[kc]=!0,Ha=function(e,t){if(gc(e,kc))throw Ec(Tc);return t.facade=e,mc(e,kc,t),t},Ga=function(e){return gc(e,kc)?e[kc]:{}},Wa=function(e){return gc(e,kc)}}var Ic={set:Ha,get:Ga,has:Wa,enforce:function(e){return Wa(e)?Ga(e):Ha(e,{})},getterFor:function(e){return function(t){var i;if(!fc(t)||(i=Ga(t)).type!==e)throw Ec("Incompatible receiver, "+e+" required");return i}}},wc=lr,Ac=at,Oc=hi,Dc=rn,Cc=Ts,Nc=Ie([].push),Rc=function(e){var t=1==e,i=2==e,r=3==e,n=4==e,o=6==e,s=7==e,a=5==e||o;return function(c,d,u,h){for(var l,p,f=Oc(c),m=Ac(f),g=wc(d,u),v=Dc(m),_=0,y=h||Cc,T=t?y(c,v):i||s?y(c,0):void 0;v>_;_++)if((a||_ in m)&&(p=g(l=m[_],_,f),e))if(t)T[_]=p;else if(p)switch(e){case 3:return!0;case 5:return l;case 6:return _;case 2:Nc(T,l)}else switch(e){case 4:return!1;case 7:Nc(T,l)}return o?-1:r||n?n:T}},Mc={forEach:Rc(0),map:Rc(1),filter:Rc(2),some:Rc(3),every:Rc(4),find:Rc(5),findIndex:Rc(6),filterReject:Rc(7)},Pc=Wr,Lc=Oe,xc=Je,Uc=Ie,Vc=ze,jc=Lt,Bc=ye,Fc=fi,Hc=we,Gc=_r,Wc=ft,Kc=Vi,zc=Dn,qc=it,Yc=Ta,Jc=Js,Qc=Ea,Xc=ka,Zc=La,$c=Ke,ed=pr,td=Vs,id=Qe,rd=Ua,nd=ja,od=ci,sd=js,ad=yi,cd=Oi,dd=Ba,ud=Ja,hd=ec,ld=dc,pd=Ic,fd=Mc.forEach,md=sa("hidden"),gd="Symbol",vd="prototype",_d=pd.set,yd=pd.getterFor(gd),Td=Object[vd],Ed=Lc.Symbol,bd=Ed&&Ed[vd],Sd=Lc.TypeError,kd=Lc.QObject,Id=$c.f,wd=ed.f,Ad=Xc.f,Od=id.f,Dd=Uc([].push),Cd=od("symbols"),Nd=od("op-symbols"),Rd=od("wks"),Md=!kd||!kd[vd]||!kd[vd].findChild,Pd=Vc&&Bc((function(){return 7!=Yc(wd({},"a",{get:function(){return wd(this,"a",{value:7}).a}})).a}))?function(e,t,i){var r=Id(Td,t);r&&delete Td[t],wd(e,t,i),r&&e!==Td&&wd(Td,t,r)}:wd,Ld=function(e,t){var i=Cd[e]=Yc(bd);return _d(i,{type:gd,tag:e,description:t}),Vc||(i.description=t),i},xd=function(e,t,i){e===Td&&xd(Nd,t,i),Gc(e);var r=Kc(t);return Gc(i),Fc(Cd,r)?(i.enumerable?(Fc(e,md)&&e[md][r]&&(e[md][r]=!1),i=Yc(i,{enumerable:qc(0,!1)})):(Fc(e,md)||wd(e,md,qc(1,{})),e[md][r]=!0),Pd(e,r,i)):wd(e,r,i)},Ud=function(e,t){Gc(e);var i=Wc(t),r=Jc(i).concat(Fd(i));return fd(r,(function(t){Vc&&!xc(Vd,i,t)||xd(e,t,i[t])})),e},Vd=function(e){var t=Kc(e),i=xc(Od,this,t);return!(this===Td&&Fc(Cd,t)&&!Fc(Nd,t))&&(!(i||!Fc(this,t)||!Fc(Cd,t)||Fc(this,md)&&this[md][t])||i)},jd=function(e,t){var i=Wc(e),r=Kc(t);if(i!==Td||!Fc(Cd,r)||Fc(Nd,r)){var n=Id(i,r);return!n||!Fc(Cd,r)||Fc(i,md)&&i[md][r]||(n.enumerable=!0),n}},Bd=function(e){var t=Ad(Wc(e)),i=[];return fd(t,(function(e){Fc(Cd,e)||Fc(sd,e)||Dd(i,e)})),i},Fd=function(e){var t=e===Td,i=Ad(t?Nd:Wc(e)),r=[];return fd(i,(function(e){!Fc(Cd,e)||t&&!Fc(Td,e)||Dd(r,Cd[e])})),r};jc||(rd(bd=(Ed=function(){if(Hc(bd,this))throw Sd("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?zc(arguments[0]):void 0,t=ad(e),i=function(e){this===Td&&xc(i,Nd,e),Fc(this,md)&&Fc(this[md],t)&&(this[md][t]=!1),Pd(this,t,qc(1,e))};return Vc&&Md&&Pd(Td,t,{configurable:!0,set:i}),Ld(t,e)})[vd],"toString",(function(){return yd(this).tag})),rd(Ed,"withoutSetter",(function(e){return Ld(ad(e),e)})),id.f=Vd,ed.f=xd,td.f=Ud,$c.f=jd,Qc.f=Xc.f=Bd,Zc.f=Fd,dd.f=function(e){return Ld(cd(e),e)},Vc&&nd(bd,"description",{configurable:!0,get:function(){return yd(this).description}})),Pc({global:!0,constructor:!0,wrap:!0,forced:!jc,sham:!jc},{Symbol:Ed}),fd(Jc(Rd),(function(e){ud(e)})),Pc({target:gd,stat:!0,forced:!jc},{useSetter:function(){Md=!0},useSimple:function(){Md=!1}}),Pc({target:"Object",stat:!0,forced:!jc,sham:!Vc},{create:function(e,t){return void 0===t?Yc(e):Ud(Yc(e),t)},defineProperty:xd,defineProperties:Ud,getOwnPropertyDescriptor:jd}),Pc({target:"Object",stat:!0,forced:!jc},{getOwnPropertyNames:Bd}),hd(),ld(Ed,gd),sd[md]=!0;var Hd=Lt&&!!Symbol.for&&!!Symbol.keyFor,Gd=Wr,Wd=St,Kd=fi,zd=Dn,qd=ci,Yd=Hd,Jd=qd("string-to-symbol-registry"),Qd=qd("symbol-to-string-registry");Gd({target:"Symbol",stat:!0,forced:!Yd},{for:function(e){var t=zd(e);if(Kd(Jd,t))return Jd[t];var i=Wd("Symbol")(t);return Jd[t]=i,Qd[i]=t,i}});var Xd=Wr,Zd=fi,$d=Ft,eu=Gt,tu=Hd,iu=ci("symbol-to-string-registry");Xd({target:"Symbol",stat:!0,forced:!tu},{keyFor:function(e){if(!$d(e))throw TypeError(eu(e)+" is not a symbol");if(Zd(iu,e))return iu[e]}});var ru=Ie([].slice),nu=Wo,ou=We,su=Ue,au=Dn,cu=Ie([].push),du=Wr,uu=St,hu=Me,lu=Je,pu=Ie,fu=ye,mu=We,gu=Ft,vu=ru,_u=function(e){if(ou(e))return e;if(nu(e)){for(var t=e.length,i=[],r=0;r<t;r++){var n=e[r];"string"==typeof n?cu(i,n):"number"!=typeof n&&"Number"!=su(n)&&"String"!=su(n)||cu(i,au(n))}var o=i.length,s=!0;return function(e,t){if(s)return s=!1,t;if(nu(this))return t;for(var r=0;r<o;r++)if(i[r]===e)return t}}},yu=Lt,Tu=String,Eu=uu("JSON","stringify"),bu=pu(/./.exec),Su=pu("".charAt),ku=pu("".charCodeAt),Iu=pu("".replace),wu=pu(1..toString),Au=/[\uD800-\uDFFF]/g,Ou=/^[\uD800-\uDBFF]$/,Du=/^[\uDC00-\uDFFF]$/,Cu=!yu||fu((function(){var e=uu("Symbol")();return"[null]"!=Eu([e])||"{}"!=Eu({a:e})||"{}"!=Eu(Object(e))})),Nu=fu((function(){return'"\\udf06\\ud834"'!==Eu("\udf06\ud834")||'"\\udead"'!==Eu("\udead")})),Ru=function(e,t){var i=vu(arguments),r=_u(t);if(mu(r)||void 0!==e&&!gu(e))return i[1]=function(e,t){if(mu(r)&&(t=lu(r,this,Tu(e),t)),!gu(t))return t},hu(Eu,null,i)},Mu=function(e,t,i){var r=Su(i,t-1),n=Su(i,t+1);return bu(Ou,e)&&!bu(Du,n)||bu(Du,e)&&!bu(Ou,r)?"\\u"+wu(ku(e,0),16):e};Eu&&du({target:"JSON",stat:!0,arity:3,forced:Cu||Nu},{stringify:function(e,t,i){var r=vu(arguments),n=hu(Cu?Ru:Eu,null,r);return Nu&&"string"==typeof n?Iu(n,Au,Mu):n}});var Pu=La,Lu=hi;Wr({target:"Object",stat:!0,forced:!Lt||ye((function(){Pu.f(1)}))},{getOwnPropertySymbols:function(e){var t=Pu.f;return t?t(Lu(e)):[]}}),Ja("asyncIterator"),Ja("hasInstance"),Ja("isConcatSpreadable"),Ja("iterator"),Ja("match"),Ja("matchAll"),Ja("replace"),Ja("search"),Ja("species"),Ja("split");var xu=ec;Ja("toPrimitive"),xu();var Uu=St,Vu=dc;Ja("toStringTag"),Vu(Uu("Symbol"),"Symbol"),Ja("unscopables"),dc(Oe.JSON,"JSON",!0);var ju,Bu,Fu,Hu=_t.Symbol,Gu={},Wu=ze,Ku=fi,zu=Function.prototype,qu=Wu&&Object.getOwnPropertyDescriptor,Yu=Ku(zu,"name"),Ju={EXISTS:Yu,PROPER:Yu&&"something"===function(){}.name,CONFIGURABLE:Yu&&(!Wu||Wu&&qu(zu,"name").configurable)},Qu=!ye((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Xu=fi,Zu=We,$u=hi,eh=Qu,th=sa("IE_PROTO"),ih=Object,rh=ih.prototype,nh=eh?ih.getPrototypeOf:function(e){var t=$u(e);if(Xu(t,th))return t[th];var i=t.constructor;return Zu(i)&&t instanceof i?i.prototype:t instanceof ih?rh:null},oh=ye,sh=We,ah=vt,ch=Ta,dh=nh,uh=Ua,hh=Oi("iterator"),lh=!1;[].keys&&("next"in(Fu=[].keys())?(Bu=dh(dh(Fu)))!==Object.prototype&&(ju=Bu):lh=!0);var ph=!ah(ju)||oh((function(){var e={};return ju[hh].call(e)!==e}));sh((ju=ph?{}:ch(ju))[hh])||uh(ju,hh,(function(){return this}));var fh={IteratorPrototype:ju,BUGGY_SAFARI_ITERATORS:lh},mh=fh.IteratorPrototype,gh=Ta,vh=it,_h=dc,yh=Gu,Th=function(){return this},Eh=Ie,bh=qt,Sh=We,kh=String,Ih=TypeError,wh=function(e,t,i){try{return Eh(bh(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(e){}},Ah=_r,Oh=function(e){if("object"==typeof e||Sh(e))return e;throw Ih("Can't set "+kh(e)+" as a prototype")},Dh=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=wh(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(e){}return function(i,r){return Ah(i),Oh(r),t?e(i,r):i.__proto__=r,i}}():void 0),Ch=Wr,Nh=Je,Rh=Ju,Mh=function(e,t,i,r){var n=t+" Iterator";return e.prototype=gh(mh,{next:vh(+!r,i)}),_h(e,n,!1,!0),yh[n]=Th,e},Ph=nh,Lh=dc,xh=Ua,Uh=Gu,Vh=fh,jh=Rh.PROPER,Bh=Vh.BUGGY_SAFARI_ITERATORS,Fh=Oi("iterator"),Hh="keys",Gh="values",Wh="entries",Kh=function(){return this},zh=function(e,t,i,r,n,o,s){Mh(i,t,r);var a,c,d,u=function(e){if(e===n&&m)return m;if(!Bh&&e in p)return p[e];switch(e){case Hh:case Gh:case Wh:return function(){return new i(this,e)}}return function(){return new i(this)}},h=t+" Iterator",l=!1,p=e.prototype,f=p[Fh]||p["@@iterator"]||n&&p[n],m=!Bh&&f||u(n),g="Array"==t&&p.entries||f;if(g&&(a=Ph(g.call(new e)))!==Object.prototype&&a.next&&(Lh(a,h,!0,!0),Uh[h]=Kh),jh&&n==Gh&&f&&f.name!==Gh&&(l=!0,m=function(){return Nh(f,this)}),n)if(c={values:u(Gh),keys:o?m:u(Hh),entries:u(Wh)},s)for(d in c)(Bh||l||!(d in p))&&xh(p,d,c[d]);else Ch({target:t,proto:!0,forced:Bh||l},c);return s&&p[Fh]!==m&&xh(p,Fh,m,{name:n}),Uh[t]=m,c},qh=function(e,t){return{value:e,done:t}},Yh=ft,Jh=Gu,Qh=Ic;pr.f;var Xh=zh,Zh=qh,$h="Array Iterator",el=Qh.set,tl=Qh.getterFor($h);Xh(Array,"Array",(function(e,t){el(this,{type:$h,target:Yh(e),index:0,kind:t})}),(function(){var e=tl(this),t=e.target,i=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,Zh(void 0,!0)):Zh("keys"==i?r:"values"==i?t[r]:[r,t[r]],!1)}),"values"),Jh.Arguments=Jh.Array;var il={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},rl=Oe,nl=wn,ol=Rr,sl=Gu,al=Oi("toStringTag");for(var cl in il){var dl=rl[cl],ul=dl&&dl.prototype;ul&&nl(ul)!==al&&ol(ul,al,cl),sl[cl]=sl.Array}var hl=Hu,ll=Oi,pl=pr.f,fl=ll("metadata"),ml=Function.prototype;void 0===ml[fl]&&pl(ml,fl,{value:null}),Ja("dispose"),Ja("metadata");var gl=hl;Ja("asyncDispose");var vl=Ie,_l=St("Symbol"),yl=_l.keyFor,Tl=vl(_l.prototype.valueOf),El=_l.isRegisteredSymbol||function(e){try{return void 0!==yl(Tl(e))}catch(e){return!1}};Wr({target:"Symbol",stat:!0},{isRegisteredSymbol:El});for(var bl=ci,Sl=St,kl=Ie,Il=Ft,wl=Oi,Al=Sl("Symbol"),Ol=Al.isWellKnownSymbol,Dl=Sl("Object","getOwnPropertyNames"),Cl=kl(Al.prototype.valueOf),Nl=bl("wks"),Rl=0,Ml=Dl(Al),Pl=Ml.length;Rl<Pl;Rl++)try{var Ll=Ml[Rl];Il(Al[Ll])&&wl(Ll)}catch(e){}var xl=function(e){if(Ol&&Ol(e))return!0;try{for(var t=Cl(e),i=0,r=Dl(Nl),n=r.length;i<n;i++)if(Nl[r[i]]==t)return!0}catch(e){}return!1};Wr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:xl}),Ja("matcher"),Ja("observable"),Wr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:El}),Wr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:xl}),Ja("metadataKey"),Ja("patternMatch"),Ja("replaceAll");var Ul=_e(gl),Vl=Ie,jl=Yr,Bl=Dn,Fl=ht,Hl=Vl("".charAt),Gl=Vl("".charCodeAt),Wl=Vl("".slice),Kl=function(e){return function(t,i){var r,n,o=Bl(Fl(t)),s=jl(i),a=o.length;return s<0||s>=a?e?"":void 0:(r=Gl(o,s))<55296||r>56319||s+1===a||(n=Gl(o,s+1))<56320||n>57343?e?Hl(o,s):r:e?Wl(o,s,s+2):n-56320+(r-55296<<10)+65536}},zl={codeAt:Kl(!1),charAt:Kl(!0)}.charAt,ql=Dn,Yl=Ic,Jl=zh,Ql=qh,Xl="String Iterator",Zl=Yl.set,$l=Yl.getterFor(Xl);Jl(String,"String",(function(e){Zl(this,{type:Xl,string:ql(e),index:0})}),(function(){var e,t=$l(this),i=t.string,r=t.index;return r>=i.length?Ql(void 0,!0):(e=zl(i,r),t.index+=e.length,Ql(e,!1))}));var ep=_e(Ba.f("iterator"));function tp(e){return tp="function"==typeof Ul&&"symbol"==typeof ep?function(e){return typeof e}:function(e){return e&&"function"==typeof Ul&&e.constructor===Ul&&e!==Ul.prototype?"symbol":typeof e},tp(e)}var ip=_e(Ba.f("toPrimitive"));function rp(e){var t=function(e,t){if("object"!==tp(e)||null===e)return e;var i=e[ip];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==tp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===tp(t)?t:String(t)}function np(e,t,i){return(t=rp(t))in e?Ho(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var op=St,sp=Ea,ap=La,cp=_r,dp=Ie([].concat),up=op("Reflect","ownKeys")||function(e){var t=sp.f(cp(e)),i=ap.f;return i?dp(t,i(e)):t},hp=fi,lp=up,pp=Ke,fp=pr,mp=vt,gp=Rr,vp=Error,_p=Ie("".replace),yp=String(vp("zxcasd").stack),Tp=/\n\s*at [^:]*:[^\n]*/,Ep=Tp.test(yp),bp=it,Sp=!ye((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",bp(1,7)),7!==e.stack)})),kp=Rr,Ip=function(e,t){if(Ep&&"string"==typeof e&&!vp.prepareStackTrace)for(;t--;)e=_p(e,Tp,"");return e},wp=Sp,Ap=Error.captureStackTrace,Op=Gu,Dp=Oi("iterator"),Cp=Array.prototype,Np=wn,Rp=Qt,Mp=ct,Pp=Gu,Lp=Oi("iterator"),xp=function(e){if(!Mp(e))return Rp(e,Lp)||Rp(e,"@@iterator")||Pp[Np(e)]},Up=Je,Vp=qt,jp=_r,Bp=Gt,Fp=xp,Hp=TypeError,Gp=Je,Wp=_r,Kp=Qt,zp=lr,qp=Je,Yp=_r,Jp=Gt,Qp=function(e){return void 0!==e&&(Op.Array===e||Cp[Dp]===e)},Xp=rn,Zp=we,$p=function(e,t){var i=arguments.length<2?Fp(e):t;if(Vp(i))return jp(Up(i,e));throw Hp(Bp(e)+" is not iterable")},ef=xp,tf=function(e,t,i){var r,n;Wp(e);try{if(!(r=Kp(e,"return"))){if("throw"===t)throw i;return i}r=Gp(r,e)}catch(e){n=!0,r=e}if("throw"===t)throw i;if(n)throw r;return Wp(r),i},rf=TypeError,nf=function(e,t){this.stopped=e,this.result=t},of=nf.prototype,sf=function(e,t,i){var r,n,o,s,a,c,d,u=i&&i.that,h=!(!i||!i.AS_ENTRIES),l=!(!i||!i.IS_RECORD),p=!(!i||!i.IS_ITERATOR),f=!(!i||!i.INTERRUPTED),m=zp(t,u),g=function(e){return r&&tf(r,"normal",e),new nf(!0,e)},v=function(e){return h?(Yp(e),f?m(e[0],e[1],g):m(e[0],e[1])):f?m(e,g):m(e)};if(l)r=e.iterator;else if(p)r=e;else{if(!(n=ef(e)))throw rf(Jp(e)+" is not iterable");if(Qp(n)){for(o=0,s=Xp(e);s>o;o++)if((a=v(e[o]))&&Zp(of,a))return a;return new nf(!1)}r=$p(e,n)}for(c=l?e.next:r.next;!(d=qp(c,r)).done;){try{a=v(d.value)}catch(e){tf(r,"throw",e)}if("object"==typeof a&&a&&Zp(of,a))return a}return new nf(!1)},af=Dn,cf=Wr,df=we,uf=nh,hf=Dh,lf=function(e,t,i){for(var r=lp(t),n=fp.f,o=pp.f,s=0;s<r.length;s++){var a=r[s];hp(e,a)||i&&hp(i,a)||n(e,a,o(t,a))}},pf=Ta,ff=Rr,mf=it,gf=function(e,t){mp(t)&&"cause"in t&&gp(e,"cause",t.cause)},vf=function(e,t,i,r){wp&&(Ap?Ap(e,t):kp(e,"stack",Ip(i,r)))},_f=sf,yf=function(e,t){return void 0===e?arguments.length<2?"":t:af(e)},Tf=Oi("toStringTag"),Ef=Error,bf=[].push,Sf=function(e,t){var i,r=df(kf,this);hf?i=hf(Ef(),r?uf(this):kf):(i=r?this:pf(kf),ff(i,Tf,"Error")),void 0!==t&&ff(i,"message",yf(t)),vf(i,Sf,i.stack,1),arguments.length>2&&gf(i,arguments[2]);var n=[];return _f(e,bf,{that:n}),ff(i,"errors",n),i};hf?hf(Sf,Ef):lf(Sf,Ef,{name:!0});var kf=Sf.prototype=pf(Ef.prototype,{constructor:mf(1,Sf),message:mf(1,""),name:mf(1,"AggregateError")});cf({global:!0,constructor:!0,arity:2},{AggregateError:Sf});var If,wf,Af,Of,Df="undefined"!=typeof process&&"process"==Ue(process),Cf=St,Nf=ja,Rf=ze,Mf=Oi("species"),Pf=we,Lf=TypeError,xf=ps,Uf=Gt,Vf=TypeError,jf=_r,Bf=function(e){if(xf(e))return e;throw Vf(Uf(e)+" is not a constructor")},Ff=ct,Hf=Oi("species"),Gf=function(e,t){var i,r=jf(e).constructor;return void 0===r||Ff(i=jf(r)[Hf])?t:Bf(i)},Wf=TypeError,Kf=/(?:ipad|iphone|ipod).*applewebkit/i.test(kt),zf=Oe,qf=Me,Yf=lr,Jf=We,Qf=fi,Xf=ye,Zf=ra,$f=ru,em=Hi,tm=function(e,t){if(e<t)throw Wf("Not enough arguments");return e},im=Kf,rm=Df,nm=zf.setImmediate,om=zf.clearImmediate,sm=zf.process,am=zf.Dispatch,cm=zf.Function,dm=zf.MessageChannel,um=zf.String,hm=0,lm={},pm="onreadystatechange";Xf((function(){If=zf.location}));var fm=function(e){if(Qf(lm,e)){var t=lm[e];delete lm[e],t()}},mm=function(e){return function(){fm(e)}},gm=function(e){fm(e.data)},vm=function(e){zf.postMessage(um(e),If.protocol+"//"+If.host)};nm&&om||(nm=function(e){tm(arguments.length,1);var t=Jf(e)?e:cm(e),i=$f(arguments,1);return lm[++hm]=function(){qf(t,void 0,i)},wf(hm),hm},om=function(e){delete lm[e]},rm?wf=function(e){sm.nextTick(mm(e))}:am&&am.now?wf=function(e){am.now(mm(e))}:dm&&!im?(Of=(Af=new dm).port2,Af.port1.onmessage=gm,wf=Yf(Of.postMessage,Of)):zf.addEventListener&&Jf(zf.postMessage)&&!zf.importScripts&&If&&"file:"!==If.protocol&&!Xf(vm)?(wf=vm,zf.addEventListener("message",gm,!1)):wf=pm in em("script")?function(e){Zf.appendChild(em("script"))[pm]=function(){Zf.removeChild(this),fm(e)}}:function(e){setTimeout(mm(e),0)});var _m={set:nm,clear:om},ym=function(){this.head=null,this.tail=null};ym.prototype={add:function(e){var t={item:e,next:null},i=this.tail;i?i.next=t:this.head=t,this.tail=t},get:function(){var e=this.head;if(e)return null===(this.head=e.next)&&(this.tail=null),e.item}};var Tm,Em,bm,Sm,km,Im=ym,wm=/ipad|iphone|ipod/i.test(kt)&&"undefined"!=typeof Pebble,Am=/web0s(?!.*chrome)/i.test(kt),Om=Oe,Dm=lr,Cm=Ke.f,Nm=_m.set,Rm=Im,Mm=Kf,Pm=wm,Lm=Am,xm=Df,Um=Om.MutationObserver||Om.WebKitMutationObserver,Vm=Om.document,jm=Om.process,Bm=Om.Promise,Fm=Cm(Om,"queueMicrotask"),Hm=Fm&&Fm.value;if(!Hm){var Gm=new Rm,Wm=function(){var e,t;for(xm&&(e=jm.domain)&&e.exit();t=Gm.get();)try{t()}catch(e){throw Gm.head&&Tm(),e}e&&e.enter()};Mm||xm||Lm||!Um||!Vm?!Pm&&Bm&&Bm.resolve?((Sm=Bm.resolve(void 0)).constructor=Bm,km=Dm(Sm.then,Sm),Tm=function(){km(Wm)}):xm?Tm=function(){jm.nextTick(Wm)}:(Nm=Dm(Nm,Om),Tm=function(){Nm(Wm)}):(Em=!0,bm=Vm.createTextNode(""),new Um(Wm).observe(bm,{characterData:!0}),Tm=function(){bm.data=Em=!Em}),Hm=function(e){Gm.head||Tm(),Gm.add(e)}}var Km=Hm,zm=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},qm=Oe.Promise,Ym="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Jm=!Ym&&!Df&&"object"==typeof window&&"object"==typeof document,Qm=Oe,Xm=qm,Zm=We,$m=cr,eg=$o,tg=Oi,ig=Jm,rg=Ym,ng=Nt,og=Xm&&Xm.prototype,sg=tg("species"),ag=!1,cg=Zm(Qm.PromiseRejectionEvent),dg=$m("Promise",(function(){var e=eg(Xm),t=e!==String(Xm);if(!t&&66===ng)return!0;if(!og.catch||!og.finally)return!0;if(!ng||ng<51||!/native code/.test(e)){var i=new Xm((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[sg]=r,!(ag=i.then((function(){}))instanceof r))return!0}return!t&&(ig||rg)&&!cg})),ug={CONSTRUCTOR:dg,REJECTION_EVENT:cg,SUBCLASSING:ag},hg={},lg=qt,pg=TypeError,fg=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw pg("Bad Promise constructor");t=e,i=r})),this.resolve=lg(t),this.reject=lg(i)};hg.f=function(e){return new fg(e)};var mg,gg,vg=Wr,_g=Df,yg=Oe,Tg=Je,Eg=Ua,bg=dc,Sg=function(e){var t=Cf(e);Rf&&t&&!t[Mf]&&Nf(t,Mf,{configurable:!0,get:function(){return this}})},kg=qt,Ig=We,wg=vt,Ag=function(e,t){if(Pf(t,e))return e;throw Lf("Incorrect invocation")},Og=Gf,Dg=_m.set,Cg=Km,Ng=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},Rg=zm,Mg=Im,Pg=Ic,Lg=qm,xg=ug,Ug=hg,Vg="Promise",jg=xg.CONSTRUCTOR,Bg=xg.REJECTION_EVENT,Fg=Pg.getterFor(Vg),Hg=Pg.set,Gg=Lg&&Lg.prototype,Wg=Lg,Kg=Gg,zg=yg.TypeError,qg=yg.document,Yg=yg.process,Jg=Ug.f,Qg=Jg,Xg=!!(qg&&qg.createEvent&&yg.dispatchEvent),Zg="unhandledrejection",$g=function(e){var t;return!(!wg(e)||!Ig(t=e.then))&&t},ev=function(e,t){var i,r,n,o=t.value,s=1==t.state,a=s?e.ok:e.fail,c=e.resolve,d=e.reject,u=e.domain;try{a?(s||(2===t.rejection&&ov(t),t.rejection=1),!0===a?i=o:(u&&u.enter(),i=a(o),u&&(u.exit(),n=!0)),i===e.promise?d(zg("Promise-chain cycle")):(r=$g(i))?Tg(r,i,c,d):c(i)):d(o)}catch(e){u&&!n&&u.exit(),d(e)}},tv=function(e,t){e.notified||(e.notified=!0,Cg((function(){for(var i,r=e.reactions;i=r.get();)ev(i,e);e.notified=!1,t&&!e.rejection&&rv(e)})))},iv=function(e,t,i){var r,n;Xg?((r=qg.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),yg.dispatchEvent(r)):r={promise:t,reason:i},!Bg&&(n=yg["on"+e])?n(r):e===Zg&&Ng("Unhandled promise rejection",i)},rv=function(e){Tg(Dg,yg,(function(){var t,i=e.facade,r=e.value;if(nv(e)&&(t=Rg((function(){_g?Yg.emit("unhandledRejection",r,i):iv(Zg,i,r)})),e.rejection=_g||nv(e)?2:1,t.error))throw t.value}))},nv=function(e){return 1!==e.rejection&&!e.parent},ov=function(e){Tg(Dg,yg,(function(){var t=e.facade;_g?Yg.emit("rejectionHandled",t):iv("rejectionhandled",t,e.value)}))},sv=function(e,t,i){return function(r){e(t,r,i)}},av=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,tv(e,!0))},cv=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw zg("Promise can't be resolved itself");var r=$g(t);r?Cg((function(){var i={done:!1};try{Tg(r,t,sv(cv,i,e),sv(av,i,e))}catch(t){av(i,t,e)}})):(e.value=t,e.state=1,tv(e,!1))}catch(t){av({done:!1},t,e)}}};jg&&(Kg=(Wg=function(e){Ag(this,Kg),kg(e),Tg(mg,this);var t=Fg(this);try{e(sv(cv,t),sv(av,t))}catch(e){av(t,e)}}).prototype,(mg=function(e){Hg(this,{type:Vg,done:!1,notified:!1,parent:!1,reactions:new Mg,rejection:!1,state:0,value:void 0})}).prototype=Eg(Kg,"then",(function(e,t){var i=Fg(this),r=Jg(Og(this,Wg));return i.parent=!0,r.ok=!Ig(e)||e,r.fail=Ig(t)&&t,r.domain=_g?Yg.domain:void 0,0==i.state?i.reactions.add(r):Cg((function(){ev(r,i)})),r.promise})),gg=function(){var e=new mg,t=Fg(e);this.promise=e,this.resolve=sv(cv,t),this.reject=sv(av,t)},Ug.f=Jg=function(e){return e===Wg||undefined===e?new gg(e):Qg(e)}),vg({global:!0,constructor:!0,wrap:!0,forced:jg},{Promise:Wg}),bg(Wg,Vg,!1,!0),Sg(Vg);var dv=Oi("iterator"),uv=!1;try{var hv=0,lv={next:function(){return{done:!!hv++}},return:function(){uv=!0}};lv[dv]=function(){return this},Array.from(lv,(function(){throw 2}))}catch(e){}var pv=qm,fv=function(e,t){if(!t&&!uv)return!1;var i=!1;try{var r={};r[dv]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(e){}return i},mv=ug.CONSTRUCTOR||!fv((function(e){pv.all(e).then(void 0,(function(){}))})),gv=Je,vv=qt,_v=hg,yv=zm,Tv=sf;Wr({target:"Promise",stat:!0,forced:mv},{all:function(e){var t=this,i=_v.f(t),r=i.resolve,n=i.reject,o=yv((function(){var i=vv(t.resolve),o=[],s=0,a=1;Tv(e,(function(e){var c=s++,d=!1;a++,gv(i,t,e).then((function(e){d||(d=!0,o[c]=e,--a||r(o))}),n)})),--a||r(o)}));return o.error&&n(o.value),i.promise}});var Ev=Wr,bv=ug.CONSTRUCTOR;qm&&qm.prototype,Ev({target:"Promise",proto:!0,forced:bv,real:!0},{catch:function(e){return this.then(void 0,e)}});var Sv=Je,kv=qt,Iv=hg,wv=zm,Av=sf;Wr({target:"Promise",stat:!0,forced:mv},{race:function(e){var t=this,i=Iv.f(t),r=i.reject,n=wv((function(){var n=kv(t.resolve);Av(e,(function(e){Sv(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var Ov=Je,Dv=hg;Wr({target:"Promise",stat:!0,forced:ug.CONSTRUCTOR},{reject:function(e){var t=Dv.f(this);return Ov(t.reject,void 0,e),t.promise}});var Cv=_r,Nv=vt,Rv=hg,Mv=function(e,t){if(Cv(e),Nv(t)&&t.constructor===e)return t;var i=Rv.f(e);return(0,i.resolve)(t),i.promise},Pv=Wr,Lv=qm,xv=ug.CONSTRUCTOR,Uv=Mv,Vv=St("Promise"),jv=!xv;Pv({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Uv(jv&&this===Vv?Lv:this,e)}});var Bv=Je,Fv=qt,Hv=hg,Gv=zm,Wv=sf;Wr({target:"Promise",stat:!0,forced:mv},{allSettled:function(e){var t=this,i=Hv.f(t),r=i.resolve,n=i.reject,o=Gv((function(){var i=Fv(t.resolve),n=[],o=0,s=1;Wv(e,(function(e){var a=o++,c=!1;s++,Bv(i,t,e).then((function(e){c||(c=!0,n[a]={status:"fulfilled",value:e},--s||r(n))}),(function(e){c||(c=!0,n[a]={status:"rejected",reason:e},--s||r(n))}))})),--s||r(n)}));return o.error&&n(o.value),i.promise}});var Kv=Je,zv=qt,qv=St,Yv=hg,Jv=zm,Qv=sf,Xv="No one promise resolved";Wr({target:"Promise",stat:!0,forced:mv},{any:function(e){var t=this,i=qv("AggregateError"),r=Yv.f(t),n=r.resolve,o=r.reject,s=Jv((function(){var r=zv(t.resolve),s=[],a=0,c=1,d=!1;Qv(e,(function(e){var u=a++,h=!1;c++,Kv(r,t,e).then((function(e){h||d||(d=!0,n(e))}),(function(e){h||d||(h=!0,s[u]=e,--c||o(new i(s,Xv)))}))})),--c||o(new i(s,Xv))}));return s.error&&o(s.value),r.promise}});var Zv=Wr,$v=qm,e_=ye,t_=St,i_=We,r_=Gf,n_=Mv,o_=$v&&$v.prototype;Zv({target:"Promise",proto:!0,real:!0,forced:!!$v&&e_((function(){o_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=r_(this,t_("Promise")),i=i_(e);return this.then(i?function(i){return n_(t,e()).then((function(){return i}))}:e,i?function(i){return n_(t,e()).then((function(){throw i}))}:e)}});var s_=_e(_t.Promise);function a_(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function c_(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class d_ extends a{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||c(8,"track-"),this._originMediaStreamTrack=e,this._mediaStreamTrack=e,no(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){if(!e){const e=de.reportApiInvoke(null,{name:d.GET_MEDIA_STREAM_TRACK,options:[],tag:u.TRACER});this._mediaStreamTrack&&"string"==typeof this._mediaStreamTrack.label?e.onSuccess(this._mediaStreamTrack.label):e.onSuccess("")}return this._mediaStreamTrack}getRTCRtpTransceiver(e){return e===fo.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,oo(this),this.emit(_o.CLOSED)}_updateRtpTransceiver(e,t){if(t===fo.LOW_STREAM){if(this._lowRtpTransceiver===e)return;this._lowRtpTransceiver=e}else{if(this._rtpTransceiver===e)return;this._rtpTransceiver=e}this.emit(vo.TRANSCEIVER_UPDATED,e,t)}}class u_ extends d_{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 h("".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,ue.debug("[".concat(this.getTrackId(),"] close")),this.emit(lo.NEED_CLOSE),super.close())}async _updateOriginMediaStreamTrack(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this._isExternalTrack=i,e!==this._originMediaStreamTrack&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),t&&this._originMediaStreamTrack.stop()),e.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=e,this._muted&&(this._originMediaStreamTrack.enabled=!1),this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await l(this,lo.NEED_REPLACE_TRACK,this),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){ue.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(_o.TRACK_ENDED)}stateCheck(e,t){if(ue.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),i(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new n(o.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",ue);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new n(o.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",ue)}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}function h_(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}const l_=window.AudioContext||window.webkitAudioContext;let p_=null;const f_=new class extends a{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=()=>{ue.info("ios15-interruption-start"),this.emit(ge.IOS_15_16_INTERRUPTION_START)},this.onLocalAudioTrackUnmute=async()=>{ue.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?ue.info("ios15-interruption-end-canceled"):(p_&&await p_.suspend(),this.emit(ge.IOS_15_16_INTERRUPTION_END))}}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){ue.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){ue.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)}};function m_(){if(!l_)return void ue.error("your browser is not support web audio");ue.info("create audio context");const e=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?h_(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):h_(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},f("WEBAUDIO_INIT_OPTIONS"));ue.debug("audio context init option:",JSON.stringify(e)),p_=new l_(e),f_.curState=p_.state,p_.onstatechange=()=>{f_.prevState=f_.curState,f_.curState=p_?p_.state:void 0;const{prevState:e,curState:t}=f_,i="running"===t,r="interrupted"===t,n="running"===e,o="suspended"===e,s="interrupted"===e,a=m().osVersion;(g()||v())&&n&&r&&(ue.info("ios".concat(a,"-interruption-start")),f_.emit(ge.IOS_INTERRUPTION_START)),(g()||v())&&(o||s)&&i&&(ue.info("ios".concat(a,"-interruption-end")),f_.emit(ge.IOS_INTERRUPTION_END)),e!==t&&(ue.debug("AudioContext State Change","".concat(e,"=>").concat(t)),f_.emit(ge.STATE_CHANGE))},setInterval((()=>{var e;const t=null===(e=p_)||void 0===e?void 0:e.currentTime;if(f_.currentTime!==t)f_.currentTimeStuckAt&&(ue.debug("AudioContext current time resume at ".concat(t)),f_.currentTimeStuckAt=void 0),f_.currentTime=t;else{if(t!==f_.currentTimeStuckAt){de.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:u.TRACER}).onSuccess(),ue.warning("AudioContext current time stuck at ".concat(t))}f_.currentTimeStuckAt=t}}),5e3),async function(e){const t=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","touchend","keydown","keyup"];let i,r=!1,n=!1,o=!1;function s(t){"running"===e.state?a(!1):g()||v()?"suspended"===e.state&&(a(!0),t&&e.resume().then(d,d)):"closed"!==e.state&&(a(!0),t&&e.resume().then(d,d))}function a(e){if(r!==e){r=e;for(let i=0,r=t;i<r.length;i+=1){const t=r[i];e?window.addEventListener(t,u,{capture:!0,passive:!0}):window.removeEventListener(t,u,{capture:!0,passive:!0})}}}function c(){s(!0)}function d(){s(!1)}function u(){s(!0)}function h(e){if(!o)if(i.paused)if(e){let e;l(!1),o=!0;try{e=i.play(),e?e.then(p,p):(i.addEventListener("playing",p),i.addEventListener("abort",p),i.addEventListener("error",p))}catch(e){p()}}else l(!0);else l(!1)}function l(e){if(n!==e){n=e;for(let i=0,r=t;i<r.length;i++){const t=r[i];e?window.addEventListener(t,f,{capture:!0,passive:!0}):window.removeEventListener(t,f,{capture:!0,passive:!0})}}}function p(){i.removeEventListener("playing",p),i.removeEventListener("abort",p),i.removeEventListener("error",p),o=!1,h(!1)}function f(){h(!0)}if(g()){const t=e.createMediaStreamDestination(),r=document.createElement("div");r.innerHTML="<audio x-webkit-airplay='deny'></audio>",i=r.children.item(0),i.controls=!1,i.disableRemotePlayback=!0,i.preload="auto",i.srcObject=t.stream,h(!0)}f_.on(ge.STATE_CHANGE,c),s(!1)}(p_)}function g_(){if(!p_){if(m_(),!p_)throw new n(o.NOT_SUPPORTED,"can not create audio context");return p_}return p_}function v_(){return!!p_}function __(e){if(function(){if(null!==T_)return T_;const e=g_(),t=e.createBufferSource(),i=e.createGain(),r=e.createGain();t.connect(i),t.connect(r),t.disconnect(i);let n=!1;try{t.disconnect(i)}catch(e){n=!0}return t.disconnect(),T_=n,n}())return;const t=e.connect,i=e.disconnect;e.connect=(i,r,n)=>{var o;return e._inputNodes||(e._inputNodes=[]),Gn(o=e._inputNodes).call(o,i)||(i instanceof AudioNode?(e._inputNodes.push(i),t.call(e,i,r,n)):t.call(e,i,r)),e},e.disconnect=(r,n,o)=>{i.call(e),r?p(e._inputNodes,r):e._inputNodes=[];for(const i of e._inputNodes)t.call(e,i)}}function y_(e){const t=g_();return new s_(((i,r)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{r(new n(o.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let T_=null;function E_(e,t){let i=!1;const r=1/t;if(f("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*r)}else{const t=g_();let n=t.createGain();n.gain.value=0,n.connect(t.destination);const o=()=>{if(i)return void(n=null);const s=t.createOscillator();s.onended=o,s.connect(n),s.start(0),s.stop(t.currentTime+r),e(t.currentTime)};o()}return()=>{i=!0}}let b_=null;function S_(){if(b_)return b_;const e=g_();if(!e.createMediaStreamDestination)throw new n(o.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 r=e.createMediaStreamDestination();return t.connect(r),b_=r.stream.getAudioTracks()[0],b_}function k_(e){for(let t=0;t<e.outputBuffer.numberOfChannels;t+=1){const i=e.outputBuffer.getChannelData(t);for(let e=0;e<i.length;e+=1)i[e]=0}return e.inputBuffer}function I_(e){const t=e.getChannelData(0);let i=0,r=0;for(let e=0;e<t.length;e+=1)0===t[e]?(i+=1,i>r&&(r=i)):i=0;return r/t.length*e.duration}const w_={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 A_(){const e=m();w_.getDisplayMedia=function(e){if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return!0;return!1}(),w_.getStreamFromExtension=e.name===_.CHROME&&Number(e.version)>34,w_.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}(),w_.supportMinBitrate=e.name===_.CHROME||e.name===_.EDGE,w_.supportSetRtpSenderParameters=function(){const e=m();if(!window.RTCRtpSender||!window.RTCRtpSender.prototype.setParameters||!window.RTCRtpSender.prototype.getParameters)return!1;return!!y()||(!(!I()&&!w())||e.name===_.FIREFOX&&Number(e.version)>=64)}(),e.name===_.SAFARI&&(Number(e.version)>=14?w_.supportDualStream=!0:w_.supportDualStream=!1),w_.webAudioMediaStreamDest=function(){const e=m();if(e.name===_.SAFARI&&Number(e.version)<12)return!1;return!0}(),w_.supportReplaceTrack=function(){if(!window.RTCRtpSender)return!1;if("function"==typeof RTCRtpSender.prototype.replaceTrack)return!0;return!1}(),w_.supportWebGL="undefined"!=typeof WebGLRenderingContext,w_.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,y()||(w_.webAudioWithAEC=!0),w_.supportShareAudio=function(){const e=m();if((e.os===k.WIN_10||e.os===k.WIN_81||e.os===k.WIN_7||e.os===k.LINUX||e.os===k.MAC_OS)&&e.name===_.CHROME&&Number(e.version)>=74)return!0;return!1}(),w_.supportDataChannel=function(){if(E(76)||b(68)||S(14))return!0;return!1}(),w_.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!A()&&!!e&&e.prototype.setConfiguration instanceof Function}(),w_.supportWebRTCEncodedTransform=function(){const e=m();return"Chrome"===e.name&&Number(e.version)>=86}(),w_.supportWebRTCInsertableStream=function(){const e=m();return(e.name===_.CHROME||e.name===_.EDGE)&&Number(e.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),T((()=>{w_.supportDualStreamEncoding=function(){const e=m();if(f("DISABLE_WEBAUDIO"))return!0;return"Safari"===e.name&&Number(e.version)>=14||!!("Chrome"===e.name&&/Windows/i.test(e.os||"")&&Number(e.version)>=100&&f("CHROME_DUAL_STREAM_USE_ENCODING"))}(),ue.info("browser compatibility",JSON.stringify(w_),JSON.stringify(e))}))}function O_(){return w_}var D_=qt,C_=hi,N_=at,R_=rn,M_=TypeError,P_=function(e){return function(t,i,r,n){D_(i);var o=C_(t),s=N_(o),a=R_(o),c=e?a-1:0,d=e?-1:1;if(r<2)for(;;){if(c in s){n=s[c],c+=d;break}if(c+=d,e?c<0:a<=c)throw M_("Reduce of empty array with no initial value")}for(;e?c>=0:a>c;c+=d)c in s&&(n=i(n,s[c],c,o));return n}},L_={left:P_(!1),right:P_(!0)},x_=ye,U_=L_.left,V_=function(e,t){var i=[][e];return!!i&&x_((function(){i.call(null,t||function(){return 1},1)}))};Wr({target:"Array",proto:!0,forced:!Df&&Nt>79&&Nt<83||!V_("reduce")},{reduce:function(e){var t=arguments.length;return U_(this,e,t,t>1?arguments[1]:void 0)}});var j_=hn("Array").reduce,B_=we,F_=j_,H_=Array.prototype,G_=_e((function(e){var t=e.reduce;return e===H_||B_(H_,e)&&t===H_.reduce?F_:t}));class W_{constructor(){this.context=void 0,this.analyserNode=void 0,this.sourceNode=void 0,this.context=g_(),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||g()||v()||"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 i=0;i<e.length;++i)e[i]=t[i]/128-1}const t=G_(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){ue.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class K_ extends a{get processSourceNode(){return this.sourceNode}set processedNode(e){var t;if(!this.isDestroyed&&this._processedNode!==e){try{var i;null===(i=this.sourceNode)||void 0===i||i.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=g_(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),__(this.outputNode),this.volumeLevelAnalyser=new W_}startGetAudioBuffer(e){this.audioBufferNode||(this.audioBufferNode=this.context.createScriptProcessor(e),this.outputNode.connect(this.audioBufferNode),this.audioBufferNode.connect(this.context.destination),this.audioBufferNode.onaudioprocess=e=>{this.emit(To.ON_AUDIO_BUFFER,k_(e))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!O_().webAudioMediaStreamDest)throw new n(o.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((()=>{f_.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;g()||v()?"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 r=!1;for(let e=0;e<i.length;e++)0!==i[e]&&(r=!0);return r?(this.isNoAudioInput=!1,!0):(await O(200),await this.checkHasAudioInput(e?e+1:1)&&r)}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 z_ extends K_{get isFreeze(){return!1}constructor(e,t,i){var r;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(ue.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 ue.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>ue.info("resume success"))),ue.debug("rebuild web audio because of ios 12 bugs"),this.disconnect();const e=this.track;this.track=this.track.clone(),this.isCurrentTrackCloned?e.stop():this.isCurrentTrackCloned=!0;const t=new MediaStream([this.track]);this.sourceNode=this.context.createMediaStreamSource(t),__(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const i=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(i,this.context.currentTime),__(this.outputNode),this.emit(To.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=t,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()},"audio"!==e.kind)throw new n(o.UNEXPECTED_ERROR);this.track=e;const s=new MediaStream([this.track]);if(this.isRemoteTrack=!!t,this.sourceNode=this.context.createMediaStreamSource(s),__(this.sourceNode),i){const e=i.clone();e.enabled=!0,this.clonedTrack=e,ue.debug("create an unmuted track ".concat(e.id," from the original track ").concat(i.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));__(t),this.originVolumeLevelAnalyser=new W_,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=s;const a=m();t&&a.os===k.IOS&&Number(null===(r=a.osVersion)||void 0===r?void 0:r.split(".")[0])<15&&(f_.on(ge.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(e){this.sourceNode.disconnect(),this.track=e,this.isCurrentTrackCloned=!1;const t=new MediaStream([e]);this.sourceNode=this.context.createMediaStreamSource(t),__(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(To.UPDATE_SOURCE),this.audioElement.srcObject=t}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),f_.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),ue.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]));__(i),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(i)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function q_(e,t,i){const r=(e,t)=>e?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t,n={audio:!!i&&{mandatory:{chromeMediaSource:"desktop"}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e,maxHeight:r(t.height,1080),maxWidth:r(t.width,1920)}}};return t.frameRate&&"number"!=typeof t.frameRate?(n.video.mandatory.maxFrameRate=t.frameRate.max,n.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(n.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(n)}async function Y_(e,t){const i=await J_(e.mediaSource),{sourceId:r,audio:n}=await D(i,t);return await q_(r,e,n)}async function J_(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);const i=C();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new n(o.ELECTRON_IS_NULL);let r=null;try{var s;r=(null===(s=i.desktopCapturer)||void 0===s?void 0:s.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){r=null}r&&r.then||(r=new s_(((e,r)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?r(t):e(i)}))})));try{return await r}catch(e){throw new n(o.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}function Q_(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}const X_=new h("safari");let Z_=!1,$_=!1;async function ey(e,t){let i=0,r=null;for(;i<2;)try{r=await ty(e,t,i>0);break}catch(e){if(e instanceof n)throw ue.error("[".concat(t,"] ").concat(e.toString())),e;const r=iy(e.name||e.code||e,e.message);if(r.code===o.MEDIA_OPTION_INVALID){ue.debug("[".concat(t,"] detect media option invalid, retry")),i+=1,await O(500);continue}throw ue.error("[".concat(t,"] ").concat(r.toString())),r}if(!r)throw new n(o.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return r}async function ty(e,t,i){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new n(o.NOT_SUPPORTED,"can not find getUserMedia");i&&(e.video&&(delete e.video.width,delete e.video.height),e.screen&&(delete e.screen.width,delete e.screen.height));const r=O_(),s=new MediaStream;if(e.audioSource&&s.addTrack(e.audioSource),e.videoSource&&s.addTrack(e.videoSource),!e.audio&&!e.video&&!e.screen)return ue.debug("Using Video Source/ Audio Source"),s;if(e.screen)if(N())if(e.screen.sourceId){ry(s,await q_(e.screen.sourceId,e.screen,e.screenAudio))}else{ry(s,await Y_(e.screen,e.screenAudio))}else if(R()&&e.screen.extensionId&&e.screen.mandatory){if(!r.getStreamFromExtension)throw new n(o.NOT_SUPPORTED,"This browser does not support screen sharing");ue.debug("[".concat(t,'] Screen access on chrome stable, looking for extension"'));const i=await(c=e.screen.extensionId,d=t,new s_(((e,t)=>{try{chrome.runtime.sendMessage(c,{getStream:!0},(i=>{if(!i||!i.streamId)return ue.error("[".concat(d,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new n(o.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){ue.error("[".concat(d,"] AgoraRTC screensharing plugin is not accessible(").concat(c,")"),e.toString()),t(new n(o.CHROME_PLUGIN_NOT_INSTALL))}})));e.screen.mandatory.chromeMediaSourceId=i;ry(s,await navigator.mediaDevices.getUserMedia({video:{mandatory:e.screen.mandatory}}))}else if(r.getDisplayMedia){var a;e.screen.mediaSource&&ho(e.screen.mediaSource);const i={width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate,displaySurface:null!==(a=e.screen.displaySurface)&&void 0!==a?a:"screen"===e.screen.mediaSource?"monitor":e.screen.mediaSource},{selfBrowserSurface:r,surfaceSwitching:n,systemAudio:o}=e.screen,c={selfBrowserSurface:r,surfaceSwitching:n,systemAudio:o};!r&&delete c.selfBrowserSurface,!n&&delete c.surfaceSwitching,!o&&delete c.systemAudio,ue.debug("[".concat(t,"] getDisplayMedia:"),JSON.stringify({video:i,audio:!!e.screenAudio,controls:c}));const d=await navigator.mediaDevices.getDisplayMedia(function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Q_(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Q_(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({video:i,audio:!!e.screenAudio},c));ry(s,d)}else{if(!A())throw ue.error("[".concat(t,"] This browser does not support screenSharing")),new n(o.NOT_SUPPORTED,"This browser does not support screen sharing");{e.screen.mediaSource&&ho(e.screen.mediaSource);const i={video:{mediaSource:e.screen.mediaSource,width:e.screen.width,height:e.screen.height,frameRate:e.screen.frameRate}};ue.debug("[".concat(t,"] getUserMedia: ").concat(JSON.stringify(i)));ry(s,await navigator.mediaDevices.getUserMedia(i))}}var c,d;if(!e.video&&!e.audio)return s;let u={video:e.video,audio:e.audio},h=f("MEDIA_DEVICE_CONSTRAINTS");if(h)try{"string"==typeof h&&(h=JSON.parse(h)),u=M(u,h)}catch(e){}ue.debug("[".concat(t,"] GetUserMedia"),JSON.stringify(u)),m();let l,p=null;(I()||g()||w())&&(p=await X_.lock());try{l=await navigator.mediaDevices.getUserMedia(u)}catch(e){throw p&&p(),e}return u.audio&&(Z_=!0),u.video&&($_=!0),ry(s,l),p&&p(),s}function iy(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new n(o.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new n(o.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new n(o.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new n(o.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new n(o.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new n(o.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return ue.error("getUserMedia unexpected error",e),new n(o.UNEXPECTED_ERROR,"".concat(e,": ").concat(t))}}function ry(e,t){const i=e.getVideoTracks()[0],r=e.getAudioTracks()[0],n=t.getVideoTracks()[0],o=t.getAudioTracks()[0];o&&(r&&e.removeTrack(r),e.addTrack(o)),n&&(i&&e.removeTrack(i),e.addTrack(n))}class ny extends a{get state(){return this._state}set state(e){e!==this._state&&(this.emit(No.STATE_CHANGE,e),this._state=e)}constructor(){super(),this._state=Co.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((()=>{(f("ENUMERATE_DEVICES_INTERVAL")||(P()||L())&&y())&&this.updateDevicesInfo()}),f("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>ue.error(e.toString())))}async enumerateDevices(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices){return new n(o.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const r=await navigator.mediaDevices.enumerateDevices(),s=this.checkMediaDeviceInfoIsOk(r);let a=!this.isAccessMicrophonePermission&&e,c=!this.isAccessCameraPermission&&t;s.audio&&(a=!1),s.video&&(c=!1);let d=null,u=null,h=null;if(!i&&(a||c)){if(X_.isLocked){ue.debug("[device manager] wait GUM lock");(await X_.lock())(),ue.debug("[device manager] GUM unlock")}if(Z_&&(a=!1,this.isAccessMicrophonePermission=!0),$_&&(c=!1,this.isAccessCameraPermission=!0),ue.debug("[device manager] check media device permissions",e,t,a,c),a&&c){try{h=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===o.PERMISSION_DENIED)throw t;ue.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(a){try{d=await navigator.mediaDevices.getUserMedia({audio:e})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===o.PERMISSION_DENIED)throw t;ue.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(c){try{u=await navigator.mediaDevices.getUserMedia({video:t})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===o.PERMISSION_DENIED)throw t;ue.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}ue.debug("[device manager] mic permission",e,"cam permission",t)}try{const e=await navigator.mediaDevices.enumerateDevices();return d&&d.getTracks().forEach((e=>e.stop())),u&&u.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),d=null,u=null,h=null,e}catch(e){d&&d.getTracks().forEach((e=>e.stop())),u&&u.getTracks().forEach((e=>e.stop())),h&&h.getTracks().forEach((e=>e.stop())),d=null,u=null,h=null;return new n(o.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((i=>{i.device.label===e&&(t=i.device.deviceId)})),t}async getDeviceById(e){const t=(await this.enumerateDevices(!0,!0,!0)).find((t=>t.deviceId===e));if(!t)throw new n(o.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=Co.INITING;try{await this.updateDevicesInfo(),this.state=Co.INITEND}catch(e){if(ue.warning("Device Detection functionality cannot start properly.",e.toString()),this.state=Co.IDLE,!x()){new n(o.WEB_SECURITY_RESTRICT,"Your context is limited by web security, please try using https protocol or localhost.").throw()}throw e}}async updateDevicesInfo(){const e=await this.enumerateDevices(!0,!0,!0),t=Date.now(),i=[];if(e[0]&&e[0].label&&!1===this.checkdeviceMatched){this.checkdeviceMatched=!0;const t=e.find((e=>"audioinput"===e.kind&&"default"===e.deviceId)),i=e.find((e=>"audiooutput"===e.kind&&"default"===e.deviceId));t&&i?i.groupId===t.groupId?ue.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is the same group")):ue.warning("[device-check] default input ".concat(t.label," and output ").concat(i.label," is not the same group")):ue.debug("[device-check] default input or output not found")}const r=this.checkMediaDeviceInfoIsOk(e);if(e.forEach((e=>{if(!e.deviceId)return;const r=this.deviceInfoMap.get("".concat(e.kind,"_").concat(e.deviceId));if("ACTIVE"!==(r?r.state:"INACTIVE")){const r={initAt:t,updateAt:t,device:e,state:"ACTIVE"};this.deviceInfoMap.set("".concat(e.kind,"_").concat(e.deviceId),r),i.push(r)}r&&(r.updateAt=t)})),this.deviceInfoMap.forEach(((e,r)=>{"ACTIVE"===e.state&&e.updateAt!==t&&(e.state="INACTIVE",i.push(e))})),this.state!==Co.INITEND)return r.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),void(r.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0));i.forEach((e=>{switch(e.device.kind){case"audioinput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(No.RECORDING_DEVICE_CHANGED,e);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(No.CAMERA_DEVICE_CHANGED,e);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(No.PLAYOUT_DEVICE_CHANGED,e)}})),r.audio&&(this.lastAccessMicrophonePermission=!0,this.isAccessMicrophonePermission=!0),r.video&&(this.lastAccessCameraPermission=!0,this.isAccessCameraPermission=!0)}checkMediaDeviceInfoIsOk(e){const t=e.filter((e=>"audioinput"===e.kind)),i=e.filter((e=>"videoinput"===e.kind)),r={audio:!1,video:!1};for(const e of t)if(e.label&&e.deviceId){r.audio=!0;break}for(const e of i)if(e.label&&e.deviceId){r.video=!0;break}return r}}const oy=new ny;let sy=!1;const ay=new class extends a{constructor(){super(...arguments),this.onAutoplayFailed=void 0,this.onAudioAutoplayFailed=void 0}};function cy(){if(m(),!sy){const e=t=>{t.preventDefault(),sy=!1,U()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};sy=!0,U()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),ue.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),ay.onAutoplayFailed?ay.onAutoplayFailed():ay.onAudioAutoplayFailed?ue.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 ."):ue.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 ."),ay.emit("autoplay-failed")}}function dy(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function uy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?dy(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):dy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function hy(e,t,i,r){if(!e)return;const n=de.getBaseInfoBySessionId(e);if(!n)return;const o=n.info,s=Date.now(),a=uy(uy({},o),{},{vid:void 0===o.vid?0:Number(o.vid),lts:s,elapse:s-n.startTime,cbRegistered:ay.onAutoplayFailed||ay.onAudioAutoplayFailed?1:-1,errorMsg:i,mediaType:t,trackId:r,extend:void 0});de.send({type:he.AUTOPLAY_FAILED,data:a},!0)}const ly=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],py=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[t,i]=e;const r=this.elementStateMap.get(t),n=i.srcObject.getAudioTracks()[0];V()?n&&"live"===n.readyState&&"running"===f_.curState&&(ue.debug("auto resume after interruption for iOS 15"),i.pause(),i.play()):r&&"paused"===r&&n&&"live"===n.readyState&&"running"===f_.curState&&(ue.debug("auto resume after interruption for iOS"),i.play())}))},this.autoResumeAfterInterruptionOnIOS15_16=()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[t,i]=e;const r=i.srcObject.getAudioTracks()[0];r&&"live"===r.readyState&&(ue.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))},this.autoResumeAudioElement(),f_.on(ge.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),f_.on(ge.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),f_.on(ge.STATE_CHANGE,(()=>{g()&&"suspended"===f_.prevState&&"running"===f_.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 n(o.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(e,t,i,r){if(this.elementMap.has(t))return;const n=document.createElement("audio");n.autoplay=!0,n.srcObject=new MediaStream([e]),this.bindAudioElementEvents(t,n),this.elementMap.set(t,n),this.elementStateMap.set(t,Ro.INIT),this.setVolume(t,i);const o=this.sinkIdMap.get(t);if(o)try{n.setSinkId(o).catch((e=>{ue.warning("[".concat(t,"] set sink id failed"),e.toString())}))}catch(e){ue.warning("[".concat(t,"] set sink id failed"),e.toString())}const s=n.play();s&&s.then&&s.catch((e=>{r&&hy(r,"audio",e.message,t),ue.warning("audio element play warning",e.toString()),this.elementMap.has(t)&&"NotAllowedError"===e.name&&(ue.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(n),T((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),cy()})))}))}updateTrack(e,t){const i=this.elementMap.get(e);i&&(i.srcObject=new MediaStream([t]))}isPlaying(e){return this.elementMap.has(e)&&"playing"===this.elementStateMap.get(e)}setVolume(e,t){const i=this.elementMap.get(e);i&&(t=Math.max(0,Math.min(100,t)),i.volume=t/100)}stop(e){const t=this.elementMap.get(e);if(this.sinkIdMap.delete(e),!t)return;const i=this.elementsNeedToResume.indexOf(t);this.elementsNeedToResume.splice(i,1),t.srcObject=null,t.remove(),this.elementMap.delete(e),this.elementStateMap.delete(e)}bindAudioElementEvents(e,t){ly.forEach((i=>{t.addEventListener(i,(i=>{const r=this.elementStateMap.get(e),n="pause"===i.type?"paused":i.type;if(ue.debug("[".concat(e,"] audio-element-status change ").concat(r," => ").concat(n)),"error"===i.type){const i=null==t?void 0:t.error;i&&ue.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=>{ue.debug("Auto resume audio element success")})).catch((e=>{ue.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};j().then((()=>{U()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function fy(){return function(e,t,i){const r=i.value;return"function"==typeof r&&(i.value=function(){this._isClosed&&new n(o.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",ue);for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const s=r.apply(this,t);return s instanceof s_?new s_(((e,t)=>{s.then(e).catch(t)})):s}),i}}var my=hn("Array").values,gy=wn,vy=fi,_y=we,yy=my,Ty=Array.prototype,Ey={DOMTokenList:!0,NodeList:!0},by=_e((function(e){var t=e.values;return e===Ty||_y(Ty,e)&&t===Ty.values||vy(Ey,gy(e))?yy:t}));function Sy(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function ky(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Sy(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Sy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class Iy extends a{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 n(o.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new n(o.NOT_SUPPORTED,"VideoProcessor cannot unpipe to any other Processor")}enable(){}disable(){}updateInput(e){if(e.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).");e.track&&e.track!==this.inputTrack&&(this.videoContext.chained=!0,this.inputTrack=e.track,this.emit(Oo.ON_TRACK,e.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(Oo.ON_TRACK,void 0)}}class wy extends a{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 B(this,Do.REQUEST_CONSTRAINTS)}async requestApplyConstraints(e,t){var i;return ue.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),l(this,Do.REQUEST_UPDATE_CONSTRAINTS,Array.from(by(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return ue.info("processor ".concat(e.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(e),l(this,Do.REQUEST_UPDATE_CONSTRAINTS,Array.from(by(t=this.constraintsMap).call(t)))}registerStats(e,t,i){this.statsRegistry.find((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:i})}unregisterStats(e,t){const i=this.statsRegistry.findIndex((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t));-1!==i&&this.statsRegistry.splice(i,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:i,type:r,cb:s}of this.statsRegistry)try{const n=s();e.push({processorID:t,processorName:i,type:r,stats:n})}catch(e){ue.error(new n(o.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 i=t();i instanceof s_&&(i=await i),e.push(ky(ky({},i),{},{direction:this.direction}))}catch(e){ue.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class Ay extends a{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 n(o.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new n(o.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(Oo.ON_TRACK,void 0),this.emit(Oo.ON_NODE,void 0)}updateInput(e){if(e.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).");e.track&&this.inputTrack!==e.track&&(this.audioProcessorContext.chained=!0,this.inputTrack=e.track,this.emit(Oo.ON_TRACK,this.inputTrack)),e.node&&this.inputNode!==e.node&&(this.audioProcessorContext.chained=!0,this.inputNode=e.node,this.emit(Oo.ON_NODE,this.inputNode))}}class Oy extends a{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t,i){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=i}async getConstraints(){return B(this,Do.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(e,t){var i;return ue.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),l(this,Do.REQUEST_UPDATE_CONSTRAINTS,Array.from(by(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return this.constraintsMap.delete(e),l(this,Do.REQUEST_UPDATE_CONSTRAINTS,Array.from(by(t=this.constraintsMap).call(t)))}registerStats(e,t,i){this.statsRegistry.find((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t))||this.statsRegistry.push({processorName:e.name,processorID:e.ID,type:t,cb:i})}unregisterStats(e,t){const i=this.statsRegistry.findIndex((i=>i.processorID===e.ID&&i.processorName===e.name&&i.type===t));-1!==i&&this.statsRegistry.splice(i,1)}gatherStats(){const e=[];for(const{processorID:t,processorName:i,type:r,cb:s}of this.statsRegistry)try{const n=s();e.push({processorID:t,processorName:i,type:r,stats:n})}catch(e){ue.error(new n(o.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 i=t();i instanceof s_&&(i=await i),e.push(ky(ky({},i),{},{direction:this.direction}))}catch(e){ue.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class Dy extends a{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 Cy}setVolume(){}createOutputTrack(){throw new n(o.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 Cy{disconnect(){}connect(){}}let Ny=null;class Ry{constructor(){this.state="open",this.trigger=void 0,this.tasks=[],ue.debug("[macro-task-queue] is created."),this.trigger=window.setTimeout((()=>{this.state="closed",ue.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,ue.debug("[macro-task-queue] is closed.")}))}enqueue(e,t){"closed"!==this.state&&(this.tasks.push({key:e,func:t}),ue.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);ue.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,ue.debug("[macro-task-queue] is closed."))}}function My(e){return function(t,i,r){var n;const o=null!==(n=r.value)&&void 0!==n?n:r.get,s=function(){Ny&&"open"===Ny.state&&Ny.runTask(e);for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return null==o?void 0:o.apply(this,...i)};return r.value?r.value=s:r.get=s,r}}function Py(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function Ly(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Py(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Py(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class xy extends u_{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?py.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"LocalAudioTrack"}constructor(e,t,i,r,n){super(e,i),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=t,this._getOriginVolumeLevel=!!r;const o=()=>{this.processorContext=new Oy(this._source.context,this.getTrackId(),"local"),this.processorDestination=new Ay(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(To.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))},s=n&&I()&&!v_();if(f("DISABLE_WEBAUDIO")?(this._source=new Dy,this._useAudioElement=!0,this._bypassWebAudio=!0):s?this._source=new Dy:(this._source=new z_(e,!1,this._getOriginVolumeLevel?e:void 0),f("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0)),o(),!f("DISABLE_WEBAUDIO")&&s){(Ny||(Ny=new Ry),Ny).enqueue("INIT_WEBAUDIO",(()=>{this._source=new z_(e,!1,this._getOriginVolumeLevel?e:void 0),f("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0),o(),this.emit(Eo.UPDATE_TRACK_SOURCE)}))}}setVolume(e){t(e,"volume",0,1e3),this._volume=e,this._source.setVolume(e/100),this._useAudioElement&&py.setVolume(this.getTrackId(),e);try{if(this._bypassWebAudio)return void ue.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const e=this._source.createOutputTrack();this._mediaStreamTrack!==e&&(this._mediaStreamTrack=e,l(this,lo.NEED_REPLACE_TRACK,this).then((()=>{ue.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{ue.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 n(o.NOT_SUPPORTED,"your browser does not support setting the audio output device");await py.setSinkID(this.getTrackId(),e)}async setEnabled(e,t,i){return this._setEnabled(e,t,i)}async _setEnabled(e,t,i){if(!i){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(ue.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){this._originMediaStreamTrack.enabled=!0;try{i||(this._enabled=!0),await l(this,lo.NEED_ENABLE_TRACK,this),ue.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(e," success"))}catch(e){throw i||(this._enabled=!1),ue.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,i||(this._enabled=!1);try{await l(this,lo.NEED_DISABLE_TRACK,this)}catch(e){throw i||(this._enabled=!0),ue.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}}}async setMuted(e){e!==this._muted&&(this.stateCheck("muted",e),this._muted=e,this._originMediaStreamTrack.enabled=!e,ue.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await l(this,lo.NEED_MUTE_TRACK,this):await l(this,lo.NEED_UNMUTE_TRACK,this))}getStats(){H((()=>{ue.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const e=G(this,lo.GET_STATS);return e||Ly({},So)}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(To.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(To.ON_AUDIO_BUFFER),this._source.on(To.ON_AUDIO_BUFFER,(t=>e(t)))}play(){ue.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(ue.debug("[".concat(this.getTrackId(),"] start audio playback in element")),py.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){ue.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?py.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];ue.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&py.updateTrack(this.getTrackId(),this._mediaStreamTrack)}async _updateOriginMediaStreamTrack(e,t){this._originMediaStreamTrack!==e&&(this._originMediaStreamTrack&&(this._originMediaStreamTrack.removeEventListener("ended",this._handleTrackEnded),t&&this._originMediaStreamTrack.stop()),e.addEventListener("ended",this._handleTrackEnded),this._originMediaStreamTrack=e,this._muted&&(this._originMediaStreamTrack.enabled=!1),this.processor&&this.processor.updateInput({track:e,context:this.processorContext}),this._mediaStreamTrack!==this._source.outputTrack?(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await l(this,lo.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(e))}renewMediaStreamTrack(e){return s_.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new n(o.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new n(o.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(Oo.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e),await l(this,lo.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await l(this,lo.NEED_REPLACE_TRACK,this))})),this.processorDestination.on(Oo.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(Oo.ON_TRACK),this.processorDestination.removeAllListeners(Oo.ON_NODE)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Do.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Do.REQUEST_CONSTRAINTS)}}a_([My("INIT_WEBAUDIO"),c_("design:type",Object),c_("design:paramtypes",[Object])],xy.prototype,"_source",null),a_([My("INIT_WEBAUDIO"),c_("design:type",Oy),c_("design:paramtypes",[Oy])],xy.prototype,"processorContext",null),a_([My("INIT_WEBAUDIO"),c_("design:type",Ay),c_("design:paramtypes",[Ay])],xy.prototype,"processorDestination",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),c_("design:type",Function),c_("design:paramtypes",[Number]),c_("design:returntype",void 0)],xy.prototype,"setVolume",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[String]),c_("design:returntype",s_)],xy.prototype,"setPlaybackDevice",null),a_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean,Object,Boolean]),c_("design:returntype",s_)],xy.prototype,"setEnabled",null),a_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean]),c_("design:returntype",s_)],xy.prototype,"setMuted",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",Object)],xy.prototype,"getStats",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[Object,Number]),c_("design:returntype",void 0)],xy.prototype,"setAudioFrameCallback",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],xy.prototype,"play",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],xy.prototype,"stop",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],xy.prototype,"close",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",Object)],xy.prototype,"pipe",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],xy.prototype,"unpipe",null);class Uy extends xy{get __className__(){return"MicrophoneAudioTrack"}constructor(e,t,i,r){super(e,t.encoderConfig?io(t.encoderConfig):{},r,f("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=t,this._constraints=i,this._originalConstraints=i,this._deviceName=e.label,"boolean"==typeof t.bypassWebAudio&&(this._bypassWebAudio=t.bypassWebAudio),(V()||W())&&f_.bindInterruptDetectorTrack(this),this.on(Eo.UPDATE_TRACK_SOURCE,(()=>{this.bindProcessorContextEvents()})),v_()&&this.bindProcessorContextEvents()}async setDevice(e){if(ue.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await oy.getDeviceById(e),i={};i.audio=Ly({},this._constraints),i.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let r=null;try{r=await ey(i,this.getTrackId())}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await ey({audio:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(r.getAudioTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(r.getAudioTracks()[0],!1),this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await oy.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(e,t,i){if(t)return ue.debug("[".concat(this.getTrackId(),"] setEnabled false (do not close microphone)")),await super._setEnabled(e);if(!i){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(ue.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){var r;this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop(),null===(r=this._source.clonedTrack)||void 0===r||r.stop(),i||(this._enabled=!1);try{await l(this,lo.NEED_DISABLE_TRACK,this)}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const n=Ly({},this._constraints),o=oy.searchDeviceIdByName(this._deviceName);o&&!n.deviceId&&(n.deviceId=o);try{i||(this._enabled=!0);const e=await ey({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!1),await l(this,lo.NEED_ENABLE_TRACK,this)}catch(e){throw i||(this._enabled=!1),ue.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(V()||W())&&f_.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((g()||v())&&this._enabled&&!this._isClosed&&f_.duringInterruption){const e=async()=>{f_.off(ge.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(ue.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};f_.on(ge.IOS_INTERRUPTION_END,e)}else ue.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(_o.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=oy.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId=i),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await ey({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(){this.processorContext.on(Do.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,i)=>{try{const i=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(i),t()}catch(e){i(e)}})),this.processorContext.on(Do.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[String]),c_("design:returntype",s_)],Uy.prototype,"setDevice",null),a_([F("MicrophoneAudioTrack","_enabledMutex"),le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean,Boolean,Boolean]),c_("design:returntype",s_)],Uy.prototype,"setEnabled",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],Uy.prototype,"close",null);class Vy extends xy{get __className__(){return"BufferSourceAudioTrack"}constructor(e,t,i,r){super(t.createOutputTrack(),i,r),this.source=void 0,this._bufferSource=void 0,this.source=e,this._bufferSource=t,this._bufferSource.on(To.AUDIO_SOURCE_STATE_CHANGE,(e=>{this.safeEmit(_o.SOURCE_STATE_CHANGE,e)}));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(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}a_([le({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",void 0)],Vy.prototype,"startProcessAudioBuffer",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],Vy.prototype,"pauseProcessAudioBuffer",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Number]),c_("design:returntype",void 0)],Vy.prototype,"seekAudioBuffer",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],Vy.prototype,"resumeProcessAudioBuffer",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],Vy.prototype,"stopProcessAudioBuffer",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],Vy.prototype,"close",null),a_([le({argsMap:e=>[e.getTrackId()]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Number]),c_("design:returntype",void 0)],Vy.prototype,"setAudioBufferPlaybackSpeed",null);class jy extends xy{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=g_().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,c(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)?(ue.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):ue.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){ue.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}p(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(e){this._rtpTransceiver!==e&&(this._rtpTransceiver=e,this.trackList.forEach((t=>{t instanceof jy?t.emit(vo.TRANSCEIVER_UPDATED,e):t._updateRtpTransceiver(e)})))}}function By(e){const t={};e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId});const i=Zn(e.encoderConfig);return null!=i.width&&(t.width=i.width),null!=i.height&&(t.height=i.height),!K()&&i.frameRate&&(t.frameRate=i.frameRate),z()&&"object"==typeof t.frameRate&&(t.frameRate.max=60),A()&&(t.frameRate={ideal:30,max:30}),t}function Fy(e){const t={};e.screenSourceType&&(t.mediaSource=e.screenSourceType),e.extensionId&&R()&&(t.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:n,surfaceSwitching:o,systemAudio:s}=e;(E(107)||q(107)||Y(93))&&(i&&(r(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),n?(r(n,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=n):t.selfBrowserSurface="include",o&&(r(o,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=o)),(E(105)||q(105)||Y(91))&&s&&(r(s,"systemAudio",["exclude","include"]),t.systemAudio=s),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const a=e.encoderConfig?$n(e.encoderConfig):null;return t.mandatory={chromeMediaSource:"desktop",maxWidth:a?a.width:void 0,maxHeight:a?a.height:void 0},a&&(a.frameRate&&("number"==typeof a.frameRate?(t.mandatory.maxFrameRate=a.frameRate,t.mandatory.minFrameRate=a.frameRate):(t.mandatory.maxFrameRate=a.frameRate.max||a.frameRate.ideal||a.frameRate.exact||void 0,t.mandatory.minFrameRate=a.frameRate.min||a.frameRate.ideal||a.frameRate.exact||void 0),t.frameRate=a.frameRate),a.width&&(t.width=a.width),a.height&&(t.height=a.height)),t}function Hy(e){const t={};if(K()||(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()&&e.ANS&&(t.googHighpassFilter=e.ANS))),e.encoderConfig){const i=io(e.encoderConfig);t.channelCount=i.stereo?2:1,t.sampleRate=i.sampleRate,t.sampleSize=i.sampleSize}return e.microphoneId&&(t.deviceId={exact:e.microphoneId}),P()&&(t.sampleRate=void 0),t}class Gy extends K_{set currentState(e){e!==this._currentState&&(this._currentState=e,this.safeEmit(To.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):ue.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 Wy=new Map;const Ky=e=>{const t=document.createElement("canvas");return t.width=2,t.height=2,new s_(((i,r)=>{t.toBlob((async e=>{if(t.remove(),e){const r=await zy(e);i({buffer:r,width:t.width,height:t.height})}else r(new n(o.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},zy=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};const qy=new class extends a{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(),ue.debug("document visibility went ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}};function Yy(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function Jy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Yy(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Yy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class Qy{get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(ue.debug("[".concat(this.trackId,"] video-element-status change ").concat(this._videoElementStatus," => ").concat(e)),this._videoElementStatus=e)}constructor(e){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=Ro.NONE,this.isGettingVideoDimensions=!1,this.startGetVideoDimensions=()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return ue.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"===f_.curState&&(ue.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(Q())),X()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.handleVideoEvents=e=>{switch(e.type){case"play":case"playing":this.startGetVideoDimensions(),this.videoElementStatus=Ro.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=Ro.CANPLAY;break;case"stalled":this.videoElementStatus=Ro.STALLED;break;case"suspend":this.videoElementStatus=Ro.SUSPEND;break;case"pause":this.videoElementStatus=Ro.PAUSED,g()||v()||I()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(ue.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=Ro.WAITING;break;case"abort":this.videoElementStatus=Ro.ABORT;break;case"ended":this.videoElementStatus=Ro.ENDED;break;case"emptied":this.videoElementStatus=Ro.EMPTIED;break;case"error":{this.videoElementStatus=Ro.ERROR;const e=this.videoElement.error;e&&ue.error("[".concat(this.trackId,"] media error, code: ").concat(e.code,", message: ").concat(e.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,qy.lastVisibleTime<qy.lastHiddenTime||i<qy.lastHiddenTime||i<qy.lastVisibleTime)return;for(t>f("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&&(ue.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(Q())),X()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))},this.trackId=e.trackId,this.config=e,e.element instanceof HTMLVideoElement?this.videoElement=e.element:this.videoElement=document.createElement("video"),f_.on(ge.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),f_.on(ge.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&&hy(e,"video",t.message,this.trackId),"NotAllowedError"===t.name?(ue.warning("detected video element autoplay failed",t),this.autoplayFailed=!0,this.handleAutoPlayFailed()):ue.warning("[".concat(this.trackId,"] play warning: "),t)}));const i=m();if(("Safari"===i.name&&15===Number(i.version)||V())&&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 ue.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 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 r=i.getContext("2d");return r?(r.drawImage(this.videoElement,0,0,i.width,i.height),new s_(((r,s)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await zy(e);r({buffer:t,width:i.width,height:i.height})}else s(new n(o.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await Ky(e)}destroy(){f_.off(ge.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),f_.off(ge.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[]}initVideoElement(){if(this.videoElementStatus=Ro.INIT,!this.videoElementCheckInterval&&(Xy.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{Z(this.videoElement)||(this.videoElementStatus=Ro.DESTROYED)}),1e3),f("ENABLE_VIDEO_FRAME_CALLBACK"))){var e,t;let i;const r=(e,t)=>{if(this.videoElementStatus===Ro.PLAYING){if(i){const e=t.presentationTime-i.presentationTime;e>f("VIDEO_FREEZE_DURATION")&&qy.lastVisibleTime>=qy.lastHiddenTime&&i.timestamp>qy.lastVisibleTime&&i.timestamp>qy.lastHiddenTime&&(this.renderFreezeAccTime+=e)}i=Jy(Jy({},t),{},{timestamp:e})}var n,o;f("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(n=(o=this.videoElement).requestVideoFrameCallback)||void 0===n||n.call(o,r))};null===(e=(t=this.videoElement).requestVideoFrameCallback)||void 0===e||e.call(t,r)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),P()&&(this.videoElement.poster="noposter");const i=m();if("Safari"===i.name&&15===Number(i.version)||V()||!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,A()&&this.videoElement.load())}else this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,A()&&this.videoElement.load();const r=this.videoElement.play();void 0!==r&&r.catch((e=>{ue.debug("[".concat(this.trackId,"] playback interrupted"),e.toString())}))}resetVideoElement(){Xy.forEach((e=>{this.videoElement&&this.videoElement.removeEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval&&(window.clearInterval(this.videoElementCheckInterval),this.videoElementCheckInterval=void 0),this.videoElementStatus=Ro.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{ue.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{ue.error(e)})),this.autoplayFailed=!1,U()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};U()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),cy()}}const Xy=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class Zy extends Qy{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 i=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,i):await Ky(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",f("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 $y(e){return new s_(((t,i)=>{let r=!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 o=g()?"canplay":"playing";n.addEventListener(o,(()=>{const e=n.videoWidth,i=n.videoHeight;!e&&A()||(r=!0,n.srcObject=null,n.remove(),t([e,i]))})),n.srcObject=new MediaStream([e]),n.play().catch($),setTimeout((()=>{r||(n.srcObject=null,n.remove(),t([n.videoWidth,n.videoHeight]))}),4e3)}))}function eT(e,t,i,r){let n;const o=200*Math.pow(i/15,.6)*Math.pow(e*t/640/360,.75),s=o;if("STANDARD_BITRATE"===r)n=4*o;else{if("COMPATIABLE_BITRATE"!==r)return;n=2*o}return[Math.floor(n),Math.floor(s)]}const tT=async(e,t,i)=>await(async(e,t,i)=>{const r=ee(te(""+t+i)).slice(0,16),n=r.slice(0,12),o=await window.crypto.subtle.importKey("raw",r,"AES-GCM",!0,["encrypt"]);return new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:n},o,e))})(e.buffer,t,i);function iT(e,t){if("VideoFrame"in window&&"TransformStream"in window&&O_().supportWebRTCInsertableStream){const i=new MediaStreamTrackProcessor(e),r=new MediaStreamTrackGenerator({kind:"video"});let n,o,s=Date.now();const a=()=>{c&&(clearInterval(c),c=void 0),n&&(n.close(),n=void 0),e.stop(),o=void 0,r.removeEventListener("ended",a)};let c=window.setInterval((()=>{if(o&&n&&Date.now()-s>(null!=t?t:1e3))try{"live"===r.readyState?o.enqueue(n.clone()):a()}catch(e){a()}}),null!=t?t:1e3);const d=new TransformStream({transform:(e,t)=>{"live"===r.readyState?(o=t,s=Date.now(),void 0===n?(n=e,t.enqueue(e.clone())):(t.enqueue(n),n=e)):e.close()}});return r.addEventListener("ended",a),i.readable.pipeThrough(d).pipeTo(r.writable),r}}function rT(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function nT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?rT(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):rT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class oT extends u_{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==Ro.PLAYING)}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(e,t,i,r,n,o){if(super(e,n),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,I()){const{width:t,height:i}=e.getSettings();this._videoWidth=t,this._videoHeight=i}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=t,this._scalabilityMode=i,this._optimizationMode=r,this._hints=o||[],-1===this._hints.indexOf(po.SCREEN_TRACK))this.updateBitrateFromProfile();else if(ie(_.CHROME,115)&&re()){const t=iT(e);t&&(ue.info("local screen video track begin to inject frame"),this._mediaStreamTrack=t)}t&&-1!==this._hints.indexOf(po.CUSTOM_TRACK)&&this.setEncoderConfiguration(t),this.processorContext=new wy(this.getTrackId(),"local"),this.processorDestination=new Iy(this.processorContext),this.bindProcessorDestinationEvents()}play(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e){const t=document.getElementById(e);t?e=t:(ue.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}ue.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=nT(nT(nT({},this._getDefaultPlayerConfig()),t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new Qy(i):this._player=new Zy(i),this._player.updateVideoTrack(this._mediaStreamTrack)),this._player.play(),this._videoVisibleTimer&&window.clearInterval(this._videoVisibleTimer),this._clearPreviousVideoVisibleStatus(),this._videoVisibleTimer=window.setInterval((()=>{try{const e=this.getVideoElementVisibleStatus();this.safeEmit(_o.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),f("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,ue.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(ue.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){this._originMediaStreamTrack.enabled=!1;try{await l(this,lo.NEED_DISABLE_TRACK,this)}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return t||(this._enabled=!1),void ue.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await l(this,lo.NEED_ENABLE_TRACK,this)}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] setEnabled to true success")),t||(this._enabled=!0)}async setMuted(e){e!==this._muted&&(this.stateCheck("muted",e),this._muted=e,this._originMediaStreamTrack.enabled=!e,ue.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await l(this,lo.NEED_MUTE_TRACK,this):await l(this,lo.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(e,t){if(!this._enabled)throw new n(o.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");if("720p_auto"===e?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),e=Zn(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:e.bitrateMin),e.width||e.height||e.frameRate){const t=By({encoderConfig:e});(I()||g()||v())&&(t.deviceId=void 0),ue.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(e),JSON.stringify(t));try{await this._originMediaStreamTrack.applyConstraints(t),this.updateMediaStreamTrackResolution()}catch(e){const t=new n(o.UNEXPECTED_ERROR,e.toString());throw ue.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=e,-1===this._hints.indexOf(po.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await l(this,lo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(ue)}}getStats(){H((()=>{ue.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const e=G(this,lo.GET_STATS);return e||nT({},ko)}async setBeautyEffect(e){ue.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 Ky(e)}async setBitrateLimit(e){if(ue.debug("[".concat(this.getTrackId(),"] set bitrate limit, ").concat(JSON.stringify(e))),e){this._forceBitrateLimit=e,this._encoderConfig&&(this._encoderConfig.bitrateMax?this._encoderConfig.bitrateMax=this._encoderConfig.bitrateMax<e.max_bitrate?this._encoderConfig.bitrateMax:e.max_bitrate:this._encoderConfig.bitrateMax=e.max_bitrate,this._encoderConfig.bitrateMin,this._encoderConfig.bitrateMin=e.min_bitrate);try{await l(this,lo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(ue)}}}async setOptimizationMode(e){if("motion"!==e&&"detail"!==e&&"balanced"!==e)return void ue.error(o.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const t=this._optimizationMode;try{this._optimizationMode=e,await l(this,lo.SET_OPTIMIZATION_MODE,this)}catch(e){throw this._optimizationMode=t,ue.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(e,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return ue.error(o.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,ue.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){$y(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch($)}_updatePlayerSource(){this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}_getDefaultPlayerConfig(){return{fit:"contain"}}async setSenderConfiguration(e){if(!this._enabled)throw new n(o.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");ue.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(e)),e=Zn(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:e.bitrateMin),this._encoderConfig=e,-1===this._hints.indexOf(po.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await l(this,lo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(ue)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:t,frameRate:i}=this.getMediaStreamTrackSettings();if(!e||!t||!i)return;const[r,n]=eT(e,t,i,f("BITRATE_ADAPTER_TYPE"))||[void 0,void 0];this._encoderConfig.bitrateMin||this._encoderConfig.bitrateMax||(this._encoderConfig.bitrateMin=n,this._encoderConfig.bitrateMax=r,ue.debug("[".concat(this.getTrackId(),"] update bitrate from profile, [w: ").concat(e,", h: ").concat(t,", fps: ").concat(i,"] => [brMax: ").concat(r,", brMin: ").concat(n,"]")))}getVideoElementVisibleStatus(){try{var e,t;const i=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),r={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==i?void 0:i.parentElement},{element:n,slot:o}=r;if(this.isPlaying&&n instanceof HTMLVideoElement&&o instanceof HTMLElement){const e=ne.checkOneElementVisible(n),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=de.reportApiInvoke(null,{tag:u.TRACER,name:d.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 n(o.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new n(o.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],i=this._encoderConfig;e&&(i=nT(nT({},i),Zn(e))),i=oe(i);const r=c(8,"track-video-cloned-"),n=new oT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,i,oe(this._scalabilityMode),this._optimizationMode,r,oe(this._hints));return e&&i&&n.setEncoderConfiguration(i),ue.debug("clone video track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(t)),n}async replaceTrack(e,t){if(!(e instanceof MediaStreamTrack))throw new n(o.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new n(o.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}startMonitorStats(){if(!I()&&!g())return;this._statsTimer&&window.clearInterval(this._statsTimer);let e=2,t=Jn[e];let i=-1;let r=Date.now();const n=e=>{e>2||e<0||(r=Date.now(),t=Jn[e],this.setSenderConfiguration(t))};this.isUseScaleResolutionDownBy=!0,this._statsTimer=window.setInterval((()=>{const o=this.getStats(),s=G(this,lo.GET_RTC_STATS);if(o.sendPackets>0&&s){-1===i&&(i=Date.now());const a=Date.now();if(a-i<1e3||a-r<f("PROFILE_SWITCH_INTERVAL"))return;const c=o.sendFrameRate,d=.6*t.frameRate,u=.9*t.frameRate;"number"==typeof c&&c>0&&c<d?e>0&&(e--,n(e),ue.debug("[".concat(this.getTrackId(),"] step down for fps ").concat(c,", switchProfile to ").concat(e))):s.OutgoingAvailableBandwidth<t.bitrateMin?e>0&&(e--,n(e),ue.debug("[".concat(this.getTrackId(),"] step down for OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", bitrateMin ").concat(t.bitrateMin,", switchProfile to ").concat(e))):"number"==typeof c&&c>u&&e<Jn.length-1&&s.OutgoingAvailableBandwidth>1.2*Jn[e+1].bitrateMin&&(e++,n(e),ue.debug("[".concat(this.getTrackId(),"] step up for fps ").concat(c,", OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", switchProfile to ").concat(e)))}}),f("CHECK_LOCAL_STATS_INTERVAL"))}bindProcessorDestinationEvents(){this.processorDestination.on(Oo.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(),await l(this,lo.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await l(this,lo.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(Oo.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Do.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Do.REQUEST_CONSTRAINTS)}}a_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Object,Object]),c_("design:returntype",void 0)],oT.prototype,"play",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],oT.prototype,"stop",null),a_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean,Boolean]),c_("design:returntype",s_)],oT.prototype,"setEnabled",null),a_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean]),c_("design:returntype",s_)],oT.prototype,"setMuted",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Object,Boolean]),c_("design:returntype",s_)],oT.prototype,"setEncoderConfiguration",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",Object)],oT.prototype,"getStats",null),a_([le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean,Object]),c_("design:returntype",s_)],oT.prototype,"setBeautyEffect",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",ImageData)],oT.prototype,"getCurrentFrameData",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[String,Number]),c_("design:returntype",s_)],oT.prototype,"getCurrentFrameImage",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",s_)],oT.prototype,"setBitrateLimit",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[String]),c_("design:returntype",s_)],oT.prototype,"setOptimizationMode",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",void 0)],oT.prototype,"setScalabiltyMode",null),a_([fy(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],oT.prototype,"updateMediaStreamTrackResolution",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",Object)],oT.prototype,"pipe",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],oT.prototype,"unpipe",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],oT.prototype,"close",null),a_([le({argsMap:(e,t,i)=>[e.getTrackId(),t.label,i]}),c_("design:type",Function),c_("design:paramtypes",[MediaStreamTrack,Boolean]),c_("design:returntype",s_)],oT.prototype,"replaceTrack",null),a_([le(),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],oT.prototype,"startMonitorStats",null);class sT extends oT{get __className__(){return"CameraVideoTrack"}constructor(e,t,i,r,n,o){super(e,Zn(t.encoderConfig),r,n,o),this._config=void 0,this._originalConstraints=void 0,this._constraints=void 0,this._enabled=!0,this._deviceName="default",this.tryResumeVideoForIOS15_16WeChat=async()=>{(V()||W())&&!se()&&ae()&&this._enabled&&!this._isClosed&&(ue.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS 15 device on WeChat.")),await this.renewMediaStreamTrack())},this._config=t,this._originalConstraints=i,this._constraints=i,this._deviceName=e.label,this._encoderConfig=Zn(this._config.encoderConfig),f_.on(ge.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),f_.on(ge.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(ue.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await oy.getDeviceById(e),i={};i.video=nT({},this._constraints),i.video.deviceId={exact:e},i.video.facingMode=void 0,this._originMediaStreamTrack.stop();let r=null;try{r=await ey(i,this.getTrackId())}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await ey({video:this._constraints},this.getTrackId()),await this._updateOriginMediaStreamTrack(r.getVideoTracks()[0],!1),e}await this._updateOriginMediaStreamTrack(r.getVideoTracks()[0],!1),this.updateMediaStreamTrackResolution(),this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await oy.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){ue.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:nT(nT({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await ey(t,this.getTrackId())}catch(t){throw ue.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await ey({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=nT({},t.video),ue.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(ue.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await ey({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await l(this,lo.NEED_ENABLE_TRACK,this)}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),ue.info("[".concat(this.getTrackId(),"] setEnabled to true success")),t||(this._enabled=!0)}else{this.isExternalTrack?this._originMediaStreamTrack.enabled=!1:(this._originMediaStreamTrack.onended=null,this._originMediaStreamTrack.stop()),t||(this._enabled=!1);try{await l(this,lo.NEED_DISABLE_TRACK,this)}catch(e){throw ue.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}ue.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(e,t){if(!this._enabled)throw new n(o.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");"720p_auto"===e?this.startMonitorStats():this._statsTimer&&(window.clearInterval(this._statsTimer),this._statsTimer=null),e=Zn(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate?this._forceBitrateLimit.max_bitrate:e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate?this._forceBitrateLimit.min_bitrate:e.bitrateMin);const i=ce(this._config);i.encoderConfig=e;const r=By(i);(I()||g()||v())&&(r.deviceId=void 0),ue.debug("[".concat(this.getTrackId(),"] setEncoderConfiguration applyConstraints"),JSON.stringify(e),JSON.stringify(r));try{await this._originMediaStreamTrack.applyConstraints(r),this.updateMediaStreamTrackResolution()}catch(e){const t=new n(o.UNEXPECTED_ERROR,e.toString());throw ue.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}this._config=i,this._constraints=r,this._originalConstraints=r,this._encoderConfig=e,-1===this._hints.indexOf(po.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await l(this,lo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(ue)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((g()||v())&&this._enabled&&!this._isClosed&&f_.duringInterruption){const e=async()=>{f_.off(ge.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(ue.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};f_.on(ge.IOS_INTERRUPTION_END,e)}else ue.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(_o.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=oy.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId={exact:i}),this._enabled){const e=await ey({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),f_.off(ge.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),f_.off(ge.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this._encoderConfig;e&&(i=nT(nT({},i),Zn(e))),i=oe(i);const r=c(8,"track-cam-cloned-"),n=new sT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,oe(nT(nT({},this._config),{},{encoderConfig:i})),oe(this._constraints),oe(this._scalabilityMode),this._optimizationMode,r);return e&&i&&n.setEncoderConfiguration(i),ue.debug("clone track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(t)),n}bindProcessorContextEvents(){this.processorContext.on(Do.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,i)=>{try{const i=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(i),t()}catch(e){i(e)}})),this.processorContext.on(Do.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}function aT(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function cT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?aT(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):aT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function dT(e){const t=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),i=new xy(e.mediaStreamTrack,e.encoderConfig?io(e.encoderConfig):{},c(8,"track-cus-"),!1,!0);return ue.info("create custom audio track success with config",e,"trackId",i.getTrackId()),t.onSuccess(i.getTrackId()),i}async function uT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_MIC_AUDIO_TRACK,options:[e]}),i=Hy(e),r=c(8,"track-mic-");let s=null;ue.info("start create microphone audio track with config",JSON.stringify(e),"trackId",r);try{s=(await ey({audio:i},r)).getAudioTracks()[0]||null}catch(e){throw t.onError(e),e}if(!s){const e=new n(o.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(ue)}const a=new Uy(s,e,i,r);return t.onSuccess(a.getTrackId()),ue.info("create microphone audio track success, trackId:",r),a}async function hT(e){var t;const{cacheOnlineFile:i,encoderConfig:r}=e;let{source:s}=e;const a={source:s instanceof AudioBuffer?"AudioBuffer":s instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":s,cacheOnlineFile:i,encoderConfig:r},h=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_BUFFER_AUDIO_TRACK,options:[a]});if(f("DISABLE_WEBAUDIO"))throw new n(o.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const l=c(8,"track-buf-");ue.info("start create buffer source audio track with config",JSON.stringify(a),"trackId",l);const p=s;if(!(s instanceof AudioBuffer))try{s=await async function(e,t){let i=null;if("string"==typeof e){const t=Wy.get(e);if(t)return ue.debug("use cached audio resource: ",e),t;try{i=(await J((()=>pe.get(e,{responseType:"arraybuffer"})),void 0,void 0,{maxRetryCount:3})).data}catch(e){throw new n(o.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new s_(((t,i)=>{const r=new FileReader;r.onload=e=>{e.target?t(e.target.result):i(new n(o.READ_LOCAL_AUDIO_FILE_ERROR))},r.onerror=()=>{i(new n(o.READ_LOCAL_AUDIO_FILE_ERROR))},r.readAsArrayBuffer(e)}));i=await t}const r=await y_(i);return"string"==typeof e&&t&&Wy.set(e,r),r}(s,i)}catch(e){return h.onError(e),e.throw(ue)}const m=new Gy(s),g=new Vy(p,m,r?io(r):{},l);return ue.info("create buffer source audio track success, trackId:",l),h.onSuccess(g.getTrackId()),g}function lT(e){const t=new jy;return e.forEach((e=>t.addAudioTrack(e))),t}function pT(e){const t=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_CUSTOM_VIDEO_TRACK,options:[e]}),i=new oT(e.mediaStreamTrack,{width:e.width,height:e.height,frameRate:e.frameRate,bitrateMax:e.bitrateMax,bitrateMin:e.bitrateMin},e.scalabiltyMode?eo(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,c(8,"track-cus-"),[po.CUSTOM_TRACK]);return t.onSuccess(i.getTrackId()),ue.info("create custom video track success with config",e,"trackId",i.getTrackId()),i}async function fT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_CAM_VIDEO_TRACK,options:[cT({},e)]}),i=By(e),r=c(8,"track-cam-");let s=null;const a="720p_auto"===e.encoderConfig;ue.info("start create camera video track with config",JSON.stringify(e),"trackId",r);try{s=(await ey({video:i},r)).getVideoTracks()[0]||null}catch(e){throw t.onError(e),e}if(!s){const e=new n(o.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(ue)}e.optimizationMode&&vT(r,s,e,Zn(e.encoderConfig));const h=new sT(s,e,i,e.scalabiltyMode?eo(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,r);return a&&h.startMonitorStats(),t.onSuccess(h.getTrackId()),ue.info("create camera video success, trackId:",r),h}async function mT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_MIC_AND_CAM_TRACKS,options:[e,t]}),r="720p_auto"===t.encoderConfig,s=By(t),a=Hy(e),h=c(8,"track-mic-"),l=c(8,"track-cam-");let p=null,f=null;ue.info("start create camera video track(".concat(l,") and microphone audio track(").concat(h,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await ey({audio:a,video:s},"".concat(h,"-").concat(l));p=e.getAudioTracks()[0],f=e.getVideoTracks()[0]}catch(e){throw i.onError(e),e}if(!p||!f){const e=new n(o.UNEXPECTED_ERROR,"can not find tracks in media stream");return i.onError(e),e.throw(ue)}t.optimizationMode&&vT(l,f,t,Zn(t.encoderConfig));const m=new Uy(p,e,a,h),g=new sT(f,t,s,t.scalabiltyMode?eo(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,l);return r&&g.startMonitorStats(),i.onSuccess([m.getTrackId(),g.getTrackId()]),ue.info("create camera video track(".concat(l,") and microphone audio track(").concat(h,") success")),[m,g]}async function gT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const i=de.reportApiInvoke(null,{tag:u.TRACER,name:d.CREATE_SCREEN_VIDEO_TRACK,options:[cT({},e),t]}),r="720p_auto"===e.encoderConfig;e.encoderConfig?"string"==typeof e.encoderConfig||e.encoderConfig.width&&e.encoderConfig.height||(e.encoderConfig.width={max:1920},e.encoderConfig.height={max:1080}):e.encoderConfig="1080p_2";const s=Fy(e),a=c(8,"track-scr-v-");let h=null,l=null;const p=O_();if(!p.supportShareAudio&&"enable"===t){const e=new n(o.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return i.onError(e),e.throw(ue)}ue.info("start create screen video track with config",e,"withAudio",t,"trackId",a);try{const e=await ey({screen:s,screenAudio:"auto"===t?p.supportShareAudio:"enable"===t},a);h=e.getVideoTracks()[0]||null,l=e.getAudioTracks()[0]||null}catch(e){throw i.onError(e),e}if(!h){const e=new n(o.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(ue)}if(!l&&"enable"===t){h&&h.stop();const e=new n(o.SHARE_AUDIO_NOT_ALLOWED);return i.onError(e),e.throw(ue)}if(e.optimizationMode||(e.optimizationMode="detail"),e.optimizationMode){vT(a,h,e,e.encoderConfig&&$n(e.encoderConfig)||void 0),e.encoderConfig&&"string"!=typeof e.encoderConfig&&(e.encoderConfig.bitrateMin=e.encoderConfig.bitrateMax)}const f=new oT(h,e.encoderConfig?$n(e.encoderConfig):{},e.scalabiltyMode?eo(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,a,[po.SCREEN_TRACK]);if(r&&f.startMonitorStats(),!l)return i.onSuccess(f.getTrackId()),ue.info("create screen video track success","video:",f.getTrackId()),f;const m=new xy(l,void 0,c(8,"track-scr-a-"),!1,!0);return i.onSuccess([f.getTrackId(),m.getTrackId()]),ue.info("create screen video track success","video:",f.getTrackId(),"audio:",m.getTrackId()),[f,m]}function vT(e,t,i,r){i.optimizationMode&&(r&&r.width&&r.height?(i.encoderConfig=cT(cT({},r),{},{bitrateMin:r.bitrateMin,bitrateMax:r.bitrateMax}),"motion"!==i.optimizationMode&&"detail"!==i.optimizationMode||(t.contentHint=i.optimizationMode,t.contentHint===i.optimizationMode?ue.debug("[".concat(e,"] set content hint to"),i.optimizationMode):ue.debug("[".concat(e,"] set content hint failed")))):ue.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}function _T(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function yT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?_T(Object(i),!0).forEach((function(t){np(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):_T(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",s_)],sT.prototype,"setDevice",null),a_([F("CameraVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Boolean,Boolean]),c_("design:returntype",s_)],sT.prototype,"setEnabled",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),c_("design:type",Function),c_("design:paramtypes",[Object,Boolean]),c_("design:returntype",s_)],sT.prototype,"setEncoderConfiguration",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],sT.prototype,"close",null);class TT extends d_{getUserId(){return this._userId}constructor(e,t,i,r){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(r.clientId,"_").concat(c(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=r}_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,ue.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}class ET extends TT{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==Ro.PLAYING)}get __className__(){return"RemoteVideoTrack"}constructor(e,t,i,r){super(e,t,i,r),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 wy(this.getTrackId(),"remote"),this.processorDestination=new Iy(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){H((()=>{ue.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return G(this,lo.GET_STATS)||yT({},Ao)}play(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e){const t=document.getElementById(e);t?e=t:(ue.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}ue.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=yT(yT({fit:"cover"},t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new Qy(i):this._player=new Zy(i),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(yo.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 e=this.getVideoElementVisibleStatus();this.safeEmit(yo.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),f("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,ue.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){$y(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch($)}_updatePlayerSource(){ue.debug("[".concat(this.getTrackId(),"] update player source track")),this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}getVideoElementVisibleStatus(){try{var e,t;const i=null==this||null===(e=this._player)||void 0===e?void 0:e.getContainerElement(),r={track:this,element:null==this||null===(t=this._player)||void 0===t?void 0:t.getVideoElement(),slot:null==i?void 0:i.parentElement},{element:n,slot:o}=r;if(this.isPlaying&&n instanceof HTMLVideoElement&&o instanceof HTMLElement){const e=ne.checkOneElementVisible(n),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=de.reportApiInvoke(null,{tag:u.TRACER,name:d.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 n(o.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new n(o.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(Oo.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(Oo.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}}a_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),c_("design:type",Function),c_("design:paramtypes",[Object,Object]),c_("design:returntype",void 0)],ET.prototype,"play",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],ET.prototype,"stop",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",Object)],ET.prototype,"pipe",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],ET.prototype,"unpipe",null);class bT extends TT{get isPlaying(){return this._useAudioElement?py.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"RemoteAudioTrack"}constructor(e,t,i,r){super(e,t,i,r),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,f("DISABLE_WEBAUDIO")?(this._source=new Dy,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new z_(e,!0),f("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(To.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(yo.FIRST_FRAME_DECODED)})),this.processorContext=new Oy(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new Ay(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(To.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(To.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(To.ON_AUDIO_BUFFER),this._source.on(To.ON_AUDIO_BUFFER,(t=>e(t)))}setVolume(e){this._volume=e,this._useAudioElement?py.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement)throw new n(o.NOT_SUPPORTED,"your browser does not support setting the audio output device");await py.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){H((()=>{ue.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return G(this,lo.GET_STATS)||yT({},Io)}play(){ue.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(ue.debug("[".concat(this.getTrackId(),"] use audio element to play")),py.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){ue.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?py.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];ue.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&py.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new n(o.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new n(o.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 n(o.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(Oo.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(Oo.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(Oo.ON_TRACK),this.processorDestination.removeAllListeners(Oo.ON_NODE)}}var ST;a_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),c_("design:type",Function),c_("design:paramtypes",[Number]),c_("design:returntype",void 0)],bT.prototype,"setVolume",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),c_("design:type",Function),c_("design:paramtypes",[String]),c_("design:returntype",s_)],bT.prototype,"setPlaybackDevice",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],bT.prototype,"play",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],bT.prototype,"stop",null),a_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),c_("design:type",Function),c_("design:paramtypes",[Object]),c_("design:returntype",Object)],bT.prototype,"pipe",null),a_([le({argsMap:e=>[e.getTrackId()]}),c_("design:type",Function),c_("design:paramtypes",[]),c_("design:returntype",void 0)],bT.prototype,"unpipe",null),function(e){e[e.ONE_BYTE=0]="ONE_BYTE",e[e.TWO_BYTE=1]="TWO_BYTE"}(ST||(ST={}));class kT{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 i=new Uint8Array(4);i.set([1,0,0,0]);const r={id:0,length:4,data:i.buffer},n={profile:this.isUseOneByte?0:1,length:this.isUseOneByte?5:6,datas:[r]};t.commonPacketHeader.extension=1,t.extension=n,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 i=new ArrayBuffer(t.commonPacketHeader.length),r=new Uint8Array(i),n=new DataView(i);let o=0;if(n.setUint16(o,t.commonPacketHeader.extension<<15|t.commonPacketHeader.reserved<<14|t.commonPacketHeader.length,!0),o+=2,n.setUint32(o,t.commonPacketHeader.sequence,!0),o+=4,n.setUint16(o,t.commonStreamHeader,!0),o+=2,t.extension){const e=this.serializeExtension(t.extension);r.set(new Uint8Array(e),o),o+=e.byteLength}if(r.set(new Uint8Array(t.payload),o),o+=t.payload.byteLength,o!==t.commonPacketHeader.length)throw Error("serialize error!");return i}deserialize(e){if(e.byteLength<4)return new ArrayBuffer(0);const t=new DataView(e);let i=0;const r=t.getUint16(i,!0);i+=2;const n=(32768&r)>>15;t.getUint16(i+2,!0),t.getUint16(i,!0);let o,s;if(i+=4,t.getUint16(i,!0),i+=2,n){s=this.deserializeExtension(e.slice(i)),i+=2+s.length,o=e.slice(i);let t=!1;if(s.datas.length>0){const e=s.datas.find((e=>0===e.id));if(e){t=1==(1&new DataView(e.data).getUint32(0,!0))}}o=t?this.decompress(o):o}else o=e.slice(8);return o}serializeExtension(e){const{profile:t,length:i,datas:r}=e,n=new ArrayBuffer(i+2),o=new Uint8Array(n),s=new DataView(n);let a=0;if(s.setUint8(a++,t),s.setUint8(a++,i),r.forEach((e=>{t?(s.setUint8(a++,e.id),s.setUint8(a++,e.length),o.set(new Uint8Array(e.data),a),a+=e.data.byteLength):(s.setUint8(a++,e.id|e.length<<4),o.set(new Uint8Array(e.data),a),a+=e.data.byteLength)})),a!==i+2)throw Error("serialize extension error, is ".concat(a,"!==").concat(i+2));return n}deserializeExtension(e){const t=new DataView(e);let i=0;const r=t.getUint8(i);i++;const n=t.getUint8(i);i++;const o=r===ST.TWO_BYTE,s=[],a=new DataView(e,2);let c=0;for(;c<n;){let e=0,t=0,i=new ArrayBuffer(0);o?(e=a.getUint8(c),c++,t=a.getUint8(c),c++):(e=15&a.getUint8(c),t=a.getUint8(c)>>4,c++),t>0&&(i=a.buffer.slice(c+2,c+2+t),c+=i.byteLength),s.push({id:e,length:t,data:i})}if(c!==n)throw Error("parse error");return{profile:r,length:n,datas:s}}decompress(e){return fe(new Uint8Array(e))}compress(e){return me(new Uint8Array(e))}}class IT extends a{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 kT}get id(){return this._config.id}get ordered(){return this._config.ordered}get maxRetransmits(){return f("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 s_(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new n(o.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 n(o.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new n(o.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(e){this._unbindDataChannelEvents(e),[Lo.OPEN,Lo.CLOSE,Lo.ERROR].forEach((t=>{const i=()=>{this.emit(t)};this._datachannelEventMap.set(t,i),e.addEventListener(t,i)}))}_unbindDataChannelEvents(e){Array.from(this._datachannelEventMap.entries()).forEach((t=>{let[i,r]=t;e.removeEventListener(i,r)})),this._datachannelEventMap.clear()}}class wT extends IT{constructor(e){super(e),this._messageListener=void 0,this._messageListener=e=>{if(e.data.byteLength<this._dataStreamPacketHeader.byteLength)throw Error("invalid byteLength: the byte length must exceed "+this._dataStreamPacketHeader.byteLength);const t=e.data.slice(0,this._dataStreamPacketHeader.byteLength);if(new DataView(t).getUint8(3)!==this.id)return;let i=e.data.slice(this._dataStreamPacketHeader.byteLength);i=this._dataStreamPacketHandler.deserialize(i),this.emit(Lo.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)}}class AT extends IT{send(e){if(this._originDataChannel){let t=e;t=this._dataStreamPacketHandler.serialize(e);const i=new Uint8Array(this._dataStreamPacketHeader.byteLength+t.byteLength);i.set(new Uint8Array(this._dataStreamPacketHeader),0),i.set(new Uint8Array(t),this._dataStreamPacketHeader.byteLength),this._originDataChannel.send(i.buffer)}}}export{ge as AUDIO_CONTEXT_EVENT,to as AUDIO_ENCODER_CONFIG_SETTINGS,Eo as AUDIO_TRACK_EVENT,Oy as AudioProcessorContext,Ay as AudioProcessorDestination,To as AudioSourceEvents,Vy as BufferSourceAudioTrack,sT as CameraVideoTrack,So as DEFAULT_LOCAL_AUDIO_TRACK_STATS,ko as DEFAULT_LOCAL_VIDEO_TRACK_STATS,wo as DEFAULT_NETWORK_QUALITY_STATS,Io as DEFAULT_REMOTE_AUDIO_TRACK_STATS,Ao as DEFAULT_REMOTE_VIDEO_TRACK_STATS,IT as DataChannel,Lo as DataChannelEvents,ny as DeviceManager,No as DeviceManagerEvent,Co as DeviceManagerState,Z_ as HAS_GUM_AUDIO,$_ as HAS_GUM_VIDEO,xy as LocalAudioTrack,AT as LocalDataChannel,u_ as LocalTrack,_o as LocalTrackEvents,oT as LocalVideoTrack,Po as MediaElementNumStatus,Ro as MediaElementStatus,Uy as MicrophoneAudioTrack,jy as MixingAudioTrack,Do as PROCESSOR_CONTEXT_EVENTS,Oo as PROCESSOR_DESTINATION_EVENTS,bT as RemoteAudioTrack,wT as RemoteDataChannel,go as RemoteStreamFallbackType,mo as RemoteStreamType,TT as RemoteTrack,yo as RemoteTrackEvents,ET as RemoteVideoTrack,X_ as SAFARI_GLOBAL_GUM_LOCK,Jn as SUPPORT_720P_AUTO_CONFIG_LIST,Qn as SUPPORT_SCREEN_ENCODER_CONFIG_LIST,Xn as SUPPORT_SVC_CONFIG_LIST,Yn as SUPPORT_VIDEO_ENCODER_CONFIG_LIST,fo as StreamType,d_ as Track,vo as TrackEvents,po as TrackHint,lo as TrackInternalEvent,wy as VideoProcessorContext,Iy as VideoProcessorDestination,ro as __TRACK_LIST__,no as addTrack,f_ as audioContextState,py as audioElementPlayCenter,E_ as audioTimerLoop,ay as autoPlayGestureEventEmitter,zy as blob2Uint8Array,$y as checkMediaStreamTrackResolution,fy as checkTrackState,hT as createBufferSourceAudioTrack,fT as createCameraVideoTrack,dT as createCustomAudioTrack,pT as createCustomVideoTrack,mT as createMicrophoneAndCameraTracks,uT as createMicrophoneAudioTrack,lT as createMixingAudioTrack,gT as createScreenVideoTrack,y_ as decodeAudioData,oy as deviceManager,Ky as emptyImage2TypedArray,tT as frameData2CryptoBuffer,g_ as getAudioContext,io as getAudioEncoderConfiguration,eT as getBitrateFromResAndFps,O_ as getCompatibility,By as getConstraintsFromCameraConfig,Hy as getConstraintsFromMicrophoneConfig,Fy as getConstraintsFromScreenConfig,J_ as getElectronScreenSources,q_ as getElectronScreenStream,Y_ as getElectronScreenStreamByUserSelect,ey as getLocalStream,eo as getScalabilityConfiguration,$n as getScreenEncoderConfiguration,S_ as getSilenceAudioTrack,I_ as getSilenceSamplesDuration,iT as getStaticTrackStream,Zn as getVideoEncoderConfiguration,iy as handleGetUserMediaError,v_ as hasAudioContext,ao as isAudioEncoderConfiguration,uo as isAudioEncoderConfigurationOrPreset,Mo as isBeautyEffectOptions,bo as isLowStreamParameter,ho as isScreenSourceType,so as isVideoEncoderConfiguration,co as isVideoEncoderConfigurationOrPreset,__ as polyfillAudioNode,oo as removeTrack,cy as requestAutoplayGesture,k_ as silenceScriptProcessHandler,A_ as updateAgoraRTCCompatibility,qy as visibilityWatcher};
|
package/AgoraRTC_N-media.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AgoraWebSDK_N-v4.19.
|
|
2
|
+
* AgoraWebSDK_N-v4.19.3-0-gb2ca8ca7 Copyright AgoraInc.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
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}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agora-js/media",
|
|
3
|
-
"version": "4.19.
|
|
3
|
+
"version": "4.19.3",
|
|
4
4
|
"description": "media module across @agora-js packages",
|
|
5
5
|
"main": "AgoraRTC_N-media.js",
|
|
6
6
|
"module": "AgoraRTC_N-media.esm.mjs",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"homepage": "https://api-ref.agora.io/en/voice-sdk/web/4.x/index.html",
|
|
24
24
|
"peerDependencies": {},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@agora-js/shared": "^4.19.
|
|
27
|
-
"@agora-js/report": "^4.19.
|
|
26
|
+
"@agora-js/shared": "^4.19.3",
|
|
27
|
+
"@agora-js/report": "^4.19.3",
|
|
28
28
|
"axios": "^0.27.2",
|
|
29
29
|
"agora-rte-extension": "^1.2.3",
|
|
30
30
|
"webrtc-adapter": "8.2.0",
|