6 lines
155 KiB
JavaScript
6 lines
155 KiB
JavaScript
/**
|
|
* AgoraWebSDK_N-v4.22.1-0-g1c8e27e9 Copyright AgoraInc.
|
|
*/
|
|
|
|
import"webrtc-adapter";import{getBrowserInfo as e,BrowserName as t,isChromeKernel as i,nextTick as r,isAboveChrome as o,isAboveFirefox as s,isAboveSafari as a,BrowserOS as n,isSafari as c,isWkWebview as d,getParameter as u,isFirefox as h,isChrome as l,isEdge as p,isMobile as m,checkValidConstrainLong as _,checkValidNumber as g,checkValidBoolean as E,checkValidEnum as T,AgoraRTCError as f,AgoraRTCErrorCode as v,isEmpty as y,EventEmitter as S,getRandomString as k,runOnce as b,AgoraAPIName as I,AgoraAPITag as A,PromiseMutex as w,emitAsPromiseNoResponse as R,removeItemFromList as D,isIOS as C,isIpadOS as N,wait as O,showElectronSelectSourceWindow as M,getElectronInstance as P,isElectron as L,recursiveMerge as V,isAndroid as x,isHarmonyOS as U,detectSecureContext as B,isAndroidChromium as F,domLoadedPromise as H,isIOS15 as G,emitAsPromise as W,noop as K,isLegacyChrome as z,isAboveEdge as j,isAboveOpera as Y,constrainLongToNumber as Z,hexToBytes as X,md5 as J,atom as Q,emitAsInvokerNoResponse as q,isIOS16 as $,retryable as ee,getOSWithVersion as te,isAboveIOS15_1 as ie,isInPage as re,isBetweenBrowser as oe,isWindows as se,elementVisibleChecker as ae,safeCloneJson as ne,jsonClone as ce,isAboveIOS15_2 as de,isWechatBrowser as ue}from"@agora-js/shared";export{isElectron}from"@agora-js/shared";import{logger as he,report as le,AgoraRTCEventUploadType as pe,apiInvoke as me}from"@agora-js/report";import _e from"axios";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,supportRequestVideoFrameCallback:!1,supportWebCrypto:!1};function Ee(){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===n.WIN_10||i.os===n.WIN_81||i.os===n.WIN_7||i.os===n.LINUX||i.os===n.MAC_OS||i.os===n.CHROMIUM_OS)&&i.name===t.CHROME&&Number(i.version)>=74)return!0;return!1}(),ge.supportDataChannel=function(){if(o(76)||s(68)||a(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||"Safari"===t.name&&Number(t.version)>=15}(),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}(),ge.supportRequestVideoFrameCallback=function(){if("requestVideoFrameCallback"in HTMLVideoElement.prototype)return!0;return!1}(),ge.supportWebCrypto="undefined"!=typeof window&&void 0!==window.crypto&&void 0!==window.crypto.subtle,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"))}(),he.info("browser compatibility",JSON.stringify(ge),JSON.stringify(l))}))}function Te(){return ge}function fe(){return"setSinkId"in HTMLAudioElement.prototype&&(!u("RESTRICTION_SET_PLAYBACK_DEVICE")||(l()||p())&&!m())}function ve(){return!ge.supportUnifiedPlan||u("CHROME_FORCE_PLAN_B")&&i()}let ye=function(e){return 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",e}({});function Se(e,t,i){return{sampleRate:e,stereo:t,bitrate:i}}function ke(e,t,i,r,o){return{width:e,height:t,frameRate:i,bitrateMin:r,bitrateMax:o}}function be(e,t,i,r,o){return{width:{max:e},height:{max:t},frameRate:i,bitrateMin:r,bitrateMax:o}}function Ie(e,t){return{numSpatialLayers:e,numTemporalLayers:t}}const Ae={"90p":ke(160,90),"90p_1":ke(160,90),"120p":ke(160,120,15,30,65),"120p_1":ke(160,120,15,30,65),"120p_3":ke(120,120,15,30,50),"120p_4":ke(212,120),"180p":ke(320,180,15,30,140),"180p_1":ke(320,180,15,30,140),"180p_3":ke(180,180,15,30,100),"180p_4":ke(240,180,15,30,120),"240p":ke(320,240,15,40,200),"240p_1":ke(320,240,15,40,200),"240p_3":ke(240,240,15,40,140),"240p_4":ke(424,240,15,40,220),"360p":ke(640,360,15,80,400),"360p_1":ke(640,360,15,80,400),"360p_3":ke(360,360,15,80,260),"360p_4":ke(640,360,30,80,600),"360p_6":ke(360,360,30,80,400),"360p_7":ke(480,360,15,80,320),"360p_8":ke(480,360,30,80,490),"360p_9":ke(640,360,15,80,800),"360p_10":ke(640,360,24,80,800),"360p_11":ke(640,360,24,80,1e3),"480p":ke(640,480,15,100,500),"480p_1":ke(640,480,15,100,500),"480p_2":ke(640,480,30,100,1e3),"480p_3":ke(480,480,15,100,400),"480p_4":ke(640,480,30,100,750),"480p_6":ke(480,480,30,100,600),"480p_8":ke(848,480,15,100,610),"480p_9":ke(848,480,30,100,930),"480p_10":ke(640,480,10,100,400),"720p":ke(1280,720,15,120,1130),"720p_auto":ke(1280,720,30,900,3e3),"720p_1":ke(1280,720,15,120,1130),"720p_2":ke(1280,720,30,120,2e3),"720p_3":ke(1280,720,30,120,1710),"720p_5":ke(960,720,15,120,910),"720p_6":ke(960,720,30,120,1380),"1080p":ke(1920,1080,15,120,2080),"1080p_1":ke(1920,1080,15,120,2080),"1080p_2":ke(1920,1080,30,120,3e3),"1080p_3":ke(1920,1080,30,120,3150),"1080p_5":ke(1920,1080,60,120,4780),"1440p":ke(2560,1440,30,120,4850),"1440p_1":ke(2560,1440,30,120,4850),"1440p_2":ke(2560,1440,60,120,7350),"4k":ke(3840,2160,30,120,8910),"4k_1":ke(3840,2160,30,120,8910),"4k_3":ke(3840,2160,60,120,13500)},we=[{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}],Re={"480p":be(640,480,5),"480p_1":be(640,480,5),"480p_2":be(640,480,30),"480p_3":be(640,480,15),"720p":be(1280,720,5),"720p_auto":ke(1280,720,30,900,3e3),"720p_1":be(1280,720,5),"720p_2":be(1280,720,30),"720p_3":be(1280,720,15),"1080p":be(1920,1080,5),"1080p_1":be(1920,1080,5),"1080p_2":be(1920,1080,30),"1080p_3":be(1920,1080,15)},De={"1SL1TL":Ie(1,1),"3SL3TL":Ie(3,3),"2SL3TL":Ie(2,3)};function Ce(e){return e||(e="480p_1"),"string"==typeof e?Object.assign({},Ae[e]):e}function Ne(e){return"string"==typeof e?Object.assign({},Re[e]):e}function Oe(e){return"string"==typeof e?Object.assign({},De[e]):e}const Me={speech_low_quality:Se(16e3,!1),speech_standard:Se(32e3,!1,18),music_standard:Se(48e3,!1),standard_stereo:Se(48e3,!0,56),high_quality:Se(48e3,!1,128),high_quality_stereo:Se(48e3,!0,192)};function Pe(e){return"string"==typeof e?Object.assign({},Me[e]):e}const Le=[];function Ve(e){Le.includes(e)||Le.push(e)}function xe(e){const t=Le.indexOf(e);-1!==t&&Le.splice(t,1)}function Ue(e){return _(e.width,"config.width"),_(e.height,"config.height"),void 0!==e.frameRate&&_(e.frameRate,"config.frameRate"),void 0!==e.bitrateMax&&g(e.bitrateMax,"config.bitrateMax"),void 0!==e.bitrateMin&&g(e.bitrateMin,"config.bitrateMin"),!0}function Be(e){return void 0!==e.sampleRate&&g(e.sampleRate,"config.sampleRate",0,96e3,!0),void 0!==e.sampleSize&&g(e.sampleRate,"config.sampleSize",0,128,!0),void 0!==e.stereo&&E(e.stereo,"config.stereo"),void 0!==e.bitrate&&g(e.bitrate,"config.bitrate",0,1e4,!1),!0}function Fe(e){return"string"==typeof e?T(e,"profile",Object.keys(Ae)):Ue(e),!0}function He(e){return"string"==typeof e?T(e,"profile",Object.keys(Me)):Be(e),!0}function Ge(e){return T(e,"mediaSource",["screen","window","application"]),!0}let We=function(e){return e.NEED_RENEGOTIATE="@need_renegotiate",e.NEED_REPLACE_TRACK="@need_replace_track",e.NEED_REPLACE_MIXING_TRACK="@need_replace_mixing_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_UPDATE_VIDEO_SEND_PARAMETERS="@need_update_video_send_parameters",e.NEED_MUTE_TRACK="@need_mute_track",e.NEED_UNMUTE_TRACK="@need_unmute_track",e}({}),Ke=function(e){return e.SCREEN_TRACK="screen_track",e.CUSTOM_TRACK="custome_track",e.LOW_STREAM="low_stream",e.SCREEN_LOW_TRACK="screen_low_track",e}({});function ze(e){if(!e)throw new f(v.INVALID_PARAMS);return y(e.width)||_(e.width,"streamParameter.width"),y(e.height)||_(e.height,"streamParameter.height"),y(e.framerate)||_(e.framerate,"streamParameter.framerate"),y(e.bitrate)||g(e.bitrate,"streamParameter.bitrate"),!0}let je=function(e){return e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM",e}({}),Ye=function(e){return e[e.HIGH_STREAM=0]="HIGH_STREAM",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.HIGH_STREAM_LAYER1=4]="HIGH_STREAM_LAYER1",e[e.HIGH_STREAM_LAYER2=5]="HIGH_STREAM_LAYER2",e[e.HIGH_STREAM_LAYER3=6]="HIGH_STREAM_LAYER3",e[e.HIGH_STREAM_LAYER4=7]="HIGH_STREAM_LAYER4",e[e.HIGH_STREAM_LAYER5=8]="HIGH_STREAM_LAYER5",e[e.HIGH_STREAM_LAYER6=9]="HIGH_STREAM_LAYER6",e}({}),Ze=function(e){return e[e.DISABLE=0]="DISABLE",e[e.LOW_STREAM=1]="LOW_STREAM",e[e.AUDIO_ONLY=2]="AUDIO_ONLY",e[e.HIGH_STREAM_LAYER1=3]="HIGH_STREAM_LAYER1",e[e.HIGH_STREAM_LAYER2=4]="HIGH_STREAM_LAYER2",e[e.HIGH_STREAM_LAYER3=5]="HIGH_STREAM_LAYER3",e[e.HIGH_STREAM_LAYER4=6]="HIGH_STREAM_LAYER4",e[e.HIGH_STREAM_LAYER5=7]="HIGH_STREAM_LAYER5",e[e.HIGH_STREAM_LAYER6=8]="HIGH_STREAM_LAYER6",e}({}),Xe=function(e){return e.TRANSCEIVER_UPDATED="transceiver-updated",e.SEI_TO_SEND="sei-to-send",e.SEI_RECEIVED="sei-received",e.TRACK_UPDATED="track-updated",e}({}),Je=function(e){return 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",e}({}),Qe=function(e){return e.FIRST_FRAME_DECODED="first-frame-decoded",e.VIDEO_ELEMENT_VISIBLE_STATUS="video-element-visible-status",e.VIDEO_STATE_CHANGED="video-state-changed",e}({}),qe=function(e){return e.AUDIO="audio",e.VIDEO="video",e.DATA="data",e}({}),$e=function(e){return 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",e}({}),et=function(e){return e.UPDATE_TRACK_SOURCE="update-track-source",e}({});const tt={sendVolumeLevel:0,sendBitrate:0,sendBytes:0,sendPackets:0,sendPacketsLost:0,sendJitterMs:0,sendRttMs:0,currentPacketLossRate:0},it={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},rt={transportDelay:0,end2EndDelay:0,receiveBitrate:0,receiveLevel:0,receiveBytes:0,receiveDelay:0,receivePackets:0,receivePacketsLost:0,receivePacketsDiscarded:0,totalDuration:0,totalFreezeTime:0,freezeRate:0,packetLossRate:0,currentPacketLossRate:0,publishDuration:-1},ot={uplinkNetworkQuality:0,downlinkNetworkQuality:0},st={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};let at=function(e){return e.ON_TRACK="on_track",e.ON_NODE="on_node",e}({}),nt=function(e){return e.REQUEST_UPDATE_CONSTRAINTS="request_update_constraints",e.REQUEST_CONSTRAINTS="request_constraints",e}({}),ct=function(e){return e.IDLE="IDLE",e.INITING="INITING",e.INITEND="INITEND",e}({}),dt=function(e){return e.STATE_CHANGE="state_change",e.RECORDING_DEVICE_CHANGED="recordingDeviceChanged",e.PLAYOUT_DEVICE_CHANGED="playoutDeviceChanged",e.CAMERA_DEVICE_CHANGED="cameraDeviceChanged",e}({});function ut(e){return void 0!==e.smoothnessLevel&&g(e.smoothnessLevel,"options.smoothnessLevel",0,1,!1),void 0!==e.lighteningLevel&&g(e.lighteningLevel,"options.lighteningLevel",0,1,!1),void 0!==e.rednessLevel&&g(e.rednessLevel,"options.rednessLevel",0,1,!1),void 0!==e.lighteningContrastLevel&&T(e.lighteningContrastLevel,"options.lighteningContrastLevel",[0,1,2]),!0}let ht=function(e){return 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",e}({}),lt=function(e){return e[e.VideoStateStopped=0]="VideoStateStopped",e[e.VideoStateStarting=1]="VideoStateStarting",e[e.VideoStateDecoding=2]="VideoStateDecoding",e[e.VideoStateFrozen=3]="VideoStateFrozen",e}({});const pt={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};let mt=function(e){return e.OPEN="open",e.MESSAGE="message",e.CLOSE="close",e.CLOSING="closing",e.ERROR="error",e}({});function _t(e,t,i,r,o){var s={};return Object.keys(r).forEach((function(e){s[e]=r[e]})),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=i.slice().reverse().reduce((function(i,r){return r(e,t,i)||i}),s),o&&void 0!==s.initializer&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0),void 0===s.initializer&&(Object.defineProperty(e,t,s),s=null),s}function gt(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function Et(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 Tt(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?Et(Object(i),!0).forEach((function(t){gt(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):Et(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}class ft extends S{set _mediaStreamTrack(e){e!==this.mediaStreamTrack&&(this.safeEmit(Xe.TRACK_UPDATED,e),this.mediaStreamTrack=e)}get _mediaStreamTrack(){return this.mediaStreamTrack}constructor(e,t){super(),gt(this,"trackMediaType",void 0),gt(this,"_ID",void 0),gt(this,"_rtpTransceiver",void 0),gt(this,"_lowRtpTransceiver",void 0),gt(this,"_hints",[]),gt(this,"_isClosed",!1),gt(this,"_originMediaStreamTrack",void 0),gt(this,"mediaStreamTrack",void 0),gt(this,"_external",{}),this._ID=t||k(8,"track-"),this._originMediaStreamTrack=e,this.mediaStreamTrack=e,Ve(this)}toString(){return this._ID}getTrackId(){return this._ID}getMediaStreamTrack(e){return e||b((()=>{var e;le.reportApiInvoke(null,{name:I.GET_MEDIA_STREAM_TRACK,options:[],tag:A.TRACER}).onSuccess((null===(e=this._mediaStreamTrack)||void 0===e?void 0:e.label)||"")}),this.mediaStreamTrack.id||this.getTrackId()),this._mediaStreamTrack}getRTCRtpTransceiver(e){return e===je.LOW_STREAM?this._lowRtpTransceiver:this._rtpTransceiver}getMediaStreamTrackSettings(){return this.getMediaStreamTrack(!0).getSettings()}close(){this._isClosed=!0,this._lowRtpTransceiver=void 0,this._rtpTransceiver=void 0,xe(this),this.emit(Je.CLOSED),this.removeAllListeners(Xe.SEI_RECEIVED)}_updateRtpTransceiver(e,t){if(t===je.LOW_STREAM){if(this._lowRtpTransceiver===e)return;this._lowRtpTransceiver=e}else{if(this._rtpTransceiver===e)return;this._rtpTransceiver=e}this.emit(Xe.TRANSCEIVER_UPDATED,e,t)}}class vt extends ft{get isExternalTrack(){return this._isExternalTrack}get muted(){return this._muted}get enabled(){return this._enabled}get processorContext(){return this._processorContext}constructor(e,t){super(e,t),gt(this,"_enabled",!0),gt(this,"_muted",!1),gt(this,"_isExternalTrack",!1),gt(this,"_isClosed",!1),gt(this,"_enabledMutex",void 0),gt(this,"processor",void 0),gt(this,"_processorContext",void 0),gt(this,"_handleTrackEnded",(()=>{this.onTrackEnded()})),this._enabledMutex=new w("".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,he.debug("[".concat(this.getTrackId(),"] close")),this.emit(We.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 R(this,We.NEED_REPLACE_TRACK,this),this.processor&&this._processorContext&&this.processor.updateInput({track:this._originMediaStreamTrack,context:this._processorContext}))}_getDefaultPlayerConfig(){return{}}onTrackEnded(){he.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Je.TRACK_ENDED)}stateCheck(e,t){if(he.debug("check track state, [muted: ".concat(this._muted,", enabled: ").concat(this._enabled,"] to [").concat(e,": ").concat(t,"]")),E(t,e),this._enabled&&this._muted&&"enabled"===e&&!1===t)throw new f(v.TRACK_STATE_UNREACHABLE,"cannot set enabled while the track is muted").print("error",he);if(!this._enabled&&!this._muted&&"muted"===e&&!0===t)throw new f(v.TRACK_STATE_UNREACHABLE,"cannot set muted while the track is disabled").print("error",he)}getProcessorStats(){return this._processorContext&&this._processorContext.gatherStats()||[]}getProcessorUsage(){return this._processorContext?this._processorContext.gatherUsage():Promise.resolve([])}}const yt=window.AudioContext||window.webkitAudioContext;let St=null;const kt=new class extends S{constructor(){super(...arguments),gt(this,"prevState",void 0),gt(this,"curState",void 0),gt(this,"currentTime",void 0),gt(this,"currentTimeStuckAt",void 0),gt(this,"interruptDetectorTrack",void 0),gt(this,"onLocalAudioTrackMute",(()=>{he.info("ios15-interruption-start"),this.emit(ye.IOS_15_16_INTERRUPTION_START)})),gt(this,"onLocalAudioTrackUnmute",(async()=>{he.info("ios15-interruption-end"),"running"!==this.curState||this.duringInterruption?he.info("ios15-interruption-end-canceled"):(St&&await St.suspend(),this.emit(ye.IOS_15_16_INTERRUPTION_END))}))}get duringInterruption(){return"running"===this.prevState&&"interrupted"===this.curState}bindInterruptDetectorTrack(e){he.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){he.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 bt(){if(!yt)return void he.error("your browser is not support web audio");he.info("create audio context");const t=Tt({},u("WEBAUDIO_INIT_OPTIONS"));he.debug("audio context init option:",JSON.stringify(t)),St=new yt(t),kt.curState=St.state,St.onstatechange=()=>{kt.prevState=kt.curState,kt.curState=St?St.state:void 0;const{prevState:t,curState:i}=kt,r="running"===i,o="interrupted"===i,s="running"===t,a="suspended"===t,n="interrupted"===t,c=e().osVersion;(C()||N())&&s&&o&&(he.info("ios".concat(c,"-interruption-start")),kt.emit(ye.IOS_INTERRUPTION_START)),(C()||N())&&(a||n)&&r&&(he.info("ios".concat(c,"-interruption-end")),kt.emit(ye.IOS_INTERRUPTION_END)),t!==i&&kt.emit(ye.STATE_CHANGE,i,t)},setInterval((()=>{var e;const t=null===(e=St)||void 0===e?void 0:e.currentTime;if(kt.currentTime!==t)kt.currentTimeStuckAt&&(he.debug("AudioContext current time resume at ".concat(t)),kt.currentTimeStuckAt=void 0),kt.currentTime=t;else{if(t!==kt.currentTimeStuckAt){le.reportApiInvoke(null,{name:"WEB_AUDIO_CURRENT_TIME_STUCK",options:{currentTime:t},tag:A.TRACER}).onSuccess(),he.warning("AudioContext current time stuck at ".concat(t))}kt.currentTimeStuckAt=t}}),5e3),async function(e){const t=["click","contextmenu","auxclick","dblclick","mousedown","mouseup","touchend","keydown","keyup"];let i,r=!1,o=!1,s=!1;function a(t){"running"===e.state?n(!1):C()||N()?"suspended"===e.state&&(n(!0),t&&e.resume().then(d,d)):"closed"!==e.state&&(n(!0),t&&e.resume().then(d,d))}function n(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(){a(!0)}function d(){a(!1)}function u(){a(!0)}function h(e){if(!s)if(i.paused)if(e){let e;l(!1),s=!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(o!==e){o=e;for(let i=0,r=t;i<r.length;i++){const t=r[i];e?window.addEventListener(t,m,{capture:!0,passive:!0}):window.removeEventListener(t,m,{capture:!0,passive:!0})}}}function p(){i.removeEventListener("playing",p),i.removeEventListener("abort",p),i.removeEventListener("error",p),s=!1,h(!1)}function m(){h(!0)}if(C()){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)}kt.on(ye.STATE_CHANGE,c),a(!1)}(St)}function It(){if(!St){if(bt(),!St)throw new f(v.NOT_SUPPORTED,"can not create audio context");return St}return St}function At(){return!!St}function wt(e){if(function(){if(null!==Dt)return Dt;const e=It(),t=e.createBufferSource(),i=e.createGain(),r=e.createGain();t.connect(i),t.connect(r),t.disconnect(i);let o=!1;try{t.disconnect(i)}catch(e){o=!0}return t.disconnect(),Dt=o,o}())return;const t=e.connect,i=e.disconnect;e.connect=(i,r,o)=>(e._inputNodes||(e._inputNodes=[]),e._inputNodes.includes(i)||(i instanceof AudioNode?(e._inputNodes.push(i),t.call(e,i,r,o)):t.call(e,i,r)),e),e.disconnect=(r,o,s)=>{i.call(e),r?D(e._inputNodes,r):e._inputNodes=[];for(const i of e._inputNodes)t.call(e,i)}}function Rt(e){const t=It();return new Promise(((i,r)=>{t.decodeAudioData(e,(e=>{i(e)}),(e=>{r(new f(v.DECODE_AUDIO_FILE_FAILED,e.toString()))}))}))}let Dt=null;function Ct(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=It();let o=t.createGain();o.gain.value=0,o.connect(t.destination);const s=()=>{if(i)return void(o=null);const a=t.createOscillator();a.onended=s,a.connect(o),a.start(0),a.stop(t.currentTime+r),e(t.currentTime)};s()}return()=>{i=!0}}let Nt=null;function Ot(){if(Nt)return Nt;const e=It();if(!e.createMediaStreamDestination)throw new f(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),Nt=r.stream.getAudioTracks()[0],Nt}function Mt(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 Pt(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}class Lt{constructor(){gt(this,"context",void 0),gt(this,"analyserNode",void 0),gt(this,"sourceNode",void 0),this.context=It(),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||C()||N()||"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=e.reduce(((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){he.warning("rebuild analyser node failed.")}}destroy(){this.updateSource(void 0)}}class Vt extends S{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(),gt(this,"outputNode",void 0),gt(this,"outputTrack",void 0),gt(this,"isPlayed",!1),gt(this,"sourceNode",void 0),gt(this,"context",void 0),gt(this,"audioBufferNode",void 0),gt(this,"destNode",void 0),gt(this,"audioOutputLevel",0),gt(this,"volumeLevelAnalyser",void 0),gt(this,"_processedNode",void 0),gt(this,"playNode",void 0),gt(this,"isDestroyed",!1),gt(this,"onNoAudioInput",void 0),gt(this,"isNoAudioInput",!1),gt(this,"_noAudioInputCount",0),this.context=It(),this.playNode=this.context.destination,this.outputNode=this.context.createGain(),wt(this.outputNode),this.volumeLevelAnalyser=new Lt}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($e.ON_AUDIO_BUFFER,Mt(e))})}stopGetAudioBuffer(){this.audioBufferNode&&(this.audioBufferNode.onaudioprocess=null,this.outputNode.disconnect(this.audioBufferNode),this.audioBufferNode=void 0)}createOutputTrack(){if(!Te().webAudioMediaStreamDest)throw new f(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((()=>{kt.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;C()||N()?"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 xt extends Vt{get isFreeze(){return!1}constructor(t,i,r){var o;if(super(),gt(this,"sourceNode",void 0),gt(this,"track",void 0),gt(this,"clonedTrack",void 0),gt(this,"audioElement",void 0),gt(this,"isCurrentTrackCloned",!1),gt(this,"isRemoteTrack",!1),gt(this,"originVolumeLevelAnalyser",void 0),gt(this,"rebuildWebAudio",(async()=>{if(he.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 he.debug("rebuild web audio success, current volume status",this.getAccurateVolumeLevel());this.context.resume().then((()=>he.info("resume success"))),he.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),wt(this.sourceNode),this.volumeLevelAnalyser.rebuildAnalyser();const i=this.outputNode.gain.value;this.outputNode=this.context.createGain(),this.outputNode.gain.setValueAtTime(i,this.context.currentTime),wt(this.outputNode),this.emit($e.UPDATE_SOURCE),this.connect(),this.audioElement.srcObject=t,this.isPlayed&&this.play(this.playNode),this.checkHasAudioInput()})),"audio"!==t.kind)throw new f(v.UNEXPECTED_ERROR);this.track=t;const s=new MediaStream([this.track]);if(this.isRemoteTrack=!!i,this.sourceNode=this.context.createMediaStreamSource(s),wt(this.sourceNode),r){const e=r.clone();e.enabled=!0,this.clonedTrack=e,he.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]));wt(t),this.originVolumeLevelAnalyser=new Lt,this.originVolumeLevelAnalyser.updateSource(t)}this.connect(),this.audioElement=document.createElement("audio"),this.audioElement.srcObject=s;const a=e();i&&a.os===n.IOS&&Number(null===(o=a.osVersion)||void 0===o?void 0:o.split(".")[0])<15&&(kt.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),wt(this.sourceNode),this.processedNode||this.sourceNode.connect(this.outputNode),this.emit($e.UPDATE_SOURCE),this.audioElement.srcObject=t}destroy(){var e;this.audioElement.srcObject=null,this.audioElement.remove(),kt.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),he.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]));wt(i),this.originVolumeLevelAnalyser&&this.originVolumeLevelAnalyser.updateSource(i)}getOriginVolumeLevel(){return this.originVolumeLevelAnalyser?this.originVolumeLevelAnalyser.getVolumeLevel():this.getAccurateVolumeLevel()}}async function Ut(e,t,i){const r=(e,t)=>e?"number"!=typeof e?e.max||e.exact||e.ideal||e.min||t:e:t,o={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?(o.video.mandatory.maxFrameRate=t.frameRate.max,o.video.mandatory.minFrameRate=t.frameRate.min):"number"==typeof t.frameRate&&(o.video.mandatory.maxFrameRate=t.frameRate),await navigator.mediaDevices.getUserMedia(o)}async function Bt(e,t){const i=await Ft(e.mediaSource),{sourceId:r,audio:o}=await M(i,t);return await Ut(r,e,o)}async function Ft(e){let t=["window","screen"];"application"!==e&&"window"!==e||(t=["window"]),"screen"===e&&(t=["screen"]);const i=P();if(!i)throw console.error("failed to fetch electron, please mount it to window"),new f(v.ELECTRON_IS_NULL);let r=null;try{var o;r=(null===(o=i.desktopCapturer)||void 0===o?void 0:o.getSources({types:t}))||i.ipcRenderer.invoke("DESKTOP_CAPTURER_GET_SOURCES",{types:t})}catch(e){r=null}r&&r.then||(r=new Promise(((e,r)=>{i.desktopCapturer.getSources({types:t},((t,i)=>{t?r(t):e(i)}))})));try{return await r}catch(e){throw new f(v.ELECTRON_DESKTOP_CAPTURER_GET_SOURCES_ERROR,e.toString())}}const Ht=new w("safari");let Gt=!1,Wt=!1;async function Kt(e,t){let i=0,r=null;for(;i<2;)try{r=await zt(e,t,i>0);break}catch(e){if(e instanceof f)throw he.error("[".concat(t,"] ").concat(e.toString())),e;const r=jt(e.name||e.code||e,e.message);if(r.code===v.MEDIA_OPTION_INVALID){he.debug("[".concat(t,"] detect media option invalid, retry")),i+=1,await O(500);continue}throw he.error("[".concat(t,"] ").concat(r.toString())),r}if(!r)throw new f(v.UNEXPECTED_ERROR,"can not find stream after getUserMedia");return r}async function zt(t,i,r){if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new f(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 o=Te(),s=new MediaStream;if(t.audioSource&&s.addTrack(t.audioSource),t.videoSource&&s.addTrack(t.videoSource),!t.audio&&!t.video&&!t.screen)return he.debug("Using Video Source/ Audio Source"),s;if(t.screen)if(L())if(t.screen.sourceId){Yt(s,await Ut(t.screen.sourceId,t.screen,t.screenAudio))}else{Yt(s,await Bt(t.screen,t.screenAudio))}else if(l()&&t.screen.extensionId&&t.screen.mandatory){if(!o.getStreamFromExtension)throw new f(v.NOT_SUPPORTED,"This browser does not support screen sharing");he.debug("[".concat(i,'] Screen access on chrome stable, looking for extension"'));const e=await(n=t.screen.extensionId,p=i,new Promise(((e,t)=>{try{chrome.runtime.sendMessage(n,{getStream:!0},(i=>{if(!i||!i.streamId)return he.error("[".concat(p,"] No response from Chrome Plugin. Plugin not installed properly"),i),void t(new f(v.CHROME_PLUGIN_NO_RESPONSE,"No response from Chrome Plugin. Plugin not installed properly"));e(i.streamId)}))}catch(e){he.error("[".concat(p,"] AgoraRTC screensharing plugin is not accessible(").concat(n,")"),e.toString()),t(new f(v.CHROME_PLUGIN_NOT_INSTALL))}})));t.screen.mandatory.chromeMediaSourceId=e;Yt(s,await navigator.mediaDevices.getUserMedia({video:{mandatory:t.screen.mandatory}}))}else if(o.getDisplayMedia){var a;t.screen.mediaSource&&Ge(t.screen.mediaSource);const e={width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate,displaySurface:null!==(a=t.screen.displaySurface)&&void 0!==a?a:"screen"===t.screen.mediaSource?"monitor":t.screen.mediaSource},{selfBrowserSurface:r,surfaceSwitching:o,systemAudio:n}=t.screen,c={selfBrowserSurface:r,surfaceSwitching:o,systemAudio:n};!r&&delete c.selfBrowserSurface,!o&&delete c.surfaceSwitching,!n&&delete c.systemAudio,he.debug("[".concat(i,"] getDisplayMedia:"),JSON.stringify({video:e,audio:!!t.screenAudio,controls:c}));Yt(s,await navigator.mediaDevices.getDisplayMedia(Tt({video:e,audio:!!t.screenAudio},c)))}else{if(!h())throw he.error("[".concat(i,"] This browser does not support screenSharing")),new f(v.NOT_SUPPORTED,"This browser does not support screen sharing");{t.screen.mediaSource&&Ge(t.screen.mediaSource);const e={video:{mediaSource:t.screen.mediaSource,width:t.screen.width,height:t.screen.height,frameRate:t.screen.frameRate}};he.debug("[".concat(i,"] getUserMedia: ").concat(JSON.stringify(e)));Yt(s,await navigator.mediaDevices.getUserMedia(e))}}var n,p;if(!t.video&&!t.audio)return s;let m={video:t.video,audio:t.audio},_=u("MEDIA_DEVICE_CONSTRAINTS");if(_)try{"string"==typeof _&&(_=JSON.parse(_)),m=V(m,_)}catch(e){}he.debug("[".concat(i,"] GetUserMedia"),JSON.stringify(m)),e();let g,E=null;(c()||C()||d())&&(E=await Ht.lock());try{g=await navigator.mediaDevices.getUserMedia(m)}catch(e){throw E&&E(),e}return m.audio&&(Gt=!0),m.video&&(Wt=!0),Yt(s,g),E&&E(),s}function jt(e,t){switch(e){case"Starting video failed":case"OverconstrainedError":case"TrackStartError":return new f(v.MEDIA_OPTION_INVALID,"".concat(e,": ").concat(t));case"NotFoundError":case"DevicesNotFoundError":return new f(v.DEVICE_NOT_FOUND,"".concat(e,": ").concat(t));case"NotSupportedError":return new f(v.NOT_SUPPORTED,"".concat(e,": ").concat(t));case"NotReadableError":return new f(v.NOT_READABLE,"".concat(e,": ").concat(t));case"InvalidStateError":case"NotAllowedError":case"PERMISSION_DENIED":case"PermissionDeniedError":return new f(v.PERMISSION_DENIED,"".concat(e,": ").concat(t));case"ConstraintNotSatisfiedError":return new f(v.CONSTRAINT_NOT_SATISFIED,"".concat(e,": ").concat(t));default:return he.error("getUserMedia unexpected error",e),new f(v.UNEXPECTED_ERROR,"".concat(e,": ").concat(t))}}function Yt(e,t){const i=e.getVideoTracks()[0],r=e.getAudioTracks()[0],o=t.getVideoTracks()[0],s=t.getAudioTracks()[0];s&&(r&&e.removeTrack(r),e.addTrack(s)),o&&(i&&e.removeTrack(i),e.addTrack(o))}class Zt extends S{get state(){return this._state}set state(e){e!==this._state&&(this.emit(dt.STATE_CHANGE,e),this._state=e)}constructor(){super(),gt(this,"_state",ct.IDLE),gt(this,"isAccessMicrophonePermission",!1),gt(this,"isAccessCameraPermission",!1),gt(this,"lastAccessMicrophonePermission",!1),gt(this,"lastAccessCameraPermission",!1),gt(this,"checkdeviceMatched",!1),gt(this,"deviceInfoMap",new Map),this.init().then((()=>{navigator.mediaDevices.addEventListener&&navigator.mediaDevices.addEventListener("devicechange",this.updateDevicesInfo.bind(this)),window.setInterval((()=>{(u("ENUMERATE_DEVICES_INTERVAL")||(x()||U())&&i())&&this.updateDevicesInfo()}),u("ENUMERATE_DEVICES_INTERVAL_TIME"))})).catch((e=>he.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 f(v.NOT_SUPPORTED,"enumerateDevices() not supported.").throw()}const r=await navigator.mediaDevices.enumerateDevices(),o=this.checkMediaDeviceInfoIsOk(r);let s=!this.isAccessMicrophonePermission&&e,a=!this.isAccessCameraPermission&&t;o.audio&&(s=!1),o.video&&(a=!1);let n=null,c=null,d=null;if(!i&&(s||a)){if(Ht.isLocked){he.debug("[device manager] wait GUM lock");(await Ht.lock())(),he.debug("[device manager] GUM unlock")}if(Gt&&(s=!1,this.isAccessMicrophonePermission=!0),Wt&&(a=!1,this.isAccessCameraPermission=!0),he.debug("[device manager] check media device permissions",e,t,s,a),s&&a){try{d=await navigator.mediaDevices.getUserMedia({audio:!0,video:!0})}catch(e){const t=jt(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;he.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0,this.isAccessMicrophonePermission=!0}else if(s){try{n=await navigator.mediaDevices.getUserMedia({audio:e})}catch(e){const t=jt(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;he.warning("getUserMedia failed in getDevices",t)}this.isAccessMicrophonePermission=!0}else if(a){try{c=await navigator.mediaDevices.getUserMedia({video:t})}catch(e){const t=jt(e.name||e.code||e,e.message);if(t.code===v.PERMISSION_DENIED)throw t;he.warning("getUserMedia failed in getDevices",t)}this.isAccessCameraPermission=!0}he.debug("[device manager] mic permission",e,"cam permission",t)}try{const e=await navigator.mediaDevices.enumerateDevices();return n&&n.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),n=null,c=null,d=null,e}catch(e){n&&n.getTracks().forEach((e=>e.stop())),c&&c.getTracks().forEach((e=>e.stop())),d&&d.getTracks().forEach((e=>e.stop())),n=null,c=null,d=null;return new f(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 f(v.DEVICE_NOT_FOUND,"deviceId: ".concat(e));return t}async init(){this.state=ct.INITING;try{await this.updateDevicesInfo(),this.state=ct.INITEND}catch(e){if(he.warning("Device Detection functionality cannot start properly.",e.toString()),this.state=ct.IDLE,!B()){new f(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?he.debug("[device-check] default input ".concat(t.label," and output ").concat(i.label," is the same group")):he.warning("[device-check] default input ".concat(t.label," and output ").concat(i.label," is not the same group")):he.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!==ct.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(dt.RECORDING_DEVICE_CHANGED,e);break;case"videoinput":this.lastAccessCameraPermission&&this.isAccessCameraPermission&&this.emit(dt.CAMERA_DEVICE_CHANGED,e);break;case"audiooutput":this.lastAccessMicrophonePermission&&this.isAccessMicrophonePermission&&this.emit(dt.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 Xt=new Zt;let Jt=!1;const Qt=new class extends S{constructor(){super(...arguments),gt(this,"onAutoplayFailed",void 0),gt(this,"onAudioAutoplayFailed",void 0)}};function qt(){if(e(),!Jt){const e=t=>{t.preventDefault(),Jt=!1,F()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};Jt=!0,F()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),he.info("detect media autoplay failed, document: https://docs.agora.io/cn/Voice/autoplay_policy_web_ng?platform=Web"),Qt.onAutoplayFailed?Qt.onAutoplayFailed():Qt.onAudioAutoplayFailed?he.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 ."):he.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 ."),Qt.emit("autoplay-failed")}}function $t(e,t,i,r){if(!e)return;const o=le.getBaseInfoBySessionId(e);if(!o)return;const s=o.info,a=Date.now(),n=Tt(Tt({},s),{},{vid:void 0===s.vid?0:Number(s.vid),lts:a,elapse:a-o.startTime,cbRegistered:Qt.onAutoplayFailed||Qt.onAudioAutoplayFailed?1:-1,errorMsg:i,mediaType:t,trackId:r,extend:void 0});le.send({type:pe.AUTOPLAY_FAILED,data:n},!0)}const ei=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","error"],ti=new class{constructor(){gt(this,"onAutoplayFailed",void 0),gt(this,"elementMap",new Map),gt(this,"elementStateMap",new Map),gt(this,"elementsNeedToResume",[]),gt(this,"sinkIdMap",new Map),gt(this,"autoResumeAfterInterruption",(e=>{Array.from(this.elementMap.entries()).forEach((t=>{let[i,r]=t;const o=this.elementStateMap.get(i),s=r.srcObject.getAudioTracks()[0],a=s&&s.readyState;if(he.debug("resume after interrupted, ele: ".concat(o," audio: ").concat(a," ").concat(e)),"live"===a){if(e)return r.pause(),void r.play();if("running"===kt.curState)return G()?(r.pause(),void r.play()):void(o&&"paused"===o&&r.play())}}))})),gt(this,"autoResumeAfterInterruptionOnIOS15_16",(()=>{Array.from(this.elementMap.entries()).forEach((e=>{let[t,i]=e;const r=i.srcObject.getAudioTracks()[0];r&&"live"===r.readyState&&(he.debug("auto resume after interruption inside autoResumeAfterInterruptionOnIOS15"),i.pause(),i.play())}))})),this.autoResumeAudioElement(),kt.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),kt.on(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),kt.on(ye.STATE_CHANGE,(()=>{C()&&"suspended"===kt.prevState&&"running"===kt.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 f(v.PERMISSION_DENIED,"can not set sink id: "+e.toString())}}play(e,t,i,o){if(this.elementMap.has(t))return;const s=document.createElement("audio");s.autoplay=!0,s.srcObject=new MediaStream([e]),this.bindAudioElementEvents(t,s),this.elementMap.set(t,s),this.elementStateMap.set(t,ht.INIT),this.setVolume(t,i);const a=this.sinkIdMap.get(t);if(a)try{s.setSinkId(a).catch((e=>{he.warning("[".concat(t,"] set sink id failed"),e.toString())}))}catch(e){he.warning("[".concat(t,"] set sink id failed"),e.toString())}const n=s.play();n&&n.then&&n.catch((e=>{o&&$t(o,"audio",e.message,t),he.warning("audio element play warning",e.toString()),this.elementMap.has(t)&&"NotAllowedError"===e.name&&(he.warning("detected audio element autoplay failed"),this.elementsNeedToResume.push(s),r((()=>{this.onAutoplayFailed&&this.onAutoplayFailed(),qt()})))}))}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){ei.forEach((i=>{t.addEventListener(i,(i=>{const r=this.elementStateMap.get(e),o="pause"===i.type?"paused":i.type;if(he.debug("[".concat(e,"] audio-element-status change ").concat(r," => ").concat(o)),"error"===i.type){const i=null==t?void 0:t.error;i&&he.error("[".concat(e,"] media error, code: ").concat(i.code,", message: ").concat(i.message))}this.elementStateMap.set(e,o)}))}))}getPlayerState(e){return this.elementStateMap.get(e)||"uninit"}autoResumeAudioElement(){const e=()=>{this.elementsNeedToResume.forEach((e=>{e.play().then((e=>{he.debug("Auto resume audio element success")})).catch((e=>{he.warning("Auto resume audio element failed!",e)}))})),this.elementsNeedToResume=[]};H().then((()=>{F()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0))}))}};function ii(){return function(e,t,i){const r=i.value;return"function"==typeof r&&(i.value=function(){this._isClosed&&new f(v.INVALID_OPERATION,"[".concat(this.getTrackId(),"] cannot operate a closed track")).print("warning",he);for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const o=r.apply(this,t);return o instanceof Promise?new Promise(((e,t)=>{o.then(e).catch(t)})):o}),i}}class ri extends S{constructor(e){super(),gt(this,"name","VideoProcessorDestination"),gt(this,"ID","0"),gt(this,"_source",void 0),gt(this,"videoContext",void 0),gt(this,"inputTrack",void 0),this.videoContext=e}get kind(){return"video"}get enabled(){return!0}pipe(){throw new f(v.NOT_SUPPORTED,"VideoProcessor cannot pipe to any other Processor")}unpipe(){throw new f(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(at.ON_TRACK,e.track))}reset(){this.inputTrack=void 0,this.videoContext.chained=!1,this.emit(at.ON_TRACK,void 0)}}class oi extends S{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t){super(),gt(this,"constraintsMap",new Map),gt(this,"statsRegistry",[]),gt(this,"usageRegistry",[]),gt(this,"trackId",void 0),gt(this,"direction",void 0),gt(this,"_chained",!1),this.trackId=e,this.direction=t}async getConstraints(){return await W(this,nt.REQUEST_CONSTRAINTS)}async requestApplyConstraints(e,t){return he.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),R(this,nt.REQUEST_UPDATE_CONSTRAINTS,Array.from(this.constraintsMap.values()))}async requestRevertConstraints(e){if(this.constraintsMap.has(e))return he.info("processor ".concat(e.name," requestRevertConstraints for ").concat(this.trackId)),this.constraintsMap.delete(e),R(this,nt.REQUEST_UPDATE_CONSTRAINTS,Array.from(this.constraintsMap.values()))}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:o}of this.statsRegistry)try{const s=o();e.push({processorID:t,processorName:i,type:r,stats:s})}catch(e){he.error(new f(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 Promise&&(i=await i),e.push(Tt(Tt({},i),{},{direction:this.direction}))}catch(e){he.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class si extends S{constructor(e){super(),gt(this,"name","AudioProcessorDestination"),gt(this,"ID","0"),gt(this,"inputTrack",void 0),gt(this,"inputNode",void 0),gt(this,"audioProcessorContext",void 0),gt(this,"_source",void 0),this.audioProcessorContext=e}get kind(){return"audio"}get enabled(){return!0}pipe(){throw new f(v.NOT_SUPPORTED,"AudioProcessorDestination cannot pipe to any other Processor")}unpipe(){throw new f(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(at.ON_TRACK,void 0),this.emit(at.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(at.ON_TRACK,this.inputTrack)),e.node&&this.inputNode!==e.node&&(this.audioProcessorContext.chained=!0,this.inputNode=e.node,this.emit(at.ON_NODE,this.inputNode))}}class ai extends S{set chained(e){this._chained=e}get chained(){return this._chained}constructor(e,t,i){super(),gt(this,"constraintsMap",new Map),gt(this,"statsRegistry",[]),gt(this,"audioContext",void 0),gt(this,"trackId",void 0),gt(this,"direction",void 0),gt(this,"usageRegistry",[]),gt(this,"_chained",!1),this.audioContext=e,this.trackId=t,this.direction=i}async getConstraints(){return W(this,nt.REQUEST_CONSTRAINTS)}getAudioContext(){return this.audioContext}async requestApplyConstraints(e,t){return he.info("processor ".concat(t.name," requestApplyConstraints for ").concat(this.trackId)),e&&this.constraintsMap.set(t,e),R(this,nt.REQUEST_UPDATE_CONSTRAINTS,Array.from(this.constraintsMap.values()))}async requestRevertConstraints(e){if(this.constraintsMap.has(e))return this.constraintsMap.delete(e),R(this,nt.REQUEST_UPDATE_CONSTRAINTS,Array.from(this.constraintsMap.values()))}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:o}of this.statsRegistry)try{const s=o();e.push({processorID:t,processorName:i,type:r,stats:s})}catch(e){he.error(new f(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 Promise&&(i=await i),e.push(Tt(Tt({},i),{},{direction:this.direction}))}catch(e){he.error("gather extension usage error",e)}return e}getDirection(){return this.direction}}class ni extends S{get isPlayed(){return!0}get isFreeze(){return!1}constructor(){super(),gt(this,"context",void 0),gt(this,"processSourceNode",void 0),gt(this,"outputTrack",void 0),gt(this,"processedNode",void 0),gt(this,"clonedTrack",void 0),gt(this,"outputNode",void 0),this.outputNode=new ci}setVolume(){}createOutputTrack(){throw new f(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 ci{disconnect(){}connect(){}}function di(e){return new Promise(((t,i)=>{let r=!1;const o=document.createElement("video");o.setAttribute("autoplay",""),o.setAttribute("muted",""),o.muted=!0,o.autoplay=!0,o.setAttribute("playsinline",""),o.setAttribute("style","position: fixed; top: 0; left: 0; width: 1px; height: 1px"),document.body.appendChild(o);const s=C()?"canplay":"playing";o.addEventListener(s,(()=>{const e=o.videoWidth,i=o.videoHeight;!e&&h()||(r=!0,o.srcObject=null,o.remove(),t([e,i]))})),o.srcObject=new MediaStream([e]),o.play().catch(K),setTimeout((()=>{r||(o.srcObject=null,o.remove(),t([o.videoWidth,o.videoHeight]))}),4e3)}))}function ui(e){const t={};e.facingMode&&(t.facingMode=e.facingMode),e.cameraId&&(t.deviceId={exact:e.cameraId});const i=Ce(e.encoderConfig);return null!=i.width&&(t.width=i.width),null!=i.height&&(t.height=i.height),!z()&&i.frameRate&&(t.frameRate=i.frameRate),p()&&"object"==typeof t.frameRate&&(t.frameRate.max=60),h()&&(t.frameRate={ideal:30,max:30}),t}function hi(e){const t={};e.screenSourceType&&(t.mediaSource=e.screenSourceType),e.extensionId&&l()&&(t.extensionId=e.extensionId);const{displaySurface:i,selfBrowserSurface:r,surfaceSwitching:s,systemAudio:a}=e;(o(107)||j(107)||Y(93))&&(i&&(T(i,"displaySurface",["browser","window","monitor"]),t.displaySurface=i),r?(T(r,"selfBrowserSurface",["exclude","include"]),t.selfBrowserSurface=r):t.selfBrowserSurface="include",s&&(T(s,"surfaceSwitching",["exclude","include"]),t.surfaceSwitching=s)),(o(105)||j(105)||Y(91))&&a&&(T(a,"systemAudio",["exclude","include"]),t.systemAudio=a),e.electronScreenSourceId&&(t.sourceId=e.electronScreenSourceId);const n=e.encoderConfig?Ne(e.encoderConfig):null;return t.mandatory={chromeMediaSource:"desktop",maxWidth:n?n.width:void 0,maxHeight:n?n.height:void 0},n&&(n.frameRate&&("number"==typeof n.frameRate?(t.mandatory.maxFrameRate=n.frameRate,t.mandatory.minFrameRate=n.frameRate):(t.mandatory.maxFrameRate=n.frameRate.max||n.frameRate.ideal||n.frameRate.exact||void 0,t.mandatory.minFrameRate=n.frameRate.min||n.frameRate.ideal||n.frameRate.exact||void 0),t.frameRate=n.frameRate),n.width&&(t.width=n.width),n.height&&(t.height=n.height)),t}function li(e){const t={};if(z()||(void 0!==e.AGC&&(t.autoGainControl=e.AGC),void 0!==e.AEC&&(t.echoCancellation=e.AEC),void 0!==e.ANS&&(t.noiseSuppression=e.ANS,l()&&e.ANS&&(t.googHighpassFilter=e.ANS))),e.encoderConfig){const i=Pe(e.encoderConfig);t.channelCount=i.stereo?2:1,t.sampleRate=i.sampleRate,t.sampleSize=i.sampleSize}return e.microphoneId&&(t.deviceId={exact:e.microphoneId}),x()&&(t.sampleRate=void 0),t}function pi(e,t,i,r,o){const s=u("BITRATE_ADAPTER_TYPE");if("DEFAULT_BITRATE"===s)return{min:r,max:o};if(void 0===o){var a;const n=Math.floor(200*Math.pow(i/15,.6)*Math.pow(e*t/640/360,.75));o="STANDARD_BITRATE"===s?4*n:2*n,r=null!==(a=r)&&void 0!==a?a:n}else{var n;r=null!==(n=r)&&void 0!==n?n:Math.floor(o/10)}return{min:r,max:o}}function mi(e,t,i){const r=200*Math.pow(i/15,.6)*Math.pow(e*t/640/360,.75);return{min:Math.floor(r),max:Math.floor(4*r)}}const _i=e=>{const t=e._encoderConfig;if(!t)return;const{frameRate:i,width:r,height:o}=e.getMediaStreamTrackSettings();let{frameRate:s=i,width:a=r,height:n=o}=t;if(!s||!a||!n)return;a=Z(a),n=Z(n),s=Z(s);const{max:c,min:d}=mi(a,n,s),{bitrateMax:h,bitrateMin:l}=t||{};h||he.debug("calculate bitrate: [w: ".concat(a,", h: ").concat(n,", fps: ").concat(s,"] => [brMax: ").concat(h,", brMin: ").concat(l,"]"));const{maxFramerate:p}=u("ENCODER_CONFIG_LIMIT");return p&&"number"==typeof p&&(s=Math.min(s,p)),{frameRate:s,bitrateMax:h||c,bitrateMin:l||d,scaleResolutionDownBy:1,scale:0}},gi=async(e,t,i)=>await(async(e,t,i)=>{const r=X(J(""+t+i)).slice(0,16),o=r.slice(0,12),s=await window.crypto.subtle.importKey("raw",r,"AES-GCM",!0,["encrypt"]);return new Uint8Array(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:o},s,e))})(e.buffer,t,i),Ei=e=>{const t=document.createElement("canvas");return t.width=2,t.height=2,new Promise(((i,r)=>{t.toBlob((async e=>{if(t.remove(),e){const r=await Ti(e);i({buffer:r,width:t.width,height:t.height})}else r(new f(v.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,1)}))},Ti=async e=>{const t=await e.arrayBuffer();return new Uint8Array(t)};function fi(e,t){if("VideoFrame"in window&&"TransformStream"in window&&Te().supportWebRTCInsertableStream){const i=new MediaStreamTrackProcessor(e),r=new MediaStreamTrackGenerator({kind:"video"});let o,s,a=Date.now();const n=()=>{c&&(clearInterval(c),c=void 0),o&&(o.close(),o=void 0),e.stop(),s=void 0,r.removeEventListener("ended",n)};let c=window.setInterval((()=>{if(s&&o&&Date.now()-a>(null!=t?t:1e3))try{"live"===r.readyState?s.enqueue(o.clone()):n()}catch(e){n()}}),null!=t?t:1e3);const d=new TransformStream({transform:(e,t)=>{"live"===r.readyState?(s=t,a=Date.now(),void 0===o?(o=e,t.enqueue(e.clone())):(t.enqueue(o),o=e)):e.close()}});return r.addEventListener("ended",n),i.readable.pipeThrough(d).pipeTo(r.writable),r}}var vi,yi,Si,ki,bi,Ii,Ai,wi,Ri,Di,Ci,Ni,Oi,Mi,Pi,Li,Vi,xi,Ui,Bi,Fi,Hi,Gi,Wi,Ki,zi,ji,Yi,Zi,Xi,Ji,Qi,qi,$i,er,tr,ir,rr,or,sr;let ar=(vi=me({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),yi=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Si=ii(),ki=Q("LocalAudioTrack","_enabledMutex"),bi=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Ii=ii(),Ai=Q("LocalAudioTrack","_enabledMutex"),wi=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Ri=ii(),Di=ii(),Ci=ii(),Ni=me({argsMap:e=>[e.getTrackId()]}),Oi=ii(),Mi=me({argsMap:e=>[e.getTrackId()]}),Pi=ii(),Li=me({argsMap:e=>[e.getTrackId()]}),Vi=me({argsMap:(e,t)=>[e.getTrackId(),t.name]}),xi=me({argsMap:e=>[e.getTrackId()]}),_t((Ui=class extends vt{get _source(){return this.initWebAudio()}set _source(e){this._trackSource=e}get processorContext(){return this._processorContext||(this._processorContext=this.initProcessor().processorContext),this._processorContext}get processorDestination(){return this._processorDestination||(this._processorDestination=this.initProcessor().processorDestination),this._processorDestination}get isPlaying(){return this._useAudioElement?ti.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"LocalAudioTrack"}constructor(e,t,i,r){super(e,i),gt(this,"trackMediaType",qe.AUDIO),gt(this,"_encoderConfig",void 0),gt(this,"_trackSource",void 0),gt(this,"_enabled",!0),gt(this,"_volume",100),gt(this,"_useAudioElement",!0),gt(this,"_bypassWebAudio",!1),gt(this,"processor",void 0),gt(this,"_processorContext",void 0),gt(this,"_processorDestination",void 0),gt(this,"_getOriginVolumeLevel",void 0),this._encoderConfig=t,this._getOriginVolumeLevel=!!r,this._trackSource=new ni,u("DISABLE_WEBAUDIO")&&(this._bypassWebAudio=!0),u("LOCAL_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1);c()&&!At()?setTimeout((()=>this.initWebAudio())):this.initWebAudio()}setVolume(e){g(e,"volume",0,1e3),this._volume=e,this._source.setVolume(e/100),this._useAudioElement&&ti.setVolume(this.getTrackId(),e);try{if(this._bypassWebAudio)return void he.debug("[".concat(this.getTrackId(),"] setVolume returned because no pass through WebAudio."));const e=this._source.createOutputTrack();this._mediaStreamTrack!==e&&(this._mediaStreamTrack=e,R(this,We.NEED_REPLACE_TRACK,this).then((()=>{he.debug("[".concat(this.getTrackId(),"] replace web audio track success"))})).catch((e=>{he.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||!fe())throw new f(v.NOT_SUPPORTED,"your browser does not support setting the audio output device");await ti.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(he.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){this._originMediaStreamTrack.enabled=!0;try{i||(this._enabled=!0),await R(this,We.NEED_ENABLE_TRACK,this),he.info("[".concat(this.getTrackId(),"] setEnabled to ").concat(e," success"))}catch(e){throw i||(this._enabled=!1),he.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}}else{this._originMediaStreamTrack.enabled=!1,i||(this._enabled=!1);try{await R(this,We.NEED_DISABLE_TRACK,this)}catch(e){throw i||(this._enabled=!0),he.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,he.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await R(this,We.NEED_MUTE_TRACK,this):await R(this,We.NEED_UNMUTE_TRACK,this))}getStats(){b((()=>{he.warning("[deprecated] LocalAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalAudioStats instead")}),"localAudioTrackGetStatsWarning");const e=q(this,We.GET_STATS);return e||Tt({},tt)}setAudioFrameCallback(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4096;if(!e)return this._source.removeAllListeners($e.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners($e.ON_AUDIO_BUFFER),this._source.on($e.ON_AUDIO_BUFFER,(t=>e(t)))}play(){he.debug("[".concat(this.getTrackId(),"] start audio playback")),this._useAudioElement?(he.debug("[".concat(this.getTrackId(),"] start audio playback in element")),ti.play(this._mediaStreamTrack,this.getTrackId(),this._volume)):this._source.play()}stop(){he.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._useAudioElement?ti.stop(this.getTrackId()):this._source.stop()}close(){super.close(),this._processorDestination&&this.unbindProcessorDestinationEvents(this._processorDestination),this._processorContext&&this.unbindProcessorContextEvents(this._processorContext),this.unpipe(),this._processorDestination&&this._processorDestination._source&&this._processorDestination._source.unpipe(),this._source.destroy()}_updatePlayerSource(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];he.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&ti.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._processorContext&&this.processor.updateInput({track:e,context:this._processorContext}),this._mediaStreamTrack!==this._source.outputTrack?(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await R(this,We.NEED_REPLACE_TRACK,this)):this._source.updateTrack(this._originMediaStreamTrack),this._getOriginVolumeLevel&&this._source.updateOriginTrack(e))}renewMediaStreamTrack(e){return Promise.resolve(void 0)}pipe(e){if(this._bypassWebAudio)throw new f(v.INVALID_OPERATION,"Can not process AudioTrack when bypassWebAudio set to true.");if(this.processor===e)return e;if(e._source)throw new f(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(e){e.on(at.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(!1),this._source.processedNode=this._source.createMediaStreamSourceNode(e),await R(this,We.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await R(this,We.NEED_REPLACE_TRACK,this))})),e.on(at.ON_NODE,(e=>{this._source.processedNode=e}))}unbindProcessorDestinationEvents(e){e.removeAllListeners(at.ON_TRACK),e.removeAllListeners(at.ON_NODE)}bindProcessorContextEvents(e){e.on(nt.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}unbindProcessorContextEvents(e){e.removeAllListeners(nt.REQUEST_CONSTRAINTS)}initWebAudio(){return this._trackSource instanceof ni&&(this._trackSource=new xt(this._mediaStreamTrack,!1,this._getOriginVolumeLevel?this._mediaStreamTrack:void 0)),this._trackSource}initProcessor(){const e=new ai(this._source.context,this.getTrackId(),"local"),t=new si(e);return this._processorContext=e,this._processorDestination=t,this.bindProcessorContextEvents(e),this.bindProcessorDestinationEvents(t),this._source.on($e.UPDATE_SOURCE,(()=>{this.processor&&this.processor.updateInput({node:this._source.processSourceNode,context:e})})),this._useAudioElement&&(this._useAudioElement=!1,this.isPlaying&&(ti.stop(this.getTrackId()),this._source.play()),R(this,We.NEED_REPLACE_MIXING_TRACK,this).then((()=>{he.debug("[".concat(this.getTrackId(),"] replace from origin track to web audio track success"))})).catch((e=>{he.warning("[".concat(this.getTrackId(),"] replace from origin track to web audio track failed"),e)}))),{processorContext:e,processorDestination:t}}}).prototype,"setVolume",[vi],Object.getOwnPropertyDescriptor(Ui.prototype,"setVolume"),Ui.prototype),_t(Ui.prototype,"setPlaybackDevice",[yi,Si],Object.getOwnPropertyDescriptor(Ui.prototype,"setPlaybackDevice"),Ui.prototype),_t(Ui.prototype,"setEnabled",[ki,bi,Ii],Object.getOwnPropertyDescriptor(Ui.prototype,"setEnabled"),Ui.prototype),_t(Ui.prototype,"setMuted",[Ai,wi,Ri],Object.getOwnPropertyDescriptor(Ui.prototype,"setMuted"),Ui.prototype),_t(Ui.prototype,"getStats",[Di],Object.getOwnPropertyDescriptor(Ui.prototype,"getStats"),Ui.prototype),_t(Ui.prototype,"setAudioFrameCallback",[Ci],Object.getOwnPropertyDescriptor(Ui.prototype,"setAudioFrameCallback"),Ui.prototype),_t(Ui.prototype,"play",[Ni,Oi],Object.getOwnPropertyDescriptor(Ui.prototype,"play"),Ui.prototype),_t(Ui.prototype,"stop",[Mi,Pi],Object.getOwnPropertyDescriptor(Ui.prototype,"stop"),Ui.prototype),_t(Ui.prototype,"close",[Li],Object.getOwnPropertyDescriptor(Ui.prototype,"close"),Ui.prototype),_t(Ui.prototype,"pipe",[Vi],Object.getOwnPropertyDescriptor(Ui.prototype,"pipe"),Ui.prototype),_t(Ui.prototype,"unpipe",[xi],Object.getOwnPropertyDescriptor(Ui.prototype,"unpipe"),Ui.prototype),Ui),nr=(Bi=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Fi=ii(),Hi=Q("MicrophoneAudioTrack","_enabledMutex"),Gi=me({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),Wi=ii(),Ki=me({argsMap:e=>[e.getTrackId()]}),_t((zi=class extends ar{get __className__(){return"MicrophoneAudioTrack"}constructor(e,t,i,r){super(e,t.encoderConfig?Pe(t.encoderConfig):{},r,u("GET_VOLUME_OF_MUTED_AUDIO_TRACK")),gt(this,"_config",void 0),gt(this,"_deviceName","default"),gt(this,"_constraints",void 0),gt(this,"_originalConstraints",void 0),gt(this,"_enabled",!0),this._config=t,this._constraints=i,this._originalConstraints=i,this._deviceName=e.label,"boolean"==typeof t.bypassWebAudio&&(this._bypassWebAudio=t.bypassWebAudio),(G()||$())&&kt.bindInterruptDetectorTrack(this)}async setDevice(e){if(he.info("[".concat(this.getTrackId(),"] start set device to ").concat(e)),this._enabled)try{const t=await Xt.getDeviceById(e),i={};i.audio=Tt({},this._constraints),i.audio.deviceId={exact:e},this._originMediaStreamTrack.stop();let r=null;try{r=await Kt(i,this.getTrackId())}catch(e){throw he.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await Kt({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 he.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await Xt.getDeviceById(e);this._deviceName=t.label,this._config.microphoneId=e,this._constraints.deviceId={exact:e}}catch(e){throw he.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}he.info("[".concat(this.getTrackId(),"] set device to ").concat(e," success"))}async setEnabled(e,t,i){if(t)return he.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(he.info("[".concat(this.getTrackId(),"] start setEnabled"),e),u("AUTO_RESET_AUDIO_ROUTE")&&(C()||N())){const t=navigator.audioSession;t&&(e||(t.type="playback"),t.type="auto")}if(!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 R(this,We.NEED_DISABLE_TRACK,this)}catch(e){throw he.error("[".concat(this.getTrackId(),"] setEnabled false failed"),e.toString()),e}return}const o=Tt({},this._constraints),s=Xt.searchDeviceIdByName(this._deviceName);s&&!o.deviceId&&(o.deviceId=s);try{i||(this._enabled=!0);const e=await Kt({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!1),await R(this,We.NEED_ENABLE_TRACK,this)}catch(e){throw i||(this._enabled=!1),he.error("[".concat(this.getTrackId(),"] setEnabled true failed"),e.toString()),e}he.info("[".concat(this.getTrackId(),"] setEnabled success"))}close(){super.close(),(G()||$())&&kt.unbindInterruptDetectorTrack(this)}onTrackEnded(){if((C()||N())&&this._enabled&&!this._isClosed&&kt.duringInterruption){const e=async()=>{kt.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(he.debug("[".concat(this.getTrackId(),"] try capture microphone media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};kt.on(ye.IOS_INTERRUPTION_END,e)}else he.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Je.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=Xt.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId=i),this._constraints=t,this._enabled){this._originMediaStreamTrack.stop();const e=await Kt({audio:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getAudioTracks()[0],!0)}}bindProcessorContextEvents(e){super.bindProcessorContextEvents(e),e.on(nt.REQUEST_UPDATE_CONSTRAINTS,(async(e,t,i)=>{try{const i=Object.assign({},this._originalConstraints,...e);await this.renewMediaStreamTrack(i),t()}catch(e){i(e)}}))}unbindProcessorContextEvents(e){super.unbindProcessorContextEvents(e),e.removeAllListeners(nt.REQUEST_UPDATE_CONSTRAINTS)}}).prototype,"setDevice",[Bi,Fi],Object.getOwnPropertyDescriptor(zi.prototype,"setDevice"),zi.prototype),_t(zi.prototype,"setEnabled",[Hi,Gi,Wi],Object.getOwnPropertyDescriptor(zi.prototype,"setEnabled"),zi.prototype),_t(zi.prototype,"close",[Ki],Object.getOwnPropertyDescriptor(zi.prototype,"close"),zi.prototype),zi),cr=(ji=me({argsMap:(e,t)=>[e.getTrackId(),t,e.duration]}),Yi=ii(),Zi=me({argsMap:e=>[e.getTrackId()]}),Xi=ii(),Ji=me({argsMap:e=>[e.getTrackId()]}),Qi=ii(),qi=me({argsMap:e=>[e.getTrackId()]}),$i=ii(),er=me({argsMap:e=>[e.getTrackId()]}),tr=ii(),ir=me({argsMap:e=>[e.getTrackId()]}),rr=me({argsMap:e=>[e.getTrackId()]}),or=ii(),_t((sr=class extends ar{get __className__(){return"BufferSourceAudioTrack"}constructor(e,t,i,r){super(t.createOutputTrack(),i,r),gt(this,"source",void 0),gt(this,"_bufferSource",void 0),this._useAudioElement=!1,this.source=e,this._bufferSource=t,this._bufferSource.on($e.AUDIO_SOURCE_STATE_CHANGE,(e=>{this.safeEmit(Je.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){g(e,"speed",0),this._bufferSource.setAudioBufferPlaybackSpeed(e)}}).prototype,"startProcessAudioBuffer",[ji,Yi],Object.getOwnPropertyDescriptor(sr.prototype,"startProcessAudioBuffer"),sr.prototype),_t(sr.prototype,"pauseProcessAudioBuffer",[Zi,Xi],Object.getOwnPropertyDescriptor(sr.prototype,"pauseProcessAudioBuffer"),sr.prototype),_t(sr.prototype,"seekAudioBuffer",[Ji,Qi],Object.getOwnPropertyDescriptor(sr.prototype,"seekAudioBuffer"),sr.prototype),_t(sr.prototype,"resumeProcessAudioBuffer",[qi,$i],Object.getOwnPropertyDescriptor(sr.prototype,"resumeProcessAudioBuffer"),sr.prototype),_t(sr.prototype,"stopProcessAudioBuffer",[er,tr],Object.getOwnPropertyDescriptor(sr.prototype,"stopProcessAudioBuffer"),sr.prototype),_t(sr.prototype,"close",[ir],Object.getOwnPropertyDescriptor(sr.prototype,"close"),sr.prototype),_t(sr.prototype,"setAudioBufferPlaybackSpeed",[rr,or],Object.getOwnPropertyDescriptor(sr.prototype,"setAudioBufferPlaybackSpeed"),sr.prototype),sr);class dr extends ar{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=It().createMediaStreamDestination();super(e.stream.getAudioTracks()[0],void 0,k(8,"track-mix-")),gt(this,"trackList",void 0),gt(this,"destNode",void 0),this._useAudioElement=!1;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)?(he.debug("add ".concat(e.getTrackId()," to mixing track")),e._source.outputNode.connect(this.destNode),this.trackList.push(e),this.updateEncoderConfig()):he.debug("track ".concat(e.getTrackId()," is already added"))}removeAudioTrack(e){if(-1!==this.trackList.indexOf(e)){he.debug("remove ".concat(e.getTrackId()," from mixing track"));try{e._source.outputNode.disconnect(this.destNode)}catch(e){}D(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 dr?t.emit(Xe.TRANSCEIVER_UPDATED,e):t._updateRtpTransceiver(e)})))}}class ur extends Vt{set currentState(e){e!==this._currentState&&(this._currentState=e,this.safeEmit($e.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(),gt(this,"audioBuffer",void 0),gt(this,"sourceNode",void 0),gt(this,"startPlayTime",0),gt(this,"startPlayOffset",0),gt(this,"pausePlayTime",0),gt(this,"options",void 0),gt(this,"currentLoopCount",0),gt(this,"currentPlaybackSpeed",100),gt(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):he.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 hr=new Map;class lr{get rendFrameRate(){if(this.renderStats&&this.renderStats.curTs!==this.renderStats.lastTs){const e=this.renderStats.curTs-this.renderStats.lastTs,t=(this.renderStats.renderNum-this.renderStats.lastRenderNum)/e;return this.renderStats.lastRenderNum=this.renderStats.renderNum,this.renderStats.lastTs=this.renderStats.curTs,t}return 0}get videoElementStatus(){return this._videoElementStatus}set videoElementStatus(e){e!==this._videoElementStatus&&(he.debug("[".concat(this.trackId,"] video-element-status change ").concat(this._videoElementStatus," => ").concat(e)),this._videoElementStatus=e)}get videoState(){return this._videoState}set videoState(e){var t;e!==this._videoState&&(this._videoState=e,null===(t=this.onVideoStateChanged)||void 0===t||t.call(this,this.videoState))}constructor(e){gt(this,"trackId",void 0),gt(this,"config",void 0),gt(this,"onFirstVideoFrameDecoded",void 0),gt(this,"onVideoStateChanged",void 0),gt(this,"freezeTimeCounterList",[]),gt(this,"renderFreezeAccTime",0),gt(this,"isKeepLastFrame",!1),gt(this,"timeUpdatedCount",0),gt(this,"freezeTime",0),gt(this,"playbackTime",0),gt(this,"lastTimeUpdatedTime",0),gt(this,"autoplayFailed",!1),gt(this,"videoTrack",void 0),gt(this,"videoElement",void 0),gt(this,"cacheVideoElement",void 0),gt(this,"renderStats",void 0),gt(this,"_videoState",lt.VideoStateStopped),gt(this,"videoElementCheckInterval",void 0),gt(this,"videoElementFreezeTimeout",void 0),gt(this,"_videoElementStatus",ht.NONE),gt(this,"isGettingVideoDimensions",!1),gt(this,"startGetVideoDimensions",(()=>{const e=()=>{if(this.isGettingVideoDimensions=!0,this.videoElement.videoWidth*this.videoElement.videoHeight>4)return he.debug("[".concat(this.trackId,"] current video dimensions:"),this.videoElement.videoWidth,this.videoElement.videoHeight),void(this.isGettingVideoDimensions=!1);setTimeout(e,500)};!this.isGettingVideoDimensions&&e()})),gt(this,"autoResumeAfterInterruption",(()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&"running"===kt.curState&&(he.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(te())),ie()?(this.videoElement.srcObject=null,this.videoElement.srcObject=new MediaStream([this.videoTrack]),this.videoElement.play()):(this.videoElement.pause(),this.videoElement.play()))})),gt(this,"handleVideoEvents",(e=>{switch(e.type){case"play":case"playing":this.startGetVideoDimensions(),this.videoElementStatus=ht.PLAYING;break;case"loadeddata":if(this.videoState=lt.VideoStateStarting,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=ht.CANPLAY;break;case"stalled":this.videoElementStatus=ht.STALLED;break;case"suspend":this.videoElementStatus=ht.SUSPEND;break;case"pause":this.videoElementStatus=ht.PAUSED,C()||N()||c()&&this.autoplayFailed||!this.videoTrack||"live"!==this.videoTrack.readyState||(he.debug("[track-".concat(this.trackId,"] video element paused, auto resume")),this.videoElement.play());break;case"waiting":this.videoElementStatus=ht.WAITING;break;case"abort":this.videoElementStatus=ht.ABORT;break;case"ended":this.videoElementStatus=ht.ENDED;break;case"emptied":this.videoElementStatus=ht.EMPTIED;break;case"error":{const e=this.videoElement.error,t=e?"".concat(e.message," (").concat(e.code,")"):"";e&&(this.videoElementStatus=ht.ERROR),he.error("[".concat(this.trackId,"] media error: ").concat(t," "));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,So.lastVisibleTime<So.lastHiddenTime||i<So.lastHiddenTime||i<So.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}}})),gt(this,"autoResumeAfterInterruptionOnIOS15_16",(()=>{this.videoTrack&&"live"===this.videoTrack.readyState&&(he.debug("[track-".concat(this.trackId,"] video element paused, auto resume for ").concat(te())),ie()?(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"),kt.on(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),kt.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&&$t(t,"video",e.message,this.trackId),"NotAllowedError"===e.name?(he.warning("detected video element autoplay failed",e),this.autoplayFailed=!0,this.handleAutoPlayFailed()):he.warning("[".concat(this.trackId,"] play warning: "),e)}));const r=e();if(("Safari"===r.name&&15===Number(r.version)||G())&&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 he.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 Promise(((r,o)=>{i.toBlob((async e=>{if(i.remove(),e){const t=await Ti(e);r({buffer:t,width:i.width,height:i.height})}else o(new f(v.CONVERTING_VIDEO_FRAME_TO_BLOB_FAILED))}),e,t<0?.1:t>1?1:t)}))):await Ei(e)}destroy(){this.renderStats=void 0,kt.off(ye.IOS_INTERRUPTION_END,this.autoResumeAfterInterruption),kt.off(ye.IOS_15_16_INTERRUPTION_END,this.autoResumeAfterInterruptionOnIOS15_16),this.videoElement.srcObject=null,this.resetVideoElement(),this.freezeTimeCounterList=[],this.videoState=lt.VideoStateStopped}initVideoElement(){if(this.videoElementStatus=ht.INIT,!this.videoElementCheckInterval&&(pr.forEach((e=>{this.videoElement.addEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval=window.setInterval((()=>{re(this.videoElement)||(this.videoElementStatus=ht.DESTROYED)}),1e3),u("ENABLE_VIDEO_FRAME_CALLBACK"))){var t,i;let e;const r=()=>{"visible"===document.visibilityState&&(document.removeEventListener("visibilitychange",r),this.videoElementFreezeTimeout=window.setTimeout(o,u("VIDEO_FREEZE_DURATION")))},o=()=>{this.videoElementFreezeTimeout=void 0,this.videoState===lt.VideoStateDecoding&&("visible"===document.visibilityState?this.videoState=lt.VideoStateFrozen:document.addEventListener("visibilitychange",r))},s=(t,i)=>{if(this.videoElementStatus===ht.PLAYING){if(this.renderStats?(this.renderStats.renderNum++,this.renderStats.curTs=i.mediaTime):this.renderStats={lastTs:i.mediaTime,curTs:i.mediaTime,lastRenderNum:0,renderNum:0},e){const t=i.presentationTime-e.presentationTime;this.videoState===lt.VideoStateStarting&&(this.videoState=lt.VideoStateDecoding),this.videoState===lt.VideoStateDecoding&&this.onVideoStateChanged&&(this.videoElementFreezeTimeout&&window.clearTimeout(this.videoElementFreezeTimeout),this.videoElementFreezeTimeout=window.setTimeout(o,u("VIDEO_FREEZE_DURATION"))),t<u("VIDEO_FREEZE_DURATION")&&this.videoState===lt.VideoStateFrozen&&(this.videoState=lt.VideoStateDecoding),t>u("VIDEO_FREEZE_DURATION")&&So.lastVisibleTime>=So.lastHiddenTime&&e.timestamp>So.lastVisibleTime&&e.timestamp>So.lastHiddenTime&&(this.renderFreezeAccTime+=t)}e=Tt(Tt({},i),{},{timestamp:t})}var r,a;u("ENABLE_VIDEO_FRAME_CALLBACK")&&(null===(r=(a=this.videoElement).requestVideoFrameCallback)||void 0===r||r.call(a,s))};null===(t=(i=this.videoElement).requestVideoFrameCallback)||void 0===t||t.call(i,s)}this.videoElement.controls=!1,this.videoElement.setAttribute("playsinline",""),x()&&!u("HIDE_NO_POSTER")&&(this.videoElement.poster="noposter");const r=e();if("Safari"===r.name&&15===Number(r.version)||G()||!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 o=this.videoElement.play();void 0!==o&&o.catch((e=>{he.debug("[".concat(this.trackId,"] playback interrupted"),e.toString())}))}resetVideoElement(){pr.forEach((e=>{this.videoElement&&this.videoElement.removeEventListener(e,this.handleVideoEvents)})),this.videoElementCheckInterval&&(window.clearInterval(this.videoElementCheckInterval),this.videoElementCheckInterval=void 0),this.videoElementStatus=ht.NONE}handleAutoPlayFailed(){const e=t=>{t.preventDefault(),this.videoElement.play().then((()=>{he.debug("[".concat(this.trackId,"] Video element for trackId:").concat(this.trackId," autoplay resumed."))})).catch((e=>{he.error(e)})),this.autoplayFailed=!1,F()?document.body.removeEventListener("click",e,!0):(document.body.removeEventListener("touchstart",e,!0),document.body.removeEventListener("mousedown",e,!0))};F()?document.body.addEventListener("click",e,!0):(document.body.addEventListener("touchstart",e,!0),document.body.addEventListener("mousedown",e,!0)),qt()}}const pr=["play","playing","loadeddata","canplay","pause","stalled","suspend","waiting","abort","emptied","ended","timeupdate","error"];class mr extends lr{constructor(e){super(e),gt(this,"container",void 0),gt(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 Ei(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}}var _r,gr,Er,Tr,fr,vr,yr,Sr,kr,br,Ir,Ar,wr,Rr,Dr,Cr,Nr,Or,Mr,Pr,Lr,Vr,xr,Ur,Br,Fr,Hr,Gr,Wr,Kr,zr,jr,Yr,Zr;let Xr=(_r=me({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),gr=ii(),Er=me({argsMap:e=>[e.getTrackId()]}),Tr=Q("LocalVideoTrack","_enabledMutex"),fr=me({argsMap:(e,t)=>[e.getTrackId(),t]}),vr=ii(),yr=Q("LocalVideoTrack","_enabledMutex"),Sr=me({argsMap:(e,t)=>[e.getTrackId(),t]}),kr=ii(),br=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Ir=ii(),Ar=ii(),wr=me({argsMap:(e,t,i)=>[e.getTrackId(),t,i]}),Rr=ii(),Dr=ii(),Cr=ii(),Nr=ii(),Or=ii(),Mr=ii(),Pr=ii(),Lr=me({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Vr=me({argsMap:e=>[e.getTrackId()]}),xr=me({argsMap:e=>[e.getTrackId()]}),Ur=me({argsMap:(e,t,i)=>[e.getTrackId(),t.label,i]}),Br=class e extends vt{get videoHeight(){if(c()){const{height:e}=this._mediaStreamTrack.getSettings();return this._videoHeight=e,this._videoHeight}return this._videoHeight}get videoWidth(){if(c()){const{width:e}=this._mediaStreamTrack.getSettings();return this._videoWidth=e,this._videoWidth}return this._videoWidth}get isPlaying(){return!(!this._player||this._player.videoElementStatus!==ht.PLAYING)}get processorDestination(){return this._processorDestination}get processorContext(){return this._processorContext}set processorContext(e){this._processorContext=e}get __className__(){return"LocalVideoTrack"}constructor(e,i,r,o,s,a){if(super(e,s),gt(this,"trackMediaType",qe.VIDEO),gt(this,"_player",void 0),gt(this,"isUseScaleResolutionDownBy",!1),gt(this,"_videoVisibleTimer",null),gt(this,"_previousVideoVisibleStatus",void 0),gt(this,"_clearPreviousVideoVisibleStatus",(()=>this._previousVideoVisibleStatus=void 0)),gt(this,"_encoderConfig",void 0),gt(this,"_scalabilityMode",{numSpatialLayers:1,numTemporalLayers:1}),gt(this,"_optimizationMode",void 0),gt(this,"_videoHeight",void 0),gt(this,"_videoWidth",void 0),gt(this,"_forceBitrateLimit",void 0),gt(this,"_enabled",!0),gt(this,"_processorDestination",void 0),gt(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=o,this._hints=a||[],-1===this._hints.indexOf(Ke.SCREEN_TRACK))this.updateBitrateFromProfile();else if(oe(t.CHROME,115)&&se()){const t=fi(e);t&&(he.info("local screen video track begin to inject frame"),this._mediaStreamTrack=t)}i&&-1!==this._hints.indexOf(Ke.CUSTOM_TRACK)&&this.setEncoderConfiguration(i),this._processorContext=new oi(this.getTrackId(),"local"),this._processorDestination=new ri(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:(he.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}he.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=Tt(Tt(Tt({},this._getDefaultPlayerConfig()),t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new lr(i):this._player=new mr(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(Je.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,he.debug("[".concat(this.getTrackId(),"] stop video playback")))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(he.info("[".concat(this.getTrackId(),"] start setEnabled"),e),!e){this._originMediaStreamTrack.enabled=!1;try{await R(this,We.NEED_DISABLE_TRACK,this)}catch(e){throw he.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}return t||(this._enabled=!1),void he.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}this._originMediaStreamTrack.enabled=!0;try{await R(this,We.NEED_ENABLE_TRACK,this)}catch(e){throw he.error("[".concat(this.getTrackId(),"] setEnabled to true error"),e.toString()),e}he.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,he.debug("[".concat(this.getTrackId(),"] start set muted: ").concat(e)),e?await R(this,We.NEED_MUTE_TRACK,this):await R(this,We.NEED_UNMUTE_TRACK,this))}async setEncoderConfiguration(e,t){if(!this._enabled)throw new f(v.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");if(e=Ce(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=ui({encoderConfig:e});(c()||C()||N())&&(t.deviceId=void 0),he.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 f(v.UNEXPECTED_ERROR,e.toString());throw he.error("[".concat(this.getTrackId(),"] applyConstraints error"),t.toString()),t}}this._encoderConfig=e,-1===this._hints.indexOf(Ke.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await R(this,We.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(he)}}getStats(){b((()=>{he.warning("[deprecated] LocalVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getLocalVideoStats instead")}),"localVideoTrackGetStatsWarning");const e=q(this,We.GET_STATS);return e||Tt({},it)}async setBeautyEffect(e){he.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 Ei(e)}async setBitrateLimit(e){if(he.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 R(this,We.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(he)}}}async setOptimizationMode(e){if("motion"!==e&&"detail"!==e&&"balanced"!==e)return void he.error(v.INVALID_PARAMS,"optimization mode must be motion, detail or balanced");const t=this._optimizationMode;try{this._optimizationMode=e,await R(this,We.NEED_UPDATE_VIDEO_SEND_PARAMETERS,this)}catch(e){throw this._optimizationMode=t,he.error("[".concat(this.getTrackId(),"] set optimization mode failed"),e.toString()),e}he.info("[".concat(this.getTrackId(),"] set optimization mode success (").concat(e,")"))}setScalabiltyMode(e){if(1===e.numSpatialLayers&&1!==e.numTemporalLayers)return he.error(v.INVALID_PARAMS,"scalability mode currently not supported, no SVC."),void(this._scalabilityMode={numSpatialLayers:1,numTemporalLayers:1});this._scalabilityMode=e,he.info("[".concat(this.getTrackId(),"] set scalability mode success (").concat(e,")"))}updateMediaStreamTrackResolution(){di(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch(K)}_updatePlayerSource(){this._player&&this._player.updateVideoTrack(this._mediaStreamTrack)}_getDefaultPlayerConfig(){return{fit:"contain"}}async setSenderConfiguration(e){if(!this._enabled)throw new f(v.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");he.debug("[".concat(this.getTrackId(),"] setSenderConfiguration applyConstraints"),JSON.stringify(e)),e=Ce(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(Ke.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await R(this,We.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(he)}}updateBitrateFromProfile(){if(!this._encoderConfig)return;const{width:e,height:t,frameRate:i}=this.getMediaStreamTrackSettings();if(!e||!t||!i)return;const{bitrateMax:r,bitrateMin:o}=this._encoderConfig;if(null==o||null==r){const{max:s,min:a}=pi(e,t,i,o,r);this._encoderConfig.bitrateMin=a,this._encoderConfig.bitrateMax=s,he.debug("[".concat(this.getTrackId(),"] update bitrate from profile, [w: ").concat(e,", h: ").concat(t,", fps: ").concat(i,"] => [brMax: ").concat(s,", brMin: ").concat(a,"]"))}}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:o,slot:s}=r;if(this.isPlaying&&o instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=ae.checkOneElementVisible(o),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=le.reportApiInvoke(null,{tag:A.TRACER,name:I.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 f(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}async renewMediaStreamTrack(e){}pipe(e){if(this.processor===e)return e;if(e._source)throw new f(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(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this._encoderConfig;t&&(r=Tt(Tt({},r),Ce(t))),r=ne(r);const o=k(8,"track-video-cloned-"),s=new e(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,r,ne(this._scalabilityMode),this._optimizationMode,o,ne(this._hints));return t&&r&&s.setEncoderConfiguration(r),he.debug("clone video track from ".concat(this.getTrackId()," to ").concat(o,", clone ").concat(i)),s}async replaceTrack(e,t){if(!(e instanceof MediaStreamTrack))throw new f(v.INVALID_PARAMS,"track should be an instance of MediaStreamTrack");if("video"!==e.kind)throw new f(v.INVALID_PARAMS,"track should be a video MediaStreamTrack");await this._updateOriginMediaStreamTrack(e,t,!0),this.updateMediaStreamTrackResolution()}sendSeiData(e){if(b((()=>{le.reportApiInvoke(null,{name:I.LOCAL_VIDEO_SEND_SEI_DATA,options:[],tag:A.TRACER}).onSuccess("")}),this._mediaStreamTrack.id||this.getTrackId()),!u("ENABLE_VIDEO_SEI")||!u("ENABLE_ENCODED_TRANSFORM"))return void he.warning('To send/receive SEI, please call AgoraRTC.setParameter("ENABLE_VIDEO_SEI", true) before instantiate IAgoraRtcClient');if(e instanceof Uint8Array==!1)return new f(v.INVALID_PARAMS,"Invalid argument type, ILocalVideoTrack.sendSeiData() only accept Uint8Array argument.").throw();const t=this.getRTCRtpTransceiver();if(!t)return void he.warning("Video track is not published, SEI can not be send");const i=t.sender.getParameters();if(0===i.codecs.length)return;const r=i.codecs[0].mimeType.toLocaleLowerCase();"video/h264"===r?this.safeEmit("sei-to-send",e):he.warning("SEI is not supported by ".concat(r))}bindProcessorDestinationEvents(){this.processorDestination.on(at.ON_TRACK,(async e=>{e?e!==this._mediaStreamTrack&&(this._mediaStreamTrack=e,this._updatePlayerSource(),await R(this,We.NEED_REPLACE_TRACK,this)):this._mediaStreamTrack!==this._originMediaStreamTrack&&(this._mediaStreamTrack=this._originMediaStreamTrack,this._updatePlayerSource(),await R(this,We.NEED_REPLACE_TRACK,this))}))}unbindProcessorDestinationEvents(){this.processorDestination.removeAllListeners(at.ON_TRACK)}unbindProcessorContextEvents(){this.processorContext.removeAllListeners(nt.REQUEST_UPDATE_CONSTRAINTS),this.processorContext.removeAllListeners(nt.REQUEST_CONSTRAINTS)}},_t(Br.prototype,"play",[_r,gr],Object.getOwnPropertyDescriptor(Br.prototype,"play"),Br.prototype),_t(Br.prototype,"stop",[Er],Object.getOwnPropertyDescriptor(Br.prototype,"stop"),Br.prototype),_t(Br.prototype,"setEnabled",[Tr,fr,vr],Object.getOwnPropertyDescriptor(Br.prototype,"setEnabled"),Br.prototype),_t(Br.prototype,"setMuted",[yr,Sr,kr],Object.getOwnPropertyDescriptor(Br.prototype,"setMuted"),Br.prototype),_t(Br.prototype,"setEncoderConfiguration",[br,Ir],Object.getOwnPropertyDescriptor(Br.prototype,"setEncoderConfiguration"),Br.prototype),_t(Br.prototype,"getStats",[Ar],Object.getOwnPropertyDescriptor(Br.prototype,"getStats"),Br.prototype),_t(Br.prototype,"setBeautyEffect",[wr,Rr],Object.getOwnPropertyDescriptor(Br.prototype,"setBeautyEffect"),Br.prototype),_t(Br.prototype,"getCurrentFrameData",[Dr],Object.getOwnPropertyDescriptor(Br.prototype,"getCurrentFrameData"),Br.prototype),_t(Br.prototype,"getCurrentFrameImage",[Cr],Object.getOwnPropertyDescriptor(Br.prototype,"getCurrentFrameImage"),Br.prototype),_t(Br.prototype,"setBitrateLimit",[Nr],Object.getOwnPropertyDescriptor(Br.prototype,"setBitrateLimit"),Br.prototype),_t(Br.prototype,"setOptimizationMode",[Or],Object.getOwnPropertyDescriptor(Br.prototype,"setOptimizationMode"),Br.prototype),_t(Br.prototype,"setScalabiltyMode",[Mr],Object.getOwnPropertyDescriptor(Br.prototype,"setScalabiltyMode"),Br.prototype),_t(Br.prototype,"updateMediaStreamTrackResolution",[Pr],Object.getOwnPropertyDescriptor(Br.prototype,"updateMediaStreamTrackResolution"),Br.prototype),_t(Br.prototype,"pipe",[Lr],Object.getOwnPropertyDescriptor(Br.prototype,"pipe"),Br.prototype),_t(Br.prototype,"unpipe",[Vr],Object.getOwnPropertyDescriptor(Br.prototype,"unpipe"),Br.prototype),_t(Br.prototype,"close",[xr],Object.getOwnPropertyDescriptor(Br.prototype,"close"),Br.prototype),_t(Br.prototype,"replaceTrack",[Ur],Object.getOwnPropertyDescriptor(Br.prototype,"replaceTrack"),Br.prototype),Br),Jr=(Fr=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Hr=ii(),Gr=Q("CameraVideoTrack","_enabledMutex"),Wr=me({argsMap:(e,t)=>[e.getTrackId(),t]}),Kr=ii(),zr=me({argsMap:(e,t)=>[e.getTrackId(),t]}),jr=ii(),Yr=me({argsMap:e=>[e.getTrackId()]}),Zr=class e extends Xr{get __className__(){return"CameraVideoTrack"}constructor(e,t,i,r,o,s){super(e,Ce(t.encoderConfig),r,o,s),gt(this,"_config",void 0),gt(this,"_originalConstraints",void 0),gt(this,"_constraints",void 0),gt(this,"_enabled",!0),gt(this,"_deviceName","default"),gt(this,"tryResumeVideoForIOS15_16WeChat",(async()=>{(G()||$())&&!de()&&ue()&&this._enabled&&!this._isClosed&&(he.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=Ce(this._config.encoderConfig),kt.on(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),kt.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(he.info("[".concat(this.getTrackId(),"] set device to ").concat(e)),this._enabled)try{const t=await Xt.getDeviceById(e),i={};i.video=Tt({},this._constraints),i.video.deviceId={exact:e},i.video.facingMode=void 0,this._originMediaStreamTrack.stop();let r=null;try{r=await Kt(i,this.getTrackId())}catch(e){throw he.error("[".concat(this.getTrackId(),"] setDevice failed"),e.toString()),r=await Kt({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 he.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}else try{const t=await Xt.getDeviceById(e);this._deviceName=t.label,this._config.cameraId=e,this._constraints.deviceId={exact:e}}catch(e){throw he.error("[".concat(this.getTrackId(),"] setDevice error"),e.toString()),e}he.info("[".concat(this.getTrackId(),"] setDevice success"))}async _setDeviceByFacingModel(e){he.info("[".concat(this.getTrackId(),"] set facingMode ").concat(e));const t={video:Tt(Tt({},this._constraints),{},{deviceId:void 0,facingMode:{exact:e}})};if(this._enabled){this._originMediaStreamTrack.stop();let e=null;try{e=await Kt(t,this.getTrackId())}catch(t){throw he.error("[".concat(this.getTrackId(),"] setDeviceByFacingModel failed"),t.toString()),e=await Kt({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=Tt({},t.video),he.info("[".concat(this.getTrackId(),"] setDeviceByFacingModel success"))}async setEnabled(e,t){if(!t){if(e===this._enabled)return;this.stateCheck("enabled",e)}if(he.info("[".concat(this.getTrackId(),"] start setEnabled"),e),e){try{if(this.isExternalTrack)this._originMediaStreamTrack.enabled=!0;else{const e=await Kt({video:this._constraints},this.getTrackId());await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!1)}await R(this,We.NEED_ENABLE_TRACK,this)}catch(e){throw he.error("[".concat(this.getTrackId(),"] setEnabled true error"),e.toString()),e}this.updateMediaStreamTrackResolution(),he.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 R(this,We.NEED_DISABLE_TRACK,this)}catch(e){throw he.error("[".concat(this.getTrackId(),"] setEnabled to false error"),e.toString()),e}he.info("[".concat(this.getTrackId(),"] setEnabled to false success"))}}async setEncoderConfiguration(e,t){if(!this._enabled)throw new f(v.TRACK_IS_DISABLED,"can not set encoder configuration when track is disabled");e=Ce(e),this._forceBitrateLimit&&(e.bitrateMax=this._forceBitrateLimit.max_bitrate||e.bitrateMax,e.bitrateMin=this._forceBitrateLimit.min_bitrate||e.bitrateMin);const i=ce(this._config);i.encoderConfig=e;const r=ui(i);(c()||C()||N())&&(r.deviceId=void 0),he.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 f(v.UNEXPECTED_ERROR,e.toString());throw he.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(Ke.SCREEN_TRACK)&&this.updateBitrateFromProfile();try{await R(this,We.NEED_UPDATE_VIDEO_ENCODER,this)}catch(e){return e.throw(he)}}_getDefaultPlayerConfig(){return{mirror:!0,fit:"cover"}}onTrackEnded(){if((C()||N())&&this._enabled&&!this._isClosed&&kt.duringInterruption){const e=async()=>{kt.off(ye.IOS_INTERRUPTION_END,e),this._enabled&&!this._isClosed&&(he.debug("[".concat(this.getTrackId(),"] try capture camera media device for interrupted iOS device.")),await this.setEnabled(!1),await this.setEnabled(!0))};kt.on(ye.IOS_INTERRUPTION_END,e)}else he.debug("[".concat(this.getTrackId(),"] track ended")),this.safeEmit(Je.TRACK_ENDED)}async renewMediaStreamTrack(e){const t=e||this._constraints,i=Xt.searchDeviceIdByName(this._deviceName);if(i&&!t.deviceId&&(t.deviceId={exact:i}),this._enabled){const e=await Kt({video:t},this.getTrackId());this._constraints=t,await this._updateOriginMediaStreamTrack(e.getVideoTracks()[0],!0),this.updateMediaStreamTrackResolution()}}close(){super.close(),kt.off(ye.IOS_15_16_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat),kt.off(ye.IOS_INTERRUPTION_END,this.tryResumeVideoForIOS15_16WeChat)}clone(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=this._encoderConfig;t&&(r=Tt(Tt({},r),Ce(t))),r=ne(r);const o=k(8,"track-cam-cloned-"),s=new e(i?this._mediaStreamTrack.clone():this._mediaStreamTrack,ne(Tt(Tt({},this._config),{},{encoderConfig:r})),ne(this._constraints),ne(this._scalabilityMode),this._optimizationMode,o);return t&&r&&s.setEncoderConfiguration(r),he.debug("clone track from ".concat(this.getTrackId()," to ").concat(o,", clone ").concat(i)),s}bindProcessorContextEvents(){this.processorContext.on(nt.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(nt.REQUEST_CONSTRAINTS,(async e=>{e(this._originMediaStreamTrack.getSettings())}))}},_t(Zr.prototype,"setDevice",[Fr,Hr],Object.getOwnPropertyDescriptor(Zr.prototype,"setDevice"),Zr.prototype),_t(Zr.prototype,"setEnabled",[Gr,Wr,Kr],Object.getOwnPropertyDescriptor(Zr.prototype,"setEnabled"),Zr.prototype),_t(Zr.prototype,"setEncoderConfiguration",[zr,jr],Object.getOwnPropertyDescriptor(Zr.prototype,"setEncoderConfiguration"),Zr.prototype),_t(Zr.prototype,"close",[Yr],Object.getOwnPropertyDescriptor(Zr.prototype,"close"),Zr.prototype),Zr);function Qr(e){const t=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_CUSTOM_AUDIO_TRACK,options:[e]}),i=new ar(e.mediaStreamTrack,e.encoderConfig?Pe(e.encoderConfig):{},k(8,"track-cus-"),!1);return he.info("create custom audio track success with config",e,"trackId",i.getTrackId()),t.onSuccess(i.getTrackId()),i}async function qr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_MIC_AUDIO_TRACK,options:[e]}),i=li(e),r=k(8,"track-mic-");let o=null;he.info("start create microphone audio track with config",JSON.stringify(e),"trackId",r);try{o=(await Kt({audio:i},r)).getAudioTracks()[0]||null}catch(e){throw t.onError(e),e}if(!o){const e=new f(v.UNEXPECTED_ERROR,"can not find track in media stream");return t.onError(e),e.throw(he)}const s=new nr(o,e,i,r);return t.onSuccess(s.getTrackId()),he.info("create microphone audio track success, trackId:",r),s}async function $r(e){var t;const{cacheOnlineFile:i,encoderConfig:r}=e;let{source:o}=e;const s={source:o instanceof AudioBuffer?"AudioBuffer":o instanceof File?null!==(t=File.name)&&void 0!==t?t:"File":o,cacheOnlineFile:i,encoderConfig:r},a=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_BUFFER_AUDIO_TRACK,options:[s]});if(u("DISABLE_WEBAUDIO"))throw new f(v.NOT_SUPPORTED,"can not create BufferSourceAudioTrack when WebAudio disabled");const n=k(8,"track-buf-");he.info("start create buffer source audio track with config",JSON.stringify(s),"trackId",n);const c=o;if(!(o instanceof AudioBuffer))try{o=await async function(e,t){let i=null;if("string"==typeof e){const t=hr.get(e);if(t)return he.debug("use cached audio resource: ",e),t;try{i=(await ee((()=>_e.get(e,{responseType:"arraybuffer"})),void 0,void 0,{maxRetryCount:3})).data}catch(e){throw new f(v.FETCH_AUDIO_FILE_FAILED,e.toString())}}else{const t=new Promise(((t,i)=>{const r=new FileReader;r.onload=e=>{e.target?t(e.target.result):i(new f(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.onerror=()=>{i(new f(v.READ_LOCAL_AUDIO_FILE_ERROR))},r.readAsArrayBuffer(e)}));i=await t}const r=await Rt(i);return"string"==typeof e&&t&&hr.set(e,r),r}(o,i)}catch(e){return a.onError(e),e.throw(he)}const d=new ur(o),h=new cr(c,d,r?Pe(r):{},n);return he.info("create buffer source audio track success, trackId:",n),a.onSuccess(h.getTrackId()),h}function eo(e){const t=new dr;return e.forEach((e=>t.addAudioTrack(e))),t}function to(e){const t=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_CUSTOM_VIDEO_TRACK,options:[e]}),i=new Xr(e.mediaStreamTrack,{width:e.width,height:e.height,frameRate:e.frameRate,bitrateMax:e.bitrateMax,bitrateMin:e.bitrateMin},e.scalabiltyMode?Oe(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,k(8,"track-cus-"),[Ke.CUSTOM_TRACK]);return t.onSuccess(i.getTrackId()),he.info("create custom video track success with config",e,"trackId",i.getTrackId()),i}async function io(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=u("CAMERA_CAPTURE_CONFIG"),i=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_CAM_VIDEO_TRACK,options:[Tt({},e),t]});t&&(e.encoderConfig=t);const r=ui(e),o=k(8,"track-cam-");let s=null;he.info("start create camera video track with config",JSON.stringify(e),"trackId",o);try{s=(await Kt({video:r},o)).getVideoTracks()[0]||null}catch(e){throw i.onError(e),e}if(!s){const e=new f(v.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(he)}e.optimizationMode&&so(o,s,e,Ce(e.encoderConfig));const a=new Jr(s,e,r,e.scalabiltyMode?Oe(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,o);return i.onSuccess(a.getTrackId()),he.info("create camera video success, trackId:",o),a}async function ro(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=u("CAMERA_CAPTURE_CONFIG"),r=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_MIC_AND_CAM_TRACKS,options:[e,t,i]});i&&(t.encoderConfig=i);const o=ui(t),s=li(e),a=k(8,"track-mic-"),n=k(8,"track-cam-");let c=null,d=null;he.info("start create camera video track(".concat(n,") and microphone audio track(").concat(a,") with config, audio: ").concat(JSON.stringify(e),", video: ").concat(JSON.stringify(t)));try{const e=await Kt({audio:s,video:o},"".concat(a,"-").concat(n));c=e.getAudioTracks()[0],d=e.getVideoTracks()[0]}catch(e){throw r.onError(e),e}if(!c||!d){const e=new f(v.UNEXPECTED_ERROR,"can not find tracks in media stream");return r.onError(e),e.throw(he)}t.optimizationMode&&so(n,d,t,Ce(t.encoderConfig));const h=new nr(c,e,s,a),l=new Jr(d,t,o,t.scalabiltyMode?Oe(t.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},t.optimizationMode,n);return r.onSuccess([h.getTrackId(),l.getTrackId()]),he.info("create camera video track(".concat(n,") and microphone audio track(").concat(a,") success")),[h,l]}async function oo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"disable";const i=le.reportApiInvoke(null,{tag:A.TRACER,name:I.CREATE_SCREEN_VIDEO_TRACK,options:[Tt({},e),t]});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 r=hi(e),o=k(8,"track-scr-v-");let s=null,a=null;const n=Te();if(!n.supportShareAudio&&"enable"===t){const e=new f(v.NOT_SUPPORTED,"your browser or platform is not support share-screen with audio");return i.onError(e),e.throw(he)}he.info("start create screen video track with config",e,"withAudio",t,"trackId",o);try{const e=await Kt({screen:r,screenAudio:"auto"===t?n.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 f(v.UNEXPECTED_ERROR,"can not find track in media stream");return i.onError(e),e.throw(he)}if(!a&&"enable"===t){s&&s.stop();const e=new f(v.SHARE_AUDIO_NOT_ALLOWED);return i.onError(e),e.throw(he)}if(e.optimizationMode||(e.optimizationMode="detail"),e.optimizationMode){so(o,s,e,e.encoderConfig&&Ne(e.encoderConfig)||void 0),e.encoderConfig&&"string"!=typeof e.encoderConfig&&(e.encoderConfig.bitrateMin=e.encoderConfig.bitrateMax)}const c=new Xr(s,e.encoderConfig?Ne(e.encoderConfig):{},e.scalabiltyMode?Oe(e.scalabiltyMode):{numSpatialLayers:1,numTemporalLayers:1},e.optimizationMode,o,[Ke.SCREEN_TRACK]);if(!a)return i.onSuccess(c.getTrackId()),he.info("create screen video track success","video:",c.getTrackId()),c;const d=new ar(a,void 0,k(8,"track-scr-a-"),!1);return i.onSuccess([c.getTrackId(),d.getTrackId()]),he.info("create screen video track success","video:",c.getTrackId(),"audio:",d.getTrackId()),[c,d]}function so(e,t,i,r){i.optimizationMode&&(r&&r.width&&r.height?(i.encoderConfig=Tt(Tt({},r),{},{bitrateMin:r.bitrateMin,bitrateMax:r.bitrateMax}),"motion"!==i.optimizationMode&&"detail"!==i.optimizationMode||(t.contentHint=i.optimizationMode,t.contentHint===i.optimizationMode?he.debug("[".concat(e,"] set content hint to"),i.optimizationMode):he.debug("[".concat(e,"] set content hint failed")))):he.warning("[".concat(e,"] can not apply optimization mode bitrate config, no encoderConfig")))}var ao,no,co,uo,ho,lo,po,mo,_o,go,Eo,To;class fo extends ft{getUserId(){return this._userId}constructor(e,t,i,r){super(e,"track-".concat(e.kind,"-").concat(t,"-").concat(r.clientId,"_").concat(k(5,""))),gt(this,"_userId",void 0),gt(this,"_uintId",void 0),gt(this,"_isDestroyed",!1),gt(this,"store",void 0),gt(this,"processor",void 0),gt(this,"processorContext",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,he.info("[".concat(this.getTrackId(),"] is destroyed")),this.stop(),super.close()}getProcessorStats(){return this.processorContext.gatherStats()}getProcessorUsage(){return this.processorContext.gatherUsage()}}let vo=(ao=me({argsMap:(e,t,i)=>[e.getTrackId(),"string"==typeof t?t:t instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement",i]}),no=me({argsMap:e=>[e.getTrackId()]}),co=me({argsMap:(e,t)=>[e.getTrackId(),t.name]}),uo=me({argsMap:e=>[e.getTrackId()]}),_t((ho=class extends fo{get isPlaying(){return!(!this._player||this._player.videoElementStatus!==ht.PLAYING)}get __className__(){return"RemoteVideoTrack"}constructor(e,t,i,r){super(e,t,i,r),gt(this,"_videoVisibleTimer",null),gt(this,"_previousVideoVisibleStatus",void 0),gt(this,"_clearPreviousVideoVisibleStatus",(()=>this._previousVideoVisibleStatus=void 0)),gt(this,"trackMediaType",qe.VIDEO),gt(this,"_videoWidth",void 0),gt(this,"_videoHeight",void 0),gt(this,"_player",void 0),gt(this,"processorDestination",void 0),gt(this,"processorContext",void 0),this.updateMediaStreamTrackResolution(),this.processorContext=new oi(this.getTrackId(),"remote"),this.processorDestination=new ri(this.processorContext),this.bindProcessorDestinationEvents()}getStats(){b((()=>{he.warning("[deprecated] RemoteVideoTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteVideoStats instead")}),"remoteVideoTrackGetStatsWarning");return q(this,We.GET_STATS)||Tt({},st)}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:(he.warning("[".concat(this.getTrackId(),'] can not find "#').concat(e,'" element, use document.body')),e=document.body)}he.debug("[".concat(this.getTrackId(),"] start video playback in ").concat(e instanceof HTMLVideoElement?"HTMLVideoElement":"HTMLElement"),JSON.stringify(t));const i=Tt(Tt({fit:"cover"},t),{},{trackId:this.getTrackId(),element:e});this._player?this._player.updateConfig(i):(e instanceof HTMLVideoElement?this._player=new lr(i):this._player=new mr(i),this._player.updateVideoTrack(this._mediaStreamTrack),this._player.onFirstVideoFrameDecoded=()=>{this.store.subscribe(this.getUserId(),"video",void 0,void 0,Date.now()),this.safeEmit(Qe.FIRST_FRAME_DECODED)},this._player.onVideoStateChanged=e=>{this.safeEmit(Qe.VIDEO_STATE_CHANGED,e)}),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(Qe.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,he.debug("[".concat(this.getTrackId(),"] stop video playback")))}getCurrentFrameData(){return this._player?this._player.getCurrentFrame():new ImageData(2,2)}updateMediaStreamTrackResolution(){di(this._originMediaStreamTrack).then((e=>{let[t,i]=e;this._videoHeight=i,this._videoWidth=t})).catch(K)}_updatePlayerSource(){he.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:o,slot:s}=r;if(this.isPlaying&&o instanceof HTMLVideoElement&&s instanceof HTMLElement){const e=ae.checkOneElementVisible(o),t=Object.assign({},e);if(t.visible!==this._previousVideoVisibleStatus){this._previousVideoVisibleStatus=t.visible;const e=le.reportApiInvoke(null,{tag:A.TRACER,name:I.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 f(v.GET_VIDEO_ELEMENT_VISIBLE_ERROR,e.message)}}pipe(e){if(this.processor===e)return e;if(e._source)throw new f(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(at.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(at.ON_TRACK)}_destroy(){super._destroy(),this.unbindProcessorDestinationEvents()}_onSei(e){this.emit(Xe.SEI_RECEIVED,e)}}).prototype,"play",[ao],Object.getOwnPropertyDescriptor(ho.prototype,"play"),ho.prototype),_t(ho.prototype,"stop",[no],Object.getOwnPropertyDescriptor(ho.prototype,"stop"),ho.prototype),_t(ho.prototype,"pipe",[co],Object.getOwnPropertyDescriptor(ho.prototype,"pipe"),ho.prototype),_t(ho.prototype,"unpipe",[uo],Object.getOwnPropertyDescriptor(ho.prototype,"unpipe"),ho.prototype),ho),yo=(lo=me({argsMap:(e,t)=>[e.getTrackId(),t],throttleTime:300}),po=me({argsMap:(e,t)=>[e.getTrackId(),t]}),mo=me({argsMap:e=>[e.getTrackId()]}),_o=me({argsMap:e=>[e.getTrackId()]}),go=me({argsMap:(e,t)=>[e.getTrackId(),t.name]}),Eo=me({argsMap:e=>[e.getTrackId()]}),_t((To=class extends fo{get isPlaying(){return this._useAudioElement?ti.isPlaying(this.getTrackId()):this._source.isPlayed}get __className__(){return"RemoteAudioTrack"}constructor(e,t,i,r){super(e,t,i,r),gt(this,"trackMediaType",qe.AUDIO),gt(this,"_source",void 0),gt(this,"_useAudioElement",!0),gt(this,"_volume",100),gt(this,"processorContext",void 0),gt(this,"processorDestination",void 0),gt(this,"_played",!1),gt(this,"_bypassWebAudio",!1),u("DISABLE_WEBAUDIO")?(this._source=new ni,this._bypassWebAudio=!0,this._useAudioElement=!0):(this._source=new xt(e,!0),u("REMOTE_AUDIO_TRACK_USES_WEB_AUDIO")&&(this._useAudioElement=!1)),this._source.once($e.RECEIVE_TRACK_BUFFER,(()=>{this.safeEmit(Qe.FIRST_FRAME_DECODED)})),this.processorContext=new ai(this._source.context,this.getTrackId(),"remote"),this.processorDestination=new si(this.processorContext),this.bindProcessorDestinationEvents(),this._source.on($e.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($e.ON_AUDIO_BUFFER),void this._source.stopGetAudioBuffer();this._source.startGetAudioBuffer(t),this._source.removeAllListeners($e.ON_AUDIO_BUFFER),this._source.on($e.ON_AUDIO_BUFFER,(t=>e(t)))}setVolume(e){this._volume=e,this._useAudioElement?ti.setVolume(this.getTrackId(),e):this._source.setVolume(e/100)}async setPlaybackDevice(e){if(!this._useAudioElement||!fe())throw new f(v.NOT_SUPPORTED,"your browser does not support setting the audio output device");await ti.setSinkID(this.getTrackId(),e)}getVolumeLevel(){return this._source.getAccurateVolumeLevel()}getStats(){b((()=>{he.warning("[deprecated] RemoteAudioTrack.getStats will be removed in the future, use AgoraRTCClient.getRemoteAudioStats instead")}),"remoteAudioTrackGetStatsWarning");return q(this,We.GET_STATS)||Tt({},rt)}play(){he.debug("[".concat(this.getTrackId(),"] start audio playback")),this._played=!0,this._useAudioElement?(he.debug("[".concat(this.getTrackId(),"] use audio element to play")),ti.play(this._mediaStreamTrack,this.getTrackId(),this._volume,this.store.sessionId||void 0)):this._source.play()}stop(){he.debug("[".concat(this.getTrackId(),"] stop audio playback")),this._played=!1,this._useAudioElement?ti.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];he.debug("[".concat(this.getTrackId(),"] update player source track")),e&&this._source.updateTrack(this._mediaStreamTrack),this._useAudioElement&&ti.updateTrack(this.getTrackId(),this._mediaStreamTrack)}pipe(e){if(this._bypassWebAudio)throw new f(v.NOT_SUPPORTED,"can not pipe extension when WebAudio disabled");if(this.processor===e)return e;if(e._source)throw new f(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 f(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(at.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(at.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(at.ON_TRACK),this.processorDestination.removeAllListeners(at.ON_NODE)}}).prototype,"setVolume",[lo],Object.getOwnPropertyDescriptor(To.prototype,"setVolume"),To.prototype),_t(To.prototype,"setPlaybackDevice",[po],Object.getOwnPropertyDescriptor(To.prototype,"setPlaybackDevice"),To.prototype),_t(To.prototype,"play",[mo],Object.getOwnPropertyDescriptor(To.prototype,"play"),To.prototype),_t(To.prototype,"stop",[_o],Object.getOwnPropertyDescriptor(To.prototype,"stop"),To.prototype),_t(To.prototype,"pipe",[go],Object.getOwnPropertyDescriptor(To.prototype,"pipe"),To.prototype),_t(To.prototype,"unpipe",[Eo],Object.getOwnPropertyDescriptor(To.prototype,"unpipe"),To.prototype),To);const So=new class extends S{get visibility(){return document.visibilityState}get lastHiddenTime(){return this._lastHiddenTime}get lastVisibleTime(){return this._lastVisibleTime}constructor(){super(),gt(this,"_lastHiddenTime",0),gt(this,"_lastVisibleTime",0),document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState?this._lastHiddenTime=performance.now():this._lastVisibleTime=performance.now(),he.debug("document visibility went ".concat(document.visibilityState)),this.emit("VISIBILITY_CHANGE",document.visibilityState)}))}};class ko extends S{constructor(e,t){super(),gt(this,"trackMediaType",qe.DATA),gt(this,"_version",1),gt(this,"_type",3),gt(this,"_config",void 0),gt(this,"_originDataChannel",void 0),gt(this,"_dataStreamPacketHeader",new ArrayBuffer(4)),gt(this,"_dataStreamPacketHandler",{serialize:e=>e,deserialize:e=>e}),gt(this,"_datachannelEventMap",new Map),this._config=e,t&&(this._originDataChannel=t,this._bandDataChannelEvents(t)),this._initPacketHeader()}useDataStream(e){this._dataStreamPacketHandler=e}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 Promise(((e,t)=>{if(this._originDataChannel){"open"===this._originDataChannel.readyState&&e();const i=setTimeout((()=>{var e;t(new f(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 f(v.DATACHANNEL_CONNECTION_TIMEOUT)}}else t(new f(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),[mt.OPEN,mt.CLOSE,mt.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 bo extends ko{constructor(e){super(e),gt(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")&&he.debug("invalid datachannel id: ".concat(i," !== ").concat(this.id)));let r=e.data.slice(this._dataStreamPacketHeader.byteLength);r=this._dataStreamPacketHandler.deserialize(r),this.emit(mt.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 Io extends ko{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)}}}function Ao(){const e=new Blob([atob("ZnVuY3Rpb24gZShlLHQsbil7bGV0IHI9bmV3IFVpbnQ4QXJyYXkoZSx0LG4pLGE9W10sbz0wO2Zvcig7YS5sZW5ndGg8bjspbyszPG4mJjA9PT1yW29dJiYwPT09cltvKzFdJiYzPT09cltvKzJdJiYoMD09PXJbbyszXXx8MT09PXJbbyszXXx8Mj09PXJbbyszXXx8Mz09PXJbbyszXSk/KGEucHVzaChyW29dLHJbbysxXSxyW28rM10pLG8rPTQpOihhLnB1c2gocltvXSksbysrKTtyZXR1cm4gbmV3IFVpbnQ4QXJyYXkoYSl9ZnVuY3Rpb24gdChlLHQpe2NvbnN0IG49ZnVuY3Rpb24oZSl7Y29uc3QgdD1lLmxlbmd0aDtsZXQgbj1bXSxyPTA7Zm9yKDtyPHQ7KXIrMjx0JiYwPT09ZVtyXSYmMD09PWVbcisxXSYmKDA9PT1lW3IrMl18fDE9PT1lW3IrMl18fDI9PT1lW3IrMl18fDM9PT1lW3IrMl0pPyhuLnB1c2goZVtyXSxlW3IrMV0sMyxlW3IrMl0pLHIrPTMpOihuLnB1c2goZVtyXSkscisrKTtyZXR1cm4gbmV3IFVpbnQ4QXJyYXkobil9KHQpLHI9bi5sZW5ndGgsYT1NYXRoLmZsb29yKHIvMjU1KSxvPXIlMjU1LHM9bmV3IFVpbnQ4QXJyYXkoNithKzErcitlLmJ5dGVMZW5ndGgpO3NbMF09MCxzWzFdPTAsc1syXT0wLHNbM109MSxzWzRdPTYsc1s1XT0xMDE7bGV0IGk9MDtmb3IoO2k8YTspc1s2K2ldPTI1NSxpKys7cmV0dXJuIHNbNitpXT1vLGkrKyxzLnNldChuLDYraSkscy5zZXQobmV3IFVpbnQ4QXJyYXkoZSksNitpK3IpLHMuYnVmZmVyfW5hdmlnYXRvci51c2VyQWdlbnQuaW5kZXhPZigiU2FmYXJpIik+LTEmJi0xPT09bmF2aWdhdG9yLnVzZXJBZ2VudC5pbmRleE9mKCJDaHJvbWUiKSYmKHNlbGYub25ydGN0cmFuc2Zvcm09bj0+e2NvbnN0IHI9bi50cmFuc2Zvcm1lcjtsZXQgYT1bXTtyLm9wdGlvbnMucG9ydC5vbm1lc3NhZ2U9ZT0+e2UuZGF0YS5zZWkmJmEucHVzaChlLmRhdGEuc2VpKX0sc2VsZi5wb3N0TWVzc2FnZSgic3RhcnRlZCIpO2NvbnN0IG89ci5yZWFkYWJsZS5nZXRSZWFkZXIoKSxzPXIud3JpdGFibGUuZ2V0V3JpdGVyKCk7InJ4Ij09PXIub3B0aW9ucy5uYW1lP2Z1bmN0aW9uIHQobil7by5yZWFkKCkudGhlbigocj0+e2lmKCFyLmRvbmUpe2lmKHIudmFsdWUgaW5zdGFuY2VvZiBSVENFbmNvZGVkVmlkZW9GcmFtZSl7Y29uc3QgdD1mdW5jdGlvbih0KXtjb25zdCBuPW5ldyBEYXRhVmlldyh0LmRhdGEpO2xldCByPTA7Zm9yKDtyKzQ8dC5kYXRhLmJ5dGVMZW5ndGg7KXtpZigwPT09bi5nZXRVaW50OChyKzApJiYwPT09bi5nZXRVaW50OChyKzEpJiYwPT09bi5nZXRVaW50OChyKzIpJiYxPT09bi5nZXRVaW50OChyKzMpJiY2PT09bi5nZXRVaW50OChyKzQpKXtsZXQgYT1yKzYsbz0wLHM9MDtmb3IoOzI1NT09PShzPW4uZ2V0VWludDgoYSsrKSk7KW8rPTI1NTtvKz1zO2NvbnN0IGk9ZSh0LmRhdGEsYSxvKTtyZXR1cm4gbmV3IFVpbnQ4QXJyYXkoaSl9cisrfXJldHVybiBudWxsfShyLnZhbHVlKTt0JiZuLm9wdGlvbnMucG9ydC5wb3N0TWVzc2FnZSh7c2VpOnR9KX1zLndyaXRlKHIudmFsdWUpLG4ub3B0aW9ucy5wb3J0LnBvc3RNZXNzYWdlKHt0cmFuc2Zvcm1lZDohMH0pLHQobil9fSkpfShyKToidHgiPT09ci5vcHRpb25zLm5hbWUmJmZ1bmN0aW9uIGUobil7by5yZWFkKCkudGhlbigocj0+e2lmKCFyLmRvbmUpe2lmKHIudmFsdWUgaW5zdGFuY2VvZiBSVENFbmNvZGVkVmlkZW9GcmFtZSl7Y29uc3QgZT1hLnNoaWZ0KCk7ZSYmKHIudmFsdWUuZGF0YT10KHIudmFsdWUuZGF0YSxlKSl9cy53cml0ZShyLnZhbHVlKSxuLm9wdGlvbnMucG9ydC5wb3N0TWVzc2FnZSh7dHJhbnNmb3JtZWQ6ITB9KSxlKG4pfX0pKX0ocil9LHNlbGYucG9zdE1lc3NhZ2UoInJlZ2lzdGVyZWQiKSk7Cg==")],{type:"text/javascript"});return setTimeout((()=>URL.revokeObjectURL(e)),0),new Worker(URL.createObjectURL(e))}const wo=new Map;async function Ro(e){if(!Te().supportWebRTCEncodedTransform)return void he.warning("browser not support audio encoded transform");if(wo.has(e))return;if(!e.track)return;const t={track:e.track};if(l()){if(!e.createEncodedStreams)return void he.warning("browser not support createEncodedStreams() API");let r=null;try{r=e.createEncodedStreams()}catch(e){return void he.error("create audio-encoded-streams error",e&&e.message)}const o=new TransformStream({transform(r,o){t.controller||(t.controller=o),e.track&&e.track.id!==t.track.id&&(he.debug("audio track changed: ".concat(t.track.id," => ").concat(e.track.id)),t.track.removeEventListener("ended",i),t.track=e.track,t.track.addEventListener("ended",i)),o.enqueue(r)}});r.readable.pipeThrough(o).pipeTo(r.writable)}else if(c()){if("undefined"==typeof RTCRtpScriptTransform)return void he.warning("browser not support RTCRtpScriptTransform");const r=Ao(),o=new MessageChannel;await new Promise((e=>r.onmessage=t=>{"registered"===t.data&&e(void 0)}));const s=new RTCRtpScriptTransform(r,{name:"tx",port:o.port2},[o.port2]);e.transform=s,await new Promise((e=>r.onmessage=t=>{"started"===t.data&&e(void 0)})),o.port1.onmessage=r=>{var o;r.data.transformed&&e.track&&(null===(o=e.track)||void 0===o?void 0:o.id)!==t.track.id&&(he.debug("audio track changed: ".concat(t.track.id," => ").concat(e.track.id)),t.track.removeEventListener("ended",i),t.track=e.track,t.track.addEventListener("ended",i))},t.worker=r}function i(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",i)}const t=wo.get(e);if(t){wo.delete(e);try{var r,o;null===(r=t.controller)||void 0===r||r.terminate(),null===(o=t.worker)||void 0===o||o.terminate()}catch(e){he.warning(e&&e.message)}}}wo.set(e,t),e.track.addEventListener("ended",i)}const Do=new Map;async function Co(e){if(!Te().supportWebRTCEncodedTransform)return void he.warning("browser not support audio encoded transform");if(Do.has(e))return;const t={track:e.track};if(l()){if(!e.createEncodedStreams)return void he.warning("browser not support createEncodedStreams() API");let r=null;try{r=e.createEncodedStreams()}catch(e){return void he.error("create audio-encoded-streams error",e&&e.message)}const o=new TransformStream({transform(r,o){t.controller||(t.controller=o),e.track&&e.track.id!==t.track.id&&(he.debug("audio track changed: ".concat(t.track.id," => ").concat(e.track.id)),t.track.removeEventListener("ended",i),t.track=e.track,t.track.addEventListener("ended",i)),o.enqueue(r)}});r.readable.pipeThrough(o).pipeTo(r.writable)}else if(c()){if("undefined"==typeof RTCRtpScriptTransform)return void he.warning("browser not support RTCRtpScriptTransform");const r=Ao(),o=new MessageChannel;await new Promise((e=>r.onmessage=t=>{"registered"===t.data&&e(void 0)}));const s=new RTCRtpScriptTransform(r,{name:"rx",port:o.port2},[o.port2]);e.transform=s,await new Promise((e=>r.onmessage=t=>{"started"===t.data&&e(void 0)})),o.port1.onmessage=r=>{var o;r.data.transformed&&e.track&&(null===(o=e.track)||void 0===o?void 0:o.id)!==t.track.id&&(he.debug("audio track changed: ".concat(t.track.id," => ").concat(e.track.id)),t.track.removeEventListener("ended",i),t.track=e.track,t.track.addEventListener("ended",i))},t.worker=r}function i(){e.track.removeEventListener("ended",i),function(e){const t=Do.get(e);if(t){Do.delete(e);try{var i,r;null===(i=t.controller)||void 0===i||i.terminate(),null===(r=t.worker)||void 0===r||r.terminate()}catch(e){he.warning(e&&e.message)}}}(e)}Do.set(e,t),e.track.addEventListener("ended",i)}function No(e,t,i){let r=new Uint8Array(e,t,i),o=[],s=0;for(;o.length<i;)s+3<i&&0===r[s]&&0===r[s+1]&&3===r[s+2]&&(0===r[s+3]||1===r[s+3]||2===r[s+3]||3===r[s+3])?(o.push(r[s],r[s+1],r[s+3]),s+=4):(o.push(r[s]),s++);return new Uint8Array(o)}function Oo(e,t){const i=function(e){const t=e.length;let i=[],r=0;for(;r<t;)r+2<t&&0===e[r]&&0===e[r+1]&&(0===e[r+2]||1===e[r+2]||2===e[r+2]||3===e[r+2])?(i.push(e[r],e[r+1],3,e[r+2]),r+=3):(i.push(e[r]),r++);return new Uint8Array(i)}(t),r=i.length,o=Math.floor(r/255),s=r%255,a=new Uint8Array(6+o+1+r+e.byteLength);a[0]=0,a[1]=0,a[2]=0,a[3]=1,a[4]=6,a[5]=101;let n=0;for(;n<o;)a[6+n]=255,n++;return a[6+n]=s,n++,a.set(i,6+n),a.set(new Uint8Array(e),6+n+r),a.buffer}const Mo=new Map;async function Po(e,t){if(!Te().supportWebRTCEncodedTransform)return void he.warning("browser not support video encoded transform");if(Mo.has(e))return;if(!e.track)return;const i={track:e.track};if(l()){if(!e.createEncodedStreams)return void he.warning("browser not support createEncodedStreams() API");let o=null;try{o=e.createEncodedStreams()}catch(e){return void he.error("create video-encoded-streams error",e&&e.message)}let s=[];t.on("sei-to-send",(e=>{s.push(e)}));const a=new TransformStream({transform(t,o){i.controller||(i.controller=o),e.track&&e.track.id!==i.track.id&&(he.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",r),i.track=e.track,i.track.addEventListener("ended",r));const a=s.shift();a&&(t.data=Oo(t.data,a)),o.enqueue(t)}});o.readable.pipeThrough(a).pipeTo(o.writable)}else{if(!c())return;{if("undefined"==typeof RTCRtpScriptTransform)return void he.warning("browser not support RTCRtpScriptTransform");const o=Ao(),s=new MessageChannel;await new Promise((e=>o.onmessage=t=>{"registered"===t.data&&e(void 0)}));const a=new RTCRtpScriptTransform(o,{name:"tx",port:s.port2},[s.port2]);e.transform=a,await new Promise((e=>o.onmessage=t=>{"started"===t.data&&e(void 0)})),t.on("sei-to-send",(e=>{s.port1.postMessage({sei:e})})),s.port1.onmessage=t=>{var o;t.data.transformed&&e.track&&(null===(o=e.track)||void 0===o?void 0:o.id)!==i.track.id&&(he.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",r),i.track=e.track,i.track.addEventListener("ended",r))},i.worker=o}}function r(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",r)}const t=Mo.get(e);if(t){Mo.delete(e);try{var i,o;null===(i=t.controller)||void 0===i||i.terminate(),null===(o=t.worker)||void 0===o||o.terminate()}catch(e){he.warning(e&&e.message)}}}Mo.set(e,i),e.track.addEventListener("ended",r)}const Lo=new Map;async function Vo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Te().supportWebRTCEncodedTransform)return void he.warning("browser not support video encoded transform");if(!e.track)return;if(Lo.has(e)){const i=Lo.get(e);return void(i&&(i.onSei=t.onSei))}const i={track:e.track,onSei:t.onSei};if(l()){if(!e.createEncodedStreams)return void he.warning("browser not support createEncodedStreams() API");let t=null;try{t=e.createEncodedStreams()}catch(e){return void he.error("create video-encoded-streams error",e&&e.message)}const o=new TransformStream({transform(t,o){i.controller||(i.controller=o),e.track&&e.track.id!==i.track.id&&(he.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",r),i.track=e.track,i.track.addEventListener("ended",r));const s=function(e){const t=new DataView(e.data);let i=0;for(;i+4<e.data.byteLength;){if(0===t.getUint8(i+0)&&0===t.getUint8(i+1)&&0===t.getUint8(i+2)&&1===t.getUint8(i+3)&&6===t.getUint8(i+4)){let r=i+6,o=0,s=0;for(;255===(s=t.getUint8(r++));)o+=255;o+=s;const a=No(e.data,r,o);return new Uint8Array(a)}i++}return null}(t);s&&i.onSei&&i.onSei(s),o.enqueue(t)}});t.readable.pipeThrough(o).pipeTo(t.writable)}else if(c()){if("undefined"==typeof RTCRtpScriptTransform)return void he.warning("browser not support RTCRtpScriptTransform");const t=Ao(),o=new MessageChannel;await new Promise((e=>t.onmessage=t=>{"registered"===t.data&&e(void 0)}));const s=new RTCRtpScriptTransform(t,{name:"rx",port:o.port2},[o.port2]);e.transform=s,await new Promise((e=>t.onmessage=t=>{"started"===t.data&&e(void 0)})),o.port1.onmessage=t=>{var o;t.data.transformed&&e.track&&(null===(o=e.track)||void 0===o?void 0:o.id)!==i.track.id?(he.debug("video track changed: ".concat(i.track.id," => ").concat(e.track.id)),i.track.removeEventListener("ended",r),i.track=e.track,i.track.addEventListener("ended",r)):t.data.sei&&i.onSei&&i.onSei(t.data.sei)},i.worker=t}function r(){if(e.track){if(this.id!==e.track.id)return;e.track.removeEventListener("ended",r)}!function(e){const t=Lo.get(e);if(t){Lo.delete(e);try{var i,r;null===(i=t.controller)||void 0===i||i.terminate(),null===(r=t.worker)||void 0===r||r.terminate()}catch(e){he.warning(e&&e.message)}}}(e)}Lo.set(e,i),e.track.addEventListener("ended",r)}Ee();export{ye as AUDIO_CONTEXT_EVENT,Me as AUDIO_ENCODER_CONFIG_SETTINGS,et as AUDIO_TRACK_EVENT,ai as AudioProcessorContext,si as AudioProcessorDestination,$e as AudioSourceEvents,cr as BufferSourceAudioTrack,Jr as CameraVideoTrack,tt as DEFAULT_LOCAL_AUDIO_TRACK_STATS,it as DEFAULT_LOCAL_VIDEO_TRACK_STATS,ot as DEFAULT_NETWORK_QUALITY_STATS,rt as DEFAULT_REMOTE_AUDIO_TRACK_STATS,st as DEFAULT_REMOTE_VIDEO_TRACK_STATS,ko as DataChannel,mt as DataChannelEvents,Zt as DeviceManager,dt as DeviceManagerEvent,ct as DeviceManagerState,Gt as HAS_GUM_AUDIO,Wt as HAS_GUM_VIDEO,ar as LocalAudioTrack,Io as LocalDataChannel,vt as LocalTrack,Je as LocalTrackEvents,Xr as LocalVideoTrack,pt as MediaElementNumStatus,ht as MediaElementStatus,nr as MicrophoneAudioTrack,dr as MixingAudioTrack,nt as PROCESSOR_CONTEXT_EVENTS,at as PROCESSOR_DESTINATION_EVENTS,yo as RemoteAudioTrack,bo as RemoteDataChannel,Ze as RemoteStreamFallbackType,Ye as RemoteStreamType,fo as RemoteTrack,Qe as RemoteTrackEvents,vo as RemoteVideoTrack,Ht as SAFARI_GLOBAL_GUM_LOCK,we as SUPPORT_720P_AUTO_CONFIG_LIST,Re as SUPPORT_SCREEN_ENCODER_CONFIG_LIST,De as SUPPORT_SVC_CONFIG_LIST,Ae as SUPPORT_VIDEO_ENCODER_CONFIG_LIST,je as StreamType,ft as Track,Xe as TrackEvents,Ke as TrackHint,We as TrackInternalEvent,qe as TrackMediaType,oi as VideoProcessorContext,ri as VideoProcessorDestination,lt as VideoState,Le as __TRACK_LIST__,Ve as addTrack,kt as audioContextState,ti as audioElementPlayCenter,Ct as audioTimerLoop,Qt as autoPlayGestureEventEmitter,Ti as blob2Uint8Array,di as checkMediaStreamTrackResolution,ii as checkTrackState,$r as createBufferSourceAudioTrack,io as createCameraVideoTrack,Qr as createCustomAudioTrack,to as createCustomVideoTrack,ro as createMicrophoneAndCameraTracks,qr as createMicrophoneAudioTrack,eo as createMixingAudioTrack,oo as createScreenVideoTrack,Rt as decodeAudioData,fe as detectSupportAudioElementSetSinkId,Xt as deviceManager,Ei as emptyImage2TypedArray,gi as frameData2CryptoBuffer,It as getAudioContext,Pe as getAudioEncoderConfiguration,pi as getBitrateConstrainRange,mi as getBitrateFromResAndFps,Te as getCompatibility,ui as getConstraintsFromCameraConfig,li as getConstraintsFromMicrophoneConfig,hi as getConstraintsFromScreenConfig,Ft as getElectronScreenSources,Ut as getElectronScreenStream,Bt as getElectronScreenStreamByUserSelect,Kt as getLocalStream,_i as getOriginSenderConfig,Oe as getScalabilityConfiguration,Ne as getScreenEncoderConfiguration,Ot as getSilenceAudioTrack,Pt as getSilenceSamplesDuration,fi as getStaticTrackStream,Ce as getVideoEncoderConfiguration,jt as handleGetUserMediaError,At as hasAudioContext,Ro as interceptLocalAudioFrame,Po as interceptLocalVideoFrame,Co as interceptRemoteAudioFrame,Vo as interceptRemoteVideoFrame,Be as isAudioEncoderConfiguration,He as isAudioEncoderConfigurationOrPreset,ut as isBeautyEffectOptions,ze as isLowStreamParameter,ve as isPlanB,Ge as isScreenSourceType,Ue as isVideoEncoderConfiguration,Fe as isVideoEncoderConfigurationOrPreset,wt as polyfillAudioNode,xe as removeTrack,qt as requestAutoplayGesture,Mt as silenceScriptProcessHandler,Ee as updateAgoraRTCCompatibility,So as visibilityWatcher};
|