!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.UCloudRTC=t():e.UCloudRTC=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=29)}([function(e,t,r){"use strict";var n=r(12),o=r(34),i=Object.prototype.toString;function a(e){return"[object Array]"===i.call(e)}function s(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),a(e))for(var r=0,n=e.length;r0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},n.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},n.parseFmtp=function(e){for(var t,r={},n=e.substr(e.indexOf(" ")+1).split(";"),o=0;o-1?(r.attribute=e.substr(t+1,n-t-1),r.value=e.substr(n+1)):r.attribute=e.substr(t+1),r},n.parseSsrcGroup=function(e){var t=e.substr(13).split(" ");return{semantics:t.shift(),ssrcs:t.map((function(e){return parseInt(e,10)}))}},n.getMid=function(e){var t=n.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},n.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},n.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:n.matchPrefix(e+t,"a=fingerprint:").map(n.parseFingerprint)}},n.writeDtlsParameters=function(e,t){var r="a=setup:"+t+"\r\n";return e.fingerprints.forEach((function(e){r+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"})),r},n.getIceParameters=function(e,t){var r=n.splitLines(e);return{usernameFragment:(r=r.concat(n.splitLines(t))).filter((function(e){return 0===e.indexOf("a=ice-ufrag:")}))[0].substr(12),password:r.filter((function(e){return 0===e.indexOf("a=ice-pwd:")}))[0].substr(10)}},n.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},n.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},r=n.splitLines(e)[0].split(" "),o=3;o0?"9":"0",r+=" UDP/TLS/RTP/SAVPF ",r+=t.codecs.map((function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType})).join(" ")+"\r\n",r+="c=IN IP4 0.0.0.0\r\n",r+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach((function(e){r+=n.writeRtpMap(e),r+=n.writeFmtp(e),r+=n.writeRtcpFb(e)}));var o=0;return t.codecs.forEach((function(e){e.maxptime>o&&(o=e.maxptime)})),o>0&&(r+="a=maxptime:"+o+"\r\n"),r+="a=rtcp-mux\r\n",t.headerExtensions&&t.headerExtensions.forEach((function(e){r+=n.writeExtmap(e)})),r},n.parseRtpEncodingParameters=function(e){var t,r=[],o=n.parseRtpParameters(e),i=-1!==o.fecMechanisms.indexOf("RED"),a=-1!==o.fecMechanisms.indexOf("ULPFEC"),s=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute})),c=s.length>0&&s[0].ssrc,u=n.matchPrefix(e,"a=ssrc-group:FID").map((function(e){return e.substr(17).split(" ").map((function(e){return parseInt(e,10)}))}));u.length>0&&u[0].length>1&&u[0][0]===c&&(t=u[0][1]),o.codecs.forEach((function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var n={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10)};c&&t&&(n.rtx={ssrc:t}),r.push(n),i&&((n=JSON.parse(JSON.stringify(n))).fec={ssrc:c,mechanism:a?"red+ulpfec":"red"},r.push(n))}})),0===r.length&&c&&r.push({ssrc:c});var d=n.matchPrefix(e,"b=");return d.length&&(d=0===d[0].indexOf("b=TIAS:")?parseInt(d[0].substr(7),10):0===d[0].indexOf("b=AS:")?1e3*parseInt(d[0].substr(5),10)*.95-16e3:void 0,r.forEach((function(e){e.maxBitrate=d}))),r},n.parseRtcpParameters=function(e){var t={},r=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"cname"===e.attribute}))[0];r&&(t.cname=r.value,t.ssrc=r.ssrc);var o=n.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=o.length>0,t.compound=0===o.length;var i=n.matchPrefix(e,"a=rtcp-mux");return t.mux=i.length>0,t},n.parseMsid=function(e){var t,r=n.matchPrefix(e,"a=msid:");if(1===r.length)return{stream:(t=r[0].substr(7).split(" "))[0],track:t[1]};var o=n.matchPrefix(e,"a=ssrc:").map((function(e){return n.parseSsrcMedia(e)})).filter((function(e){return"msid"===e.attribute}));return o.length>0?{stream:(t=o[0].value.split(" "))[0],track:t[1]}:void 0},n.parseSctpDescription=function(e){var t,r=n.parseMLine(e),o=n.matchPrefix(e,"a=max-message-size:");o.length>0&&(t=parseInt(o[0].substr(19),10)),isNaN(t)&&(t=65536);var i=n.matchPrefix(e,"a=sctp-port:");if(i.length>0)return{port:parseInt(i[0].substr(12),10),protocol:r.fmt,maxMessageSize:t};if(n.matchPrefix(e,"a=sctpmap:").length>0){var a=n.matchPrefix(e,"a=sctpmap:")[0].substr(10).split(" ");return{port:parseInt(a[0],10),protocol:a[1],maxMessageSize:t}}},n.writeSctpDescription=function(e,t){var r=[];return r="DTLS/SCTP"!==e.protocol?["m="+e.kind+" 9 "+e.protocol+" "+t.protocol+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctp-port:"+t.port+"\r\n"]:["m="+e.kind+" 9 "+e.protocol+" "+t.port+"\r\n","c=IN IP4 0.0.0.0\r\n","a=sctpmap:"+t.port+" "+t.protocol+" 65535\r\n"],void 0!==t.maxMessageSize&&r.push("a=max-message-size:"+t.maxMessageSize+"\r\n"),r.join("")},n.generateSessionId=function(){return Math.random().toString().substr(2,21)},n.writeSessionBoilerplate=function(e,t,r){var o=void 0!==t?t:2;return"v=0\r\no="+(r||"thisisadapterortc")+" "+(e||n.generateSessionId())+" "+o+" IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},n.writeMediaSection=function(e,t,r,o){var i=n.writeRtpDescription(e.kind,t);if(i+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),i+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":"active"),i+="a=mid:"+e.mid+"\r\n",e.direction?i+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?i+="a=sendrecv\r\n":e.rtpSender?i+="a=sendonly\r\n":e.rtpReceiver?i+="a=recvonly\r\n":i+="a=inactive\r\n",e.rtpSender){var a="msid:"+o.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+a,i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a,e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+a,i+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(i+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),i},n.getDirection=function(e,t){for(var r=n.splitLines(e),o=0;o0&&a.length>o&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=a.length,s=c,console&&console.warn&&console.warn(s)}return e}function f(){for(var e=[],t=0;t0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)i(c,this,t);else{var u=c.length,d=m(c,u);for(r=0;r=0;i--)if(r[i]===t||r[i].listener===t){a=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return l(this,e,!0)},s.prototype.rawListeners=function(e){return l(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SERVER_CONFIG={api:"https://urtc.com.cn",log:"https://log.urtc.com.cn"},t.setServers=function(e){for(var r in t.SERVER_CONFIG)"string"==typeof e[r]?t.SERVER_CONFIG[r]=e[r]:t.SERVER_CONFIG[r]=t.SERVER_CONFIG[r]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(22);r(67);var o=r(5),i=r(23),a=r(1),s=r(59),c=r(24),u=r(3),d=r(62),f=r(4);t.enumerateDevices=function(e,t,r){var o=this;new Promise((function(t,r){return n.__awaiter(o,void 0,void 0,(function(){var o,i,s,c,u,d;return n.__generator(this,(function(n){switch(n.label){case 0:o=!0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.enumerateDevices()];case 2:return 0===(u=n.sent()).length?(t(u),[2]):(u.forEach((function(e){""===e.label&&(o=!1)})),o?(t(u),[2]):[3,4]);case 3:return i=n.sent(),r(i),[2];case 4:return n.trys.push([4,6,,7]),s={},e.includes("audio")&&(s.audio=!0),e.includes("video")&&(s.video=!0),[4,navigator.mediaDevices.getUserMedia(s)];case 5:return n.sent().getTracks().forEach((function(e){e.stop()})),[3,7];case 6:return c=n.sent(),a.default.warn("EnumerateDevices ",c),[3,7];case 7:return n.trys.push([7,9,,10]),[4,navigator.mediaDevices.enumerateDevices()];case 8:return u=n.sent(),t(u),[3,10];case 9:return d=n.sent(),r(d),[3,10];case 10:return[2]}}))}))})).then(t).catch(r)};function p(){return"safari"===f.getBrowserInfo().name.toLowerCase()}function l(){return"chrome"===f.getBrowserInfo().name.toLowerCase()}var h=function(){function e(e,t){if(this.resolution=i.getResolution(""),this.isSubscriber=!1,this.currentStatsReports=new d.StatsReports,this.mediaType=e,this.emitter=t,this.mediaStream=new MediaStream,l()||p()){this.peerConnection=new RTCPeerConnection({sdpSemantics:"plan-b"})}else this.peerConnection=new RTCPeerConnection;var r=this;this.peerConnection.addEventListener("iceconnectionstatechange",(function(e){switch(a.default.debug("iceconnectionstatechange event ",this.connectionState,e),this.connectionState){case"new":case"connecting":break;case"connected":r.startUploadStats();break;case"disconnected":a.default.warn("peerconnection disconnected"),r.stopUploadStats();break;case"failed":a.default.warn("peerconnection failed"),r.stopUploadStats();break;case"closed":r.stopUploadStats()}})),this.peerConnection.addEventListener("connectionstatechange",(function(e){switch(a.default.debug("connectionstatechange event",this.connectionState,e),this.connectionState){case"new":case"connecting":break;case"connected":r.emitter.emit("stream-connected",r),r.startUploadStats();break;case"disconnected":a.default.warn("peerconnection disconnected"),r.stopUploadStats();break;case"failed":a.default.warn("peerconnection failed"),r.stopUploadStats();break;case"closed":r.stopUploadStats()}}))}return e.prototype.setResolution=function(e){this.resolution=e},Object.defineProperty(e.prototype,"videoConstraints",{get:function(){return this.resolution.video},enumerable:!0,configurable:!0}),e.prototype._connect=function(e,t){return n.__awaiter(this,void 0,void 0,(function(){var r,o,i;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,this.peerConnection.createOffer({offerToReceiveAudio:e,offerToReceiveVideo:t})];case 1:return r=n.sent(),o=this.resolution.attributes,r.sdp&&t&&(r.sdp=function(e,t){a.default.debug("sdp attributes",t);var r,n=e.match(/m=video.*\r\n/);return n&&(r=n[0]+"b=AS:"+t.maxVideoBW+"\r\n",e=e.replace(n[0],r)),e}(r.sdp,o),r.sdp=(s=r.sdp,c=this.videoCodec,a.default.debug("sdp codec",c),"h264"===c&&p(),s)),[4,this.peerConnection.setLocalDescription(r)];case 2:return n.sent(),[2,r];case 3:throw i=n.sent(),a.default.error("peerconnection create offer error ",i),i;case 4:return[2]}var s,c}))}))},e.prototype.answer=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t;return n.__generator(this,(function(r){return a.default.debug("stream worker answer: ",e),t=new RTCSessionDescription({type:e.type,sdp:e.sdpcontent}),[2,this.peerConnection.setRemoteDescription(t)]}))}))},e.prototype.getVideoTrack=function(){return this.mediaStream.getVideoTracks()[0]},e.prototype.getAudioTrack=function(){return this.mediaStream.getAudioTracks()[0]},e.prototype.muteVideo=function(){var e=this.getVideoTrack();return!!e&&(e.enabled=!1,!0)},e.prototype.unmuteVideo=function(){var e=this.getVideoTrack();return!!e&&(e.enabled=!0,!0)},e.prototype.muteAudio=function(){var e=this.getAudioTrack();return!!e&&(e.enabled=!1,!0)},e.prototype.unmuteAudio=function(){var e=this.getAudioTrack();return!!e&&(e.enabled=!0,!0)},e.prototype.getMediaStream=function(){return this.mediaStream},e.prototype.close=function(){this.mediaStream.getTracks().forEach((function(e){e.stop()})),this.audioHelper&&this.audioHelper.destroy(),this.peerConnection.close()},e.prototype.getAudioVolume=function(){return this.audioHelper?this.audioHelper.getVolume():(a.default.warn("No audio track"),0)},e.prototype.updateStatsReports=function(e,t){var r=this,n=this.lastStatsReports,o=this.currentStatsReports,i=new d.StatsReports;if(i.timestamp-o.timestamp<500){if(n)return void e({last:n,current:o});var s="invoke function too frequently";return a.default.error(s),void t(s)}this.peerConnection.getStats().then((function(t){t.forEach((function(e){i.original.push(e),"inbound-rtp"===e.type&&"audio"===e.mediaType&&(i.inAudioReport.bytesReceived=e.bytesReceived||i.inAudioReport.bytesReceived,i.inAudioReport.jitter=e.jitter||i.inAudioReport.jitter,i.inAudioReport.packetsLost=e.packetsLost||i.inAudioReport.packetsLost,i.inAudioReport.packetsReceived=e.packetsReceived||i.inAudioReport.packetsReceived),"inbound-rtp"===e.type&&"video"===e.mediaType&&(i.inVideoReport.bytesReceived=e.bytesReceived||i.inVideoReport.bytesReceived,i.inVideoReport.packetsLost=e.packetsLost||i.inVideoReport.packetsLost,i.inVideoReport.packetsReceived=e.packetsReceived||i.inVideoReport.packetsReceived,i.inVideoReport.firCount=e.firCount||i.inVideoReport.firCount,i.inVideoReport.nackCount=e.nackCount||i.inVideoReport.nackCount,i.inVideoReport.pliCount=e.pliCount||i.inVideoReport.pliCount,i.inVideoReport.framesDecoded=e.framesDecoded||i.inVideoReport.framesDecoded),"outbound-rtp"===e.type&&"audio"===e.mediaType&&(i.outAudioReport.bytesSent=e.bytesSent||i.outAudioReport.bytesSent,i.outAudioReport.packetsSent=e.packetsSent||i.outAudioReport.packetsSent),"outbound-rtp"===e.type&&"video"===e.mediaType&&(i.outVideoReport.bytesSent=e.bytesSent||i.outVideoReport.bytesSent,i.outVideoReport.packetsSent=e.packetsSent||i.outVideoReport.packetsSent,i.outVideoReport.firCount=e.firCount||i.outVideoReport.firCount,i.outVideoReport.nackCount=e.nackCount||i.outVideoReport.nackCount,i.outVideoReport.pliCount=e.pliCount||i.outVideoReport.pliCount,i.outVideoReport.framesEncoded=e.framesEncoded||i.outVideoReport.framesEncoded),"track"===e.type&&(i.inAudioReport.audioLevel=e.audioLevel||i.inAudioReport.audioLevel,i.inVideoReport.frameHeight=e.frameHeight||i.inVideoReport.frameHeight,i.inVideoReport.frameWidth=e.frameWidth||i.inVideoReport.frameWidth,i.inVideoReport.framesDecoded=e.framesDecoded||i.inVideoReport.framesDecoded,i.inVideoReport.framesDropped=e.framesDropped||i.inVideoReport.framesDropped,i.inVideoReport.framesReceived=e.framesReceived||i.inVideoReport.framesReceived,i.outVideoReport.frameHeight=e.frameHeight||i.outVideoReport.frameHeight,i.outVideoReport.frameWidth=e.frameWidth||i.outVideoReport.frameWidth,i.outVideoReport.framesSent=e.framesSent||i.outVideoReport.framesSent),"track"===e.type&&(i.outAudioReport.audioLevel=e.audioLevel||i.outAudioReport.audioLevel),"media-source"===e.type&&"audio"===e.kind&&(i.outAudioReport.audioLevel=e.audioLevel||i.outAudioReport.audioLevel),"outbound-rtp"===e.type&&"audio"===e.mediaType&&(i.outAudioReport.retransmittedBytesSent=e.retransmittedBytesSent||i.outAudioReport.retransmittedBytesSent,i.outAudioReport.retransmittedPacketsSent=e.retransmittedPacketsSent||i.outAudioReport.retransmittedPacketsSent),"candidate-pair"===e.type&&(i.candidatePairReport.availableIncomingBitrate=e.availableIncomingBitrate||i.candidatePairReport.availableIncomingBitrate,i.candidatePairReport.availableOutgoingBitrate=e.availableOutgoingBitrate||i.candidatePairReport.availableOutgoingBitrate,i.candidatePairReport.bytesReceived=e.bytesReceived||i.candidatePairReport.bytesReceived,i.candidatePairReport.bytesSent=e.bytesSent||i.candidatePairReport.bytesSent,i.candidatePairReport.currentRoundTripTime=e.currentRoundTripTime||i.candidatePairReport.currentRoundTripTime,i.candidatePairReport.totalRoundTripTime=e.totalRoundTripTime||i.candidatePairReport.totalRoundTripTime),"local-candidate"===e.type&&(i.localCandidateReport.ip=e.ip||e.address||i.localCandidateReport.ip,i.localCandidateReport.networkType=e.networkType||i.localCandidateReport.networkType,i.localCandidateReport.port=e.port||i.localCandidateReport.port,i.localCandidateReport.protocol=e.protocol||i.localCandidateReport.protocol),"remote-candidate"===e.type&&(i.remoteCandidateReport.ip=e.ip||e.address||i.remoteCandidateReport.ip,i.remoteCandidateReport.port=e.port||i.remoteCandidateReport.port,i.remoteCandidateReport.protocol=e.protocol||i.remoteCandidateReport.protocol),"transport"===e.type&&(i.transportReport.bytesReceived=e.bytesReceived||i.transportReport.bytesReceived,i.transportReport.bytesSent=e.bytesSent||i.transportReport.bytesSent,i.transportReport.dtlsState=e.dtlsState||i.transportReport.dtlsState)})),i.timestamp=Date.now(),r.lastStatsReports=o,r.currentStatsReports=i,e({last:o,current:i})})).catch((function(e){a.default.error("getStats ",e),t(e)}))},e.prototype.getStats=function(e,t){var r=this;this.updateStatsReports((function(t){var n=t.last,o=t.current,i=Math.round((o.timestamp-n.timestamp)/1e3),a={br:-1,lostpre:-1,vol:-1,mime:r.audioCodec};if(r.isSubscriber){if(o.inAudioReport&&n.inAudioReport){var s=o.inAudioReport.bytesReceived-n.inAudioReport.bytesReceived,c=o.inAudioReport.packetsReceived-n.inAudioReport.packetsReceived,u=o.inAudioReport.packetsLost-n.inAudioReport.packetsLost;a.br=Math.floor(8*s/i)||0,a.lostpre=Math.floor(u/(c+u)/i)||0,a.vol=Math.floor(100*(o.inAudioReport.audioLevel||0))||0}}else if(o.outAudioReport&&n.outAudioReport){var d=o.outAudioReport.bytesSent-n.outAudioReport.bytesSent,f=o.outAudioReport.packetsSent-n.outAudioReport.packetsSent;u=o.outAudioReport.retransmittedPacketsSent-n.outAudioReport.retransmittedPacketsSent;a.br=Math.floor(8*d/i)||0,a.lostpre=Math.floor(u/(f+u)/i)||0,a.vol=Math.floor(100*(o.outAudioReport.audioLevel||0))||0}var p={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:r.videoCodec};if(r.isSubscriber){if(o.inVideoReport&&n.inVideoReport){s=o.inVideoReport.bytesReceived-n.inVideoReport.bytesReceived,c=o.inVideoReport.packetsReceived-n.inVideoReport.packetsReceived,u=o.inVideoReport.packetsLost-n.inVideoReport.packetsLost;var l=o.inVideoReport.framesReceived-n.inVideoReport.framesReceived;p.br=Math.floor(8*s/i)||0,p.lostpre=Math.floor(u/(c+u)/i)||0,p.frt=Math.floor(l/i)||0,p.w=o.inVideoReport.frameWidth||-1,p.h=o.inVideoReport.frameHeight||-1}}else if(o.outVideoReport&&n.outVideoReport){d=o.outVideoReport.bytesSent-n.outVideoReport.bytesSent,f=o.outVideoReport.packetsSent-n.outVideoReport.packetsSent,u=o.outVideoReport.nackCount-n.outVideoReport.nackCount;var h=o.outVideoReport.framesSent-n.outVideoReport.framesSent;p.br=Math.floor(8*d/i)||0,p.lostpre=Math.floor(u/(f+u)/i)||0,p.frt=Math.floor(h/i)||0,p.w=o.outVideoReport.frameWidth||-1,p.h=o.outVideoReport.frameHeight||-1}var m={rtt:-1,delay:-1};r.isSubscriber?o.candidatePairReport&&(m.delay=Math.floor(1e3*o.candidatePairReport.currentRoundTripTime)||0):o.candidatePairReport&&(m.rtt=Math.floor(1e3*o.candidatePairReport.currentRoundTripTime)||0),e({audio:a,video:p,connection:m})}),t)},e.prototype.startUploadStats=function(){var e=this;this.timer||(this.timer=window.setInterval((function(){e.getStats((function(t){e.isSubscriber?e.logReporter.reportSubscribeStatusLog(e.streamSubId,e.streamId,e.userId,e.mediaType,{delay:t.connection.delay,rtt:-1,audio:t.audio,video:t.video,cpu:0,memory:0}):e.logReporter.reportPublishStatusLog(e.streamId,e.mediaType,{delay:-1,rtt:t.connection.rtt,audio:t.audio,video:t.video,cpu:0,memory:0})}),(function(e){a.default.error("upload stats ",e)}))}),3e3))},e.prototype.stopUploadStats=function(){this.timer&&(window.clearInterval(this.timer),this.timer=0)},e.prototype.playEffect=function(e,t,r){var n=this;if(this.audioHelper)this.audioHelper.createAudioBufferSource(e,t).then((function(){if(!n.audioHelper)return r();var e=n.getAudioTrack(),t=n.audioHelper.dstAudioTrack;if(!e||!t)return r();n.isSubscriber?(n.mediaStream.removeTrack(e),n.mediaStream.addTrack(t)):n.peerConnection.getSenders().forEach((function(r){r.track&&r.track.id===e.id&&(a.default.debug("local stream - replace audio track ",t,e),r.replaceTrack(t),n.mediaStream.removeTrack(e),n.mediaStream.addTrack(t))})),r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e.prototype.pauseEffect=function(e,t){var r=this;if(this.audioHelper)this.audioHelper.pauseEffect(e).then((function(){if(r.isSubscriber&&r.audioHelper){var e=r.getAudioTrack(),n=r.audioHelper.srcAudioTrack;e&&n&&(r.mediaStream.removeTrack(e),r.mediaStream.addTrack(n))}t()})).catch((function(e){t(e)}));else{t("the stream cannot play audio")}},e.prototype.resumeEffect=function(e,t,r){var n=this;if(this.audioHelper)this.audioHelper.resumeEffect(e,t).then((function(){if(n.isSubscriber&&n.audioHelper){var e=n.getAudioTrack(),t=n.audioHelper.dstAudioTrack;e&&t&&(n.mediaStream.removeTrack(e),n.mediaStream.addTrack(t))}r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e.prototype.stopEffect=function(e,t){var r=this;if(this.audioHelper)this.audioHelper.removeAudioBufferSource(e).then((function(){if(r.isSubscriber&&r.audioHelper){var e=r.getAudioTrack(),n=r.audioHelper.srcAudioTrack;e&&n&&(r.mediaStream.removeTrack(e),r.mediaStream.addTrack(n))}t()})).catch((function(e){t(e)}));else{t("the stream cannot play audio")}},e.prototype.setEffectVolume=function(e,t,r){if(this.audioHelper)this.audioHelper.setGainNodeVolume(e,t).then((function(){r()})).catch((function(e){r(e)}));else{r("the stream cannot play audio")}},e}();t.RTCStream=h;var m=function(e){function t(t,r,n){var o=e.call(this,t,r)||this;return o.config=Object.assign({screenAudio:!1,screenVideo:n.screen,externalAudio:!1,externalVideo:!1},n),o.peerConnection.addEventListener("track",(function(e){a.default.debug("local - track event ",e)})),o}return n.__extends(t,e),Object.defineProperty(t.prototype,"publishConfig",{get:function(){return Object.assign({},this.config,{audio:this.config.audio||this.config.screenAudio||this.config.externalAudio,video:this.config.video||this.config.screenVideo||this.config.externalVideo})},enumerable:!0,configurable:!0}),t.prototype.setVideoProfile=function(e){var t=this.getVideoTrack();return null===t?Promise.reject("no video track found"):t.applyConstraints(e.video)},t.prototype.initMediaStream=function(){return n.__awaiter(this,void 0,void 0,(function(){var e,t,r,o,i,u,d,f,p,h=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(e=this.config,t={audio:!1,video:!1},e.audio&&e.microphoneId?t.audio={deviceId:e.microphoneId}:e.audio&&(t.audio=!0),r=this.resolution.video,e.video&&e.cameraId?t.video={deviceId:e.cameraId,width:r.width,height:r.height,frameRate:r.frameRate}:e.video&&(t.video={width:r.width,height:r.height,frameRate:r.frameRate}),!t.audio&&!t.video)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(t)];case 2:return(o=n.sent()).getTracks().forEach((function(e){a.default.debug("local stream - add track ",e),"audio"!==e.kind||h.audioHelper||(h.audioHelper=new s.AudioHelper(o)),"video"===e.kind&&h.mediaStream.addTrack(e),h.peerConnection.addTrack(e)})),[3,4];case 3:throw i=n.sent(),a.default.error("local stream - get user media ",i),t.audio&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones),t.video&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras),i;case 4:if(t.audio&&t.video||!e.screen)return[3,16];if(!l()||!e.extensionId)return[3,9];n.label=5;case 5:return n.trys.push([5,7,,8]),[4,new Promise((function(t,r){window.chrome.runtime.sendMessage(e.extensionId,{},(function(e){if(a.default.debug("local stream (chrome extension) response ",e),!e)return r("chrome extension - no response");if("success"!==e.type)return r("chrome extension - response error");var n=e.options,o={audio:!!(void 0===n?{canRequestAudioTrack:!1}:n).canRequestAudioTrack&&{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e.streamId}},video:{mandatory:{chromeMediaSource:"desktop",chromeMediaSourceId:e.streamId}}};if(navigator.mediaDevices.getUserMedia)navigator.mediaDevices.getUserMedia(o).then(t).catch(r);else if(navigator.webkitGetUserMedia)navigator.webkitGetUserMedia(o,t,r);else{r("browser no support screen share")}}))}))];case 6:return u=n.sent(),a.default.debug("local stream (chrome extension) - ",u),[3,8];case 7:throw d=n.sent(),a.default.error("chrome extend stream - get screen ",d),d;case 8:return[3,15];case 9:if(!navigator.mediaDevices.getDisplayMedia)return[3,14];n.label=10;case 10:return n.trys.push([10,12,,13]),[4,navigator.mediaDevices.getDisplayMedia({audio:!0,video:!0})];case 11:return u=n.sent(),a.default.debug("local stream - ",u),[3,13];case 12:throw f=n.sent(),a.default.error("local stream - get screen ",f),f;case 13:return[3,15];case 14:throw p="browser no support screen share",a.default.error("local stream - get screen ",p),new Error(p);case 15:try{u.getTracks().forEach((function(t){a.default.debug("local stream - add screen track ",t),t.addEventListener("mute",(function(e){a.default.debug("screen track mute ",this.muted,e)})),t.addEventListener("unmute",(function(e){a.default.debug("screen track unmute ",this.muted,e)})),t.addEventListener("isolationchange",(function(e){a.default.debug("screen track isolationchange ",this.isolated,e)}));var r=h;t.addEventListener("ended",(function(e){a.default.debug("screen track ended ",this.readyState,e),r.emitter.emit("screen-track-ended",r)})),"audio"!==t.kind||e.audio||(h.peerConnection.addTrack(t),h.audioHelper=new s.AudioHelper(u),e.screenAudio=!0),"video"!==t.kind||e.video||(h.mediaStream.addTrack(t),h.peerConnection.addTrack(t),e.screenVideo=!0)}))}catch(e){throw a.default.error("local stream - add track ",e),e}n.label=16;case 16:return[2,this.mediaStream]}}))}))},t.prototype.connect=function(t){return n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(r){return this.streamId=t,[2,e.prototype._connect.call(this,this.publishConfig.audio,this.publishConfig.video)]}))}))},t.prototype.switchMicrophone=function(e,t,r){return n.__awaiter(this,void 0,void 0,(function(){var o,i,s,c,u=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.config.audio)return o="audio config is false, cannot switch microphone",a.default.error("local stream switch microphone - ",o),r(o),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia({audio:{deviceId:e}})];case 2:return i=n.sent(),s=i.getAudioTracks()[0],this.mediaStream.getAudioTracks().forEach((function(e){u.peerConnection.getSenders().forEach((function(t){t.track&&t.track.id===e.id&&(a.default.debug("local stream - replace audio track ",s,e),t.replaceTrack(s),u.mediaStream.removeTrack(e),u.mediaStream.addTrack(s),e.stop())}))})),t(),[3,4];case 3:return c=n.sent(),a.default.error("local stream - get microphone ",c),r(c),[3,4];case 4:return[2]}}))}))},t.prototype.switchCamera=function(e,t,r){return n.__awaiter(this,void 0,void 0,(function(){var o,i,s,c,u,d,f=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(!this.config.video)return o="video config is false, cannot switch camera",a.default.error("local stream switch camera - ",o),r(o),[2];n.label=1;case 1:return n.trys.push([1,3,,4]),i=this.resolution.video,s={video:{deviceId:e,width:i.width,height:i.height,frameRate:i.frameRate}},[4,navigator.mediaDevices.getUserMedia(s)];case 2:return c=n.sent(),u=c.getVideoTracks()[0],this.mediaStream.getVideoTracks().forEach((function(e){f.peerConnection.getSenders().forEach((function(t){t.track&&t.track.id===e.id&&(a.default.debug("local stream - replace video track ",u,e),t.replaceTrack(u),f.mediaStream.removeTrack(e),f.mediaStream.addTrack(u),e.stop())}))})),t(),[3,4];case 3:return d=n.sent(),a.default.error("local stream - get camera ",d),r(d),[3,4];case 4:return[2]}}))}))},t}(h);t.LocalStream=m;var v=function(e){function t(t,r,n){var o=e.call(this,r,n)||this,i=o;return o.streamId=t,o.isSubscriber=!0,o.peerConnection.addEventListener("track",(function(e){a.default.debug("remote - track event ",e),i.mediaStream.addTrack(e.track),"audio"!==e.track.kind||i.audioHelper||(i.audioHelper=new s.AudioHelper(e.streams[0]))})),o}return n.__extends(t,e),t.prototype.connect=function(t,r,o){return n.__awaiter(this,void 0,void 0,(function(){return n.__generator(this,(function(n){return this.streamSubId=t,[2,e.prototype._connect.call(this,r,o)]}))}))},t}(h);t.RemoteStream=v;var g=function(){function e(e,t){var r=this;this.originalPublishConfig={audio:!0,video:!0,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1},this.localStreams=[],this.remoteStreams=[],this.cachedAudioBuffers=new Map,this.innerEmitter=new o.EventEmitter,this.currentResolution=i.getResolution(""),this.audioCodec=e,this.videoCodec=t,this.innerEmitter.on("stream-connected",(function(e){a.default.debug("stream-connected ",e),r.getLocalStream(e.streamId)?r._emitter.emit("mediaStreamPublished",{mediaStream:e.getMediaStream()}):r.getRemoteStream(e.streamId)&&r._emitter.emit("mediaStreamSubscribed",{streamId:e.streamId,mediaStream:e.getMediaStream()})})),this.innerEmitter.on("screen-track-ended",(function(e){a.default.debug("screen-track-ended",e),r._emitter.emit("screenMediaStreamEnded",e)}))}return Object.defineProperty(e.prototype,"emitter",{set:function(e){this._emitter=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"logReporter",{set:function(e){this._logReporter=e},enumerable:!0,configurable:!0}),e.prototype.updatePublishConfig=function(e){var t=e.audio,r=e.video,n=e.screen,o=e.microphoneId,i=e.cameraId,a=e.extensionId;this.originalPublishConfig.audio=t,this.originalPublishConfig.video=r,this.originalPublishConfig.screen=n,o&&(this.originalPublishConfig.microphoneId=o),i&&(this.originalPublishConfig.cameraId=i),n&&(this.originalPublishConfig.mediaType=u.ENUM_MEDIA_TYPE.desktop),r&&(this.originalPublishConfig.mediaType=u.ENUM_MEDIA_TYPE.camera),a&&(this.originalPublishConfig.extensionId=a)},e.prototype.getPublishConfig=function(){return Object.assign({},this.originalPublishConfig)},e.prototype.getResolution=function(){return this.currentResolution},e.prototype.getLocalStream=function(e){return e?this.localStreams.find((function(t){return t.streamId===e})):this.localStreams[0]},e.prototype.getRemoteStream=function(e){return this.remoteStreams.find((function(t){return t.streamId===e||t.streamSubId===e}))},e.prototype.getStream=function(e){return e?this.getLocalStream(e)||this.getRemoteStream(e):this.getLocalStream(e)},e.prototype.createLocalStream=function(e,t){return n.__awaiter(this,void 0,void 0,(function(){var r,o,i;return n.__generator(this,(function(n){switch(n.label){case 0:if(a.default.debug("create local stream ",e),this.getLocalStream())throw r="local stream has already created",a.default.error("create local stream - ",r),new Error(r);return(o=new m(t,this.innerEmitter,this.originalPublishConfig)).userId=e,o.audioCodec=this.audioCodec,o.videoCodec=this.videoCodec,o.logReporter=this._logReporter,o.setResolution(this.currentResolution),[4,o.initMediaStream()];case 1:return i=n.sent(),a.default.debug("local mediaStream ",i),this.localStreams.push(o),[2,o]}}))}))},e.prototype.removeLocalStream=function(e){try{var t=this.getLocalStream(e);if(t){var r=this.localStreams.indexOf(t);this.localStreams.splice(r,1),t.close()}}catch(e){a.default.error("removeLocalStream ",e)}},e.prototype.createRemoteStream=function(e,t,r){return n.__awaiter(this,void 0,void 0,(function(){var o,i;return n.__generator(this,(function(n){if(a.default.debug("create remote stream ",e,t),this.getRemoteStream(t))throw o="remote stream exists",a.default.error("create remote stream - ",o),new Error(o);return(i=new v(t,r,this.innerEmitter)).userId=e,i.audioCodec=this.audioCodec,i.videoCodec=this.videoCodec,i.logReporter=this._logReporter,i.setResolution(this.currentResolution),this.remoteStreams.push(i),[2,i]}))}))},e.prototype.removeRemoteStream=function(e){try{var t=this.getRemoteStream(e);if(t){var r=this.remoteStreams.indexOf(t);this.remoteStreams.splice(r,1),t.close()}}catch(e){a.default.error("removeRemoteStream ",e)}},e.prototype.setVideoProfile=function(e){return this.currentResolution=i.getResolution(e),Promise.resolve()},e.prototype.preloadEffect=function(e,t,r){s.AudioHelper.loadAudioBuffer(this.cachedAudioBuffers,e,t).then((function(){r()})).catch((function(e){a.default.error("preloadEffect - ",e),r(e)}))},e.prototype.unloadEffect=function(e){s.AudioHelper.unloadAudioBuffer(this.cachedAudioBuffers,e)},e.prototype.playEffect=function(e,t,r){var n=this.getStream(e);if(n)n.playEffect(this.cachedAudioBuffers,t,r);else{r("cannot find stream")}},e.prototype.pauseEffect=function(e,t,r){var n=this.getStream(e);if(n)n.pauseEffect(t,r);else{r("cannot find stream")}},e.prototype.resumeEffect=function(e,t,r){var n=this.getStream(e);if(n)n.resumeEffect(this.cachedAudioBuffers,t,r);else{r("cannot find stream")}},e.prototype.stopEffect=function(e,t,r){var n=this.getStream(e);if(n)n.stopEffect(t,r);else{r("cannot find stream")}},e.prototype.setEffectVolume=function(e,t,r,n){var o=this.getStream(e);if(o)o.setEffectVolume(t,r,n);else{n("cannot find stream")}},e}();t.StreamWorker=g},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="1.3.6"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(11),o=r(49),i=r(21),a=r(7),s=function(e){return new i(e).origin!==window.location.origin};function c(e){var t=e.url,r=void 0===t?a.SERVER_CONFIG.api+"/uteach":t,c=e.method,u=void 0===c?"GET":c,d=e.responseType,f=void 0===d?"json":d,p=e.data,l=void 0===p?{}:p,h=e.crossOrigin,m=void 0!==h&&h,v=e.needVerifyResponse,g=void 0===v||v;return new Promise((function(e,t){!m&&s(r)?o(r,{param:i.qs.stringify(l)+"&callback"},(function(r,n){return r?t(r):g&&0!==n.err?t(n.msg):void e(n)})):n.default.request({url:r,method:u,responseType:f,data:l}).then((function(r){var n=r.data;if(g&&0!==n.err)return t(n.msg);e(n)})).catch((function(e){t(e)}))}))}t.query=c,t.get=function(e){return c(Object.assign(e,{method:"GET"}))},t.post=function(e){return c(Object.assign(e,{method:"POST"}))}},function(e,t,r){e.exports=r(33)},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(i)})),e.exports=c}).call(this,r(16))},function(e,t){var r,n,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var c,u=[],d=!1,f=-1;function p(){d&&c&&(d=!1,c.length?u=c.concat(u):f=-1,u.length&&l())}function l(){if(!d){var e=s(p);d=!0;for(var t=u.length;t;){for(c=u,u=[];++f1)for(var r=1;r=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function c(e,t){return function(r,n){t(r,n,e)}}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function s(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new r((function(t){t(e.value)})).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}function h(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function m(){for(var e=[],t=0;t1||s(e,t)}))})}function s(e,t){try{(r=o[e](t)).value instanceof g?Promise.resolve(r.value.v).then(c,u):d(i[0][2],r)}catch(e){d(i[0][3],e)}var r}function c(e){s("next",e)}function u(e){s("throw",e)}function d(e,t){e(t),i.shift(),i.length&&s(i[0][0],i[0][1])}}function y(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:g(e[n](t)),done:"return"===n}:o?o(t):t}:o}}function S(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=l(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function R(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function E(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SUPPORT_RESOLUTIONS={"240*180":{width:240,height:180,minFrameRate:20,maxFrameRate:20,minVideoBW:50,maxVideoBW:200},"480*360":{width:480,height:360,minFrameRate:20,maxFrameRate:20,minVideoBW:80,maxVideoBW:300},"640*360":{width:640,height:360,minFrameRate:20,maxFrameRate:20,minVideoBW:80,maxVideoBW:400},"640*480":{width:640,height:480,minFrameRate:20,maxFrameRate:20,minVideoBW:100,maxVideoBW:500},"1280*720":{width:1280,height:720,minFrameRate:20,maxFrameRate:20,minVideoBW:200,maxVideoBW:1e3},"1920*1080":{width:1920,height:1080,minFrameRate:20,maxFrameRate:20,minVideoBW:300,maxVideoBW:1500}};var n="640*480";t.getSupportProfileNames=function(){return Object.keys(t.SUPPORT_RESOLUTIONS)},t.getResolution=function(e){var r=t.SUPPORT_RESOLUTIONS[e];return r||(e=n,r=t.SUPPORT_RESOLUTIONS[e]),{profileName:e,video:{width:r.width,height:r.height,frameRate:{ideal:r.maxFrameRate}},attributes:{minFrameRate:r.minFrameRate,maxFrameRate:r.maxFrameRate,minVideoBW:r.minVideoBW,maxVideoBW:r.maxVideoBW}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o,i,a=r(21),s=r(7),c=r(10),u=r(1),d=r(3),f=r(9),p=r(25),l=r(4);!function(e){e[e.join=10]="join",e[e.stats=2]="stats",e[e.leave=3]="leave",e[e.exception=4]="exception",e[e.operation=5]="operation"}(n||(n={})),function(e){e[e.publish=1]="publish",e[e.subscribe=2]="subscribe",e[e.getCameras=3]="getCameras",e[e.getMicrophones=4]="getMicrophones",e[e.getLoudspeakers=5]="getLoudspeakers",e[e.highCPU=6]="highCPU",e[e.highLoss=7]="highLoss",e[e.highDelay=8]="highDelay",e[e.record=9]="record",e[e.storage=10]="storage",e[e.im=11]="im",e[e.whiteboard=12]="whiteboard",e[e.others=13]="others"}(o=t.ENUM_LOG_EXCEPTION_TYPE||(t.ENUM_LOG_EXCEPTION_TYPE={})),function(e){e[e.joinRoom=1]="joinRoom",e[e.leaveRoom=2]="leaveRoom",e[e.publish=3]="publish",e[e.unpublish=4]="unpublish",e[e.subscribe=5]="subscribe",e[e.unsubscribe=6]="unsubscribe",e[e.unmuteVideo=7]="unmuteVideo",e[e.muteVideo=8]="muteVideo",e[e.unmuteAudio=9]="unmuteAudio",e[e.muteAudio=10]="muteAudio",e[e.startRecord=11]="startRecord",e[e.stopRecord=12]="stopRecord"}(i=t.ENUM_LOG_OPERATION_TYPE||(t.ENUM_LOG_OPERATION_TYPE={}));var h=function(){function e(){}return e.prototype.init=function(e,t,r){this.app_id=e,this.room_id=t,this.user_id=r},e.prototype.reset=function(){this.app_id="",this.room_id="",this.user_id=""},Object.defineProperty(e.prototype,"isValid",{get:function(){return!!(this.app_id&&this.room_id&&this.user_id)},enumerable:!0,configurable:!0}),e.prototype.getCommonHeader=function(e,t){return{version:"1.0",method:"logup",rpc_id:p.getId(),type:e,ts:Math.round(Date.now()/1e3),aid:this.app_id,rid:this.room_id,sid:t&&t.sid||"",uid:this.user_id,streamid:t&&t.streamId||"",stype:t&&t.stype||0,mtype:t&&t.mtype||0}},e.prototype.reportJoinRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.join),t=l.getDeviceInfo(),r=l.getSystemInfo(),o=l.getCPUInfo(),i={sdkv:f.version,agent:p.getAgent(),device:t.vendor+"_"+t.brand+"_"+t.model,system:""+r.name+r.version+"_"+r.versionName,network:""+l.getNetworkInfo().network,cpu:o.brand+"_"+o.model+"_"+o.core,mem:l.getMemInfo().capacity,micphone:1,speaker:1,video:1};if(s.SERVER_CONFIG.log){var d=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),h=Object.assign({},e,{data:i});c.post({url:d.href,data:h,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.error("report joinroom log error ",e)}))}}},e.prototype.reportLeaveRoomLog=function(){if(this.isValid){var e=this.getCommonHeader(n.leave);if(s.SERVER_CONFIG.log){var t=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcJoinLeaveClientLog"),r=Object.assign({},e,{data:{sdkv:"",agent:"",device:"",system:"",network:"",cpu:"",mem:0,micphone:0,speaker:0,video:0}});c.post({url:t.href,data:r,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.error("report leaveroom log error ",e)}))}}},e.prototype.reportPublishStatusLog=function(e,t,r){if(this.isValid){var o=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.publish,mtype:t});if(s.SERVER_CONFIG.log){var i=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),f=Object.assign({userid:"",streamid:""},r),p=Object.assign({},o,{data:f});c.post({url:i.href,data:p,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.error("report stats log error ",e)}))}}},e.prototype.reportSubscribeStatusLog=function(e,t,r,o,i){if(this.isValid){var u=this.getCommonHeader(n.stats,{streamId:e,stype:d.ENUM_STREAM_TYPE.subscribe,mtype:o});if(s.SERVER_CONFIG.log){var f=new a(s.SERVER_CONFIG.log).set("pathname","api/rtcClinetLog"),p=Object.assign({userid:r||"",streamid:t||""},i),l=Object.assign({},u,{data:p});c.post({url:f.href,data:l,crossOrigin:!0,needVerifyResponse:!1})}}},e.prototype.reportExceptionLog=function(e,t){if(this.isValid){var r=this.getCommonHeader(n.exception,t);if(s.SERVER_CONFIG.log){var i=new a(s.SERVER_CONFIG.log).set("pathname","api/exceptionLog"),d=Object.assign({},r,{data:{errorType:e,userid:e===o.subscribe&&t&&t.userId||"",streamid:e===o.subscribe&&t&&t.streamId||""}});c.post({url:i.href,data:d,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.error("report exception log error ",e)}))}}},e.prototype.reportOperationLog=function(e,t){if(this.isValid){var r=i,o=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteVideo,r.muteAudio],d=[r.subscribe,r.unsubscribe,r.unmuteVideo,r.muteVideo,r.unmuteVideo,r.muteAudio],f=[r.startRecord,r.stopRecord],p=this.getCommonHeader(n.operation,t);if(s.SERVER_CONFIG.log){var l=new a(s.SERVER_CONFIG.log).set("pathname","api/opertionLog"),h=Object.assign({},p,{data:{opertionType:e,userid:o.includes(e)&&t&&t.userId||"",streamid:d.includes(e)&&t&&t.streamId||"",recordid:f.includes(e)&&t&&t.recordId||""}});c.post({url:l.href,data:h,crossOrigin:!0,needVerifyResponse:!1}).catch((function(e){u.default.error("report operation log error ",e)}))}}},e}();t.LogReporter=h},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(4),o=r(61),i=1e7,a="web_"+n.getBrowserInfo().name+n.getBrowserInfo().version,s=i,c=a;t.getAgent=function(){return c},t.setAgent=function(e){c=e},t.resetSeq=function(){s=i},t.getId=function(){return c+"_"+o.formatTime(new Date,"YYYYMMDDHHmmss")+"_"+s++}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(63),o=r(64),i=r(65);function a(e,t,r,a){var s=e,c=t,u=r,d=a,f=n.Base64.encode(JSON.stringify({user_id:d,room_id:u,app_id:s,appkey:c})),p=Math.round(Date.now()/1e3),l=i.randNum(8),h=d+s+p+l+u,m=new o("SHA-1","TEXT");return m.setHMACKey(c,"TEXT"),m.update(h),f+"."+m.getHMAC("HEX")+p+l}function s(e){return JSON.parse(n.Base64.decode(e))}function c(e){return n.Base64.encode(JSON.stringify(e))}t.genToken=a,t.decode=s,t.encode=c;var u={genToken:a,decode:s,encode:c};t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(3);t.convertToOuterUser=function(e){return{uid:e.user_id}},t.convertToOuterStream=function(e){return{sid:e.sid,uid:e.uid,type:e.stream_type===n.ENUM_STREAM_TYPE.publish?"publish":"subscribe",audio:e.audio,video:e.video,muteAudio:e.muteaudio,muteVideo:e.mutevideo,mediaStream:e.mediaStream}}},function(e,t,r){"use strict";var n=r(2);function o(e,t,r,o,i){var a=n.writeRtpDescription(e.kind,t);if(a+=n.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=n.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===r?"actpass":i||"active"),a+="a=mid:"+e.mid+"\r\n",e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var s=e.rtpSender._initialTrackId||e.rtpSender.track.id;e.rtpSender._initialTrackId=s;var c="msid:"+(o?o.id:"-")+" "+s+"\r\n";a+="a="+c,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+c,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+c,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+n.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+n.localCName+"\r\n"),a}function i(e,t){var r={codecs:[],headerExtensions:[],fecMechanisms:[]},n=function(e,t){e=parseInt(e,10);for(var r=0;r=14393&&-1===e.indexOf("?transport=udp")})),delete e.url,e.urls=o?n[0]:n,!!n.length}}))}(r.iceServers||[],t),this._iceGatherers=[],r.iceCandidatePoolSize)for(var a=r.iceCandidatePoolSize;a>0;a--)this._iceGatherers.push(new e.RTCIceGatherer({iceServers:r.iceServers,gatherPolicy:r.iceTransportPolicy}));else r.iceCandidatePoolSize=0;this._config=r,this.transceivers=[],this._sdpSessionId=n.generateSessionId(),this._sdpSessionVersion=0,this._dtlsRole=void 0,this._isClosed=!1};Object.defineProperty(d.prototype,"localDescription",{configurable:!0,get:function(){return this._localDescription}}),Object.defineProperty(d.prototype,"remoteDescription",{configurable:!0,get:function(){return this._remoteDescription}}),d.prototype.onicecandidate=null,d.prototype.onaddstream=null,d.prototype.ontrack=null,d.prototype.onremovestream=null,d.prototype.onsignalingstatechange=null,d.prototype.oniceconnectionstatechange=null,d.prototype.onconnectionstatechange=null,d.prototype.onicegatheringstatechange=null,d.prototype.onnegotiationneeded=null,d.prototype.ondatachannel=null,d.prototype._dispatchEvent=function(e,t){this._isClosed||(this.dispatchEvent(t),"function"==typeof this["on"+e]&&this["on"+e](t))},d.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this._dispatchEvent("icegatheringstatechange",e)},d.prototype.getConfiguration=function(){return this._config},d.prototype.getLocalStreams=function(){return this.localStreams},d.prototype.getRemoteStreams=function(){return this.remoteStreams},d.prototype._createTransceiver=function(e,t){var r=this.transceivers.length>0,n={track:null,iceGatherer:null,iceTransport:null,dtlsTransport:null,localCapabilities:null,remoteCapabilities:null,rtpSender:null,rtpReceiver:null,kind:e,mid:null,sendEncodingParameters:null,recvEncodingParameters:null,stream:null,associatedRemoteMediaStreams:[],wantReceive:!0};if(this.usingBundle&&r)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var o=this._createIceAndDtlsTransports();n.iceTransport=o.iceTransport,n.dtlsTransport=o.dtlsTransport}return t||this.transceivers.push(n),n},d.prototype.addTrack=function(t,r){if(this._isClosed)throw c("InvalidStateError","Attempted to call addTrack on a closed peerconnection.");var n;if(this.transceivers.find((function(e){return e.track===t})))throw c("InvalidAccessError","Track already exists.");for(var o=0;o=15025)e.getTracks().forEach((function(t){r.addTrack(t,e)}));else{var n=e.clone();e.getTracks().forEach((function(e,t){var r=n.getTracks()[t];e.addEventListener("enabled",(function(e){r.enabled=e.enabled}))})),n.getTracks().forEach((function(e){r.addTrack(e,n)}))}},d.prototype.removeTrack=function(t){if(this._isClosed)throw c("InvalidStateError","Attempted to call removeTrack on a closed peerconnection.");if(!(t instanceof e.RTCRtpSender))throw new TypeError("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.");var r=this.transceivers.find((function(e){return e.rtpSender===t}));if(!r)throw c("InvalidAccessError","Sender was not created by this connection.");var n=r.stream;r.rtpSender.stop(),r.rtpSender=null,r.track=null,r.stream=null,-1===this.transceivers.map((function(e){return e.stream})).indexOf(n)&&this.localStreams.indexOf(n)>-1&&this.localStreams.splice(this.localStreams.indexOf(n),1),this._maybeFireNegotiationNeeded()},d.prototype.removeStream=function(e){var t=this;e.getTracks().forEach((function(e){var r=t.getSenders().find((function(t){return t.track===e}));r&&t.removeTrack(r)}))},d.prototype.getSenders=function(){return this.transceivers.filter((function(e){return!!e.rtpSender})).map((function(e){return e.rtpSender}))},d.prototype.getReceivers=function(){return this.transceivers.filter((function(e){return!!e.rtpReceiver})).map((function(e){return e.rtpReceiver}))},d.prototype._createIceGatherer=function(t,r){var n=this;if(r&&t>0)return this.transceivers[0].iceGatherer;if(this._iceGatherers.length)return this._iceGatherers.shift();var o=new e.RTCIceGatherer({iceServers:this._config.iceServers,gatherPolicy:this._config.iceTransportPolicy});return Object.defineProperty(o,"state",{value:"new",writable:!0}),this.transceivers[t].bufferedCandidateEvents=[],this.transceivers[t].bufferCandidates=function(e){var r=!e.candidate||0===Object.keys(e.candidate).length;o.state=r?"completed":"gathering",null!==n.transceivers[t].bufferedCandidateEvents&&n.transceivers[t].bufferedCandidateEvents.push(e)},o.addEventListener("localcandidate",this.transceivers[t].bufferCandidates),o},d.prototype._gather=function(t,r){var o=this,i=this.transceivers[r].iceGatherer;if(!i.onlocalcandidate){var a=this.transceivers[r].bufferedCandidateEvents;this.transceivers[r].bufferedCandidateEvents=null,i.removeEventListener("localcandidate",this.transceivers[r].bufferCandidates),i.onlocalcandidate=function(e){if(!(o.usingBundle&&r>0)){var a=new Event("icecandidate");a.candidate={sdpMid:t,sdpMLineIndex:r};var s=e.candidate,c=!s||0===Object.keys(s).length;if(c)"new"!==i.state&&"gathering"!==i.state||(i.state="completed");else{"new"===i.state&&(i.state="gathering"),s.component=1,s.ufrag=i.getLocalParameters().usernameFragment;var u=n.writeCandidate(s);a.candidate=Object.assign(a.candidate,n.parseCandidate(u)),a.candidate.candidate=u,a.candidate.toJSON=function(){return{candidate:a.candidate.candidate,sdpMid:a.candidate.sdpMid,sdpMLineIndex:a.candidate.sdpMLineIndex,usernameFragment:a.candidate.usernameFragment}}}var d=n.getMediaSections(o._localDescription.sdp);d[a.candidate.sdpMLineIndex]+=c?"a=end-of-candidates\r\n":"a="+a.candidate.candidate+"\r\n",o._localDescription.sdp=n.getDescription(o._localDescription.sdp)+d.join("");var f=o.transceivers.every((function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state}));"gathering"!==o.iceGatheringState&&(o.iceGatheringState="gathering",o._emitGatheringStateChange()),c||o._dispatchEvent("icecandidate",a),f&&(o._dispatchEvent("icecandidate",new Event("icecandidate")),o.iceGatheringState="complete",o._emitGatheringStateChange())}},e.setTimeout((function(){a.forEach((function(e){i.onlocalcandidate(e)}))}),0)}},d.prototype._createIceAndDtlsTransports=function(){var t=this,r=new e.RTCIceTransport(null);r.onicestatechange=function(){t._updateIceConnectionState(),t._updateConnectionState()};var n=new e.RTCDtlsTransport(r);return n.ondtlsstatechange=function(){t._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),t._updateConnectionState()},{iceTransport:r,dtlsTransport:n}},d.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var r=this.transceivers[e].iceTransport;r&&(delete r.onicestatechange,delete this.transceivers[e].iceTransport);var n=this.transceivers[e].dtlsTransport;n&&(delete n.ondtlsstatechange,delete n.onerror,delete this.transceivers[e].dtlsTransport)},d.prototype._transceive=function(e,r,o){var a=i(e.localCapabilities,e.remoteCapabilities);r&&e.rtpSender&&(a.encodings=e.sendEncodingParameters,a.rtcp={cname:n.localCName,compound:e.rtcpParameters.compound},e.recvEncodingParameters.length&&(a.rtcp.ssrc=e.recvEncodingParameters[0].ssrc),e.rtpSender.send(a)),o&&e.rtpReceiver&&a.codecs.length>0&&("video"===e.kind&&e.recvEncodingParameters&&t<15019&&e.recvEncodingParameters.forEach((function(e){delete e.rtx})),e.recvEncodingParameters.length?a.encodings=e.recvEncodingParameters:a.encodings=[{}],a.rtcp={compound:e.rtcpParameters.compound},e.rtcpParameters.cname&&(a.rtcp.cname=e.rtcpParameters.cname),e.sendEncodingParameters.length&&(a.rtcp.ssrc=e.sendEncodingParameters[0].ssrc),e.rtpReceiver.receive(a))},d.prototype.setLocalDescription=function(e){var t,r,o=this;if(-1===["offer","answer"].indexOf(e.type))return Promise.reject(c("TypeError",'Unsupported type "'+e.type+'"'));if(!a("setLocalDescription",e.type,o.signalingState)||o._isClosed)return Promise.reject(c("InvalidStateError","Can not set local "+e.type+" in state "+o.signalingState));if("offer"===e.type)t=n.splitSections(e.sdp),r=t.shift(),t.forEach((function(e,t){var r=n.parseRtpParameters(e);o.transceivers[t].localCapabilities=r})),o.transceivers.forEach((function(e,t){o._gather(e.mid,t)}));else if("answer"===e.type){t=n.splitSections(o._remoteDescription.sdp),r=t.shift();var s=n.matchPrefix(r,"a=ice-lite").length>0;t.forEach((function(e,t){var a=o.transceivers[t],c=a.iceGatherer,u=a.iceTransport,d=a.dtlsTransport,f=a.localCapabilities,p=a.remoteCapabilities;if(!(n.isRejected(e)&&0===n.matchPrefix(e,"a=bundle-only").length)&&!a.rejected){var l=n.getIceParameters(e,r),h=n.getDtlsParameters(e,r);s&&(h.role="server"),o.usingBundle&&0!==t||(o._gather(a.mid,t),"new"===u.state&&u.start(c,l,s?"controlling":"controlled"),"new"===d.state&&d.start(h));var m=i(f,p);o._transceive(a,m.codecs.length>0,!1)}}))}return o._localDescription={type:e.type,sdp:e.sdp},"offer"===e.type?o._updateSignalingState("have-local-offer"):o._updateSignalingState("stable"),Promise.resolve()},d.prototype.setRemoteDescription=function(o){var d=this;if(-1===["offer","answer"].indexOf(o.type))return Promise.reject(c("TypeError",'Unsupported type "'+o.type+'"'));if(!a("setRemoteDescription",o.type,d.signalingState)||d._isClosed)return Promise.reject(c("InvalidStateError","Can not set remote "+o.type+" in state "+d.signalingState));var f={};d.remoteStreams.forEach((function(e){f[e.id]=e}));var p=[],l=n.splitSections(o.sdp),h=l.shift(),m=n.matchPrefix(h,"a=ice-lite").length>0,v=n.matchPrefix(h,"a=group:BUNDLE ").length>0;d.usingBundle=v;var g=n.matchPrefix(h,"a=ice-options:")[0];return d.canTrickleIceCandidates=!!g&&g.substr(14).split(" ").indexOf("trickle")>=0,l.forEach((function(a,c){var u=n.splitLines(a),l=n.getKind(a),g=n.isRejected(a)&&0===n.matchPrefix(a,"a=bundle-only").length,b=u[0].substr(2).split(" ")[2],y=n.getDirection(a,h),S=n.parseMsid(a),_=n.getMid(a)||n.generateIdentifier();if(g||"application"===l&&("DTLS/SCTP"===b||"UDP/DTLS/SCTP"===b))d.transceivers[c]={mid:_,kind:l,protocol:b,rejected:!0};else{var R,E,T,w,C,P,k,M,A;!g&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(l,!0));var O,N,I=n.parseRtpParameters(a);g||(O=n.getIceParameters(a,h),(N=n.getDtlsParameters(a,h)).role="client"),k=n.parseRtpEncodingParameters(a);var U=n.parseRtcpParameters(a),x=n.matchPrefix(a,"a=end-of-candidates",h).length>0,L=n.matchPrefix(a,"a=candidate:").map((function(e){return n.parseCandidate(e)})).filter((function(e){return 1===e.component}));if(("offer"===o.type||"answer"===o.type)&&!g&&v&&c>0&&d.transceivers[c]&&(d._disposeIceAndDtlsTransports(c),d.transceivers[c].iceGatherer=d.transceivers[0].iceGatherer,d.transceivers[c].iceTransport=d.transceivers[0].iceTransport,d.transceivers[c].dtlsTransport=d.transceivers[0].dtlsTransport,d.transceivers[c].rtpSender&&d.transceivers[c].rtpSender.setTransport(d.transceivers[0].dtlsTransport),d.transceivers[c].rtpReceiver&&d.transceivers[c].rtpReceiver.setTransport(d.transceivers[0].dtlsTransport)),"offer"!==o.type||g){if("answer"===o.type&&!g){E=(R=d.transceivers[c]).iceGatherer,T=R.iceTransport,w=R.dtlsTransport,C=R.rtpReceiver,P=R.sendEncodingParameters,M=R.localCapabilities,d.transceivers[c].recvEncodingParameters=k,d.transceivers[c].remoteCapabilities=I,d.transceivers[c].rtcpParameters=U,L.length&&"new"===T.state&&(!m&&!x||v&&0!==c?L.forEach((function(e){s(R.iceTransport,e)})):T.setRemoteCandidates(L)),v&&0!==c||("new"===T.state&&T.start(E,O,"controlling"),"new"===w.state&&w.start(N)),!i(R.localCapabilities,R.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&R.sendEncodingParameters[0].rtx&&delete R.sendEncodingParameters[0].rtx,d._transceive(R,"sendrecv"===y||"recvonly"===y,"sendrecv"===y||"sendonly"===y),!C||"sendrecv"!==y&&"sendonly"!==y?delete R.rtpReceiver:(A=C.track,S?(f[S.stream]||(f[S.stream]=new e.MediaStream),r(A,f[S.stream]),p.push([A,C,f[S.stream]])):(f.default||(f.default=new e.MediaStream),r(A,f.default),p.push([A,C,f.default])))}}else{(R=d.transceivers[c]||d._createTransceiver(l)).mid=_,R.iceGatherer||(R.iceGatherer=d._createIceGatherer(c,v)),L.length&&"new"===R.iceTransport.state&&(!x||v&&0!==c?L.forEach((function(e){s(R.iceTransport,e)})):R.iceTransport.setRemoteCandidates(L)),M=e.RTCRtpReceiver.getCapabilities(l),t<15019&&(M.codecs=M.codecs.filter((function(e){return"rtx"!==e.name}))),P=R.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var D,j=!1;if("sendrecv"===y||"sendonly"===y){if(j=!R.rtpReceiver,C=R.rtpReceiver||new e.RTCRtpReceiver(R.dtlsTransport,l),j)A=C.track,S&&"-"===S.stream||(S?(f[S.stream]||(f[S.stream]=new e.MediaStream,Object.defineProperty(f[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(A,"id",{get:function(){return S.track}}),D=f[S.stream]):(f.default||(f.default=new e.MediaStream),D=f.default)),D&&(r(A,D),R.associatedRemoteMediaStreams.push(D)),p.push([A,C,D])}else R.rtpReceiver&&R.rtpReceiver.track&&(R.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===R.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),R.associatedRemoteMediaStreams=[]);R.localCapabilities=M,R.remoteCapabilities=I,R.rtpReceiver=C,R.rtcpParameters=U,R.sendEncodingParameters=P,R.recvEncodingParameters=k,d._transceive(d.transceivers[c],!1,j)}}})),void 0===d._dtlsRole&&(d._dtlsRole="offer"===o.type?"active":"passive"),d._remoteDescription={type:o.type,sdp:o.sdp},"offer"===o.type?d._updateSignalingState("have-remote-offer"):d._updateSignalingState("stable"),Object.keys(f).forEach((function(t){var r=f[t];if(r.getTracks().length){if(-1===d.remoteStreams.indexOf(r)){d.remoteStreams.push(r);var n=new Event("addstream");n.stream=r,e.setTimeout((function(){d._dispatchEvent("addstream",n)}))}p.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),p.forEach((function(e){e[2]||u(d,e[0],e[1],[])})),e.setTimeout((function(){d&&d.transceivers&&d.transceivers.forEach((function(e){e.iceTransport&&"new"===e.iceTransport.state&&e.iceTransport.getRemoteCandidates().length>0&&(console.warn("Timeout for addRemoteCandidate. Consider sending an end-of-candidates notification"),e.iceTransport.addRemoteCandidate({}))}))}),4e3),Promise.resolve()},d.prototype.close=function(){this.transceivers.forEach((function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()})),this._isClosed=!0,this._updateSignalingState("closed")},d.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this._dispatchEvent("signalingstatechange",t)},d.prototype._maybeFireNegotiationNeeded=function(){var t=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,e.setTimeout((function(){if(t.needNegotiation){t.needNegotiation=!1;var e=new Event("negotiationneeded");t._dispatchEvent("negotiationneeded",e)}}),0))},d.prototype._updateIceConnectionState=function(){var e,t={new:0,closed:0,checking:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&!e.rejected&&t[e.iceTransport.state]++})),e="new",t.failed>0?e="failed":t.checking>0?e="checking":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0?e="connected":t.completed>0&&(e="completed"),e!==this.iceConnectionState){this.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this._dispatchEvent("iceconnectionstatechange",r)}},d.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,connected:0,completed:0,disconnected:0,failed:0};if(this.transceivers.forEach((function(e){e.iceTransport&&e.dtlsTransport&&!e.rejected&&(t[e.iceTransport.state]++,t[e.dtlsTransport.state]++)})),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":t.connected>0&&(e="connected"),e!==this.connectionState){this.connectionState=e;var r=new Event("connectionstatechange");this._dispatchEvent("connectionstatechange",r)}},d.prototype.createOffer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createOffer after close"));var i=r.transceivers.filter((function(e){return"audio"===e.kind})).length,a=r.transceivers.filter((function(e){return"video"===e.kind})).length,s=arguments[0];if(s){if(s.mandatory||s.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==s.offerToReceiveAudio&&(i=!0===s.offerToReceiveAudio?1:!1===s.offerToReceiveAudio?0:s.offerToReceiveAudio),void 0!==s.offerToReceiveVideo&&(a=!0===s.offerToReceiveVideo?1:!1===s.offerToReceiveVideo?0:s.offerToReceiveVideo)}for(r.transceivers.forEach((function(e){"audio"===e.kind?--i<0&&(e.wantReceive=!1):"video"===e.kind&&--a<0&&(e.wantReceive=!1)}));i>0||a>0;)i>0&&(r._createTransceiver("audio"),i--),a>0&&(r._createTransceiver("video"),a--);var u=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.transceivers.forEach((function(o,i){var a=o.track,s=o.kind,c=o.mid||n.generateIdentifier();o.mid=c,o.iceGatherer||(o.iceGatherer=r._createIceGatherer(i,r.usingBundle));var u=e.RTCRtpSender.getCapabilities(s);t<15019&&(u.codecs=u.codecs.filter((function(e){return"rtx"!==e.name}))),u.codecs.forEach((function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1"),o.remoteCapabilities&&o.remoteCapabilities.codecs&&o.remoteCapabilities.codecs.forEach((function(t){e.name.toLowerCase()===t.name.toLowerCase()&&e.clockRate===t.clockRate&&(e.preferredPayloadType=t.payloadType)}))})),u.headerExtensions.forEach((function(e){(o.remoteCapabilities&&o.remoteCapabilities.headerExtensions||[]).forEach((function(t){e.uri===t.uri&&(e.id=t.id)}))}));var d=o.sendEncodingParameters||[{ssrc:1001*(2*i+1)}];a&&t>=15019&&"video"===s&&!d[0].rtx&&(d[0].rtx={ssrc:d[0].ssrc+1}),o.wantReceive&&(o.rtpReceiver=new e.RTCRtpReceiver(o.dtlsTransport,s)),o.localCapabilities=u,o.sendEncodingParameters=d})),"max-compat"!==r._config.bundlePolicy&&(u+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),u+="a=ice-options:trickle\r\n",r.transceivers.forEach((function(e,t){u+=o(e,e.localCapabilities,"offer",e.stream,r._dtlsRole),u+="a=rtcp-rsize\r\n",!e.iceGatherer||"new"===r.iceGatheringState||0!==t&&r.usingBundle||(e.iceGatherer.getLocalCandidates().forEach((function(e){e.component=1,u+="a="+n.writeCandidate(e)+"\r\n"})),"completed"===e.iceGatherer.state&&(u+="a=end-of-candidates\r\n"))}));var d=new e.RTCSessionDescription({type:"offer",sdp:u});return Promise.resolve(d)},d.prototype.createAnswer=function(){var r=this;if(r._isClosed)return Promise.reject(c("InvalidStateError","Can not call createAnswer after close"));if("have-remote-offer"!==r.signalingState&&"have-local-pranswer"!==r.signalingState)return Promise.reject(c("InvalidStateError","Can not call createAnswer in signalingState "+r.signalingState));var a=n.writeSessionBoilerplate(r._sdpSessionId,r._sdpSessionVersion++);r.usingBundle&&(a+="a=group:BUNDLE "+r.transceivers.map((function(e){return e.mid})).join(" ")+"\r\n"),a+="a=ice-options:trickle\r\n";var s=n.getMediaSections(r._remoteDescription.sdp).length;r.transceivers.forEach((function(e,n){if(!(n+1>s)){if(e.rejected)return"application"===e.kind?"DTLS/SCTP"===e.protocol?a+="m=application 0 DTLS/SCTP 5000\r\n":a+="m=application 0 "+e.protocol+" webrtc-datachannel\r\n":"audio"===e.kind?a+="m=audio 0 UDP/TLS/RTP/SAVPF 0\r\na=rtpmap:0 PCMU/8000\r\n":"video"===e.kind&&(a+="m=video 0 UDP/TLS/RTP/SAVPF 120\r\na=rtpmap:120 VP8/90000\r\n"),void(a+="c=IN IP4 0.0.0.0\r\na=inactive\r\na=mid:"+e.mid+"\r\n");var c;if(e.stream)"audio"===e.kind?c=e.stream.getAudioTracks()[0]:"video"===e.kind&&(c=e.stream.getVideoTracks()[0]),c&&t>=15019&&"video"===e.kind&&!e.sendEncodingParameters[0].rtx&&(e.sendEncodingParameters[0].rtx={ssrc:e.sendEncodingParameters[0].ssrc+1});var u=i(e.localCapabilities,e.remoteCapabilities);!u.codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&e.sendEncodingParameters[0].rtx&&delete e.sendEncodingParameters[0].rtx,a+=o(e,u,"answer",e.stream,r._dtlsRole),e.rtcpParameters&&e.rtcpParameters.reducedSize&&(a+="a=rtcp-rsize\r\n")}}));var u=new e.RTCSessionDescription({type:"answer",sdp:a});return Promise.resolve(u)},d.prototype.addIceCandidate=function(e){var t,r=this;return e&&void 0===e.sdpMLineIndex&&!e.sdpMid?Promise.reject(new TypeError("sdpMLineIndex or sdpMid required")):new Promise((function(o,i){if(!r._remoteDescription)return i(c("InvalidStateError","Can not add ICE candidate without a remote description"));if(e&&""!==e.candidate){var a=e.sdpMLineIndex;if(e.sdpMid)for(var u=0;u0?n.parseCandidate(e.candidate):{};if("tcp"===f.protocol&&(0===f.port||9===f.port))return o();if(f.component&&1!==f.component)return o();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,f))return i(c("OperationError","Can not add ICE candidate"));var p=e.candidate.trim();0===p.indexOf("a=")&&(p=p.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(f.type?p:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l921600?l.ENUM_VP_LEVEL.hdp:i>230400?l.ENUM_VP_LEVEL.hd:l.ENUM_VP_LEVEL.sd}var s=function(e){n.streamWorker.removeLocalStream(),c(e)};n.send("publish",{user_id:n.user.user_id,media_type:e.publishConfig.mediaType,audio:e.publishConfig.audio,video:e.publishConfig.video,data:e.publishConfig.data,vp:r,payload:e.videoCodec},a,s).catch(s)})).catch(c)},e.prototype.onPublish=function(e,t,r){var n=this,o=e.stream_id,i=e.media_type;d.default.debug("onPublish ",o,i),this.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.publish,{streamId:o,stype:l.ENUM_STREAM_TYPE.publish,mtype:i}),this.publishId=o;var a=function(e){d.default.debug("rollback publish ",e),n.publishId="",r(e),n.send("unpublish",{user_id:n.user.user_id,stream_id:o,media_type:i},(function(){d.default.debug("rollback publish success"),n.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:o,stype:l.ENUM_STREAM_TYPE.publish,mtype:i})}),(function(e){d.default.error("rollback publish - ",e)})).catch((function(e){d.default.error("rollback publish - ",e)}))},c=this.streamWorker.getLocalStream();if(c)this.mediaStream=c.getMediaStream(),t(this.stream),c.connect(o).then((function(e){n.sdpPublish(o,e,(function(){}),a)})).catch(a);else{a("cannot find local stream")}},e.prototype.unpublish=function(e,t){var r=this,n="",o=this.getLocalStream();if(!o)return n="you have not published",d.default.error("unpublish - ",n),void t(n);switch(this.publishStatus){case l.ENUM_PUBLISH_STATUS.unpublish:return n="you have not published",d.default.error("unpublish - ",n),void t(n);case l.ENUM_PUBLISH_STATUS.publishing:return n="you are publishing",d.default.error("unpublish - ",n),void t(n);case l.ENUM_PUBLISH_STATUS.unpublishing:return n="you are unpublishing",d.default.error("unpublish - ",n),void t(n);case l.ENUM_PUBLISH_STATUS.published:}this.publishStatus=l.ENUM_PUBLISH_STATUS.unpublishing;var i=Object.assign({},o),a=function(e){d.default.error("unpublish ",e),r.publishStatus=l.ENUM_PUBLISH_STATUS.published,t(e)};if(this.streamWorker.getLocalStream())this.send("unpublish",{user_id:i.uid,stream_id:i.sid,media_type:i.media_type},(function(){d.default.debug("unpublish success "),i.pubStatus=r.publishStatus=l.ENUM_PUBLISH_STATUS.unpublish,i.mediaStream=void 0,e(h.convertToOuterStream(i))}),a).catch(a);else{a("cannot find local stream")}},e.prototype.onUnpublish=function(e,t,r){d.default.debug("onUnpublish ",e);var n=this.streamWorker.getLocalStream(),o=this.getLocalStream();if(o&&n)this.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unpublish,{streamId:o.sid,stype:l.ENUM_STREAM_TYPE.publish,mtype:n.publishConfig.mediaType}),this.streamWorker.removeLocalStream(this.publishId),this.mediaStream=void 0,this.publishId="",t();else{r("cannot find local stream")}},e.prototype.subscribe=function(e,t,r){var n=this,o="";if(!this.isJoinedRoom)return o="you have not joined the room",d.default.error("subscribe - ",o),void r(o);var i=this.streams.find((function(t){return t.sid===e}));if(d.default.debug("subscribe - ",e,i),!i)return o="cannot find the stream",d.default.error("subscribe - ",o),void r(o);switch(i.subStatus){case l.ENUM_SUBSCRIBE_STATUS.subscribing:return o="you are subscribing",d.default.error("subscribe - ",o),void r(o);case l.ENUM_SUBSCRIBE_STATUS.unsubscribing:return o="you are unsubscribing",d.default.error("subscribe - ",o),void r(o);case l.ENUM_SUBSCRIBE_STATUS.subscribed:return o="you have already subscribed",d.default.error("subscribe - ",o),void r(o);case l.ENUM_SUBSCRIBE_STATUS.unsubscribe:}i.subStatus=l.ENUM_SUBSCRIBE_STATUS.subscribing;var a=function(e){d.default.debug("subscribe success "),t(h.convertToOuterStream(e))},c=function(e){d.default.error("subscribe ",e),i.subStatus=l.ENUM_SUBSCRIBE_STATUS.unsubscribe,n.logReporter.reportExceptionLog(s.ENUM_LOG_EXCEPTION_TYPE.subscribe,{userId:i.uid,streamId:i.sid,stype:l.ENUM_STREAM_TYPE.subscribe,mtype:i.media_type}),r(e)};this.streamWorker.createRemoteStream(i.uid,i.sid,i.media_type).then((function(e){d.default.debug("createRemoteStream ",e);var t=function(e){n.streamWorker.removeRemoteStream(i.sid),c(e)};n.send("subscribe",{src:{user_id:n.user.user_id,audio:i.audio,video:i.video,data:i.data},dst:{user_id:i.uid,stream_id:i.sid,media_type:i.media_type}},a,t).catch(t)})).catch(c)},e.prototype.onSubscribe=function(e,t,r){var n=this,o=e.streamsub_id,i=e.stream_id,a=e.media_type,c=e.user_id;d.default.debug("onSubscribe ",o,i,a,c);var u=this.streams.find((function(e){return e.sid===i}));if(!u){var f="cannot find stream in local cache";return d.default.error("onSubscribe - ",f),void r(f)}this.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.subscribe,{streamId:u.sid,userId:u.uid,stype:l.ENUM_STREAM_TYPE.subscribe,mtype:u.media_type}),u.streamsub_id=o;var p=function(e){d.default.debug("subscribe rollback ",e),u.streamsub_id=void 0,r(e),n.send("unsubscribe",{src:{user_id:n.user.user_id,streamsub_id:o},dst:{user_id:u.uid,stream_id:u.sid,media_type:u.media_type}},(function(){d.default.debug("subscribe rollback success"),n.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:u.sid,userId:u.uid,stype:l.ENUM_STREAM_TYPE.subscribe,mtype:u.media_type})}),(function(e){d.default.error("subscribe rollback - ",e)})).catch((function(e){d.default.error("subscribe rollback - ",e)}))},h=this.streamWorker.getRemoteStream(u.sid);h?(u.mediaStream=h.getMediaStream(),t(u),h.connect(o,u.audio,u.video).then((function(e){n.sdpSubscribe(u.sid,e,(function(){}),p)})).catch(p)):p(f="cannot find remote stream")},e.prototype.unsubscribe=function(e,t,r){var n="",o=this.streams.find((function(t){return t.sid===e}));if(d.default.debug("unsubscribe ",e,o),!o)return n="cannot find the stream",d.default.error("unsubscribe - ",n),void r(n);switch(o.subStatus){case l.ENUM_SUBSCRIBE_STATUS.subscribing:return n="you are subscribing",d.default.error("unsubscribe - ",n),void r(n);case l.ENUM_SUBSCRIBE_STATUS.unsubscribing:return n="you are unsubscribing",d.default.error("unsubscribe - ",n),void r(n);case l.ENUM_SUBSCRIBE_STATUS.unsubscribe:return n="you have not subscribed",d.default.error("unsubscribe - ",n),void r(n);case l.ENUM_SUBSCRIBE_STATUS.subscribed:}o.subStatus=l.ENUM_SUBSCRIBE_STATUS.unsubscribing;var i=function(e){d.default.error("unsubscribe ",e),o.subStatus=l.ENUM_SUBSCRIBE_STATUS.subscribed,r(e)};if(this.streamWorker.getRemoteStream(o.sid))this.send("unsubscribe",{src:{user_id:this.user.user_id,streamsub_id:o.streamsub_id},dst:{user_id:o.uid,stream_id:o.sid,media_type:o.media_type}},(function(e){d.default.debug("unsubscribe success"),e.subStatus=l.ENUM_SUBSCRIBE_STATUS.unsubscribe,e.mediaStream=void 0,t(h.convertToOuterStream(e))}),i).catch(i);else{i("cannot find remote stream")}},e.prototype.onUnsubscribe=function(e,t,r){var n=e.user_id,o=e.media_type,i=this.streams.find((function(e){return e.uid===n}));if(d.default.debug("onUnsubscribe ",n,o,i),!i&&this.isJoinedRoom){var a="cannot find stream in local cache";return d.default.error("onUnsubscribe ",a),void r(a)}if(i){this.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unsubscribe,{streamId:i.sid,userId:i.uid,stype:l.ENUM_STREAM_TYPE.subscribe,mtype:i.media_type});try{this.streamWorker.removeRemoteStream(i.sid),i.streamsub_id=void 0,i.mediaStream=void 0,t()}catch(a){d.default.error("unsubscribe - ",a),r(a)}}},e.prototype.sdpPublish=function(e,t,r,n){d.default.debug("sdpPublish ",t);var o=function(e){d.default.error("sdpPublish - ",e),n(e)},i=this.streamWorker.getLocalStream(e);if(i)this.send("sdp",{src:{user_id:this.user.user_id,stream_id:i.streamId,media_type:i.publishConfig.mediaType,stream_type:l.ENUM_STREAM_TYPE.publish},sdp:{type:"offer",sdpcontent:t.sdp}},(function(){d.default.debug("sdpPublish"),r()}),o).catch(o);else{o("cannot find local stream")}},e.prototype.onSdpPublish=function(e,t,r){var n=this;d.default.debug("onSdpPublish ",e);var o=e.stream_id,i=e.sdp,a=function(e){d.default.error("onSdpPublish - ",e),r(e)},s=this.streamWorker.getLocalStream(o);if(s)s.answer(i).then((function(){d.default.debug("sdpPublish"),n.publishStatus=l.ENUM_PUBLISH_STATUS.published,t()})).catch(a);else{a("cannot find local stream")}},e.prototype.sdpSubscribe=function(e,t,r,n){d.default.debug("sdpSubscribe ",e,t);var o=this.streams.find((function(t){return t.sid===e}));if(!o){var i="cannot find stream in local cache";return d.default.error("sdpSubscribe - ",i),void n(i)}var a=function(e){d.default.error("sdpSubscribe - ",e),n(e)};this.streamWorker.getRemoteStream(o.sid)?this.send("sdp",{src:{user_id:this.user.user_id,stream_id:o.streamsub_id,media_type:o.media_type,stream_type:l.ENUM_STREAM_TYPE.subscribe},sdp:{type:"offer",sdpcontent:t.sdp}},(function(){d.default.debug("sdpSubscribe"),r()}),a).catch(a):a(i="cannot find remote stream")},e.prototype.onSdpSubscribe=function(e,t,r){d.default.debug("onSdpSubscribe ",e);var n=e.stream_id,o=e.sdp,i=this.streams.find((function(e){return e.streamsub_id===n}));if(!i){var a="cannot find stream in local cache";return d.default.error("onSdpSubscribe - ",a),void r(a)}var s=function(e){d.default.error("onSdpSubscribe - ",e),r(e)},c=this.streamWorker.getRemoteStream(i.sid);c?c.answer(o).then((function(){d.default.debug("sdpPublish"),i.subStatus=l.ENUM_SUBSCRIBE_STATUS.subscribed,t()})).catch(s):s(a="cannot find remote stream")},e.prototype.muteVideo=function(e){var t=this,r=this.getStream(e),n=this.streamWorker.getStream(e);if(!r||!n){return d.default.error("muteVideo - ","cannot find stream"),!1}if(r.mutevideo=!0,r.stream_type===l.ENUM_STREAM_TYPE.publish){this.send("mute",{user_id:r.uid,stream_id:r.sid,stream_type:r.stream_type,track_type:l.ENUM_TRACK_TYPE.video,mute:r.mutevideo},(function(){t.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.muteVideo,{streamId:r.sid,userId:r.uid,stype:r.stream_type,mtype:r.media_type})}),(function(){n.unmuteVideo(),r.mutevideo=!1}))}return n.muteVideo()},e.prototype.unmuteVideo=function(e){var t=this,r=this.getStream(e),n=this.streamWorker.getStream(e);if(!r||!n){return d.default.error("unmuteVideo - ","cannot find stream"),!1}if(r.mutevideo=!1,r.stream_type===l.ENUM_STREAM_TYPE.publish){this.send("mute",{user_id:r.uid,stream_id:r.sid,stream_type:r.stream_type,track_type:l.ENUM_TRACK_TYPE.video,mute:r.mutevideo},(function(){t.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unmuteVideo,{streamId:r.sid,userId:r.uid,stype:r.stream_type,mtype:r.media_type})}),(function(){n.muteVideo(),r.mutevideo=!0}))}return n.unmuteVideo()},e.prototype.muteAudio=function(e){var t=this,r=this.getStream(e),n=this.streamWorker.getStream(e);if(!r||!n){return d.default.error("muteAudio - ","cannot find stream"),!1}if(r.muteaudio=!0,r.stream_type===l.ENUM_STREAM_TYPE.publish){this.send("mute",{user_id:r.uid,stream_id:r.sid,stream_type:r.stream_type,track_type:l.ENUM_TRACK_TYPE.audio,mute:r.muteaudio},(function(){t.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.muteAudio,{streamId:r.sid,userId:r.uid,stype:r.stream_type,mtype:r.media_type})}),(function(){n.unmuteAudio(),r.muteaudio=!1}))}return n.muteAudio()},e.prototype.unmuteAudio=function(e){var t=this,r=this.getStream(e),n=this.streamWorker.getStream(e);if(!r||!n){return d.default.error("unmuteAudio - ","cannot find stream"),!1}if(r.muteaudio=!1,r.stream_type===l.ENUM_STREAM_TYPE.publish){this.send("mute",{user_id:r.uid,stream_id:r.sid,stream_type:r.stream_type,track_type:l.ENUM_TRACK_TYPE.audio,mute:r.muteaudio},(function(){t.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.unmuteAudio,{streamId:r.sid,userId:r.uid,stype:r.stream_type,mtype:r.media_type})}),(function(){n.muteAudio(),r.muteaudio=!0}))}return n.unmuteAudio()},e.prototype.muteData=function(){},e.prototype.unmuteData=function(){},e.prototype.startRecording=function(e,t,r){var n=this,o="";if(!this.isPublished)return o="you have not published",d.default.error("startRecording - ",o),void r(o);var i,a=this.getLocalStream(),c=this.streamWorker.getLocalStream();if(!a||!c){var u="cannot find stream";return d.default.error("startRecording - ",u),void r(u)}switch(this.recordStatus){case l.ENUM_RECORD_STATUS.starting:return o="local stream record is starting",d.default.error("startRecording - ",o),void r(o);case l.ENUM_RECORD_STATUS.stopping:return o="local stream record is stopping",d.default.error("startRecording - ",o),void r(o);case l.ENUM_RECORD_STATUS.recording:return o="local stream is recording",d.default.error("startRecording - ",o),void r(o);case l.ENUM_RECORD_STATUS.unrecord:}var f=c.publishConfig;if(f.audio&&f.video)i=l.ENUM_RECORD_MIME.audioVideo;else if(f.audio&&f.screen)i=l.ENUM_RECORD_MIME.audioVideo;else if(f.audio)i=l.ENUM_RECORD_MIME.audio;else if(f.video)i=l.ENUM_RECORD_MIME.video;else{if(!f.screen)return o="stream config is incorrect",d.default.error(o),void r(o);i=l.ENUM_RECORD_MIME.video}var p=this.streamWorker.getResolution().video,h=p.width,m=p.height;this.recordStatus=l.ENUM_RECORD_STATUS.starting;var v=function(e){d.default.error("startRecording ",e),n.recordStatus=l.ENUM_RECORD_STATUS.unrecord,r(e)};this.send("startrecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id,config:{mimetype:i,mainviewuid:this.session.user_id,mainviewtype:f.mediaType,width:h,height:m,watermarkpos:e.waterMarkPos,watertype:e.waterMarkType,waterurl:e.waterMarkRemarks,wtemplate:e.waterMarkTemplate,isaverage:e.isAverage,bucket:e.bucket,region:e.region}},(function(e){d.default.debug("startRecording success",e),n.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.startRecord,{recordId:e.RecordId,stype:l.ENUM_STREAM_TYPE.publish,mtype:f.mediaType}),n.recordStatus=l.ENUM_RECORD_STATUS.recording,t({FileName:e.FileName,RecordId:e.RecordId})}),v).catch(v)},e.prototype.onStartRecord=function(e,t){d.default.debug("onStartRecord ",e);var r=e.RecordId,n=e.FileName;this.recordId=r,t({RecordId:r,FileName:n})},e.prototype.stopRecording=function(e,t){var r=this,n="",o=this.getLocalStream(),i=this.streamWorker.getLocalStream();if(!o||!i)return n="cannot find stream",d.default.error("stopRecording - ",n),void t(n);switch(this.recordStatus){case l.ENUM_RECORD_STATUS.starting:return n="local stream record is starting",d.default.error("stopRecording - ",n),void t(n);case l.ENUM_RECORD_STATUS.stopping:return n="local stream record is stopping",d.default.error("stopRecording - ",n),void t(n);case l.ENUM_RECORD_STATUS.unrecord:return n="local stream isnot recording",d.default.error("stopRecording - ",n),void t(n);case l.ENUM_RECORD_STATUS.recording:}this.recordStatus=l.ENUM_RECORD_STATUS.stopping;var a=this.recordId,c=function(e){d.default.error("stopRecording - ",e),r.recordStatus=l.ENUM_RECORD_STATUS.recording,t(e)};this.send("stoprecord",{room_id:this.session.room_id,app_id:this.session.app_id,user_id:this.session.user_id},(function(){d.default.debug("stopRecording success"),r.logReporter.reportOperationLog(s.ENUM_LOG_OPERATION_TYPE.stopRecord,{recordId:a,stype:l.ENUM_STREAM_TYPE.publish,mtype:i.publishConfig.mediaType}),r.recordStatus=l.ENUM_RECORD_STATUS.unrecord,e()}),c).catch(c)},e.prototype.onStopRecord=function(e,t){d.default.debug("onStopRecord ",e),this.recordId="",t()},e.prototype.setVideoProfile=function(e,t,r){this.streamWorker.setVideoProfile(e).then((function(e){t(e)})).catch((function(e){r(e)}))},e.prototype.switchDevice=function(e,t,r,n){var o=this.streamWorker.getLocalStream();if(o)switch(e){case"audio":o.switchMicrophone(t,r,n);break;case"video":o.switchCamera(t,r,n)}else{n("cannot find local stream")}},e.prototype.getAudioVolume=function(e){var t=this.streamWorker.getStream(e);return t?t.getAudioVolume():0},e.prototype.getStats=function(e,t,r){var n=this.streamWorker.getStream(e);if(n)n.getStats(t,r);else{var o="cannot find stream";d.default.error("getStats - ",o),r(o)}},e.prototype.preloadEffect=function(e,t,r){this.streamWorker.preloadEffect(e,t,r)},e.prototype.unloadEffect=function(e){this.streamWorker.unloadEffect(e)},e.prototype.playEffect=function(e,t,r){this.streamWorker.playEffect(e,t,r)},e.prototype.pauseEffect=function(e,t,r){this.streamWorker.pauseEffect(e,t,r)},e.prototype.resumeEffect=function(e,t,r){this.streamWorker.resumeEffect(e,t,r)},e.prototype.stopEffect=function(e,t,r){this.streamWorker.stopEffect(e,t,r)},e.prototype.setEffectVolume=function(e,t,r,n){this.streamWorker.setEffectVolume(e,t,r,n)},e.prototype.onError=function(e){d.default.error("onError "+e.method,e.msg)},e.prototype.onUserJoin=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;if(d.default.debug("onUserJoin ",t,r,n),!this.users.find((function(e){return e.user_id===t}))){var o={user_id:t};this.users.push(o),this._emitter.emit("user-added",h.convertToOuterUser(o))}},e.prototype.onUserLeave=function(e){var t=e.user_id,r=e.cmdtype,n=e.reason;d.default.debug("onUserLeave ",t,r,n),this.onRemoveStream({user_id:t});var o=this.users.findIndex((function(e){return e.user_id===t}));if(o>=0){var i=this.users[o];this.users.splice(o,1),this._emitter.emit("user-removed",h.convertToOuterUser(i))}},e.prototype.onAddStream=function(e){var t=e.user_id,r=e.cmdtype,n=e.stream;d.default.debug("onAddStream ",t,r,n);var o=Object.assign({uid:t},n,{stream_type:l.ENUM_STREAM_TYPE.subscribe,subStatus:l.ENUM_SUBSCRIBE_STATUS.unsubscribe});this.streams.push(o),this._emitter.emit("stream-added",h.convertToOuterStream(o))},e.prototype.onRemoveStream=function(e){var t=e.user_id,r=e.stream;d.default.debug("onRemoveStream ",t,r);var n=r||this.streams.find((function(e){return e.uid===t}));if(n){var o=this.streams.findIndex((function(e){return e.sid===n.sid}));if(o>=0){var i=this.streams.splice(o,1)[0];(i.streamsub_id||i.mediaStream)&&(this.streamWorker.removeRemoteStream(i.sid),i.streamsub_id=void 0,i.mediaStream=void 0),this._emitter.emit("stream-removed",h.convertToOuterStream(i))}}else{d.default.warn("onRemoveStream ","cannot find stream in local cache")}},e.prototype.onTransportClose=function(e){var t=e.user_id,r=e.stream;d.default.debug("onTransportClose ",t,r),t===this.user.user_id||this.onRemoveStream({user_id:t,stream:r})},e.prototype.onTransportTimeout=function(e){d.default.debug("onTransportTimeout",e)},e.prototype.onAudioTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;d.default.debug("onAudioTrackst ",t,r,n,o,i);var a=this.streams.find((function(e){return e.sid===r}));if(a){a.muteaudio=n;var s=h.convertToOuterStream(a);n?this._emitter.emit("mute-audio",s):this._emitter.emit("unmute-audio",s)}else{d.default.error("onAudioTrackst ","cannot find stream in local cache")}},e.prototype.onVideoTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;d.default.debug("onVideoTrackst ",t,r,n,o,i);var a=this.streams.find((function(e){return e.sid===r}));if(a){a.mutevideo=n;var s=h.convertToOuterStream(a);n?this._emitter.emit("mute-video",s):this._emitter.emit("unmute-video",s)}else{d.default.error("onVideoTrackst ","cannot find stream in local cache")}},e.prototype.onDataTrackst=function(e){var t=e.user_id,r=e.stream_id,n=e.mute,o=e.track_type,i=e.media_type;d.default.debug("onDataTrackst ",t,r,n,o,i);var a=this.streams.find((function(e){return e.sid===r}));if(a)n?this._emitter.emit("mute-data",a):this._emitter.emit("unmute-data",a);else{d.default.error("onDataTrackst ","cannot find stream in local cache")}},e.prototype.onKickoff=function(e){d.default.debug("onKickoff",e)},e.prototype.onMediaStreamPublished=function(e){var t=e.mediaStream;this.mediaStream=t,this.stream&&this._emitter.emit("stream-published",h.convertToOuterStream(this.stream))},e.prototype.onMediaStreamSubscribed=function(e){var t=e.streamId,r=e.mediaStream,n=this.streams.find((function(e){return e.sid===t}));n&&(n.mediaStream=r,this._emitter.emit("stream-subscribed",h.convertToOuterStream(n)))},e.prototype.onScreenMediaStreamEnded=function(e){d.default.debug("screen media stream ended ",e),this.isPublished&&this.unpublish((function(e){d.default.debug("screen media stream ended ",e)}),(function(e){d.default.debug("screen media stream ended ",e)}))},e}();t.SessionWorker=v},function(e,t,r){"use strict";var n=r(0),o=r(12),i=r(35),a=r(19);function s(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var c=s(r(15));c.Axios=i,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(20),c.CancelToken=r(47),c.isCancel=r(14),c.all=function(e){return Promise.all(e)},c.spread=r(48),e.exports=c,e.exports.default=c},function(e,t){ /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh * @license MIT */ e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";var n=r(0),o=r(13),i=r(36),a=r(37),s=r(19);function c(e){this.defaults=e,this.interceptors={request:new i,response:new i}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=s(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,o){return this.request(n.merge(o||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(0);function o(){this.handlers=[]}o.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,r){"use strict";var n=r(0),o=r(38),i=r(14),a=r(15),s=r(45),c=r(46);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!s(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=o(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return u(e),t.data=o(t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(18);e.exports=function(e,t,r){var o=r.config.validateStatus;!o||o(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,r){"use strict";var n=r(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,a={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(a[t]&&o.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,a){var s=[];s.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),n.isString(o)&&s.push("path="+o),n.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(20);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){var n=r(50)("jsonp");e.exports=function(e,t,r){"function"==typeof t&&(r=t,t={});t||(t={});var a,s,c=t.prefix||"__jp",u=t.name||c+o++,d=t.param||"callback",f=null!=t.timeout?t.timeout:6e4,p=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;f&&(s=setTimeout((function(){h(),r&&r(new Error("Timeout"))}),f));function h(){a.parentNode&&a.parentNode.removeChild(a),window[u]=i,s&&clearTimeout(s)}return window[u]=function(e){n("jsonp got",e),h(),r&&r(null,e)},e=(e+=(~e.indexOf("?")?"&":"?")+d+"="+p(u)).replace("?&","?"),n('jsonp req "%s"',e),(a=document.createElement("script")).src=e,l.parentNode.insertBefore(a,l),function(){window[u]&&h()}};var o=0;function i(){}},function(e,t,r){(function(n){function o(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(51)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var o=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))})),e.splice(i,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=o,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(o())}).call(this,r(16))},function(e,t,r){var n;function o(e){function r(){if(r.enabled){var e=r,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;for(var a=new Array(arguments.length),s=0;s0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*a;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*o;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?s(c=e,i,"day")||s(c,o,"hour")||s(c,n,"minute")||s(c,r,"second")||c+" ms":function(e){if(e>=i)return Math.round(e/i)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";e.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},function(e,t,r){"use strict";var n,o=Object.prototype.hasOwnProperty;function i(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}t.stringify=function(e,t){t=t||"";var r,i,a=[];for(i in"string"!=typeof t&&(t="?"),e)if(o.call(e,i)){if((r=e[i])||null!==r&&r!==n&&!isNaN(r)||(r=""),i=encodeURIComponent(i),r=encodeURIComponent(r),null===i||null===r)continue;a.push(i+"="+r)}return a.length?t+a.join("&"):""},t.parse=function(e){for(var t,r=/([^=?&]+)=?([^&]*)/g,n={};t=r.exec(e);){var o=i(t[1]),a=i(t[2]);null===o||null===a||o in n||(n[o]=a)}return n}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(56),o=r(1),i=function(){function e(e){this.readyState=n.w3cwebsocket.CLOSED,null!=e&&(this.url=e)}return e.prototype.connect=function(e){var t=this;return o.default.debug("Socket connect ",e),new Promise((function(r,i){try{t._websocket=new n.w3cwebsocket(e||t.url)}catch(e){return o.default.debug("Socket create error ",e),i(new Event("Create Socket Error"))}t.readyState=n.w3cwebsocket.CONNECTING,t._websocket.onopen=function(){t.readyState=n.w3cwebsocket.OPEN,r("opened"),t.onopen("opened"),t._websocket&&(t._websocket.onclose=function(){t.readyState=n.w3cwebsocket.CLOSED,t.onclose("closed"),t._websocket=null},t._websocket.onmessage=function(e){t.onmessage(e)},t._websocket.onerror=function(e){o.default.debug("Socket onerror ",e),t._websocket&&(t.readyState=t._websocket.readyState),t.onerror(e)})}}))},e.prototype.onopen=function(e){},e.prototype.onmessage=function(e){},e.prototype.onclose=function(e){},e.prototype.onerror=function(e){},e.prototype.send=function(e){var t=this;return new Promise((function(r,n){t._websocket?(t._websocket.send(e),r()):n("No Socket Connection")}))},e.prototype.close=function(e,t){var r=this;return void 0===e&&(e=1e3),new Promise((function(n,o){r._websocket?(r._websocket.close(e,t),n()):o("No Socket Connection")}))},Object.defineProperty(e.prototype,"isOpened",{get:function(){return this.readyState===n.w3cwebsocket.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isClosed",{get:function(){return this.readyState===n.w3cwebsocket.CLOSED},enumerable:!0,configurable:!0}),e}();t.SocketWorker=i},function(e,t,r){(function(t){var n=function(){return this||void 0===t?this:t}(),o=n.WebSocket||n.MozWebSocket,i=r(57);function a(e,t){return t?new o(e,t):new o(e)}o&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(e){Object.defineProperty(a,e,{get:function(){return o[e]}})})),e.exports={w3cwebsocket:o?a:null,version:i}}).call(this,r(6))},function(e,t,r){e.exports=r(58).version},function(e){e.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo (http://dev.sipdoc.net)"],"version":"1.0.30","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0"}')},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,o=r(22),i=r(11),a=r(1),s=i.default.create({responseType:"arraybuffer"}),c=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext;!function(e){e[e.init=1]="init",e[e.play=2]="play",e[e.pause=3]="pause"}(n||(n={}));var u=function(e){this.state=n.init,this.startedAt=-1,this.pausedAt=-1,this.config=e},d=function(){};t.CachedAudioBuffer=d;var f=function(){function e(e){if(this.effects=new Map,this.mediaStream=e.clone(),this.audioContext=new c,this.audioContext){this.sourceNode=this.audioContext.createMediaStreamSource(this.mediaStream),this.destinationNode=this.audioContext.createMediaStreamDestination(),this.sourceNode.connect(this.destinationNode);var t=this.audioContext.createMediaStreamSource(this.destinationNode.stream);this.analyser=this.audioContext.createAnalyser(),this.timeDomainData=new Uint8Array(this.analyser.frequencyBinCount),t.connect(this.analyser)}else a.default.error("cannot create audioContext")}return Object.defineProperty(e.prototype,"srcAudioTrack",{get:function(){return this.mediaStream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dstAudioTrack",{get:function(){return this.destinationNode.stream.getAudioTracks()[0]},enumerable:!0,configurable:!0}),e.prototype.destroy=function(){this.effects.forEach((function(e){e.bufferSourceNode.stop()})),this.audioContext&&this.audioContext.close()},e.prototype.getVolume=function(){var e=0;return this.analyser&&(this.analyser.getByteTimeDomainData(this.timeDomainData),this.timeDomainData.forEach((function(t){e=Math.max(e,Math.abs(t-128))}))),e/128},e.loadAudioBuffer=function(e,t,r){var n=new c;return new Promise((function(o,i){if(!n){var c="cannot create audioContext";return a.default.error("loadAudioBuffer - ",c),void i(c)}if(e[t]){c="the effect Id already exists";return a.default.error("loadAudioBuffer - ",c),void i(c)}s.get(r).then((function(i){n.decodeAudioData(i.data).then((function(n){e[t]={filePath:r,audioBuffer:n},o(n)}))})).catch((function(e){i(e)}))}))},e.unloadAudioBuffer=function(e,t){delete e[t]},e.prototype.createAudioBufferSource=function(t,r){var i=this;return new Promise((function(s,c){return o.__awaiter(i,void 0,void 0,(function(){var i,d,f,p,l,h,m=this;return o.__generator(this,(function(o){switch(o.label){case 0:if(i=this.effects[r.effectId])switch(h=void 0,i.state){case n.pause:break;case n.play:return[2,c(h="the effect is playing")];case n.init:default:return[2,c(h="the effect is initing")]}return t[r.effectId]?(p=t[r.effectId],r.filePath&&r.filePath!==p.filePath?(h="wrong effectId or filepath, the effect "+r.effectId+" cached filepath is "+p.filePath,[2,c(h)]):(d=p.audioBuffer,i=new u(Object.assign({loop:!1,playTime:0},r,{filePath:p.filePath})),[3,7])):[3,1];case 1:if(!r.filePath)return[3,6];o.label=2;case 2:return o.trys.push([2,4,,5]),[4,e.loadAudioBuffer(t,r.effectId,r.filePath)];case 3:return d=o.sent(),i=new u(Object.assign({loop:!1,playTime:0},r,{filePath:r.filePath})),[3,5];case 4:return l=o.sent(),a.default.error("createAudioBufferSource - ",l),[2,c(l)];case 5:return[3,7];case 6:return h="cannot find effect and no filepath in options to create new one",a.default.error("createAudioBufferSource - ",h),[2,c(h)];case 7:try{i.bufferSourceNode=f=this.audioContext.createBufferSource(),i.bufferSourceNode.buffer=d,i.gainNode=this.audioContext.createGain(),i.bufferSourceNode.connect(i.gainNode),i.gainNode.connect(this.destinationNode),i.bufferSourceNode.loop=i.config.loop,this.effects[i.config.effectId]=i,i.bufferSourceNode.addEventListener("ended",(function(){i.state!==n.pause&&delete m.effects[i.config.effectId]}),{once:!0}),i.config.replace&&this.sourceNode.disconnect(this.destinationNode),i.bufferSourceNode.start(0,i.config.playTime%d.duration),i.startedAt=Date.now(),i.state=n.play}catch(e){return a.default.error("createAudioBufferSource - ",e),[2,c(e)]}return s(f),[2]}}))}))}))},e.prototype.removeAudioBufferSource=function(e){var t=this;return new Promise((function(r,o){var i=t.effects[e];if(i){switch(i.state){case n.pause:delete t.effects[e];break;case n.play:i.bufferSourceNode.stop();break;case n.init:default:return o("the effect is initing")}r()}else{o("cannot find effect "+e)}}))},e.prototype.setGainNodeVolume=function(e,t){var r=this;return new Promise((function(o,i){var a=r.effects[e];if(a){switch(a.state){case n.play:return a.gainNode.gain.value=t/100,o();case n.pause:return i("the effect is paused");case n.init:default:return i("the effect is initing")}}else{i("cannot find effect "+e)}}))},e.prototype.pauseEffect=function(e){var t=this;return new Promise((function(r,o){var i=t.effects[e];if(!i)return o("cannot find effect "+e);switch(i.state){case n.play:return i.state=n.pause,i.bufferSourceNode.stop(),i.pausedAt=Date.now(),r();case n.pause:return o("the effect is paused");case n.init:default:return o("the effect is initing")}}))},e.prototype.resumeEffect=function(e,t){var r=this;return new Promise((function(o,i){var a=r.effects[t];if(!a)return i("cannot find effect "+t);switch(a.state){case n.play:return i("the effect is playing");case n.pause:var s=Object.assign({},a.config,{playTime:a.config.playTime+(a.pausedAt-a.startedAt)/1e3});r.createAudioBufferSource(e,s).then(o).catch(i);break;case n.init:default:return i("the effect is initing")}}))},e}();t.AudioHelper=f},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),o=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var o=e.getVersionPrecision(t),i=e.getVersionPrecision(r),a=Math.max(o,i),s=0,c=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(o,i)),a-=1;a>=s;){if(c[0][a]>c[1][a])return 1;if(c[0][a]===c[1][a]){if(a===s)return 0;a-=1}else if(c[0][a]0){var a=Object.keys(r),s=a.find((function(e){return t.isOS(e)}));if(s){var c=this.satisfies(r[s]);if(void 0!==c)return c}var u=a.find((function(e){return t.isPlatform(e)}));if(u){var d=this.satisfies(r[u]);if(void 0!==d)return d}}if(i>0){var f=Object.keys(o).find((function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(o[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),o=s.default.getBrowserTypeByAlias(n);return t&&o&&(n=o.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,o=this.getBrowserVersion();if("string"==typeof o)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(o,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e){return this.isBrowser(e)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=u,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=o.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=o.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=o.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=o.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=o.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=o.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=o.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=o.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=o.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=o.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=o.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=o.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=o.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=o.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=o.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=o.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=o.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=o.default.getFirstMatch(i,e)||o.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=o.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=o.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=o.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=o.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=o.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=o.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=o.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=o.default.getFirstMatch(i,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:o.default.getFirstMatch(t,e),version:o.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=o.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:i.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=o.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.WindowsPhone,version:t}}},{test:[/windows/i],describe:function(e){var t=o.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=o.default.getWindowsVersionName(t);return{name:i.OS_MAP.Windows,version:t,versionName:r}}},{test:[/macintosh/i],describe:function(e){var t=o.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=o.default.getMacOSVersionName(t),n={name:i.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=o.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:i.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=o.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=o.default.getAndroidVersionName(t),n={name:i.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=o.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:i.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=o.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||o.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||o.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:i.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=o.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=o.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:i.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:i.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=o.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:i.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=o.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:i.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:i.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=o.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:i.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:i.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:i.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:i.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,o=(n=r(17))&&n.__esModule?n:{default:n},i=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:i.ENGINE_MAP.Blink};var t=o.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:i.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:i.ENGINE_MAP.Trident},r=o.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:i.ENGINE_MAP.Presto},r=o.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:i.ENGINE_MAP.Gecko},r=o.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:i.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:i.ENGINE_MAP.WebKit},r=o.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatTime=function(e,t){void 0===t&&(t="YYYY/MM/DD HH:mm:ss");var r={"M+":e.getMonth()+1,"D+":e.getDate(),"H+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};for(var n in/(y+)/i.test(t)&&(t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return t}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(){this.bytesReceived=0,this.jitter=0,this.packetsLost=0,this.packetsReceived=0,this.audioLevel=0},o=function(){this.bytesReceived=0,this.packetsLost=0,this.packetsReceived=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesDecoded=0,this.frameHeight=0,this.frameWidth=0,this.framesDropped=0,this.framesReceived=0},i=function(){this.bytesSent=0,this.packetsSent=0,this.retransmittedBytesSent=0,this.retransmittedPacketsSent=0,this.audioLevel=0},a=function(){this.bytesSent=0,this.packetsSent=0,this.firCount=0,this.nackCount=0,this.pliCount=0,this.framesEncoded=0,this.frameHeight=0,this.frameWidth=0,this.framesSent=0},s=function(){this.availableIncomingBitrate=0,this.availableOutgoingBitrate=0,this.bytesReceived=0,this.bytesSent=0,this.currentRoundTripTime=0,this.totalRoundTripTime=0},c=function(){this.ip="",this.port=0,this.networkType="",this.protocol="udp"},u=function(){this.ip="",this.port=0,this.protocol="udp"},d=function(){this.bytesReceived=0,this.bytesSent=0,this.dtlsState=""},f=function(){this.inAudioReport=new n,this.inVideoReport=new o,this.outAudioReport=new i,this.outVideoReport=new a,this.candidatePairReport=new s,this.localCandidateReport=new c,this.remoteCandidateReport=new u,this.transportReport=new d,this.timestamp=Date.now(),this.original=[]};t.StatsReports=f},function(module,exports,__webpack_require__){(function(global){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;!function(e,t){module.exports=t(e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==global?global:this,(function(global){"use strict";global=global||{};var _Base64=global.Base64,version="2.5.1",buffer;if(module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var t={},r=0,n=e.length;r>>6)+fromCharCode(128|63&t):fromCharCode(224|t>>>12&15)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|t>>>18&7)+fromCharCode(128|t>>>12&63)+fromCharCode(128|t>>>6&63)+fromCharCode(128|63&t)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var t=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(r>>>18),b64chars.charAt(r>>>12&63),t>=2?"=":b64chars.charAt(r>>>6&63),t>=1?"=":b64chars.charAt(63&r)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e)).toString("base64")}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e)).toString("base64")}:function(e){return btoa(utob(e))},encode=function(e,t){return t?_encode(String(e)).replace(/[+\/]/g,(function(e){return"+"==e?"-":"_"})).replace(/=/g,""):_encode(String(e))},encodeURI=function(e){return encode(e,!0)},re_btou=new RegExp(["[À-ß][€-¿]","[à-ï][€-¿]{2}","[ð-÷][€-¿]{3}"].join("|"),"g"),cb_btou=function(e){switch(e.length){case 4:var t=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(t>>>10))+fromCharCode(56320+(1023&t));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var t=e.length,r=t%4,n=(t>0?b64tab[e.charAt(0)]<<18:0)|(t>1?b64tab[e.charAt(1)]<<12:0)|(t>2?b64tab[e.charAt(2)]<<6:0)|(t>3?b64tab[e.charAt(3)]:0),o=[fromCharCode(n>>>16),fromCharCode(n>>>8&255),fromCharCode(255&n)];return o.length-=[0,0,2,1][r],o.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,(function(e){return"-"==e?"+":"/"})).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum((function(){return decode(this)}))),Object.defineProperty(String.prototype,"toBase64",noEnum((function(e){return encode(this,e)}))),Object.defineProperty(String.prototype,"toBase64URI",noEnum((function(){return encode(this,!0)})))}}return global.Meteor&&(Base64=global.Base64),module.exports?module.exports.Base64=global.Base64:(__WEBPACK_AMD_DEFINE_ARRAY__=[],__WEBPACK_AMD_DEFINE_RESULT__=function(){return global.Base64}.apply(exports,__WEBPACK_AMD_DEFINE_ARRAY__),void 0===__WEBPACK_AMD_DEFINE_RESULT__||(module.exports=__WEBPACK_AMD_DEFINE_RESULT__)),{Base64:global.Base64}}))}).call(this,__webpack_require__(6))},function(e,t,r){"use strict";var n;!function(o){function i(e,t,r){var n,o,i,a,l,h,m,v,g,b=0,y=[],S=0,_=!1,R=[],E=[],T=!1,w=!1,C=-1;if(n=(r=r||{}).encoding||"UTF8",(g=r.numRounds||1)!==parseInt(g,10)||1>g)throw Error("numRounds must a integer >= 1");if("SHA-1"===e)l=512,h=j,m=B,a=160,v=function(e){return e.slice()};else if(0===e.lastIndexOf("SHA-",0))if(h=function(t,r){return F(t,r,e)},m=function(t,r,n,o){var i,a;if("SHA-224"===e||"SHA-256"===e)i=15+(r+65>>>9<<4),a=16;else{if("SHA-384"!==e&&"SHA-512"!==e)throw Error("Unexpected error in SHA-2 implementation");i=31+(r+129>>>10<<5),a=32}for(;t.length<=i;)t.push(0);for(t[r>>>5]|=128<<24-r%32,r+=n,t[i]=4294967295&r,t[i-1]=r/4294967296|0,n=t.length,r=0;rt;t+=1)r[t]=e[t].slice();return r},C=1,"SHA3-224"===e)l=1152,a=224;else if("SHA3-256"===e)l=1088,a=256;else if("SHA3-384"===e)l=832,a=384;else if("SHA3-512"===e)l=576,a=512;else if("SHAKE128"===e)l=1344,a=-1,P=31,w=!0;else{if("SHAKE256"!==e)throw Error("Chosen SHA variant is not supported");l=1088,a=-1,P=31,w=!0}m=function(e,t,r,n,o){var i,a=P,s=[],c=(r=l)>>>5,u=0,d=t>>>5;for(i=0;i=r;i+=c)n=V(e.slice(i,i+c),n),t-=r;for(e=e.slice(i),t%=r;e.length>>3)>>2]^=a<=o));)s.push(e.a),0==64*(u+=1)%r&&V(null,n);return s}}i=p(t,n,C),o=D(e),this.setHMACKey=function(t,r,i){var s;if(!0===_)throw Error("HMAC key already set");if(!0===T)throw Error("Cannot set HMAC key after calling update");if(!0===w)throw Error("SHAKE is not supported for HMAC");if(t=(r=p(r,n=(i||{}).encoding||"UTF8",C)(t)).binLen,r=r.value,i=(s=l>>>3)/4-1,st/8){for(;r.length<=i;)r.push(0);r[i]&=4294967040}for(t=0;t<=i;t+=1)R[t]=909522486^r[t],E[t]=1549556828^r[t];o=h(R,o),b=l,_=!0},this.update=function(e){var t,r,n,a=0,s=l>>>5;for(e=(t=i(e,y,S)).binLen,r=t.value,t=e>>>5,n=0;n>>5),S=e%l,T=!0},this.getHash=function(t,r){var n,i,p,l;if(!0===_)throw Error("Cannot call getHash after setting HMAC key");if(p=f(r),!0===w){if(-1===p.shakeLen)throw Error("shakeLen must be specified in options");a=p.shakeLen}switch(t){case"HEX":n=function(e){return s(e,a,C,p)};break;case"B64":n=function(e){return c(e,a,C,p)};break;case"BYTES":n=function(e){return u(e,a,C)};break;case"ARRAYBUFFER":try{i=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,C)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=m(y.slice(),S,b,v(o),a),i=1;i>>24-a%32),l=m(l,a,0,D(e),a);return n(l)},this.getHMAC=function(t,r){var n,i,p,g;if(!1===_)throw Error("Cannot call getHMAC without first setting HMAC key");switch(p=f(r),t){case"HEX":n=function(e){return s(e,a,C,p)};break;case"B64":n=function(e){return c(e,a,C,p)};break;case"BYTES":n=function(e){return u(e,a,C)};break;case"ARRAYBUFFER":try{n=new ArrayBuffer(0)}catch(e){throw Error("ARRAYBUFFER not supported by this environment")}n=function(e){return d(e,a,C)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return i=m(y.slice(),S,b,v(o),a),g=h(E,D(e)),n(g=m(i,a,l,g,a))}}function a(e,t){this.a=e,this.b=t}function s(e,t,r,n){var o,i,a,s="";for(t/=8,a=-1===r?3:0,o=0;o>>2]>>>8*(a+o%4*r),s+="0123456789abcdef".charAt(i>>>4&15)+"0123456789abcdef".charAt(15&i);return n.outputUpper?s.toUpperCase():s}function c(e,t,r,n){var o,i,a,s,c="",u=t/8;for(s=-1===r?3:0,o=0;o>>2]:0,a=o+2>>2]:0,a=(e[o>>>2]>>>8*(s+o%4*r)&255)<<16|(i>>>8*(s+(o+1)%4*r)&255)<<8|a>>>8*(s+(o+2)%4*r)&255,i=0;4>i;i+=1)c+=8*o+6*i<=t?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6*(3-i)&63):n.b64Pad;return c}function u(e,t,r){var n,o,i,a="";for(t/=8,i=-1===r?3:0,n=0;n>>2]>>>8*(i+n%4*r)&255,a+=String.fromCharCode(o);return a}function d(e,t,r){t/=8;var n,o,i,a=new ArrayBuffer(t);for(i=new Uint8Array(a),o=-1===r?3:0,n=0;n>>2]>>>8*(o+n%4*r)&255;return a}function f(e){var t={outputUpper:!1,b64Pad:"=",shakeLen:-1};if(e=e||{},t.outputUpper=e.outputUpper||!1,!0===e.hasOwnProperty("b64Pad")&&(t.b64Pad=e.b64Pad),!0===e.hasOwnProperty("shakeLen")){if(0!=e.shakeLen%8)throw Error("shakeLen must be a multiple of 8");t.shakeLen=e.shakeLen}if("boolean"!=typeof t.outputUpper)throw Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw Error("Invalid b64Pad formatting option");return t}function p(e,t,r){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":e=function(e,t,n){var o,i,a,s,c,u,d=e.length;if(0!=d%2)throw Error("String of HEX type must be in byte increments");for(t=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0,o=0;o>>1)+c)>>>2;t.length<=a;)t.push(0);t[a]|=i<<8*(u+s%4*r)}return{value:t,binLen:4*d+n}};break;case"TEXT":e=function(e,n,o){var i,a,s,c,u,d,f,p,l=0;if(n=n||[0],u=(o=o||0)>>>3,"UTF8"===t)for(p=-1===r?3:0,s=0;s(i=e.charCodeAt(s))?a.push(i):2048>i?(a.push(192|i>>>6),a.push(128|63&i)):55296>i||57344<=i?a.push(224|i>>>12,128|i>>>6&63,128|63&i):(s+=1,i=65536+((1023&i)<<10|1023&e.charCodeAt(s)),a.push(240|i>>>18,128|i>>>12&63,128|i>>>6&63,128|63&i)),c=0;c>>2;n.length<=d;)n.push(0);n[d]|=a[c]<<8*(p+f%4*r),l+=1}else if("UTF16BE"===t||"UTF16LE"===t)for(p=-1===r?2:0,a="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,s=0;s>>8),d=(f=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=i<<8*(p+f%4*r),l+=2}return{value:n,binLen:8*l+o}};break;case"B64":e=function(e,t,n){var o,i,a,s,c,u,d,f,p=0;if(-1===e.search(/^[a-zA-Z0-9=+\/]+$/))throw Error("Invalid character in base-64 string");if(i=e.indexOf("="),e=e.replace(/\=/g,""),-1!==i&&ie===t))throw new DOMException("The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.","NotSupportedError");const o=this.getSenders().find(e=>e.track===t);if(o)throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const i=this._streams[r.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const n=new e.MediaStream([t]);this._streams[r.id]=n,this._reverseStreams[n.id]=r,this.addStream(n)}return this.getSenders().find(e=>e.track===t)},["createOffer","createAnswer"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){const e=arguments;return arguments.length&&"function"==typeof arguments[0]?r.apply(this,[t=>{const r=i(this,t);e[0].apply(null,[r])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):r.apply(this,arguments).then(e=>i(this,e))}};e.RTCPeerConnection.prototype[t]=n[t]}));const s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return arguments.length&&arguments[0].type?(arguments[0]=a(this,arguments[0]),s.apply(this,arguments)):s.apply(this,arguments)};const c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(e.RTCPeerConnection.prototype,"localDescription",{get(){const e=c.get.apply(this);return""===e.type?e:i(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if("closed"===this.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!e._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(e._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");let t;this._streams=this._streams||{},Object.keys(this._streams).forEach(r=>{this._streams[r].getTracks().find(t=>e.track===t)&&(t=this._streams[r])}),t&&(1===t.getTracks().length?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event("negotiationneeded")))}}function A(e){const t=v(e);if(!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),!e.RTCPeerConnection)return;t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]}));const r=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?t.version<78&&arguments[0]&&""===arguments[0].candidate?Promise.resolve():r.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}function O(e){f(e,"negotiationneeded",e=>{if("stable"===e.target.signalingState)return e})}var N=r(28),I=r.n(N);function U(e){const t=e&&e.navigator,r=t.mediaDevices.getUserMedia.bind(t.mediaDevices);t.mediaDevices.getUserMedia=function(e){return r(e).catch(e=>Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString(){return this.name}}}(e)))}}function x(e){"getDisplayMedia"in e.navigator&&e.navigator.mediaDevices&&(e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||(e.navigator.mediaDevices.getDisplayMedia=e.navigator.getDisplayMedia.bind(e.navigator)))}function L(e){const t=v(e);if(e.RTCIceGatherer&&(e.RTCIceCandidate||(e.RTCIceCandidate=function(e){return e}),e.RTCSessionDescription||(e.RTCSessionDescription=function(e){return e}),t.version<15025)){const t=Object.getOwnPropertyDescriptor(e.MediaStreamTrack.prototype,"enabled");Object.defineProperty(e.MediaStreamTrack.prototype,"enabled",{set(e){t.set.call(this,e);const r=new Event("enabled");r.enabled=e,this.dispatchEvent(r)}})}!e.RTCRtpSender||"dtmf"in e.RTCRtpSender.prototype||Object.defineProperty(e.RTCRtpSender.prototype,"dtmf",{get(){return void 0===this._dtmf&&("audio"===this.track.kind?this._dtmf=new e.RTCDtmfSender(this):"video"===this.track.kind&&(this._dtmf=null)),this._dtmf}}),e.RTCDtmfSender&&!e.RTCDTMFSender&&(e.RTCDTMFSender=e.RTCDtmfSender);const r=I()(e,t.version);e.RTCPeerConnection=function(e){return e&&e.iceServers&&(e.iceServers=function(e,t){let r=!1;return(e=JSON.parse(JSON.stringify(e))).filter(e=>{if(e&&(e.urls||e.url)){var t=e.urls||e.url;e.url&&!e.urls&&m("RTCIceServer.url","RTCIceServer.urls");const n="string"==typeof t;return n&&(t=[t]),t=t.filter(e=>{if(0===e.indexOf("stun:"))return!1;const t=e.startsWith("turn")&&!e.startsWith("turn:[")&&e.includes("transport=udp");return t&&!r?(r=!0,!0):t&&!r}),delete e.url,e.urls=n?t[0]:t,!!t.length}})}(e.iceServers,t.version),h("ICE servers after filtering:",e.iceServers)),new r(e)},e.RTCPeerConnection.prototype=r.prototype}function D(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function j(e){const t=v(e),r=e&&e.navigator,n=e&&e.MediaStreamTrack;if(r.getUserMedia=function(e,t,n){m("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),r.mediaDevices.getUserMedia(e).then(t,n)},!(t.version>55&&"autoGainControl"in r.mediaDevices.getSupportedConstraints())){const e=function(e,t,r){t in e&&!(r in e)&&(e[r]=e[t],delete e[t])},t=r.mediaDevices.getUserMedia.bind(r.mediaDevices);if(r.mediaDevices.getUserMedia=function(r){return"object"==typeof r&&"object"==typeof r.audio&&(r=JSON.parse(JSON.stringify(r)),e(r.audio,"autoGainControl","mozAutoGainControl"),e(r.audio,"noiseSuppression","mozNoiseSuppression")),t(r)},n&&n.prototype.getSettings){const t=n.prototype.getSettings;n.prototype.getSettings=function(){const r=t.apply(this,arguments);return e(r,"mozAutoGainControl","autoGainControl"),e(r,"mozNoiseSuppression","noiseSuppression"),r}}if(n&&n.prototype.applyConstraints){const t=n.prototype.applyConstraints;n.prototype.applyConstraints=function(r){return"audio"===this.kind&&"object"==typeof r&&(r=JSON.parse(JSON.stringify(r)),e(r,"autoGainControl","mozAutoGainControl"),e(r,"noiseSuppression","mozNoiseSuppression")),t.apply(this,[r])}}}}function B(e,t){e.navigator.mediaDevices&&"getDisplayMedia"in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(r){if(!r||!r.video){const e=new DOMException("getDisplayMedia without video constraints is undefined");return e.name="NotFoundError",e.code=8,Promise.reject(e)}return!0===r.video?r.video={mediaSource:t}:r.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(r)})}function F(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function V(e){const t=v(e);if("object"!=typeof e||!e.RTCPeerConnection&&!e.mozRTCPeerConnection)return;if(!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach((function(t){const r=e.RTCPeerConnection.prototype[t],n={[t](){return arguments[0]=new("addIceCandidate"===t?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=n[t]})),t.version<68){const t=e.RTCPeerConnection.prototype.addIceCandidate;e.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?arguments[0]&&""===arguments[0].candidate?Promise.resolve():t.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}const r={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){const[e,o,i]=arguments;return n.apply(this,[e||null]).then(e=>{if(t.version<53&&!o)try{e.forEach(e=>{e.type=r[e.type]||e.type})}catch(t){if("TypeError"!==t.name)throw t;e.forEach((t,n)=>{e.set(n,Object.assign({},t,{type:r[t.type]||t.type}))})}return e}).then(o,i)}}function W(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpSender.prototype)return;const t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});const r=e.RTCPeerConnection.prototype.addTrack;r&&(e.RTCPeerConnection.prototype.addTrack=function(){const e=r.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function H(e){if("object"!=typeof e||!e.RTCPeerConnection||!e.RTCRtpSender)return;if(e.RTCRtpSender&&"getStats"in e.RTCRtpReceiver.prototype)return;const t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){const e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),f(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function G(e){!e.RTCPeerConnection||"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){m("removeStream","removeTrack"),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Y(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function z(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];const e=arguments[1],r=e&&"sendEncodings"in e;r&&e.sendEncodings.forEach(e=>{if("rid"in e){if(!/^[a-z0-9]{0,16}$/i.test(e.rid))throw new TypeError("Invalid RID value provided.")}if("scaleResolutionDownBy"in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in e&&!(parseFloat(e.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const n=t.apply(this,arguments);if(r){const{sender:t}=n,r=t.getParameters();"encodings"in r||(r.encodings=e.sendEncodings,this.setParametersPromises.push(t.setParameters(r).catch(()=>{})))}return n})}function q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function J(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function K(e){if("object"==typeof e&&e.RTCPeerConnection){if("getLocalStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in e.RTCPeerConnection.prototype)){const t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||(this._localStreams=[]),this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(r=>t.call(this,r,e)),e.getVideoTracks().forEach(r=>t.call(this,r,e))},e.RTCPeerConnection.prototype.addTrack=function(e){const r=arguments[1];return r&&(this._localStreams?this._localStreams.includes(r)||this._localStreams.push(r):this._localStreams=[r]),t.apply(this,arguments)}}"removeStream"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||(this._localStreams=[]);const t=this._localStreams.indexOf(e);if(-1===t)return;this._localStreams.splice(t,1);const r=e.getTracks();this.getSenders().forEach(e=>{r.includes(e.track)&&this.removeTrack(e)})})}}function X(e){if("object"==typeof e&&e.RTCPeerConnection&&("getRemoteStreams"in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(e))return;this._remoteStreams.push(e);const t=new Event("addstream");t.stream=e,this.dispatchEvent(t)})})}});const t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){const e=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||(e._remoteStreams=[]),e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);const r=new Event("addstream");r.stream=t,e.dispatchEvent(r)})}),t.apply(e,arguments)}}}function Q(e){if("object"!=typeof e||!e.RTCPeerConnection)return;const t=e.RTCPeerConnection.prototype,r=t.createOffer,n=t.createAnswer,o=t.setLocalDescription,i=t.setRemoteDescription,a=t.addIceCandidate;t.createOffer=function(e,t){const n=arguments.length>=2?arguments[2]:arguments[0],o=r.apply(this,[n]);return t?(o.then(e,t),Promise.resolve()):o},t.createAnswer=function(e,t){const r=arguments.length>=2?arguments[2]:arguments[0],o=n.apply(this,[r]);return t?(o.then(e,t),Promise.resolve()):o};let s=function(e,t,r){const n=o.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n};t.setLocalDescription=s,s=function(e,t,r){const n=i.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.setRemoteDescription=s,s=function(e,t,r){const n=a.apply(this,[e]);return r?(n.then(t,r),Promise.resolve()):n},t.addIceCandidate=s}function Z(e){const t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){const e=t.mediaDevices,r=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>r($(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function $(e){return e&&void 0!==e.video?Object.assign({},e,{video:b(e.video)}):e}function ee(e){const t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,r){if(e&&e.iceServers){const t=[];for(let r=0;rt.generateCertificate})}function te(e){"object"==typeof e&&e.RTCTrackEvent&&"receiver"in e.RTCTrackEvent.prototype&&!("transceiver"in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function re(e){const t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){void 0!==e.offerToReceiveAudio&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);const t=this.getTransceivers().find(e=>"audio"===e.receiver.track.kind);!1===e.offerToReceiveAudio&&t?"sendrecv"===t.direction?t.setDirection?t.setDirection("sendonly"):t.direction="sendonly":"recvonly"===t.direction&&(t.setDirection?t.setDirection("inactive"):t.direction="inactive"):!0!==e.offerToReceiveAudio||t||this.addTransceiver("audio"),void 0!==e.offerToReceiveVideo&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);const r=this.getTransceivers().find(e=>"video"===e.receiver.track.kind);!1===e.offerToReceiveVideo&&r?"sendrecv"===r.direction?r.setDirection?r.setDirection("sendonly"):r.direction="sendonly":"recvonly"===r.direction&&(r.setDirection?r.setDirection("inactive"):r.direction="inactive"):!0!==e.offerToReceiveVideo||r||this.addTransceiver("video")}return t.apply(this,arguments)}}var ne=r(2),oe=r.n(ne);function ie(e){if(!e.RTCIceCandidate||e.RTCIceCandidate&&"foundation"in e.RTCIceCandidate.prototype)return;const t=e.RTCIceCandidate;e.RTCIceCandidate=function(e){if("object"==typeof e&&e.candidate&&0===e.candidate.indexOf("a=")&&((e=JSON.parse(JSON.stringify(e))).candidate=e.candidate.substr(2)),e.candidate&&e.candidate.length){const r=new t(e),n=oe.a.parseCandidate(e.candidate),o=Object.assign(r,n);return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new t(e)},e.RTCIceCandidate.prototype=t.prototype,f(e,"icecandidate",t=>(t.candidate&&Object.defineProperty(t,"candidate",{value:new e.RTCIceCandidate(t.candidate),writable:"false"}),t))}function ae(e){if(!e.RTCPeerConnection)return;const t=v(e);"sctp"in e.RTCPeerConnection.prototype||Object.defineProperty(e.RTCPeerConnection.prototype,"sctp",{get(){return void 0===this._sctp?null:this._sctp}});const r=function(e){if(!e||!e.sdp)return!1;const t=oe.a.splitSections(e.sdp);return t.shift(),t.some(e=>{const t=oe.a.parseMLine(e);return t&&"application"===t.kind&&-1!==t.protocol.indexOf("SCTP")})},n=function(e){const t=e.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(null===t||t.length<2)return-1;const r=parseInt(t[1],10);return r!=r?-1:r},o=function(e){let r=65536;return"firefox"===t.browser&&(r=t.version<57?-1===e?16384:2147483637:t.version<60?57===t.version?65535:65536:2147483637),r},i=function(e,r){let n=65536;"firefox"===t.browser&&57===t.version&&(n=65535);const o=oe.a.matchPrefix(e.sdp,"a=max-message-size:");return o.length>0?n=parseInt(o[0].substr(19),10):"firefox"===t.browser&&-1!==r&&(n=2147483637),n},a=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,"chrome"===t.browser&&t.version>=76){const{sdpSemantics:e}=this.getConfiguration();"plan-b"===e&&Object.defineProperty(this,"sctp",{get(){return void 0===this._sctp?null:this._sctp},enumerable:!0,configurable:!0})}if(r(arguments[0])){const e=n(arguments[0]),t=o(e),r=i(arguments[0],e);let a;a=0===t&&0===r?Number.POSITIVE_INFINITY:0===t||0===r?Math.max(t,r):Math.min(t,r);const s={};Object.defineProperty(s,"maxMessageSize",{get:()=>a}),this._sctp=s}return a.apply(this,arguments)}}function se(e){if(!(e.RTCPeerConnection&&"createDataChannel"in e.RTCPeerConnection.prototype))return;function t(e,t){const r=e.send;e.send=function(){const n=arguments[0],o=n.length||n.size||n.byteLength;if("open"===e.readyState&&t.sctp&&o>t.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+t.sctp.maxMessageSize+" bytes)");return r.apply(e,arguments)}}const r=e.RTCPeerConnection.prototype.createDataChannel;e.RTCPeerConnection.prototype.createDataChannel=function(){const e=r.apply(this,arguments);return t(e,this),e},f(e,"datachannel",e=>(t(e.channel,e.target),e))}function ce(e){if(!e.RTCPeerConnection||"connectionState"in e.RTCPeerConnection.prototype)return;const t=e.RTCPeerConnection.prototype;Object.defineProperty(t,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(t,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(e){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),e&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=e)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(e=>{const r=t[e];t[e]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=e=>{const t=e.target;if(t._lastConnectionState!==t.connectionState){t._lastConnectionState=t.connectionState;const r=new Event("connectionstatechange",e);t.dispatchEvent(r)}return e},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function ue(e){if(!e.RTCPeerConnection)return;const t=v(e);if("chrome"===t.browser&&t.version>=71)return;const r=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(e){return e&&e.sdp&&-1!==e.sdp.indexOf("\na=extmap-allow-mixed")&&(e.sdp=e.sdp.split("\n").filter(e=>"a=extmap-allow-mixed"!==e.trim()).join("\n")),r.apply(this,arguments)}}const de=function({window:e}={},t={shimChrome:!0,shimFirefox:!0,shimEdge:!0,shimSafari:!0}){const r=h,c=v(e),u={browserDetails:c,commonShim:s,extractVersion:d,disableLog:p,disableWarnings:l};switch(c.browser){case"chrome":if(!n||!A||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;r("adapter.js shimming chrome."),u.browserShim=n,_(e),E(e),A(e),T(e),M(e),w(e),C(e),P(e),O(e),ie(e),ce(e),ae(e),se(e),ue(e);break;case"firefox":if(!i||!V||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=i,j(e),V(e),F(e),G(e),W(e),H(e),Y(e),z(e),q(e),J(e),ie(e),ce(e),ae(e),se(e);break;case"edge":if(!o||!L||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=o,U(e),x(e),L(e),D(e),ae(e),se(e);break;case"safari":if(!a||!t.shimSafari)return r("Safari shim is not included in this adapter release."),u;r("adapter.js shimming safari."),u.browserShim=a,ee(e),re(e),Q(e),K(e),X(e),te(e),Z(e),ie(e),ae(e),se(e),ue(e);break;default:r("Unsupported browser!")}return u}({window:window});t.default=de}])}));