@agora-js/media 4.20.0-300 → 4.20.0-400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * AgoraWebSDK_N-v4.20.0-300-0-g36644d0c Copyright AgoraInc.
2
+ * AgoraWebSDK_N-v4.20.0-400-0-g92209271-dirty Copyright AgoraInc.
3
3
  */
4
4
 
5
- import"webrtc-adapter";import{getBrowserInfo as e,BrowserName as t,isChromeKernel as i,nextTick as r,isAboveChrome as n,isAboveFirefox as o,isAboveSafari as s,BrowserOS as a,isSafari as c,isWkWebview as d,getParameter as u,isFirefox as h,checkValidConstrainLong as l,checkValidNumber as p,checkValidBoolean as f,checkValidEnum as m,AgoraRTCError as g,AgoraRTCErrorCode as v,isEmpty as _,EventEmitter as y,getRandomString as T,AgoraAPIName as E,AgoraAPITag as b,PromiseMutex as S,emitAsPromiseNoResponse as k,removeItemFromList as w,isIOS as I,isIpadOS as A,wait as O,showElectronSelectSourceWindow as D,getElectronInstance as N,isElectron as C,isChrome as R,recursiveMerge as M,isAndroid as P,isHarmonyOS as L,detectSecureContext as x,isAndroidChromium as U,isIOS15 as V,domLoadedPromise as B,emitAsPromise as j,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{logger as de,report as ue,AgoraRTCEventUploadType as he,apiInvoke as le}from"@agora-js/report";import pe from"axios";import{inflate as fe,deflate as me}from"pako";const ge={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 ve(){const l=e();ge.getDisplayMedia=function(e){if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return!0;return!1}(),ge.getStreamFromExtension=l.name===t.CHROME&&Number(l.version)>34,ge.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}(),ge.supportMinBitrate=l.name===t.CHROME||l.name===t.EDGE,ge.supportSetRtpSenderParameters=function(){const r=e();if(!window.RTCRtpSender||!window.RTCRtpSender.prototype.setParameters||!window.RTCRtpSender.prototype.getParameters)return!1;return!!i()||(!(!c()&&!d())||r.name===t.FIREFOX&&Number(r.version)>=64)}(),l.name===t.SAFARI&&(Number(l.version)>=14?ge.supportDualStream=!0:ge.supportDualStream=!1),ge.webAudioMediaStreamDest=function(){const i=e();if(i.name===t.SAFARI&&Number(i.version)<12)return!1;return!0}(),ge.supportReplaceTrack=function(){if(!window.RTCRtpSender)return!1;if("function"==typeof RTCRtpSender.prototype.replaceTrack)return!0;return!1}(),ge.supportWebGL="undefined"!=typeof WebGLRenderingContext,ge.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,i()||(ge.webAudioWithAEC=!0),ge.supportShareAudio=function(){const i=e();if((i.os===a.WIN_10||i.os===a.WIN_81||i.os===a.WIN_7||i.os===a.LINUX||i.os===a.MAC_OS||i.os===a.CHROMIUM_OS)&&i.name===t.CHROME&&Number(i.version)>=74)return!0;return!1}(),ge.supportDataChannel=function(){if(n(76)||o(68)||s(14))return!0;return!1}(),ge.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!h()&&!!e&&e.prototype.setConfiguration instanceof Function}(),ge.supportWebRTCEncodedTransform=function(){const t=e();return"Chrome"===t.name&&Number(t.version)>=86}(),ge.supportWebRTCInsertableStream=function(){const i=e();return(i.name===t.CHROME||i.name===t.EDGE)&&Number(i.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),r((()=>{ge.supportDualStreamEncoding=function(){const t=e();if(u("DISABLE_WEBAUDIO"))return!0;return"Safari"===t.name&&Number(t.version)>=14||!!("Chrome"===t.name&&/Windows/i.test(t.os||"")&&Number(t.version)>=100&&u("CHROME_DUAL_STREAM_USE_ENCODING"))}(),de.info("browser compatibility",JSON.stringify(ge),JSON.stringify(l))}))}function _e(){return ge}var ye;!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"}(ye||(ye={}));var Te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var be=function(e){try{return!!e()}catch(e){return!0}},Se=!be((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),ke=Se,we=Function.prototype,Ie=we.call,Ae=ke&&we.bind.bind(Ie,Ie),Oe=ke?Ae:function(e){return function(){return Ie.apply(e,arguments)}},De=Oe({}.isPrototypeOf),Ne=function(e){return e&&e.Math===Math&&e},Ce=Ne("object"==typeof globalThis&&globalThis)||Ne("object"==typeof window&&window)||Ne("object"==typeof self&&self)||Ne("object"==typeof Te&&Te)||Ne("object"==typeof Te&&Te)||function(){return this}()||Function("return this")(),Re=Se,Me=Function.prototype,Pe=Me.apply,Le=Me.call,xe="object"==typeof Reflect&&Reflect.apply||(Re?Le.bind(Pe):function(){return Le.apply(Pe,arguments)}),Ue=Oe,Ve=Ue({}.toString),Be=Ue("".slice),je=function(e){return Be(Ve(e),8,-1)},Fe=je,He=Oe,Ge=function(e){if("Function"===Fe(e))return He(e)},We="object"==typeof document&&document.all,Ke=void 0===We&&void 0!==We?function(e){return"function"==typeof e||e===We}:function(e){return"function"==typeof e},ze={},qe=!be((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),Ye=Se,Je=Function.prototype.call,Qe=Ye?Je.bind(Je):function(){return Je.apply(Je,arguments)},Xe={},Ze={}.propertyIsEnumerable,$e=Object.getOwnPropertyDescriptor,et=$e&&!Ze.call({1:2},1);Xe.f=et?function(e){var t=$e(this,e);return!!t&&t.enumerable}:Ze;var tt,it,rt=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},nt=be,ot=je,st=Object,at=Oe("".split),ct=nt((function(){return!st("z").propertyIsEnumerable(0)}))?function(e){return"String"===ot(e)?at(e,""):st(e)}:st,dt=function(e){return null==e},ut=dt,ht=TypeError,lt=function(e){if(ut(e))throw new ht("Can't call method on "+e);return e},pt=ct,ft=lt,mt=function(e){return pt(ft(e))},gt=Ke,vt=function(e){return"object"==typeof e?null!==e:gt(e)},_t={},yt=_t,Tt=Ce,Et=Ke,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=Ce.navigator,wt=kt&&kt.userAgent,It=wt?String(wt):"",At=Ce,Ot=It,Dt=At.process,Nt=At.Deno,Ct=Dt&&Dt.versions||Nt&&Nt.version,Rt=Ct&&Ct.v8;Rt&&(it=(tt=Rt.split("."))[0]>0&&tt[0]<4?1:+(tt[0]+tt[1])),!it&&Ot&&(!(tt=Ot.match(/Edge\/(\d+)/))||tt[1]>=74)&&(tt=Ot.match(/Chrome\/(\d+)/))&&(it=+tt[1]);var Mt=it,Pt=Mt,Lt=be,xt=Ce.String,Ut=!!Object.getOwnPropertySymbols&&!Lt((function(){var e=Symbol("symbol detection");return!xt(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Pt&&Pt<41})),Vt=Ut&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Bt=St,jt=Ke,Ft=De,Ht=Object,Gt=Vt?function(e){return"symbol"==typeof e}:function(e){var t=Bt("Symbol");return jt(t)&&Ft(t.prototype,Ht(e))},Wt=String,Kt=function(e){try{return Wt(e)}catch(e){return"Object"}},zt=Ke,qt=Kt,Yt=TypeError,Jt=function(e){if(zt(e))return e;throw new Yt(qt(e)+" is not a function")},Qt=Jt,Xt=dt,Zt=function(e,t){var i=e[t];return Xt(i)?void 0:Qt(i)},$t=Qe,ei=Ke,ti=vt,ii=TypeError,ri={exports:{}},ni=Ce,oi=Object.defineProperty,si=Ce,ai=function(e,t){try{oi(ni,e,{value:t,configurable:!0,writable:!0})}catch(i){ni[e]=t}return t},ci="__core-js_shared__",di=ri.exports=si[ci]||ai(ci,{});(di.versions||(di.versions=[])).push({version:"3.39.0",mode:"pure",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var ui=ri.exports,hi=ui,li=function(e,t){return hi[e]||(hi[e]=t||{})},pi=lt,fi=Object,mi=function(e){return fi(pi(e))},gi=mi,vi=Oe({}.hasOwnProperty),_i=Object.hasOwn||function(e,t){return vi(gi(e),t)},yi=Oe,Ti=0,Ei=Math.random(),bi=yi(1..toString),Si=function(e){return"Symbol("+(void 0===e?"":e)+")_"+bi(++Ti+Ei,36)},ki=li,wi=_i,Ii=Si,Ai=Ut,Oi=Vt,Di=Ce.Symbol,Ni=ki("wks"),Ci=Oi?Di.for||Di:Di&&Di.withoutSetter||Ii,Ri=function(e){return wi(Ni,e)||(Ni[e]=Ai&&wi(Di,e)?Di[e]:Ci("Symbol."+e)),Ni[e]},Mi=Qe,Pi=vt,Li=Gt,xi=Zt,Ui=function(e,t){var i,r;if("string"===t&&ei(i=e.toString)&&!ti(r=$t(i,e)))return r;if(ei(i=e.valueOf)&&!ti(r=$t(i,e)))return r;if("string"!==t&&ei(i=e.toString)&&!ti(r=$t(i,e)))return r;throw new ii("Can't convert object to primitive value")},Vi=TypeError,Bi=Ri("toPrimitive"),ji=function(e,t){if(!Pi(e)||Li(e))return e;var i,r=xi(e,Bi);if(r){if(void 0===t&&(t="default"),i=Mi(r,e,t),!Pi(i)||Li(i))return i;throw new Vi("Can't convert object to primitive value")}return void 0===t&&(t="number"),Ui(e,t)},Fi=Gt,Hi=function(e){var t=ji(e,"string");return Fi(t)?t:t+""},Gi=vt,Wi=Ce.document,Ki=Gi(Wi)&&Gi(Wi.createElement),zi=function(e){return Ki?Wi.createElement(e):{}},qi=zi,Yi=!qe&&!be((function(){return 7!==Object.defineProperty(qi("div"),"a",{get:function(){return 7}}).a})),Ji=qe,Qi=Qe,Xi=Xe,Zi=rt,$i=mt,er=Hi,tr=_i,ir=Yi,rr=Object.getOwnPropertyDescriptor;ze.f=Ji?rr:function(e,t){if(e=$i(e),t=er(t),ir)try{return rr(e,t)}catch(e){}if(tr(e,t))return Zi(!Qi(Xi.f,e,t),e[t])};var nr=be,or=Ke,sr=/#|\.prototype\./,ar=function(e,t){var i=dr[cr(e)];return i===hr||i!==ur&&(or(t)?nr(t):!!t)},cr=ar.normalize=function(e){return String(e).replace(sr,".").toLowerCase()},dr=ar.data={},ur=ar.NATIVE="N",hr=ar.POLYFILL="P",lr=ar,pr=Jt,fr=Se,mr=Ge(Ge.bind),gr=function(e,t){return pr(e),void 0===t?e:fr?mr(e,t):function(){return e.apply(t,arguments)}},vr={},_r=qe&&be((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),yr=vt,Tr=String,Er=TypeError,br=function(e){if(yr(e))return e;throw new Er(Tr(e)+" is not an object")},Sr=qe,kr=Yi,wr=_r,Ir=br,Ar=Hi,Or=TypeError,Dr=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,Cr="enumerable",Rr="configurable",Mr="writable";vr.f=Sr?wr?function(e,t,i){if(Ir(e),t=Ar(t),Ir(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Mr in i&&!i[Mr]){var r=Nr(e,t);r&&r[Mr]&&(e[t]=i.value,i={configurable:Rr in i?i[Rr]:r[Rr],enumerable:Cr in i?i[Cr]:r[Cr],writable:!1})}return Dr(e,t,i)}:Dr:function(e,t,i){if(Ir(e),t=Ar(t),Ir(i),kr)try{return Dr(e,t,i)}catch(e){}if("get"in i||"set"in i)throw new Or("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Pr=vr,Lr=rt,xr=qe?function(e,t,i){return Pr.f(e,t,Lr(1,i))}:function(e,t,i){return e[t]=i,e},Ur=Ce,Vr=xe,Br=Ge,jr=Ke,Fr=ze.f,Hr=lr,Gr=_t,Wr=gr,Kr=xr,zr=_i,qr=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 Vr(e,this,arguments)};return t.prototype=e.prototype,t},Yr=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?Ur:p?Ur[h]:Ur[h]&&Ur[h].prototype,g=l?Gr:Gr[h]||Kr(Gr,h,{})[h],v=g.prototype;for(o in t)r=!(i=Hr(l?o:h+(p?".":"#")+o,e.forced))&&m&&zr(m,o),a=g[o],r&&(c=e.dontCallGetSet?(u=Fr(m,o))&&u.value:m[o]),s=r&&c?c:t[o],(i||f||typeof a!=typeof s)&&(d=e.bind&&r?Wr(s,Ur):e.wrap&&r?qr(s):f&&jr(s)?Br(s):s,(e.sham||s&&s.sham||a&&a.sham)&&Kr(d,"sham",!0),Kr(g,o,d),f&&(zr(Gr,n=h+"Prototype")||Kr(Gr,n,{}),Kr(Gr[n],o,s),e.real&&v&&(i||!v[o])&&Kr(v,o,s)))},Jr=Math.ceil,Qr=Math.floor,Xr=Math.trunc||function(e){var t=+e;return(t>0?Qr:Jr)(t)},Zr=function(e){var t=+e;return t!=t||0===t?0:Xr(t)},$r=Zr,en=Math.max,tn=Math.min,rn=Zr,nn=Math.min,on=function(e){var t=rn(e);return t>0?nn(t,9007199254740991):0},sn=function(e){return on(e.length)},an=mt,cn=function(e,t){var i=$r(e);return i<0?en(i+t,0):tn(i,t)},dn=sn,un=function(e){return function(t,i,r){var n=an(t),o=dn(n);if(0===o)return!e&&-1;var s,a=cn(r,o);if(e&&i!=i){for(;o>a;)if((s=n[a++])!=s)return!0}else for(;o>a;a++)if((e||a in n)&&n[a]===i)return e||a||0;return!e&&-1}},hn={includes:un(!0),indexOf:un(!1)},ln=hn.includes;Yr({target:"Array",proto:!0,forced:be((function(){return!Array(1).includes()}))},{includes:function(e){return ln(this,e,arguments.length>1?arguments[1]:void 0)}});var pn=Ce,fn=_t,mn=function(e,t){var i=fn[e+"Prototype"],r=i&&i[t];if(r)return r;var n=pn[e],o=n&&n.prototype;return o&&o[t]},gn=mn("Array","includes"),vn=vt,_n=je,yn=Ri("match"),Tn=function(e){var t;return vn(e)&&(void 0!==(t=e[yn])?!!t:"RegExp"===_n(e))},En=TypeError,bn={};bn[Ri("toStringTag")]="z";var Sn="[object z]"===String(bn),kn=Sn,wn=Ke,In=je,An=Ri("toStringTag"),On=Object,Dn="Arguments"===In(function(){return arguments}()),Nn=kn?In: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=On(e),An))?i:Dn?In(t):"Object"===(r=In(t))&&wn(t.callee)?"Arguments":r},Cn=Nn,Rn=String,Mn=function(e){if("Symbol"===Cn(e))throw new TypeError("Cannot convert a Symbol value to a string");return Rn(e)},Pn=Ri("match"),Ln=Yr,xn=function(e){if(Tn(e))throw new En("The method doesn't accept regular expressions");return e},Un=lt,Vn=Mn,Bn=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[Pn]=!1,"/./"[e](t)}catch(e){}}return!1},jn=Oe("".indexOf);Ln({target:"String",proto:!0,forced:!Bn("includes")},{includes:function(e){return!!~jn(Vn(Un(this)),Vn(xn(e)),arguments.length>1?arguments[1]:void 0)}});var Fn=mn("String","includes"),Hn=De,Gn=gn,Wn=Fn,Kn=Array.prototype,zn=String.prototype,qn=Ee((function(e){var t=e.includes;return e===Kn||Hn(Kn,e)&&t===Kn.includes?Gn:"string"==typeof e||e===zn||Hn(zn,e)&&t===zn.includes?Wn:t}));function Yn(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function Jn(e,t,i,r,n){return{width:e,height:t,frameRate:i,bitrateMin:r,bitrateMax:n}}function Qn(e,t,i,r,n){return{width:{max:e},height:{max:t},frameRate:i,bitrateMin:r,bitrateMax:n}}function Xn(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const Zn={"90p":Jn(160,90),"90p_1":Jn(160,90),"120p":Jn(160,120,15,30,65),"120p_1":Jn(160,120,15,30,65),"120p_3":Jn(120,120,15,30,50),"120p_4":Jn(212,120),"180p":Jn(320,180,15,30,140),"180p_1":Jn(320,180,15,30,140),"180p_3":Jn(180,180,15,30,100),"180p_4":Jn(240,180,15,30,120),"240p":Jn(320,240,15,40,200),"240p_1":Jn(320,240,15,40,200),"240p_3":Jn(240,240,15,40,140),"240p_4":Jn(424,240,15,40,220),"360p":Jn(640,360,15,80,400),"360p_1":Jn(640,360,15,80,400),"360p_3":Jn(360,360,15,80,260),"360p_4":Jn(640,360,30,80,600),"360p_6":Jn(360,360,30,80,400),"360p_7":Jn(480,360,15,80,320),"360p_8":Jn(480,360,30,80,490),"360p_9":Jn(640,360,15,80,800),"360p_10":Jn(640,360,24,80,800),"360p_11":Jn(640,360,24,80,1e3),"480p":Jn(640,480,15,100,500),"480p_1":Jn(640,480,15,100,500),"480p_2":Jn(640,480,30,100,1e3),"480p_3":Jn(480,480,15,100,400),"480p_4":Jn(640,480,30,100,750),"480p_6":Jn(480,480,30,100,600),"480p_8":Jn(848,480,15,100,610),"480p_9":Jn(848,480,30,100,930),"480p_10":Jn(640,480,10,100,400),"720p":Jn(1280,720,15,120,1130),"720p_auto":Jn(1280,720,30,900,3e3),"720p_1":Jn(1280,720,15,120,1130),"720p_2":Jn(1280,720,30,120,2e3),"720p_3":Jn(1280,720,30,120,1710),"720p_5":Jn(960,720,15,120,910),"720p_6":Jn(960,720,30,120,1380),"1080p":Jn(1920,1080,15,120,2080),"1080p_1":Jn(1920,1080,15,120,2080),"1080p_2":Jn(1920,1080,30,120,3e3),"1080p_3":Jn(1920,1080,30,120,3150),"1080p_5":Jn(1920,1080,60,120,4780),"1440p":Jn(2560,1440,30,120,4850),"1440p_1":Jn(2560,1440,30,120,4850),"1440p_2":Jn(2560,1440,60,120,7350),"4k":Jn(3840,2160,30,120,8910),"4k_1":Jn(3840,2160,30,120,8910),"4k_3":Jn(3840,2160,60,120,13500)},$n=[{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}],eo={"480p":Qn(640,480,5),"480p_1":Qn(640,480,5),"480p_2":Qn(640,480,30),"480p_3":Qn(640,480,15),"720p":Qn(1280,720,5),"720p_auto":Jn(1280,720,30,900,3e3),"720p_1":Qn(1280,720,5),"720p_2":Qn(1280,720,30),"720p_3":Qn(1280,720,15),"1080p":Qn(1920,1080,5),"1080p_1":Qn(1920,1080,5),"1080p_2":Qn(1920,1080,30),"1080p_3":Qn(1920,1080,15)},to={"1SL1TL":Xn(1,1),"3SL3TL":Xn(3,3),"2SL3TL":Xn(2,3)};function io(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},Zn[e]):e}function ro(e){return"string"==typeof e?Object.assign({},eo[e]):e}function no(e){return"string"==typeof e?Object.assign({},to[e]):e}const oo={speech_low_quality:Yn(16e3,!1),speech_standard:Yn(32e3,!1,18),music_standard:Yn(48e3,!1),standard_stereo:Yn(48e3,!0,56),high_quality:Yn(48e3,!1,128),high_quality_stereo:Yn(48e3,!0,192)};function so(e){return"string"==typeof e?Object.assign({},oo[e]):e}const ao=[];function co(e){qn(ao).call(ao,e)||ao.push(e)}function uo(e){const t=ao.indexOf(e);-1!==t&&ao.splice(t,1)}function ho(e){return l(e.width,"config.width"),l(e.height,"config.height"),void 0!==e.frameRate&&l(e.frameRate,"config.frameRate"),void 0!==e.bitrateMax&&p(e.bitrateMax,"config.bitrateMax"),void 0!==e.bitrateMin&&p(e.bitrateMin,"config.bitrateMin"),!0}function lo(e){return void 0!==e.sampleRate&&p(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&p(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&f(e.stereo,"config.stereo"),void 0!==e.bitrate&&p(e.bitrate,"config.bitrate",0,1e4,!1),!0}function po(e){return"string"==typeof e?m(e,"profile",Object.keys(Zn)):ho(e),!0}function fo(e){return"string"==typeof e?m(e,"profile",Object.keys(oo)):lo(e),!0}function mo(e){return m(e,"mediaSource",["screen","window","application"]),!0}var go,vo,_o,yo,To,Eo,bo,So,ko,wo;function Io(e){if(!e)throw new g(v.INVALID_PARAMS);return _(e.width)||l(e.width,"streamParameter.width"),_(e.height)||l(e.height,"streamParameter.height"),_(e.framerate)||l(e.framerate,"streamParameter.framerate"),_(e.bitrate)||p(e.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"}(go||(go={})),function(e){e.SCREEN_TRACK="screen_track",e.CUSTOM_TRACK="custome_track",e.LOW_STREAM="low_stream"}(vo||(vo={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(_o||(_o={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(yo||(yo={})),function(e){e[e.DISABLE=0]="DISABLE",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.AUDIO_ONLY=2]="AUDIO_ONLY"}(To||(To={})),function(e){e.TRANSCEIVER_UPDATED="transceiver-updated"}(Eo||(Eo={})),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"}(bo||(bo={})),function(e){e.FIRST_FRAME_DECODED="first-frame-decoded",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status"}(So||(So={})),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"}(ko||(ko={})),function(e){e.UPDATE_TRACK_SOURCE="update-track-source"}(wo||(wo={}));const Ao={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},Oo={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},Do={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},No={uplinkNetworkQuality:0,downlinkNetworkQuality:0},Co={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 Ro,Mo,Po,Lo,xo;function Uo(e){return void 0!==e.smoothnessLevel&&p(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&p(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&p(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&m(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0}!function(e){e.ON_TRACK="on_track",e.ON_NODE="on_node"}(Ro||(Ro={})),function(e){e.REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",e.REQUEST_CONSTRAINTS="request_constraints"}(Mo||(Mo={})),function(e){e.IDLE="IDLE",e.INITING="INITING",e.INITEND="INITEND"}(Po||(Po={})),function(e){e.STATE_CHANGE="state_change",e.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",e.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",e.CAMERA_DEVICE_CHANGED="cameraDeviceChanged"}(Lo||(Lo={})),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"}(xo||(xo={}));const Vo={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 Bo;!function(e){e.OPEN="open",e.MESSAGE="message",e.CLOSE="close",e.CLOSING="closing",e.ERROR="error"}(Bo||(Bo={}));var jo={exports:{}},Fo=Yr,Ho=qe,Go=vr.f;Fo({target:"Object",stat:!0,forced:Object.defineProperty!==Go,sham:!Ho},{defineProperty:Go});var Wo=_t.Object,Ko=jo.exports=function(e,t,i){return Wo.defineProperty(e,t,i)};Wo.defineProperty.sham&&(Ko.sham=!0);var zo=Ee(jo.exports),qo=je,Yo=Array.isArray||function(e){return"Array"===qo(e)},Jo=TypeError,Qo=qe,Xo=vr,Zo=rt,$o=Ke,es=ui,ts=Oe(Function.toString);$o(es.inspectSource)||(es.inspectSource=function(e){return ts(e)});var is=es.inspectSource,rs=Oe,ns=be,os=Ke,ss=Nn,as=is,cs=function(){},ds=St("Reflect","construct"),us=/^\s*(?:class|function)\b/,hs=rs(us.exec),ls=!us.test(cs),ps=function(e){if(!os(e))return!1;try{return ds(cs,[],e),!0}catch(e){return!1}},fs=function(e){if(!os(e))return!1;switch(ss(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ls||!!hs(us,as(e))}catch(e){return!0}};fs.sham=!0;var ms=!ds||ns((function(){var e;return ps(ps.call)||!ps(Object)||!ps((function(){e=!0}))||e}))?fs:ps,gs=Yo,vs=ms,_s=vt,ys=Ri("species"),Ts=Array,Es=function(e){var t;return gs(e)&&(t=e.constructor,(vs(t)&&(t===Ts||gs(t.prototype))||_s(t)&&null===(t=t[ys]))&&(t=void 0)),void 0===t?Ts:t},bs=function(e,t){return new(Es(e))(0===t?0:t)},Ss=be,ks=Mt,ws=Ri("species"),Is=Yr,As=be,Os=Yo,Ds=vt,Ns=mi,Cs=sn,Rs=function(e){if(e>9007199254740991)throw Jo("Maximum allowed index exceeded");return e},Ms=function(e,t,i){Qo?Xo.f(e,t,Zo(0,i)):e[t]=i},Ps=bs,Ls=function(e){return ks>=51||!Ss((function(){var t=[];return(t.constructor={})[ws]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},xs=Mt,Us=Ri("isConcatSpreadable"),Vs=xs>=51||!As((function(){var e=[];return e[Us]=!1,e.concat()[0]!==e})),Bs=function(e){if(!Ds(e))return!1;var t=e[Us];return void 0!==t?!!t:Os(e)};Is({target:"Array",proto:!0,arity:1,forced:!Vs||!Ls("concat")},{concat:function(e){var t,i,r,n,o,s=Ns(this),a=Ps(s,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(Bs(o=-1===t?s:arguments[t]))for(n=Cs(o),Rs(c+n),i=0;i<n;i++,c++)i in o&&Ms(a,c,o[i]);else Rs(c+1),Ms(a,c++,o);return a.length=c,a}});var js={},Fs={},Hs=_i,Gs=mt,Ws=hn.indexOf,Ks=Fs,zs=Oe([].push),qs=function(e,t){var i,r=Gs(e),n=0,o=[];for(i in r)!Hs(Ks,i)&&Hs(r,i)&&zs(o,i);for(;t.length>n;)Hs(r,i=t[n++])&&(~Ws(o,i)||zs(o,i));return o},Ys=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Js=qs,Qs=Ys,Xs=Object.keys||function(e){return Js(e,Qs)},Zs=qe,$s=_r,ea=vr,ta=br,ia=mt,ra=Xs;js.f=Zs&&!$s?Object.defineProperties:function(e,t){ta(e);for(var i,r=ia(t),n=ra(t),o=n.length,s=0;o>s;)ea.f(e,i=n[s++],r[i]);return e};var na,oa=St("document","documentElement"),sa=Si,aa=li("keys"),ca=function(e){return aa[e]||(aa[e]=sa(e))},da=br,ua=js,ha=Ys,la=Fs,pa=oa,fa=zi,ma="prototype",ga="script",va=ca("IE_PROTO"),_a=function(){},ya=function(e){return"<"+ga+">"+e+"</"+ga+">"},Ta=function(e){e.write(ya("")),e.close();var t=e.parentWindow.Object;return e=null,t},Ea=function(){try{na=new ActiveXObject("htmlfile")}catch(e){}var e,t,i;Ea="undefined"!=typeof document?document.domain&&na?Ta(na):(t=fa("iframe"),i="java"+ga+":",t.style.display="none",pa.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(ya("document.F=Object")),e.close(),e.F):Ta(na);for(var r=ha.length;r--;)delete Ea[ma][ha[r]];return Ea()};la[va]=!0;var ba=Object.create||function(e,t){var i;return null!==e?(_a[ma]=da(e),i=new _a,_a[ma]=null,i[va]=e):i=Ea(),void 0===t?i:ua.f(i,t)},Sa={},ka=qs,wa=Ys.concat("length","prototype");Sa.f=Object.getOwnPropertyNames||function(e){return ka(e,wa)};var Ia={},Aa=Oe([].slice),Oa=je,Da=mt,Na=Sa.f,Ca=Aa,Ra="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Ia.f=function(e){return Ra&&"Window"===Oa(e)?function(e){try{return Na(e)}catch(e){return Ca(Ra)}}(e):Na(Da(e))};var Ma={};Ma.f=Object.getOwnPropertySymbols;var Pa=xr,La=function(e,t,i,r){return r&&r.enumerable?e[t]=i:Pa(e,t,i),e},xa=vr,Ua=function(e,t,i){return xa.f(e,t,i)},Va={},Ba=Ri;Va.f=Ba;var ja,Fa,Ha,Ga=_t,Wa=_i,Ka=Va,za=vr.f,qa=function(e){var t=Ga.Symbol||(Ga.Symbol={});Wa(t,e)||za(t,e,{value:Ka.f(e)})},Ya=Qe,Ja=St,Qa=Ri,Xa=La,Za=function(){var e=Ja("Symbol"),t=e&&e.prototype,i=t&&t.valueOf,r=Qa("toPrimitive");t&&!t[r]&&Xa(t,r,(function(e){return Ya(i,this)}),{arity:1})},$a=Nn,ec=Sn?{}.toString:function(){return"[object "+$a(this)+"]"},tc=Sn,ic=vr.f,rc=xr,nc=_i,oc=ec,sc=Ri("toStringTag"),ac=function(e,t,i,r){var n=i?e:e&&e.prototype;n&&(nc(n,sc)||ic(n,sc,{configurable:!0,value:t}),r&&!tc&&rc(n,"toString",oc))},cc=Ke,dc=Ce.WeakMap,uc=cc(dc)&&/native code/.test(String(dc)),hc=Ce,lc=vt,pc=xr,fc=_i,mc=ui,gc=ca,vc=Fs,_c="Object already initialized",yc=hc.TypeError,Tc=hc.WeakMap;if(uc||mc.state){var Ec=mc.state||(mc.state=new Tc);Ec.get=Ec.get,Ec.has=Ec.has,Ec.set=Ec.set,ja=function(e,t){if(Ec.has(e))throw new yc(_c);return t.facade=e,Ec.set(e,t),t},Fa=function(e){return Ec.get(e)||{}},Ha=function(e){return Ec.has(e)}}else{var bc=gc("state");vc[bc]=!0,ja=function(e,t){if(fc(e,bc))throw new yc(_c);return t.facade=e,pc(e,bc,t),t},Fa=function(e){return fc(e,bc)?e[bc]:{}},Ha=function(e){return fc(e,bc)}}var Sc={set:ja,get:Fa,has:Ha,enforce:function(e){return Ha(e)?Fa(e):ja(e,{})},getterFor:function(e){return function(t){var i;if(!lc(t)||(i=Fa(t)).type!==e)throw new yc("Incompatible receiver, "+e+" required");return i}}},kc=gr,wc=ct,Ic=mi,Ac=sn,Oc=bs,Dc=Oe([].push),Nc=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=Ic(c),m=wc(f),g=Ac(m),v=kc(d,u),_=0,y=h||Oc,T=t?y(c,g):i||s?y(c,0):void 0;g>_;_++)if((a||_ in m)&&(p=v(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:Dc(T,l)}else switch(e){case 4:return!1;case 7:Dc(T,l)}return o?-1:r||n?n:T}},Cc={forEach:Nc(0),map:Nc(1),filter:Nc(2),some:Nc(3),every:Nc(4),find:Nc(5),findIndex:Nc(6),filterReject:Nc(7)},Rc=Yr,Mc=Ce,Pc=Qe,Lc=Oe,xc=qe,Uc=Ut,Vc=be,Bc=_i,jc=De,Fc=br,Hc=mt,Gc=Hi,Wc=Mn,Kc=rt,zc=ba,qc=Xs,Yc=Sa,Jc=Ia,Qc=Ma,Xc=ze,Zc=vr,$c=js,ed=Xe,td=La,id=Ua,rd=li,nd=Fs,od=Si,sd=Ri,ad=Va,cd=qa,dd=Za,ud=ac,hd=Sc,ld=Cc.forEach,pd=ca("hidden"),fd="Symbol",md="prototype",gd=hd.set,vd=hd.getterFor(fd),_d=Object[md],yd=Mc.Symbol,Td=yd&&yd[md],Ed=Mc.RangeError,bd=Mc.TypeError,Sd=Mc.QObject,kd=Xc.f,wd=Zc.f,Id=Jc.f,Ad=ed.f,Od=Lc([].push),Dd=rd("symbols"),Nd=rd("op-symbols"),Cd=rd("wks"),Rd=!Sd||!Sd[md]||!Sd[md].findChild,Md=function(e,t,i){var r=kd(_d,t);r&&delete _d[t],wd(e,t,i),r&&e!==_d&&wd(_d,t,r)},Pd=xc&&Vc((function(){return 7!==zc(wd({},"a",{get:function(){return wd(this,"a",{value:7}).a}})).a}))?Md:wd,Ld=function(e,t){var i=Dd[e]=zc(Td);return gd(i,{type:fd,tag:e,description:t}),xc||(i.description=t),i},xd=function(e,t,i){e===_d&&xd(Nd,t,i),Fc(e);var r=Gc(t);return Fc(i),Bc(Dd,r)?(i.enumerable?(Bc(e,pd)&&e[pd][r]&&(e[pd][r]=!1),i=zc(i,{enumerable:Kc(0,!1)})):(Bc(e,pd)||wd(e,pd,Kc(1,zc(null))),e[pd][r]=!0),Pd(e,r,i)):wd(e,r,i)},Ud=function(e,t){Fc(e);var i=Hc(t),r=qc(i).concat(Fd(i));return ld(r,(function(t){xc&&!Pc(Vd,i,t)||xd(e,t,i[t])})),e},Vd=function(e){var t=Gc(e),i=Pc(Ad,this,t);return!(this===_d&&Bc(Dd,t)&&!Bc(Nd,t))&&(!(i||!Bc(this,t)||!Bc(Dd,t)||Bc(this,pd)&&this[pd][t])||i)},Bd=function(e,t){var i=Hc(e),r=Gc(t);if(i!==_d||!Bc(Dd,r)||Bc(Nd,r)){var n=kd(i,r);return!n||!Bc(Dd,r)||Bc(i,pd)&&i[pd][r]||(n.enumerable=!0),n}},jd=function(e){var t=Id(Hc(e)),i=[];return ld(t,(function(e){Bc(Dd,e)||Bc(nd,e)||Od(i,e)})),i},Fd=function(e){var t=e===_d,i=Id(t?Nd:Hc(e)),r=[];return ld(i,(function(e){!Bc(Dd,e)||t&&!Bc(_d,e)||Od(r,Dd[e])})),r};Uc||(td(Td=(yd=function(){if(jc(Td,this))throw new bd("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Wc(arguments[0]):void 0,t=od(e),i=function(e){var r=void 0===this?Mc:this;r===_d&&Pc(i,Nd,e),Bc(r,pd)&&Bc(r[pd],t)&&(r[pd][t]=!1);var n=Kc(1,e);try{Pd(r,t,n)}catch(e){if(!(e instanceof Ed))throw e;Md(r,t,n)}};return xc&&Rd&&Pd(_d,t,{configurable:!0,set:i}),Ld(t,e)})[md],"toString",(function(){return vd(this).tag})),td(yd,"withoutSetter",(function(e){return Ld(od(e),e)})),ed.f=Vd,Zc.f=xd,$c.f=Ud,Xc.f=Bd,Yc.f=Jc.f=jd,Qc.f=Fd,ad.f=function(e){return Ld(sd(e),e)},xc&&id(Td,"description",{configurable:!0,get:function(){return vd(this).description}})),Rc({global:!0,constructor:!0,wrap:!0,forced:!Uc,sham:!Uc},{Symbol:yd}),ld(qc(Cd),(function(e){cd(e)})),Rc({target:fd,stat:!0,forced:!Uc},{useSetter:function(){Rd=!0},useSimple:function(){Rd=!1}}),Rc({target:"Object",stat:!0,forced:!Uc,sham:!xc},{create:function(e,t){return void 0===t?zc(e):Ud(zc(e),t)},defineProperty:xd,defineProperties:Ud,getOwnPropertyDescriptor:Bd}),Rc({target:"Object",stat:!0,forced:!Uc},{getOwnPropertyNames:jd}),dd(),ud(yd,fd),nd[pd]=!0;var Hd=Ut&&!!Symbol.for&&!!Symbol.keyFor,Gd=Yr,Wd=St,Kd=_i,zd=Mn,qd=li,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=Yr,Zd=_i,$d=Gt,eu=Kt,tu=Hd,iu=li("symbol-to-string-registry");Xd({target:"Symbol",stat:!0,forced:!tu},{keyFor:function(e){if(!$d(e))throw new TypeError(eu(e)+" is not a symbol");if(Zd(iu,e))return iu[e]}});var ru=Yo,nu=Ke,ou=je,su=Mn,au=Oe([].push),cu=Yr,du=St,uu=xe,hu=Qe,lu=Oe,pu=be,fu=Ke,mu=Gt,gu=Aa,vu=function(e){if(nu(e))return e;if(ru(e)){for(var t=e.length,i=[],r=0;r<t;r++){var n=e[r];"string"==typeof n?au(i,n):"number"!=typeof n&&"Number"!==ou(n)&&"String"!==ou(n)||au(i,su(n))}var o=i.length,s=!0;return function(e,t){if(s)return s=!1,t;if(ru(this))return t;for(var r=0;r<o;r++)if(i[r]===e)return t}}},_u=Ut,yu=String,Tu=du("JSON","stringify"),Eu=lu(/./.exec),bu=lu("".charAt),Su=lu("".charCodeAt),ku=lu("".replace),wu=lu(1..toString),Iu=/[\uD800-\uDFFF]/g,Au=/^[\uD800-\uDBFF]$/,Ou=/^[\uDC00-\uDFFF]$/,Du=!_u||pu((function(){var e=du("Symbol")("stringify detection");return"[null]"!==Tu([e])||"{}"!==Tu({a:e})||"{}"!==Tu(Object(e))})),Nu=pu((function(){return'"\\udf06\\ud834"'!==Tu("\udf06\ud834")||'"\\udead"'!==Tu("\udead")})),Cu=function(e,t){var i=gu(arguments),r=vu(t);if(fu(r)||void 0!==e&&!mu(e))return i[1]=function(e,t){if(fu(r)&&(t=hu(r,this,yu(e),t)),!mu(t))return t},uu(Tu,null,i)},Ru=function(e,t,i){var r=bu(i,t-1),n=bu(i,t+1);return Eu(Au,e)&&!Eu(Ou,n)||Eu(Ou,e)&&!Eu(Au,r)?"\\u"+wu(Su(e,0),16):e};Tu&&cu({target:"JSON",stat:!0,arity:3,forced:Du||Nu},{stringify:function(e,t,i){var r=gu(arguments),n=uu(Du?Cu:Tu,null,r);return Nu&&"string"==typeof n?ku(n,Iu,Ru):n}});var Mu=Ma,Pu=mi;Yr({target:"Object",stat:!0,forced:!Ut||be((function(){Mu.f(1)}))},{getOwnPropertySymbols:function(e){var t=Mu.f;return t?t(Pu(e)):[]}}),qa("asyncIterator"),qa("hasInstance"),qa("isConcatSpreadable"),qa("iterator"),qa("match"),qa("matchAll"),qa("replace"),qa("search"),qa("species"),qa("split");var Lu=Za;qa("toPrimitive"),Lu();var xu=St,Uu=ac;qa("toStringTag"),Uu(xu("Symbol"),"Symbol"),qa("unscopables"),ac(Ce.JSON,"JSON",!0);var Vu,Bu,ju,Fu=_t.Symbol,Hu={},Gu=qe,Wu=_i,Ku=Function.prototype,zu=Gu&&Object.getOwnPropertyDescriptor,qu=Wu(Ku,"name"),Yu={EXISTS:qu,PROPER:qu&&"something"===function(){}.name,CONFIGURABLE:qu&&(!Gu||Gu&&zu(Ku,"name").configurable)},Ju=!be((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),Qu=_i,Xu=Ke,Zu=mi,$u=Ju,eh=ca("IE_PROTO"),th=Object,ih=th.prototype,rh=$u?th.getPrototypeOf:function(e){var t=Zu(e);if(Qu(t,eh))return t[eh];var i=t.constructor;return Xu(i)&&t instanceof i?i.prototype:t instanceof th?ih:null},nh=be,oh=Ke,sh=vt,ah=ba,ch=rh,dh=La,uh=Ri("iterator"),hh=!1;[].keys&&("next"in(ju=[].keys())?(Bu=ch(ch(ju)))!==Object.prototype&&(Vu=Bu):hh=!0);var lh=!sh(Vu)||nh((function(){var e={};return Vu[uh].call(e)!==e}));oh((Vu=lh?{}:ah(Vu))[uh])||dh(Vu,uh,(function(){return this}));var ph={IteratorPrototype:Vu,BUGGY_SAFARI_ITERATORS:hh},fh=ph.IteratorPrototype,mh=ba,gh=rt,vh=ac,_h=Hu,yh=function(){return this},Th=Oe,Eh=Jt,bh=vt,Sh=function(e){return bh(e)||null===e},kh=String,wh=TypeError,Ih=function(e,t,i){try{return Th(Eh(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(e){}},Ah=vt,Oh=lt,Dh=function(e){if(Sh(e))return e;throw new wh("Can't set "+kh(e)+" as a prototype")},Nh=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Ih(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(e){}return function(i,r){return Oh(i),Dh(r),Ah(i)?(t?e(i,r):i.__proto__=r,i):i}}():void 0),Ch=Yr,Rh=Qe,Mh=Yu,Ph=function(e,t,i,r){var n=t+" Iterator";return e.prototype=mh(fh,{next:gh(+!r,i)}),vh(e,n,!1,!0),_h[n]=yh,e},Lh=rh,xh=ac,Uh=La,Vh=Hu,Bh=ph,jh=Mh.PROPER,Fh=Bh.BUGGY_SAFARI_ITERATORS,Hh=Ri("iterator"),Gh="keys",Wh="values",Kh="entries",zh=function(){return this},qh=function(e,t,i,r,n,o,s){Ph(i,t,r);var a,c,d,u=function(e){if(e===n&&m)return m;if(!Fh&&e&&e in p)return p[e];switch(e){case Gh:case Wh:case Kh:return function(){return new i(this,e)}}return function(){return new i(this)}},h=t+" Iterator",l=!1,p=e.prototype,f=p[Hh]||p["@@iterator"]||n&&p[n],m=!Fh&&f||u(n),g="Array"===t&&p.entries||f;if(g&&(a=Lh(g.call(new e)))!==Object.prototype&&a.next&&(xh(a,h,!0,!0),Vh[h]=zh),jh&&n===Wh&&f&&f.name!==Wh&&(l=!0,m=function(){return Rh(f,this)}),n)if(c={values:u(Wh),keys:o?m:u(Gh),entries:u(Kh)},s)for(d in c)(Fh||l||!(d in p))&&Uh(p,d,c[d]);else Ch({target:t,proto:!0,forced:Fh||l},c);return s&&p[Hh]!==m&&Uh(p,Hh,m,{name:n}),Vh[t]=m,c},Yh=function(e,t){return{value:e,done:t}},Jh=mt,Qh=Hu,Xh=Sc;vr.f;var Zh=qh,$h=Yh,el="Array Iterator",tl=Xh.set,il=Xh.getterFor(el);Zh(Array,"Array",(function(e,t){tl(this,{type:el,target:Jh(e),index:0,kind:t})}),(function(){var e=il(this),t=e.target,i=e.index++;if(!t||i>=t.length)return e.target=null,$h(void 0,!0);switch(e.kind){case"keys":return $h(i,!1);case"values":return $h(t[i],!1)}return $h([i,t[i]],!1)}),"values"),Qh.Arguments=Qh.Array;var rl={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},nl=Ce,ol=ac,sl=Hu;for(var al in rl)ol(nl[al],al),sl[al]=sl.Array;var cl=Fu,dl=Ri,ul=vr.f,hl=dl("metadata"),ll=Function.prototype;void 0===ll[hl]&&ul(ll,hl,{value:null}),qa("asyncDispose"),qa("dispose"),qa("metadata");var pl=cl,fl=Oe,ml=St("Symbol"),gl=ml.keyFor,vl=fl(ml.prototype.valueOf),_l=ml.isRegisteredSymbol||function(e){try{return void 0!==gl(vl(e))}catch(e){return!1}};Yr({target:"Symbol",stat:!0},{isRegisteredSymbol:_l});for(var yl=li,Tl=St,El=Oe,bl=Gt,Sl=Ri,kl=Tl("Symbol"),wl=kl.isWellKnownSymbol,Il=Tl("Object","getOwnPropertyNames"),Al=El(kl.prototype.valueOf),Ol=yl("wks"),Dl=0,Nl=Il(kl),Cl=Nl.length;Dl<Cl;Dl++)try{var Rl=Nl[Dl];bl(kl[Rl])&&Sl(Rl)}catch(e){}var Ml=function(e){if(wl&&wl(e))return!0;try{for(var t=Al(e),i=0,r=Il(Ol),n=r.length;i<n;i++)if(Ol[r[i]]==t)return!0}catch(e){}return!1};Yr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:Ml}),qa("customMatcher"),qa("observable"),Yr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:_l}),Yr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:Ml}),qa("matcher"),qa("metadataKey"),qa("patternMatch"),qa("replaceAll");var Pl=Ee(pl),Ll=Oe,xl=Zr,Ul=Mn,Vl=lt,Bl=Ll("".charAt),jl=Ll("".charCodeAt),Fl=Ll("".slice),Hl=function(e){return function(t,i){var r,n,o=Ul(Vl(t)),s=xl(i),a=o.length;return s<0||s>=a?e?"":void 0:(r=jl(o,s))<55296||r>56319||s+1===a||(n=jl(o,s+1))<56320||n>57343?e?Bl(o,s):r:e?Fl(o,s,s+2):n-56320+(r-55296<<10)+65536}},Gl={codeAt:Hl(!1),charAt:Hl(!0)}.charAt,Wl=Mn,Kl=Sc,zl=qh,ql=Yh,Yl="String Iterator",Jl=Kl.set,Ql=Kl.getterFor(Yl);zl(String,"String",(function(e){Jl(this,{type:Yl,string:Wl(e),index:0})}),(function(){var e,t=Ql(this),i=t.string,r=t.index;return r>=i.length?ql(void 0,!0):(e=Gl(i,r),t.index+=e.length,ql(e,!1))}));var Xl=Ee(Va.f("iterator"));function Zl(e){return Zl="function"==typeof Pl&&"symbol"==typeof Xl?function(e){return typeof e}:function(e){return e&&"function"==typeof Pl&&e.constructor===Pl&&e!==Pl.prototype?"symbol":typeof e},Zl(e)}var $l=Ee(Va.f("toPrimitive"));function ep(e){var t=function(e,t){if("object"!==Zl(e)||null===e)return e;var i=e[$l];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==Zl(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===Zl(t)?t:String(t)}function tp(e,t,i){return(t=ep(t))in e?zo(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var ip=St,rp=Sa,np=Ma,op=br,sp=Oe([].concat),ap=ip("Reflect","ownKeys")||function(e){var t=rp.f(op(e)),i=np.f;return i?sp(t,i(e)):t},cp=_i,dp=ap,up=ze,hp=vr,lp=vt,pp=xr,fp=Error,mp=Oe("".replace),gp=String(new fp("zxcasd").stack),vp=/\n\s*at [^:]*:[^\n]*/,_p=vp.test(gp),yp=rt,Tp=!be((function(){var e=new Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",yp(1,7)),7!==e.stack)})),Ep=xr,bp=function(e,t){if(_p&&"string"==typeof e&&!fp.prepareStackTrace)for(;t--;)e=mp(e,vp,"");return e},Sp=Tp,kp=Error.captureStackTrace,wp=Hu,Ip=Ri("iterator"),Ap=Array.prototype,Op=Nn,Dp=Zt,Np=dt,Cp=Hu,Rp=Ri("iterator"),Mp=function(e){if(!Np(e))return Dp(e,Rp)||Dp(e,"@@iterator")||Cp[Op(e)]},Pp=Qe,Lp=Jt,xp=br,Up=Kt,Vp=Mp,Bp=TypeError,jp=Qe,Fp=br,Hp=Zt,Gp=gr,Wp=Qe,Kp=br,zp=Kt,qp=function(e){return void 0!==e&&(wp.Array===e||Ap[Ip]===e)},Yp=sn,Jp=De,Qp=function(e,t){var i=arguments.length<2?Vp(e):t;if(Lp(i))return xp(Pp(i,e));throw new Bp(Up(e)+" is not iterable")},Xp=Mp,Zp=function(e,t,i){var r,n;Fp(e);try{if(!(r=Hp(e,"return"))){if("throw"===t)throw i;return i}r=jp(r,e)}catch(e){n=!0,r=e}if("throw"===t)throw i;if(n)throw r;return Fp(r),i},$p=TypeError,ef=function(e,t){this.stopped=e,this.result=t},tf=ef.prototype,rf=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=Gp(t,u),g=function(e){return r&&Zp(r,"normal",e),new ef(!0,e)},v=function(e){return h?(Kp(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=Xp(e)))throw new $p(zp(e)+" is not iterable");if(qp(n)){for(o=0,s=Yp(e);s>o;o++)if((a=v(e[o]))&&Jp(tf,a))return a;return new ef(!1)}r=Qp(e,n)}for(c=l?e.next:r.next;!(d=Wp(c,r)).done;){try{a=v(d.value)}catch(e){Zp(r,"throw",e)}if("object"==typeof a&&a&&Jp(tf,a))return a}return new ef(!1)},nf=Mn,of=Yr,sf=De,af=rh,cf=Nh,df=function(e,t,i){for(var r=dp(t),n=hp.f,o=up.f,s=0;s<r.length;s++){var a=r[s];cp(e,a)||i&&cp(i,a)||n(e,a,o(t,a))}},uf=ba,hf=xr,lf=rt,pf=function(e,t){lp(t)&&"cause"in t&&pp(e,"cause",t.cause)},ff=function(e,t,i,r){Sp&&(kp?kp(e,t):Ep(e,"stack",bp(i,r)))},mf=rf,gf=function(e,t){return void 0===e?arguments.length<2?"":t:nf(e)},vf=Ri("toStringTag"),_f=Error,yf=[].push,Tf=function(e,t){var i,r=sf(Ef,this);cf?i=cf(new _f,r?af(this):Ef):(i=r?this:uf(Ef),hf(i,vf,"Error")),void 0!==t&&hf(i,"message",gf(t)),ff(i,Tf,i.stack,1),arguments.length>2&&pf(i,arguments[2]);var n=[];return mf(e,yf,{that:n}),hf(i,"errors",n),i};cf?cf(Tf,_f):df(Tf,_f,{name:!0});var Ef=Tf.prototype=uf(_f.prototype,{constructor:lf(1,Tf),message:lf(1,""),name:lf(1,"AggregateError")});of({global:!0,constructor:!0,arity:2},{AggregateError:Tf});var bf,Sf,kf,wf,If=Ce,Af=It,Of=je,Df=function(e){return Af.slice(0,e.length)===e},Nf=Df("Bun/")?"BUN":Df("Cloudflare-Workers")?"CLOUDFLARE":Df("Deno/")?"DENO":Df("Node.js/")?"NODE":If.Bun&&"string"==typeof Bun.version?"BUN":If.Deno&&"object"==typeof Deno.version?"DENO":"process"===Of(If.process)?"NODE":If.window&&If.document?"BROWSER":"REST",Cf="NODE"===Nf,Rf=St,Mf=Ua,Pf=qe,Lf=Ri("species"),xf=De,Uf=TypeError,Vf=ms,Bf=Kt,jf=TypeError,Ff=br,Hf=function(e){if(Vf(e))return e;throw new jf(Bf(e)+" is not a constructor")},Gf=dt,Wf=Ri("species"),Kf=function(e,t){var i,r=Ff(e).constructor;return void 0===r||Gf(i=Ff(r)[Wf])?t:Hf(i)},zf=TypeError,qf=/(?:ipad|iphone|ipod).*applewebkit/i.test(It),Yf=Ce,Jf=xe,Qf=gr,Xf=Ke,Zf=_i,$f=be,em=oa,tm=Aa,im=zi,rm=function(e,t){if(e<t)throw new zf("Not enough arguments");return e},nm=qf,om=Cf,sm=Yf.setImmediate,am=Yf.clearImmediate,cm=Yf.process,dm=Yf.Dispatch,um=Yf.Function,hm=Yf.MessageChannel,lm=Yf.String,pm=0,fm={},mm="onreadystatechange";$f((function(){bf=Yf.location}));var gm=function(e){if(Zf(fm,e)){var t=fm[e];delete fm[e],t()}},vm=function(e){return function(){gm(e)}},_m=function(e){gm(e.data)},ym=function(e){Yf.postMessage(lm(e),bf.protocol+"//"+bf.host)};sm&&am||(sm=function(e){rm(arguments.length,1);var t=Xf(e)?e:um(e),i=tm(arguments,1);return fm[++pm]=function(){Jf(t,void 0,i)},Sf(pm),pm},am=function(e){delete fm[e]},om?Sf=function(e){cm.nextTick(vm(e))}:dm&&dm.now?Sf=function(e){dm.now(vm(e))}:hm&&!nm?(wf=(kf=new hm).port2,kf.port1.onmessage=_m,Sf=Qf(wf.postMessage,wf)):Yf.addEventListener&&Xf(Yf.postMessage)&&!Yf.importScripts&&bf&&"file:"!==bf.protocol&&!$f(ym)?(Sf=ym,Yf.addEventListener("message",_m,!1)):Sf=mm in im("script")?function(e){em.appendChild(im("script"))[mm]=function(){em.removeChild(this),gm(e)}}:function(e){setTimeout(vm(e),0)});var Tm={set:sm,clear:am},Em=Ce,bm=qe,Sm=Object.getOwnPropertyDescriptor,km=function(){this.head=null,this.tail=null};km.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 wm,Im,Am,Om,Dm,Nm=km,Cm=/ipad|iphone|ipod/i.test(It)&&"undefined"!=typeof Pebble,Rm=/web0s(?!.*chrome)/i.test(It),Mm=Ce,Pm=function(e){if(!bm)return Em[e];var t=Sm(Em,e);return t&&t.value},Lm=gr,xm=Tm.set,Um=Nm,Vm=qf,Bm=Cm,jm=Rm,Fm=Cf,Hm=Mm.MutationObserver||Mm.WebKitMutationObserver,Gm=Mm.document,Wm=Mm.process,Km=Mm.Promise,zm=Pm("queueMicrotask");if(!zm){var qm=new Um,Ym=function(){var e,t;for(Fm&&(e=Wm.domain)&&e.exit();t=qm.get();)try{t()}catch(e){throw qm.head&&wm(),e}e&&e.enter()};Vm||Fm||jm||!Hm||!Gm?!Bm&&Km&&Km.resolve?((Om=Km.resolve(void 0)).constructor=Km,Dm=Lm(Om.then,Om),wm=function(){Dm(Ym)}):Fm?wm=function(){Wm.nextTick(Ym)}:(xm=Lm(xm,Mm),wm=function(){xm(Ym)}):(Im=!0,Am=Gm.createTextNode(""),new Hm(Ym).observe(Am,{characterData:!0}),wm=function(){Am.data=Im=!Im}),zm=function(e){qm.head||wm(),qm.add(e)}}var Jm=zm,Qm=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Xm=Ce.Promise,Zm=Ce,$m=Xm,eg=Ke,tg=lr,ig=is,rg=Ri,ng=Nf,og=Mt,sg=$m&&$m.prototype,ag=rg("species"),cg=!1,dg=eg(Zm.PromiseRejectionEvent),ug=tg("Promise",(function(){var e=ig($m),t=e!==String($m);if(!t&&66===og)return!0;if(!sg.catch||!sg.finally)return!0;if(!og||og<51||!/native code/.test(e)){var i=new $m((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[ag]=r,!(cg=i.then((function(){}))instanceof r))return!0}return!(t||"BROWSER"!==ng&&"DENO"!==ng||dg)})),hg={CONSTRUCTOR:ug,REJECTION_EVENT:dg,SUBCLASSING:cg},lg={},pg=Jt,fg=TypeError,mg=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw new fg("Bad Promise constructor");t=e,i=r})),this.resolve=pg(t),this.reject=pg(i)};lg.f=function(e){return new mg(e)};var gg,vg,_g=Yr,yg=Cf,Tg=Ce,Eg=Qe,bg=La,Sg=ac,kg=function(e){var t=Rf(e);Pf&&t&&!t[Lf]&&Mf(t,Lf,{configurable:!0,get:function(){return this}})},wg=Jt,Ig=Ke,Ag=vt,Og=function(e,t){if(xf(t,e))return e;throw new Uf("Incorrect invocation")},Dg=Kf,Ng=Tm.set,Cg=Jm,Rg=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(e){}},Mg=Qm,Pg=Nm,Lg=Sc,xg=Xm,Ug=hg,Vg=lg,Bg="Promise",jg=Ug.CONSTRUCTOR,Fg=Ug.REJECTION_EVENT,Hg=Lg.getterFor(Bg),Gg=Lg.set,Wg=xg&&xg.prototype,Kg=xg,zg=Wg,qg=Tg.TypeError,Yg=Tg.document,Jg=Tg.process,Qg=Vg.f,Xg=Qg,Zg=!!(Yg&&Yg.createEvent&&Tg.dispatchEvent),$g="unhandledrejection",ev=function(e){var t;return!(!Ag(e)||!Ig(t=e.then))&&t},tv=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&&sv(t),t.rejection=1),!0===a?i=o:(u&&u.enter(),i=a(o),u&&(u.exit(),n=!0)),i===e.promise?d(new qg("Promise-chain cycle")):(r=ev(i))?Eg(r,i,c,d):c(i)):d(o)}catch(e){u&&!n&&u.exit(),d(e)}},iv=function(e,t){e.notified||(e.notified=!0,Cg((function(){for(var i,r=e.reactions;i=r.get();)tv(i,e);e.notified=!1,t&&!e.rejection&&nv(e)})))},rv=function(e,t,i){var r,n;Zg?((r=Yg.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),Tg.dispatchEvent(r)):r={promise:t,reason:i},!Fg&&(n=Tg["on"+e])?n(r):e===$g&&Rg("Unhandled promise rejection",i)},nv=function(e){Eg(Ng,Tg,(function(){var t,i=e.facade,r=e.value;if(ov(e)&&(t=Mg((function(){yg?Jg.emit("unhandledRejection",r,i):rv($g,i,r)})),e.rejection=yg||ov(e)?2:1,t.error))throw t.value}))},ov=function(e){return 1!==e.rejection&&!e.parent},sv=function(e){Eg(Ng,Tg,(function(){var t=e.facade;yg?Jg.emit("rejectionHandled",t):rv("rejectionhandled",t,e.value)}))},av=function(e,t,i){return function(r){e(t,r,i)}},cv=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,iv(e,!0))},dv=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw new qg("Promise can't be resolved itself");var r=ev(t);r?Cg((function(){var i={done:!1};try{Eg(r,t,av(dv,i,e),av(cv,i,e))}catch(t){cv(i,t,e)}})):(e.value=t,e.state=1,iv(e,!1))}catch(t){cv({done:!1},t,e)}}};jg&&(zg=(Kg=function(e){Og(this,zg),wg(e),Eg(gg,this);var t=Hg(this);try{e(av(dv,t),av(cv,t))}catch(e){cv(t,e)}}).prototype,(gg=function(e){Gg(this,{type:Bg,done:!1,notified:!1,parent:!1,reactions:new Pg,rejection:!1,state:0,value:null})}).prototype=bg(zg,"then",(function(e,t){var i=Hg(this),r=Qg(Dg(this,Kg));return i.parent=!0,r.ok=!Ig(e)||e,r.fail=Ig(t)&&t,r.domain=yg?Jg.domain:void 0,0===i.state?i.reactions.add(r):Cg((function(){tv(r,i)})),r.promise})),vg=function(){var e=new gg,t=Hg(e);this.promise=e,this.resolve=av(dv,t),this.reject=av(cv,t)},Vg.f=Qg=function(e){return e===Kg||undefined===e?new vg(e):Xg(e)}),_g({global:!0,constructor:!0,wrap:!0,forced:jg},{Promise:Kg}),Sg(Kg,Bg,!1,!0),kg(Bg);var uv=Ri("iterator"),hv=!1;try{var lv=0,pv={next:function(){return{done:!!lv++}},return:function(){hv=!0}};pv[uv]=function(){return this},Array.from(pv,(function(){throw 2}))}catch(e){}var fv=Xm,mv=function(e,t){try{if(!t&&!hv)return!1}catch(e){return!1}var i=!1;try{var r={};r[uv]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(e){}return i},gv=hg.CONSTRUCTOR||!mv((function(e){fv.all(e).then(void 0,(function(){}))})),vv=Qe,_v=Jt,yv=lg,Tv=Qm,Ev=rf;Yr({target:"Promise",stat:!0,forced:gv},{all:function(e){var t=this,i=yv.f(t),r=i.resolve,n=i.reject,o=Tv((function(){var i=_v(t.resolve),o=[],s=0,a=1;Ev(e,(function(e){var c=s++,d=!1;a++,vv(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 bv=Yr,Sv=hg.CONSTRUCTOR;Xm&&Xm.prototype,bv({target:"Promise",proto:!0,forced:Sv,real:!0},{catch:function(e){return this.then(void 0,e)}});var kv=Qe,wv=Jt,Iv=lg,Av=Qm,Ov=rf;Yr({target:"Promise",stat:!0,forced:gv},{race:function(e){var t=this,i=Iv.f(t),r=i.reject,n=Av((function(){var n=wv(t.resolve);Ov(e,(function(e){kv(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var Dv=lg;Yr({target:"Promise",stat:!0,forced:hg.CONSTRUCTOR},{reject:function(e){var t=Dv.f(this);return(0,t.reject)(e),t.promise}});var Nv=br,Cv=vt,Rv=lg,Mv=function(e,t){if(Nv(e),Cv(t)&&t.constructor===e)return t;var i=Rv.f(e);return(0,i.resolve)(t),i.promise},Pv=Yr,Lv=Xm,xv=hg.CONSTRUCTOR,Uv=Mv,Vv=St("Promise"),Bv=!xv;Pv({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Uv(Bv&&this===Vv?Lv:this,e)}});var jv=Qe,Fv=Jt,Hv=lg,Gv=Qm,Wv=rf;Yr({target:"Promise",stat:!0,forced:gv},{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++,jv(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=Qe,zv=Jt,qv=St,Yv=lg,Jv=Qm,Qv=rf,Xv="No one promise resolved";Yr({target:"Promise",stat:!0,forced:gv},{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=Yr,$v=xe,e_=Aa,t_=lg,i_=Jt,r_=Qm,n_=Ce.Promise,o_=!1;Zv({target:"Promise",stat:!0,forced:!n_||!n_.try||r_((function(){n_.try((function(e){o_=8===e}),8)})).error||!o_},{try:function(e){var t=arguments.length>1?e_(arguments,1):[],i=t_.f(this),r=r_((function(){return $v(i_(e),void 0,t)}));return(r.error?i.reject:i.resolve)(r.value),i.promise}});var s_=lg;Yr({target:"Promise",stat:!0},{withResolvers:function(){var e=s_.f(this);return{promise:e.promise,resolve:e.resolve,reject:e.reject}}});var a_=Yr,c_=Xm,d_=be,u_=St,h_=Ke,l_=Kf,p_=Mv,f_=c_&&c_.prototype;a_({target:"Promise",proto:!0,real:!0,forced:!!c_&&d_((function(){f_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=l_(this,u_("Promise")),i=h_(e);return this.then(i?function(i){return p_(t,e()).then((function(){return i}))}:e,i?function(i){return p_(t,e()).then((function(){throw i}))}:e)}});var m_=Ee(_t.Promise);function g_(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 v_(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class __ extends y{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||T(8,"track-"),this._originMediaStreamTrack=e,this._mediaStreamTrack=e,co(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){if(!e){const e=ue.reportApiInvoke(null,{name:E.GET_MEDIA_STREAM_TRACK,options:[],tag:b.TRACER});this._mediaStreamTrack&&"string"==typeof this._mediaStreamTrack.label?e.onSuccess(this._mediaStreamTrack.label):e.onSuccess("")}return this._mediaStreamTrack}getRTCRtpTransceiver(e){return e===_o.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,uo(this),this.emit(bo.CLOSED)}_updateRtpTransceiver(e,t){if(t===_o.LOW_STREAM){if(this._lowRtpTransceiver===e)return;this._lowRtpTransceiver=e}else{if(this._rtpTransceiver===e)return;this._rtpTransceiver=e}this.emit(Eo.TRANSCEIVER_UPDATED,e,t)}}class y_ extends __{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 S("".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,de.debug("[".concat(this.getTrackId(),"] close")),this.emit(go.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 k(this,go.NEED_REPLACE_TRACK,this),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bo.TRACK_ENDED)}stateCheck(e,t){if(de.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),f(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new g(v.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",de);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new g(v.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",de)}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}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}const E_=window.AudioContext||window.webkitAudioContext;let b_=null;const S_=new class extends y{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=()=>{de.info("ios15-interruption-start"),this.emit(ye.IOS_15_16_INTERRUPTION_START)},this.onLocalAudioTrackUnmute=async()=>{de.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?de.info("ios15-interruption-end-canceled"):(b_&&await b_.suspend(),this.emit(ye.IOS_15_16_INTERRUPTION_END))}}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){de.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){de.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 k_(){if(!E_)return void de.error("your browser is not support web audio");de.info("create audio context");const t=function(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){tp(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}({},u("WEBAUDIO_INIT_OPTIONS"));de.debug("audio context init option:",JSON.stringify(t)),b_=new E_(t),S_.curState=b_.state,b_.onstatechange=()=>{S_.prevState=S_.curState,S_.curState=b_?b_.state:void 0;const{prevState:t,curState:i}=S_,r="running"===i,n="interrupted"===i,o="running"===t,s="suspended"===t,a="interrupted"===t,c=e().osVersion;(I()||A())&&o&&n&&(de.info("ios".concat(c,"-interruption-start")),S_.emit(ye.IOS_INTERRUPTION_START)),(I()||A())&&(s||a)&&r&&(de.info("ios".concat(c,"-interruption-end")),S_.emit(ye.IOS_INTERRUPTION_END)),t!==i&&S_.emit(ye.STATE_CHANGE,i,t)},setInterval((()=>{var e;const t=null===(e=b_)||void 0===e?void 0:e.currentTime;if(S_.currentTime!==t)S_.currentTimeStuckAt&&(de.debug("AudioContext current time resume at ".concat(t)),S_.currentTimeStuckAt=void 0),S_.currentTime=t;else{if(t!==S_.currentTimeStuckAt){ue.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:b.TRACER}).onSuccess(),de.warning("AudioContext current time stuck at ".concat(t))}S_.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):I()||A()?"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(I()){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)}S_.on(ye.STATE_CHANGE,c),s(!1)}(b_)}function w_(){if(!b_){if(k_(),!b_)throw new g(v.NOT_SUPPORTED,"can not create audio context");return b_}return b_}function I_(){return!!b_}function A_(e){if(function(){if(null!==D_)return D_;const e=w_(),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(),D_=n,n}())return;const t=e.connect,i=e.disconnect;e.connect=(i,r,n)=>{var o;return e._inputNodes||(e._inputNodes=[]),qn(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?w(e._inputNodes,r):e._inputNodes=[];for(const i of e._inputNodes)t.call(e,i)}}function O_(e){const t=w_();return new m_(((i,r)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{r(new g(v.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let D_=null;function N_(e,t){let i=!1;const r=1/t;if(u("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*r)}else{const t=w_();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 C_=null;function R_(){if(C_)return C_;const e=w_();if(!e.createMediaStreamDestination)throw new g(v.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),C_=r.stream.getAudioTracks()[0],C_}function M_(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 P_(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}var L_=Jt,x_=mi,U_=ct,V_=sn,B_=TypeError,j_="Reduce of empty array with no initial value",F_=function(e){return function(t,i,r,n){var o=x_(t),s=U_(o),a=V_(o);if(L_(i),0===a&&r<2)throw new B_(j_);var 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 new B_(j_)}for(;e?c>=0:a>c;c+=d)c in s&&(n=i(n,s[c],c,o));return n}},H_={left:F_(!1),right:F_(!0)},G_=be,W_=H_.left,K_=function(e,t){var i=[][e];return!!i&&G_((function(){i.call(null,t||function(){return 1},1)}))};Yr({target:"Array",proto:!0,forced:!Cf&&Mt>79&&Mt<83||!K_("reduce")},{reduce:function(e){var t=arguments.length;return W_(this,e,t,t>1?arguments[1]:void 0)}});var z_=mn("Array","reduce"),q_=De,Y_=z_,J_=Array.prototype,Q_=Ee((function(e){var t=e.reduce;return e===J_||q_(J_,e)&&t===J_.reduce?Y_:t}));class X_{constructor(){this.context=void 0,this.analyserNode=void 0,this.sourceNode=void 0,this.context=w_(),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||I()||A()||"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=Q_(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){de.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class Z_ extends y{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=w_(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),A_(this.outputNode),this.volumeLevelAnalyser=new X_}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(ko.ON_AUDIO_BUFFER,M_(e))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!_e().webAudioMediaStreamDest)throw new g(v.NOT_SUPPORTED,"your browser is not support audio processor");return this.destNode&&this.outputTrack||(this.destNode=this.context.createMediaStreamDestination(),this.outputNode.connect(this.destNode),this.outputTrack=this.destNode.stream.getAudioTracks()[0]),this.outputTrack}play(e){"running"!==this.context.state&&r((()=>{S_.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;I()||A()?"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 $_ extends Z_{get isFreeze(){return!1}constructor(t,i,r){var n;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(de.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 de.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>de.info("resume success"))),de.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),A_(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const i=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(i,this.context.currentTime),A_(this.outputNode),this.emit(ko.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=t,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()},"audio"!==t.kind)throw new g(v.UNEXPECTED_ERROR);this.track=t;const o=new MediaStream([this.track]);if(this.isRemoteTrack=!!i,this.sourceNode=this.context.createMediaStreamSource(o),A_(this.sourceNode),r){const e=r.clone();e.enabled=!0,this.clonedTrack=e,de.debug("create an unmuted track ".concat(e.id," from the original track ").concat(r.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));A_(t),this.originVolumeLevelAnalyser=new X_,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=o;const s=e();i&&s.os===a.IOS&&Number(null===(n=s.osVersion)||void 0===n?void 0:n.split(".")[0])<15&&(S_.on(ye.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),A_(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(ko.UPDATE_SOURCE),this.audioElement.srcObject=t}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),S_.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),de.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]));A_(i),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(i)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function ey(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 ty(e,t){const i=await iy(e.mediaSource),{sourceId:r,audio:n}=await D(i,t);return await ey(r,e,n)}async function iy(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);const i=N();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new g(v.ELECTRON_IS_NULL);let r=null;try{var n;r=(null===(n=i.desktopCapturer)||void 0===n?void 0:n.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){r=null}r&&r.then||(r=new m_(((e,r)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?r(t):e(i)}))})));try{return await r}catch(e){throw new g(v.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}function ry(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 ny=new S("safari");let oy=!1,sy=!1;async function ay(e,t){let i=0,r=null;for(;i<2;)try{r=await cy(e,t,i>0);break}catch(e){if(e instanceof g)throw de.error("[".concat(t,"] ").concat(e.toString())),e;const r=dy(e.name||e.code||e,e.message);if(r.code===v.MEDIA_OPTION_INVALID){de.debug("[".concat(t,"] detect media option invalid, retry")),i+=1,await O(500);continue}throw de.error("[".concat(t,"] ").concat(r.toString())),r}if(!r)throw new g(v.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return r}async function cy(t,i,r){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new g(v.NOT_SUPPORTED,"can not find getUserMedia");r&&(t.video&&(delete t.video.width,delete t.video.height),t.screen&&(delete t.screen.width,delete t.screen.height));const n=_e(),o=new MediaStream;if(t.audioSource&&o.addTrack(t.audioSource),t.videoSource&&o.addTrack(t.videoSource),!t.audio&&!t.video&&!t.screen)return de.debug("Using Video Source/ Audio Source"),o;if(t.screen)if(C())if(t.screen.sourceId){uy(o,await ey(t.screen.sourceId,t.screen,t.screenAudio))}else{uy(o,await ty(t.screen,t.screenAudio))}else if(R()&&t.screen.extensionId&&t.screen.mandatory){if(!n.getStreamFromExtension)throw new g(v.NOT_SUPPORTED,"This browser does not support screen sharing");de.debug("[".concat(i,'] Screen access on chrome stable, looking for extension"'));const e=await(a=t.screen.extensionId,l=i,new m_(((e,t)=>{try{chrome.runtime.sendMessage(a,{getStream:!0},(i=>{if(!i||!i.streamId)return de.error("[".concat(l,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new g(v.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){de.error("[".concat(l,"] AgoraRTC screensharing plugin is not accessible(").concat(a,")"),e.toString()),t(new g(v.CHROME_PLUGIN_NOT_INSTALL))}})));t.screen.mandatory.chromeMediaSourceId=e;uy(o,await navigator.mediaDevices.getUserMedia({video:{mandatory:t.screen.mandatory}}))}else if(n.getDisplayMedia){var s;t.screen.mediaSource&&mo(t.screen.mediaSource);const e={width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate,displaySurface:null!==(s=t.screen.displaySurface)&&void 0!==s?s:"screen"===t.screen.mediaSource?"monitor":t.screen.mediaSource},{selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a}=t.screen,c={selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a};!r&&delete c.selfBrowserSurface,!n&&delete c.surfaceSwitching,!a&&delete c.systemAudio,de.debug("[".concat(i,"] getDisplayMedia:"),JSON.stringify({video:e,audio:!!t.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?ry(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):ry(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({video:e,audio:!!t.screenAudio},c));uy(o,d)}else{if(!h())throw de.error("[".concat(i,"] This browser does not support screenSharing")),new g(v.NOT_SUPPORTED,"This browser does not support screen sharing");{t.screen.mediaSource&&mo(t.screen.mediaSource);const e={video:{mediaSource:t.screen.mediaSource,width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate}};de.debug("[".concat(i,"] getUserMedia: ").concat(JSON.stringify(e)));uy(o,await navigator.mediaDevices.getUserMedia(e))}}var a,l;if(!t.video&&!t.audio)return o;let p={video:t.video,audio:t.audio},f=u("MEDIA_DEVICE_CONSTRAINTS");if(f)try{"string"==typeof f&&(f=JSON.parse(f)),p=M(p,f)}catch(e){}de.debug("[".concat(i,"] GetUserMedia"),JSON.stringify(p)),e();let m,_=null;(c()||I()||d())&&(_=await ny.lock());try{m=await navigator.mediaDevices.getUserMedia(p)}catch(e){throw _&&_(),e}return p.audio&&(oy=!0),p.video&&(sy=!0),uy(o,m),_&&_(),o}function dy(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new g(v.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new g(v.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new g(v.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new g(v.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new g(v.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new g(v.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return de.error("getUserMedia unexpected error",e),new g(v.UNEXPECTED_ERROR,"".concat(e,": ").concat(t))}}function uy(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 hy extends y{get state(){return this._state}set state(e){e!==this._state&&(this.emit(Lo.STATE_CHANGE,e),this._state=e)}constructor(){super(),this._state=Po.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((()=>{(u("ENUMERATE_DEVICES_INTERVAL")||(P()||L())&&i())&&this.updateDevicesInfo()}),u("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>de.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 g(v.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const r=await navigator.mediaDevices.enumerateDevices(),n=this.checkMediaDeviceInfoIsOk(r);let o=!this.isAccessMicrophonePermission&&e,s=!this.isAccessCameraPermission&&t;n.audio&&(o=!1),n.video&&(s=!1);let a=null,c=null,d=null;if(!i&&(o||s)){if(ny.isLocked){de.debug("[device manager] wait GUM lock");(await ny.lock())(),de.debug("[device manager] GUM unlock")}if(oy&&(o=!1,this.isAccessMicrophonePermission=!0),sy&&(s=!1,this.isAccessCameraPermission=!0),de.debug("[device manager] check media device permissions",e,t,o,s),o&&s){try{d=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=dy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(o){try{a=await navigator.mediaDevices.getUserMedia({audio:e})}catch(e){const t=dy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(s){try{c=await navigator.mediaDevices.getUserMedia({video:t})}catch(e){const t=dy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}de.debug("[device manager] mic permission",e,"cam permission",t)}try{const e=await navigator.mediaDevices.enumerateDevices();return a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null,e}catch(e){a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null;return new g(v.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 g(v.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=Po.INITING;try{await this.updateDevicesInfo(),this.state=Po.INITEND}catch(e){if(de.warning("Device Detection functionality cannot start properly.",e.toString()),this.state=Po.IDLE,!x()){new g(v.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?de.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is the same group")):de.warning("[device-check] default input ".concat(t.label," and output ").concat(i.label," is not the same group")):de.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!==Po.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(Lo.RECORDING_DEVICE_CHANGED,e);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(Lo.CAMERA_DEVICE_CHANGED,e);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(Lo.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 ly=new hy;let py=!1;const fy=new class extends y{constructor(){super(...arguments),this.onAutoplayFailed=void 0,this.onAudioAutoplayFailed=void 0}};function my(){if(e(),!py){const e=t=>{t.preventDefault(),py=!1,U()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};py=!0,U()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),de.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),fy.onAutoplayFailed?fy.onAutoplayFailed():fy.onAudioAutoplayFailed?de.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 ."):de.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 ."),fy.emit("autoplay-failed")}}function gy(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 vy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?gy(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):gy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function _y(e,t,i,r){if(!e)return;const n=ue.getBaseInfoBySessionId(e);if(!n)return;const o=n.info,s=Date.now(),a=vy(vy({},o),{},{vid:void 0===o.vid?0:Number(o.vid),lts:s,elapse:s-n.startTime,cbRegistered:fy.onAutoplayFailed||fy.onAudioAutoplayFailed?1:-1,errorMsg:i,mediaType:t,trackId:r,extend:void 0});ue.send({type:he.AUTOPLAY_FAILED,data:a},!0)}const yy=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],Ty=new class{constructor(){this.onAutoplayFailed=void 0,this.elementMap=new Map,this.elementStateMap=new Map,this.elementsNeedToResume=[],this.sinkIdMap=new Map,this.autoResumeAfterInterruption=e=>{Array.from(this.elementMap.entries()).forEach((t=>{let[i,r]=t;const n=this.elementStateMap.get(i),o=r.srcObject.getAudioTracks()[0],s=o&&o.readyState;if(de.debug("resume after interrupted, ele: ".concat(n," audio: ").concat(s," ").concat(e)),"live"===s){if(e)return r.pause(),void r.play();if("running"===S_.curState)return V()?(r.pause(),void r.play()):void(n&&"paused"===n&&r.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&&(de.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))},this.autoResumeAudioElement(),S_.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),S_.on(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),S_.on(ye.STATE_CHANGE,(()=>{I()&&"suspended"===S_.prevState&&"running"===S_.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 g(v.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(e,t,i,n){if(this.elementMap.has(t))return;const o=document.createElement("audio");o.autoplay=!0,o.srcObject=new MediaStream([e]),this.bindAudioElementEvents(t,o),this.elementMap.set(t,o),this.elementStateMap.set(t,xo.INIT),this.setVolume(t,i);const s=this.sinkIdMap.get(t);if(s)try{o.setSinkId(s).catch((e=>{de.warning("[".concat(t,"] set sink id failed"),e.toString())}))}catch(e){de.warning("[".concat(t,"] set sink id failed"),e.toString())}const a=o.play();a&&a.then&&a.catch((e=>{n&&_y(n,"audio",e.message,t),de.warning("audio element play warning",e.toString()),this.elementMap.has(t)&&"NotAllowedError"===e.name&&(de.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(o),r((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),my()})))}))}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){yy.forEach((i=>{t.addEventListener(i,(i=>{const r=this.elementStateMap.get(e),n="pause"===i.type?"paused":i.type;if(de.debug("[".concat(e,"] audio-element-status change ").concat(r," => ").concat(n)),"error"===i.type){const i=null==t?void 0:t.error;i&&de.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=>{de.debug("Auto resume audio element success")})).catch((e=>{de.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};B().then((()=>{U()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function Ey(){return function(e,t,i){const r=i.value;return"function"==typeof r&&(i.value=function(){this._isClosed&&new g(v.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",de);for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=r.apply(this,t);return n instanceof m_?new m_(((e,t)=>{n.then(e).catch(t)})):n}),i}}var by=mn("Array","values"),Sy=Nn,ky=_i,wy=De,Iy=by,Ay=Array.prototype,Oy={DOMTokenList:!0,NodeList:!0},Dy=Ee((function(e){var t=e.values;return e===Ay||wy(Ay,e)&&t===Ay.values||ky(Oy,Sy(e))?Iy:t}));function Ny(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 Cy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Ny(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Ny(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class Ry extends y{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 g(v.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new g(v.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(Ro.ON_TRACK,e.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(Ro.ON_TRACK,void 0)}}class My extends y{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 j(this,Mo.REQUEST_CONSTRAINTS)}async requestApplyConstraints(e,t){var i;return de.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),k(this,Mo.REQUEST_UPDATE_CONSTRAINTS,Array.from(Dy(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return de.info("processor ".concat(e.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(e),k(this,Mo.REQUEST_UPDATE_CONSTRAINTS,Array.from(Dy(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:n}of this.statsRegistry)try{const o=n();e.push({processorID:t,processorName:i,type:r,stats:o})}catch(e){de.error(new g(v.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 m_&&(i=await i),e.push(Cy(Cy({},i),{},{direction:this.direction}))}catch(e){de.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class Py extends y{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 g(v.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new g(v.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(Ro.ON_TRACK,void 0),this.emit(Ro.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(Ro.ON_TRACK,this.inputTrack)),e.node&&this.inputNode!==e.node&&(this.audioProcessorContext.chained=!0,this.inputNode=e.node,this.emit(Ro.ON_NODE,this.inputNode))}}class Ly extends y{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 j(this,Mo.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(e,t){var i;return de.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),k(this,Mo.REQUEST_UPDATE_CONSTRAINTS,Array.from(Dy(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return this.constraintsMap.delete(e),k(this,Mo.REQUEST_UPDATE_CONSTRAINTS,Array.from(Dy(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:n}of this.statsRegistry)try{const o=n();e.push({processorID:t,processorName:i,type:r,stats:o})}catch(e){de.error(new g(v.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 m_&&(i=await i),e.push(Cy(Cy({},i),{},{direction:this.direction}))}catch(e){de.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class xy extends y{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 Uy}setVolume(){}createOutputTrack(){throw new g(v.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 Uy{disconnect(){}connect(){}}let Vy=null;class By{constructor(){this.state="open",this.trigger=void 0,this.tasks=[],de.debug("[macro-task-queue] is created."),this.trigger=window.setTimeout((()=>{this.state="closed",de.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,de.debug("[macro-task-queue] is closed.")}))}enqueue(e,t){"closed"!==this.state&&(this.tasks.push({key:e,func:t}),de.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);de.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,de.debug("[macro-task-queue] is closed."))}}function jy(e){return function(t,i,r){var n;const o=null!==(n=r.value)&&void 0!==n?n:r.get,s=function(){Vy&&"open"===Vy.state&&Vy.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 Fy(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 Hy(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Fy(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Fy(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class Gy extends y_{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?Ty.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 Ly(this._source.context,this.getTrackId(),"local"),this.processorDestination=new Py(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(ko.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))},s=n&&c()&&!I_();if(u("DISABLE_WEBAUDIO")?(this._source=new xy,this._useAudioElement=!0,this._bypassWebAudio=!0):s?this._source=new xy:(this._source=new $_(e,!1,this._getOriginVolumeLevel?e:void 0),u("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0)),o(),!u("DISABLE_WEBAUDIO")&&s){(Vy||(Vy=new By),Vy).enqueue("INIT_WEBAUDIO",(()=>{this._source=new $_(e,!1,this._getOriginVolumeLevel?e:void 0),u("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0),o(),this.emit(wo.UPDATE_TRACK_SOURCE)}))}}setVolume(e){p(e,"volume",0,1e3),this._volume=e,this._source.setVolume(e/100),this._useAudioElement&&Ty.setVolume(this.getTrackId(),e);try{if(this._bypassWebAudio)return void de.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const e=this._source.createOutputTrack();this._mediaStreamTrack!==e&&(this._mediaStreamTrack=e,k(this,go.NEED_REPLACE_TRACK,this).then((()=>{de.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{de.warning("[".concat(this.getTrackId(),"] replace web audio track failed"),e)})))}catch(e){}}getVolumeLevel(){return this._muted&&this.enabled&&this._getOriginVolumeLevel?this._source.getOriginVolumeLevel():this._source.getAccurateVolumeLevel()}async setPlaybackDevice(e){if(!this._useAudioElement||!R()&&u("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new g(v.NOT_SUPPORTED,"your browser does not support setting the audio output device");await Ty.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(de.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){this._originMediaStreamTrack.enabled=!0;try{i||(this._enabled=!0),await k(this,go.NEED_ENABLE_TRACK,this),de.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(e," success"))}catch(e){throw i||(this._enabled=!1),de.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,i||(this._enabled=!1);try{await k(this,go.NEED_DISABLE_TRACK,this)}catch(e){throw i||(this._enabled=!0),de.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,de.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await k(this,go.NEED_MUTE_TRACK,this):await k(this,go.NEED_UNMUTE_TRACK,this))}getStats(){H((()=>{de.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const e=G(this,go.GET_STATS);return e||Hy({},Ao)}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(ko.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(ko.ON_AUDIO_BUFFER),this._source.on(ko.ON_AUDIO_BUFFER,(t=>e(t)))}play(){de.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(de.debug("[".concat(this.getTrackId(),"] start audio playback in element")),Ty.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){de.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?Ty.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];de.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&Ty.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 k(this,go.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(e))}renewMediaStreamTrack(e){return m_.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new g(v.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new g(v.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(Ro.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e),await k(this,go.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await k(this,go.NEED_REPLACE_TRACK,this))})),this.processorDestination.on(Ro.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(Ro.ON_TRACK),this.processorDestination.removeAllListeners(Ro.ON_NODE)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Mo.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Mo.REQUEST_CONSTRAINTS)}}g_([jy("INIT_WEBAUDIO"),v_("design:type",Object),v_("design:paramtypes",[Object])],Gy.prototype,"_source",null),g_([jy("INIT_WEBAUDIO"),v_("design:type",Ly),v_("design:paramtypes",[Ly])],Gy.prototype,"processorContext",null),g_([jy("INIT_WEBAUDIO"),v_("design:type",Py),v_("design:paramtypes",[Py])],Gy.prototype,"processorDestination",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),v_("design:type",Function),v_("design:paramtypes",[Number]),v_("design:returntype",void 0)],Gy.prototype,"setVolume",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[String]),v_("design:returntype",m_)],Gy.prototype,"setPlaybackDevice",null),g_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean,Object,Boolean]),v_("design:returntype",m_)],Gy.prototype,"setEnabled",null),g_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean]),v_("design:returntype",m_)],Gy.prototype,"setMuted",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",Object)],Gy.prototype,"getStats",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[Object,Number]),v_("design:returntype",void 0)],Gy.prototype,"setAudioFrameCallback",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Gy.prototype,"play",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Gy.prototype,"stop",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Gy.prototype,"close",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",Object)],Gy.prototype,"pipe",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Gy.prototype,"unpipe",null);class Wy extends Gy{get __className__(){return"MicrophoneAudioTrack"}constructor(e,t,i,r){super(e,t.encoderConfig?so(t.encoderConfig):{},r,u("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())&&S_.bindInterruptDetectorTrack(this),this.on(wo.UPDATE_TRACK_SOURCE,(()=>{this.bindProcessorContextEvents()})),I_()&&this.bindProcessorContextEvents()}async setDevice(e){if(de.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await ly.getDeviceById(e),i={};i.audio=Hy({},this._constraints),i.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let r=null;try{r=await ay(i,this.getTrackId())}catch(e){throw de.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await ay({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 de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await ly.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(e,t,i){if(t)return de.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(de.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 k(this,go.NEED_DISABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const n=Hy({},this._constraints),o=ly.searchDeviceIdByName(this._deviceName);o&&!n.deviceId&&(n.deviceId=o);try{i||(this._enabled=!0);const e=await ay({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!1),await k(this,go.NEED_ENABLE_TRACK,this)}catch(e){throw i||(this._enabled=!1),de.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(V()||W())&&S_.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((I()||A())&&this._enabled&&!this._isClosed&&S_.duringInterruption){const e=async()=>{S_.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(de.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};S_.on(ye.IOS_INTERRUPTION_END,e)}else de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bo.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=ly.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId=i),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await ay({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(){this.processorContext.on(Mo.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(Mo.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[String]),v_("design:returntype",m_)],Wy.prototype,"setDevice",null),g_([F("MicrophoneAudioTrack","_enabledMutex"),le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean,Boolean,Boolean]),v_("design:returntype",m_)],Wy.prototype,"setEnabled",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Wy.prototype,"close",null);class Ky extends Gy{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(ko.AUDIO_SOURCE_STATE_CHANGE,(e=>{this.safeEmit(bo.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){p(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}g_([le({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",void 0)],Ky.prototype,"startProcessAudioBuffer",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Ky.prototype,"pauseProcessAudioBuffer",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Number]),v_("design:returntype",void 0)],Ky.prototype,"seekAudioBuffer",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Ky.prototype,"resumeProcessAudioBuffer",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Ky.prototype,"stopProcessAudioBuffer",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],Ky.prototype,"close",null),g_([le({argsMap:e=>[e.getTrackId()]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Number]),v_("design:returntype",void 0)],Ky.prototype,"setAudioBufferPlaybackSpeed",null);class zy extends Gy{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=w_().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,T(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)?(de.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):de.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){de.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}w(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 zy?t.emit(Eo.TRANSCEIVER_UPDATED,e):t._updateRtpTransceiver(e)})))}}function qy(e){const t={};e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId});const i=io(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),h()&&(t.frameRate={ideal:30,max:30}),t}function Yy(e){const t={};e.screenSourceType&&(t.mediaSource=e.screenSourceType),e.extensionId&&R()&&(t.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:r,surfaceSwitching:o,systemAudio:s}=e;(n(107)||q(107)||Y(93))&&(i&&(m(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),r?(m(r,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=r):t.selfBrowserSurface="include",o&&(m(o,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=o)),(n(105)||q(105)||Y(91))&&s&&(m(s,"systemAudio",["exclude","include"]),t.systemAudio=s),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const a=e.encoderConfig?ro(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 Jy(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=so(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 Qy extends Z_{set currentState(e){e!==this._currentState&&(this._currentState=e,this.safeEmit(ko.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):de.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 Xy=new Map;const Zy=e=>{const t=document.createElement("canvas");return t.width=2,t.height=2,new m_(((i,r)=>{t.toBlob((async e=>{if(t.remove(),e){const r=await $y(e);i({buffer:r,width:t.width,height:t.height})}else r(new g(v.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},$y=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};const eT=new class extends y{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(),de.debug("document visibility went ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}};function tT(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 iT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?tT(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):tT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class rT{get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(de.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=xo.NONE,this.isGettingVideoDimensions=!1,this.startGetVideoDimensions=()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return de.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"===S_.curState&&(de.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=xo.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=xo.CANPLAY;break;case"stalled":this.videoElementStatus=xo.STALLED;break;case"suspend":this.videoElementStatus=xo.SUSPEND;break;case"pause":this.videoElementStatus=xo.PAUSED,I()||A()||c()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(de.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=xo.WAITING;break;case"abort":this.videoElementStatus=xo.ABORT;break;case"ended":this.videoElementStatus=xo.ENDED;break;case"emptied":this.videoElementStatus=xo.EMPTIED;break;case"error":{this.videoElementStatus=xo.ERROR;const e=this.videoElement.error;e&&de.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,eT.lastVisibleTime<eT.lastHiddenTime||i<eT.lastHiddenTime||i<eT.lastVisibleTime)return;for(t>u("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&&(de.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"),S_.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),S_.on(ye.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(t){const i=this.videoElement.play();i&&i.catch&&i.catch((e=>{t&&_y(t,"video",e.message,this.trackId),"NotAllowedError"===e.name?(de.warning("detected video element autoplay failed",e),this.autoplayFailed=!0,this.handleAutoPlayFailed()):de.warning("[".concat(this.trackId,"] play warning: "),e)}));const r=e();if(("Safari"===r.name&&15===Number(r.version)||V())&&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 de.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 m_(((r,n)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await $y(e);r({buffer:t,width:i.width,height:i.height})}else n(new g(v.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await Zy(e)}destroy(){S_.off(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),S_.off(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[]}initVideoElement(){if(this.videoElementStatus=xo.INIT,!this.videoElementCheckInterval&&(nT.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{Z(this.videoElement)||(this.videoElementStatus=xo.DESTROYED)}),1e3),u("ENABLE_VIDEO_FRAME_CALLBACK"))){var t,i;let e;const r=(t,i)=>{if(this.videoElementStatus===xo.PLAYING){if(e){const t=i.presentationTime-e.presentationTime;t>u("VIDEO_FREEZE_DURATION")&&eT.lastVisibleTime>=eT.lastHiddenTime&&e.timestamp>eT.lastVisibleTime&&e.timestamp>eT.lastHiddenTime&&(this.renderFreezeAccTime+=t)}e=iT(iT({},i),{},{timestamp:t})}var n,o;u("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(n=(o=this.videoElement).requestVideoFrameCallback)||void 0===n||n.call(o,r))};null===(t=(i=this.videoElement).requestVideoFrameCallback)||void 0===t||t.call(i,r)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),P()&&(this.videoElement.poster="noposter");const r=e();if("Safari"===r.name&&15===Number(r.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,h()&&this.videoElement.load())}else this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,h()&&this.videoElement.load();const n=this.videoElement.play();void 0!==n&&n.catch((e=>{de.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=xo.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{de.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{de.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)),my()}}const nT=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class oT 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 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 Zy(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",u("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 sT(e){return new m_(((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=I()?"canplay":"playing";n.addEventListener(o,(()=>{const e=n.videoWidth,i=n.videoHeight;!e&&h()||(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 aT(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 cT=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 dT(e,t){if("VideoFrame"in window&&"TransformStream"in window&&_e().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 uT(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 hT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?uT(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):uT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class lT extends y_{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==xo.PLAYING)}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(e,i,r,n,o,s){if(super(e,o),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,c()){const{width:t,height:i}=e.getSettings();this._videoWidth=t,this._videoHeight=i}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=i,this._scalabilityMode=r,this._optimizationMode=n,this._hints=s||[],-1===this._hints.indexOf(vo.SCREEN_TRACK))this.updateBitrateFromProfile();else if(ie(t.CHROME,115)&&re()){const t=dT(e);t&&(de.info("local screen video track begin to inject frame"),this._mediaStreamTrack=t)}i&&-1!==this._hints.indexOf(vo.CUSTOM_TRACK)&&this.setEncoderConfiguration(i),this.processorContext=new My(this.getTrackId(),"local"),this.processorDestination=new Ry(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:(de.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}de.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=hT(hT(hT({},this._getDefaultPlayerConfig()),t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new rT(i):this._player=new oT(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(bo.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),u("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,de.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(de.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){this._originMediaStreamTrack.enabled=!1;try{await k(this,go.NEED_DISABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return t||(this._enabled=!1),void de.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await k(this,go.NEED_ENABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}de.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,de.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await k(this,go.NEED_MUTE_TRACK,this):await k(this,go.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(e,t){if(!this._enabled)throw new g(v.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=io(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=qy({encoderConfig:e});(c()||I()||A())&&(t.deviceId=void 0),de.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 g(v.UNEXPECTED_ERROR,e.toString());throw de.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=e,-1===this._hints.indexOf(vo.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,go.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}getStats(){H((()=>{de.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const e=G(this,go.GET_STATS);return e||hT({},Oo)}async setBeautyEffect(e){de.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 Zy(e)}async setBitrateLimit(e){if(de.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 k(this,go.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}}async setOptimizationMode(e){if("motion"!==e&&"detail"!==e&&"balanced"!==e)return void de.error(v.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const t=this._optimizationMode;try{this._optimizationMode=e,await k(this,go.SET_OPTIMIZATION_MODE,this)}catch(e){throw this._optimizationMode=t,de.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(e,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return de.error(v.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,de.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){sT(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 g(v.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");de.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(e)),e=io(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(vo.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,go.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:t,frameRate:i}=this.getMediaStreamTrackSettings();if(!e||!t||!i)return;const[r,n]=aT(e,t,i,u("BITRATE_ADAPTER_TYPE"))||[void 0,void 0];this._encoderConfig.bitrateMin||this._encoderConfig.bitrateMax||(this._encoderConfig.bitrateMin=n,this._encoderConfig.bitrateMax=r,de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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 g(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new g(v.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=hT(hT({},i),io(e))),i=oe(i);const r=T(8,"track-video-cloned-"),n=new lT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,i,oe(this._scalabilityMode),this._optimizationMode,r,oe(this._hints));return e&&i&&n.setEncoderConfiguration(i),de.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 g(v.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new g(v.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}startMonitorStats(){if(!c()&&!I())return;this._statsTimer&&window.clearInterval(this._statsTimer);let e=2,t=$n[e];let i=-1;let r=Date.now();const n=e=>{e>2||e<0||(r=Date.now(),t=$n[e],this.setSenderConfiguration(t))};this.isUseScaleResolutionDownBy=!0,this._statsTimer=window.setInterval((()=>{const o=this.getStats(),s=G(this,go.GET_RTC_STATS);if(o.sendPackets>0&&s){-1===i&&(i=Date.now());const a=Date.now();if(a-i<1e3||a-r<u("PROFILE_SWITCH_INTERVAL"))return;const c=o.sendFrameRate,d=.6*t.frameRate,h=.9*t.frameRate;"number"==typeof c&&c>0&&c<d?e>0&&(e--,n(e),de.debug("[".concat(this.getTrackId(),"] step down for fps ").concat(c,", switchProfile to ").concat(e))):s.OutgoingAvailableBandwidth<t.bitrateMin?e>0&&(e--,n(e),de.debug("[".concat(this.getTrackId(),"] step down for OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", bitrateMin ").concat(t.bitrateMin,", switchProfile to ").concat(e))):"number"==typeof c&&c>h&&e<$n.length-1&&s.OutgoingAvailableBandwidth>1.2*$n[e+1].bitrateMin&&(e++,n(e),de.debug("[".concat(this.getTrackId(),"] step up for fps ").concat(c,", OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", switchProfile to ").concat(e)))}}),u("CHECK_LOCAL_STATS_INTERVAL"))}bindProcessorDestinationEvents(){this.processorDestination.on(Ro.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(),await k(this,go.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await k(this,go.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(Ro.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Mo.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Mo.REQUEST_CONSTRAINTS)}}g_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Object,Object]),v_("design:returntype",void 0)],lT.prototype,"play",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],lT.prototype,"stop",null),g_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean,Boolean]),v_("design:returntype",m_)],lT.prototype,"setEnabled",null),g_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean]),v_("design:returntype",m_)],lT.prototype,"setMuted",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Object,Boolean]),v_("design:returntype",m_)],lT.prototype,"setEncoderConfiguration",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",Object)],lT.prototype,"getStats",null),g_([le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean,Object]),v_("design:returntype",m_)],lT.prototype,"setBeautyEffect",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",ImageData)],lT.prototype,"getCurrentFrameData",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[String,Number]),v_("design:returntype",m_)],lT.prototype,"getCurrentFrameImage",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",m_)],lT.prototype,"setBitrateLimit",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[String]),v_("design:returntype",m_)],lT.prototype,"setOptimizationMode",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",void 0)],lT.prototype,"setScalabiltyMode",null),g_([Ey(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],lT.prototype,"updateMediaStreamTrackResolution",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",Object)],lT.prototype,"pipe",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],lT.prototype,"unpipe",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],lT.prototype,"close",null),g_([le({argsMap:(e,t,i)=>[e.getTrackId(),t.label,i]}),v_("design:type",Function),v_("design:paramtypes",[MediaStreamTrack,Boolean]),v_("design:returntype",m_)],lT.prototype,"replaceTrack",null),g_([le(),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],lT.prototype,"startMonitorStats",null);class pT extends lT{get __className__(){return"CameraVideoTrack"}constructor(e,t,i,r,n,o){super(e,io(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&&(de.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=io(this._config.encoderConfig),S_.on(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),S_.on(ye.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(de.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await ly.getDeviceById(e),i={};i.video=hT({},this._constraints),i.video.deviceId={exact:e},i.video.facingMode=void 0,this._originMediaStreamTrack.stop();let r=null;try{r=await ay(i,this.getTrackId())}catch(e){throw de.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await ay({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 de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await ly.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){de.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:hT(hT({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await ay(t,this.getTrackId())}catch(t){throw de.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await ay({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=hT({},t.video),de.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(de.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await ay({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await k(this,go.NEED_ENABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),de.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 k(this,go.NEED_DISABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(e,t){if(!this._enabled)throw new g(v.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=io(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=qy(i);(c()||I()||A())&&(r.deviceId=void 0),de.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 g(v.UNEXPECTED_ERROR,e.toString());throw de.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(vo.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,go.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((I()||A())&&this._enabled&&!this._isClosed&&S_.duringInterruption){const e=async()=>{S_.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(de.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};S_.on(ye.IOS_INTERRUPTION_END,e)}else de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(bo.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=ly.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId={exact:i}),this._enabled){const e=await ay({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),S_.off(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),S_.off(ye.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this._encoderConfig;e&&(i=hT(hT({},i),io(e))),i=oe(i);const r=T(8,"track-cam-cloned-"),n=new pT(t?this._mediaStreamTrack.clone():this._mediaStreamTrack,oe(hT(hT({},this._config),{},{encoderConfig:i})),oe(this._constraints),oe(this._scalabilityMode),this._optimizationMode,r);return e&&i&&n.setEncoderConfiguration(i),de.debug("clone track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(t)),n}bindProcessorContextEvents(){this.processorContext.on(Mo.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(Mo.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}function fT(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 mT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?fT(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):fT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function gT(e){const t=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),i=new Gy(e.mediaStreamTrack,e.encoderConfig?so(e.encoderConfig):{},T(8,"track-cus-"),!1,!0);return de.info("create custom audio track success with config",e,"trackId",i.getTrackId()),t.onSuccess(i.getTrackId()),i}async function vT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_MIC_AUDIO_TRACK,options:[e]}),i=Jy(e),r=T(8,"track-mic-");let n=null;de.info("start create microphone audio track with config",JSON.stringify(e),"trackId",r);try{n=(await ay({audio:i},r)).getAudioTracks()[0]||null}catch(e){throw t.onError(e),e}if(!n){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(de)}const o=new Wy(n,e,i,r);return t.onSuccess(o.getTrackId()),de.info("create microphone audio track success, trackId:",r),o}async function _T(e){var t;const{cacheOnlineFile:i,encoderConfig:r}=e;let{source:n}=e;const o={source:n instanceof AudioBuffer?"AudioBuffer":n instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":n,cacheOnlineFile:i,encoderConfig:r},s=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_BUFFER_AUDIO_TRACK,options:[o]});if(u("DISABLE_WEBAUDIO"))throw new g(v.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const a=T(8,"track-buf-");de.info("start create buffer source audio track with config",JSON.stringify(o),"trackId",a);const c=n;if(!(n instanceof AudioBuffer))try{n=await async function(e,t){let i=null;if("string"==typeof e){const t=Xy.get(e);if(t)return de.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 g(v.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new m_(((t,i)=>{const r=new FileReader;r.onload=e=>{e.target?t(e.target.result):i(new g(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.onerror=()=>{i(new g(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.readAsArrayBuffer(e)}));i=await t}const r=await O_(i);return"string"==typeof e&&t&&Xy.set(e,r),r}(n,i)}catch(e){return s.onError(e),e.throw(de)}const d=new Qy(n),h=new Ky(c,d,r?so(r):{},a);return de.info("create buffer source audio track success, trackId:",a),s.onSuccess(h.getTrackId()),h}function yT(e){const t=new zy;return e.forEach((e=>t.addAudioTrack(e))),t}function TT(e){const t=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_CUSTOM_VIDEO_TRACK,options:[e]}),i=new lT(e.mediaStreamTrack,{width:e.width,height:e.height,frameRate:e.frameRate,bitrateMax:e.bitrateMax,bitrateMin:e.bitrateMin},e.scalabiltyMode?no(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,T(8,"track-cus-"),[vo.CUSTOM_TRACK]);return t.onSuccess(i.getTrackId()),de.info("create custom video track success with config",e,"trackId",i.getTrackId()),i}async function ET(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_CAM_VIDEO_TRACK,options:[mT({},e)]}),i=qy(e),r=T(8,"track-cam-");let n=null;const o="720p_auto"===e.encoderConfig;de.info("start create camera video track with config",JSON.stringify(e),"trackId",r);try{n=(await ay({video:i},r)).getVideoTracks()[0]||null}catch(e){throw t.onError(e),e}if(!n){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(de)}e.optimizationMode&&kT(r,n,e,io(e.encoderConfig));const s=new pT(n,e,i,e.scalabiltyMode?no(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,r);return o&&s.startMonitorStats(),t.onSuccess(s.getTrackId()),de.info("create camera video success, trackId:",r),s}async function bT(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_MIC_AND_CAM_TRACKS,options:[e,t]}),r="720p_auto"===t.encoderConfig,n=qy(t),o=Jy(e),s=T(8,"track-mic-"),a=T(8,"track-cam-");let c=null,d=null;de.info("start create camera video track(".concat(a,") and microphone audio track(").concat(s,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await ay({audio:o,video:n},"".concat(s,"-").concat(a));c=e.getAudioTracks()[0],d=e.getVideoTracks()[0]}catch(e){throw i.onError(e),e}if(!c||!d){const e=new g(v.UNEXPECTED_ERROR,"can not find tracks in media stream");return i.onError(e),e.throw(de)}t.optimizationMode&&kT(a,d,t,io(t.encoderConfig));const u=new Wy(c,e,o,s),h=new pT(d,t,n,t.scalabiltyMode?no(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,a);return r&&h.startMonitorStats(),i.onSuccess([u.getTrackId(),h.getTrackId()]),de.info("create camera video track(".concat(a,") and microphone audio track(").concat(s,") success")),[u,h]}async function ST(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const i=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_SCREEN_VIDEO_TRACK,options:[mT({},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 n=Yy(e),o=T(8,"track-scr-v-");let s=null,a=null;const c=_e();if(!c.supportShareAudio&&"enable"===t){const e=new g(v.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return i.onError(e),e.throw(de)}de.info("start create screen video track with config",e,"withAudio",t,"trackId",o);try{const e=await ay({screen:n,screenAudio:"auto"===t?c.supportShareAudio:"enable"===t},o);s=e.getVideoTracks()[0]||null,a=e.getAudioTracks()[0]||null}catch(e){throw i.onError(e),e}if(!s){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(de)}if(!a&&"enable"===t){s&&s.stop();const e=new g(v.SHARE_AUDIO_NOT_ALLOWED);return i.onError(e),e.throw(de)}if(e.optimizationMode||(e.optimizationMode="detail"),e.optimizationMode){kT(o,s,e,e.encoderConfig&&ro(e.encoderConfig)||void 0),e.encoderConfig&&"string"!=typeof e.encoderConfig&&(e.encoderConfig.bitrateMin=e.encoderConfig.bitrateMax)}const d=new lT(s,e.encoderConfig?ro(e.encoderConfig):{},e.scalabiltyMode?no(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,o,[vo.SCREEN_TRACK]);if(r&&d.startMonitorStats(),!a)return i.onSuccess(d.getTrackId()),de.info("create screen video track success","video:",d.getTrackId()),d;const u=new Gy(a,void 0,T(8,"track-scr-a-"),!1,!0);return i.onSuccess([d.getTrackId(),u.getTrackId()]),de.info("create screen video track success","video:",d.getTrackId(),"audio:",u.getTrackId()),[d,u]}function kT(e,t,i,r){i.optimizationMode&&(r&&r.width&&r.height?(i.encoderConfig=mT(mT({},r),{},{bitrateMin:r.bitrateMin,bitrateMax:r.bitrateMax}),"motion"!==i.optimizationMode&&"detail"!==i.optimizationMode||(t.contentHint=i.optimizationMode,t.contentHint===i.optimizationMode?de.debug("[".concat(e,"] set content hint to"),i.optimizationMode):de.debug("[".concat(e,"] set content hint failed")))):de.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}function wT(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 IT(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?wT(Object(i),!0).forEach((function(t){tp(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):wT(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",m_)],pT.prototype,"setDevice",null),g_([F("CameraVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Boolean,Boolean]),v_("design:returntype",m_)],pT.prototype,"setEnabled",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),Ey(),v_("design:type",Function),v_("design:paramtypes",[Object,Boolean]),v_("design:returntype",m_)],pT.prototype,"setEncoderConfiguration",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],pT.prototype,"close",null);class AT extends __{getUserId(){return this._userId}constructor(e,t,i,r){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(r.clientId,"_").concat(T(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,de.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}class OT extends AT{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==xo.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 My(this.getTrackId(),"remote"),this.processorDestination=new Ry(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){H((()=>{de.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return G(this,go.GET_STATS)||IT({},Co)}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:(de.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}de.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=IT(IT({fit:"cover"},t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new rT(i):this._player=new oT(i),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(So.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(So.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),u("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,de.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){sT(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch($)}_updatePlayerSource(){de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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 g(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new g(v.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(Ro.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(Ro.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}}g_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),v_("design:type",Function),v_("design:paramtypes",[Object,Object]),v_("design:returntype",void 0)],OT.prototype,"play",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],OT.prototype,"stop",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",Object)],OT.prototype,"pipe",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],OT.prototype,"unpipe",null);class DT extends AT{get isPlaying(){return this._useAudioElement?Ty.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,u("DISABLE_WEBAUDIO")?(this._source=new xy,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new $_(e,!0),u("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(ko.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(So.FIRST_FRAME_DECODED)})),this.processorContext=new Ly(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new Py(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(ko.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(ko.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(ko.ON_AUDIO_BUFFER),this._source.on(ko.ON_AUDIO_BUFFER,(t=>e(t)))}setVolume(e){this._volume=e,this._useAudioElement?Ty.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement||!R()&&u("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new g(v.NOT_SUPPORTED,"your browser does not support setting the audio output device");await Ty.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){H((()=>{de.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return G(this,go.GET_STATS)||IT({},Do)}play(){de.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(de.debug("[".concat(this.getTrackId(),"] use audio element to play")),Ty.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){de.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?Ty.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];de.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&Ty.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new g(v.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new g(v.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 g(v.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(Ro.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(Ro.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(Ro.ON_TRACK),this.processorDestination.removeAllListeners(Ro.ON_NODE)}}var NT;g_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),v_("design:type",Function),v_("design:paramtypes",[Number]),v_("design:returntype",void 0)],DT.prototype,"setVolume",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),v_("design:type",Function),v_("design:paramtypes",[String]),v_("design:returntype",m_)],DT.prototype,"setPlaybackDevice",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],DT.prototype,"play",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],DT.prototype,"stop",null),g_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),v_("design:type",Function),v_("design:paramtypes",[Object]),v_("design:returntype",Object)],DT.prototype,"pipe",null),g_([le({argsMap:e=>[e.getTrackId()]}),v_("design:type",Function),v_("design:paramtypes",[]),v_("design:returntype",void 0)],DT.prototype,"unpipe",null),function(e){e[e.ONE_BYTE=0]="ONE_BYTE",e[e.TWO_BYTE=1]="TWO_BYTE"}(NT||(NT={}));class CT{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;u("SHOW_DATASTREAM2_LOG")&&de.debug("send data header: ".concat(JSON.stringify(t.commonPacketHeader)));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={length:16383&r,reserved:(16384&r)>>14,extension:(32768&r)>>15,sequence:t.getUint16(i+2,!0)<<16|t.getUint16(i,!0)};let o,s;if(i+=4,u("SHOW_DATASTREAM2_LOG")&&de.debug("receive data header: ".concat(JSON.stringify(n))),t.getUint16(i,!0),i+=2,n.extension){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===NT.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 RT extends y{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 CT}get id(){return this._config.id}get ordered(){return this._config.ordered}get maxRetransmits(){return u("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 m_(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new g(v.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 g(v.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new g(v.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),[Bo.OPEN,Bo.CLOSE,Bo.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 MT extends RT{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),i=new DataView(t).getUint8(3);if(i!==this.id)return void(u("SHOW_DATASTREAM2_LOG")&&de.debug("invalid datachannel id: ".concat(i," !== ").concat(this.id)));let r=e.data.slice(this._dataStreamPacketHeader.byteLength);r=this._dataStreamPacketHandler.deserialize(r),this.emit(Bo.MESSAGE,r)}}_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 PT extends RT{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)}}}ve();export{ye as AUDIO_CONTEXT_EVENT,oo as AUDIO_ENCODER_CONFIG_SETTINGS,wo as AUDIO_TRACK_EVENT,Ly as AudioProcessorContext,Py as AudioProcessorDestination,ko as AudioSourceEvents,Ky as BufferSourceAudioTrack,pT as CameraVideoTrack,Ao as DEFAULT_LOCAL_AUDIO_TRACK_STATS,Oo as DEFAULT_LOCAL_VIDEO_TRACK_STATS,No as DEFAULT_NETWORK_QUALITY_STATS,Do as DEFAULT_REMOTE_AUDIO_TRACK_STATS,Co as DEFAULT_REMOTE_VIDEO_TRACK_STATS,RT as DataChannel,Bo as DataChannelEvents,hy as DeviceManager,Lo as DeviceManagerEvent,Po as DeviceManagerState,oy as HAS_GUM_AUDIO,sy as HAS_GUM_VIDEO,Gy as LocalAudioTrack,PT as LocalDataChannel,y_ as LocalTrack,bo as LocalTrackEvents,lT as LocalVideoTrack,Vo as MediaElementNumStatus,xo as MediaElementStatus,Wy as MicrophoneAudioTrack,zy as MixingAudioTrack,Mo as PROCESSOR_CONTEXT_EVENTS,Ro as PROCESSOR_DESTINATION_EVENTS,DT as RemoteAudioTrack,MT as RemoteDataChannel,To as RemoteStreamFallbackType,yo as RemoteStreamType,AT as RemoteTrack,So as RemoteTrackEvents,OT as RemoteVideoTrack,ny as SAFARI_GLOBAL_GUM_LOCK,$n as SUPPORT_720P_AUTO_CONFIG_LIST,eo as SUPPORT_SCREEN_ENCODER_CONFIG_LIST,to as SUPPORT_SVC_CONFIG_LIST,Zn as SUPPORT_VIDEO_ENCODER_CONFIG_LIST,_o as StreamType,__ as Track,Eo as TrackEvents,vo as TrackHint,go as TrackInternalEvent,My as VideoProcessorContext,Ry as VideoProcessorDestination,ao as __TRACK_LIST__,co as addTrack,S_ as audioContextState,Ty as audioElementPlayCenter,N_ as audioTimerLoop,fy as autoPlayGestureEventEmitter,$y as blob2Uint8Array,sT as checkMediaStreamTrackResolution,Ey as checkTrackState,_T as createBufferSourceAudioTrack,ET as createCameraVideoTrack,gT as createCustomAudioTrack,TT as createCustomVideoTrack,bT as createMicrophoneAndCameraTracks,vT as createMicrophoneAudioTrack,yT as createMixingAudioTrack,ST as createScreenVideoTrack,O_ as decodeAudioData,ly as deviceManager,Zy as emptyImage2TypedArray,cT as frameData2CryptoBuffer,w_ as getAudioContext,so as getAudioEncoderConfiguration,aT as getBitrateFromResAndFps,_e as getCompatibility,qy as getConstraintsFromCameraConfig,Jy as getConstraintsFromMicrophoneConfig,Yy as getConstraintsFromScreenConfig,iy as getElectronScreenSources,ey as getElectronScreenStream,ty as getElectronScreenStreamByUserSelect,ay as getLocalStream,no as getScalabilityConfiguration,ro as getScreenEncoderConfiguration,R_ as getSilenceAudioTrack,P_ as getSilenceSamplesDuration,dT as getStaticTrackStream,io as getVideoEncoderConfiguration,dy as handleGetUserMediaError,I_ as hasAudioContext,lo as isAudioEncoderConfiguration,fo as isAudioEncoderConfigurationOrPreset,Uo as isBeautyEffectOptions,Io as isLowStreamParameter,mo as isScreenSourceType,ho as isVideoEncoderConfiguration,po as isVideoEncoderConfigurationOrPreset,A_ as polyfillAudioNode,uo as removeTrack,my as requestAutoplayGesture,M_ as silenceScriptProcessHandler,ve as updateAgoraRTCCompatibility,eT as visibilityWatcher};
5
+ import"webrtc-adapter";import{getBrowserInfo as e,BrowserName as t,isChromeKernel as i,nextTick as r,isAboveChrome as n,isAboveFirefox as o,isAboveSafari as s,BrowserOS as a,isSafari as c,isWkWebview as d,getParameter as u,isFirefox as h,checkValidConstrainLong as l,checkValidNumber as p,checkValidBoolean as f,checkValidEnum as m,AgoraRTCError as g,AgoraRTCErrorCode as v,isEmpty as _,EventEmitter as y,getRandomString as T,AgoraAPIName as E,AgoraAPITag as b,PromiseMutex as S,emitAsPromiseNoResponse as k,removeItemFromList as I,isIOS as w,isIpadOS 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{logger as de,report as ue,AgoraRTCEventUploadType as he,apiInvoke as le}from"@agora-js/report";import pe from"axios";import{inflate as fe,deflate as me}from"pako";const ge={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 ve(){const l=e();ge.getDisplayMedia=function(e){if(navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia)return!0;return!1}(),ge.getStreamFromExtension=l.name===t.CHROME&&Number(l.version)>34,ge.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}(),ge.supportMinBitrate=l.name===t.CHROME||l.name===t.EDGE,ge.supportSetRtpSenderParameters=function(){const r=e();if(!window.RTCRtpSender||!window.RTCRtpSender.prototype.setParameters||!window.RTCRtpSender.prototype.getParameters)return!1;return!!i()||(!(!c()&&!d())||r.name===t.FIREFOX&&Number(r.version)>=64)}(),l.name===t.SAFARI&&(Number(l.version)>=14?ge.supportDualStream=!0:ge.supportDualStream=!1),ge.webAudioMediaStreamDest=function(){const i=e();if(i.name===t.SAFARI&&Number(i.version)<12)return!1;return!0}(),ge.supportReplaceTrack=function(){if(!window.RTCRtpSender)return!1;if("function"==typeof RTCRtpSender.prototype.replaceTrack)return!0;return!1}(),ge.supportWebGL="undefined"!=typeof WebGLRenderingContext,ge.supportRequestFrame=!!window.CanvasCaptureMediaStreamTrack,i()||(ge.webAudioWithAEC=!0),ge.supportShareAudio=function(){const i=e();if((i.os===a.WIN_10||i.os===a.WIN_81||i.os===a.WIN_7||i.os===a.LINUX||i.os===a.MAC_OS||i.os===a.CHROMIUM_OS)&&i.name===t.CHROME&&Number(i.version)>=74)return!0;return!1}(),ge.supportDataChannel=function(){if(n(76)||o(68)||s(14))return!0;return!1}(),ge.supportPCSetConfiguration=function(){const e=window.RTCPeerConnection;return!h()&&!!e&&e.prototype.setConfiguration instanceof Function}(),ge.supportWebRTCEncodedTransform=function(){const t=e();return"Chrome"===t.name&&Number(t.version)>=86}(),ge.supportWebRTCInsertableStream=function(){const i=e();return(i.name===t.CHROME||i.name===t.EDGE)&&Number(i.version)>=94&&"MediaStreamTrackGenerator"in window&&"MediaStreamTrackProcessor"in window}(),r((()=>{ge.supportDualStreamEncoding=function(){const t=e();if(u("DISABLE_WEBAUDIO"))return!0;return"Safari"===t.name&&Number(t.version)>=14||!!("Chrome"===t.name&&/Windows/i.test(t.os||"")&&Number(t.version)>=100&&u("CHROME_DUAL_STREAM_USE_ENCODING"))}(),de.info("browser compatibility",JSON.stringify(ge),JSON.stringify(l))}))}function _e(){return ge}var ye;!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"}(ye||(ye={}));var Te="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ee(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var be=function(e){try{return!!e()}catch(e){return!0}},Se=!be((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),ke=Se,Ie=Function.prototype,we=Ie.call,Ae=ke&&Ie.bind.bind(we,we),Oe=ke?Ae:function(e){return function(){return we.apply(e,arguments)}},De=Oe({}.isPrototypeOf),Ce=function(e){return e&&e.Math==Math&&e},Ne=Ce("object"==typeof globalThis&&globalThis)||Ce("object"==typeof window&&window)||Ce("object"==typeof self&&self)||Ce("object"==typeof Te&&Te)||function(){return this}()||Te||Function("return this")(),Re=Se,Me=Function.prototype,Pe=Me.apply,Le=Me.call,xe="object"==typeof Reflect&&Reflect.apply||(Re?Le.bind(Pe):function(){return Le.apply(Pe,arguments)}),Ue=Oe,Ve=Ue({}.toString),je=Ue("".slice),Be=function(e){return je(Ve(e),8,-1)},Fe=Be,He=Oe,Ge=function(e){if("Function"===Fe(e))return He(e)},We="object"==typeof document&&document.all,Ke={all:We,IS_HTMLDDA:void 0===We&&void 0!==We},ze=Ke.all,qe=Ke.IS_HTMLDDA?function(e){return"function"==typeof e||e===ze}:function(e){return"function"==typeof e},Ye={},Je=!be((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Qe=Se,Xe=Function.prototype.call,Ze=Qe?Xe.bind(Xe):function(){return Xe.apply(Xe,arguments)},$e={},et={}.propertyIsEnumerable,tt=Object.getOwnPropertyDescriptor,it=tt&&!et.call({1:2},1);$e.f=it?function(e){var t=tt(this,e);return!!t&&t.enumerable}:et;var rt,nt,ot=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},st=be,at=Be,ct=Object,dt=Oe("".split),ut=st((function(){return!ct("z").propertyIsEnumerable(0)}))?function(e){return"String"==at(e)?dt(e,""):ct(e)}:ct,ht=function(e){return null==e},lt=ht,pt=TypeError,ft=function(e){if(lt(e))throw pt("Can't call method on "+e);return e},mt=ut,gt=ft,vt=function(e){return mt(gt(e))},_t=qe,yt=Ke.all,Tt=Ke.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:_t(e)||e===yt}:function(e){return"object"==typeof e?null!==e:_t(e)},Et={},bt=Et,St=Ne,kt=qe,It=function(e){return kt(e)?e:void 0},wt=function(e,t){return arguments.length<2?It(bt[e])||It(St[e]):bt[e]&&bt[e][t]||St[e]&&St[e][t]},At="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Ot=Ne,Dt=At,Ct=Ot.process,Nt=Ot.Deno,Rt=Ct&&Ct.versions||Nt&&Nt.version,Mt=Rt&&Rt.v8;Mt&&(nt=(rt=Mt.split("."))[0]>0&&rt[0]<4?1:+(rt[0]+rt[1])),!nt&&Dt&&(!(rt=Dt.match(/Edge\/(\d+)/))||rt[1]>=74)&&(rt=Dt.match(/Chrome\/(\d+)/))&&(nt=+rt[1]);var Pt=nt,Lt=Pt,xt=be,Ut=Ne.String,Vt=!!Object.getOwnPropertySymbols&&!xt((function(){var e=Symbol();return!Ut(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&Lt&&Lt<41})),jt=Vt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Bt=wt,Ft=qe,Ht=De,Gt=Object,Wt=jt?function(e){return"symbol"==typeof e}:function(e){var t=Bt("Symbol");return Ft(t)&&Ht(t.prototype,Gt(e))},Kt=String,zt=function(e){try{return Kt(e)}catch(e){return"Object"}},qt=qe,Yt=zt,Jt=TypeError,Qt=function(e){if(qt(e))return e;throw Jt(Yt(e)+" is not a function")},Xt=Qt,Zt=ht,$t=function(e,t){var i=e[t];return Zt(i)?void 0:Xt(i)},ei=Ze,ti=qe,ii=Tt,ri=TypeError,ni={exports:{}},oi=Ne,si=Object.defineProperty,ai=function(e,t){try{si(oi,e,{value:t,configurable:!0,writable:!0})}catch(i){oi[e]=t}return t},ci="__core-js_shared__",di=Ne[ci]||ai(ci,{}),ui=di;(ni.exports=function(e,t){return ui[e]||(ui[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 hi=ni.exports,li=ft,pi=Object,fi=function(e){return pi(li(e))},mi=fi,gi=Oe({}.hasOwnProperty),vi=Object.hasOwn||function(e,t){return gi(mi(e),t)},_i=Oe,yi=0,Ti=Math.random(),Ei=_i(1..toString),bi=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Ei(++yi+Ti,36)},Si=hi,ki=vi,Ii=bi,wi=Vt,Ai=jt,Oi=Ne.Symbol,Di=Si("wks"),Ci=Ai?Oi.for||Oi:Oi&&Oi.withoutSetter||Ii,Ni=function(e){return ki(Di,e)||(Di[e]=wi&&ki(Oi,e)?Oi[e]:Ci("Symbol."+e)),Di[e]},Ri=Ze,Mi=Tt,Pi=Wt,Li=$t,xi=function(e,t){var i,r;if("string"===t&&ti(i=e.toString)&&!ii(r=ei(i,e)))return r;if(ti(i=e.valueOf)&&!ii(r=ei(i,e)))return r;if("string"!==t&&ti(i=e.toString)&&!ii(r=ei(i,e)))return r;throw ri("Can't convert object to primitive value")},Ui=TypeError,Vi=Ni("toPrimitive"),ji=function(e,t){if(!Mi(e)||Pi(e))return e;var i,r=Li(e,Vi);if(r){if(void 0===t&&(t="default"),i=Ri(r,e,t),!Mi(i)||Pi(i))return i;throw Ui("Can't convert object to primitive value")}return void 0===t&&(t="number"),xi(e,t)},Bi=Wt,Fi=function(e){var t=ji(e,"string");return Bi(t)?t:t+""},Hi=Tt,Gi=Ne.document,Wi=Hi(Gi)&&Hi(Gi.createElement),Ki=function(e){return Wi?Gi.createElement(e):{}},zi=Ki,qi=!Je&&!be((function(){return 7!=Object.defineProperty(zi("div"),"a",{get:function(){return 7}}).a})),Yi=Je,Ji=Ze,Qi=$e,Xi=ot,Zi=vt,$i=Fi,er=vi,tr=qi,ir=Object.getOwnPropertyDescriptor;Ye.f=Yi?ir:function(e,t){if(e=Zi(e),t=$i(t),tr)try{return ir(e,t)}catch(e){}if(er(e,t))return Xi(!Ji(Qi.f,e,t),e[t])};var rr=be,nr=qe,or=/#|\.prototype\./,sr=function(e,t){var i=cr[ar(e)];return i==ur||i!=dr&&(nr(t)?rr(t):!!t)},ar=sr.normalize=function(e){return String(e).replace(or,".").toLowerCase()},cr=sr.data={},dr=sr.NATIVE="N",ur=sr.POLYFILL="P",hr=sr,lr=Qt,pr=Se,fr=Ge(Ge.bind),mr=function(e,t){return lr(e),void 0===t?e:pr?fr(e,t):function(){return e.apply(t,arguments)}},gr={},vr=Je&&be((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),_r=Tt,yr=String,Tr=TypeError,Er=function(e){if(_r(e))return e;throw Tr(yr(e)+" is not an object")},br=Je,Sr=qi,kr=vr,Ir=Er,wr=Fi,Ar=TypeError,Or=Object.defineProperty,Dr=Object.getOwnPropertyDescriptor,Cr="enumerable",Nr="configurable",Rr="writable";gr.f=br?kr?function(e,t,i){if(Ir(e),t=wr(t),Ir(i),"function"==typeof e&&"prototype"===t&&"value"in i&&Rr in i&&!i[Rr]){var r=Dr(e,t);r&&r[Rr]&&(e[t]=i.value,i={configurable:Nr in i?i[Nr]:r[Nr],enumerable:Cr in i?i[Cr]:r[Cr],writable:!1})}return Or(e,t,i)}:Or:function(e,t,i){if(Ir(e),t=wr(t),Ir(i),Sr)try{return Or(e,t,i)}catch(e){}if("get"in i||"set"in i)throw Ar("Accessors not supported");return"value"in i&&(e[t]=i.value),e};var Mr=gr,Pr=ot,Lr=Je?function(e,t,i){return Mr.f(e,t,Pr(1,i))}:function(e,t,i){return e[t]=i,e},xr=Ne,Ur=xe,Vr=Ge,jr=qe,Br=Ye.f,Fr=hr,Hr=Et,Gr=mr,Wr=Lr,Kr=vi,zr=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 Ur(e,this,arguments)};return t.prototype=e.prototype,t},qr=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?xr:p?xr[h]:(xr[h]||{}).prototype,g=l?Hr:Hr[h]||Wr(Hr,h,{})[h],v=g.prototype;for(o in t)r=!(i=Fr(l?o:h+(p?".":"#")+o,e.forced))&&m&&Kr(m,o),a=g[o],r&&(c=e.dontCallGetSet?(u=Br(m,o))&&u.value:m[o]),s=r&&c?c:t[o],r&&typeof a==typeof s||(d=e.bind&&r?Gr(s,xr):e.wrap&&r?zr(s):f&&jr(s)?Vr(s):s,(e.sham||s&&s.sham||a&&a.sham)&&Wr(d,"sham",!0),Wr(g,o,d),f&&(Kr(Hr,n=h+"Prototype")||Wr(Hr,n,{}),Wr(Hr[n],o,s),e.real&&v&&(i||!v[o])&&Wr(v,o,s)))},Yr=Math.ceil,Jr=Math.floor,Qr=Math.trunc||function(e){var t=+e;return(t>0?Jr:Yr)(t)},Xr=function(e){var t=+e;return t!=t||0===t?0:Qr(t)},Zr=Xr,$r=Math.max,en=Math.min,tn=function(e,t){var i=Zr(e);return i<0?$r(i+t,0):en(i,t)},rn=Xr,nn=Math.min,on=function(e){return e>0?nn(rn(e),9007199254740991):0},sn=function(e){return on(e.length)},an=vt,cn=tn,dn=sn,un=function(e){return function(t,i,r){var n,o=an(t),s=dn(o),a=cn(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}},hn={includes:un(!0),indexOf:un(!1)},ln=hn.includes;qr({target:"Array",proto:!0,forced:be((function(){return!Array(1).includes()}))},{includes:function(e){return ln(this,e,arguments.length>1?arguments[1]:void 0)}});var pn=Et,fn=function(e){return pn[e+"Prototype"]},mn=fn("Array").includes,gn=Tt,vn=Be,_n=Ni("match"),yn=function(e){var t;return gn(e)&&(void 0!==(t=e[_n])?!!t:"RegExp"==vn(e))},Tn=TypeError,En={};En[Ni("toStringTag")]="z";var bn="[object z]"===String(En),Sn=bn,kn=qe,In=Be,wn=Ni("toStringTag"),An=Object,On="Arguments"==In(function(){return arguments}()),Dn=Sn?In: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=An(e),wn))?i:On?In(t):"Object"==(r=In(t))&&kn(t.callee)?"Arguments":r},Cn=Dn,Nn=String,Rn=function(e){if("Symbol"===Cn(e))throw TypeError("Cannot convert a Symbol value to a string");return Nn(e)},Mn=Ni("match"),Pn=qr,Ln=function(e){if(yn(e))throw Tn("The method doesn't accept regular expressions");return e},xn=ft,Un=Rn,Vn=function(e){var t=/./;try{"/./"[e](t)}catch(i){try{return t[Mn]=!1,"/./"[e](t)}catch(e){}}return!1},jn=Oe("".indexOf);Pn({target:"String",proto:!0,forced:!Vn("includes")},{includes:function(e){return!!~jn(Un(xn(this)),Un(Ln(e)),arguments.length>1?arguments[1]:void 0)}});var Bn=fn("String").includes,Fn=De,Hn=mn,Gn=Bn,Wn=Array.prototype,Kn=String.prototype,zn=Ee((function(e){var t=e.includes;return e===Wn||Fn(Wn,e)&&t===Wn.includes?Hn:"string"==typeof e||e===Kn||Fn(Kn,e)&&t===Kn.includes?Gn:t}));function qn(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function Yn(e,t,i,r,n){return{width:e,height:t,frameRate:i,bitrateMin:r,bitrateMax:n}}function Jn(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 Xn={"90p":Yn(160,90),"90p_1":Yn(160,90),"120p":Yn(160,120,15,30,65),"120p_1":Yn(160,120,15,30,65),"120p_3":Yn(120,120,15,30,50),"120p_4":Yn(212,120),"180p":Yn(320,180,15,30,140),"180p_1":Yn(320,180,15,30,140),"180p_3":Yn(180,180,15,30,100),"180p_4":Yn(240,180,15,30,120),"240p":Yn(320,240,15,40,200),"240p_1":Yn(320,240,15,40,200),"240p_3":Yn(240,240,15,40,140),"240p_4":Yn(424,240,15,40,220),"360p":Yn(640,360,15,80,400),"360p_1":Yn(640,360,15,80,400),"360p_3":Yn(360,360,15,80,260),"360p_4":Yn(640,360,30,80,600),"360p_6":Yn(360,360,30,80,400),"360p_7":Yn(480,360,15,80,320),"360p_8":Yn(480,360,30,80,490),"360p_9":Yn(640,360,15,80,800),"360p_10":Yn(640,360,24,80,800),"360p_11":Yn(640,360,24,80,1e3),"480p":Yn(640,480,15,100,500),"480p_1":Yn(640,480,15,100,500),"480p_2":Yn(640,480,30,100,1e3),"480p_3":Yn(480,480,15,100,400),"480p_4":Yn(640,480,30,100,750),"480p_6":Yn(480,480,30,100,600),"480p_8":Yn(848,480,15,100,610),"480p_9":Yn(848,480,30,100,930),"480p_10":Yn(640,480,10,100,400),"720p":Yn(1280,720,15,120,1130),"720p_auto":Yn(1280,720,30,900,3e3),"720p_1":Yn(1280,720,15,120,1130),"720p_2":Yn(1280,720,30,120,2e3),"720p_3":Yn(1280,720,30,120,1710),"720p_5":Yn(960,720,15,120,910),"720p_6":Yn(960,720,30,120,1380),"1080p":Yn(1920,1080,15,120,2080),"1080p_1":Yn(1920,1080,15,120,2080),"1080p_2":Yn(1920,1080,30,120,3e3),"1080p_3":Yn(1920,1080,30,120,3150),"1080p_5":Yn(1920,1080,60,120,4780),"1440p":Yn(2560,1440,30,120,4850),"1440p_1":Yn(2560,1440,30,120,4850),"1440p_2":Yn(2560,1440,60,120,7350),"4k":Yn(3840,2160,30,120,8910),"4k_1":Yn(3840,2160,30,120,8910),"4k_3":Yn(3840,2160,60,120,13500)},Zn=[{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}],$n={"480p":Jn(640,480,5),"480p_1":Jn(640,480,5),"480p_2":Jn(640,480,30),"480p_3":Jn(640,480,15),"720p":Jn(1280,720,5),"720p_auto":Yn(1280,720,30,900,3e3),"720p_1":Jn(1280,720,5),"720p_2":Jn(1280,720,30),"720p_3":Jn(1280,720,15),"1080p":Jn(1920,1080,5),"1080p_1":Jn(1920,1080,5),"1080p_2":Jn(1920,1080,30),"1080p_3":Jn(1920,1080,15)},eo={"1SL1TL":Qn(1,1),"3SL3TL":Qn(3,3),"2SL3TL":Qn(2,3)};function to(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},Xn[e]):e}function io(e){return"string"==typeof e?Object.assign({},$n[e]):e}function ro(e){return"string"==typeof e?Object.assign({},eo[e]):e}const no={speech_low_quality:qn(16e3,!1),speech_standard:qn(32e3,!1,18),music_standard:qn(48e3,!1),standard_stereo:qn(48e3,!0,56),high_quality:qn(48e3,!1,128),high_quality_stereo:qn(48e3,!0,192)};function oo(e){return"string"==typeof e?Object.assign({},no[e]):e}const so=[];function ao(e){zn(so).call(so,e)||so.push(e)}function co(e){const t=so.indexOf(e);-1!==t&&so.splice(t,1)}function uo(e){return l(e.width,"config.width"),l(e.height,"config.height"),void 0!==e.frameRate&&l(e.frameRate,"config.frameRate"),void 0!==e.bitrateMax&&p(e.bitrateMax,"config.bitrateMax"),void 0!==e.bitrateMin&&p(e.bitrateMin,"config.bitrateMin"),!0}function ho(e){return void 0!==e.sampleRate&&p(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&p(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&f(e.stereo,"config.stereo"),void 0!==e.bitrate&&p(e.bitrate,"config.bitrate",0,1e4,!1),!0}function lo(e){return"string"==typeof e?m(e,"profile",Object.keys(Xn)):uo(e),!0}function po(e){return"string"==typeof e?m(e,"profile",Object.keys(no)):ho(e),!0}function fo(e){return m(e,"mediaSource",["screen","window","application"]),!0}var mo,go,vo,_o,yo,To,Eo,bo,So,ko;function Io(e){if(!e)throw new g(v.INVALID_PARAMS);return _(e.width)||l(e.width,"streamParameter.width"),_(e.height)||l(e.height,"streamParameter.height"),_(e.framerate)||l(e.framerate,"streamParameter.framerate"),_(e.bitrate)||p(e.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"}(mo||(mo={})),function(e){e.SCREEN_TRACK="screen_track",e.CUSTOM_TRACK="custome_track",e.LOW_STREAM="low_stream"}(go||(go={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(vo||(vo={})),function(e){e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM"}(_o||(_o={})),function(e){e[e.DISABLE=0]="DISABLE",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.AUDIO_ONLY=2]="AUDIO_ONLY"}(yo||(yo={})),function(e){e.TRANSCEIVER_UPDATED="transceiver-updated"}(To||(To={})),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"}(Eo||(Eo={})),function(e){e.FIRST_FRAME_DECODED="first-frame-decoded",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status"}(bo||(bo={})),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"}(So||(So={})),function(e){e.UPDATE_TRACK_SOURCE="update-track-source"}(ko||(ko={}));const wo={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},Ao={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},Oo={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},Do={uplinkNetworkQuality:0,downlinkNetworkQuality:0},Co={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 No,Ro,Mo,Po,Lo;function xo(e){return void 0!==e.smoothnessLevel&&p(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&p(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&p(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&m(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0}!function(e){e.ON_TRACK="on_track",e.ON_NODE="on_node"}(No||(No={})),function(e){e.REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",e.REQUEST_CONSTRAINTS="request_constraints"}(Ro||(Ro={})),function(e){e.IDLE="IDLE",e.INITING="INITING",e.INITEND="INITEND"}(Mo||(Mo={})),function(e){e.STATE_CHANGE="state_change",e.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",e.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",e.CAMERA_DEVICE_CHANGED="cameraDeviceChanged"}(Po||(Po={})),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"}(Lo||(Lo={}));const Uo={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 Vo;!function(e){e.OPEN="open",e.MESSAGE="message",e.CLOSE="close",e.CLOSING="closing",e.ERROR="error"}(Vo||(Vo={}));var jo={exports:{}},Bo=qr,Fo=Je,Ho=gr.f;Bo({target:"Object",stat:!0,forced:Object.defineProperty!==Ho,sham:!Fo},{defineProperty:Ho});var Go=Et.Object,Wo=jo.exports=function(e,t,i){return Go.defineProperty(e,t,i)};Go.defineProperty.sham&&(Wo.sham=!0);var Ko=Ee(jo.exports),zo=Be,qo=Array.isArray||function(e){return"Array"==zo(e)},Yo=TypeError,Jo=Fi,Qo=gr,Xo=ot,Zo=function(e,t,i){var r=Jo(t);r in e?Qo.f(e,r,Xo(0,i)):e[r]=i},$o=qe,es=di,ts=Oe(Function.toString);$o(es.inspectSource)||(es.inspectSource=function(e){return ts(e)});var is=es.inspectSource,rs=Oe,ns=be,os=qe,ss=Dn,as=is,cs=function(){},ds=[],us=wt("Reflect","construct"),hs=/^\s*(?:class|function)\b/,ls=rs(hs.exec),ps=!hs.exec(cs),fs=function(e){if(!os(e))return!1;try{return us(cs,ds,e),!0}catch(e){return!1}},ms=function(e){if(!os(e))return!1;switch(ss(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ps||!!ls(hs,as(e))}catch(e){return!0}};ms.sham=!0;var gs=!us||ns((function(){var e;return fs(fs.call)||!fs(Object)||!fs((function(){e=!0}))||e}))?ms:fs,vs=qo,_s=gs,ys=Tt,Ts=Ni("species"),Es=Array,bs=function(e){var t;return vs(e)&&(t=e.constructor,(_s(t)&&(t===Es||vs(t.prototype))||ys(t)&&null===(t=t[Ts]))&&(t=void 0)),void 0===t?Es:t},Ss=function(e,t){return new(bs(e))(0===t?0:t)},ks=be,Is=Pt,ws=Ni("species"),As=qr,Os=be,Ds=qo,Cs=Tt,Ns=fi,Rs=sn,Ms=function(e){if(e>9007199254740991)throw Yo("Maximum allowed index exceeded");return e},Ps=Zo,Ls=Ss,xs=function(e){return Is>=51||!ks((function(){var t=[];return(t.constructor={})[ws]=function(){return{foo:1}},1!==t[e](Boolean).foo}))},Us=Pt,Vs=Ni("isConcatSpreadable"),js=Us>=51||!Os((function(){var e=[];return e[Vs]=!1,e.concat()[0]!==e})),Bs=function(e){if(!Cs(e))return!1;var t=e[Vs];return void 0!==t?!!t:Ds(e)};As({target:"Array",proto:!0,arity:1,forced:!js||!xs("concat")},{concat:function(e){var t,i,r,n,o,s=Ns(this),a=Ls(s,0),c=0;for(t=-1,r=arguments.length;t<r;t++)if(Bs(o=-1===t?s:arguments[t]))for(n=Rs(o),Ms(c+n),i=0;i<n;i++,c++)i in o&&Ps(a,c,o[i]);else Ms(c+1),Ps(a,c++,o);return a.length=c,a}});var Fs={},Hs={},Gs=vi,Ws=vt,Ks=hn.indexOf,zs=Hs,qs=Oe([].push),Ys=function(e,t){var i,r=Ws(e),n=0,o=[];for(i in r)!Gs(zs,i)&&Gs(r,i)&&qs(o,i);for(;t.length>n;)Gs(r,i=t[n++])&&(~Ks(o,i)||qs(o,i));return o},Js=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Qs=Ys,Xs=Js,Zs=Object.keys||function(e){return Qs(e,Xs)},$s=Je,ea=vr,ta=gr,ia=Er,ra=vt,na=Zs;Fs.f=$s&&!ea?Object.defineProperties:function(e,t){ia(e);for(var i,r=ra(t),n=na(t),o=n.length,s=0;o>s;)ta.f(e,i=n[s++],r[i]);return e};var oa,sa=wt("document","documentElement"),aa=bi,ca=hi("keys"),da=function(e){return ca[e]||(ca[e]=aa(e))},ua=Er,ha=Fs,la=Js,pa=Hs,fa=sa,ma=Ki,ga="prototype",va="script",_a=da("IE_PROTO"),ya=function(){},Ta=function(e){return"<"+va+">"+e+"</"+va+">"},Ea=function(e){e.write(Ta("")),e.close();var t=e.parentWindow.Object;return e=null,t},ba=function(){try{oa=new ActiveXObject("htmlfile")}catch(e){}var e,t,i;ba="undefined"!=typeof document?document.domain&&oa?Ea(oa):(t=ma("iframe"),i="java"+va+":",t.style.display="none",fa.appendChild(t),t.src=String(i),(e=t.contentWindow.document).open(),e.write(Ta("document.F=Object")),e.close(),e.F):Ea(oa);for(var r=la.length;r--;)delete ba[ga][la[r]];return ba()};pa[_a]=!0;var Sa=Object.create||function(e,t){var i;return null!==e?(ya[ga]=ua(e),i=new ya,ya[ga]=null,i[_a]=e):i=ba(),void 0===t?i:ha.f(i,t)},ka={},Ia=Ys,wa=Js.concat("length","prototype");ka.f=Object.getOwnPropertyNames||function(e){return Ia(e,wa)};var Aa={},Oa=tn,Da=sn,Ca=Zo,Na=Array,Ra=Math.max,Ma=Be,Pa=vt,La=ka.f,xa=function(e,t,i){for(var r=Da(e),n=Oa(t,r),o=Oa(void 0===i?r:i,r),s=Na(Ra(o-n,0)),a=0;n<o;n++,a++)Ca(s,a,e[n]);return s.length=a,s},Ua="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];Aa.f=function(e){return Ua&&"Window"==Ma(e)?function(e){try{return La(e)}catch(e){return xa(Ua)}}(e):La(Pa(e))};var Va={};Va.f=Object.getOwnPropertySymbols;var ja=Lr,Ba=function(e,t,i,r){return r&&r.enumerable?e[t]=i:ja(e,t,i),e},Fa=gr,Ha=function(e,t,i){return Fa.f(e,t,i)},Ga={},Wa=Ni;Ga.f=Wa;var Ka,za,qa,Ya=Et,Ja=vi,Qa=Ga,Xa=gr.f,Za=function(e){var t=Ya.Symbol||(Ya.Symbol={});Ja(t,e)||Xa(t,e,{value:Qa.f(e)})},$a=Ze,ec=wt,tc=Ni,ic=Ba,rc=function(){var e=ec("Symbol"),t=e&&e.prototype,i=t&&t.valueOf,r=tc("toPrimitive");t&&!t[r]&&ic(t,r,(function(e){return $a(i,this)}),{arity:1})},nc=Dn,oc=bn?{}.toString:function(){return"[object "+nc(this)+"]"},sc=bn,ac=gr.f,cc=Lr,dc=vi,uc=oc,hc=Ni("toStringTag"),lc=function(e,t,i,r){if(e){var n=i?e:e.prototype;dc(n,hc)||ac(n,hc,{configurable:!0,value:t}),r&&!sc&&cc(n,"toString",uc)}},pc=qe,fc=Ne.WeakMap,mc=pc(fc)&&/native code/.test(String(fc)),gc=Ne,vc=Tt,_c=Lr,yc=vi,Tc=di,Ec=da,bc=Hs,Sc="Object already initialized",kc=gc.TypeError,Ic=gc.WeakMap;if(mc||Tc.state){var wc=Tc.state||(Tc.state=new Ic);wc.get=wc.get,wc.has=wc.has,wc.set=wc.set,Ka=function(e,t){if(wc.has(e))throw kc(Sc);return t.facade=e,wc.set(e,t),t},za=function(e){return wc.get(e)||{}},qa=function(e){return wc.has(e)}}else{var Ac=Ec("state");bc[Ac]=!0,Ka=function(e,t){if(yc(e,Ac))throw kc(Sc);return t.facade=e,_c(e,Ac,t),t},za=function(e){return yc(e,Ac)?e[Ac]:{}},qa=function(e){return yc(e,Ac)}}var Oc={set:Ka,get:za,has:qa,enforce:function(e){return qa(e)?za(e):Ka(e,{})},getterFor:function(e){return function(t){var i;if(!vc(t)||(i=za(t)).type!==e)throw kc("Incompatible receiver, "+e+" required");return i}}},Dc=mr,Cc=ut,Nc=fi,Rc=sn,Mc=Ss,Pc=Oe([].push),Lc=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=Nc(c),m=Cc(f),g=Dc(d,u),v=Rc(m),_=0,y=h||Mc,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:Pc(T,l)}else switch(e){case 4:return!1;case 7:Pc(T,l)}return o?-1:r||n?n:T}},xc={forEach:Lc(0),map:Lc(1),filter:Lc(2),some:Lc(3),every:Lc(4),find:Lc(5),findIndex:Lc(6),filterReject:Lc(7)},Uc=qr,Vc=Ne,jc=Ze,Bc=Oe,Fc=Je,Hc=Vt,Gc=be,Wc=vi,Kc=De,zc=Er,qc=vt,Yc=Fi,Jc=Rn,Qc=ot,Xc=Sa,Zc=Zs,$c=ka,ed=Aa,td=Va,id=Ye,rd=gr,nd=Fs,od=$e,sd=Ba,ad=Ha,cd=hi,dd=Hs,ud=bi,hd=Ni,ld=Ga,pd=Za,fd=rc,md=lc,gd=Oc,vd=xc.forEach,_d=da("hidden"),yd="Symbol",Td="prototype",Ed=gd.set,bd=gd.getterFor(yd),Sd=Object[Td],kd=Vc.Symbol,Id=kd&&kd[Td],wd=Vc.TypeError,Ad=Vc.QObject,Od=id.f,Dd=rd.f,Cd=ed.f,Nd=od.f,Rd=Bc([].push),Md=cd("symbols"),Pd=cd("op-symbols"),Ld=cd("wks"),xd=!Ad||!Ad[Td]||!Ad[Td].findChild,Ud=Fc&&Gc((function(){return 7!=Xc(Dd({},"a",{get:function(){return Dd(this,"a",{value:7}).a}})).a}))?function(e,t,i){var r=Od(Sd,t);r&&delete Sd[t],Dd(e,t,i),r&&e!==Sd&&Dd(Sd,t,r)}:Dd,Vd=function(e,t){var i=Md[e]=Xc(Id);return Ed(i,{type:yd,tag:e,description:t}),Fc||(i.description=t),i},jd=function(e,t,i){e===Sd&&jd(Pd,t,i),zc(e);var r=Yc(t);return zc(i),Wc(Md,r)?(i.enumerable?(Wc(e,_d)&&e[_d][r]&&(e[_d][r]=!1),i=Xc(i,{enumerable:Qc(0,!1)})):(Wc(e,_d)||Dd(e,_d,Qc(1,{})),e[_d][r]=!0),Ud(e,r,i)):Dd(e,r,i)},Bd=function(e,t){zc(e);var i=qc(t),r=Zc(i).concat(Wd(i));return vd(r,(function(t){Fc&&!jc(Fd,i,t)||jd(e,t,i[t])})),e},Fd=function(e){var t=Yc(e),i=jc(Nd,this,t);return!(this===Sd&&Wc(Md,t)&&!Wc(Pd,t))&&(!(i||!Wc(this,t)||!Wc(Md,t)||Wc(this,_d)&&this[_d][t])||i)},Hd=function(e,t){var i=qc(e),r=Yc(t);if(i!==Sd||!Wc(Md,r)||Wc(Pd,r)){var n=Od(i,r);return!n||!Wc(Md,r)||Wc(i,_d)&&i[_d][r]||(n.enumerable=!0),n}},Gd=function(e){var t=Cd(qc(e)),i=[];return vd(t,(function(e){Wc(Md,e)||Wc(dd,e)||Rd(i,e)})),i},Wd=function(e){var t=e===Sd,i=Cd(t?Pd:qc(e)),r=[];return vd(i,(function(e){!Wc(Md,e)||t&&!Wc(Sd,e)||Rd(r,Md[e])})),r};Hc||(sd(Id=(kd=function(){if(Kc(Id,this))throw wd("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?Jc(arguments[0]):void 0,t=ud(e),i=function(e){this===Sd&&jc(i,Pd,e),Wc(this,_d)&&Wc(this[_d],t)&&(this[_d][t]=!1),Ud(this,t,Qc(1,e))};return Fc&&xd&&Ud(Sd,t,{configurable:!0,set:i}),Vd(t,e)})[Td],"toString",(function(){return bd(this).tag})),sd(kd,"withoutSetter",(function(e){return Vd(ud(e),e)})),od.f=Fd,rd.f=jd,nd.f=Bd,id.f=Hd,$c.f=ed.f=Gd,td.f=Wd,ld.f=function(e){return Vd(hd(e),e)},Fc&&ad(Id,"description",{configurable:!0,get:function(){return bd(this).description}})),Uc({global:!0,constructor:!0,wrap:!0,forced:!Hc,sham:!Hc},{Symbol:kd}),vd(Zc(Ld),(function(e){pd(e)})),Uc({target:yd,stat:!0,forced:!Hc},{useSetter:function(){xd=!0},useSimple:function(){xd=!1}}),Uc({target:"Object",stat:!0,forced:!Hc,sham:!Fc},{create:function(e,t){return void 0===t?Xc(e):Bd(Xc(e),t)},defineProperty:jd,defineProperties:Bd,getOwnPropertyDescriptor:Hd}),Uc({target:"Object",stat:!0,forced:!Hc},{getOwnPropertyNames:Gd}),fd(),md(kd,yd),dd[_d]=!0;var Kd=Vt&&!!Symbol.for&&!!Symbol.keyFor,zd=qr,qd=wt,Yd=vi,Jd=Rn,Qd=hi,Xd=Kd,Zd=Qd("string-to-symbol-registry"),$d=Qd("symbol-to-string-registry");zd({target:"Symbol",stat:!0,forced:!Xd},{for:function(e){var t=Jd(e);if(Yd(Zd,t))return Zd[t];var i=qd("Symbol")(t);return Zd[t]=i,$d[i]=t,i}});var eu=qr,tu=vi,iu=Wt,ru=zt,nu=Kd,ou=hi("symbol-to-string-registry");eu({target:"Symbol",stat:!0,forced:!nu},{keyFor:function(e){if(!iu(e))throw TypeError(ru(e)+" is not a symbol");if(tu(ou,e))return ou[e]}});var su=Oe([].slice),au=qo,cu=qe,du=Be,uu=Rn,hu=Oe([].push),lu=qr,pu=wt,fu=xe,mu=Ze,gu=Oe,vu=be,_u=qe,yu=Wt,Tu=su,Eu=function(e){if(cu(e))return e;if(au(e)){for(var t=e.length,i=[],r=0;r<t;r++){var n=e[r];"string"==typeof n?hu(i,n):"number"!=typeof n&&"Number"!=du(n)&&"String"!=du(n)||hu(i,uu(n))}var o=i.length,s=!0;return function(e,t){if(s)return s=!1,t;if(au(this))return t;for(var r=0;r<o;r++)if(i[r]===e)return t}}},bu=Vt,Su=String,ku=pu("JSON","stringify"),Iu=gu(/./.exec),wu=gu("".charAt),Au=gu("".charCodeAt),Ou=gu("".replace),Du=gu(1..toString),Cu=/[\uD800-\uDFFF]/g,Nu=/^[\uD800-\uDBFF]$/,Ru=/^[\uDC00-\uDFFF]$/,Mu=!bu||vu((function(){var e=pu("Symbol")();return"[null]"!=ku([e])||"{}"!=ku({a:e})||"{}"!=ku(Object(e))})),Pu=vu((function(){return'"\\udf06\\ud834"'!==ku("\udf06\ud834")||'"\\udead"'!==ku("\udead")})),Lu=function(e,t){var i=Tu(arguments),r=Eu(t);if(_u(r)||void 0!==e&&!yu(e))return i[1]=function(e,t){if(_u(r)&&(t=mu(r,this,Su(e),t)),!yu(t))return t},fu(ku,null,i)},xu=function(e,t,i){var r=wu(i,t-1),n=wu(i,t+1);return Iu(Nu,e)&&!Iu(Ru,n)||Iu(Ru,e)&&!Iu(Nu,r)?"\\u"+Du(Au(e,0),16):e};ku&&lu({target:"JSON",stat:!0,arity:3,forced:Mu||Pu},{stringify:function(e,t,i){var r=Tu(arguments),n=fu(Mu?Lu:ku,null,r);return Pu&&"string"==typeof n?Ou(n,Cu,xu):n}});var Uu=Va,Vu=fi;qr({target:"Object",stat:!0,forced:!Vt||be((function(){Uu.f(1)}))},{getOwnPropertySymbols:function(e){var t=Uu.f;return t?t(Vu(e)):[]}}),Za("asyncIterator"),Za("hasInstance"),Za("isConcatSpreadable"),Za("iterator"),Za("match"),Za("matchAll"),Za("replace"),Za("search"),Za("species"),Za("split");var ju=rc;Za("toPrimitive"),ju();var Bu=wt,Fu=lc;Za("toStringTag"),Fu(Bu("Symbol"),"Symbol"),Za("unscopables"),lc(Ne.JSON,"JSON",!0);var Hu,Gu,Wu,Ku=Et.Symbol,zu={},qu=Je,Yu=vi,Ju=Function.prototype,Qu=qu&&Object.getOwnPropertyDescriptor,Xu=Yu(Ju,"name"),Zu={EXISTS:Xu,PROPER:Xu&&"something"===function(){}.name,CONFIGURABLE:Xu&&(!qu||qu&&Qu(Ju,"name").configurable)},$u=!be((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})),eh=vi,th=qe,ih=fi,rh=$u,nh=da("IE_PROTO"),oh=Object,sh=oh.prototype,ah=rh?oh.getPrototypeOf:function(e){var t=ih(e);if(eh(t,nh))return t[nh];var i=t.constructor;return th(i)&&t instanceof i?i.prototype:t instanceof oh?sh:null},ch=be,dh=qe,uh=Tt,hh=Sa,lh=ah,ph=Ba,fh=Ni("iterator"),mh=!1;[].keys&&("next"in(Wu=[].keys())?(Gu=lh(lh(Wu)))!==Object.prototype&&(Hu=Gu):mh=!0);var gh=!uh(Hu)||ch((function(){var e={};return Hu[fh].call(e)!==e}));dh((Hu=gh?{}:hh(Hu))[fh])||ph(Hu,fh,(function(){return this}));var vh={IteratorPrototype:Hu,BUGGY_SAFARI_ITERATORS:mh},_h=vh.IteratorPrototype,yh=Sa,Th=ot,Eh=lc,bh=zu,Sh=function(){return this},kh=Oe,Ih=Qt,wh=qe,Ah=String,Oh=TypeError,Dh=function(e,t,i){try{return kh(Ih(Object.getOwnPropertyDescriptor(e,t)[i]))}catch(e){}},Ch=Er,Nh=function(e){if("object"==typeof e||wh(e))return e;throw Oh("Can't set "+Ah(e)+" as a prototype")},Rh=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,i={};try{(e=Dh(Object.prototype,"__proto__","set"))(i,[]),t=i instanceof Array}catch(e){}return function(i,r){return Ch(i),Nh(r),t?e(i,r):i.__proto__=r,i}}():void 0),Mh=qr,Ph=Ze,Lh=Zu,xh=function(e,t,i,r){var n=t+" Iterator";return e.prototype=yh(_h,{next:Th(+!r,i)}),Eh(e,n,!1,!0),bh[n]=Sh,e},Uh=ah,Vh=lc,jh=Ba,Bh=zu,Fh=vh,Hh=Lh.PROPER,Gh=Fh.BUGGY_SAFARI_ITERATORS,Wh=Ni("iterator"),Kh="keys",zh="values",qh="entries",Yh=function(){return this},Jh=function(e,t,i,r,n,o,s){xh(i,t,r);var a,c,d,u=function(e){if(e===n&&m)return m;if(!Gh&&e in p)return p[e];switch(e){case Kh:case zh:case qh:return function(){return new i(this,e)}}return function(){return new i(this)}},h=t+" Iterator",l=!1,p=e.prototype,f=p[Wh]||p["@@iterator"]||n&&p[n],m=!Gh&&f||u(n),g="Array"==t&&p.entries||f;if(g&&(a=Uh(g.call(new e)))!==Object.prototype&&a.next&&(Vh(a,h,!0,!0),Bh[h]=Yh),Hh&&n==zh&&f&&f.name!==zh&&(l=!0,m=function(){return Ph(f,this)}),n)if(c={values:u(zh),keys:o?m:u(Kh),entries:u(qh)},s)for(d in c)(Gh||l||!(d in p))&&jh(p,d,c[d]);else Mh({target:t,proto:!0,forced:Gh||l},c);return s&&p[Wh]!==m&&jh(p,Wh,m,{name:n}),Bh[t]=m,c},Qh=function(e,t){return{value:e,done:t}},Xh=vt,Zh=zu,$h=Oc;gr.f;var el=Jh,tl=Qh,il="Array Iterator",rl=$h.set,nl=$h.getterFor(il);el(Array,"Array",(function(e,t){rl(this,{type:il,target:Xh(e),index:0,kind:t})}),(function(){var e=nl(this),t=e.target,i=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,tl(void 0,!0)):tl("keys"==i?r:"values"==i?t[r]:[r,t[r]],!1)}),"values"),Zh.Arguments=Zh.Array;var ol={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},sl=Ne,al=Dn,cl=Lr,dl=zu,ul=Ni("toStringTag");for(var hl in ol){var ll=sl[hl],pl=ll&&ll.prototype;pl&&al(pl)!==ul&&cl(pl,ul,hl),dl[hl]=dl.Array}var fl=Ku,ml=Ni,gl=gr.f,vl=ml("metadata"),_l=Function.prototype;void 0===_l[vl]&&gl(_l,vl,{value:null}),Za("dispose"),Za("metadata");var yl=fl;Za("asyncDispose");var Tl=Oe,El=wt("Symbol"),bl=El.keyFor,Sl=Tl(El.prototype.valueOf),kl=El.isRegisteredSymbol||function(e){try{return void 0!==bl(Sl(e))}catch(e){return!1}};qr({target:"Symbol",stat:!0},{isRegisteredSymbol:kl});for(var Il=hi,wl=wt,Al=Oe,Ol=Wt,Dl=Ni,Cl=wl("Symbol"),Nl=Cl.isWellKnownSymbol,Rl=wl("Object","getOwnPropertyNames"),Ml=Al(Cl.prototype.valueOf),Pl=Il("wks"),Ll=0,xl=Rl(Cl),Ul=xl.length;Ll<Ul;Ll++)try{var Vl=xl[Ll];Ol(Cl[Vl])&&Dl(Vl)}catch(e){}var jl=function(e){if(Nl&&Nl(e))return!0;try{for(var t=Ml(e),i=0,r=Rl(Pl),n=r.length;i<n;i++)if(Pl[r[i]]==t)return!0}catch(e){}return!1};qr({target:"Symbol",stat:!0,forced:!0},{isWellKnownSymbol:jl}),Za("matcher"),Za("observable"),qr({target:"Symbol",stat:!0,name:"isRegisteredSymbol"},{isRegistered:kl}),qr({target:"Symbol",stat:!0,name:"isWellKnownSymbol",forced:!0},{isWellKnown:jl}),Za("metadataKey"),Za("patternMatch"),Za("replaceAll");var Bl=Ee(yl),Fl=Oe,Hl=Xr,Gl=Rn,Wl=ft,Kl=Fl("".charAt),zl=Fl("".charCodeAt),ql=Fl("".slice),Yl=function(e){return function(t,i){var r,n,o=Gl(Wl(t)),s=Hl(i),a=o.length;return s<0||s>=a?e?"":void 0:(r=zl(o,s))<55296||r>56319||s+1===a||(n=zl(o,s+1))<56320||n>57343?e?Kl(o,s):r:e?ql(o,s,s+2):n-56320+(r-55296<<10)+65536}},Jl={codeAt:Yl(!1),charAt:Yl(!0)}.charAt,Ql=Rn,Xl=Oc,Zl=Jh,$l=Qh,ep="String Iterator",tp=Xl.set,ip=Xl.getterFor(ep);Zl(String,"String",(function(e){tp(this,{type:ep,string:Ql(e),index:0})}),(function(){var e,t=ip(this),i=t.string,r=t.index;return r>=i.length?$l(void 0,!0):(e=Jl(i,r),t.index+=e.length,$l(e,!1))}));var rp=Ee(Ga.f("iterator"));function np(e){return np="function"==typeof Bl&&"symbol"==typeof rp?function(e){return typeof e}:function(e){return e&&"function"==typeof Bl&&e.constructor===Bl&&e!==Bl.prototype?"symbol":typeof e},np(e)}var op=Ee(Ga.f("toPrimitive"));function sp(e){var t=function(e,t){if("object"!==np(e)||null===e)return e;var i=e[op];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==np(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===np(t)?t:String(t)}function ap(e,t,i){return(t=sp(t))in e?Ko(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}var cp=wt,dp=ka,up=Va,hp=Er,lp=Oe([].concat),pp=cp("Reflect","ownKeys")||function(e){var t=dp.f(hp(e)),i=up.f;return i?lp(t,i(e)):t},fp=vi,mp=pp,gp=Ye,vp=gr,_p=Tt,yp=Lr,Tp=Error,Ep=Oe("".replace),bp=String(Tp("zxcasd").stack),Sp=/\n\s*at [^:]*:[^\n]*/,kp=Sp.test(bp),Ip=ot,wp=!be((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",Ip(1,7)),7!==e.stack)})),Ap=Lr,Op=function(e,t){if(kp&&"string"==typeof e&&!Tp.prepareStackTrace)for(;t--;)e=Ep(e,Sp,"");return e},Dp=wp,Cp=Error.captureStackTrace,Np=zu,Rp=Ni("iterator"),Mp=Array.prototype,Pp=Dn,Lp=$t,xp=ht,Up=zu,Vp=Ni("iterator"),jp=function(e){if(!xp(e))return Lp(e,Vp)||Lp(e,"@@iterator")||Up[Pp(e)]},Bp=Ze,Fp=Qt,Hp=Er,Gp=zt,Wp=jp,Kp=TypeError,zp=Ze,qp=Er,Yp=$t,Jp=mr,Qp=Ze,Xp=Er,Zp=zt,$p=function(e){return void 0!==e&&(Np.Array===e||Mp[Rp]===e)},ef=sn,tf=De,rf=function(e,t){var i=arguments.length<2?Wp(e):t;if(Fp(i))return Hp(Bp(i,e));throw Kp(Gp(e)+" is not iterable")},nf=jp,of=function(e,t,i){var r,n;qp(e);try{if(!(r=Yp(e,"return"))){if("throw"===t)throw i;return i}r=zp(r,e)}catch(e){n=!0,r=e}if("throw"===t)throw i;if(n)throw r;return qp(r),i},sf=TypeError,af=function(e,t){this.stopped=e,this.result=t},cf=af.prototype,df=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=Jp(t,u),g=function(e){return r&&of(r,"normal",e),new af(!0,e)},v=function(e){return h?(Xp(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=nf(e)))throw sf(Zp(e)+" is not iterable");if($p(n)){for(o=0,s=ef(e);s>o;o++)if((a=v(e[o]))&&tf(cf,a))return a;return new af(!1)}r=rf(e,n)}for(c=l?e.next:r.next;!(d=Qp(c,r)).done;){try{a=v(d.value)}catch(e){of(r,"throw",e)}if("object"==typeof a&&a&&tf(cf,a))return a}return new af(!1)},uf=Rn,hf=qr,lf=De,pf=ah,ff=Rh,mf=function(e,t,i){for(var r=mp(t),n=vp.f,o=gp.f,s=0;s<r.length;s++){var a=r[s];fp(e,a)||i&&fp(i,a)||n(e,a,o(t,a))}},gf=Sa,vf=Lr,_f=ot,yf=function(e,t){_p(t)&&"cause"in t&&yp(e,"cause",t.cause)},Tf=function(e,t,i,r){Dp&&(Cp?Cp(e,t):Ap(e,"stack",Op(i,r)))},Ef=df,bf=function(e,t){return void 0===e?arguments.length<2?"":t:uf(e)},Sf=Ni("toStringTag"),kf=Error,If=[].push,wf=function(e,t){var i,r=lf(Af,this);ff?i=ff(kf(),r?pf(this):Af):(i=r?this:gf(Af),vf(i,Sf,"Error")),void 0!==t&&vf(i,"message",bf(t)),Tf(i,wf,i.stack,1),arguments.length>2&&yf(i,arguments[2]);var n=[];return Ef(e,If,{that:n}),vf(i,"errors",n),i};ff?ff(wf,kf):mf(wf,kf,{name:!0});var Af=wf.prototype=gf(kf.prototype,{constructor:_f(1,wf),message:_f(1,""),name:_f(1,"AggregateError")});hf({global:!0,constructor:!0,arity:2},{AggregateError:wf});var Of,Df,Cf,Nf,Rf="undefined"!=typeof process&&"process"==Be(process),Mf=wt,Pf=Ha,Lf=Je,xf=Ni("species"),Uf=De,Vf=TypeError,jf=gs,Bf=zt,Ff=TypeError,Hf=Er,Gf=function(e){if(jf(e))return e;throw Ff(Bf(e)+" is not a constructor")},Wf=ht,Kf=Ni("species"),zf=function(e,t){var i,r=Hf(e).constructor;return void 0===r||Wf(i=Hf(r)[Kf])?t:Gf(i)},qf=TypeError,Yf=/(?:ipad|iphone|ipod).*applewebkit/i.test(At),Jf=Ne,Qf=xe,Xf=mr,Zf=qe,$f=vi,em=be,tm=sa,im=su,rm=Ki,nm=function(e,t){if(e<t)throw qf("Not enough arguments");return e},om=Yf,sm=Rf,am=Jf.setImmediate,cm=Jf.clearImmediate,dm=Jf.process,um=Jf.Dispatch,hm=Jf.Function,lm=Jf.MessageChannel,pm=Jf.String,fm=0,mm={},gm="onreadystatechange";em((function(){Of=Jf.location}));var vm=function(e){if($f(mm,e)){var t=mm[e];delete mm[e],t()}},_m=function(e){return function(){vm(e)}},ym=function(e){vm(e.data)},Tm=function(e){Jf.postMessage(pm(e),Of.protocol+"//"+Of.host)};am&&cm||(am=function(e){nm(arguments.length,1);var t=Zf(e)?e:hm(e),i=im(arguments,1);return mm[++fm]=function(){Qf(t,void 0,i)},Df(fm),fm},cm=function(e){delete mm[e]},sm?Df=function(e){dm.nextTick(_m(e))}:um&&um.now?Df=function(e){um.now(_m(e))}:lm&&!om?(Nf=(Cf=new lm).port2,Cf.port1.onmessage=ym,Df=Xf(Nf.postMessage,Nf)):Jf.addEventListener&&Zf(Jf.postMessage)&&!Jf.importScripts&&Of&&"file:"!==Of.protocol&&!em(Tm)?(Df=Tm,Jf.addEventListener("message",ym,!1)):Df=gm in rm("script")?function(e){tm.appendChild(rm("script"))[gm]=function(){tm.removeChild(this),vm(e)}}:function(e){setTimeout(_m(e),0)});var Em={set:am,clear:cm},bm=function(){this.head=null,this.tail=null};bm.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 Sm,km,Im,wm,Am,Om=bm,Dm=/ipad|iphone|ipod/i.test(At)&&"undefined"!=typeof Pebble,Cm=/web0s(?!.*chrome)/i.test(At),Nm=Ne,Rm=mr,Mm=Ye.f,Pm=Em.set,Lm=Om,xm=Yf,Um=Dm,Vm=Cm,jm=Rf,Bm=Nm.MutationObserver||Nm.WebKitMutationObserver,Fm=Nm.document,Hm=Nm.process,Gm=Nm.Promise,Wm=Mm(Nm,"queueMicrotask"),Km=Wm&&Wm.value;if(!Km){var zm=new Lm,qm=function(){var e,t;for(jm&&(e=Hm.domain)&&e.exit();t=zm.get();)try{t()}catch(e){throw zm.head&&Sm(),e}e&&e.enter()};xm||jm||Vm||!Bm||!Fm?!Um&&Gm&&Gm.resolve?((wm=Gm.resolve(void 0)).constructor=Gm,Am=Rm(wm.then,wm),Sm=function(){Am(qm)}):jm?Sm=function(){Hm.nextTick(qm)}:(Pm=Rm(Pm,Nm),Sm=function(){Pm(qm)}):(km=!0,Im=Fm.createTextNode(""),new Bm(qm).observe(Im,{characterData:!0}),Sm=function(){Im.data=km=!km}),Km=function(e){zm.head||Sm(),zm.add(e)}}var Ym=Km,Jm=function(e){try{return{error:!1,value:e()}}catch(e){return{error:!0,value:e}}},Qm=Ne.Promise,Xm="object"==typeof Deno&&Deno&&"object"==typeof Deno.version,Zm=!Xm&&!Rf&&"object"==typeof window&&"object"==typeof document,$m=Ne,eg=Qm,tg=qe,ig=hr,rg=is,ng=Ni,og=Zm,sg=Xm,ag=Pt,cg=eg&&eg.prototype,dg=ng("species"),ug=!1,hg=tg($m.PromiseRejectionEvent),lg=ig("Promise",(function(){var e=rg(eg),t=e!==String(eg);if(!t&&66===ag)return!0;if(!cg.catch||!cg.finally)return!0;if(!ag||ag<51||!/native code/.test(e)){var i=new eg((function(e){e(1)})),r=function(e){e((function(){}),(function(){}))};if((i.constructor={})[dg]=r,!(ug=i.then((function(){}))instanceof r))return!0}return!t&&(og||sg)&&!hg})),pg={CONSTRUCTOR:lg,REJECTION_EVENT:hg,SUBCLASSING:ug},fg={},mg=Qt,gg=TypeError,vg=function(e){var t,i;this.promise=new e((function(e,r){if(void 0!==t||void 0!==i)throw gg("Bad Promise constructor");t=e,i=r})),this.resolve=mg(t),this.reject=mg(i)};fg.f=function(e){return new vg(e)};var _g,yg,Tg=qr,Eg=Rf,bg=Ne,Sg=Ze,kg=Ba,Ig=lc,wg=function(e){var t=Mf(e);Lf&&t&&!t[xf]&&Pf(t,xf,{configurable:!0,get:function(){return this}})},Ag=Qt,Og=qe,Dg=Tt,Cg=function(e,t){if(Uf(t,e))return e;throw Vf("Incorrect invocation")},Ng=zf,Rg=Em.set,Mg=Ym,Pg=function(e,t){try{1==arguments.length?console.error(e):console.error(e,t)}catch(e){}},Lg=Jm,xg=Om,Ug=Oc,Vg=Qm,jg=pg,Bg=fg,Fg="Promise",Hg=jg.CONSTRUCTOR,Gg=jg.REJECTION_EVENT,Wg=Ug.getterFor(Fg),Kg=Ug.set,zg=Vg&&Vg.prototype,qg=Vg,Yg=zg,Jg=bg.TypeError,Qg=bg.document,Xg=bg.process,Zg=Bg.f,$g=Zg,ev=!!(Qg&&Qg.createEvent&&bg.dispatchEvent),tv="unhandledrejection",iv=function(e){var t;return!(!Dg(e)||!Og(t=e.then))&&t},rv=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&&cv(t),t.rejection=1),!0===a?i=o:(u&&u.enter(),i=a(o),u&&(u.exit(),n=!0)),i===e.promise?d(Jg("Promise-chain cycle")):(r=iv(i))?Sg(r,i,c,d):c(i)):d(o)}catch(e){u&&!n&&u.exit(),d(e)}},nv=function(e,t){e.notified||(e.notified=!0,Mg((function(){for(var i,r=e.reactions;i=r.get();)rv(i,e);e.notified=!1,t&&!e.rejection&&sv(e)})))},ov=function(e,t,i){var r,n;ev?((r=Qg.createEvent("Event")).promise=t,r.reason=i,r.initEvent(e,!1,!0),bg.dispatchEvent(r)):r={promise:t,reason:i},!Gg&&(n=bg["on"+e])?n(r):e===tv&&Pg("Unhandled promise rejection",i)},sv=function(e){Sg(Rg,bg,(function(){var t,i=e.facade,r=e.value;if(av(e)&&(t=Lg((function(){Eg?Xg.emit("unhandledRejection",r,i):ov(tv,i,r)})),e.rejection=Eg||av(e)?2:1,t.error))throw t.value}))},av=function(e){return 1!==e.rejection&&!e.parent},cv=function(e){Sg(Rg,bg,(function(){var t=e.facade;Eg?Xg.emit("rejectionHandled",t):ov("rejectionhandled",t,e.value)}))},dv=function(e,t,i){return function(r){e(t,r,i)}},uv=function(e,t,i){e.done||(e.done=!0,i&&(e=i),e.value=t,e.state=2,nv(e,!0))},hv=function(e,t,i){if(!e.done){e.done=!0,i&&(e=i);try{if(e.facade===t)throw Jg("Promise can't be resolved itself");var r=iv(t);r?Mg((function(){var i={done:!1};try{Sg(r,t,dv(hv,i,e),dv(uv,i,e))}catch(t){uv(i,t,e)}})):(e.value=t,e.state=1,nv(e,!1))}catch(t){uv({done:!1},t,e)}}};Hg&&(Yg=(qg=function(e){Cg(this,Yg),Ag(e),Sg(_g,this);var t=Wg(this);try{e(dv(hv,t),dv(uv,t))}catch(e){uv(t,e)}}).prototype,(_g=function(e){Kg(this,{type:Fg,done:!1,notified:!1,parent:!1,reactions:new xg,rejection:!1,state:0,value:void 0})}).prototype=kg(Yg,"then",(function(e,t){var i=Wg(this),r=Zg(Ng(this,qg));return i.parent=!0,r.ok=!Og(e)||e,r.fail=Og(t)&&t,r.domain=Eg?Xg.domain:void 0,0==i.state?i.reactions.add(r):Mg((function(){rv(r,i)})),r.promise})),yg=function(){var e=new _g,t=Wg(e);this.promise=e,this.resolve=dv(hv,t),this.reject=dv(uv,t)},Bg.f=Zg=function(e){return e===qg||undefined===e?new yg(e):$g(e)}),Tg({global:!0,constructor:!0,wrap:!0,forced:Hg},{Promise:qg}),Ig(qg,Fg,!1,!0),wg(Fg);var lv=Ni("iterator"),pv=!1;try{var fv=0,mv={next:function(){return{done:!!fv++}},return:function(){pv=!0}};mv[lv]=function(){return this},Array.from(mv,(function(){throw 2}))}catch(e){}var gv=Qm,vv=function(e,t){if(!t&&!pv)return!1;var i=!1;try{var r={};r[lv]=function(){return{next:function(){return{done:i=!0}}}},e(r)}catch(e){}return i},_v=pg.CONSTRUCTOR||!vv((function(e){gv.all(e).then(void 0,(function(){}))})),yv=Ze,Tv=Qt,Ev=fg,bv=Jm,Sv=df;qr({target:"Promise",stat:!0,forced:_v},{all:function(e){var t=this,i=Ev.f(t),r=i.resolve,n=i.reject,o=bv((function(){var i=Tv(t.resolve),o=[],s=0,a=1;Sv(e,(function(e){var c=s++,d=!1;a++,yv(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 kv=qr,Iv=pg.CONSTRUCTOR;Qm&&Qm.prototype,kv({target:"Promise",proto:!0,forced:Iv,real:!0},{catch:function(e){return this.then(void 0,e)}});var wv=Ze,Av=Qt,Ov=fg,Dv=Jm,Cv=df;qr({target:"Promise",stat:!0,forced:_v},{race:function(e){var t=this,i=Ov.f(t),r=i.reject,n=Dv((function(){var n=Av(t.resolve);Cv(e,(function(e){wv(n,t,e).then(i.resolve,r)}))}));return n.error&&r(n.value),i.promise}});var Nv=Ze,Rv=fg;qr({target:"Promise",stat:!0,forced:pg.CONSTRUCTOR},{reject:function(e){var t=Rv.f(this);return Nv(t.reject,void 0,e),t.promise}});var Mv=Er,Pv=Tt,Lv=fg,xv=function(e,t){if(Mv(e),Pv(t)&&t.constructor===e)return t;var i=Lv.f(e);return(0,i.resolve)(t),i.promise},Uv=qr,Vv=Qm,jv=pg.CONSTRUCTOR,Bv=xv,Fv=wt("Promise"),Hv=!jv;Uv({target:"Promise",stat:!0,forced:true},{resolve:function(e){return Bv(Hv&&this===Fv?Vv:this,e)}});var Gv=Ze,Wv=Qt,Kv=fg,zv=Jm,qv=df;qr({target:"Promise",stat:!0,forced:_v},{allSettled:function(e){var t=this,i=Kv.f(t),r=i.resolve,n=i.reject,o=zv((function(){var i=Wv(t.resolve),n=[],o=0,s=1;qv(e,(function(e){var a=o++,c=!1;s++,Gv(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 Yv=Ze,Jv=Qt,Qv=wt,Xv=fg,Zv=Jm,$v=df,e_="No one promise resolved";qr({target:"Promise",stat:!0,forced:_v},{any:function(e){var t=this,i=Qv("AggregateError"),r=Xv.f(t),n=r.resolve,o=r.reject,s=Zv((function(){var r=Jv(t.resolve),s=[],a=0,c=1,d=!1;$v(e,(function(e){var u=a++,h=!1;c++,Yv(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,e_)))}))})),--c||o(new i(s,e_))}));return s.error&&o(s.value),r.promise}});var t_=qr,i_=Qm,r_=be,n_=wt,o_=qe,s_=zf,a_=xv,c_=i_&&i_.prototype;t_({target:"Promise",proto:!0,real:!0,forced:!!i_&&r_((function(){c_.finally.call({then:function(){}},(function(){}))}))},{finally:function(e){var t=s_(this,n_("Promise")),i=o_(e);return this.then(i?function(i){return a_(t,e()).then((function(){return i}))}:e,i?function(i){return a_(t,e()).then((function(){throw i}))}:e)}});var d_=Ee(Et.Promise);function u_(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 h_(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}class l_ extends y{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||T(8,"track-"),this._originMediaStreamTrack=e,this._mediaStreamTrack=e,ao(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){if(!e){const e=ue.reportApiInvoke(null,{name:E.GET_MEDIA_STREAM_TRACK,options:[],tag:b.TRACER});this._mediaStreamTrack&&"string"==typeof this._mediaStreamTrack.label?e.onSuccess(this._mediaStreamTrack.label):e.onSuccess("")}return this._mediaStreamTrack}getRTCRtpTransceiver(e){return e===vo.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,co(this),this.emit(Eo.CLOSED)}_updateRtpTransceiver(e,t){if(t===vo.LOW_STREAM){if(this._lowRtpTransceiver===e)return;this._lowRtpTransceiver=e}else{if(this._rtpTransceiver===e)return;this._rtpTransceiver=e}this.emit(To.TRANSCEIVER_UPDATED,e,t)}}class p_ extends l_{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 S("".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,de.debug("[".concat(this.getTrackId(),"] close")),this.emit(mo.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 k(this,mo.NEED_REPLACE_TRACK,this),this.processor&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this.processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Eo.TRACK_ENDED)}stateCheck(e,t){if(de.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),f(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new g(v.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",de);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new g(v.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",de)}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}function f_(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 m_=window.AudioContext||window.webkitAudioContext;let g_=null;const v_=new class extends y{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=()=>{de.info("ios15-interruption-start"),this.emit(ye.IOS_15_16_INTERRUPTION_START)},this.onLocalAudioTrackUnmute=async()=>{de.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?de.info("ios15-interruption-end-canceled"):(g_&&await g_.suspend(),this.emit(ye.IOS_15_16_INTERRUPTION_END))}}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){de.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){de.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 __(){if(!m_)return void de.error("your browser is not support web audio");de.info("create audio context");const t=function(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?f_(Object(i),!0).forEach((function(t){ap(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):f_(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}({},u("WEBAUDIO_INIT_OPTIONS"));de.debug("audio context init option:",JSON.stringify(t)),g_=new m_(t),v_.curState=g_.state,g_.onstatechange=()=>{v_.prevState=v_.curState,v_.curState=g_?g_.state:void 0;const{prevState:t,curState:i}=v_,r="running"===i,n="interrupted"===i,o="running"===t,s="suspended"===t,a="interrupted"===t,c=e().osVersion;(w()||A())&&o&&n&&(de.info("ios".concat(c,"-interruption-start")),v_.emit(ye.IOS_INTERRUPTION_START)),(w()||A())&&(s||a)&&r&&(de.info("ios".concat(c,"-interruption-end")),v_.emit(ye.IOS_INTERRUPTION_END)),t!==i&&v_.emit(ye.STATE_CHANGE,i,t)},setInterval((()=>{var e;const t=null===(e=g_)||void 0===e?void 0:e.currentTime;if(v_.currentTime!==t)v_.currentTimeStuckAt&&(de.debug("AudioContext current time resume at ".concat(t)),v_.currentTimeStuckAt=void 0),v_.currentTime=t;else{if(t!==v_.currentTimeStuckAt){ue.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:b.TRACER}).onSuccess(),de.warning("AudioContext current time stuck at ".concat(t))}v_.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):w()||A()?"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(w()){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)}v_.on(ye.STATE_CHANGE,c),s(!1)}(g_)}function y_(){if(!g_){if(__(),!g_)throw new g(v.NOT_SUPPORTED,"can not create audio context");return g_}return g_}function T_(){return!!g_}function E_(e){if(function(){if(null!==S_)return S_;const e=y_(),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(),S_=n,n}())return;const t=e.connect,i=e.disconnect;e.connect=(i,r,n)=>{var o;return e._inputNodes||(e._inputNodes=[]),zn(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?I(e._inputNodes,r):e._inputNodes=[];for(const i of e._inputNodes)t.call(e,i)}}function b_(e){const t=y_();return new d_(((i,r)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{r(new g(v.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let S_=null;function k_(e,t){let i=!1;const r=1/t;if(u("DISABLE_WEBAUDIO")){const t=window.setInterval((()=>{i?window.clearInterval(t):e(performance.now()/1e3)}),1e3*r)}else{const t=y_();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 I_=null;function w_(){if(I_)return I_;const e=y_();if(!e.createMediaStreamDestination)throw new g(v.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),I_=r.stream.getAudioTracks()[0],I_}function A_(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 O_(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}var D_=Qt,C_=fi,N_=ut,R_=sn,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_=be,U_=L_.left,V_=function(e,t){var i=[][e];return!!i&&x_((function(){i.call(null,t||function(){return 1},1)}))};qr({target:"Array",proto:!0,forced:!Rf&&Pt>79&&Pt<83||!V_("reduce")},{reduce:function(e){var t=arguments.length;return U_(this,e,t,t>1?arguments[1]:void 0)}});var j_=fn("Array").reduce,B_=De,F_=j_,H_=Array.prototype,G_=Ee((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=y_(),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||w()||A()||"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){de.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class K_ extends y{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=y_(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),E_(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(So.ON_AUDIO_BUFFER,A_(e))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!_e().webAudioMediaStreamDest)throw new g(v.NOT_SUPPORTED,"your browser is not support audio processor");return this.destNode&&this.outputTrack||(this.destNode=this.context.createMediaStreamDestination(),this.outputNode.connect(this.destNode),this.outputTrack=this.destNode.stream.getAudioTracks()[0]),this.outputTrack}play(e){"running"!==this.context.state&&r((()=>{v_.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;w()||A()?"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(t,i,r){var n;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(de.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 de.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>de.info("resume success"))),de.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),E_(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const i=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(i,this.context.currentTime),E_(this.outputNode),this.emit(So.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=t,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()},"audio"!==t.kind)throw new g(v.UNEXPECTED_ERROR);this.track=t;const o=new MediaStream([this.track]);if(this.isRemoteTrack=!!i,this.sourceNode=this.context.createMediaStreamSource(o),E_(this.sourceNode),r){const e=r.clone();e.enabled=!0,this.clonedTrack=e,de.debug("create an unmuted track ".concat(e.id," from the original track ").concat(r.id," to get the volume"));const t=this.context.createMediaStreamSource(new MediaStream([e]));E_(t),this.originVolumeLevelAnalyser=new W_,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=o;const s=e();i&&s.os===a.IOS&&Number(null===(n=s.osVersion)||void 0===n?void 0:n.split(".")[0])<15&&(v_.on(ye.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),E_(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit(So.UPDATE_SOURCE),this.audioElement.srcObject=t}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),v_.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),de.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]));E_(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 g(v.ELECTRON_IS_NULL);let r=null;try{var n;r=(null===(n=i.desktopCapturer)||void 0===n?void 0:n.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){r=null}r&&r.then||(r=new d_(((e,r)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?r(t):e(i)}))})));try{return await r}catch(e){throw new g(v.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 S("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 g)throw de.error("[".concat(t,"] ").concat(e.toString())),e;const r=iy(e.name||e.code||e,e.message);if(r.code===v.MEDIA_OPTION_INVALID){de.debug("[".concat(t,"] detect media option invalid, retry")),i+=1,await O(500);continue}throw de.error("[".concat(t,"] ").concat(r.toString())),r}if(!r)throw new g(v.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return r}async function ty(t,i,r){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new g(v.NOT_SUPPORTED,"can not find getUserMedia");r&&(t.video&&(delete t.video.width,delete t.video.height),t.screen&&(delete t.screen.width,delete t.screen.height));const n=_e(),o=new MediaStream;if(t.audioSource&&o.addTrack(t.audioSource),t.videoSource&&o.addTrack(t.videoSource),!t.audio&&!t.video&&!t.screen)return de.debug("Using Video Source/ Audio Source"),o;if(t.screen)if(N())if(t.screen.sourceId){ry(o,await q_(t.screen.sourceId,t.screen,t.screenAudio))}else{ry(o,await Y_(t.screen,t.screenAudio))}else if(R()&&t.screen.extensionId&&t.screen.mandatory){if(!n.getStreamFromExtension)throw new g(v.NOT_SUPPORTED,"This browser does not support screen sharing");de.debug("[".concat(i,'] Screen access on chrome stable, looking for extension"'));const e=await(a=t.screen.extensionId,l=i,new d_(((e,t)=>{try{chrome.runtime.sendMessage(a,{getStream:!0},(i=>{if(!i||!i.streamId)return de.error("[".concat(l,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new g(v.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){de.error("[".concat(l,"] AgoraRTC screensharing plugin is not accessible(").concat(a,")"),e.toString()),t(new g(v.CHROME_PLUGIN_NOT_INSTALL))}})));t.screen.mandatory.chromeMediaSourceId=e;ry(o,await navigator.mediaDevices.getUserMedia({video:{mandatory:t.screen.mandatory}}))}else if(n.getDisplayMedia){var s;t.screen.mediaSource&&fo(t.screen.mediaSource);const e={width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate,displaySurface:null!==(s=t.screen.displaySurface)&&void 0!==s?s:"screen"===t.screen.mediaSource?"monitor":t.screen.mediaSource},{selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a,monitorTypeSurfaces:c}=t.screen,d={selfBrowserSurface:r,surfaceSwitching:n,systemAudio:a,monitorTypeSurfaces:c};!r&&delete d.selfBrowserSurface,!n&&delete d.surfaceSwitching,!a&&delete d.systemAudio,!c&&delete d.monitorTypeSurfaces,de.debug("[".concat(i,"] getDisplayMedia:"),JSON.stringify({video:e,audio:!!t.screenAudio,controls:d}));const u=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){ap(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:e,audio:!!t.screenAudio},d));ry(o,u)}else{if(!h())throw de.error("[".concat(i,"] This browser does not support screenSharing")),new g(v.NOT_SUPPORTED,"This browser does not support screen sharing");{t.screen.mediaSource&&fo(t.screen.mediaSource);const e={video:{mediaSource:t.screen.mediaSource,width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate}};de.debug("[".concat(i,"] getUserMedia: ").concat(JSON.stringify(e)));ry(o,await navigator.mediaDevices.getUserMedia(e))}}var a,l;if(!t.video&&!t.audio)return o;let p={video:t.video,audio:t.audio},f=u("MEDIA_DEVICE_CONSTRAINTS");if(f)try{"string"==typeof f&&(f=JSON.parse(f)),p=M(p,f)}catch(e){}de.debug("[".concat(i,"] GetUserMedia"),JSON.stringify(p)),e();let m,_=null;(c()||w()||d())&&(_=await X_.lock());try{m=await navigator.mediaDevices.getUserMedia(p)}catch(e){throw _&&_(),e}return p.audio&&(Z_=!0),p.video&&($_=!0),ry(o,m),_&&_(),o}function iy(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new g(v.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new g(v.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new g(v.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new g(v.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new g(v.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new g(v.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return de.error("getUserMedia unexpected error",e),new g(v.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 y{get state(){return this._state}set state(e){e!==this._state&&(this.emit(Po.STATE_CHANGE,e),this._state=e)}constructor(){super(),this._state=Mo.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((()=>{(u("ENUMERATE_DEVICES_INTERVAL")||(P()||L())&&i())&&this.updateDevicesInfo()}),u("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>de.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 g(v.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const r=await navigator.mediaDevices.enumerateDevices(),n=this.checkMediaDeviceInfoIsOk(r);let o=!this.isAccessMicrophonePermission&&e,s=!this.isAccessCameraPermission&&t;n.audio&&(o=!1),n.video&&(s=!1);let a=null,c=null,d=null;if(!i&&(o||s)){if(X_.isLocked){de.debug("[device manager] wait GUM lock");(await X_.lock())(),de.debug("[device manager] GUM unlock")}if(Z_&&(o=!1,this.isAccessMicrophonePermission=!0),$_&&(s=!1,this.isAccessCameraPermission=!0),de.debug("[device manager] check media device permissions",e,t,o,s),o&&s){try{d=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(o){try{a=await navigator.mediaDevices.getUserMedia({audio:e})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(s){try{c=await navigator.mediaDevices.getUserMedia({video:t})}catch(e){const t=iy(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;de.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}de.debug("[device manager] mic permission",e,"cam permission",t)}try{const e=await navigator.mediaDevices.enumerateDevices();return a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null,e}catch(e){a&&a.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),a=null,c=null,d=null;return new g(v.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 g(v.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=Mo.INITING;try{await this.updateDevicesInfo(),this.state=Mo.INITEND}catch(e){if(de.warning("Device Detection functionality cannot start properly.",e.toString()),this.state=Mo.IDLE,!x()){new g(v.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?de.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is the same group")):de.warning("[device-check] default input ".concat(t.label," and output ").concat(i.label," is not the same group")):de.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!==Mo.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(Po.RECORDING_DEVICE_CHANGED,e);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(Po.CAMERA_DEVICE_CHANGED,e);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(Po.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 y{constructor(){super(...arguments),this.onAutoplayFailed=void 0,this.onAudioAutoplayFailed=void 0}};function cy(){if(e(),!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)),de.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),ay.onAutoplayFailed?ay.onAutoplayFailed():ay.onAudioAutoplayFailed?de.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 ."):de.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){ap(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=ue.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});ue.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=e=>{Array.from(this.elementMap.entries()).forEach((t=>{let[i,r]=t;const n=this.elementStateMap.get(i),o=r.srcObject.getAudioTracks()[0],s=o&&o.readyState;if(de.debug("resume after interrupted, ele: ".concat(n," audio: ").concat(s," ").concat(e)),"live"===s){if(e)return r.pause(),void r.play();if("running"===v_.curState)return V()?(r.pause(),void r.play()):void(n&&"paused"===n&&r.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&&(de.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))},this.autoResumeAudioElement(),v_.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),v_.on(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),v_.on(ye.STATE_CHANGE,(()=>{w()&&"suspended"===v_.prevState&&"running"===v_.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 g(v.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(e,t,i,n){if(this.elementMap.has(t))return;const o=document.createElement("audio");o.autoplay=!0,o.srcObject=new MediaStream([e]),this.bindAudioElementEvents(t,o),this.elementMap.set(t,o),this.elementStateMap.set(t,Lo.INIT),this.setVolume(t,i);const s=this.sinkIdMap.get(t);if(s)try{o.setSinkId(s).catch((e=>{de.warning("[".concat(t,"] set sink id failed"),e.toString())}))}catch(e){de.warning("[".concat(t,"] set sink id failed"),e.toString())}const a=o.play();a&&a.then&&a.catch((e=>{n&&hy(n,"audio",e.message,t),de.warning("audio element play warning",e.toString()),this.elementMap.has(t)&&"NotAllowedError"===e.name&&(de.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(o),r((()=>{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(de.debug("[".concat(e,"] audio-element-status change ").concat(r," => ").concat(n)),"error"===i.type){const i=null==t?void 0:t.error;i&&de.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=>{de.debug("Auto resume audio element success")})).catch((e=>{de.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 g(v.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",de);for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const n=r.apply(this,t);return n instanceof d_?new d_(((e,t)=>{n.then(e).catch(t)})):n}),i}}var my=fn("Array").values,gy=Dn,vy=vi,_y=De,yy=my,Ty=Array.prototype,Ey={DOMTokenList:!0,NodeList:!0},by=Ee((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){ap(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 y{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 g(v.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new g(v.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(No.ON_TRACK,e.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(No.ON_TRACK,void 0)}}class wy extends y{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,Ro.REQUEST_CONSTRAINTS)}async requestApplyConstraints(e,t){var i;return de.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),k(this,Ro.REQUEST_UPDATE_CONSTRAINTS,Array.from(by(i=this.constraintsMap).call(i)))}async requestRevertConstraints(e){var t;if(this.constraintsMap.has(e))return de.info("processor ".concat(e.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(e),k(this,Ro.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:n}of this.statsRegistry)try{const o=n();e.push({processorID:t,processorName:i,type:r,stats:o})}catch(e){de.error(new g(v.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 d_&&(i=await i),e.push(ky(ky({},i),{},{direction:this.direction}))}catch(e){de.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class Ay extends y{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 g(v.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new g(v.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(No.ON_TRACK,void 0),this.emit(No.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(No.ON_TRACK,this.inputTrack)),e.node&&this.inputNode!==e.node&&(this.audioProcessorContext.chained=!0,this.inputNode=e.node,this.emit(No.ON_NODE,this.inputNode))}}class Oy extends y{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,Ro.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(e,t){var i;return de.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),k(this,Ro.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),k(this,Ro.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:n}of this.statsRegistry)try{const o=n();e.push({processorID:t,processorName:i,type:r,stats:o})}catch(e){de.error(new g(v.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 d_&&(i=await i),e.push(ky(ky({},i),{},{direction:this.direction}))}catch(e){de.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class Dy extends y{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 g(v.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=[],de.debug("[macro-task-queue] is created."),this.trigger=window.setTimeout((()=>{this.state="closed",de.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,de.debug("[macro-task-queue] is closed.")}))}enqueue(e,t){"closed"!==this.state&&(this.tasks.push({key:e,func:t}),de.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);de.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,de.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){ap(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 p_{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(So.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:this.processorContext})}))},s=n&&c()&&!T_();if(u("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),u("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0)),o(),!u("DISABLE_WEBAUDIO")&&s){(Ny||(Ny=new Ry),Ny).enqueue("INIT_WEBAUDIO",(()=>{this._source=new z_(e,!1,this._getOriginVolumeLevel?e:void 0),u("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")||(this._useAudioElement=!0),o(),this.emit(ko.UPDATE_TRACK_SOURCE)}))}}setVolume(e){p(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 de.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const e=this._source.createOutputTrack();this._mediaStreamTrack!==e&&(this._mediaStreamTrack=e,k(this,mo.NEED_REPLACE_TRACK,this).then((()=>{de.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{de.warning("[".concat(this.getTrackId(),"] replace web audio track failed"),e)})))}catch(e){}}getVolumeLevel(){return this._muted&&this.enabled&&this._getOriginVolumeLevel?this._source.getOriginVolumeLevel():this._source.getAccurateVolumeLevel()}async setPlaybackDevice(e){if(!this._useAudioElement||!R()&&u("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new g(v.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(de.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){this._originMediaStreamTrack.enabled=!0;try{i||(this._enabled=!0),await k(this,mo.NEED_ENABLE_TRACK,this),de.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(e," success"))}catch(e){throw i||(this._enabled=!1),de.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,i||(this._enabled=!1);try{await k(this,mo.NEED_DISABLE_TRACK,this)}catch(e){throw i||(this._enabled=!0),de.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,de.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await k(this,mo.NEED_MUTE_TRACK,this):await k(this,mo.NEED_UNMUTE_TRACK,this))}getStats(){H((()=>{de.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const e=G(this,mo.GET_STATS);return e||Ly({},wo)}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners(So.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(So.ON_AUDIO_BUFFER),this._source.on(So.ON_AUDIO_BUFFER,(t=>e(t)))}play(){de.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(de.debug("[".concat(this.getTrackId(),"] start audio playback in element")),py.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){de.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];de.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 k(this,mo.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(e))}renewMediaStreamTrack(e){return d_.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new g(v.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new g(v.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(No.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e),await k(this,mo.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await k(this,mo.NEED_REPLACE_TRACK,this))})),this.processorDestination.on(No.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(No.ON_TRACK),this.processorDestination.removeAllListeners(No.ON_NODE)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Ro.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Ro.REQUEST_CONSTRAINTS)}}u_([My("INIT_WEBAUDIO"),h_("design:type",Object),h_("design:paramtypes",[Object])],xy.prototype,"_source",null),u_([My("INIT_WEBAUDIO"),h_("design:type",Oy),h_("design:paramtypes",[Oy])],xy.prototype,"processorContext",null),u_([My("INIT_WEBAUDIO"),h_("design:type",Ay),h_("design:paramtypes",[Ay])],xy.prototype,"processorDestination",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),h_("design:type",Function),h_("design:paramtypes",[Number]),h_("design:returntype",void 0)],xy.prototype,"setVolume",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[String]),h_("design:returntype",d_)],xy.prototype,"setPlaybackDevice",null),u_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean,Object,Boolean]),h_("design:returntype",d_)],xy.prototype,"setEnabled",null),u_([F("LocalAudioTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean]),h_("design:returntype",d_)],xy.prototype,"setMuted",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",Object)],xy.prototype,"getStats",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[Object,Number]),h_("design:returntype",void 0)],xy.prototype,"setAudioFrameCallback",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],xy.prototype,"play",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],xy.prototype,"stop",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],xy.prototype,"close",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",Object)],xy.prototype,"pipe",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("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?oo(t.encoderConfig):{},r,u("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())&&v_.bindInterruptDetectorTrack(this),this.on(ko.UPDATE_TRACK_SOURCE,(()=>{this.bindProcessorContextEvents()})),T_()&&this.bindProcessorContextEvents()}async setDevice(e){if(de.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 de.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 de.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 de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(e,t,i){if(t)return de.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(de.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 k(this,mo.NEED_DISABLE_TRACK,this)}catch(e){throw de.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 k(this,mo.NEED_ENABLE_TRACK,this)}catch(e){throw i||(this._enabled=!1),de.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(V()||W())&&v_.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((w()||A())&&this._enabled&&!this._isClosed&&v_.duringInterruption){const e=async()=>{v_.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(de.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};v_.on(ye.IOS_INTERRUPTION_END,e)}else de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Eo.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(Ro.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(Ro.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}}u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[String]),h_("design:returntype",d_)],Uy.prototype,"setDevice",null),u_([F("MicrophoneAudioTrack","_enabledMutex"),le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean,Boolean,Boolean]),h_("design:returntype",d_)],Uy.prototype,"setEnabled",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("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(So.AUDIO_SOURCE_STATE_CHANGE,(e=>{this.safeEmit(Eo.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){p(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}u_([le({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",void 0)],Vy.prototype,"startProcessAudioBuffer",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],Vy.prototype,"pauseProcessAudioBuffer",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Number]),h_("design:returntype",void 0)],Vy.prototype,"seekAudioBuffer",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],Vy.prototype,"resumeProcessAudioBuffer",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],Vy.prototype,"stopProcessAudioBuffer",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],Vy.prototype,"close",null),u_([le({argsMap:e=>[e.getTrackId()]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Number]),h_("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=y_().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,T(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)?(de.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):de.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){de.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}I(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(To.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=to(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),h()&&(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:r,surfaceSwitching:o,systemAudio:s,monitorTypeSurfaces:a}=e;(n(107)||q(107)||Y(93))&&(i&&(m(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),r?(m(r,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=r):t.selfBrowserSurface="include",o&&(m(o,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=o)),(n(119)||q(119)||Y(105))&&a&&(m(a,"monitorTypeSurfaces",["exclude","include"]),t.monitorTypeSurfaces=a),(n(105)||q(105)||Y(91))&&s&&(m(s,"systemAudio",["exclude","include"]),t.systemAudio=s),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const c=e.encoderConfig?io(e.encoderConfig):null;return t.mandatory={chromeMediaSource:"desktop",maxWidth:c?c.width:void 0,maxHeight:c?c.height:void 0},c&&(c.frameRate&&("number"==typeof c.frameRate?(t.mandatory.maxFrameRate=c.frameRate,t.mandatory.minFrameRate=c.frameRate):(t.mandatory.maxFrameRate=c.frameRate.max||c.frameRate.ideal||c.frameRate.exact||void 0,t.mandatory.minFrameRate=c.frameRate.min||c.frameRate.ideal||c.frameRate.exact||void 0),t.frameRate=c.frameRate),c.width&&(t.width=c.width),c.height&&(t.height=c.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=oo(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(So.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):de.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 d_(((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 g(v.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 y{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(),de.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){ap(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&&(de.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=Lo.NONE,this.isGettingVideoDimensions=!1,this.startGetVideoDimensions=()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return de.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"===v_.curState&&(de.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=Lo.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=Lo.CANPLAY;break;case"stalled":this.videoElementStatus=Lo.STALLED;break;case"suspend":this.videoElementStatus=Lo.SUSPEND;break;case"pause":this.videoElementStatus=Lo.PAUSED,w()||A()||c()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(de.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=Lo.WAITING;break;case"abort":this.videoElementStatus=Lo.ABORT;break;case"ended":this.videoElementStatus=Lo.ENDED;break;case"emptied":this.videoElementStatus=Lo.EMPTIED;break;case"error":{this.videoElementStatus=Lo.ERROR;const e=this.videoElement.error;e&&de.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>u("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&&(de.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"),v_.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),v_.on(ye.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(t){const i=this.videoElement.play();i&&i.catch&&i.catch((e=>{t&&hy(t,"video",e.message,this.trackId),"NotAllowedError"===e.name?(de.warning("detected video element autoplay failed",e),this.autoplayFailed=!0,this.handleAutoPlayFailed()):de.warning("[".concat(this.trackId,"] play warning: "),e)}));const r=e();if(("Safari"===r.name&&15===Number(r.version)||V())&&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 de.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 d_(((r,n)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await zy(e);r({buffer:t,width:i.width,height:i.height})}else n(new g(v.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await Ky(e)}destroy(){v_.off(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),v_.off(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[]}initVideoElement(){if(this.videoElementStatus=Lo.INIT,!this.videoElementCheckInterval&&(Xy.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{Z(this.videoElement)||(this.videoElementStatus=Lo.DESTROYED)}),1e3),u("ENABLE_VIDEO_FRAME_CALLBACK"))){var t,i;let e;const r=(t,i)=>{if(this.videoElementStatus===Lo.PLAYING){if(e){const t=i.presentationTime-e.presentationTime;t>u("VIDEO_FREEZE_DURATION")&&qy.lastVisibleTime>=qy.lastHiddenTime&&e.timestamp>qy.lastVisibleTime&&e.timestamp>qy.lastHiddenTime&&(this.renderFreezeAccTime+=t)}e=Jy(Jy({},i),{},{timestamp:t})}var n,o;u("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(n=(o=this.videoElement).requestVideoFrameCallback)||void 0===n||n.call(o,r))};null===(t=(i=this.videoElement).requestVideoFrameCallback)||void 0===t||t.call(i,r)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),P()&&(this.videoElement.poster="noposter");const r=e();if("Safari"===r.name&&15===Number(r.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,h()&&this.videoElement.load())}else this.videoElement.srcObject=this.videoTrack?new MediaStream([this.videoTrack]):null,h()&&this.videoElement.load();const n=this.videoElement.play();void 0!==n&&n.catch((e=>{de.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=Lo.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{de.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{de.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",u("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 d_(((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=w()?"canplay":"playing";n.addEventListener(o,(()=>{const e=n.videoWidth,i=n.videoHeight;!e&&h()||(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&&_e().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){ap(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 p_{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==Lo.PLAYING)}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(e,i,r,n,o,s){if(super(e,o),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,c()){const{width:t,height:i}=e.getSettings();this._videoWidth=t,this._videoHeight=i}else this.updateMediaStreamTrackResolution();if(this._encoderConfig=i,this._scalabilityMode=r,this._optimizationMode=n,this._hints=s||[],-1===this._hints.indexOf(go.SCREEN_TRACK))this.updateBitrateFromProfile();else if(ie(t.CHROME,115)&&re()){const t=iT(e);t&&(de.info("local screen video track begin to inject frame"),this._mediaStreamTrack=t)}i&&-1!==this._hints.indexOf(go.CUSTOM_TRACK)&&this.setEncoderConfiguration(i),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:(de.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}de.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(Eo.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),u("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,de.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(de.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){this._originMediaStreamTrack.enabled=!1;try{await k(this,mo.NEED_DISABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return t||(this._enabled=!1),void de.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await k(this,mo.NEED_ENABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}de.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,de.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await k(this,mo.NEED_MUTE_TRACK,this):await k(this,mo.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(e,t){if(!this._enabled)throw new g(v.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=to(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});(c()||w()||A())&&(t.deviceId=void 0),de.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 g(v.UNEXPECTED_ERROR,e.toString());throw de.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=e,-1===this._hints.indexOf(go.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,mo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}getStats(){H((()=>{de.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const e=G(this,mo.GET_STATS);return e||nT({},Ao)}async setBeautyEffect(e){de.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(de.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 k(this,mo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}}async setOptimizationMode(e){if("motion"!==e&&"detail"!==e&&"balanced"!==e)return void de.error(v.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const t=this._optimizationMode;try{this._optimizationMode=e,await k(this,mo.SET_OPTIMIZATION_MODE,this)}catch(e){throw this._optimizationMode=t,de.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(e,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return de.error(v.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,de.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 g(v.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");de.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(e)),e=to(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(go.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,mo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}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,u("BITRATE_ADAPTER_TYPE"))||[void 0,void 0];this._encoderConfig.bitrateMin||this._encoderConfig.bitrateMax||(this._encoderConfig.bitrateMin=n,this._encoderConfig.bitrateMax=r,de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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 g(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new g(v.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),to(e))),i=oe(i);const r=T(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),de.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 g(v.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new g(v.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}startMonitorStats(){if(!c()&&!w())return;this._statsTimer&&window.clearInterval(this._statsTimer);let e=2,t=Zn[e];let i=-1;let r=Date.now();const n=e=>{e>2||e<0||(r=Date.now(),t=Zn[e],this.setSenderConfiguration(t))};this.isUseScaleResolutionDownBy=!0,this._statsTimer=window.setInterval((()=>{const o=this.getStats(),s=G(this,mo.GET_RTC_STATS);if(o.sendPackets>0&&s){-1===i&&(i=Date.now());const a=Date.now();if(a-i<1e3||a-r<u("PROFILE_SWITCH_INTERVAL"))return;const c=o.sendFrameRate,d=.6*t.frameRate,h=.9*t.frameRate;"number"==typeof c&&c>0&&c<d?e>0&&(e--,n(e),de.debug("[".concat(this.getTrackId(),"] step down for fps ").concat(c,", switchProfile to ").concat(e))):s.OutgoingAvailableBandwidth<t.bitrateMin?e>0&&(e--,n(e),de.debug("[".concat(this.getTrackId(),"] step down for OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", bitrateMin ").concat(t.bitrateMin,", switchProfile to ").concat(e))):"number"==typeof c&&c>h&&e<Zn.length-1&&s.OutgoingAvailableBandwidth>1.2*Zn[e+1].bitrateMin&&(e++,n(e),de.debug("[".concat(this.getTrackId(),"] step up for fps ").concat(c,", OutgoingAvailableBandwidth ").concat(s.OutgoingAvailableBandwidth,", switchProfile to ").concat(e)))}}),u("CHECK_LOCAL_STATS_INTERVAL"))}bindProcessorDestinationEvents(){this.processorDestination.on(No.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(),await k(this,mo.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await k(this,mo.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(No.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(Ro.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(Ro.REQUEST_CONSTRAINTS)}}u_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Object,Object]),h_("design:returntype",void 0)],oT.prototype,"play",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],oT.prototype,"stop",null),u_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean,Boolean]),h_("design:returntype",d_)],oT.prototype,"setEnabled",null),u_([F("LocalVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean]),h_("design:returntype",d_)],oT.prototype,"setMuted",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Object,Boolean]),h_("design:returntype",d_)],oT.prototype,"setEncoderConfiguration",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",Object)],oT.prototype,"getStats",null),u_([le({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean,Object]),h_("design:returntype",d_)],oT.prototype,"setBeautyEffect",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",ImageData)],oT.prototype,"getCurrentFrameData",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[String,Number]),h_("design:returntype",d_)],oT.prototype,"getCurrentFrameImage",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",d_)],oT.prototype,"setBitrateLimit",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[String]),h_("design:returntype",d_)],oT.prototype,"setOptimizationMode",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",void 0)],oT.prototype,"setScalabiltyMode",null),u_([fy(),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],oT.prototype,"updateMediaStreamTrackResolution",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",Object)],oT.prototype,"pipe",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],oT.prototype,"unpipe",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],oT.prototype,"close",null),u_([le({argsMap:(e,t,i)=>[e.getTrackId(),t.label,i]}),h_("design:type",Function),h_("design:paramtypes",[MediaStreamTrack,Boolean]),h_("design:returntype",d_)],oT.prototype,"replaceTrack",null),u_([le(),h_("design:type",Function),h_("design:paramtypes",[]),h_("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,to(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&&(de.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=to(this._config.encoderConfig),v_.on(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),v_.on(ye.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(de.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 de.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 de.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 de.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){de.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 de.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),de.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(de.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 k(this,mo.NEED_ENABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),de.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 k(this,mo.NEED_DISABLE_TRACK,this)}catch(e){throw de.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}de.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(e,t){if(!this._enabled)throw new g(v.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=to(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);(c()||w()||A())&&(r.deviceId=void 0),de.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 g(v.UNEXPECTED_ERROR,e.toString());throw de.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(go.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await k(this,mo.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(de)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((w()||A())&&this._enabled&&!this._isClosed&&v_.duringInterruption){const e=async()=>{v_.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(de.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};v_.on(ye.IOS_INTERRUPTION_END,e)}else de.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Eo.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(),v_.off(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),v_.off(ye.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),to(e))),i=oe(i);const r=T(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),de.debug("clone track from ".concat(this.getTrackId()," to ").concat(r,", clone ").concat(t)),n}bindProcessorContextEvents(){this.processorContext.on(Ro.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(Ro.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){ap(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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),i=new xy(e.mediaStreamTrack,e.encoderConfig?oo(e.encoderConfig):{},T(8,"track-cus-"),!1,!0);return de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_MIC_AUDIO_TRACK,options:[e]}),i=Hy(e),r=T(8,"track-mic-");let n=null;de.info("start create microphone audio track with config",JSON.stringify(e),"trackId",r);try{n=(await ey({audio:i},r)).getAudioTracks()[0]||null}catch(e){throw t.onError(e),e}if(!n){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(de)}const o=new Uy(n,e,i,r);return t.onSuccess(o.getTrackId()),de.info("create microphone audio track success, trackId:",r),o}async function hT(e){var t;const{cacheOnlineFile:i,encoderConfig:r}=e;let{source:n}=e;const o={source:n instanceof AudioBuffer?"AudioBuffer":n instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":n,cacheOnlineFile:i,encoderConfig:r},s=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_BUFFER_AUDIO_TRACK,options:[o]});if(u("DISABLE_WEBAUDIO"))throw new g(v.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const a=T(8,"track-buf-");de.info("start create buffer source audio track with config",JSON.stringify(o),"trackId",a);const c=n;if(!(n instanceof AudioBuffer))try{n=await async function(e,t){let i=null;if("string"==typeof e){const t=Wy.get(e);if(t)return de.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 g(v.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new d_(((t,i)=>{const r=new FileReader;r.onload=e=>{e.target?t(e.target.result):i(new g(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.onerror=()=>{i(new g(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.readAsArrayBuffer(e)}));i=await t}const r=await b_(i);return"string"==typeof e&&t&&Wy.set(e,r),r}(n,i)}catch(e){return s.onError(e),e.throw(de)}const d=new Gy(n),h=new Vy(c,d,r?oo(r):{},a);return de.info("create buffer source audio track success, trackId:",a),s.onSuccess(h.getTrackId()),h}function lT(e){const t=new jy;return e.forEach((e=>t.addAudioTrack(e))),t}function pT(e){const t=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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?ro(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,T(8,"track-cus-"),[go.CUSTOM_TRACK]);return t.onSuccess(i.getTrackId()),de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_CAM_VIDEO_TRACK,options:[cT({},e)]}),i=By(e),r=T(8,"track-cam-");let n=null;const o="720p_auto"===e.encoderConfig;de.info("start create camera video track with config",JSON.stringify(e),"trackId",r);try{n=(await ey({video:i},r)).getVideoTracks()[0]||null}catch(e){throw t.onError(e),e}if(!n){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(de)}e.optimizationMode&&vT(r,n,e,to(e.encoderConfig));const s=new sT(n,e,i,e.scalabiltyMode?ro(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,r);return o&&s.startMonitorStats(),t.onSuccess(s.getTrackId()),de.info("create camera video success, trackId:",r),s}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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.CREATE_MIC_AND_CAM_TRACKS,options:[e,t]}),r="720p_auto"===t.encoderConfig,n=By(t),o=Hy(e),s=T(8,"track-mic-"),a=T(8,"track-cam-");let c=null,d=null;de.info("start create camera video track(".concat(a,") and microphone audio track(").concat(s,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await ey({audio:o,video:n},"".concat(s,"-").concat(a));c=e.getAudioTracks()[0],d=e.getVideoTracks()[0]}catch(e){throw i.onError(e),e}if(!c||!d){const e=new g(v.UNEXPECTED_ERROR,"can not find tracks in media stream");return i.onError(e),e.throw(de)}t.optimizationMode&&vT(a,d,t,to(t.encoderConfig));const u=new Uy(c,e,o,s),h=new sT(d,t,n,t.scalabiltyMode?ro(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,a);return r&&h.startMonitorStats(),i.onSuccess([u.getTrackId(),h.getTrackId()]),de.info("create camera video track(".concat(a,") and microphone audio track(").concat(s,") success")),[u,h]}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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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 n=Fy(e),o=T(8,"track-scr-v-");let s=null,a=null;const c=_e();if(!c.supportShareAudio&&"enable"===t){const e=new g(v.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return i.onError(e),e.throw(de)}de.info("start create screen video track with config",e,"withAudio",t,"trackId",o);try{const e=await ey({screen:n,screenAudio:"auto"===t?c.supportShareAudio:"enable"===t},o);s=e.getVideoTracks()[0]||null,a=e.getAudioTracks()[0]||null}catch(e){throw i.onError(e),e}if(!s){const e=new g(v.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(de)}if(!a&&"enable"===t){s&&s.stop();const e=new g(v.SHARE_AUDIO_NOT_ALLOWED);return i.onError(e),e.throw(de)}if(e.optimizationMode||(e.optimizationMode="detail"),e.optimizationMode){vT(o,s,e,e.encoderConfig&&io(e.encoderConfig)||void 0),e.encoderConfig&&"string"!=typeof e.encoderConfig&&(e.encoderConfig.bitrateMin=e.encoderConfig.bitrateMax)}const d=new oT(s,e.encoderConfig?io(e.encoderConfig):{},e.scalabiltyMode?ro(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,o,[go.SCREEN_TRACK]);if(r&&d.startMonitorStats(),!a)return i.onSuccess(d.getTrackId()),de.info("create screen video track success","video:",d.getTrackId()),d;const u=new xy(a,void 0,T(8,"track-scr-a-"),!1,!0);return i.onSuccess([d.getTrackId(),u.getTrackId()]),de.info("create screen video track success","video:",d.getTrackId(),"audio:",u.getTrackId()),[d,u]}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?de.debug("[".concat(e,"] set content hint to"),i.optimizationMode):de.debug("[".concat(e,"] set content hint failed")))):de.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){ap(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}u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",d_)],sT.prototype,"setDevice",null),u_([F("CameraVideoTrack","_enabledMutex"),le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Boolean,Boolean]),h_("design:returntype",d_)],sT.prototype,"setEnabled",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),fy(),h_("design:type",Function),h_("design:paramtypes",[Object,Boolean]),h_("design:returntype",d_)],sT.prototype,"setEncoderConfiguration",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],sT.prototype,"close",null);class TT extends l_{getUserId(){return this._userId}constructor(e,t,i,r){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(r.clientId,"_").concat(T(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,de.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!==Lo.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((()=>{de.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return G(this,mo.GET_STATS)||yT({},Co)}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:(de.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}de.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(bo.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(bo.VIDEO_ELEMENT_VISIBLE_STATUS,e)}catch(e){}}),u("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,de.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(){de.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=ue.reportApiInvoke(null,{tag:b.TRACER,name:E.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 g(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new g(v.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(No.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(No.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}}u_([le({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),h_("design:type",Function),h_("design:paramtypes",[Object,Object]),h_("design:returntype",void 0)],ET.prototype,"play",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],ET.prototype,"stop",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",Object)],ET.prototype,"pipe",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("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,u("DISABLE_WEBAUDIO")?(this._source=new Dy,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new z_(e,!0),u("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once(So.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(bo.FIRST_FRAME_DECODED)})),this.processorContext=new Oy(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new Ay(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on(So.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(So.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners(So.ON_AUDIO_BUFFER),this._source.on(So.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||!R()&&u("RESTRICTION_SET_PLAYBACK_DEVICE"))throw new g(v.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((()=>{de.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return G(this,mo.GET_STATS)||yT({},Oo)}play(){de.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(de.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(){de.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];de.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 g(v.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new g(v.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 g(v.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(No.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(No.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(No.ON_TRACK),this.processorDestination.removeAllListeners(No.ON_NODE)}}var ST;u_([le({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),h_("design:type",Function),h_("design:paramtypes",[Number]),h_("design:returntype",void 0)],bT.prototype,"setVolume",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t]}),h_("design:type",Function),h_("design:paramtypes",[String]),h_("design:returntype",d_)],bT.prototype,"setPlaybackDevice",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],bT.prototype,"play",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("design:returntype",void 0)],bT.prototype,"stop",null),u_([le({argsMap:(e,t)=>[e.getTrackId(),t.name]}),h_("design:type",Function),h_("design:paramtypes",[Object]),h_("design:returntype",Object)],bT.prototype,"pipe",null),u_([le({argsMap:e=>[e.getTrackId()]}),h_("design:type",Function),h_("design:paramtypes",[]),h_("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;u("SHOW_DATASTREAM2_LOG")&&de.debug("send data header: ".concat(JSON.stringify(t.commonPacketHeader)));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={length:16383&r,reserved:(16384&r)>>14,extension:(32768&r)>>15,sequence:t.getUint16(i+2,!0)<<16|t.getUint16(i,!0)};let o,s;if(i+=4,u("SHOW_DATASTREAM2_LOG")&&de.debug("receive data header: ".concat(JSON.stringify(n))),t.getUint16(i,!0),i+=2,n.extension){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 y{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 u("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 d_(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new g(v.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 g(v.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new g(v.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),[Vo.OPEN,Vo.CLOSE,Vo.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),i=new DataView(t).getUint8(3);if(i!==this.id)return void(u("SHOW_DATASTREAM2_LOG")&&de.debug("invalid datachannel id: ".concat(i," !== ").concat(this.id)));let r=e.data.slice(this._dataStreamPacketHeader.byteLength);r=this._dataStreamPacketHandler.deserialize(r),this.emit(Vo.MESSAGE,r)}}_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)}}}ve();export{ye as AUDIO_CONTEXT_EVENT,no as AUDIO_ENCODER_CONFIG_SETTINGS,ko as AUDIO_TRACK_EVENT,Oy as AudioProcessorContext,Ay as AudioProcessorDestination,So as AudioSourceEvents,Vy as BufferSourceAudioTrack,sT as CameraVideoTrack,wo as DEFAULT_LOCAL_AUDIO_TRACK_STATS,Ao as DEFAULT_LOCAL_VIDEO_TRACK_STATS,Do as DEFAULT_NETWORK_QUALITY_STATS,Oo as DEFAULT_REMOTE_AUDIO_TRACK_STATS,Co as DEFAULT_REMOTE_VIDEO_TRACK_STATS,IT as DataChannel,Vo as DataChannelEvents,ny as DeviceManager,Po as DeviceManagerEvent,Mo as DeviceManagerState,Z_ as HAS_GUM_AUDIO,$_ as HAS_GUM_VIDEO,xy as LocalAudioTrack,AT as LocalDataChannel,p_ as LocalTrack,Eo as LocalTrackEvents,oT as LocalVideoTrack,Uo as MediaElementNumStatus,Lo as MediaElementStatus,Uy as MicrophoneAudioTrack,jy as MixingAudioTrack,Ro as PROCESSOR_CONTEXT_EVENTS,No as PROCESSOR_DESTINATION_EVENTS,bT as RemoteAudioTrack,wT as RemoteDataChannel,yo as RemoteStreamFallbackType,_o as RemoteStreamType,TT as RemoteTrack,bo as RemoteTrackEvents,ET as RemoteVideoTrack,X_ as SAFARI_GLOBAL_GUM_LOCK,Zn as SUPPORT_720P_AUTO_CONFIG_LIST,$n as SUPPORT_SCREEN_ENCODER_CONFIG_LIST,eo as SUPPORT_SVC_CONFIG_LIST,Xn as SUPPORT_VIDEO_ENCODER_CONFIG_LIST,vo as StreamType,l_ as Track,To as TrackEvents,go as TrackHint,mo as TrackInternalEvent,wy as VideoProcessorContext,Iy as VideoProcessorDestination,so as __TRACK_LIST__,ao as addTrack,v_ as audioContextState,py as audioElementPlayCenter,k_ 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,b_ as decodeAudioData,oy as deviceManager,Ky as emptyImage2TypedArray,tT as frameData2CryptoBuffer,y_ as getAudioContext,oo as getAudioEncoderConfiguration,eT as getBitrateFromResAndFps,_e as getCompatibility,By as getConstraintsFromCameraConfig,Hy as getConstraintsFromMicrophoneConfig,Fy as getConstraintsFromScreenConfig,J_ as getElectronScreenSources,q_ as getElectronScreenStream,Y_ as getElectronScreenStreamByUserSelect,ey as getLocalStream,ro as getScalabilityConfiguration,io as getScreenEncoderConfiguration,w_ as getSilenceAudioTrack,O_ as getSilenceSamplesDuration,iT as getStaticTrackStream,to as getVideoEncoderConfiguration,iy as handleGetUserMediaError,T_ as hasAudioContext,ho as isAudioEncoderConfiguration,po as isAudioEncoderConfigurationOrPreset,xo as isBeautyEffectOptions,Io as isLowStreamParameter,fo as isScreenSourceType,uo as isVideoEncoderConfiguration,lo as isVideoEncoderConfigurationOrPreset,E_ as polyfillAudioNode,co as removeTrack,cy as requestAutoplayGesture,A_ as silenceScriptProcessHandler,ve as updateAgoraRTCCompatibility,qy as visibilityWatcher};