UNPKG

zego-express-engine-webrtc

Version:

zego webrtc express sdk

1 lines 80.8 kB
!function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("long"));else if("function"==typeof define&&define.amd)define(["long"],n);else{var i="object"==typeof exports?n(require("long")):n(t.long);for(var e in i)("object"==typeof exports?exports:t)[e]=i[e]}}("undefined"!=typeof self?self:this,function(t){return function(){"use strict";var n={166:function(t,n,i){var e,r,o,s;i.d(n,{PP:function(){return s}}),function(t){t[t.NONE=0]="NONE",t[t.MEN_TO_CHILD=1]="MEN_TO_CHILD",t[t.MEN_TO_WOMEN=2]="MEN_TO_WOMEN",t[t.WOMEN_TO_CHILD=3]="WOMEN_TO_CHILD",t[t.WOMEN_TO_MEN=4]="WOMEN_TO_MEN",t[t.FOREIGNER=5]="FOREIGNER",t[t.OPTIMUS_PRIME=6]="OPTIMUS_PRIME",t[t.ANDROID=7]="ANDROID",t[t.ETHEREAL=8]="ETHEREAL",t[t.MALE_MAGNETIC=9]="MALE_MAGNETIC",t[t.FEMALE_FRESH=10]="FEMALE_FRESH",t[t.MAJOR_C=11]="MAJOR_C",t[t.MINOR_A=12]="MINOR_A",t[t.HARMONIC_MINOR=13]="HARMONIC_MINOR",t[t.FEMALE_ENERGETIC=14]="FEMALE_ENERGETIC",t[t.RICHNESS=15]="RICHNESS",t[t.MUFFLED=16]="MUFFLED",t[t.ROUNDNESS=17]="ROUNDNESS",t[t.FALSETTO=18]="FALSETTO",t[t.FULLNESS=19]="FULLNESS",t[t.CLEAR=20]="CLEAR",t[t.HIGHLY_RESONANT=21]="HIGHLY_RESONANT",t[t.LOUD_CLEAR=22]="LOUD_CLEAR"}(e||(e={})),function(t){t[t.None=0]="None",t[t.SoftRoom=1]="SoftRoom",t[t.LargeRoom=2]="LargeRoom",t[t.ConcertHall=3]="ConcertHall",t[t.Valley=4]="Valley",t[t.RecordingStudio=5]="RecordingStudio",t[t.Basement=6]="Basement",t[t.KTV=7]="KTV",t[t.Popular=8]="Popular",t[t.Rock=9]="Rock",t[t.VocalConcert=10]="VocalConcert",t[t.GramoPhone=11]="GramoPhone",t[t.EnhancedKTV=12]="EnhancedKTV"}(r||(r={})),function(t){t[t.None=0]="None",t[t.Local=1]="Local",t[t.Publish=2]="Publish",t[t.All=3]="All"}(o||(o={})),function(t){t[t.AI=0]="AI",t[t.AIBalanced=1]="AIBalanced",t[t.AIAggressive=2]="AIAggressive"}(s||(s={}))},2638:function(t,n,i){var e;i(3052);!function(t){t[t.debug=0]="debug",t[t.info=1]="info",t[t.warn=2]="warn",t[t.error=3]="error",t[t.report=99]="report",t[t.disable=100]="disable"}(e||(e={}));var r,o,s;!function(t){t[t.disable=0]="disable",t[t.websocket=1]="websocket",t[t.https=2]="https"}(r||(r={})),function(t){t[t.SDKProject_ZegoWebRTC=6]="SDKProject_ZegoWebRTC",t[t.SDKProject_ZegoMiniProgram=7]="SDKProject_ZegoMiniProgram"}(o||(o={})),function(t){t[t.UDP=0]="UDP",t[t.RTMP=1]="RTMP",t[t.FLV=2]="FLV",t[t.HLS=3]="HLS",t[t.WEBRTC=4]="WEBRTC"}(s||(s={}));var u,c;u=1,function(){var t=1}();!function(t){t[t.ClientType_None=0]="ClientType_None",t[t.ClientType_H5=1]="ClientType_H5",t[t.ClientType_SmallPragram=2]="ClientType_SmallPragram",t[t.ClientType_Webrtc=3]="ClientType_Webrtc"}(c||(c={}));var a,h,f,l,d,v,m,p,g,w,b,y,E;!function(t){t[t.Default=0]="Default",t[t.Extranet=1]="Extranet",t[t.Intranet=2]="Intranet"}(a||(a={})),function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login"}(h||(h={})),function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login",t[t.reconnect=3]="reconnect"}(f||(f={})),function(t){t[t.stop=0]="stop",t[t.start=1]="start"}(l||(l={})),function(t){t[t.CDN=0]="CDN",t[t.RTC=1]="RTC",t[t.L3=2]="L3",t[t.DG=3]="DG"}(d||(d={})),function(t){t[t.useAnalyzer=0]="useAnalyzer",t[t.useWorklet=1]="useWorklet"}(v||(v={})),function(t){t[t.Default=3]="Default",t[t.StandardVideoCall=4]="StandardVideoCall",t[t.HighVideoCall=5]="HighVideoCall",t[t.StandardChatroom=6]="StandardChatroom",t[t.HighQualityChatroom=7]="HighQualityChatroom",t[t.Broadcast=8]="Broadcast",t[t.Karaoke=9]="Karaoke",t[t.UNKNOWN=100]="UNKNOWN"}(m||(m={})),function(t){t.WIN32="WIN32",t.MAC="Mac",t.ANDROID="Android",t.LINUX="Linux",t.IOS="iOS",t.Harmony="Harmony",t.UNKNOWN="WTF"}(p||(p={})),function(t){t.CDN="cdn",t.L3="l3",t.RTC="rtc"}(g||(g={})),function(t){t[t.RTC=0]="RTC",t[t.CDN=1]="CDN",t[t.L3=2]="L3",t[t.DG=3]="DG",t[t.CUSTOM=5]="CUSTOM"}(w||(w={})),function(t){t[t.offline=0]="offline",t[t.online=1]="online"}(b||(b={})),function(t){t[t.MinQuality=0]="MinQuality",t[t.DieQuality=0]="DieQuality",t[t.PoorMinQuality=1]="PoorMinQuality",t[t.MiddleMinQuality=30]="MiddleMinQuality",t[t.GoodMinQuality=60]="GoodMinQuality",t[t.ExcellentMinQuality=85]="ExcellentMinQuality",t[t.MaxQuality=100]="MaxQuality"}(y||(y={})),function(t){t[t.Unknown=-1]="Unknown",t[t.Excellent=0]="Excellent",t[t.Good=1]="Good",t[t.Middle=2]="Middle",t[t.Poor=3]="Poor",t[t.Die=4]="Die"}(E||(E={}));var T,S,k=function(){function t(t,n){void 0===t&&(t=null),void 0===n&&(n=null),this.next=null,this.prev=null,this._id=t,this._data=n}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id?this._id:null},set:function(t){this._id=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(t){this._data=t},enumerable:!1,configurable:!0}),t.prototype.hasNext=function(){return this.next&&this.next.id},t.prototype.hasPrev=function(){return this.prev&&this.prev.id},t}();!function(){function t(){this.start=new k,this.end=new k,this._idCounter=0,this._numNodes=0,this.start.next=this.end,this.start.prev=null,this.end.prev=this.start,this.end.next=null}t.prototype.insertBefore=function(t,n){var i=new k(this._idCounter,n);return i.next=t,i.prev=t.prev,t.prev&&(t.prev.next=i),t.prev=i,++this._idCounter,++this._numNodes,i},t.prototype.addLast=function(t){return this.insertBefore(this.end,t)},t.prototype.add=function(t){return this.addLast(t)},t.prototype.getFirst=function(){return 0===this._numNodes?null:this.start.next},t.prototype.getLast=function(){return 0===this._numNodes?null:this.end.prev},t.prototype.size=function(){return this._numNodes},t.prototype.getFromFirst=function(t){var n=0,i=this.start.next;if(t>=0)for(;n<t&&null!==i;)i=i.next,++n;else i=null;if(null===i)throw"Index out of bounds.";return i},t.prototype.get=function(t){return 0===t?this.getFirst():t===this._numNodes-1?this.getLast():this.getFromFirst(t)},t.prototype.remove=function(t){return t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),--this._numNodes,t},t.prototype.removeFirst=function(){var t=null;return this._numNodes>0&&this.start.next&&(t=this.remove(this.start.next)),t},t.prototype.removeLast=function(){var t=null;return this._numNodes>0&&this.end.prev&&(t=this.remove(this.end.prev)),t},t.prototype.removeAll=function(){this.start.next=this.end,this.end.prev=this.start,this._numNodes=0,this._idCounter=0},t.prototype.each=function(t){for(var n=this.start;n.hasNext();)t(n=n.next)},t.prototype.find=function(t){for(var n=this.start,i=!1,e=null;n.hasNext()&&!i;)t(n=n.next)&&(e=n,i=!0);return e},t.prototype.map=function(t){for(var n=this.start,i=[];n.hasNext();)t(n=n.next)&&i.push(n);return i},t.prototype.push=function(t){return this.addLast(t)},t.prototype.unshift=function(t){this.insertBefore(this._numNodes>0?this.start.next:this.end,t)},t.prototype.pop=function(){return this.removeLast()},t.prototype.shift=function(){return this.removeFirst()}}();!function(t){t.ONLY_BASELINE="only_baseline",t.HARD_SOFT_ENCODEC_FIRST="hard_or_soft_encodec_first",t.HIGH_PROFILE_FIRST="high_profile_first"}(T||(T={})),function(t){t[t.None=0]="None",t[t.Vocalist=1]="Vocalist",t[t.BackingSinging=2]="BackingSinging"}(S||(S={}))},3052:function(t,n,i){var e,r;!function(t){t[t.SWITCH_ONE=1]="SWITCH_ONE",t[t.SWITCH_TWO=2]="SWITCH_TWO"}(e||(e={})),function(t){t[t.ZegoGeoFenceTypeNone=0]="ZegoGeoFenceTypeNone",t[t.ZegoGeoFenceTypeInclude=1]="ZegoGeoFenceTypeInclude",t[t.ZegoGeoFenceTypeExclude=2]="ZegoGeoFenceTypeExclude"}(r||(r={}));var o,s;!function(t){t[t.TT_NONE=0]="TT_NONE",t[t.TT_PC=1]="TT_PC",t[t.TT_IOS=2]="TT_IOS",t[t.TT_ANDROID=3]="TT_ANDROID",t[t.TT_MAC=4]="TT_MAC",t[t.TT_LINUX=5]="TT_LINUX",t[t.TT_WEB=6]="TT_WEB",t[t.TT_MINIPROGRAM=7]="TT_MINIPROGRAM",t[t.TT_UNKNOWN=32]="TT_UNKNOWN"}(o||(o={})),function(t){t[t.disconnected=0]="disconnected",t[t.connecting=1]="connecting",t[t.connected=2]="connected"}(s||(s={}));var u,c,a,h;!function(t){t[t.logout=0]="logout",t[t.trylogin=1]="trylogin",t[t.login=2]="login"}(u||(u={})),function(t){t[t.I=0]="I",t[t.H=10]="H",t[t.M=100]="M",t[t.L=1e3]="L"}(c||(c={})),function(t){t[t.offline=0]="offline",t[t.online=1]="online"}(a||(a={})),function(t){t[t.NT_NONE=0]="NT_NONE",t[t.NT_LINE=1]="NT_LINE",t[t.NT_WIFI=2]="NT_WIFI",t[t.NT_2G=3]="NT_2G",t[t.NT_3G=4]="NT_3G",t[t.NT_4G=5]="NT_4G",t[t.NT_UNKNOWN=32]="NT_UNKNOWN"}(h||(h={}))},4872:function(t,n,i){function e(t){return"number"==typeof t}function r(t){return"string"==typeof t}function o(t){return"boolean"==typeof t}function s(t){return void 0===t}function u(t){return"function"==typeof t}function c(t){return t instanceof HTMLMediaElement}i.d(n,{Cs:function(){return e},JO:function(){return u},QP:function(){return r},Si:function(){return c},TE:function(){return s},dd:function(){return o}})},4908:function(t,n,i){i(8627),i(5095)},5095:function(t,n,i){i.d(n,{Gq:function(){return e},Tr:function(){return s},tK:function(){return r},yS:function(){return u},yp:function(){return o}});var e=function(t){return t},r=function(t){return t},o=function(t){return t},s=function(t){return t},u=function(t){return t}},6493:function(t,n,i){i.d(n,{$t:function(){return e},Fr:function(){return s},H8:function(){return o}});i(2638);function e(){return navigator.userAgent||""}function r(){var t,n=navigator.userAgent,i=n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)/i)||[];return/trident/i.test(i[1])?{name:"IE",version:(t=/\brv[ :]+([\d\.]+)/g.exec(n)||[])[1]||""}:"Chrome"===i[1]&&null!=(t=n.match(/\bOPR|Edge\/([\d\.]+)/))?{name:"Opera",version:t[1]}:(i=i[2]?[i[1],i[2]]:[navigator.appName,navigator.appVersion,"-?"],null!=(t=n.match(/version\/([\d+\.]+)/i))&&i.splice(1,1,t[1]),{name:i[0],version:i[1]})}function o(){return"chrome"==r().name.toLowerCase()}function s(){var t=e();return!!(t.match(/Mobi/i)||t.match(/Android/i)||t.match(/iPhone/i))}},6994:function(n){n.exports=t},7202:function(t,n,i){i(6994)},8627:function(t,n,i){i.d(n,{$wo:function(){return U},Arx:function(){return Tt},B3d:function(){return gt},Be2:function(){return et},FB3:function(){return J},HCP:function(){return z},HO9:function(){return g},I4J:function(){return Mt},I7C:function(){return nt},J79:function(){return c},JDv:function(){return ot},JSm:function(){return rt},L8E:function(){return G},LLz:function(){return x},MK1:function(){return lt},MrD:function(){return Y},MrS:function(){return k},MuX:function(){return Rt},NCg:function(){return jt},OdW:function(){return It},OrZ:function(){return _},Oy0:function(){return d},PA0:function(){return a},PTE:function(){return T},Q3v:function(){return st},Q9p:function(){return l},RBR:function(){return ct},RZs:function(){return Ct},RfS:function(){return V},S4u:function(){return o},S5f:function(){return h},SB8:function(){return bt},SRE:function(){return B},SmZ:function(){return M},T_8:function(){return ht},Tij:function(){return kt},V2t:function(){return S},VU9:function(){return I},WP4:function(){return X},XHx:function(){return Et},Xxx:function(){return E},ZEp:function(){return f},ZpF:function(){return R},Zws:function(){return wt},_68:function(){return L},_HD:function(){return v},aUw:function(){return b},aa2:function(){return F},ann:function(){return ft},b1q:function(){return Ot},cMG:function(){return At},ckD:function(){return Dt},ckg:function(){return Lt},clM:function(){return s},d49:function(){return u},dXc:function(){return _t},dg1:function(){return D},dqB:function(){return dt},ekj:function(){return yt},f43:function(){return q},fzq:function(){return W},g9p:function(){return p},gHA:function(){return vt},gSF:function(){return m},hYx:function(){return Pt},hje:function(){return pt},iei:function(){return P},jZ$:function(){return j},jut:function(){return C},kOd:function(){return K},kbF:function(){return Z},lgu:function(){return St},m6U:function(){return tt},mrK:function(){return $},pWJ:function(){return Nt},qvY:function(){return ut},sJH:function(){return A},sVF:function(){return y},s_m:function(){return O},t85:function(){return H},wxm:function(){return mt},xU2:function(){return Q},xbZ:function(){return at},xfZ:function(){return w},yK:function(){return N},zML:function(){return xt},zs3:function(){return it}});var e=i(8866),r="the user cancels the stream request.",o={code:1000002,message:"not login room"},s={code:1000014,message:"stream ID is too long"},u={code:1000015,message:"streamID is empty"},c={code:1000016,message:"stream ID contains illegal characters"},a={code:1000017,message:e.Rl},h={code:1000018,message:e.qC},f={code:1100001,message:e.dO},l={code:1100002,message:"network timeout."},d={code:1100999,message:"unknown server error"},v={code:1101005,message:"signal hb fail"},m={code:1102017,message:"dispatch error"},p={code:1102018,message:"token expired"},g={code:1102021,message:"biz channel error."},w={code:1102022,message:"dispatch request timeout"},b={code:1102024,message:"invalid channel"},y={code:1102026,msg:e.fT},E={code:1003025,message:"stream is forbided by media server"},T={code:1003050,message:"the extra info of the stream is null"},S={code:1003051,message:"the extra info of the stream is too long"},k={code:1003080,message:"browser does not support the codec"},x={code:1103001,message:e.dO},_={code:1103002,message:"browser do not support"},N={code:1103010,message:"screen fail"},O={code:1103011,message:"enumerate devices fail"},C={code:1103012,message:"use camera device fail"},A={code:1103019,message:"publish streams auth fail"},R={code:1103021,message:"session request fail"},M={code:1103022,message:"create offer error"},I={code:1103023,message:"setLocalDescription error"},D={code:1103024,message:"mediaDesc error"},P={code:1103025,message:"other side offer error"},L={code:1103026,message:"candidate error"},j={code:1103027,message:"server session closed"},F={code:1103028,message:"ice connection error"},U={code:1103030,message:"negotiation timeout"},H={code:1103042,message:"screen canceled"},G={code:1103043,message:"screen not support"},W={code:1103044,message:e.aw},q={code:1103099,message:"stream is not capturing"},V={code:1103049,message:"repeated pull same stream"},z={code:1103050,message:"websocket disconnected"},B={code:1103051,message:"publisher retry timeout"},J={code:1103053,message:"https is required"},Q={code:1103055,message:e.Wk},Z={code:1103056,message:"publish is publishing"},K={code:1103058,message:"client ip changed"},X={code:1103059,message:"ttl over time"},Y={code:1103060,message:"session request timeout"},$={code:1103061,message:"get media fail"},tt={code:1103062,message:"update stream info fail"},nt={code:1103063,message:"publish target no response"},it={code:1103064,message:"get device not allowed"},et={code:1103065,message:"device is not readable"},rt={code:1103066,message:"device does not meet constraints"},ot={code:1103067,message:"update sdp time out"},st={code:1103068,message:"update sdp fail"},ut={code:1103073,message:"video effect is starting, please operate after video effect is started"},ct={code:1103078,message:"publish stream poor and net probe poor"},at={code:1103089,message:r},ht={code:1004099,message:"internal exeception"},ft={code:1104001,message:"input parm error"},lt={code:1104021,message:"session request fail"},dt={code:1104022,message:"create offer error"},vt={code:1104023,message:"setLocalDescription error"},mt={code:1104024,message:"mediaDesc error"},pt={code:1104025,message:"other side offer error"},gt={code:1104026,message:"candidate error"},wt={code:1104028,message:"ice connection error"},bt={code:1104029,message:"websocket disconnected"},yt={code:1104030,message:"negotiation timeout"},Et={code:1104031,message:"player retry timeout"},Tt={code:1104032,message:"player is playing"},St={code:1104033,message:"client ip changed"},kt={code:1104034,message:"ttl is over time"},xt={code:1104035,message:"reset session push"},_t={code:1104036,message:"session request timeout"},Nt={code:1104037,message:"probe time out"},Ot={code:1104038,message:"resource mode is not supported"},Ct={code:1104039,message:"play stream not found"},At={code:1004020,message:"play stream interrupted"},Rt={code:1104041,message:"stream quality poor and net probe poor"},Mt={code:1104042,message:r},It={code:1104043,message:"mini sdp error"},Dt={code:1104045,message:"play streams is out limit"},Pt={code:1104046,message:"play streams auth fail"},Lt={code:1103048,message:e.pt},jt={code:1103100,message:"background process is start, but not subscribe yet"}},8866:function(t,n,i){i.d(n,{Rl:function(){return l},VJ:function(){return r},Wk:function(){return f},aw:function(){return u},dO:function(){return c},fT:function(){return o},h2:function(){return h},l3:function(){return e},pt:function(){return s},qC:function(){return a}});i(7202),i(8627),i(4908);var e=Promise,r=document;var o="room not exist",s="device is not found",u="stream is not from zego",c="input param error",a="local stream wrong",h="no preview",f="publish stream no found",l="network is broken"},8899:function(t,n,i){var e,r,o,s;i.d(n,{UF:function(){return o},eI:function(){return e},ju:function(){return s},kf:function(){return r}}),function(t){t[t.Off=0]="Off",t[t.TurningOn=1]="TurningOn",t[t.On=2]="On"}(e||(e={})),function(t){t[t.World=0]="World",t[t.Team=1]="Team",t[t.SecretTeam=2]="SecretTeam"}(r||(r={})),function(t){t[t.All=0]="All",t[t.World=1]="World",t[t.Team=2]="Team"}(o||(o={})),function(t){t[t.All=0]="All",t[t.World=1]="World",t[t.Team=2]="Team"}(s||(s={}))}},i={};function e(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return n[t](o,o.exports,e),o.exports}e.d=function(t,n){for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};e.r(r),e.d(r,{RangeAudio:function(){return it}});var o=e(8899),s=e(8866),u=function(){function t(){}return t.generateEls=function(t){if(void 0===t&&(t=30),this.elements.length>=t)this.elements.forEach(function(t){t.dom.play().catch(function(t){})});else{var n=Array(t-this.elements.length).fill(0).map(function(t,n){var i=s.VJ.createElement("audio");return i.muted=!0,i.setAttribute("autoplay","autoplay"),i.setAttribute("playsInline","playsInline"),i.id="audio"+n,{dom:i,id:n,used:!1}});this.elements=this.elements.concat(n)}},t.useAudioEl=function(){0===this.elements.length&&this.generateEls();var t=this.elements.find(function(t){return!t.used});return t&&(t.used=!0),t},t.stopUsingAudioEl=function(t){var n=this.elements[t];n&&(n.dom.onpause=null,n.dom.onerror=null,n.dom.muted=!0,n.used=!1)},t.elements=[],t}(),c=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},a=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},h="zc.ra.3",f=function(){function t(t,n){this.t=t,this.i=n,this.rtcConn=null,this.loopbackConn=null,this.destStream=new MediaStream,this.onError=null}return t.prototype.bindStream=function(t,n){var i,e;return c(this,void 0,void 0,function(){var r,o,s,u,c,f,l=this;return a(this,function(a){switch(a.label){case 0:return n&&(this.t=n),r=["completed","connected"],this.rtcConn&&this.loopbackConn&&r.includes(this.rtcConn.connectionState)?(o=null===(i=this.rtcConn)||void 0===i?void 0:i.getSenders().find(function(t){var n;return"audio"===(null===(n=t.track)||void 0===n?void 0:n.kind)}),t.getTracks().forEach(function(t){"audio"===t.kind&&(null==o||o.replaceTrack(t))}),[3,10]):[3,1];case 1:this.rtcConn=new RTCPeerConnection,this.loopbackConn=new RTCPeerConnection,s={offerVideo:!0,offerAudio:!0,offerToReceiveAudio:!1,offerToReceiveVideo:!1},this.rtcConn.onicecandidateerror=function(t){l.i.warn(h+" ".concat(l.t," loopback in ice error: ").concat(JSON.stringify(t)))},this.loopbackConn.onicecandidateerror=function(t){l.i.warn(h+" ".concat(l.t," loopback out ice error: ").concat(JSON.stringify(t)))},this.rtcConn.onicecandidate=function(t){var n,i=t.candidate;i&&(l.i.info(h+" ".concat(l.t," loopback add out candidate: ").concat(i)),null===(n=l.loopbackConn)||void 0===n||n.addIceCandidate(new RTCIceCandidate(i)))},this.loopbackConn.onicecandidate=function(t){var n,i=t.candidate;i&&(l.i.info(h+" ".concat(l.t," loopback add in candidate: ").concat(i)),null===(n=l.rtcConn)||void 0===n||n.addIceCandidate(new RTCIceCandidate(i)))},window.setTimeout(function(){l.rtcConn&&l.loopbackConn&&(r.includes(l.rtcConn.iceConnectionState)&&r.includes(l.loopbackConn.iceConnectionState)?l.i.info(h+" ".concat(l.t," loopback connect ok.")):(l.i.warn(h+" ".concat(l.t," loopback connect failed. in state: ").concat(l.rtcConn.iceConnectionState,", out state: ").concat(l.loopbackConn.iceConnectionState)),l.close(),l.onError&&l.onError("time out")))},2e3),this.loopbackConn.ontrack=function(t){var n=t.track;l.i.info(h+" ".concat(l.t," loopback receive track")),l.replaceTrack(n)},t.getTracks().find(function(n){var i;if("audio"===n.kind)return null===(i=l.rtcConn)||void 0===i||i.addTrack(n,t),!0}),a.label=2;case 2:return a.trys.push([2,9,,10]),[4,this.rtcConn.createOffer(s)];case 3:return u=a.sent(),[4,this.rtcConn.setLocalDescription(u)];case 4:return a.sent(),[4,this.loopbackConn.setRemoteDescription(u)];case 5:return a.sent(),[4,this.loopbackConn.createAnswer()];case 6:return(c=a.sent()).sdp=null===(e=c.sdp)||void 0===e?void 0:e.replace(/useinbandfec=/,"stereo=1;useinbandfec="),[4,this.loopbackConn.setLocalDescription(c)];case 7:return a.sent(),[4,this.rtcConn.setRemoteDescription(c)];case 8:return a.sent(),this.i.info(h+" ".concat(this.t," loopback set sdp completed.")),[3,10];case 9:return f=a.sent(),this.i.error(h+" ".concat(this.t," loopback connect failed.").concat(f)),this.close(),this.onError&&this.onError("connect failed"),this.onError=null,[3,10];case 10:return[2,this.destStream]}})})},t.prototype.replaceTrack=function(t){var n=this;"audio"===t.kind&&(this.destStream.getTracks().forEach(function(t){n.destStream.removeTrack(t)}),this.destStream.addTrack(t))},t.prototype.close=function(){var t=this,n=this.rtcConn,i=this.loopbackConn;this.destStream.getTracks().forEach(function(n){t.destStream.removeTrack(n)}),null==n||n.close(),null==i||i.close(),this.rtcConn=null,this.loopbackConn=null},t}();var l=e(4872),d=e(6493),v=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},m=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},p="zc.ra.5";var g,w=function(){function t(t,n){this.i=t,this.userID="base"+(new Date).getTime(),this.isHide=!1,this.distance=null,this.maxDistance=1e3,this.position=null,this.speaker="",this.audioEl=null,this.sourceNode=null,this.isPlaying=!1,this.config={needLoopback:!0,useGain:!0,playOnAudioContext:!1,useWebAudio:!0},this.volume=1,this.gainNode=null,this.isSpatial=!1,this.panner=null,this.audioCtx=n.audioCtx,this.isSpatial=n.isSpatial,this.setMaxDistance((0,l.Cs)(n.maxDistance)?n.maxDistance:1e5),this.destNode=this.audioCtx.createMediaStreamDestination(),this.setVolume(n.volume),this.setSpeaker(n.speaker).catch(function(t){}),this.inBackground(n.isHide)}return t.prototype.setPosition=function(t){this.i.info(p+" ".concat(this.userID," set position: ")+t),this.position=t,this.panner&&(void 0!==this.panner.positionX?(this.panner.positionX.value=t[1],this.panner.positionY.value=t[2],this.panner.positionZ.value=-t[0]):this.panner.setPosition(t[1],t[2],-t[0]))},t.prototype.getDistanceFromListener=function(t){return this.distance=function(t,n){if(!n||!t)return null;var i=[t[0]-n[0],t[1]-n[1],t[2]-n[2]];return Math.sqrt(Math.pow(i[0],2)+Math.pow(i[1],2)+Math.pow(i[2],2))}(this.position,t.position),this.distance},t.prototype.setMaxDistance=function(t){this.maxDistance=t,this.panner&&(t<10&&(t=10),this.panner.maxDistance=2.6*t)},t.prototype.setVolume=function(t){isNaN(t)||(this.volume=t,this.gainNode&&(this.gainNode.gain.value=this.volume))},t.prototype.setSpeaker=function(t){var n;return v(this,void 0,void 0,function(){var i,e,r;return m(this,function(o){switch(o.label){case 0:if(!(0,l.QP)(t))return[2];if(this.speaker=t,!(i=null===(n=this.audioEl)||void 0===n?void 0:n.dom))return[3,10];if(!(e=i.setSinkId))return[3,8];o.label=1;case 1:return o.trys.push([1,6,,7]),this.config.playOnAudioContext?[3,3]:[4,e.call(i,t||"")];case 2:return o.sent(),[3,5];case 3:return[4,e.call(i,"")];case 4:o.sent(),o.label=5;case 5:return this.i.info(p+" ".concat(this.userID," set speaker success. id: ").concat(t,".")),[3,7];case 6:throw r=o.sent(),this.i.error(p+" ".concat(this.userID," set speaker failed. id: ").concat(t," error: ").concat(r,".")),r;case 7:return[3,9];case 8:throw"setting speaker not support.";case 9:return[3,11];case 10:this.i.info(p+" ".concat(this.userID," no element for set speaker.")),o.label=11;case 11:return[2]}})})},t.prototype.initPanner=function(){if(!this.panner){var t=function(t,n,i){var e=i||[0,0,0],r=t.createPanner(),o=t.createGain();return r.panningModel="HRTF",r.distanceModel="linear",r.refDistance=1,r.maxDistance=2.6*n||1,r.rolloffFactor=1,r.coneOuterGain=.4,void 0!==r.positionX?(r.positionX.value=e[1],r.positionY.value=e[2],r.positionZ.value=-e[0]):r.setPosition(e[1],e[2],-e[0]),{panner:r,gainNode:o}}(this.audioCtx,this.maxDistance,this.position),n=t.gainNode;this.panner=t.panner,this.gainNode=n,n.gain.value=this.volume}},t.prototype.changeRenderConfig=function(t,n,i,e){var r,o,s,u,c;return void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===e&&(e=!0),v(this,void 0,void 0,function(){var a,h,l,v,g,w,b,y,E,T,S,k,x=this;return m(this,function(m){switch(m.label){case 0:return n||this.isSpatial!==t?(this.isSpatial=t,a=(0,d.H8)()&&(0,d.Fr)(),[4,K()]):[2];case 1:return h=m.sent(),l="Windows"===h.platform&&h.majorPlatformVersion>=13,v=this.isHide&&(l||a),g="running"!==this.audioCtx.state,e&&(v||g)&&(this.i.warn("".concat(p," ").concat(this.userID," stop web audio. system: ").concat(h.platform," ").concat(h.majorPlatformVersion)),e=!1),this.config.useWebAudio=e,w=(0,d.$t)(),b=w.includes("safari")&&!w.includes("chrome"),y=w.includes("micromessenger")&&new RegExp(/(iphone|ipad|ipod|ios)/i).test(w),e||this.stream||(i=!0),this.config.playOnAudioContext=i,this.initPanner(),this.isPlaying&&this.sourceNode?(this.lastNode&&this.lastNode.disconnect(),E=this.sourceNode,this.sourceNode.disconnect(),null===(r=this.panner)||void 0===r||r.disconnect(),null===(o=this.gainNode)||void 0===o||o.disconnect(),this.gainNode?(e&&(this.config.useGain&&(E=this.sourceNode.connect(this.gainNode)),this.panner&&t&&(E=E.connect(this.panner))),E.connect(i?this.audioCtx.destination:this.destNode),this.lastNode=E,this.position&&this.setPosition(this.position),this.i.info(p+" '".concat(this.userID,"' play ").concat(t?"3d":"normal"," stream on ").concat(i?"audio ctx":"element")),(T=null===(s=this.audioEl)||void 0===s?void 0:s.dom)?(T.onpause=function(){x.i.warn(p+" ".concat(x.streamID," audio paused"))},T.onerror=function(t){x.i.warn(p+" ".concat(x.streamID," audio error, ").concat(t))},i?(this.stream&&T.srcObject!==this.stream&&(T.srcObject=this.stream,T.muted=!0,T.oncanplay=function(){T.play().then(function(){x.i.info(p+" ".concat(x.userID," ctx autoplay success.")),x.checkPlayStatus()}).catch(function(t){x.i.warn(p+" ".concat(x.userID," ctx autoplay failed."))})}),[3,6]):[3,2]):[3,6]):[3,6]):[3,6];case 2:return S=this.destNode.stream,(k=this.config.needLoopback&&!y&&!b)&&this.loopbackConn&&(this.loopbackConn.close(),this.loopbackConn.onError=null),e||!this.stream?[3,3]:(this.i.info("".concat(p," ").concat(this.userID," stop audio api")),this.sourceNode.disconnect(),null===(u=this.panner)||void 0===u||u.disconnect(),null===(c=this.gainNode)||void 0===c||c.disconnect(),S=this.stream,[3,5]);case 3:return k&&S?(this.loopbackConn=this.loopbackConn||new f(this.streamID||"",this.i),this.loopbackConn.onError=function(t){x.i.warn(p+" ".concat(x.userID," loopback failed! ").concat(t)),x.changeRenderConfig(x.isSpatial,!0,!0)},[4,this.loopbackConn.bindStream(S,this.streamID||void 0)]):[3,5];case 4:return S=m.sent(),[3,5];case 5:T.muted=!0,T.srcObject=S,this.setSpeaker(this.speaker).catch(function(t){}),T.oncanplay=function(){if(T){T.muted=!1;var t=function(t){x.i.error(p+" ".concat(x.userID," autoplay failed. error: ").concat(t)),x.changeRenderConfig(x.isSpatial,!0,!0)};T.play().then(function(){(null==T?void 0:T.paused)?t("audio paused"):(x.i.info(p+" ".concat(x.userID," element autoplay success.")),x.checkPlayStatus())}).catch(function(n){t(n)})}},m.label=6;case 6:return[2]}})})},t.prototype.checkPlayStatus=function(){var t=this;setTimeout(function(){var n;if(t.isPlaying){var i=null===(n=t.audioEl)||void 0===n?void 0:n.dom,e=t.audioCtx.state;!i||i.paused||i.muted&&!t.config.playOnAudioContext||"running"!==e?(t.i.warn("".concat(p," ").concat(t.userID," play detection is abnormal. audio ctx:").concat(e,", paused:").concat(null==i?void 0:i.paused,", muted:").concat(null==i?void 0:i.muted)),"running"!==e&&(t.audioCtx.resume(),setTimeout(function(){t.i.warn("".concat(p," ").concat(t.userID," play resume. audio ctx:").concat(e,", paused:").concat(null==i?void 0:i.paused,", muted:").concat(null==i?void 0:i.muted))},1e3))):t.i.info("".concat(p," ").concat(t.userID," play detection is fine"))}},2e3)},t.prototype.inBackground=function(t,n){void 0===t&&(t=!1),void 0===n&&(n=!1),this.isHide!==t&&(this.isHide=t,t||this.config.useWebAudio||this.changeRenderConfig(this.isSpatial,!0))},t}(),b=(g=function(t,n){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},g(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}g(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}),y=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},E=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},T="zc.ra.1",S=function(t){function n(n,i,e){var r=t.call(this,n,e)||this;return r.i=n,r.audioTrack=null,r.zegoRTC=e.zegoRTC,r.userID=i.userID,r.teamID=i.teamID,r.raMode=void 0!==i.raMode?i.raMode:o.kf.World,i.position&&(r.position=i.position),r}return b(n,t),Object.defineProperty(n.prototype,"sendMode",{get:function(){return void 0!==this._sendMode?this._sendMode:this.raMode===o.kf.World?o.UF.All:o.UF.Team},set:function(t){this._sendMode=t},enumerable:!1,configurable:!0}),n.prototype.checkTrackChanged=function(){var t;if(this.stream){var n=this.stream.getAudioTracks()[0];n&&n!==this.audioTrack&&(this.i.info(T+" retry play success, render stream."),null===(t=this.sourceNode)||void 0===t||t.disconnect(),this.sourceNode=this.audioCtx.createMediaStreamSource(this.stream),this.changeRenderConfig(this.isSpatial,!0),this.audioTrack=n)}},n.prototype.startPlayingAudio=function(t){var n,i;return y(this,void 0,void 0,function(){var e,r,o;return E(this,function(c){switch(c.label){case 0:if(!this.streamID)return[2];c.label=1;case 1:return c.trys.push([1,3,,4]),t&&this.i.info(T+" ".concat(this.streamID," ")+t),this.isPlaying=!0,e=this,[4,this.zegoRTC.startPlayingStream(this.streamID)];case 2:return e.stream=c.sent(),this.audioTrack=this.stream.getAudioTracks()[0],[3,4];case 3:if(r=c.sent(),this.isPlaying=!1,1103049===r.code)return[2];throw r;case 4:return this.audioEl=this.audioEl||u.useAudioEl()||null,this.i.info(T+" ".concat(this.streamID," start using audio el ").concat(null===(n=this.audioEl)||void 0===n?void 0:n.id)),(o=null===(i=this.audioEl)||void 0===i?void 0:i.dom)||(this.i.error(T+" not enough audio elements"),o=s.VJ.createElement("audio"),this.audioEl={id:-1,dom:o,used:!0},o.setAttribute("autoplay","autoplay")),o.muted=!0,this.stream&&(this.sourceNode=this.audioCtx.createMediaStreamSource(this.stream)),this.sourceNode?[4,this.changeRenderConfig(this.isSpatial,!0)]:[3,6];case 5:c.sent(),c.label=6;case 6:return"suspended"===this.audioCtx.state&&this.audioCtx.resume(),[2]}})})},n.prototype.stopPlayingAudio=function(t){this.isPlaying&&this.streamID?(this.i.info(T+" ".concat(this.streamID," ")+t),this.zegoRTC.stopPlayingStream(this.streamID),this.isPlaying=!1):this.streamID&&this.i.info(T+" ".concat(this.streamID," not playing, ")+t),this.stream=void 0,this.sourceNode&&(this.sourceNode.disconnect(),this.sourceNode=null);var n=this.audioEl,i=null==n?void 0:n.dom;i&&(i.srcObject=null,i.parentNode&&i.parentNode.removeChild(i));var e=(null==n?void 0:n.id)||-1;n&&e>=0&&(u.stopUsingAudioEl(e),this.i.info(T+" ".concat(this.streamID," stop using audio el ").concat(e))),this.audioEl=null,this.loopbackConn&&(this.loopbackConn.close(),this.loopbackConn.onError=null)},n.prototype.isSpeakInTeam=function(t){var n=![this.teamID,t].includes(void 0)&&""!==this.teamID&&this.teamID===t,i=[o.UF.Team,o.UF.All].includes(this.sendMode);return n&&i},n}(w),k=function(){var t=function(n,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},t(n,i)};return function(n,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function e(){this.constructor=n}t(n,i),n.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}}(),x=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},_=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},N="zc.ra.4",O=function(t){function n(n,i,e){var r=t.call(this,n,e)||this;return r.i=n,r.media=i.media,r.position=i.position||null,r.createSource(),r.userID="custom"+(new Date).getTime(),r.config={needLoopback:!1,useGain:!1,playOnAudioContext:!1,useWebAudio:!0},r}return k(n,t),n.prototype.createSource=function(){var t=this;if((0,d.Fr)())return this.i.info("".concat((0,d.Fr)()," ").concat(this.userID," not create src.")),void(this.changeRenderConfig=function(){return x(t,void 0,void 0,function(){return _(this,function(t){return[2]})})});this.media&&(this.i.info(N+" create el source."),this.sourceNode||(this.sourceNode=this.audioCtx.createMediaElementSource(this.media)),null!==this.distance&&this.distance<this.maxDistance&&this.startPlayingAudio("in range"))},n.prototype.startPlayingAudio=function(t){var n,i;return x(this,void 0,void 0,function(){var e;return _(this,function(r){switch(r.label){case 0:return this.isPlaying?(this.i.info(N+" ".concat(this.userID," is already playing")),[2]):(t&&this.i.info(N+" vocal ".concat(this.userID," play for ").concat(t)),this.isPlaying=!0,(0,d.Fr)()?(this.media.muted=!1,[2]):(this.audioEl=this.audioEl||u.useAudioEl()||null,this.i.info(N+" ".concat(this.userID," start using audio el ").concat(null===(n=this.audioEl)||void 0===n?void 0:n.id)),(e=null===(i=this.audioEl)||void 0===i?void 0:i.dom)||(this.i.error(N+" ".concat(this.userID," not enough audio elements")),e=s.VJ.createElement("audio"),this.audioEl={id:-1,dom:e,used:!0},e.setAttribute("autoplay","autoplay")),e.muted=!0,e.setAttribute("autoplay","autoplay"),e.setAttribute("id","zg-audio-source-"+this.userID),this.sourceNode?[4,this.changeRenderConfig(this.isSpatial,!0)]:[3,2]));case 1:r.sent(),r.label=2;case 2:return"suspended"===this.audioCtx.state&&this.audioCtx.resume(),[2]}})})},n.prototype.stopPlayingAudio=function(t){if(void 0===t&&(t=""),this.isPlaying&&(this.i.info(N+" vocal ".concat(this.userID," stop for ")+t),this.isPlaying=!1),(0,d.Fr)())this.media.muted=!0;else{this.sourceNode&&this.sourceNode.disconnect();var n=this.audioEl,i=null==n?void 0:n.dom;i&&(i.srcObject=null,i.parentNode&&i.parentNode.removeChild(i));var e=(null==n?void 0:n.id)||-1;n&&e>=0&&(u.stopUsingAudioEl(e),this.i.info(N+" ".concat(this.userID," stop using audio el ").concat(e))),this.audioEl=null}},n.prototype.checkIfCanPlay=function(t){var n=this.distance=this.getDistanceFromListener(t);null===n||n>this.maxDistance||0===this.maxDistance?this.stopPlayingAudio("out of range. ".concat(n," > ").concat(this.maxDistance)):this.startPlayingAudio("in range")},n}(w),C=function(){var t=function(n,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},t(n,i)};return function(n,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function e(){this.constructor=n}t(n,i),n.prototype=null===i?Object.create(i):(e.prototype=i.prototype,new e)}}(),A=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},R=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}},M="zc.ra.4",I=function(t){function n(n,i,e){var r=t.call(this,n,e)||this;return r.i=n,r.streamView=i.streamView,r.position=i.position||null,r.createSource(),r.userID="stream"+(new Date).getTime(),r.config={needLoopback:!1,useGain:!1,playOnAudioContext:!1,useWebAudio:!0},r.streamView.on("_trackChange",function(t,n){"audio"===t&&(n?r.createSource(!0):r.i.error("".concat(M," ").concat(r.userID," audio track lost")))}),r}return C(n,t),n.prototype.createSource=function(t){var n=this;if(void 0===t&&(t=!1),(0,d.Fr)())return this.i.info("".concat(M," ").concat(this.userID," not create src.")),this.changeRenderConfig=function(){return A(n,void 0,void 0,function(){return R(this,function(t){return[2]})})},!1;if(!this.streamView)return!1;if(this.i.info(M+" create view source. trackChanged: "+t),!this.sourceNode||t){var i=this.streamView.v.getAudioNodeAndStopRender();if(!i)return this.i.error(M+" create view source failed."),!1;this.sourceNode&&this.sourceNode.disconnect(),this.sourceNode=i,this.changeRenderConfig(this.isSpatial,!0)}return null!==this.distance&&this.distance<this.maxDistance&&this.startPlayingAudio("in range"),!0},n.prototype.startPlayingAudio=function(t){var n,i;return A(this,void 0,void 0,function(){var e;return R(this,function(r){switch(r.label){case 0:return this.isPlaying?(this.i.info(M+" ".concat(this.userID," is already playing")),[2]):(t&&this.i.info(M+" vocal ".concat(this.userID," play for ").concat(t)),this.isPlaying=!0,(0,d.Fr)()?(this.streamView.setAudioMuted(!1),[2]):(this.audioEl=this.audioEl||u.useAudioEl()||null,this.i.info(M+" ".concat(this.userID," start using audio el ").concat(null===(n=this.audioEl)||void 0===n?void 0:n.id)),(e=null===(i=this.audioEl)||void 0===i?void 0:i.dom)||(this.i.error(M+" ".concat(this.userID," not enough audio elements")),e=s.VJ.createElement("audio"),this.audioEl={id:-1,dom:e,used:!0},e.setAttribute("autoplay","autoplay")),e.muted=!0,e.setAttribute("autoplay","autoplay"),e.setAttribute("id","zg-audio-source-"+this.userID),this.sourceNode?[4,this.changeRenderConfig(this.isSpatial,!0)]:[3,2]));case 1:r.sent(),r.label=2;case 2:return"suspended"===this.audioCtx.state&&this.audioCtx.resume(),[2]}})})},n.prototype.stopPlayingAudio=function(t){if(void 0===t&&(t=""),this.isPlaying&&(this.i.info(M+" vocal ".concat(this.userID," stop for ")+t),this.isPlaying=!1),(0,d.Fr)())this.streamView.setAudioMuted(!0);else{this.sourceNode&&this.sourceNode.disconnect();var n=this.audioEl,i=null==n?void 0:n.dom;i&&(i.srcObject=null,i.parentNode&&i.parentNode.removeChild(i));var e=(null==n?void 0:n.id)||-1;n&&e>=0&&(u.stopUsingAudioEl(e),this.i.info(M+" ".concat(this.userID," stop using audio el ").concat(e))),this.audioEl=null}},n.prototype.checkIfCanPlay=function(t){var n=this.distance=this.getDistanceFromListener(t);null===n||n>this.maxDistance||0===this.maxDistance?this.stopPlayingAudio("out of range. ".concat(n," > ").concat(this.maxDistance)):this.startPlayingAudio("in range")},n}(w),D=e(166),P=function(){function t(){this.u={}}return t.getInstance=function(){return t.instance||(t.instance=new t),t.instance},t.prototype.addEventHandler=function(t,n){if(this.u[t]||(this.u[t]=[]),!(0,l.JO)(n))throw new Error("Params callBack is not a Function");return-1==this.u[t].indexOf(n)&&this.u[t].push(n),!0},t.prototype.removeEventHandler=function(t,n){return!!this.u[t]&&(this.u[t]=n?this.u[t].filter(function(t){return t!==n}):[],!0)},t.prototype.emit=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.u[t]&&this.u[t].forEach(function(i){try{setTimeout(function(){i.apply(void 0,n)},0)}catch(n){console.error('Fail to execute callback of event "'.concat(t,'" : ').concat(n))}})},t.prototype.reset=function(){this.u={}},t}(),L=P,j=function(t,n,i,e){return new(i||(i=Promise))(function(r,o){function s(t){try{c(e.next(t))}catch(t){o(t)}}function u(t){try{c(e.throw(t))}catch(t){o(t)}}function c(t){var n;t.done?r(t.value):(n=t.value,n instanceof i?n:new i(function(t){t(n)})).then(s,u)}c((e=e.apply(t,n||[])).next())})},F=function(t,n){var i,e,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(c){return function(u){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(i=1,e&&(r=2&u[0]?e.return:u[0]?e.throw||((r=e.return)&&r.call(e),0):e.next)&&!(r=r.call(e,u[1])).done)return r;switch(e=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,e=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){s.label=u[1];break}if(6===u[0]&&s.label<r[1]){s.label=r[1],r=u;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(u);break}r[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],e=0}finally{i=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}};var U,H=function(){function t(t,n){var i=this;this.raMode=o.kf.World,this.recvRange=null,this.position=null,this.forwardAxis=[1,0,0],this.upAxis=[0,0,1],this.audioStream=null,this.enableMic=!1,this.isPublishing=!1,this.streamID=null,this.isDenoise=!1,this.denoiseMode=D.PP.AI,this.voiceChanger=null,this.voiceParam=null,this.isUpdated=!0,this.zegoRTC=n,this.audioCtx=t,this.audioListener=this.audioCtx.listener,this.eventHandler=L.getInstance(),this.zegoRTC.on("publisherStateUpdate",function(t){var n=t.state,e=t.errorCode,r=t.extendedData,s=t.streamID.match(/(.*)_(.*)/);if(3===(null==s?void 0:s.length)){if(i.userID!==s[1])return;"NO_PUBLISH"===n?(i.isPublishing=!1,i.stopPublishingStream()):(i.isPublishing=!0,i.isUpdated||(i.i.info(T+" resend stream info"),i.updateSteamExtraInfo())),i.eventHandler.emit("microphoneStateUpdate",{NO_PUBLISH:o.eI.Off,PUBLISH_REQUESTING:o.eI.TurningOn,PUBLISHING:o.eI.On}[n],e,r)}}),this.zegoRTC.on("deviceError",function(t,n){return j(i,void 0,void 0,function(){var i,e;return F(this,function(r){switch(r.label){case 0:return this.i.info(T+" device fail ".concat(t," ").concat(n," ").concat(!!this.audioStream," ").concat(this.micID)),this.audioStream?[4,this.zegoRTC.enumDevices()]:[2];case 1:return i=r.sent(),e=i.microphones,this.micID||0!==e.length?1106009!==t?[3,3]:[4,this.zegoRTC.useAudioDevice(this.audioStream,this.micID||e[0].deviceID)]:[2];case 2:r.sent(),r.label=3;case 3:return[2]}})})})}return Object.defineProperty(t.prototype,"recvMode",{get:function(){return void 0!==this._recvMode?this._recvMode:[o.kf.World,o.kf.SecretTeam].includes(this.raMode)?o.ju.All:o.ju.Team},set:function(t){this._recvMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sendMode",{get:function(){return void 0!==this._sendMode?this._sendMode:this.raMode===o.kf.World?o.UF.All:o.UF.Team},set:function(t){this._sendMode=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"i",{get:function(){return this.zegoRTC.logger},enumerable:!1,configurable:!0}),t.getInstance=function(n,i){return t.instance||(t.instance=new t(n,i)),t.instance},t.prototype.updateSelfPosition=function(t,n,i){this.position=t,this.fo