text: !function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports.PeerConnector=t():e.PeerConnector=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.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 o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));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=7)}([function(e,t,n){e.exports=n(28)},function(e,t,n){"use strict";var r,o,i,a,c,s,u,f=n(8),l=n(25),h=Function.prototype.apply,d=Function.prototype.call,p=Object.create,v=Object.defineProperty,y=Object.defineProperties,m=Object.prototype.hasOwnProperty,w={configurable:!0,enumerable:!1,writable:!0};o=function(e,t){var n,o;return l(t),o=this,r.call(this,e,n=function(){i.call(o,e,n),h.call(t,this,arguments)}),n.__eeOnceListener__=t,this},c={on:r=function(e,t){var n;return l(t),m.call(this,"__ee__")?n=this.__ee__:(n=w.value=p(null),v(this,"__ee__",w),w.value=null),n[e]?"object"===typeof n[e]?n[e].push(t):n[e]=[n[e],t]:n[e]=t,this},once:o,off:i=function(e,t){var n,r,o,i;if(l(t),!m.call(this,"__ee__"))return this;if(!(n=this.__ee__)[e])return this;if("object"===typeof(r=n[e]))for(i=0;o=r[i];++i)o!==t&&o.__eeOnceListener__!==t||(2===r.length?n[e]=r[i?0:1]:r.splice(i,1));else r!==t&&r.__eeOnceListener__!==t||delete n[e];return this},emit:a=function(e){var t,n,r,o,i;if(m.call(this,"__ee__")&&(o=this.__ee__[e]))if("object"===typeof o){for(n=arguments.length,i=new Array(n-1),t=1;t<n;++t)i[t-1]=arguments[t];for(o=o.slice(),t=0;r=o[t];++t)h.call(r,this,i)}else switch(arguments.length){case 1:d.call(o,this);break;case 2:d.call(o,this,arguments[1]);break;case 3:d.call(o,this,arguments[1],arguments[2]);break;default:for(n=arguments.length,i=new Array(n-1),t=1;t<n;++t)i[t-1]=arguments[t];h.call(o,this,i)}}},s={on:f(r),once:f(o),off:f(i),emit:f(a)},u=y({},s),e.exports=t=function(e){return null==e?p(u):y(Object(e),s)},t.methods=c},function(e,t,n){"use strict";var r=n(26),o=Object.prototype.hasOwnProperty;e.exports=function(e){var t,n=arguments[1];if(r(e),void 0===n)o.call(e,"__ee__")&&delete e.__ee__;else{if(!(t=o.call(e,"__ee__")&&e.__ee__))return;t[n]&&delete t[n]}}},function(e,t,n){var r=self.crypto||self.msCrypto;e.exports=function(e){e=e||21;for(var t="",n=r.getRandomValues(new Uint8Array(e));e--;)t+="QLUint8ARdomValuesObj0h6345-79BCrypgJzHKTNYDSMkXPZ_FfG1WcqvwxEI2"[63&n[e]];return t}},function(e,t,n){"use strict";var r=n(19)();e.exports=function(e){return e!==r&&null!==e}},function(e,t,n){"use strict";e.exports=function(e){return void 0!==e&&null!==e}},function(e,t,n){"use strict";(function(e){var n=this&&this.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,c=i.length;a<c;a++,o++)r[o]=i[a];return r};Object.defineProperty(t,"__esModule",{value:!0});var r=function(e,t,n){this.name=e,this.version=t,this.os=n};t.BrowserInfo=r;var o=function(t){this.version=t,this.name="node",this.os=e.platform};t.NodeInfo=o;var i=function(){this.bot=!0,this.name="bot",this.version=null,this.os=null};t.BotInfo=i;var a=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["vivaldi",/Vivaldi\/([0-9\.]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/Edg\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FBAV\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],c=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/],["Search Bot",/(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves\/Teoma)|(ia_archiver)/]];function s(e){var t=""!==e&&a.reduce((function(t,n){var r=n[0],o=n[1];if(t)return t;var i=o.exec(e);return!!i&&[r,i]}),!1);if(!t)return null;var o=t[0],c=t[1];if("searchbot"===o)return new i;var s=c[1]&&c[1].split(/[._]/).slice(0,3);return s?s.length<3&&(s=n(s,function(e){for(var t=[],n=0;n<e;n++)t.push("0");return t}(3-s.length))):s=[],new r(o,s.join("."),u(e))}function u(e){for(var t=0,n=c.length;t<n;t++){var r=c[t],o=r[0];if(r[1].test(e))return o}return null}function f(){return"undefined"!==typeof e&&e.version?new o(e.version.slice(1)):null}t.detect=function(e){return e?s(e):"undefined"!==typeof navigator?s(navigator.userAgent):f()},t.parseUserAgent=s,t.detectOS=u,t.getNodeVersion=f}).call(this,n(29))},function(e,t,n){e.exports=n(30)},function(e,t,n){"use strict";var r=n(5),o=n(9),i=n(13),a=n(21),c=n(22);(e.exports=function(e,t){var n,o,s,u,f;return arguments.length<2||"string"!==typeof e?(u=t,t=e,e=null):u=arguments[2],r(e)?(n=c.call(e,"c"),o=c.call(e,"e"),s=c.call(e,"w")):(n=s=!0,o=!1),f={value:t,configurable:n,enumerable:o,writable:s},u?i(a(u),f):f}).gs=function(e,t,n){var s,u,f,l;return"string"!==typeof e?(f=n,n=t,t=e,e=null):f=arguments[3],r(t)?o(t)?r(n)?o(n)||(f=n,n=void 0):n=void 0:(f=t,t=n=void 0):t=void 0,r(e)?(s=c.call(e,"c"),u=c.call(e,"e")):(s=!0,u=!1),l={get:t,set:n,configurable:s,enumerable:u},f?i(a(f),l):l}},function(e,t,n){"use strict";var r=n(10),o=/^\s*class[\s{/}]/,i=Function.prototype.toString;e.exports=function(e){return!!r(e)&&!o.test(i.call(e))}},function(e,t,n){"use strict";var r=n(11);e.exports=function(e){if("function"!==typeof e)return!1;if(!hasOwnProperty.call(e,"length"))return!1;try{if("number"!==typeof e.length)return!1;if("function"!==typeof e.call)return!1;if("function"!==typeof e.apply)return!1}catch(t){return!1}return!r(e)}},function(e,t,n){"use strict";var r=n(12);e.exports=function(e){if(!r(e))return!1;try{return!!e.constructor&&e.constructor.prototype===e}catch(t){return!1}}},function(e,t,n){"use strict";var r=n(5),o={object:!0,function:!0,undefined:!0};e.exports=function(e){return!!r(e)&&hasOwnProperty.call(o,typeof e)}},function(e,t,n){"use strict";e.exports=n(14)()?Object.assign:n(15)},function(e,t,n){"use strict";e.exports=function(){var e,t=Object.assign;return"function"===typeof t&&(t(e={foo:"raz"},{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},function(e,t,n){"use strict";var r=n(16),o=n(20),i=Math.max;e.exports=function(e,t){var n,a,c,s=i(arguments.length,2);for(e=Object(o(e)),c=function(r){try{e[r]=t[r]}catch(o){n||(n=o)}},a=1;a<s;++a)t=arguments[a],r(t).forEach(c);if(void 0!==n)throw n;return e}},function(e,t,n){"use strict";e.exports=n(17)()?Object.keys:n(18)},function(e,t,n){"use strict";e.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},function(e,t,n){"use strict";var r=n(4),o=Object.keys;e.exports=function(e){return o(r(e)?Object(e):e)}},function(e,t,n){"use strict";e.exports=function(){}},function(e,t,n){"use strict";var r=n(4);e.exports=function(e){if(!r(e))throw new TypeError("Cannot use null or undefined");return e}},function(e,t,n){"use strict";var r=n(4),o=Array.prototype.forEach,i=Object.create,a=function(e,t){var n;for(n in e)t[n]=e[n]};e.exports=function(e){var t=i(null);return o.call(arguments,(function(e){r(e)&&a(Object(e),t)})),t}},function(e,t,n){"use strict";e.exports=n(23)()?String.prototype.contains:n(24)},function(e,t,n){"use strict";var r="razdwatrzy";e.exports=function(){return"function"===typeof r.contains&&(!0===r.contains("dwa")&&!1===r.contains("foo"))}},function(e,t,n){"use strict";var r=String.prototype.indexOf;e.exports=function(e){return r.call(this,e,arguments[1])>-1}},function(e,t,n){"use strict";e.exports=function(e){if("function"!==typeof e)throw new TypeError(e+" is not a function");return e}},function(e,t,n){"use strict";var r=n(27);e.exports=function(e){if(!r(e))throw new TypeError(e+" is not an Object");return e}},function(e,t,n){"use strict";var r=n(4),o={function:!0,object:!0};e.exports=function(e){return r(e)&&o[typeof e]||!1}},function(e,t,n){var r=function(e){"use strict";var t=Object.prototype,n=t.hasOwnProperty,r="function"===typeof Symbol?Symbol:{},o=r.iterator||"@@iterator",i=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function c(e,t,n,r){var o=t&&t.prototype instanceof f?t:f,i=Object.create(o.prototype),a=new S(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return O()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=g(a,n);if(c){if(c===u)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var f=s(e,t,n);if("normal"===f.type){if(r=n.done?"completed":"suspendedYield",f.arg===u)continue;return{value:f.arg,done:n.done}}"throw"===f.type&&(r="completed",n.method="throw",n.arg=f.arg)}}}(e,n,a),i}function s(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(r){return{type:"throw",arg:r}}}e.wrap=c;var u={};function f(){}function l(){}function h(){}var d={};d[o]=function(){return this};var p=Object.getPrototypeOf,v=p&&p(p(x([])));v&&v!==t&&n.call(v,o)&&(d=v);var y=h.prototype=f.prototype=Object.create(d);function m(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function w(e){var t;this._invoke=function(r,o){function i(){return new Promise((function(t,i){!function t(r,o,i,a){var c=s(e[r],e,o);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"===typeof f&&n.call(f,"__await")?Promise.resolve(f.__await).then((function(e){t("next",e,i,a)}),(function(e){t("throw",e,i,a)})):Promise.resolve(f).then((function(e){u.value=e,i(u)}),(function(e){return t("throw",e,i,a)}))}a(c.arg)}(r,o,t,i)}))}return t=t?t.then(i,i):i()}}function g(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,g(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var r=s(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,u;var o=r.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function b(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function x(e){if(e){var t=e[o];if(t)return t.call(e);if("function"===typeof e.next)return e;if(!isNaN(e.length)){var r=-1,i=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return l.prototype=y.constructor=h,h.constructor=l,h[a]=l.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"===typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,a in e||(e[a]="GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},m(w.prototype),w.prototype[i]=function(){return this},e.AsyncIterator=w,e.async=function(t,n,r,o){var i=new w(c(t,n,r,o));return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},m(y),y[a]="Generator",y[o]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=x,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(b),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),b(n),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;b(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:x(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),u}},e}(e.exports);try{regeneratorRuntime=r}catch(o){Function("r","regeneratorRuntime = r")(r)}},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"===typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"===typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var s,u=[],f=!1,l=-1;function h(){f&&s&&(f=!1,s.length?u=s.concat(u):l=-1,u.length&&d())}function d(){if(!f){var e=c(h);f=!0;for(var t=u.length;t;){for(s=u,u=[];++l<t;)s&&s[l].run();l=-1,t=u.length}s=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function v(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new p(e,t)),1!==u.length||f||c(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";n.r(t);var r=n(1),o=n.n(r),i=n(2),a=n.n(i),c=n(3),s=n.n(c);function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var l=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.stream,r=void 0!==n&&n,i=t.config,a=t.channel,c=void 0===a||a,f=t.channelName,l=void 0===f?s()(20):f,h=t.channelConfig,d=void 0===h?{}:h;u(this,e),this.stream=r,this.peers=new Map,this.config=i,this.channel=c,this.channelName=l,this.channelConfig=d,this._emitter=new o.a}var t,n,r;return t=e,(n=[{key:"on",value:function(e,t){this._emitter.on(e,t)}},{key:"once",value:function(e,t){this._emitter.once(e,t)}},{key:"off",value:function(e,t){this._emitter.off(e,t)}},{key:"addPeer",value:function(e){var t=this;return e.once("connect",(function(){return t._emitter.emit("connect",e)})),this.peers.set(e.id,e),e}},{key:"removePeer",value:function(e){return this.peers.delete(e)}},{key:"hasPeer",value:function(e){return this.peers.has(e)}},{key:"getPeer",value:function(e){return this.peers.get(e)}},{key:"close",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.peers.values()[Symbol.iterator]();!(e=(r=o.next()).done);e=!0)r.value.close()}catch(i){t=!0,n=i}finally{try{e||null==o.return||o.return()}finally{if(t)throw n}}this.destroy()}},{key:"destroy",value:function(){a()(this._emitter)}}])&&f(t.prototype,n),r&&f(t,r),e}(),h=n(0),d=n.n(h);function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,c=e[Symbol.iterator]();!(r=(a=c.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(s){o=!0,i=s}finally{try{r||null==c.return||c.return()}finally{if(o)throw i}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function v(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(u){return void n(u)}c.done?t(s):Promise.resolve(s).then(r,o)}function y(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){v(i,r,o,a,c,"next",e)}function c(e){v(i,r,o,a,c,"throw",e)}a(void 0)}))}}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var g={iceServers:[{urls:"stun:stun.l.google.com:19302"}]},_=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.stream,r=void 0!==n&&n,i=t.id,a=void 0===i?s()(20):i,c=t.config,u=void 0===c?g:c;m(this,e),this.id=a,this.localStream=r,this.remoteStream=null,this.localSdp=null,this.remoteSdp=null,this._rtcPeer=new RTCPeerConnection(u),this._dataChannel=null,this._emitter=new o.a,this._attachEvents()}var t,n,r;return t=e,(n=[{key:"on",value:function(e,t){this._emitter.on(e,t)}},{key:"once",value:function(e,t){this._emitter.once(e,t)}},{key:"off",value:function(e,t){this._emitter.off(e,t)}},{key:"getSenders",value:function(){return this._rtcPeer.getSenders()}},{key:"createOfferSdp",value:function(){var e=y(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._rtcPeer.createOffer(t);case 2:return this.localSdp=e.sent,this._rtcPeer.setLocalDescription(this.localSdp),e.abrupt("return",this.localSdp);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"createAnswerSdp",value:function(){var e=y(d.a.mark((function e(t){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._rtcPeer.createAnswer(t);case 2:return this.localSdp=e.sent,this._rtcPeer.setLocalDescription(this.localSdp),e.abrupt("return",this.localSdp);case 5:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"createDataChannel",value:function(e,t){this._rtcPeer.createDataChannel&&this._setDataChannel(this._rtcPeer.createDataChannel(e,t))}},{key:"setRemoteDescription",value:function(e){return this.remoteSdp=e,this._rtcPeer.setRemoteDescription(new RTCSessionDescription(this.remoteSdp))}},{key:"addIceCandidate",value:function(e){return this._rtcPeer.addIceCandidate(e)}},{key:"send",value:function(e){this._dataChannel&&"open"===this._dataChannel.readyState&&"connected"===this._rtcPeer.iceConnectionState&&this._dataChannel.send(e)}},{key:"close",value:function(){this.closePeer(),this.closeChannel(),this.destroy()}},{key:"closePeer",value:function(){"disconnected"!==!this._rtcPeer.iceConnectionState&&this._rtcPeer.close()}},{key:"closeChannel",value:function(){this._dataChannel&&"closed"!==this._dataChannel.readyState&&this._dataChannel.close()}},{key:"destroy",value:function(){a()(this._emitter)}},{key:"_setDataChannel",value:function(e){var t=this;this._dataChannel=e,this._dataChannel.onopen=function(){t._emitter.emit("open")},this._dataChannel.onmessage=function(e){var n=e.data;t._emitter.emit("data",n)},this._dataChannel.onerror=function(e){if(!t._emitter.hasListeners(t._emitter,"error"))throw e;t._emitter.emit("error",e)},this._dataChannel.onclose=function(){return t._emitter.emit("close","datachannel")}}},{key:"_attachEvents",value:function(){var e=this;this.localStream&&this.localStream.getTracks().forEach((function(t){e._rtcPeer.addTrack(t,e.localStream)})),this._rtcPeer.onicecandidate=function(t){var n=t.candidate;n&&e._emitter.emit("iceCandidate",n)},this._rtcPeer.ontrack=function(t){var n=t.streams;if(!e.remoteStream){var r=p(n,1)[0];e._emitter.emit("stream",e.remoteStream=r)}},this._rtcPeer.ondatachannel=function(t){var n=t.channel;return e._setDataChannel(n)},this._rtcPeer.oniceconnectionstatechange=function(){var t=e._rtcPeer.iceConnectionState;"connected"===t&&e._emitter.emit("connect"),"disconnected"===t&&e._emitter.emit("close","ICE Connection"),e._emitter.emit("changeIceState",t)}}}])&&w(t.prototype,n),r&&w(t,r),e}();function b(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(u){return void n(u)}c.done?t(s):Promise.resolve(s).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){b(i,r,o,a,c,"next",e)}function c(e){b(i,r,o,a,c,"throw",e)}a(void 0)}))}}function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach((function(t){k(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function k(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var E={JOIN:"join",REQUEST_CONNECT:"requestConnect",SDP:"sdp",CANDIDATE:"candidate"},C=function(){function e(t){var n=t.websocket,r=t.id,i=void 0===r?s()(20):r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.id=i,this._emitter=new o.a,this._ws=n,n.onmessage=this._onMessage.bind(this)}var t,n,r;return t=e,(n=[{key:"on",value:function(e,t){this._emitter.on(e,t)}},{key:"once",value:function(e,t){this._emitter.once(e,t)}},{key:"off",value:function(e,t){this._emitter.off(e,t)}},{key:"send",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._ws.send(JSON.stringify({event:e,data:O({sender:this.id},t)}))}},{key:"autoSignal",value:function(e){var t=this;this.send(E.JOIN),this._emitter.on(E.JOIN,(function(e){var n=e.sender;t.send(E.REQUEST_CONNECT,{receiver:n})})),this._emitter.on(E.REQUEST_CONNECT,function(){var n=S(d.a.mark((function n(r){var o,i,a,c,s,u,f;return d.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return o=r.sender,i=e.stream,a=e.config,c=e.channel,s=e.channelName,u=e.channelConfig,f=new _({id:o,stream:i,config:a,channel:c}),e.addPeer(f),c&&f.createDataChannel(s,u),f.on("iceCandidate",(function(e){t.send(E.CANDIDATE,{receiver:f.id,candidate:e})})),n.t0=t,n.t1=E.SDP,n.t2=f.id,n.next=11,f.createOfferSdp();case 11:n.t3=n.sent,n.t4={receiver:n.t2,sdp:n.t3},n.t0.send.call(n.t0,n.t1,n.t4);case 14:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()),this._emitter.on(E.SDP,function(){var n=S(d.a.mark((function n(r){var o,i,a,c,s,u,f;return d.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(o=r.sender,"answer"!==(i=r.sdp).type){n.next=7;break}return a=e.getPeer(o),n.next=5,a.setRemoteDescription(i);case 5:n.next=21;break;case 7:return c=e.stream,s=e.config,u=e.channel,f=new _({id:o,stream:c,config:s,channel:u}),e.addPeer(f),f.on("iceCandidate",(function(e){t.send(E.CANDIDATE,{receiver:f.id,candidate:e})})),n.next=13,f.setRemoteDescription(i);case 13:return n.t0=t,n.t1=E.SDP,n.t2=f.id,n.next=18,f.createAnswerSdp();case 18:n.t3=n.sent,n.t4={receiver:n.t2,sdp:n.t3},n.t0.send.call(n.t0,n.t1,n.t4);case 21:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()),this._emitter.on(E.CANDIDATE,(function(t){var n=t.sender,r=t.candidate;e.getPeer(n).addIceCandidate(r)}))}},{key:"destroy",value:function(){a()(this._emitter)}},{key:"_onMessage",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.data,n=JSON.parse(t),r=n.event,o=n.data;this._equalId(o)&&(this._emitter.emit(r,o),this._emitter.emit("message",{event:r,data:o}))}},{key:"_equalId",value:function(e){return!e.receiver||e.receiver===this.id}}])&&P(t.prototype,n),r&&P(t,r),e}(),j=n(6);function T(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(u){return void n(u)}c.done?t(s):Promise.resolve(s).then(r,o)}function L(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){T(i,r,o,a,c,"next",e)}function c(e){T(i,r,o,a,c,"throw",e)}a(void 0)}))}}var N="https://chrome.google.com/webstore/detail/screen-sharing-extension/".concat("mopiaiibclcaiolndiidmkpejmcpjmcf");function A(){return D.apply(this,arguments)}function D(){return(D=L(d.a.mark((function e(){return d.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=Object(j.detect)().name,e.next="firefox"===e.t0?3:"chrome"===e.t0?4:15;break;case 3:return e.abrupt("return",{mediaSource:"screen"});case 4:return e.next=6,M();case 6:if(e.sent){e.next=8;break}window.location.href=N;case 8:return e.next=10,W();case 10:return e.t1=e.sent,e.t2=window.screen.width,e.t3=window.screen.height,e.t4={chromeMediaSource:"desktop",chromeMediaSourceId:e.t1,maxWidth:e.t2,maxHeight:e.t3},e.abrupt("return",{mandatory:e.t4});case 15:throw new Error("not support browser");case 16:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(){return new Promise((function(e){window.postMessage({type:"SCREEN_REQUEST",text:"start"},"*"),window.addEventListener("message",(function t(n){var r=n.data,o=r.type,i=r.streamId;"SCREEN_SHARE"===o&&(window.removeEventListener("message",t),e(i)),"SCREEN_CANCEL"===o&&(window.removeEventListener("message",t),e(!1))}))}))}function M(){return new Promise((function(e){var t=document.createElement("img");t.src="chrome-extension://".concat("mopiaiibclcaiolndiidmkpejmcpjmcf","/icon.png"),t.onload=function(){return e(!0)},t.onerror=function(){return e(!1)}}))}function I(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.screen,n=e.video,r=e.audio;return t?B():navigator.mediaDevices.getUserMedia({video:n,audio:r})}function B(){return navigator.getDisplayMedia?navigator.getDisplayMedia({video:!0}):navigator.mediaDevices.getDisplayMedia?navigator.mediaDevices.getDisplayMedia({video:!0}):navigator.mediaDevices.getUserMedia({video:A()})}function R(e,t){return new Promise((function(n,r){var o=new WebSocket(e,t);o.onopen=function(){return n(o)},o.onerror=function(){return r(new Error("connect failed."))}}))}n.d(t,"PeerConnector",(function(){return l})),n.d(t,"Peer",(function(){return _})),n.d(t,"Signal",(function(){return C})),n.d(t,"SIGNAL_EVENT",(function(){return E})),n.d(t,"getMediaStream",(function(){return I})),n.d(t,"connectWebsocket",(function(){return R}));t.default=l}])}));