!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=26)}([function(e,t,r){"use strict";var n=r(11),o=r(32),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 p(){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)t.SERVER_CONFIG[r]=e[r]||t.SERVER_CONFIG[r]}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(57);r(66);var o=r(4),i=r(21),a=r(1),s=r(58),c=r(22),u=r(3),d=r(61);t.getDevices=function(e,t){navigator.mediaDevices.enumerateDevices().then((function(t){a.default.debug("GetDevices: ",t),e(t)})).catch((function(e){t(e)}))};var p={offerToReceiveAudio:!0,offerToReceiveVideo:!0},f=function(){function e(e,t,r){this.resolution=i.getResolution(""),this.isSubscriber=!1,this.currentStatsReports=new d.StatsReports,this.streamId=e,this.mediaType=t,this.emitter=r,this.mediaStream=new MediaStream,this.peerConnection=new RTCPeerConnection;var n=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":n.startUploadStats();break;case"disconnected":a.default.warn("peerconnection disconnected"),n.stopUploadStats();break;case"failed":a.default.warn("peerconnection failed"),n.stopUploadStats();break;case"closed":n.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":n.emitter.emit("stream-connected",n),n.startUploadStats();break;case"disconnected":a.default.warn("peerconnection disconnected"),n.stopUploadStats();break;case"failed":a.default.warn("peerconnection failed"),n.stopUploadStats();break;case"closed":n.stopUploadStats()}}))}return e.prototype.setResolution=function(e){this.resolution=e},e.prototype.answer=function(e){return n.__awaiter(this,void 0,void 0,(function(){var t,r,o,i;return n.__generator(this,(function(n){switch(n.label){case 0:a.default.debug("stream worker answer: ",e),t=this.resolution.attributes,r=(r=e.sdpcontent.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+t.maxVideoBW+"\r\n")).replace(/a=mid:1\r\n/g,"a=mid:1\r\nb=AS:"+t.maxVideoBW+"\r\n"),o=new RTCSessionDescription({type:e.type,sdp:r}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.peerConnection.setRemoteDescription(o)];case 2:return n.sent(),[3,4];case 3:return i=n.sent(),a.default.error("stream "+this.streamId+" answer error: ",i),[3,4];case 4:return[2]}}))}))},e.prototype.getStream=function(){return this.mediaStream},e.prototype.getId=function(){return this.mediaStream.id},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.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.framesEncoded=e.framesEncoded||i.inVideoReport.framesEncoded,i.inVideoReport.totalDecodeTime=e.totalDecodeTime||i.inVideoReport.totalDecodeTime),"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&&"audio"===e.kind&&(i.inAudioReport.audioLevel=e.audioLevel||i.inAudioReport.audioLevel),"track"===e.type&&"video"===e.kind&&(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),"media-source"===e.type&&"audio"===e.kind&&(i.outAudioReport.audioLevel=e.audioLevel||i.outAudioReport.audioLevel),"media-source"===e.type&&"video"===e.kind&&(i.outVideoReport.height=e.height||i.outVideoReport.height,i.outVideoReport.width=e.width||i.outVideoReport.width,i.outVideoReport.framesPerSecond=e.framesPerSecond||i.outVideoReport.framesPerSecond),"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){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),a.lostpre=Math.floor(u/(c+u)/i),a.vol=Math.floor(100*(o.inAudioReport.audioLevel||0))}else{var d=o.outAudioReport.bytesSent-n.outAudioReport.bytesSent,p=o.outAudioReport.packetsSent-n.outAudioReport.packetsSent;u=o.outAudioReport.retransmittedPacketsSent-n.outAudioReport.retransmittedPacketsSent;a.br=Math.floor(8*d/i),a.lostpre=Math.floor(u/(p+u)/i),a.vol=Math.floor(100*(o.outAudioReport.audioLevel||0))}var f={br:-1,lostpre:-1,frt:-1,w:-1,h:-1,mime:r.videoCodec};if(r.isSubscriber){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;f.br=Math.floor(8*s/i),f.lostpre=Math.floor(u/(c+u)/i),f.frt=Math.floor(l/i),f.w=o.inVideoReport.frameWidth,f.h=o.inVideoReport.frameHeight}else{d=o.outVideoReport.bytesSent-n.outVideoReport.bytesSent,p=o.outVideoReport.packetsSent-n.outVideoReport.packetsSent,u=o.outVideoReport.nackCount-n.outVideoReport.nackCount;f.br=Math.floor(8*d/i),f.lostpre=Math.floor(u/(p+u)/i),f.frt=o.outVideoReport.framesPerSecond,f.w=o.outVideoReport.width,f.h=o.outVideoReport.height}var h={rtt:-1,delay:-1};r.isSubscriber?h.delay=Math.floor(1e3*o.candidatePairReport.currentRoundTripTime):h.rtt=Math.floor(1e3*o.candidatePairReport.currentRoundTripTime),e({audio:a,video:f,connection:h})}),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}(),l=function(e){function t(t,r,n){var o=e.call(this,t,r,n)||this;return o.peerConnection.addEventListener("track",(function(e){a.default.debug("local - track event ",e)})),o}return n.__extends(t,e),t.prototype.setVideoProfile=function(e){var t=this.getVideoTrack();return null===t?Promise.reject("no video track found"):t.applyConstraints(e.video)},t.prototype.connect=function(e,t,r){return n.__awaiter(this,void 0,void 0,(function(){var o,i,u,d,f,l,h=this;return n.__generator(this,(function(n){switch(n.label){case 0:if(o={audio:!1,video:!1},e.audio&&e.microphoneId?o.audio={deviceId:e.microphoneId}:e.audio&&(o.audio=!0),i=this.resolution.video,e.video&&e.cameraId?o.video={deviceId:e.cameraId,width:i.width,height:i.height,frameRate:i.frameRate}:e.video&&(o.video={width:i.width,height:i.height,frameRate:i.frameRate}),!o.audio&&!o.video)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,navigator.mediaDevices.getUserMedia(o)];case 2:return n.sent().getTracks().forEach((function(e){a.default.debug("local stream - add track ",e),h.mediaStream.addTrack(e),h.peerConnection.addTrack(e,h.mediaStream),"audio"!==e.kind||h.audioHelper||(h.audioHelper=new s.AudioHelper(h.mediaStream))})),[3,4];case 3:return u=n.sent(),a.default.error("local stream - get user media ",u),o.audio&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getMicrophones),o.video&&this.logReporter.reportExceptionLog(c.ENUM_LOG_EXCEPTION_TYPE.getCameras),r(u),[2];case 4:e.screen,n.label=5;case 5:return n.trys.push([5,8,,9]),[4,this.peerConnection.createOffer(p)];case 6:return d=n.sent(),f=this.resolution.attributes,d.sdp&&(d.sdp=d.sdp.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+f.maxVideoBW+"\r\n"),d.sdp=d.sdp.replace(/a=mid:1\r\n/g,"a=mid:1\r\nb=AS:"+f.maxVideoBW+"\r\n")),[4,this.peerConnection.setLocalDescription(d)];case 7:return n.sent(),t(d),[3,9];case 8:return l=n.sent(),a.default.error("local stream - peer connection error ",l),r(l),[3,9];case 9:return[2]}}))}))},t.prototype.switchMicrophone=function(e,t,r){return n.__awaiter(this,void 0,void 0,(function(){var o,i,s,c=this;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,navigator.mediaDevices.getUserMedia({audio:{deviceId:e}})];case 1:return o=n.sent(),i=o.getAudioTracks()[0],this.mediaStream.getAudioTracks().forEach((function(e){c.peerConnection.getSenders().forEach((function(t){t.track&&t.track.id===e.id&&(a.default.debug("local stream - replace audio track ",i,e),t.replaceTrack(i),c.mediaStream.removeTrack(e),c.mediaStream.addTrack(i),e.stop())}))})),t(),[3,3];case 2:return s=n.sent(),a.default.error("local stream - get microphone ",s),r(s),[3,3];case 3: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=this;return n.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),o=this.resolution.video,i={video:{deviceId:e,width:o.width,height:o.height,frameRate:o.frameRate}},[4,navigator.mediaDevices.getUserMedia(i)];case 1:return s=n.sent(),c=s.getVideoTracks()[0],this.mediaStream.getVideoTracks().forEach((function(e){d.peerConnection.getSenders().forEach((function(t){t.track&&t.track.id===e.id&&(a.default.debug("local stream - replace video track ",c,e),t.replaceTrack(c),d.mediaStream.removeTrack(e),d.mediaStream.addTrack(c),e.stop())}))})),t(),[3,3];case 2:return u=n.sent(),a.default.error("local stream - get camera ",u),r(u),[3,3];case 3:return[2]}}))}))},t}(f),h=function(e){function t(t,r,n,o){var i=e.call(this,t,r,o)||this,c=i;return i.streamSubId=n,i.isSubscriber=!0,i.peerConnection.addEventListener("track",(function(e){a.default.debug("remote - track event ",e),c.mediaStream.addTrack(e.track),"audio"!==e.track.kind||c.audioHelper||(c.audioHelper=new s.AudioHelper(c.mediaStream))})),i}return n.__extends(t,e),t.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(p)];case 1:return r=n.sent(),o=this.resolution.attributes,r.sdp&&(r.sdp=r.sdp.replace(/a=mid:video\r\n/g,"a=mid:video\r\nb=AS:"+o.maxVideoBW+"\r\n"),r.sdp=r.sdp.replace(/a=mid:1\r\n/g,"a=mid:1\r\nb=AS:"+o.maxVideoBW+"\r\n")),[4,this.peerConnection.setLocalDescription(r)];case 2:return n.sent(),e(r),[3,4];case 3:return i=n.sent(),a.default.error("remote stream "+this.streamId+" - peer connection error ",i),t(i),[3,4];case 4:return[2]}}))}))},t}(f),m=function(){function e(e,t){var r=this;this.publishConfig={audio:!0,video:!0,screen:!1,mediaType:u.ENUM_MEDIA_TYPE.camera,data:!1},this.localStreams=[],this.remoteStreams=[],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()})}))}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;this.publishConfig.audio=t,this.publishConfig.video=r,this.publishConfig.screen=n,o&&(this.publishConfig.microphoneId=o),i&&(this.publishConfig.cameraId=i),n&&(this.publishConfig.mediaType=u.ENUM_MEDIA_TYPE.desktop),r&&(this.publishConfig.mediaType=u.ENUM_MEDIA_TYPE.camera)},e.prototype.getPublishConfig=function(){return Object.assign({},this.publishConfig)},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,r,n,o){var i=this;a.default.debug("create local stream ",t);var s=this.getLocalStream(t);if(s)a.default.debug("create local stream ",s);else{var c=new l(t,r,this.innerEmitter);c.userId=e,c.audioCodec=this.audioCodec,c.videoCodec=this.videoCodec,c.logReporter=this._logReporter,c.setResolution(this.currentResolution),c.connect(this.publishConfig,(function(e){i.localStreams.push(c),n(e)}),o)}},e.prototype.removeLocalStream=function(e,t,r){try{var n=this.getLocalStream(e);if(n){var o=this.localStreams.indexOf(n);this.localStreams.splice(o,1),n.close()}t()}catch(e){a.default.error("removeLocalStream ",e),r(e)}},e.prototype.createRemoteStream=function(e,t,r,n){var o=this,i=t.stream_id,s=t.streamsub_id;a.default.debug("create remote stream ",i,s);var c=this.getRemoteStream(i);if(c)a.default.debug("create remote stream ",c);else{var u=new h(i,t.media_type,s,this.innerEmitter);u.userId=e,u.audioCodec=this.audioCodec,u.videoCodec=this.videoCodec,u.logReporter=this._logReporter,u.setResolution(this.currentResolution),u.connect((function(e){o.remoteStreams.push(u),r(u.streamId,e)}),n)}},e.prototype.removeRemoteStream=function(e,t,r){try{var n=this.getRemoteStream(e);if(n){var o=this.remoteStreams.indexOf(n);this.remoteStreams.splice(o,1),n.close()}t()}catch(e){a.default.error("removeRemoteStream ",e),r(e)}},e.prototype.answer=function(e,t){var r=this.getStream(e);r&&r.answer(t)},e.prototype.getMediaStream=function(e){var t=this.getStream(e);return t?t.getMediaStream():new MediaStream},e.prototype.setVideoProfile=function(e){this.currentResolution=i.getResolution(e);var t=this.getLocalStream();return t?(t.setResolution(this.currentResolution),t.setVideoProfile(this.currentResolution)):Promise.resolve()},e.prototype.muteVideo=function(e){var t=this.getStream(e);return!!t&&t.muteVideo()},e.prototype.unmuteVideo=function(e){var t=this.getStream(e);return!!t&&t.unmuteVideo()},e.prototype.muteAudio=function(e){var t=this.getStream(e);return!!t&&t.muteAudio()},e.prototype.unmuteAudio=function(e){var t=this.getStream(e);return!!t&&t.unmuteAudio()},e.prototype.getAudioVolume=function(e){var t=this.getStream(e);return t?t.getAudioVolume():0},e.prototype.getStats=function(e,t,r){var n=this.getStream(e);n&&n.getStats(t,r)},e.prototype.switchMicrophone=function(e,t,r){var n=this.getLocalStream("");if(n)n.switchMicrophone(e,t,r);else{var o="local media stream cannot find";a.default.error("switchMicrophone ",o),r(o)}},e.prototype.switchCamera=function(e,t,r){var n=this.getLocalStream("");if(n)n.switchCamera(e,t,r);else{var o="local media stream cannot find";a.default.error("switchCamera ",o),r(o)}},e}();t.StreamWorker=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version="1.1.0"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(59);t.isMobile=function(){return n.default().isMobile},t.isWebview=function(){return n.default().browser.webview},t.getBrowserInfo=function(){return n.default().browser},t.getSystemInfo=function(){return{version:""+n.default().os.name,arch:""}},t.getDeviceInfo=function(){var e=n.default();return{vendor:window.navigator.vendor,brand:e.browser.name,model:""+e.browser.version}},t.getNetworkInfo=function(){return{network:""}},t.getCPUInfo=function(){return{brand:"",model:"",core:null!=window.navigator.hardwareConcurrency?window.navigator.hardwareConcurrency:0}},t.getMemInfo=function(){return{capacity:0}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(30),o=r(47),i=r(20),a=r(6),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.data,p=e.crossOrigin,f=void 0!==p&&p,l=e.needVerifyResponse,h=void 0===l||l;return new Promise((function(e,t){!f&&s(r)?o(r,{param:i.qs.stringify(d)+"&callback"},(function(r,n){return r?t(r):h&&0!==n.err?t(n.msg):void e(n)})):n.default.request({url:r,method:u,responseType:"json",data:d}).then((function(r){var n=r.data;if(h&&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){"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(15))},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,p=-1;function f(){d&&c&&(d=!1,c.length?u=c.concat(u):p=-1,u.length&&l())}function l(){if(!d){var e=s(f);d=!0;for(var t=u.length;t;){for(c=u,u=[];++p1)for(var r=1;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 p=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),p&&(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,p=a.localCapabilities,f=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(p,f);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 p={};d.remoteStreams.forEach((function(e){p[e.id]=e}));var f=[],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,y=u[0].substr(2).split(" ")[2],b=n.getDirection(a,h),S=n.parseMsid(a),R=n.getMid(a)||n.generateIdentifier();if(g||"application"===l&&("DTLS/SCTP"===y||"UDP/DTLS/SCTP"===y))d.transceivers[c]={mid:R,kind:l,protocol:y,rejected:!0};else{var _,w,C,T,E,P,k,O,M;!g&&d.transceivers[c]&&d.transceivers[c].rejected&&(d.transceivers[c]=d._createTransceiver(l,!0));var A,x,I=n.parseRtpParameters(a);g||(A=n.getIceParameters(a,h),(x=n.getDtlsParameters(a,h)).role="client"),k=n.parseRtpEncodingParameters(a);var L=n.parseRtcpParameters(a),D=n.matchPrefix(a,"a=end-of-candidates",h).length>0,N=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){w=(_=d.transceivers[c]).iceGatherer,C=_.iceTransport,T=_.dtlsTransport,E=_.rtpReceiver,P=_.sendEncodingParameters,O=_.localCapabilities,d.transceivers[c].recvEncodingParameters=k,d.transceivers[c].remoteCapabilities=I,d.transceivers[c].rtcpParameters=L,N.length&&"new"===C.state&&(!m&&!D||v&&0!==c?N.forEach((function(e){s(_.iceTransport,e)})):C.setRemoteCandidates(N)),v&&0!==c||("new"===C.state&&C.start(w,A,"controlling"),"new"===T.state&&T.start(x)),!i(_.localCapabilities,_.remoteCapabilities).codecs.filter((function(e){return"rtx"===e.name.toLowerCase()})).length&&_.sendEncodingParameters[0].rtx&&delete _.sendEncodingParameters[0].rtx,d._transceive(_,"sendrecv"===b||"recvonly"===b,"sendrecv"===b||"sendonly"===b),!E||"sendrecv"!==b&&"sendonly"!==b?delete _.rtpReceiver:(M=E.track,S?(p[S.stream]||(p[S.stream]=new e.MediaStream),r(M,p[S.stream]),f.push([M,E,p[S.stream]])):(p.default||(p.default=new e.MediaStream),r(M,p.default),f.push([M,E,p.default])))}}else{(_=d.transceivers[c]||d._createTransceiver(l)).mid=R,_.iceGatherer||(_.iceGatherer=d._createIceGatherer(c,v)),N.length&&"new"===_.iceTransport.state&&(!D||v&&0!==c?N.forEach((function(e){s(_.iceTransport,e)})):_.iceTransport.setRemoteCandidates(N)),O=e.RTCRtpReceiver.getCapabilities(l),t<15019&&(O.codecs=O.codecs.filter((function(e){return"rtx"!==e.name}))),P=_.sendEncodingParameters||[{ssrc:1001*(2*c+2)}];var j,U=!1;if("sendrecv"===b||"sendonly"===b){if(U=!_.rtpReceiver,E=_.rtpReceiver||new e.RTCRtpReceiver(_.dtlsTransport,l),U)M=E.track,S&&"-"===S.stream||(S?(p[S.stream]||(p[S.stream]=new e.MediaStream,Object.defineProperty(p[S.stream],"id",{get:function(){return S.stream}})),Object.defineProperty(M,"id",{get:function(){return S.track}}),j=p[S.stream]):(p.default||(p.default=new e.MediaStream),j=p.default)),j&&(r(M,j),_.associatedRemoteMediaStreams.push(j)),f.push([M,E,j])}else _.rtpReceiver&&_.rtpReceiver.track&&(_.associatedRemoteMediaStreams.forEach((function(t){var r=t.getTracks().find((function(e){return e.id===_.rtpReceiver.track.id}));r&&function(t,r){r.removeTrack(t),r.dispatchEvent(new e.MediaStreamTrackEvent("removetrack",{track:t}))}(r,t)})),_.associatedRemoteMediaStreams=[]);_.localCapabilities=O,_.remoteCapabilities=I,_.rtpReceiver=E,_.rtcpParameters=L,_.sendEncodingParameters=P,_.recvEncodingParameters=k,d._transceive(d.transceivers[c],!1,U)}}})),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(p).forEach((function(t){var r=p[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)}))}f.forEach((function(e){var t=e[0],n=e[1];r.id===e[2].id&&u(d,t,n,[r])}))}})),f.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"===p.protocol&&(0===p.port||9===p.port))return o();if(p.component&&1!==p.component)return o();if((0===a||a>0&&d.iceTransport!==r.transceivers[0].iceTransport)&&!s(d.iceTransport,p))return i(c("OperationError","Can not add ICE candidate"));var f=e.candidate.trim();0===f.indexOf("a=")&&(f=f.substr(2)),(t=n.getMediaSections(r._remoteDescription.sdp))[a]+="a="+(p.type?f:"end-of-candidates")+"\r\n",r._remoteDescription.sdp=n.getDescription(r._remoteDescription.sdp)+t.join("")}else for(var l=0;l=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});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,(function(){delete i.streamsub_id,delete i.mediaStream}),(function(e){d.default.error("onRemoveStream ",e)})),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._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}();t.SessionWorker=v},function(e,t,r){e.exports=r(31)},function(e,t,r){"use strict";var n=r(0),o=r(11),i=r(33),a=r(18);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(14));c.Axios=i,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=r(19),c.CancelToken=r(45),c.isCancel=r(13),c.all=function(e){return Promise.all(e)},c.spread=r(46),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(12),i=r(34),a=r(35),s=r(18);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(36),i=r(13),a=r(14),s=r(43),c=r(44);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(17);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(19);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(48)("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",p=null!=t.timeout?t.timeout:6e4,f=encodeURIComponent,l=document.getElementsByTagName("script")[0]||document.head;p&&(s=setTimeout((function(){h(),r&&r(new Error("Timeout"))}),p));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+"="+f(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(49)).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(15))},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(54),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(55);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(5))},function(e,t,r){e.exports=r(56).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";r.r(t),r.d(t,"__extends",(function(){return o})),r.d(t,"__assign",(function(){return i})),r.d(t,"__rest",(function(){return a})),r.d(t,"__decorate",(function(){return s})),r.d(t,"__param",(function(){return c})),r.d(t,"__metadata",(function(){return u})),r.d(t,"__awaiter",(function(){return d})),r.d(t,"__generator",(function(){return p})),r.d(t,"__exportStar",(function(){return f})),r.d(t,"__values",(function(){return l})),r.d(t,"__read",(function(){return h})),r.d(t,"__spread",(function(){return m})),r.d(t,"__spreadArrays",(function(){return v})),r.d(t,"__await",(function(){return g})),r.d(t,"__asyncGenerator",(function(){return y})),r.d(t,"__asyncDelegator",(function(){return b})),r.d(t,"__asyncValues",(function(){return S})),r.d(t,"__makeTemplateObject",(function(){return R})),r.d(t,"__importStar",(function(){return _})),r.d(t,"__importDefault",(function(){return w})); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function o(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var i=function(){return(i=Object.assign||function(e){for(var t,r=1,n=arguments.length;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 p(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 b(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 R(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function _(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 w(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=window.AudioContext||window.webkitAudioContext||window.mozAudioContext||window.msAudioContext||window.oAudioContext,o=function(){function e(e){this.mediaStream=e,this.audioContext=new n,this.sourceNode=this.audioContext.createMediaStreamSource(this.mediaStream),this.analyser=this.audioContext.createAnalyser(),this.timeDomainData=new Uint8Array(this.analyser.frequencyBinCount),this.sourceNode.connect(this.analyser)}return e.prototype.getVolume=function(){var e=0;return this.analyser.getByteTimeDomainData(this.timeDomainData),this.timeDomainData.forEach((function(t){e=Math.max(e,Math.abs(t-128))})),e/128},e}();t.AudioHelper=o},function(e,t,r){"use strict";r.r(t);var n="undefined"!=typeof window&&window||{},o=(n.RegExp,n.navigator),i={browser:[{criteria:"PhantomJS",identity:"PhantomJS"},{criteria:/Whale/,identity:"Whale",versionSearch:"Whale"},{criteria:/Edge/,identity:"Edge",versionSearch:"Edge"},{criteria:/MSIE|Trident|Windows Phone/,identity:"IE",versionSearch:"IEMobile|MSIE|rv"},{criteria:/MiuiBrowser/,identity:"MIUI Browser",versionSearch:"MiuiBrowser"},{criteria:/SamsungBrowser/,identity:"Samsung Internet",versionSearch:"SamsungBrowser"},{criteria:/SAMSUNG /,identity:"Samsung Internet",versionSearch:"Version"},{criteria:/Chrome|CriOS/,identity:"Chrome"},{criteria:/Android/,identity:"Android Browser",versionSearch:"Version"},{criteria:/iPhone|iPad/,identity:"Safari",versionSearch:"Version"},{criteria:"Apple",identity:"Safari",versionSearch:"Version"},{criteria:"Firefox",identity:"Firefox"}],os:[{criteria:/Windows Phone/,identity:"Windows Phone",versionSearch:"Windows Phone"},{criteria:"Windows 2000",identity:"Window",versionAlias:"5.0"},{criteria:/Windows NT/,identity:"Window",versionSearch:"Windows NT"},{criteria:/iPhone|iPad/,identity:"iOS",versionSearch:"iPhone OS|CPU OS"},{criteria:"Mac",versionSearch:"OS X",identity:"MAC"},{criteria:/Android/,identity:"Android"},{criteria:/Tizen/,identity:"Tizen"},{criteria:/Web0S/,identity:"WebOS"}],webview:[{criteria:/iPhone|iPad/,browserVersionSearch:"Version",webviewBrowserVersion:/-1/},{criteria:/iPhone|iPad|Android/,webviewToken:/NAVER|DAUM|; wv/}],defaultString:{browser:{version:"-1",name:"unknown"},os:{version:"-1",name:"unknown"}}};function a(e,t){for(var r=[],n=0;n-1}function u(e,t){var r=a(e,(function(e){return c(s,e.criteria)}))[0];return r&&r.identity||t.name}function d(e,t){return a(e,(function(e){var r=e.criteria,n=new RegExp(e.identity,"i").test(t);return!!(r?n&&c(s,r):n)}))[0]}function p(e,t){var r=i.defaultString.browser.version,n=new RegExp("("+e+")","i").exec(t);if(!n)return r;var o=n.index,a=n[0];if(o>-1){var s=o+a.length+1;r=t.substring(s).split(" ")[0].replace(/_/g,".").replace(/;|\)/g,"")}return r}function f(e){if(e)return p(function(e){var t=d(i.browser,e);return t||(t={criteria:e,versionSearch:e,identity:e}),t}(e).versionSearch||e,s)}function l(e){var t=function(e){return d(i.os,e)}(e)||{},r=i.defaultString.os.version,n=void 0;if(e){if(t.versionAlias)return t.versionAlias;var o=t.versionSearch||e,a=new RegExp("("+o+")\\s([\\d_\\.]+|\\d_0)","i");return a.exec(s)&&(n=a.exec(s)[2].replace(/_/g,".").replace(/;|\)/g,"")),n||r}}function h(){var e=u(i.os,i.defaultString.os);return{name:e,version:l(e)}}function m(){var e,t,r=u(i.browser,i.defaultString.browser);return{name:r,version:f(r),webview:(e=i.webview,t=void 0,function(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:o.userAgent);var e={os:h(),browser:m(),isMobile:-1!==s.indexOf("Mobi")};return e.browser.name=e.browser.name.toLowerCase(),e.os.name=e.os.name.toLowerCase(),e.os.version=e.os.version.toLowerCase(),"ios"===e.os.name&&e.browser.webview&&(e.browser.version="-1"),e}v.VERSION="2.1.5",t.default=v},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.framesEncoded=0,this.totalDecodeTime=0,this.frameHeight=0,this.frameWidth=0,this.framesDecoded=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.framesPerSecond=0,this.height=0,this.width=0,this.frameHeight=0,this.frameWidth=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=""},p=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=p},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){var t=e.user_id,r=e.room_id,a=e.app_id,s=e.appkey,c=n.Base64.encode(JSON.stringify({user_id:t,room_id:r,app_id:a,appkey:s})),u=Math.round(Date.now()/1e3),d=i.randNum(8),p=t+a+u+d+r,f=new o("SHA-1","TEXT");return f.setHMACKey(s,"TEXT"),f.update(p),c+"."+f.getHMAC("HEX")+u+d}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(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__(5))},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,y=0,b=[],S=0,R=!1,_=[],w=[],C=!1,T=!1,E=-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=U,m=V,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},E=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,T=!0;else{if("SHAKE256"!==e)throw Error("Chosen SHA variant is not supported");l=1088,a=-1,P=31,T=!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=W(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&&W(null,n);return s}}i=f(t,n,E),o=j(e),this.setHMACKey=function(t,r,i){var s;if(!0===R)throw Error("HMAC key already set");if(!0===C)throw Error("Cannot set HMAC key after calling update");if(!0===T)throw Error("SHAKE is not supported for HMAC");if(t=(r=f(r,n=(i||{}).encoding||"UTF8",E)(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)_[t]=909522486^r[t],w[t]=1549556828^r[t];o=h(_,o),y=l,R=!0},this.update=function(e){var t,r,n,a=0,s=l>>>5;for(e=(t=i(e,b,S)).binLen,r=t.value,t=e>>>5,n=0;n>>5),S=e%l,C=!0},this.getHash=function(t,r){var n,i,f,l;if(!0===R)throw Error("Cannot call getHash after setting HMAC key");if(f=p(r),!0===T){if(-1===f.shakeLen)throw Error("shakeLen must be specified in options");a=f.shakeLen}switch(t){case"HEX":n=function(e){return s(e,a,E,f)};break;case"B64":n=function(e){return c(e,a,E,f)};break;case"BYTES":n=function(e){return u(e,a,E)};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,E)};break;default:throw Error("format must be HEX, B64, BYTES, or ARRAYBUFFER")}for(l=m(b.slice(),S,y,v(o),a),i=1;i>>24-a%32),l=m(l,a,0,j(e),a);return n(l)},this.getHMAC=function(t,r){var n,i,f,g;if(!1===R)throw Error("Cannot call getHMAC without first setting HMAC key");switch(f=p(r),t){case"HEX":n=function(e){return s(e,a,E,f)};break;case"B64":n=function(e){return c(e,a,E,f)};break;case"BYTES":n=function(e){return u(e,a,E)};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,E)};break;default:throw Error("outputFormat must be HEX, B64, BYTES, or ARRAYBUFFER")}return i=m(b.slice(),S,y,v(o),a),g=h(w,j(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 p(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 f(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,p,f,l=0;if(n=n||[0],u=(o=o||0)>>>3,"UTF8"===t)for(f=-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*(f+p%4*r),l+=1}else if("UTF16BE"===t||"UTF16LE"===t)for(f=-1===r?2:0,a="UTF16LE"===t&&1!==r||"UTF16LE"!==t&&1===r,s=0;s>>8),d=(p=l+u)>>>2;n.length<=d;)n.push(0);n[d]|=i<<8*(f+p%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,p,f=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 M(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 A(e){p(e,"negotiationneeded",e=>{if("stable"===e.target.signalingState)return e})}var x=r(25),I=r.n(x);function L(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 D(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 N(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 j(e){!e.RTCRtpSender||"replaceTrack"in e.RTCRtpSender.prototype||(e.RTCRtpSender.prototype.replaceTrack=e.RTCRtpSender.prototype.setTrack)}function U(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 V(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 W(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 B(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 G(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}),p(e,"track",e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Y(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 H(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function J(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 z(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 q(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 $(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(Q(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,r,n){t.mediaDevices.getUserMedia(e).then(r,n)}.bind(t))}function Q(e){return e&&void 0!==e.video?Object.assign({},e,{video:y(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,p(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},p(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:f,disableWarnings:l};switch(c.browser){case"chrome":if(!n||!M||!t.shimChrome)return r("Chrome shim is not included in this adapter release."),u;r("adapter.js shimming chrome."),u.browserShim=n,R(e),w(e),M(e),C(e),O(e),T(e),E(e),P(e),A(e),ie(e),ce(e),ae(e),se(e),ue(e);break;case"firefox":if(!i||!W||!t.shimFirefox)return r("Firefox shim is not included in this adapter release."),u;r("adapter.js shimming firefox."),u.browserShim=i,U(e),W(e),F(e),Y(e),B(e),G(e),H(e),J(e),z(e),q(e),ie(e),ce(e),ae(e),se(e);break;case"edge":if(!o||!N||!t.shimEdge)return r("MS edge shim is not included in this adapter release."),u;r("adapter.js shimming edge."),u.browserShim=o,L(e),D(e),N(e),j(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),$(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}])}));