text: System.register([],function(e){return{execute:function(){e(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=95)}({14:function(e,t,n){"use strict";n(18);var r=class{constructor(e){if(this._textMessage=e.textMessage,this._dataSize=e.dataSize,this._data=[],this._progress=0,this._sendingTime=e.sendingTime,this._progressPercentage=0,!this._textMessage.body||!this._textMessage.body.value)throw Error("[P2PDataReceiver constructor] invalid Hyperty Resource message. Does not comtain a body.value",e)}get from(){return this._textMessage.from}get to(){return this._textMessage.to}get id(){return this._textMessage.id}get type(){return this._textMessage.type}receiveText(e){let t=this;if(t._data.push(e.data),t._progress=t._progress+e.data.length,t._progress===t._dataSize){let e=t._data.join("");t._processLastMessage(e)}else{let e=parseInt(100*t._progress/t._dataSize);e-t._progressPercentage>0&&(t._progressPercentage=e,console.debug("[P2PDataReceiver] progressing: ",t._progressPercentage),t._onProgress(t._progressPercentage))}}receiveBinary(e){let t=this;if(t._data.push(e),t._progress=t._progress+e.byteLength,t._progress===t._dataSize)t._processLastMessage(t._data);else if(t._onProgress){let e=parseInt(100*t._progress/t._dataSize);e-t._progressPercentage>0&&(t._progressPercentage=e,console.debug("[P2PDataReceiver] progressing: ",t._progressPercentage),t._onProgress(t._progressPercentage))}}_processLastMessage(e){let t=(new Date).getTime()-this._sendingTime,n=this._textMessage;n.body.value.content=e,this._onReceived(n,t)}onReceived(e){this._onReceived=e}onProgress(e){this._onProgress=e}};var i=class{constructor(e,t){this._msg=e,this._channel=t,this._packetSize=16384,this._bufferFullThreshold=5*this._packetSize,this._msgObject=e,this.isData=!1,this._init(),this._cancel=!1}cancel(){this._cancel=!0}_init(){let e=this,t=(Math.random()*(new Date).getTime()).toString(36).replace(/\./g,"-"),n=(new Date).getTime();e._initialPacket={uuid:t,sendingTime:n},e._msg.body&&e._msg.body.value&&e._msg.body.value.content&&(e.isData=!0),e.isData&&e._msg.body.value.mimetype&&"text"!=e._msg.body.value.mimetype.split("/")[0]?(e._send=e._sendBinary,e._initialPacket.dataSize=e._msg.body.value.content.byteLength):(e._send=e._sendText,e.isData&&(e._initialPacket.dataSize=e._msg.body.value.content.length)),e._initialPacket.textMessage=JSON.parse(JSON.stringify(e._msg)),e.isData?(delete e._initialPacket.textMessage.body.value.content,e._data=e._msg.body.value.content):e._initialPacket.dataSize=0}_sendText(e,t){let n={uuid:e,data:t};this._channel.send(JSON.stringify(n))}_sendBinary(e,t){let n=this._str2ab(e),r=this._appendBuffer(n,t);this._channel.send(r)}_str2ab(e){for(var t=new ArrayBuffer(2*e.length),n=new Uint16Array(t),r=0,i=e.length;r<i;r++)n[r]=e.charCodeAt(r);return t}_appendBuffer(e,t){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e),0),n.set(new Uint8Array(t),e.byteLength),n.buffer}sendData(){this._size=this._initialPacket.dataSize,console.log("[P2PDataSender] start sending to: ",this._msg.to),this._sendText(this._initialPacket.uuid,this._initialPacket),this.isData?this._sendData():this._onSent&&this._onSent()}_sendData(){let e=this,t={},n={};t.max=e._size,n.max=t.max,t.value=0,n.value=0;let r,i=e._channel,a=e._packetSize,o=5*a,s=!0,c=!1;"number"==typeof i.bufferedAmountLowThreshold&&(console.info("[P2PDataSender] Using the bufferedamountlow event for flow control"),s=!1,o=a/2,i.bufferedAmountLowThreshold=o);var d=function(){i.removeEventListener("bufferedamountlow",d),l()},l=function(){for(;t.value<t.max&&!e._cancel;){if(i.bufferedAmount>o)return void(s?setTimeout(l,250):i.addEventListener("bufferedamountlow",d));r=e._data.slice(t.value,t.value+a),t.value+a<t.max?t.value+=a:(c=!0,t.value=t.max),e._send(e._initialPacket.uuid,r),c&&e._onSent&&e._onSent()}};setTimeout(l,5)}onSent(e){this._onSent=e}onProgress(e){this.onProgress=e}};t.a=class{constructor(e,t,n,r){if(!e)throw new Error("The own url (myUrl) is a needed parameter");if(!t)throw new Error("The syncher is a needed parameter");if(!n)throw new Error("The configuration is a needed parameter");this._domain=this._divideURL(e).domain,this._objectDescURL="hyperty-catalogue://catalogue."+this._domain+"/.well-known/dataschema/Connection",this._myUrl=e,this._syncher=t,this._configuration=n,this._caller=r,this._dataObjectObserver,this._dataObjectReporter,this._peerUrl,this._dataChannel,this._onStatusUpdate,this._remoteRuntimeURL,this._receivers={},this._senders={},this._maxSize=16384,this._threshold=0,this._peerConnection=this._createPeerConnection()}_createPeerConnection(){let e=this._peerConnection;return e||(e=new RTCPeerConnection(this._configuration),console.log("[P2P-ConnectionController]: created PeerConnection"),e.ondatachannel=e=>{console.log("[P2P-ConnectionController]: ondatachannel -> remote side has created a datachannel"),this._dataChannel=e.channel,this._addDataChannelListeners()},e.onicecandidate=e=>{if(console.log("[P2P-ConnectionController]: icecandidateevent occured: ",e),!e.candidate)return;let t={type:"candidate",candidate:e.candidate.candidate,sdpMid:e.candidate.sdpMid,sdpMLineIndex:e.candidate.sdpMLineIndex};this._dataObjectReporter.data.iceCandidates.push(t)}),e}observe(e){return this._peerUrl=e.from,this._remoteRuntimeURL=e.value.runtime,new Promise((t,n)=>{let r={schema:this._objectDescURL,resource:e.url};this._syncher.subscribe(r).then(e=>{console.info("+[P2P-ConnectionController] got Data Object Observer",e),this._setupObserver(e),t()}).catch(function(e){console.error(e),n()})})}report(e,t){return this._peerUrl||(this._peerUrl=e),new Promise((e,n)=>{this._peerConnection||(this._peerConnection=this._createPeerConnection()),this._caller&&(console.log("[P2P-ConnectionController]: we are in caller role --\x3e createDataChannel ..."),this._dataChannel=this._peerConnection.createDataChannel("P2PChannel"),this._dataChannel.binaryType="arraybuffer",this._dataChannel.bufferedAmountLowThreshold=this._threshold,console.log("P2P: datachannel object",this._dataChannel),this._addDataChannelListeners());let r={name:"P2PConnection",status:"",owner:this._myUrl,runtimeURL:t,connectionDescription:{},iceCandidates:[]},i=Object.assign({resources:["data"]});this._syncher.create(this._objectDescURL,[this._peerUrl],r,!1,!1,"p2p connection",{},i).then(t=>{console.info("[P2P-ConnectionController] Created WebRTC Object Reporter",t),this._dataObjectReporter=t,this._dataObjectReporter.onSubscription(e=>{e.accept()}),(this._caller?this._peerConnection.createOffer({offerToReceiveAudio:!1,offerToReceiveVideo:!1}):this._peerConnection.createAnswer()).then(t=>{console.log("[P2P-ConnectionController] SDP created",t),this._peerConnection.setLocalDescription(new RTCSessionDescription(t),()=>{console.info("[P2P-ConnectionController] localDescription set successfully"),this._dataObjectReporter.data.connectionDescription.sdp=t.sdp,this._dataObjectReporter.data.connectionDescription.type=t.type,e()}).catch(e=>{n("setting of localDescription failed: ",e)})}).catch(e=>{console.error(e),n(e)})})})}onMessage(e){this._onDataChannelMessage=e}onStatusUpdate(e){this._onStatusUpdate=e}sendMessage(e){let t=this;if(console.log("[P2P-ConnectionController] --\x3e starting sending data to ",e.to),"open"!=t._dataChannel.readyState)throw Error("[P2PStub.ConnectionController.sendMessage] data channel is not opened. droping message: ",e);let n=new i(e,t._dataChannel),r=e.from+e.to+e.id;t._senders[r]=n,n.sendData(),n.onProgress(e=>{console.debug("[P2P-ConnectionController] sending progress ",e)}),n.onSent(()=>{console.debug("[P2P-ConnectionController] data was sent to:",e.to),delete t._senders[r]})}cleanup(){delete this._dataObjectReporter,delete this._dataObjectObserver,this._dataChannel&&this._dataChannel.close(),this._peerConnection&&this._peerConnection.close(),this._dataChannel=null,this._peerConnection=null}_addDataChannelListeners(){this._dataChannel.onopen=()=>{this._onDataChannelOpen()},this._dataChannel.onerror=e=>{this._onDataChannelError(e)},this._dataChannel.onmessage=e=>{let t=e.data;"object"!=typeof t?this._onTextMessage(t):this._onBinaryMessage(t)},this._dataChannel.onclose=()=>{this._onDataChannelClose()}}_onTextMessage(e){let t=this,n=JSON.parse(e);if(!n.uuid)throw Error("[P2P-ConnectionController.onmessage] message is invalid",n);if(n.data.textMessage.hasOwnProperty("to")&&n.data.textMessage.to===t._myUrl)t._onMyMessage(n.data.textMessage);else if(t._receivers[n.uuid])t._receivers[n.uuid].receiveText(n);else{if(!n.data||!n.data.textMessage||!n.data.textMessage.from)throw Error("[P2P-ConnectionController.onmessage] initial packet is invalid",n);if(console.debug("[P2P-ConnectionController] <-- incoming msg : ",n),0===n.data.dataSize){let e=n.data.textMessage;this._onDataChannelMessage(e)}else{let e=new r(n.data);e.onReceived((e,r)=>{console.debug("[P2P-ConnectionController] complete message received from: "+e.from+" latency: "+r),t._onDataChannelMessage(e),delete t._receivers[n.uuid]}),e.onProgress(n=>{let r={from:e.from,to:e.to,id:e.id,type:e.type,body:{code:183,desc:"Message reception is progressing",value:n}};console.debug("[P2P-ConnectionController] onprogress sending provisional response: ",r),t._syncher._bus.postMessage(r)}),t._receivers[n.uuid]=e}}}_onMyMessage(e){if(e.hasOwnProperty("body")&&e.body.hasOwnProperty("resource")){let t=e.body.resource;this._senders[t]&&"delete"===e.type&&(console.log("[ConnectionController._onMyMessage] cancelling: ",this._senders[t]),this._senders[t].cancel,delete this._senders[t])}}_onBinaryMessage(e){let t=this,n=String.fromCharCode.apply(null,new Uint16Array(e.slice(0,24)));if(t._receivers[n])t._receivers[n].receiveBinary(e.slice(24));else{let n=Object.keys(t._receivers);if(1!==n.length)throw Error("[P2P-ConnectionController.onBinaryMessage] invalid binary packet",e);{let r=n[0],i={from:t._receivers[r].from,to:t._receivers[r].to,id:t._receivers[r].id,type:t._receivers[r].type,body:{code:500,desc:"Reception error"}};console.error("[P2P-ConnectionController.onBinaryMessage] malformed packet: ",e),t._syncher._bus.postMessage(i),t._cancelSent(i.from+i.to+i.id),delete t._receivers[r]}}}_cancelSent(e){let t={from:this._myUrl,to:this._peerUrl,type:"delete",body:{resource:e}};console.info("[P2P-ConnectionController._cancelSent] : ",t),this.sendMessage(t)}_setupObserver(e){this._dataObjectObserver=e;let t=this._dataObjectObserver.data;console.info("[P2P-ConnectionController]: _setupObserver Peer Data: ",t),t.hasOwnProperty("connectionDescription")&&this._processPeerInformation(t.connectionDescription),t.hasOwnProperty("iceCandidates")&&t.iceCandidates.forEach(e=>{console.log("[P2P-ConnectionController]: handleObserverObject for ice",e),this._processPeerInformation(e)}),e.onChange("*",e=>{console.debug("[P2P-ConnectionController]: Observer on change message: ",e),e.data[0]?(console.log(">>event.data[0]",e.data[0]),this._processPeerInformation(e.data[0])):(console.log("[P2P-ConnectionController]: >>event",e),this._processPeerInformation(e.data))})}_processPeerInformation(e){console.info("[P2P-ConnectionController]: processPeerInformation: ",JSON.stringify(e)),this._peerConnection?("offer"!==e.type&&"answer"!==e.type||(console.info("[P2P-ConnectionController]: Process Connection Description: ",e),this._peerConnection.setRemoteDescription(new RTCSessionDescription(e)).then(()=>{console.log("[P2P-ConnectionController]: remote success")}).catch(e=>{console.log("[P2P-ConnectionController]: remote error: ",e)})),e.candidate&&(console.info("Process Ice Candidate: ",e),this._peerConnection.addIceCandidate(new RTCIceCandidate({candidate:e.candidate})))):console.info("[P2P-ConnectionController]: processPeerInformation: no PeerConnection existing --\x3e maybe in disconnecting process. --\x3e ignoring this update")}_onDataChannelOpen(){console.log("[P2P-ConnectionController] DataChannel opened"),this._onStatusUpdate&&this._onStatusUpdate("live",void 0,this._remoteRuntimeURL)}_onDataChannelError(e){console.log("[P2P-ConnectionController] DataChannel error: ",e),this._onStatusUpdate&&this._onStatusUpdate("disconnected",""+e,this._remoteRuntimeURL)}_onDataChannelClose(){console.log("[P2P-ConnectionController] DataChannel closed: "),this._onStatusUpdate&&this._onStatusUpdate("disconnected","closed",this._remoteRuntimeURL)}_divideURL(e){let t=e.replace(/([a-zA-Z-]*):\/\/(?:\.)?([-a-zA-Z0-9@:%._\+~#=]{2,256})([-a-zA-Z0-9@:%._\+~#=\/]*)/gi,"$1,$2,$3").split(",");return t[0]===e&&(t[0]="https",t[1]=e),{type:t[0],domain:t[1],identity:t[2]}}}},18:function(e,t,n){"use strict";!function(){var t=n(3),r=t.log,i=t.browserDetails;e.exports.browserDetails=i,e.exports.extractVersion=t.extractVersion,e.exports.disableLog=t.disableLog;var a=n(19)||null,o=n(21)||null,s=n(25)||null,c=n(27)||null;switch(i.browser){case"chrome":if(!a||!a.shimPeerConnection)return void r("Chrome shim is not included in this adapter release.");r("adapter.js shimming chrome."),e.exports.browserShim=a,a.shimGetUserMedia(),a.shimMediaStream(),t.shimCreateObjectURL(),a.shimSourceObject(),a.shimPeerConnection(),a.shimOnTrack(),a.shimGetSendersWithDtmf();break;case"firefox":if(!s||!s.shimPeerConnection)return void r("Firefox shim is not included in this adapter release.");r("adapter.js shimming firefox."),e.exports.browserShim=s,s.shimGetUserMedia(),t.shimCreateObjectURL(),s.shimSourceObject(),s.shimPeerConnection(),s.shimOnTrack();break;case"edge":if(!o||!o.shimPeerConnection)return void r("MS edge shim is not included in this adapter release.");r("adapter.js shimming edge."),e.exports.browserShim=o,o.shimGetUserMedia(),t.shimCreateObjectURL(),o.shimPeerConnection(),o.shimReplaceTrack();break;case"safari":if(!c)return void r("Safari shim is not included in this adapter release.");r("adapter.js shimming safari."),e.exports.browserShim=c,c.shimCallbacksAPI(),c.shimAddStream(),c.shimOnAddStream(),c.shimGetUserMedia();break;default:r("Unsupported browser!")}}()},19:function(e,t,n){"use strict";var r=n(3).log,i=n(3).browserDetails,a={shimMediaStream:function(){window.MediaStream=window.MediaStream||window.webkitMediaStream},shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){var t=this;this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.addEventListener("addtrack",function(n){var r;r=RTCPeerConnection.prototype.getReceivers?t.getReceivers().find(function(e){return e.track.id===n.track.id}):{track:n.track};var i=new Event("track");i.track=n.track,i.receiver=r,i.streams=[e.stream],t.dispatchEvent(i)}),e.stream.getTracks().forEach(function(n){var r;r=RTCPeerConnection.prototype.getReceivers?t.getReceivers().find(function(e){return e.track.id===n.id}):{track:n};var i=new Event("track");i.track=n,i.receiver=r,i.streams=[e.stream],this.dispatchEvent(i)}.bind(this))}.bind(this))}})},shimGetSendersWithDtmf:function(){if("object"==typeof window&&window.RTCPeerConnection&&!("getSenders"in RTCPeerConnection.prototype)&&"createDTMFSender"in RTCPeerConnection.prototype){RTCPeerConnection.prototype.getSenders=function(){return this._senders||[]};var e=RTCPeerConnection.prototype.addStream,t=RTCPeerConnection.prototype.removeStream;RTCPeerConnection.prototype.addTrack||(RTCPeerConnection.prototype.addTrack=function(e,t){var n=this;if("closed"===n.signalingState)throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");var r=[].slice.call(arguments,1);if(1!==r.length||!r[0].getTracks().find(function(t){return t===e}))throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError");n._senders=n._senders||[];var i=n._senders.find(function(t){return t.track===e});if(i)throw new DOMException("Track already exists.","InvalidAccessError");n._streams=n._streams||{};var a=n._streams[t.id];if(a)a.addTrack(e),n.removeStream(a),n.addStream(a);else{var o=new MediaStream([e]);n._streams[t.id]=o,n.addStream(o)}var s={track:e,get dtmf(){return void 0===this._dtmf&&("audio"===e.kind?this._dtmf=n.createDTMFSender(e):this._dtmf=null),this._dtmf}};return n._senders.push(s),s}),RTCPeerConnection.prototype.addStream=function(t){var n=this;n._senders=n._senders||[],e.apply(n,[t]),t.getTracks().forEach(function(e){n._senders.push({track:e,get dtmf(){return void 0===this._dtmf&&("audio"===e.kind?this._dtmf=n.createDTMFSender(e):this._dtmf=null),this._dtmf}})})},RTCPeerConnection.prototype.removeStream=function(e){var n=this;n._senders=n._senders||[],t.apply(n,[e]),e.getTracks().forEach(function(e){var t=n._senders.find(function(t){return t.track===e});t&&n._senders.splice(n._senders.indexOf(t),1)})}}},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this._srcObject},set:function(e){var t=this;this._srcObject=e,this.src&&URL.revokeObjectURL(this.src),e?(this.src=URL.createObjectURL(e),e.addEventListener("addtrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)}),e.addEventListener("removetrack",function(){t.src&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)})):this.src=""}}))},shimPeerConnection:function(){if(window.RTCPeerConnection){var e=RTCPeerConnection;window.RTCPeerConnection=function(t,n){if(t&&t.iceServers){for(var r=[],i=0;i<t.iceServers.length;i++){var a=t.iceServers[i];!a.hasOwnProperty("urls")&&a.hasOwnProperty("url")?(console.warn("RTCIceServer.url is deprecated! Use urls instead."),(a=JSON.parse(JSON.stringify(a))).urls=a.url,r.push(a)):r.push(t.iceServers[i])}t.iceServers=r}return new e(t,n)},window.RTCPeerConnection.prototype=e.prototype,Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return e.generateCertificate}})}else window.RTCPeerConnection=function(e,t){return r("PeerConnection"),e&&e.iceTransportPolicy&&(e.iceTransports=e.iceTransportPolicy),new webkitRTCPeerConnection(e,t)},window.RTCPeerConnection.prototype=webkitRTCPeerConnection.prototype,webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return webkitRTCPeerConnection.generateCertificate}});var t=RTCPeerConnection.prototype.getStats;RTCPeerConnection.prototype.getStats=function(e,n,r){var i=this,a=arguments;if(arguments.length>0&&"function"==typeof e)return t.apply(this,arguments);if(0===t.length&&(0===arguments.length||"function"!=typeof arguments[0]))return t.apply(this,[]);var o=function(e){var t={};return e.result().forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:{localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},s=function(e){return new Map(Object.keys(e).map(function(t){return[t,e[t]]}))};if(arguments.length>=2){var c=function(e){a[1](s(o(e)))};return t.apply(this,[c,arguments[0]])}return new Promise(function(e,n){t.apply(i,[function(t){e(s(o(t)))},n])}).then(n,r)},i.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){var e=arguments,n=this,r=new Promise(function(r,i){t.apply(n,[e[0],r,i])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}}),i.version<52&&["createOffer","createAnswer"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var n=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,i){t.apply(e,[r,i,n])})}return t.apply(this,arguments)}}),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var n=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())}}};e.exports={shimMediaStream:a.shimMediaStream,shimOnTrack:a.shimOnTrack,shimGetSendersWithDtmf:a.shimGetSendersWithDtmf,shimSourceObject:a.shimSourceObject,shimPeerConnection:a.shimPeerConnection,shimGetUserMedia:n(20)}},20:function(e,t,n){"use strict";var r=n(3).log,i=n(3).browserDetails;e.exports=function(){var e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var a={};"number"==typeof r.ideal?(a[i("min",n)]=r.ideal,t.optional.push(a),(a={})[i("max",n)]=r.ideal,t.optional.push(a)):(a[i("",n)]=r.ideal,t.optional.push(a))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[i("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(t,n){if((t=JSON.parse(JSON.stringify(t)))&&t.audio&&(t.audio=e(t.audio)),t&&"object"==typeof t.video){var a=t.video.facingMode;a=a&&("object"==typeof a?a:{ideal:a});var o,s=i.version<61;if(a&&("user"===a.exact||"environment"===a.exact||"user"===a.ideal||"environment"===a.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode||s))if(delete t.video.facingMode,"environment"===a.exact||"environment"===a.ideal?o=["back","rear"]:"user"!==a.exact&&"user"!==a.ideal||(o=["front"]),o)return navigator.mediaDevices.enumerateDevices().then(function(i){var s=(i=i.filter(function(e){return"videoinput"===e.kind})).find(function(e){return o.some(function(t){return-1!==e.label.toLowerCase().indexOf(t)})});return!s&&i.length&&-1!==o.indexOf("back")&&(s=i[i.length-1]),s&&(t.video.deviceId=a.exact?{exact:s.deviceId}:{ideal:s.deviceId}),t.video=e(t.video),r("chrome: "+JSON.stringify(t)),n(t)});t.video=e(t.video)}return r("chrome: "+JSON.stringify(t)),n(t)},n=function(e){return{name:{ConstraintNotSatisfiedError:"OverconstrainedError",PermissionDeniedError:"NotAllowedError",TrackStartError:"NotReadableError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}};navigator.getUserMedia=function(e,r,i){t(e,function(e){navigator.webkitGetUserMedia(e,r,function(e){i(n(e))})})};var a=function(e){return new Promise(function(t,n){navigator.getUserMedia(e,t,n)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:a,enumerateDevices:function(){return new Promise(function(e){var t={audio:"audioinput",video:"videoinput"};return MediaStreamTrack.getSources(function(n){e(n.map(function(e){return{label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""}}))})})},getSupportedConstraints:function(){return{deviceId:!0,echoCancellation:!0,facingMode:!0,frameRate:!0,height:!0,width:!0}}}),navigator.mediaDevices.getUserMedia){var o=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(e){return t(e,function(e){return o(e).then(function(t){if(e.audio&&!t.getAudioTracks().length||e.video&&!t.getVideoTracks().length)throw t.getTracks().forEach(function(e){e.stop()}),new DOMException("","NotFoundError");return t},function(e){return Promise.reject(n(e))})})}}else navigator.mediaDevices.getUserMedia=function(e){return a(e)};void 0===navigator.mediaDevices.addEventListener&&(navigator.mediaDevices.addEventListener=function(){r("Dummy mediaDevices.addEventListener called.")}),void 0===navigator.mediaDevices.removeEventListener&&(navigator.mediaDevices.removeEventListener=function(){r("Dummy mediaDevices.removeEventListener called.")})}},21:function(e,t,n){"use strict";var r=n(3).browserDetails,i=n(22);e.exports={shimGetUserMedia:n(24),shimPeerConnection:function(){if(window.RTCIceGatherer&&(window.RTCIceCandidate||(window.RTCIceCandidate=function(e){return e}),window.RTCSessionDescription||(window.RTCSessionDescription=function(e){return e}),r.version<15025)){var e=Object.getOwnPropertyDescriptor(MediaStreamTrack.prototype,"enabled");Object.defineProperty(MediaStreamTrack.prototype,"enabled",{set:function(t){e.set.call(this,t);var n=new Event("enabled");n.enabled=t,this.dispatchEvent(n)}})}window.RTCPeerConnection=i(r.version)},shimReplaceTrack:function(){!window.RTCRtpSender||"replaceTrack"in RTCRtpSender.prototype||(RTCRtpSender.prototype.replaceTrack=RTCRtpSender.prototype.setTrack)}}},22:function(e,t,n){"use strict";var r=n(23);function i(e){var t=e.filter(function(e){return"audio"===e.kind}),n=e.filter(function(e){return"video"===e.kind});for(e=[];t.length||n.length;)t.length&&e.push(t.shift()),n.length&&e.push(n.shift());return e}function a(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]},r=function(e,t){e=parseInt(e,10);for(var n=0;n<t.length;n++)if(t[n].payloadType===e||t[n].preferredPayloadType===e)return t[n]},i=function(e,t,n,i){var a=r(e.parameters.apt,n),o=r(t.parameters.apt,i);return a&&o&&a.name.toLowerCase()===o.name.toLowerCase()};return e.codecs.forEach(function(r){for(var a=0;a<t.codecs.length;a++){var o=t.codecs[a];if(r.name.toLowerCase()===o.name.toLowerCase()&&r.clockRate===o.clockRate){if("rtx"===r.name.toLowerCase()&&r.parameters&&o.parameters.apt&&!i(r,o,e.codecs,t.codecs))continue;(o=JSON.parse(JSON.stringify(o))).numChannels=Math.min(r.numChannels,o.numChannels),n.codecs.push(o),o.rtcpFeedback=o.rtcpFeedback.filter(function(e){for(var t=0;t<r.rtcpFeedback.length;t++)if(r.rtcpFeedback[t].type===e.type&&r.rtcpFeedback[t].parameter===e.parameter)return!0;return!1});break}}}),e.headerExtensions.forEach(function(e){for(var r=0;r<t.headerExtensions.length;r++){var i=t.headerExtensions[r];if(e.uri===i.uri){n.headerExtensions.push(i);break}}}),n}function o(e,t,n){return-1!=={offer:{setLocalDescription:["stable","have-local-offer"],setRemoteDescription:["stable","have-remote-offer"]},answer:{setLocalDescription:["have-remote-offer","have-local-pranswer"],setRemoteDescription:["have-local-offer","have-remote-pranswer"]}}[t][e].indexOf(n)}e.exports=function(e){var t=function(t){var n=this,r=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){n[e]=r[e].bind(r)}),this.needNegotiation=!1,this.onicecandidate=null,this.onaddstream=null,this.ontrack=null,this.onremovestream=null,this.onsignalingstatechange=null,this.oniceconnectionstatechange=null,this.onicegatheringstatechange=null,this.onnegotiationneeded=null,this.ondatachannel=null,this.canTrickleIceCandidates=null,this.localStreams=[],this.remoteStreams=[],this.getLocalStreams=function(){return n.localStreams},this.getRemoteStreams=function(){return n.remoteStreams},this.localDescription=new RTCSessionDescription({type:"",sdp:""}),this.remoteDescription=new RTCSessionDescription({type:"",sdp:""}),this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",this.iceOptions={gatherPolicy:"all",iceServers:[]},t&&t.iceTransportPolicy)switch(t.iceTransportPolicy){case"all":case"relay":this.iceOptions.gatherPolicy=t.iceTransportPolicy}this.usingBundle=t&&"max-bundle"===t.bundlePolicy,t&&t.iceServers&&(this.iceOptions.iceServers=function(e,t){var n=!1;return(e=JSON.parse(JSON.stringify(e))).filter(function(e){if(e&&(e.urls||e.url)){var r=e.urls||e.url;e.url&&!e.urls&&console.warn("RTCIceServer.url is deprecated! Use urls instead.");var i="string"==typeof r;return i&&(r=[r]),r=r.filter(function(e){return 0!==e.indexOf("turn:")||-1===e.indexOf("transport=udp")||-1!==e.indexOf("turn:[")||n?0===e.indexOf("stun:")&&t>=14393:(n=!0,!0)}),delete e.url,e.urls=i?r[0]:r,!!r.length}return!1})}(t.iceServers,e)),this._config=t||{},this.transceivers=[],this._localIceCandidatesBuffer=[]};return t.prototype._emitGatheringStateChange=function(){var e=new Event("icegatheringstatechange");this.dispatchEvent(e),null!==this.onicegatheringstatechange&&this.onicegatheringstatechange(e)},t.prototype._emitBufferedCandidates=function(){var e=this,t=r.splitSections(e.localDescription.sdp);this._localIceCandidatesBuffer.forEach(function(n){if(!n.candidate||0===Object.keys(n.candidate).length)for(var r=1;r<t.length;r++)-1===t[r].indexOf("\r\na=end-of-candidates\r\n")&&(t[r]+="a=end-of-candidates\r\n");else t[n.candidate.sdpMLineIndex+1]+="a="+n.candidate.candidate+"\r\n";(e.localDescription.sdp=t.join(""),e.dispatchEvent(n),null!==e.onicecandidate&&e.onicecandidate(n),n.candidate||"complete"===e.iceGatheringState)||e.transceivers.every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state})&&"complete"!==e.iceGatheringStateChange&&(e.iceGatheringState="complete",e._emitGatheringStateChange())}),this._localIceCandidatesBuffer=[]},t.prototype.getConfiguration=function(){return this._config},t.prototype._createTransceiver=function(e){var t=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,wantReceive:!0};if(this.usingBundle&&t)n.iceTransport=this.transceivers[0].iceTransport,n.dtlsTransport=this.transceivers[0].dtlsTransport;else{var r=this._createIceAndDtlsTransports();n.iceTransport=r.iceTransport,n.dtlsTransport=r.dtlsTransport}return this.transceivers.push(n),n},t.prototype.addTrack=function(e,t){for(var n,r=0;r<this.transceivers.length;r++)this.transceivers[r].track||this.transceivers[r].kind!==e.kind||(n=this.transceivers[r]);return n||(n=this._createTransceiver(e.kind)),n.track=e,n.stream=t,n.rtpSender=new RTCRtpSender(e,n.dtlsTransport),this._maybeFireNegotiationNeeded(),n.rtpSender},t.prototype.addStream=function(t){var n=this;if(e>=15025)this.localStreams.push(t),t.getTracks().forEach(function(e){n.addTrack(e,t)});else{var r=t.clone();t.getTracks().forEach(function(e,t){var n=r.getTracks()[t];e.addEventListener("enabled",function(e){n.enabled=e.enabled})}),r.getTracks().forEach(function(e){n.addTrack(e,r)}),this.localStreams.push(r)}this._maybeFireNegotiationNeeded()},t.prototype.removeStream=function(e){var t=this.localStreams.indexOf(e);t>-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},t.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},t.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},t.prototype._createIceGatherer=function(e,t){var n=this,i=new RTCIceGatherer(n.iceOptions);return i.onlocalcandidate=function(a){var o=new Event("icecandidate");o.candidate={sdpMid:e,sdpMLineIndex:t};var s=a.candidate,c=!s||0===Object.keys(s).length;c?void 0===i.state&&(i.state="completed"):(s.component=1,o.candidate.candidate=r.writeCandidate(s));var d=r.splitSections(n.localDescription.sdp);d[o.candidate.sdpMLineIndex+1]+=c?"a=end-of-candidates\r\n":"a="+o.candidate.candidate+"\r\n",n.localDescription.sdp=d.join("");var l=(n._pendingOffer?n._pendingOffer:n.transceivers).every(function(e){return e.iceGatherer&&"completed"===e.iceGatherer.state});switch(n.iceGatheringState){case"new":c||n._localIceCandidatesBuffer.push(o),c&&l&&n._localIceCandidatesBuffer.push(new Event("icecandidate"));break;case"gathering":n._emitBufferedCandidates(),c||(n.dispatchEvent(o),null!==n.onicecandidate&&n.onicecandidate(o)),l&&(n.dispatchEvent(new Event("icecandidate")),null!==n.onicecandidate&&n.onicecandidate(new Event("icecandidate")),n.iceGatheringState="complete",n._emitGatheringStateChange())}},i},t.prototype._createIceAndDtlsTransports=function(){var e=this,t=new RTCIceTransport(null);t.onicestatechange=function(){e._updateConnectionState()};var n=new RTCDtlsTransport(t);return n.ondtlsstatechange=function(){e._updateConnectionState()},n.onerror=function(){Object.defineProperty(n,"state",{value:"failed",writable:!0}),e._updateConnectionState()},{iceTransport:t,dtlsTransport:n}},t.prototype._disposeIceAndDtlsTransports=function(e){var t=this.transceivers[e].iceGatherer;t&&(delete t.onlocalcandidate,delete this.transceivers[e].iceGatherer);var n=this.transceivers[e].iceTransport;n&&(delete n.onicestatechange,delete this.transceivers[e].iceTransport);var r=this.transceivers[e].dtlsTransport;r&&(delete r.ondtlssttatechange,delete r.onerror,delete this.transceivers[e].dtlsTransport)},t.prototype._transceive=function(t,n,i){var o=a(t.localCapabilities,t.remoteCapabilities);n&&t.rtpSender&&(o.encodings=t.sendEncodingParameters,o.rtcp={cname:r.localCName,compound:t.rtcpParameters.compound},t.recvEncodingParameters.length&&(o.rtcp.ssrc=t.recvEncodingParameters[0].ssrc),t.rtpSender.send(o)),i&&t.rtpReceiver&&("video"===t.kind&&t.recvEncodingParameters&&e<15019&&t.recvEncodingParameters.forEach(function(e){delete e.rtx}),o.encodings=t.recvEncodingParameters,o.rtcp={cname:t.rtcpParameters.cname,compound:t.rtcpParameters.compound},t.sendEncodingParameters.length&&(o.rtcp.ssrc=t.sendEncodingParameters[0].ssrc),t.rtpReceiver.receive(o))},t.prototype.setLocalDescription=function(e){var t,n,i=this;if(!o("setLocalDescription",e.type,this.signalingState)){var s=new Error("Can not set local "+e.type+" in state "+this.signalingState);return s.name="InvalidStateError",arguments.length>2&&"function"==typeof arguments[2]&&window.setTimeout(arguments[2],0,s),Promise.reject(s)}if("offer"===e.type)this._pendingOffer&&(t=r.splitSections(e.sdp),n=t.shift(),t.forEach(function(e,t){var n=r.parseRtpParameters(e);i._pendingOffer[t].localCapabilities=n}),this.transceivers=this._pendingOffer,delete this._pendingOffer);else if("answer"===e.type){t=r.splitSections(i.remoteDescription.sdp),n=t.shift();var c=r.matchPrefix(n,"a=ice-lite").length>0;t.forEach(function(e,t){var o=i.transceivers[t],s=o.iceGatherer,d=o.iceTransport,l=o.dtlsTransport,p=o.localCapabilities,u=o.remoteCapabilities;if(!r.isRejected(e)&&!o.isDatachannel){var h=r.getIceParameters(e,n),f=r.getDtlsParameters(e,n);c&&(f.role="server"),i.usingBundle&&0!==t||(d.start(s,h,c?"controlling":"controlled"),l.start(f));var m=a(p,u);i._transceive(o,m.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var d=arguments.length>1&&"function"==typeof arguments[1];if(d){var l=arguments[1];window.setTimeout(function(){l(),"new"===i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),i._emitBufferedCandidates()},0)}var p=Promise.resolve();return p.then(function(){d||("new"===i.iceGatheringState&&(i.iceGatheringState="gathering",i._emitGatheringStateChange()),window.setTimeout(i._emitBufferedCandidates.bind(i),500))}),p},t.prototype.setRemoteDescription=function(t){var n=this;if(!o("setRemoteDescription",t.type,this.signalingState)){var i=new Error("Can not set remote "+t.type+" in state "+this.signalingState);return i.name="InvalidStateError",arguments.length>2&&"function"==typeof arguments[2]&&window.setTimeout(arguments[2],0,i),Promise.reject(i)}var a={},s=[],c=r.splitSections(t.sdp),d=c.shift(),l=r.matchPrefix(d,"a=ice-lite").length>0,p=r.matchPrefix(d,"a=group:BUNDLE ").length>0;this.usingBundle=p;var u=r.matchPrefix(d,"a=ice-options:")[0];switch(this.canTrickleIceCandidates=!!u&&u.substr(14).split(" ").indexOf("trickle")>=0,c.forEach(function(i,o){var c=r.splitLines(i),u=r.getKind(i),h=r.isRejected(i),f=c[0].substr(2).split(" ")[2],m=r.getDirection(i,d),v=r.parseMsid(i),g=r.getMid(i)||r.generateIdentifier();if("application"!==u||"DTLS/SCTP"!==f){var C,y,b,w,P,_,T,S,R,E,k,x=r.parseRtpParameters(i);h||(E=r.getIceParameters(i,d),(k=r.getDtlsParameters(i,d)).role="client"),T=r.parseRtpEncodingParameters(i);var O=r.parseRtcpParameters(i),D=r.matchPrefix(i,"a=end-of-candidates",d).length>0,M=r.matchPrefix(i,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return"1"===e.component||1===e.component});"offer"!==t.type||h?"answer"!==t.type||h||(p&&o>0&&(n._disposeIceAndDtlsTransports(o),n.transceivers[o].iceGatherer=n.transceivers[0].iceGatherer,n.transceivers[o].iceTransport=n.transceivers[0].iceTransport,n.transceivers[o].dtlsTransport=n.transceivers[0].dtlsTransport,n.transceivers[o].rtpSender&&n.transceivers[o].rtpSender.setTransport(n.transceivers[0].dtlsTransport),n.transceivers[o].rtpReceiver&&n.transceivers[o].rtpReceiver.setTransport(n.transceivers[0].dtlsTransport)),y=(C=n.transceivers[o]).iceGatherer,b=C.iceTransport,w=C.dtlsTransport,P=C.rtpReceiver,_=C.sendEncodingParameters,S=C.localCapabilities,n.transceivers[o].recvEncodingParameters=T,n.transceivers[o].remoteCapabilities=x,n.transceivers[o].rtcpParameters=O,(l||D)&&M.length&&b.setRemoteCandidates(M),p&&0!==o||(b.start(y,E,"controlling"),w.start(k)),n._transceive(C,"sendrecv"===m||"recvonly"===m,"sendrecv"===m||"sendonly"===m),!P||"sendrecv"!==m&&"sendonly"!==m?delete C.rtpReceiver:(R=P.track,v?(a[v.stream]||(a[v.stream]=new MediaStream),a[v.stream].addTrack(R),s.push([R,P,a[v.stream]])):(a.default||(a.default=new MediaStream),a.default.addTrack(R),s.push([R,P,a.default])))):((C=n.transceivers[o]||n._createTransceiver(u)).mid=g,C.iceGatherer||(C.iceGatherer=p&&o>0?n.transceivers[0].iceGatherer:n._createIceGatherer(g,o)),!D||p&&0!==o||C.iceTransport.setRemoteCandidates(M),S=RTCRtpReceiver.getCapabilities(u),e<15019&&(S.codecs=S.codecs.filter(function(e){return"rtx"!==e.name})),_=[{ssrc:1001*(2*o+2)}],"sendrecv"!==m&&"sendonly"!==m||(R=(P=new RTCRtpReceiver(C.dtlsTransport,u)).track,v?(a[v.stream]||(a[v.stream]=new MediaStream,Object.defineProperty(a[v.stream],"id",{get:function(){return v.stream}})),Object.defineProperty(R,"id",{get:function(){return v.track}}),a[v.stream].addTrack(R),s.push([R,P,a[v.stream]])):(a.default||(a.default=new MediaStream),a.default.addTrack(R),s.push([R,P,a.default]))),C.localCapabilities=S,C.remoteCapabilities=x,C.rtpReceiver=P,C.rtcpParameters=O,C.sendEncodingParameters=_,C.recvEncodingParameters=T,n._transceive(n.transceivers[o],!1,"sendrecv"===m||"sendonly"===m))}else n.transceivers[o]={mid:g,isDatachannel:!0}}),this.remoteDescription={type:t.type,sdp:t.sdp},t.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+t.type+'"')}return Object.keys(a).forEach(function(e){var t=a[e];if(t.getTracks().length){n.remoteStreams.push(t);var r=new Event("addstream");r.stream=t,n.dispatchEvent(r),null!==n.onaddstream&&window.setTimeout(function(){n.onaddstream(r)},0),s.forEach(function(e){var r=e[0],i=e[1];if(t.id===e[2].id){var a=new Event("track");a.track=r,a.receiver=i,a.streams=[t],n.dispatchEvent(a),null!==n.ontrack&&window.setTimeout(function(){n.ontrack(a)},0)}})}}),window.setTimeout(function(){n&&n.transceivers&&n.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),arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},t.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._updateSignalingState("closed")},t.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),null!==this.onsignalingstatechange&&this.onsignalingstatechange(t)},t.prototype._maybeFireNegotiationNeeded=function(){var e=this;"stable"===this.signalingState&&!0!==this.needNegotiation&&(this.needNegotiation=!0,window.setTimeout(function(){if(!1!==e.needNegotiation){e.needNegotiation=!1;var t=new Event("negotiationneeded");e.dispatchEvent(t),null!==e.onnegotiationneeded&&e.onnegotiationneeded(t)}},0))},t.prototype._updateConnectionState=function(){var e,t={new:0,closed:0,connecting:0,checking:0,connected:0,completed:0,failed:0};if(this.transceivers.forEach(function(e){t[e.iceTransport.state]++,t[e.dtlsTransport.state]++}),t.connected+=t.completed,e="new",t.failed>0?e="failed":t.connecting>0||t.checking>0?e="connecting":t.disconnected>0?e="disconnected":t.new>0?e="new":(t.connected>0||t.completed>0)&&(e="connected"),e!==this.iceConnectionState){this.iceConnectionState=e;var n=new Event("iceconnectionstatechange");this.dispatchEvent(n),null!==this.oniceconnectionstatechange&&this.oniceconnectionstatechange(n)}},t.prototype.createOffer=function(){var t,n=this;if(this._pendingOffer)throw new Error("createOffer called while there is a pending offer.");1===arguments.length&&"function"!=typeof arguments[0]?t=arguments[0]:3===arguments.length&&(t=arguments[2]);var a=this.transceivers.filter(function(e){return"audio"===e.kind}).length,o=this.transceivers.filter(function(e){return"video"===e.kind}).length;if(t){if(t.mandatory||t.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==t.offerToReceiveAudio&&(a=!0===t.offerToReceiveAudio?1:!1===t.offerToReceiveAudio?0:t.offerToReceiveAudio),void 0!==t.offerToReceiveVideo&&(o=!0===t.offerToReceiveVideo?1:!1===t.offerToReceiveVideo?0:t.offerToReceiveVideo)}for(this.transceivers.forEach(function(e){"audio"===e.kind?--a<0&&(e.wantReceive=!1):"video"===e.kind&&--o<0&&(e.wantReceive=!1)});a>0||o>0;)a>0&&(this._createTransceiver("audio"),a--),o>0&&(this._createTransceiver("video"),o--);var s=i(this.transceivers),c=r.writeSessionBoilerplate();s.forEach(function(t,i){var a=t.track,o=t.kind,c=r.generateIdentifier();t.mid=c,t.iceGatherer||(t.iceGatherer=n.usingBundle&&i>0?s[0].iceGatherer:n._createIceGatherer(c,i));var d=RTCRtpSender.getCapabilities(o);e<15019&&(d.codecs=d.codecs.filter(function(e){return"rtx"!==e.name})),d.codecs.forEach(function(e){"H264"===e.name&&void 0===e.parameters["level-asymmetry-allowed"]&&(e.parameters["level-asymmetry-allowed"]="1")});var l=[{ssrc:1001*(2*i+1)}];a&&e>=15019&&"video"===o&&(l[0].rtx={ssrc:1001*(2*i+1)+1}),t.wantReceive&&(t.rtpReceiver=new RTCRtpReceiver(t.dtlsTransport,o)),t.localCapabilities=d,t.sendEncodingParameters=l}),"max-compat"!==this._config.bundlePolicy&&(c+="a=group:BUNDLE "+s.map(function(e){return e.mid}).join(" ")+"\r\n"),c+="a=ice-options:trickle\r\n",s.forEach(function(e,t){c+=r.writeMediaSection(e,e.localCapabilities,"offer",e.stream),c+="a=rtcp-rsize\r\n"}),this._pendingOffer=s;var d=new RTCSessionDescription({type:"offer",sdp:c});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,d),Promise.resolve(d)},t.prototype.createAnswer=function(){var t=r.writeSessionBoilerplate();this.usingBundle&&(t+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),this.transceivers.forEach(function(n,i){if(n.isDatachannel)t+="m=application 0 DTLS/SCTP 5000\r\nc=IN IP4 0.0.0.0\r\na=mid:"+n.mid+"\r\n";else{var o;if(n.stream)"audio"===n.kind?o=n.stream.getAudioTracks()[0]:"video"===n.kind&&(o=n.stream.getVideoTracks()[0]),o&&e>=15019&&"video"===n.kind&&(n.sendEncodingParameters[0].rtx={ssrc:1001*(2*i+2)+1});var s=a(n.localCapabilities,n.remoteCapabilities);!s.codecs.filter(function(e){return"rtx"===e.name.toLowerCase()}).length&&n.sendEncodingParameters[0].rtx&&delete n.sendEncodingParameters[0].rtx,t+=r.writeMediaSection(n,s,"answer",n.stream),n.rtcpParameters&&n.rtcpParameters.reducedSize&&(t+="a=rtcp-rsize\r\n")}});var n=new RTCSessionDescription({type:"answer",sdp:t});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,n),Promise.resolve(n)},t.prototype.addIceCandidate=function(e){if(e){var t=e.sdpMLineIndex;if(e.sdpMid)for(var n=0;n<this.transceivers.length;n++)if(this.transceivers[n].mid===e.sdpMid){t=n;break}var i=this.transceivers[t];if(i){var a=Object.keys(e.candidate).length>0?r.parseCandidate(e.candidate):{};if("tcp"===a.protocol&&(0===a.port||9===a.port))return Promise.resolve();if(a.component&&"1"!==a.component&&1!==a.component)return Promise.resolve();i.iceTransport.addRemoteCandidate(a);var o=r.splitSections(this.remoteDescription.sdp);o[t+1]+=(a.type?e.candidate.trim():"a=end-of-candidates")+"\r\n",this.remoteDescription.sdp=o.join("")}}else for(var s=0;s<this.transceivers.length;s++)if(this.transceivers[s].iceTransport.addRemoteCandidate({}),this.usingBundle)return Promise.resolve();return arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},t.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1],n=function(e){return{inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"}[e.type]||e.type};return new Promise(function(r){var i=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){e[t].type=n(e[t]),i.set(t,e[t])})}),t&&window.setTimeout(t,0,i),r(i)})})},t}},23:function(e,t,n){"use strict";var r={generateIdentifier:function(){return Math.random().toString(36).substr(2,10)}};r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){return e.split("\nm=").map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){for(var t,n={foundation:(t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" "))[0],component:t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r<t.length;r+=2)switch(t[r]){case"raddr":n.relatedAddress=t[r+1];break;case"rport":n.relatedPort=parseInt(t[r+1],10);break;case"tcptype":n.tcpType=t[r+1];break;default:n[t[r]]=t[r+1]}return n},r.writeCandidate=function(e){var t=[];t.push(e.foundation),t.push(e.component),t.push(e.protocol.toUpperCase()),t.push(e.priority),t.push(e.ip),t.push(e.port);var n=e.type;return t.push("typ"),t.push(n),"host"!==n&&e.relatedAddress&&e.relatedPort&&(t.push("raddr"),t.push(e.relatedAddress),t.push("rport"),t.push(e.relatedPort)),e.tcpType&&"tcp"===e.protocol.toLowerCase()&&(t.push("tcptype"),t.push(e.tcpType)),"candidate:"+t.join(" ")},r.parseIceOptions=function(e){return e.substr(14).split(" ")},r.parseRtpMap=function(e){var t=e.substr(9).split(" "),n={payloadType:parseInt(t.shift(),10)};return t=t[0].split("/"),n.name=t[0],n.clockRate=parseInt(t[1],10),n.numChannels=3===t.length?parseInt(t[2],10):1,n},r.writeRtpMap=function(e){var t=e.payloadType;return void 0!==e.preferredPayloadType&&(t=e.preferredPayloadType),"a=rtpmap:"+t+" "+e.name+"/"+e.clockRate+(1!==e.numChannels?"/"+e.numChannels:"")+"\r\n"},r.parseExtmap=function(e){var t=e.substr(9).split(" ");return{id:parseInt(t[0],10),direction:t[0].indexOf("/")>0?t[0].split("/")[1]:"sendrecv",uri:t[1]}},r.writeExtmap=function(e){return"a=extmap:"+(e.id||e.preferredId)+(e.direction&&"sendrecv"!==e.direction?"/"+e.direction:"")+" "+e.uri+"\r\n"},r.parseFmtp=function(e){for(var t,n={},r=e.substr(e.indexOf(" ")+1).split(";"),i=0;i<r.length;i++)n[(t=r[i].trim().split("="))[0].trim()]=t[1];return n},r.writeFmtp=function(e){var t="",n=e.payloadType;if(void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.parameters&&Object.keys(e.parameters).length){var r=[];Object.keys(e.parameters).forEach(function(t){r.push(t+"="+e.parameters[t])}),t+="a=fmtp:"+n+" "+r.join(";")+"\r\n"}return t},r.parseRtcpFb=function(e){var t=e.substr(e.indexOf(" ")+1).split(" ");return{type:t.shift(),parameter:t.join(" ")}},r.writeRtcpFb=function(e){var t="",n=e.payloadType;return void 0!==e.preferredPayloadType&&(n=e.preferredPayloadType),e.rtcpFeedback&&e.rtcpFeedback.length&&e.rtcpFeedback.forEach(function(e){t+="a=rtcp-fb:"+n+" "+e.type+(e.parameter&&e.parameter.length?" "+e.parameter:"")+"\r\n"}),t},r.parseSsrcMedia=function(e){var t=e.indexOf(" "),n={ssrc:parseInt(e.substr(7,t-7),10)},r=e.indexOf(":",t);return r>-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getMid=function(e){var t=r.matchPrefix(e,"a=mid:")[0];if(t)return t.substr(6)},r.parseFingerprint=function(e){var t=e.substr(14).split(" ");return{algorithm:t[0].toLowerCase(),value:t[1]}},r.getDtlsParameters=function(e,t){return{role:"auto",fingerprints:r.matchPrefix(e+t,"a=fingerprint:").map(r.parseFingerprint)}},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);return{usernameFragment:(n=n.concat(r.splitLines(t))).filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)}},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e)[0].split(" "),i=3;i<n.length;i++){var a=n[i],o=r.matchPrefix(e,"a=rtpmap:"+a+" ")[0];if(o){var s=r.parseRtpMap(o),c=r.matchPrefix(e,"a=fmtp:"+a+" ");switch(s.parameters=c.length?r.parseFmtp(c[0]):{},s.rtcpFeedback=r.matchPrefix(e,"a=rtcp-fb:"+a+" ").map(r.parseRtcpFb),t.codecs.push(s),s.name.toUpperCase()){case"RED":case"ULPFEC":t.fecMechanisms.push(s.name.toUpperCase())}}}return r.matchPrefix(e,"a=extmap:").forEach(function(e){t.headerExtensions.push(r.parseExtmap(e))}),t},r.writeRtpDescription=function(e,t){var n="";n+="m="+e+" ",n+=t.codecs.length>0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)});var i=0;return t.codecs.forEach(function(e){e.maxptime>i&&(i=e.maxptime)}),i>0&&(n+="a=maxptime:"+i+"\r\n"),n+="a=rtcp-mux\r\n",t.headerExtensions.forEach(function(e){n+=r.writeExtmap(e)}),n},r.parseRtpEncodingParameters=function(e){var t,n=[],i=r.parseRtpParameters(e),a=-1!==i.fecMechanisms.indexOf("RED"),o=-1!==i.fecMechanisms.indexOf("ULPFEC"),s=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),c=s.length>0&&s[0].ssrc,d=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});d.length>0&&d[0].length>1&&d[0][0]===c&&(t=d[0][1]),i.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:c,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{ssrc:t}};n.push(r),a&&((r=JSON.parse(JSON.stringify(r))).fec={ssrc:t,mechanism:o?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&c&&n.push({ssrc:c});var l=r.matchPrefix(e,"b=");return l.length&&(0===l[0].indexOf("b=TIAS:")?l=parseInt(l[0].substr(7),10):0===l[0].indexOf("b=AS:")&&(l=parseInt(l[0].substr(5),10)),n.forEach(function(e){e.maxBitrate=l})),n},r.parseRtcpParameters=function(e){var t={},n=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];n&&(t.cname=n.value,t.ssrc=n.ssrc);var i=r.matchPrefix(e,"a=rtcp-rsize");t.reducedSize=i.length>0,t.compound=0===i.length;var a=r.matchPrefix(e,"a=rtcp-mux");return t.mux=a.length>0,t},r.parseMsid=function(e){var t,n=r.matchPrefix(e,"a=msid:");if(1===n.length)return{stream:(t=n[0].substr(7).split(" "))[0],track:t[1]};var i=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"msid"===e.attribute});return i.length>0?{stream:(t=i[0].value.split(" "))[0],track:t[1]}:void 0},r.writeSessionBoilerplate=function(){return"v=0\r\no=thisisadapterortc 8169639915646943137 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,i){var a=r.writeRtpDescription(e.kind,t);if(a+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),a+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),a+="a=mid:"+e.mid+"\r\n",e.direction?a+="a="+e.direction+"\r\n":e.rtpSender&&e.rtpReceiver?a+="a=sendrecv\r\n":e.rtpSender?a+="a=sendonly\r\n":e.rtpReceiver?a+="a=recvonly\r\n":a+="a=inactive\r\n",e.rtpSender){var o="msid:"+i.id+" "+e.rtpSender.track.id+"\r\n";a+="a="+o,a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+o,e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" "+o,a+="a=ssrc-group:FID "+e.sendEncodingParameters[0].ssrc+" "+e.sendEncodingParameters[0].rtx.ssrc+"\r\n")}return a+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n",e.rtpSender&&e.sendEncodingParameters[0].rtx&&(a+="a=ssrc:"+e.sendEncodingParameters[0].rtx.ssrc+" cname:"+r.localCName+"\r\n"),a},r.getDirection=function(e,t){for(var n=r.splitLines(e),i=0;i<n.length;i++)switch(n[i]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return n[i].substr(2)}return t?r.getDirection(t):"sendrecv"},r.getKind=function(e){return r.splitLines(e)[0].split(" ")[0].substr(2)},r.isRejected=function(e){return"0"===e.split(" ",2)[1]},e.exports=r},24:function(e,t,n){"use strict";e.exports=function(){var e=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(t){return e(t).catch(function(e){return Promise.reject(function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}}(e))})}}},25:function(e,t,n){"use strict";var r=n(3).browserDetails,i={shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(){if("object"==typeof window&&(window.RTCPeerConnection||window.mozRTCPeerConnection)){window.RTCPeerConnection||(window.RTCPeerConnection=function(e,t){if(r.version<38&&e&&e.iceServers){for(var n=[],i=0;i<e.iceServers.length;i++){var a=e.iceServers[i];if(a.hasOwnProperty("urls"))for(var o=0;o<a.urls.length;o++){var s={url:a.urls[o]};0===a.urls[o].indexOf("turn")&&(s.username=a.username,s.credential=a.credential),n.push(s)}else n.push(e.iceServers[i])}e.iceServers=n}return new mozRTCPeerConnection(e,t)},window.RTCPeerConnection.prototype=mozRTCPeerConnection.prototype,mozRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return mozRTCPeerConnection.generateCertificate}}),window.RTCSessionDescription=mozRTCSessionDescription,window.RTCIceCandidate=mozRTCIceCandidate),["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=RTCPeerConnection.prototype[e];RTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}});var e=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?e.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())};var t={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},n=RTCPeerConnection.prototype.getStats;RTCPeerConnection.prototype.getStats=function(e,i,a){return n.apply(this,[e||null]).then(function(e){if(r.version<48&&(e=function(e){var t=new Map;return Object.keys(e).forEach(function(n){t.set(n,e[n]),t[n]=e[n]}),t}(e)),r.version<53&&!i)try{e.forEach(function(e){e.type=t[e.type]||e.type})}catch(n){if("TypeError"!==n.name)throw n;e.forEach(function(n,r){e.set(r,Object.assign({},n,{type:t[n.type]||n.type}))})}return e}).then(i,a)}}}};e.exports={shimOnTrack:i.shimOnTrack,shimSourceObject:i.shimSourceObject,shimPeerConnection:i.shimPeerConnection,shimGetUserMedia:n(26)}},26:function(e,t,n){"use strict";var r=n(3).log,i=n(3).browserDetails;e.exports=function(){var e=function(e){return{name:{InternalError:"NotReadableError",NotSupportedError:"TypeError",PermissionDeniedError:"NotAllowedError",SecurityError:"NotAllowedError"}[e.name]||e.name,message:{"The operation is insecure.":"The request is not allowed by the user agent or the platform in the current context."}[e.message]||e.message,constraint:e.constraint,toString:function(){return this.name+(this.message&&": ")+this.message}}},t=function(t,n,a){var o=function(e){if("object"!=typeof e||e.require)return e;var t=[];return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r=e[n]="object"==typeof e[n]?e[n]:{ideal:e[n]};if(void 0===r.min&&void 0===r.max&&void 0===r.exact||t.push(n),void 0!==r.exact&&("number"==typeof r.exact?r.min=r.max=r.exact:e[n]=r.exact,delete r.exact),void 0!==r.ideal){e.advanced=e.advanced||[];var i={};"number"==typeof r.ideal?i[n]={min:r.ideal,max:r.ideal}:i[n]=r.ideal,e.advanced.push(i),delete r.ideal,Object.keys(r).length||delete e[n]}}}),t.length&&(e.require=t),e};return t=JSON.parse(JSON.stringify(t)),i.version<38&&(r("spec: "+JSON.stringify(t)),t.audio&&(t.audio=o(t.audio)),t.video&&(t.video=o(t.video)),r("ff37: "+JSON.stringify(t))),navigator.mozGetUserMedia(t,n,function(t){a(e(t))})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:function(e){return new Promise(function(n,r){t(e,n,r)})},addEventListener:function(){},removeEventListener:function(){}}),navigator.mediaDevices.enumerateDevices=navigator.mediaDevices.enumerateDevices||function(){return new Promise(function(e){e([{kind:"audioinput",deviceId:"default",label:"",groupId:""},{kind:"videoinput",deviceId:"default",label:"",groupId:""}])})},i.version<41){var n=navigator.mediaDevices.enumerateDevices.bind(navigator.mediaDevices);navigator.mediaDevices.enumerateDevices=function(){return n().then(void 0,function(e){if("NotFoundError"===e.name)return[];throw e})}}if(i.version<49){var a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(t){return a(t).then(function(e){if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(function(e){e.stop()}),new DOMException("The object can not be found here.","NotFoundError");return e},function(t){return Promise.reject(e(t))})}}navigator.getUserMedia=function(e,n,r){if(i.version<44)return t(e,n,r);console.warn("navigator.getUserMedia has been replaced by navigator.mediaDevices.getUserMedia"),navigator.mediaDevices.getUserMedia(e).then(n,r)}}},27:function(e,t,n){"use strict";var r={shimAddStream:function(){"object"!=typeof window||!window.RTCPeerConnection||"addStream"in window.RTCPeerConnection.prototype||(RTCPeerConnection.prototype.addStream=function(e){var t=this;e.getTracks().forEach(function(n){t.addTrack(n,e)})})},shimOnAddStream:function(){"object"!=typeof window||!window.RTCPeerConnection||"onaddstream"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"onaddstream",{get:function(){return this._onaddstream},set:function(e){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=e),this.addEventListener("track",this._onaddstreampoly=function(e){var t=e.streams[0];if(this._streams||(this._streams=[]),!(this._streams.indexOf(t)>=0)){this._streams.push(t);var n=new Event("addstream");n.stream=e.streams[0],this.dispatchEvent(n)}}.bind(this))}})},shimCallbacksAPI:function(){if("object"==typeof window&&window.RTCPeerConnection){var e=RTCPeerConnection.prototype,t=e.createOffer,n=e.createAnswer,r=e.setLocalDescription,i=e.setRemoteDescription,a=e.addIceCandidate;e.createOffer=function(e,n){var r=arguments.length>=2?arguments[2]:arguments[0],i=t.apply(this,[r]);return n?(i.then(e,n),Promise.resolve()):i},e.createAnswer=function(e,t){var r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i};var o=function(e,t,n){var i=r.apply(this,[e]);return n?(i.then(t,n),Promise.resolve()):i};e.setLocalDescription=o,o=function(e,t,n){var r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},e.setRemoteDescription=o,o=function(e,t,n){var r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},e.addIceCandidate=o}},shimGetUserMedia:function(){navigator.getUserMedia||(navigator.webkitGetUserMedia?navigator.getUserMedia=navigator.webkitGetUserMedia.bind(navigator):navigator.mediaDevices&&navigator.mediaDevices.getUserMedia&&(navigator.getUserMedia=function(e,t,n){navigator.mediaDevices.getUserMedia(e).then(t,n)}.bind(navigator)))}};e.exports={shimCallbacksAPI:r.shimCallbacksAPI,shimAddStream:r.shimAddStream,shimOnAddStream:r.shimOnAddStream,shimGetUserMedia:r.shimGetUserMedia}},3:function(e,t,n){"use strict";var r=!0,i={disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},extractVersion:function(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)},detectBrowser:function(){var e={browser:null,version:null};if("undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;if(navigator.mozGetUserMedia)e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/(\d+)\./,1);else if(navigator.webkitGetUserMedia)if(window.webkitRTCPeerConnection)e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else{if(!navigator.userAgent.match(/Version\/(\d+).(\d+)/))return e.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1)}else if(navigator.mediaDevices&&navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2);else{if(!navigator.mediaDevices||!navigator.userAgent.match(/AppleWebKit\/(\d+)\./))return e.browser="Not a supported browser.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/(\d+)\./,1)}return e},shimCreateObjectURL:function(){if("object"==typeof window&&window.HTMLMediaElement&&"srcObject"in window.HTMLMediaElement.prototype){var e=URL.createObjectURL.bind(URL),t=URL.revokeObjectURL.bind(URL),n=new Map,r=0;URL.createObjectURL=function(t){if("getTracks"in t){var i="polyblob:"+ ++r;return n.set(i,t),console.log("URL.createObjectURL(stream) is deprecated! Use elem.srcObject = stream instead!"),i}return e(t)},URL.revokeObjectURL=function(e){t(e),n.delete(e)};var i=Object.getOwnPropertyDescriptor(window.HTMLMediaElement.prototype,"src");Object.defineProperty(window.HTMLMediaElement.prototype,"src",{get:function(){return i.get.apply(this)},set:function(e){return this.srcObject=n.get(e)||null,i.set.apply(this,[e])}});var a=HTMLMediaElement.prototype.setAttribute;HTMLMediaElement.prototype.setAttribute=function(){return 2===arguments.length&&"src"===(""+arguments[0]).toLowerCase()&&(this.srcObject=n.get(arguments[1])||null),a.apply(this,arguments)}}}};e.exports={log:i.log,disableLog:i.disableLog,browserDetails:i.detectBrowser(),extractVersion:i.extractVersion,shimCreateObjectURL:i.shimCreateObjectURL,detectBrowser:i.detectBrowser.bind(i)}},95:function(e,t,n){"use strict";n.r(t),n.d(t,"default",function(){return i});var r=n(14);class i{constructor(){}_start(e,t,n,r){if(!e)throw new Error("The runtimeProtoStubURL is a required parameter");if(!t)throw new Error("The bus is a required parameter");if(!n)throw new Error("The configuration is a required parameter");console.log("[P2PHandlerProtoStub.constructor] config is: ",n),this._runtimeProtoStubURL=e,this._runtimeURL=n.runtimeURL,this._configuration=n,this._bus=t,this._bus.addListener("*",e=>{this._sendChannelMsg(e)}),this._connectionControllers={},this._syncher=r.createSyncher(e,t,n),this._syncher.onNotification(e=>{switch(console.log("+[P2PHandlerProtoStub] On Syncher Notification ",e),e.ack(200),e.type){case"create":this._sendStatus("create",void 0,e.value.runtime),this._createConnectionController(e).then(t=>{this._connectionControllers[e.value.runtime]=t,t.onStatusUpdate((n,r,i)=>{this._sendStatus(n,r,i),"disconnected"===n&&(t.cleanup(),delete this._connectionControllers[e.value.runtime])}),t.onMessage(e=>{this._deliver(e)})});break;case"delete":console.log("+[P2PHandlerStub] deleting connection handler for "+e.from);let t=this._connectionControllers[e.from];t&&(t.cleanup(),delete this._connectionControllers[e.from])}})}disconnect(){Object.keys(this._connectionControllers).forEach(e=>{this._controllers[e].cleanup(),delete this._controllers[e]})}_createConnectionController(e){return new Promise((t,n)=>{let i=new r.a(this._runtimeProtoStubURL,this._syncher,this._configuration,!1);i.observe(e).then(()=>{console.log("+[P2PHandlerStub] observer setup successful"),i.report(e.from,this._runtimeURL).then(()=>{console.log("+[P2PHandlerStub] reporter setup successful"),this._sendStatus("in-progress",void 0,e.value.runtime),t(i)})})})}_sendChannelMsg(e){if(this._filter(e)){let t=this._connectionControllers[e.body.peer];t&&t.sendMessage(e)}}_sendStatus(e,t,n){let r={type:"update",from:this._runtimeProtoStubURL,to:this._runtimeProtoStubURL+"/status",body:{value:e}};n&&(r.body.resource=n),t&&(r.body.desc=t),console.log("+[P2PHandlerStub] sending status update: ",r),this._bus.postMessage(r)}_filter(e){return!e.body||e.body.via!==this._runtimeProtoStubURL}_deliver(e){console.log("+[P2PHandlerStub] posting message to msg bus: ",e),e.body||(e.body={}),e.body.via=this._runtimeProtoStubURL,this._bus.postMessage(e)}}}}))}}});