cdnbye
Version:
Save Your Bandwidth using WebRTC.
1 lines • 95.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.P2PEngine=t():e.P2PEngine=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function o(e){return"number"==typeof e}function i(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,o,a,c,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||i(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:a=Array.prototype.slice.call(arguments,1),n.apply(this,a)}else if(i(n))for(a=Array.prototype.slice.call(arguments,1),u=n.slice(),o=u.length,c=0;c<o;c++)u[c].apply(this,a);return!0},n.prototype.addListener=function(e,t){var o;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?i(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,i(this._events[e])&&!this._events[e].warned&&(o=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&o>0&&this._events[e].length>o&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),o||(o=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var o=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,o,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,o=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(i(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){o=a;break}if(o<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){"use strict";(function(e){var n,r,o,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(s,a){"object"==i(t)&&"object"==i(e)?e.exports=a():(r=[],n=a,void 0!==(o="function"==typeof n?n.apply(t,r):n)&&(e.exports=o))}("undefined"!=typeof self&&self,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default={DC_PING:"PING",DC_PONG:"PONG",DC_SIGNAL:"SIGNAL",DC_OPEN:"OPEN",DC_REQUEST:"REQUEST",DC_PIECE_NOT_FOUND:"PIECE_NOT_FOUND",DC_CLOSE:"CLOSE",DC_RESPONSE:"RESPONSE",DC_ERROR:"ERROR",DC_PIECE:"PIECE",DC_TIMEOUT:"TIMEOUT",DC_PIECE_ACK:"PIECE_ACK",DC_BITFIELD:"BITFIELD",DC_CHOKE:"CHOKE",DC_UNCHOKE:"UNCHOKE",DC_USELESS:"USELESS",DC_HAVE:"HAVE",DC_LOST:"LOST",BM_LOST:"lost",FRAG_CHANGED:"FRAG_CHANGED",FRAG_LOADED:"FRAG_LOADED",FRAG_LOADING:"FRAG_LOADING",RESTART_P2P:"RESTART_P2P"},e.exports=t.default},function(e,t,n){var r;"function"==typeof Symbol&&Symbol.iterator,function(o){function i(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function s(e,t){return e<<t|e>>>32-t}function a(e,t,n,r,o,a){return i(s(i(i(t,e),i(r,a)),o),n)}function c(e,t,n,r,o,i,s){return a(t&n|~t&r,e,t,o,i,s)}function u(e,t,n,r,o,i,s){return a(t&r|n&~r,e,t,o,i,s)}function l(e,t,n,r,o,i,s){return a(t^n^r,e,t,o,i,s)}function f(e,t,n,r,o,i,s){return a(n^(t|~r),e,t,o,i,s)}function d(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;var n,r,o,s,a,d=1732584193,h=-271733879,p=-1732584194,v=271733878;for(n=0;n<e.length;n+=16)r=d,o=h,s=p,a=v,d=c(d,h,p,v,e[n],7,-680876936),v=c(v,d,h,p,e[n+1],12,-389564586),p=c(p,v,d,h,e[n+2],17,606105819),h=c(h,p,v,d,e[n+3],22,-1044525330),d=c(d,h,p,v,e[n+4],7,-176418897),v=c(v,d,h,p,e[n+5],12,1200080426),p=c(p,v,d,h,e[n+6],17,-1473231341),h=c(h,p,v,d,e[n+7],22,-45705983),d=c(d,h,p,v,e[n+8],7,1770035416),v=c(v,d,h,p,e[n+9],12,-1958414417),p=c(p,v,d,h,e[n+10],17,-42063),h=c(h,p,v,d,e[n+11],22,-1990404162),d=c(d,h,p,v,e[n+12],7,1804603682),v=c(v,d,h,p,e[n+13],12,-40341101),p=c(p,v,d,h,e[n+14],17,-1502002290),h=c(h,p,v,d,e[n+15],22,1236535329),d=u(d,h,p,v,e[n+1],5,-165796510),v=u(v,d,h,p,e[n+6],9,-1069501632),p=u(p,v,d,h,e[n+11],14,643717713),h=u(h,p,v,d,e[n],20,-373897302),d=u(d,h,p,v,e[n+5],5,-701558691),v=u(v,d,h,p,e[n+10],9,38016083),p=u(p,v,d,h,e[n+15],14,-660478335),h=u(h,p,v,d,e[n+4],20,-405537848),d=u(d,h,p,v,e[n+9],5,568446438),v=u(v,d,h,p,e[n+14],9,-1019803690),p=u(p,v,d,h,e[n+3],14,-187363961),h=u(h,p,v,d,e[n+8],20,1163531501),d=u(d,h,p,v,e[n+13],5,-1444681467),v=u(v,d,h,p,e[n+2],9,-51403784),p=u(p,v,d,h,e[n+7],14,1735328473),h=u(h,p,v,d,e[n+12],20,-1926607734),d=l(d,h,p,v,e[n+5],4,-378558),v=l(v,d,h,p,e[n+8],11,-2022574463),p=l(p,v,d,h,e[n+11],16,1839030562),h=l(h,p,v,d,e[n+14],23,-35309556),d=l(d,h,p,v,e[n+1],4,-1530992060),v=l(v,d,h,p,e[n+4],11,1272893353),p=l(p,v,d,h,e[n+7],16,-155497632),h=l(h,p,v,d,e[n+10],23,-1094730640),d=l(d,h,p,v,e[n+13],4,681279174),v=l(v,d,h,p,e[n],11,-358537222),p=l(p,v,d,h,e[n+3],16,-722521979),h=l(h,p,v,d,e[n+6],23,76029189),d=l(d,h,p,v,e[n+9],4,-640364487),v=l(v,d,h,p,e[n+12],11,-421815835),p=l(p,v,d,h,e[n+15],16,530742520),h=l(h,p,v,d,e[n+2],23,-995338651),d=f(d,h,p,v,e[n],6,-198630844),v=f(v,d,h,p,e[n+7],10,1126891415),p=f(p,v,d,h,e[n+14],15,-1416354905),h=f(h,p,v,d,e[n+5],21,-57434055),d=f(d,h,p,v,e[n+12],6,1700485571),v=f(v,d,h,p,e[n+3],10,-1894986606),p=f(p,v,d,h,e[n+10],15,-1051523),h=f(h,p,v,d,e[n+1],21,-2054922799),d=f(d,h,p,v,e[n+8],6,1873313359),v=f(v,d,h,p,e[n+15],10,-30611744),p=f(p,v,d,h,e[n+6],15,-1560198380),h=f(h,p,v,d,e[n+13],21,1309151649),d=f(d,h,p,v,e[n+4],6,-145523070),v=f(v,d,h,p,e[n+11],10,-1120210379),p=f(p,v,d,h,e[n+2],15,718787259),h=f(h,p,v,d,e[n+9],21,-343485551),d=i(d,r),h=i(h,o),p=i(p,s),v=i(v,a);return[d,h,p,v]}function h(e){var t,n="",r=32*e.length;for(t=0;t<r;t+=8)n+=String.fromCharCode(e[t>>5]>>>t%32&255);return n}function p(e){var t,n=[];for(n[(e.length>>2)-1]=void 0,t=0;t<n.length;t+=1)n[t]=0;var r=8*e.length;for(t=0;t<r;t+=8)n[t>>5]|=(255&e.charCodeAt(t/8))<<t%32;return n}function v(e){return h(d(p(e),8*e.length))}function g(e,t){var n,r,o=p(e),i=[],s=[];for(i[15]=s[15]=void 0,o.length>16&&(o=d(o,8*e.length)),n=0;n<16;n+=1)i[n]=909522486^o[n],s[n]=1549556828^o[n];return r=d(i.concat(p(t)),512+8*t.length),h(d(s.concat(r),640))}function y(e){var t,n,r="0123456789abcdef",o="";for(n=0;n<e.length;n+=1)t=e.charCodeAt(n),o+=r.charAt(t>>>4&15)+r.charAt(15&t);return o}function m(e){return unescape(encodeURIComponent(e))}function b(e){return v(m(e))}function _(e){return y(b(e))}function w(e,t){return g(m(e),m(t))}function x(e,t){return y(w(e,t))}function E(e,t,n){return t?n?w(t,e):x(t,e):n?b(e):_(e)}void 0!==(r=function(){return E}.call(t,n,t,e))&&(e.exports=r)}()},function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function s(e){return"number"==typeof e}function a(e){return"object"===(void 0===e?"undefined":u(e))&&null!==e}function c(e){return void 0===e}var u="function"==typeof Symbol&&"symbol"==i(Symbol.iterator)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":i(e)};e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,i,s,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}if(n=this._events[e],c(n))return!1;if(o(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),n.apply(this,i)}else if(a(n))for(i=Array.prototype.slice.call(arguments,1),u=n.slice(),r=u.length,s=0;s<r;s++)u[s].apply(this,i);return!0},r.prototype.addListener=function(e,t){var n;if(!o(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,o(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(n=c(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,i,s;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(n)){for(s=i;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,n){function r(e){if(e>_)throw new RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return t.__proto__=o.prototype,t}function o(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return u(e)}return s(e,t,n)}function s(e,t,n){if("string"==typeof e)return l(e,t);if(ArrayBuffer.isView(e))return f(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+(void 0===e?"undefined":b(e)));if(y(e,ArrayBuffer)||e&&y(e.buffer,ArrayBuffer))return d(e,t,n);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return o.from(r,t,n);var i=h(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+(void 0===e?"undefined":b(e)))}function a(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function c(e,t,n){return a(e),e<=0?r(e):void 0!==t?"string"==typeof n?r(e).fill(t,n):r(e).fill(t):r(e)}function u(e){return a(e),r(e<0?0:0|p(e))}function l(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!o.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|v(e,t),i=r(n),s=i.write(e,t);return s!==n&&(i=i.slice(0,s)),i}function f(e){for(var t=e.length<0?0:0|p(e.length),n=r(t),o=0;o<t;o+=1)n[o]=255&e[o];return n}function d(e,t,n){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),r.__proto__=o.prototype,r}function h(e){if(o.isBuffer(e)){var t=0|p(e.length),n=r(t);return 0===n.length?n:(e.copy(n,0,0,t),n)}return void 0!==e.length?"number"!=typeof e.length||m(e.length)?r(0):f(e):"Buffer"===e.type&&Array.isArray(e.data)?f(e.data):void 0}function p(e){if(e>=_)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+_.toString(16)+" bytes");return 0|e}function v(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+(void 0===e?"undefined":b(e)));var n=e.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return g(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;default:if(i)return r?-1:g(e).length;t=(""+t).toLowerCase(),i=!0}}function g(e,t){t=t||1/0;for(var n,r=e.length,o=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function m(e){return e!==e}var b="function"==typeof Symbol&&"symbol"==i(Symbol.iterator)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":i(e)};t.Buffer=o;var _=2147483647;t.kMaxLength=_,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&null!=Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),o.from=function(e,t,n){return s(e,t,n)},o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,o.alloc=function(e,t,n){return c(e,t,n)},o.allocUnsafe=function(e){return u(e)},o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=o.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var s=e[n];if(y(s,Uint8Array)&&(s=o.from(s)),!o.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(r,i),i+=s.length}return r},o.byteLength=v,o.prototype._isBuffer=!0,o.prototype.copy=function(e,t,n,r){if(!o.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var s=i-1;s>=0;--s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return i}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getPeersThrottle=t.getBrowserRTC=t.Buffer=t.Fetcher=t.Events=t.DataChannel=void 0;var o=n(5),i=r(o),s=n(0),a=r(s),c=n(8),u=r(c),l=n(11),f=r(l),d=n(12),h=r(d),p=n(3).Buffer;t.DataChannel=i.default,t.Events=a.default,t.Fetcher=u.default,t.Buffer=p,t.getBrowserRTC=f.default,t.getPeersThrottle=h.default},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=(void 0===t?"undefined":i(t))&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":i(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function c(e,t,n,r){var o=[];if(r){for(var i=void 0,s=0;s<n-1;s++)i=e[l("0x72")](s*t,(s+1)*t),o[l("0x42")](i);i=e[l("0x72")](e[l("0x51")]-r,e[l("0x51")]),o.push(i)}else for(var a=void 0,c=0;c<n;c++)a=e[l("0x72")](c*t,(c+1)*t),o.push(a);return o}var u=["bXNnUXVldWU=","bWlzcw==","Yml0c2V0","Y29ublRpbWVvdXQ=","c2V0VGltZW91dA==","ZGMg","IGNvbm5lY3Rpb24gdGltZW91dA==","ZW1pdA==","ZGVmYXVsdA==","RENfRVJST1I=","cmN2ZFJlcVF1ZXVl","Y2hva2Vk","ZGVsYXlz","ZmV0Y2hlcg==","dGltZXN0YW1w","dmVyc2lvbg==","X2RhdGFjaGFubmVs","Y29uZmln","d2ViUlRDQ29uZmln","aXNJbml0aWF0b3I=","X2luaXQ=","c2lnbmFs","RENfU0lHTkFM","aW5mbw==","ZGF0YWNoYW5uZWwgQ09OTkVDVEVEIHRvIA==","cmVtb3RlUGVlcklk","Y2xlYXJUaW1lb3V0","c2hpZnQ=","b25jZQ==","Y29ubmVjdA==","c3RyaW5n","ZGVidWc=","ZGF0YWNoYW5uZWwgcmVjZWl2ZSBzdHJpbmc6IA==","IGZyb20g","ZXZlbnQ=","X2hhbmRsZVBvbmdNc2c=","RENfUElORw==","RENfUE9ORw==","X3ByZXBhcmVGb3JCaW5hcnk=","YXR0YWNobWVudHM=","c2l6ZQ==","bGV2ZWw=","ZG93bmxvYWROdW0=","RENfUElFQ0VfTk9UX0ZPVU5EIGRvd25sb2FkTnVtIA==","X2hhbmRsZVJlcXVlc3RNc2c=","RENfUElFQ0VfQUNL","X2hhbmRsZVBpZWNlQWNr","RENfQ0hPS0U=","RENfQ0xPU0U=","YnVmQXJy","cHVzaA==","cmVtYWluQXR0YWNobWVudHM=","YnVmU04=","c2VnSWQ=","ZXhwZWN0ZWRTaXpl","X2hhbmRsZUJpbmFyeURhdGE=","Y2xvc2U=","c2VuZEpzb24=","c2VuZA==","c3RyaW5naWZ5","d2Fybg==","ZGF0YWNoYW5uZWwg","IHNlbmQgZGF0YSBmYWlsZWQsIGNsb3NlIGl0","c2VuZEJpdEZpZWxk","c2VuZEJ1ZmZlcg==","Ynl0ZUxlbmd0aA==","Zmxvb3I=","c2VnX2lk","cmVxdWVzdERhdGFCeUlk","cmVxdWVzdERhdGFCeVNO","dXJnZW50","cmVjZWl2ZVNpZ25hbA==","ZGVzdHJveQ==","Y2hva2VUaW1lcg==","cmVtb3ZlQWxsTGlzdGVuZXJz","YWRkIHJlcXVlc3Qgc24g","IHRvIHJjdmRSZXFRdWV1ZQ==","dW5zaGlmdA==","RENfUkVRVUVTVA==","Z2V0UmVxdWVzdEZyb21RdWV1ZQ==","Y29uY2F0","ZXhwZWN0ZWRTaXplIA==","LCBieXRlTGVuZ3RoIA==","cmVwb3J0RENUcmFmZmlj","RENfUkVTUE9OU0U=","ZXJyb3I=","IG5vdCBlcXVhbCB0byBieXRlTGVuZ3RoIA==","ZGF0YWNoYW5uZWwgZmluaXNoIGRvd25sb2FkaW5nIA==","bG9hZHRpbWVvdXQ=","IGlzIGNob2tlZA==","cmN2ZFJlcVF1ZXVlIHBvcCA=","cGVlciBhbHJlYWR5IGhhcyA=","LCBub3RpZnkgcGVlcg==","RENfUElFQ0VfTk9UX0ZPVU5E","bm93","cGluZw==","aXNBdmFpbGFibGU=","aXNBdmFpbGFibGVVcmdlbnRseQ==","c2xpY2U=","X19lc01vZHVsZQ==","YXNzaWdu","bGVuZ3Ro","Y2FsbA==","ZW51bWVyYWJsZQ==","Y29uZmlndXJhYmxl","d3JpdGFibGU=","a2V5","cHJvdG90eXBl","VkVSU0lPTg==","X19wcm90b19f","Z2V0UHJvdG90eXBlT2Y=","ZW5naW5l","bG9nZ2Vy","Y2hhbm5lbElk","Y29ubmVjdGVk"];!function(e,t){!function(t){for(;--t;)e.push(e.shift())}(++t)}(u,329);var l=function e(t,n){t-=0;var r=u[t];void 0===e.veeqZI&&(function(){var e=function(){var e;try{e=Function('return (function() {}.constructor("return this")( ));')()}catch(t){e=window}return e}();e.atob||(e.atob=function(e){for(var t,n,r=String(e).replace(/=+$/,""),o=0,i=0,s="";n=r.charAt(i++);~n&&(t=o%4?64*t+n:n,o++%4)?s+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s})}(),e.qAQOeQ=function(e){for(var t=atob(e),n=[],r=0,o=t.length;r<o;r++)n+="%"+("00"+t.charCodeAt(r).toString(16)).slice(-2);return decodeURIComponent(n)},e.xUFsTT={},e.veeqZI=!![]);var o=e.xUFsTT[t];return void 0===o?(r=e.qAQOeQ(r),e.xUFsTT[t]=r):r=o,r};Object.defineProperty(t,l("0x0"),{value:!![]});var f=Object[l("0x1")]||function(e){for(var t=1;t<arguments[l("0x2")];t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty[l("0x3")](n,r)&&(e[r]=n[r])}return e},d=function(){function e(e,t){for(var n=0;n<t[l("0x2")];n++){var r=t[n];r[l("0x4")]=r[l("0x4")]||![],r[l("0x5")]=!![],"value"in r&&(r[l("0x6")]=!![]),Object.defineProperty(e,r[l("0x7")],r)}}return function(t,n,r){return n&&e(t[l("0x8")],n),r&&e(t,r),t}}(),h=n(6),p=r(h),v=n(2),g=r(v),y=n(0),m=r(y),b=n(3).Buffer,_=function(e){function t(e,n,r,i,a){o(this,t);var c=s(this,(t[l("0xa")]||Object[l("0xb")](t))[l("0x3")](this));c[l("0xc")]=e,c[l("0xd")]=e[l("0xd")],c.config=a,c.remotePeerId=r,c[l("0xe")]=i?n+"-"+r:r+"-"+n,c[l("0xf")]=![],c[l("0x10")]=[],c[l("0x11")]=0,c[l("0x12")],c.bufArr=[],c[l("0x13")]=window[l("0x14")](function(){c.logger.warn(l("0x15")+c[l("0xe")]+l("0x16")),c[l("0x17")](m[l("0x18")][l("0x19")])},2e4),c[l("0x1a")]=[],c.uploading=![],c[l("0x1b")]=![],c[l("0x1c")]=[];var u=c[l("0xc")][l("0x1d")],d=u[l("0xe")],h=u.id,v=u[l("0x1e")],g=u.v,y=c[l("0xc")][l("0x1f")];return c[l("0x20")]=new(p[l("0x18")])(f({initiator:i,channelName:c[l("0xe")],objectMode:!![],signInfo:{channelId:d,id:h,timestamp:v,version:y,v:g}},c[l("0x21")][l("0x22")])),c[l("0x23")]=i,c[l("0x24")](c[l("0x20")]),c.downloadNum=0,c}return a(t,e),d(t,null,[{key:l("0x9"),get:function(){return"v2"}}]),d(t,[{key:"_init",value:function(e){var t=this;e.on("error",function(e){t[l("0x17")](m[l("0x18")][l("0x19")])}),e.on(l("0x25"),function(e){t.emit(m[l("0x18")][l("0x26")],e)});var n=function(){for(t.logger[l("0x27")](l("0x28")+t[l("0x29")]),t[l("0xf")]=!![],window[l("0x2a")](t[l("0x13")]),t[l("0x17")](m.default.DC_OPEN);t[l("0x10")][l("0x2")]>0;){var e=t[l("0x10")][l("0x2b")]();t[l("0x17")](e.event,e)}};e[l("0x2c")](l("0x2d"),n),e.on("data",function(e){if((void 0===e?"undefined":i(e))===l("0x2e")){t[l("0xd")][l("0x2f")](l("0x30")+e+l("0x31")+t[l("0x29")]);var n=JSON.parse(e);if(!t[l("0xf")])return void t[l("0x10")].push(n);switch(n[l("0x32")]){case m[l("0x18")].DC_PONG:t[l("0x33")]();break;case m[l("0x18")][l("0x34")]:t.sendJson({event:m.default[l("0x35")]});break;case m[l("0x18")].DC_PIECE:t[l("0x36")](n[l("0x37")],n.seg_id,n.sn,n[l("0x38")],n[l("0x39")]),t[l("0x17")](n[l("0x32")],n);break;case m[l("0x18")].DC_PIECE_NOT_FOUND:t[l("0x3a")]--,console.warn(l("0x3b")+t[l("0x3a")]),t[l("0x17")](n.event,n);break;case m[l("0x18")].DC_REQUEST:t[l("0x3c")](n);break;case m.default[l("0x3d")]:t[l("0x3e")](),t[l("0x17")](n.event,n);break;case m[l("0x18")][l("0x3f")]:t[l("0x1b")]=!![];break;case m.default.DC_UNCHOKE:t[l("0x1b")]=![];break;case m[l("0x18")][l("0x40")]:t[l("0x17")](m.default[l("0x40")]);break;default:t.emit(n[l("0x32")],n)}}else t[l("0x41")][l("0x42")](e),t.remainAttachments--,0===t[l("0x43")]&&(t[l("0x3a")]--,t.sendJson({event:m.default.DC_PIECE_ACK,sn:t[l("0x44")],seg_id:t[l("0x45")],size:t[l("0x46")]}),t[l("0x47")]())}),e[l("0x2c")](l("0x48"),function(){t[l("0x17")](m.default[l("0x40")])})}},{key:l("0x49"),value:function(e){this[l("0x4a")](JSON[l("0x4b")](e))}},{key:l("0x4a"),value:function(e){if(this[l("0x20")]&&this._datachannel[l("0xf")])try{this[l("0x20")][l("0x4a")](e)}catch(e){this[l("0xd")][l("0x4c")](l("0x4d")+this[l("0xe")]+l("0x4e")),this[l("0x17")](m[l("0x18")][l("0x19")])}}},{key:l("0x4f"),value:function(e){this[l("0x49")]({event:m[l("0x18")].DC_BITFIELD,field:e})}},{key:l("0x50"),value:function(e,t,n,r){this.uploading=!![];var o=r[l("0x51")],i=65536,s=0,a=0;o%i==0?a=o/i:(a=Math[l("0x52")](o/i)+1,s=o%i);var u={};u[l("0x32")]=m.default.DC_PIECE,u[l("0x37")]=a,u[l("0x53")]=n,u.sn=e,u.level=t,u.size=o,this.sendJson(u);for(var f=c(r,i,a,s),d=0;d<f[l("0x2")];d++)this[l("0x4a")](f[d])}},{key:l("0x54"),value:function(e,t){var n=arguments[l("0x2")]>2&&void 0!==arguments[2]?arguments[2]:![];this.downloadNum++;var r={};r[l("0x32")]=m.default.DC_REQUEST,r.seg_id=e,r.sn=t,r.urgent=n,this[l("0x49")](r)}},{key:l("0x55"),value:function(e){var t=arguments[l("0x2")]>1&&void 0!==arguments[1]?arguments[1]:![];this[l("0x3a")]++;var n={};n.event=m.default.DC_REQUEST,n.sn=e,n[l("0x56")]=t,this[l("0x49")](n)}},{key:l("0x48"),value:function(){this[l("0x17")](m.default[l("0x40")])}},{key:l("0x57"),value:function(e){this[l("0x20")][l("0x25")](e)}},{key:l("0x58"),value:function(){this[l("0xd")].warn("destroy datachannel "+this.channelId),this[l("0x59")]&&window.clearTimeout(this[l("0x59")]),this.connTimeout&&window.clearTimeout(this[l("0x13")]);var e={};e[l("0x32")]=m.default.DC_CLOSE,this[l("0x49")](e),this[l("0x20")].removeAllListeners(),this[l("0x5a")](),this[l("0x20")][l("0x58")]()}},{key:"_handleRequestMsg",value:function(e){this.uploading||this[l("0x1a")][l("0x2")]>0?(this.logger.info(l("0x5b")+e.sn+l("0x5c")),e.urgent?this[l("0x1a")][l("0x42")](e.sn):this.rcvdReqQueue[l("0x5d")](e.sn)):this[l("0x17")](m[l("0x18")][l("0x5e")],e)}},{key:l("0x3e"),value:function(){this.uploading=![];var e=this[l("0x5f")]();e&&this[l("0x17")](m[l("0x18")][l("0x5e")],{sn:e})}},{key:l("0x36"),value:function(e,t,n,r,o){this.bufArr=[],this.remainAttachments=e,this[l("0x45")]=t,this[l("0x39")]=o,this.bufSN=n,this[l("0x46")]=r}},{key:"_handleBinaryData",value:function(){var e=b[l("0x60")](this[l("0x41")]);if(this[l("0xd")][l("0x2f")](l("0x61")+this[l("0x46")]+l("0x62")+e.byteLength),e[l("0x51")]==this.expectedSize){this[l("0xc")][l("0x1d")]?this.engine[l("0x1d")][l("0x63")](this.expectedSize):console.warn("DC report failed");var t=new Uint8Array(e).buffer;this[l("0x17")](m[l("0x18")][l("0x64")],{seg_id:this[l("0x45")],sn:this[l("0x44")],data:t,level:this.level})}else this[l("0xd")][l("0x65")]("expectedSize "+this.expectedSize+l("0x66")+e.byteLength);this[l("0xd")][l("0x27")](l("0x67")+this.segId+l("0x31")+this[l("0x29")]),this[l("0x45")]="",this.bufArr=[],this[l("0x46")]=-1}},{key:l("0x68"),value:function(){var e=this;if(this.logger[l("0x4c")]("datachannel timeout while downloading from "+this[l("0x29")]),this[l("0x17")](m[l("0x18")].DC_TIMEOUT),this[l("0x11")]++,this.miss>=4&&!this[l("0x1b")]){var t=10*this[l("0x11")];this.logger.warn(l("0x4d")+this[l("0xe")]+l("0x69")),this[l("0x1b")]=!![],t<=200&&(this[l("0x59")]=setTimeout(function(){e[l("0x1b")]=![],e.logger[l("0x4c")]("datachannel "+e[l("0xe")]+" is unchoked")},1e3*t))}}},{key:l("0x5f"),value:function(){if(0==this[l("0x1a")][l("0x2")])return null;var e=this[l("0x1a")].pop();return this[l("0xd")][l("0x27")](l("0x6a")+e),this.bitset.has(e)?(this[l("0xd")][l("0x27")](l("0x6b")+e+l("0x6c")),this[l("0x49")]({event:m[l("0x18")][l("0x6d")],sn:e}),this[l("0x5f")]()):e}},{key:l("0x33"),value:function(){var e=performance[l("0x6e")]()-this[l("0x6f")];this[l("0x1c")][l("0x42")](e)}},{key:l("0x70"),get:function(){return this[l("0x3a")]<2&&this[l("0x1b")]===![]}},{key:l("0x71"),get:function(){return 0===this[l("0x3a")]&&this.choked===![]}}]),t}(g[l("0x18")]);t[l("0x18")]=_,e.exports=t[l("0x18")]},function(e,t,n){function r(e){for(var t="",n=0;n<e.length;++n)t+=e[n].toString(16).padStart(2,"0");return t}function o(e){var t=this;if(!(t instanceof o))return new o(e);h.call(t),t.s=e.signInfo,t.channelName=e.initiator?e.channelName||r(v(20)):null,t._isChromium="undefined"!=typeof window&&!!window.webkitRTCPeerConnection,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||o.channelConfig,t.config=e.config||o.config,t.constraints=t._transformConstraints(e.constraints||o.constraints),t.offerConstraints=t._transformConstraints(e.offerConstraints||{}),t.answerConstraints=t._transformConstraints(e.answerConstraints||{}),t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"===l(e.wrtc)?e.wrtc:window,t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!1,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new WeakMap,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},"addTrack"in t._pc&&(t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)}),t.initiator&&t._needsNegotiation()}function s(e,t){var n=new Error(e);return n.code=t,n}function a(){}var c=["c3ltYm9s","ZnVuY3Rpb24=","aXRlcmF0b3I="];!function(e,t){!function(t){for(;--t;)e.push(e.shift())}(++t)}(c,131);var u=function e(t,n){t-=0;var r=c[t];void 0===e.twhUlu&&(function(){var e=function(){var e;try{e=Function('return (function() {}.constructor("return this")( ));')()}catch(t){e=window}return e}();e.atob||(e.atob=function(e){for(var t,n,r=String(e).replace(/=+$/,""),o=0,i=0,s="";n=r.charAt(i++);~n&&(t=o%4?64*t+n:n,o++%4)?s+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s})}(),e.VirwBL=function(e){for(var t=atob(e),n=[],r=0,o=t.length;r<o;r++)n+="%"+("00"+t.charCodeAt(r).toString(16)).slice(-2);return decodeURIComponent(n)},e.vizmyL={},e.twhUlu=!![]);var o=e.vizmyL[t];return void 0===o?(r=e.VirwBL(r),e.vizmyL[t]=r):r=o,r},l="function"==typeof Symbol&&i(Symbol[u("0x0")])===u("0x1")?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&("undefined"==typeof Symbol?"undefined":i(Symbol))===u("0x2")&&e.constructor===Symbol&&e!==Symbol.prototype?u("0x1"):void 0===e?"undefined":i(e)},f=n(1),d=function(e){return e&&e.__esModule?e:{default:e}}(f);e.exports=o;var h=n(2),p=n(7),v=function(e){var t=new Uint8Array(e);return window.crypto.getRandomValues(t),t};String.prototype.padStart||(String.prototype.padStart=function(e,t){return e>>=0,t=String(void 0!==t?t:" "),this.length>e||""===t?String(this):(e-=this.length,e>t.length&&(t+=t.repeat(e/t.length)),t.slice(0,e)+String(this))}),p(o,h),o.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}]},o.constraints={},o.channelConfig={},Object.defineProperty(o.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}}),o.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}},o.prototype.signal=function(e){var t=this;if(t.destroyed)throw s("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}e.renegotiate&&t._needsNegotiation(),e.candidate&&(t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())},function(e){t.destroy(s(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||t.destroy(s("signal() called with invalid signal data","ERR_SIGNALING"))},o.prototype._addIceCandidate=function(e){var t=this;try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),a,function(e){t.destroy(s(e,"ERR_ADD_ICE_CANDIDATE"))})}catch(e){t.destroy(s("error adding candidate: "+e.message,"ERR_ADD_ICE_CANDIDATE"))}},o.prototype.send=function(e){this._channel.send(e)},o.prototype.addStream=function(e){var t=this;e.getTracks().forEach(function(n){t.addTrack(n,e)})},o.prototype.addTrack=function(e,t){var n=this,r=n._pc.addTrack(e,t),o=n._senderMap.get(e)||new WeakMap;o.set(t,r),n._senderMap.set(e,o),n._needsNegotiation()},o.prototype.removeTrack=function(e,t){var n=this,r=n._senderMap.get(e),o=r?r.get(t):null;o||n.destroy(new Error("Cannot remove track that was never added."));try{n._pc.removeTrack(o)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?n._sendersAwaitingStable.push(o):n.destroy(e)}},o.prototype.removeStream=function(e){var t=this;e.getTracks().forEach(function(n){t.removeTrack(n,e)})},o.prototype._needsNegotiation=function(){var e=this;e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e.negotiate()},0))},o.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?e._queuedNegotiation=!0:e._createOffer():e.emit("signal",{renegotiate:!0}),e._isNegotiating=!0},o.prototype.destroy=function(e){var t=this;if(!t.destroyed){if(t.destroyed=!0,t.connected=!1,t._pcReady=!1,t._channelReady=!1,t._remoteTracks=null,t._remoteStreams=null,t._senderMap=null,clearInterval(t._interval),t._interval=null,t._chunk=null,t._cb=null,t._channel){try{t._channel.close()}catch(e){}t._channel.onmessage=null,t._channel.onopen=null,t._channel.onclose=null,t._channel.onerror=null}if(t._pc){try{t._pc.close()}catch(e){}t._pc.oniceconnectionstatechange=null,t._pc.onicegatheringstatechange=null,t._pc.onsignalingstatechange=null,t._pc.onicecandidate=null,"addTrack"in t._pc&&(t._pc.ontrack=null),t._pc.ondatachannel=null}t._pc=null,t._channel=null,e&&t.emit("error",e),t.emit("close")}},o.prototype._setupData=function(e){var t=this;if(!e.channel)return t.destroy(s("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=65536),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(s(e,"ERR_DATA_CHANNEL"))}},o.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(e.offerConstraints).then(function(t){function n(){e.destroyed||(e.trickle||e._iceComplete?o():e.once("_iceComplete",o))}function r(t){e.destroy(s(t,"ERR_SET_LOCAL_DESCRIPTION"))}function o(){var n=e._pc.localDescription||t;e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(n).catch(r))}).catch(function(t){e.destroy(s(t,"ERR_CREATE_OFFER"))})},o.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(e.answerConstraints).then(function(t){function n(){e.destroyed||(e.trickle||e._iceComplete?o():e.once("_iceComplete",o))}function r(t){e.destroy(s(t,"ERR_SET_LOCAL_DESCRIPTION"))}function o(){var n=e._pc.localDescription||t;e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(n).catch(r))}).catch(function(t){e.destroy(s(t,"ERR_CREATE_ANSWER"))})},o.prototype._onIceStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceConnectionState,n=e._pc.iceGatheringState;e.emit("iceStateChange",t,n),"connected"!==t&&"completed"!==t||(e._pcReady=!0,e._maybeReady()),"failed"===t&&e.destroy(s("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===t&&e.destroy(new Error("Ice connection closed."))}},o.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):t._pc.getStats.length>0?t._pc.getStats(function(n){if(!t.destroyed){var r=[];n.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,r.push(t)}),e(null,r)}},function(t){e(t)}):e(null,[])},o.prototype._maybeReady=function(){function e(){t.destroyed||t.getStats(function(n,r){function o(e){u=!0;var n=a[e.localCandidateId];n&&n.ip?(t.localAddress=n.ip,t.localPort=Number(n.port)):n&&n.ipAddress?(t.localAddress=n.ipAddress,t.localPort=Number(n.portNumber)):"string"==typeof e.googLocalAddress&&(n=e.googLocalAddress.split(":"),t.localAddress=n[0],t.localPort=Number(n[1]));var r=i[e.remoteCandidateId];r&&r.ip?(t.remoteAddress=r.ip,t.remotePort=Number(r.port)):r&&r.ipAddress?(t.remoteAddress=r.ipAddress,t.remotePort=Number(r.portNumber)):"string"==typeof e.googRemoteAddress&&(r=e.googRemoteAddress.split(":"),t.remoteAddress=r[0],t.remotePort=Number(r[1])),t.remoteFamily="IPv4"}if(!t.destroyed){n&&(r=[]);var i={},a={},c={},u=!1;if(r.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(a[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(c[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&o(c[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&o(e)}),!(u||Object.keys(c).length&&!Object.keys(a).length))return void setTimeout(e,100);if(t._connecting=!1,t.connected=!0,t._chunk){try{t.send(t._chunk)}catch(n){return t.destroy(s(n,"ERR_DATA_CHANNEL"))}t._chunk=null;var l=t._cb;t._cb=null,l(null)}"number"!=typeof t._channel.bufferedAmountLowThreshold&&(t._interval=setInterval(function(){t._onInterval()},150),t._interval.unref&&t._interval.unref());var f=["cm1QeHQ=","UU5zTEg=","WUxWS2E=","U0sqQEllRV5yMA==","ZW1pdA==","Y29ubmVjdA=="];!function(e,t){!function(t){for(;--t;)e.push(e.shift())}(++t)}(f,450);var h=function e(t,n){t-=0;var r=f[t];void 0===e.ddzinM&&(function(){var e=function(){var e;try{e=Function('return (function() {}.constructor("return this")( ));')()}catch(t){e=window}return e}();e.atob||(e.atob=function(e){for(var t,n,r=String(e).replace(/=+$/,""),o=0,i=0,s="";n=r.charAt(i++);~n&&(t=o%4?64*t+n:n,o++%4)?s+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s})}(),e.qBHZHa=function(e){for(var t=atob(e),n=[],r=0,o=t.length;r<o;r++)n+="%"+("00"+t.charCodeAt(r).toString(16)).slice(-2);return decodeURIComponent(n)},e.bWbEuz={},e.ddzinM=!![]);var o=e.bWbEuz[t];return void 0===o?(r=e.qBHZHa(r),e.bWbEuz[t]=r):r=o,r},p=t.s,v=p.channelId,g=p.id,y=p.timestamp,m=p.version,b=p.v,_=function(e,t,n,r){var o={};return o[h("0x0")]=function(e,t,n){return e(t,n)},o[h("0x1")]=function(e,t){return e+t},o[h("0x2")]=h("0x3"),o.rmPxt(d.default,o[h("0x1")](o[h("0x1")](o[h("0x1")](e,t),n),o[h("0x2")]),r)}(v,g,y,m);t[h("0x4")](_.substr(0,8)===b?h("0x5"):"")}})}var t=this;!t.connected&&!t._connecting&&t._pcReady&&t._channelReady&&(t._connecting=!0,e())},o.prototype._onInterval=function(){var e=this;!e._cb||!e._channel||e._channel.bufferedAmount>65536||e._onChannelBufferedAmountLow()},o.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&(e._isNegotiating=!1,e._sendersAwaitingStable.forEach(function(t){e.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._queuedNegotiation=!1,e._needsNegotiation()),e.emit("negotiate")),e.emit("signalingStateChange",e._pc.signalingState))},o.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||(t._iceComplete=!0,t.emit("_iceComplete")))},o.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;n instanceof ArrayBuffer&&(n=new Uint8Array(n)),t.emit("data",n)}},o.prototype._onChannelBufferedAmountLow=function(){var e=this;if(!e.destroyed&&e._cb){var t=e._cb;e._cb=null,t(null)}},o.prototype._onChannelOpen=function(){var e=this;e.connected||e.destroyed||(e._channelReady=!0,e._maybeReady())},o.prototype._onChannelClose=function(){var e=this;e.destroyed||e.destroy()},o.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n}),t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},o.prototype._transformConstraints=function(e){var t=this;if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!t._isChromium){var n=Object.assign({},e.optional,e.mandatory);return void 0!==n.OfferToReceiveVideo&&(n.offerToReceiveVideo=n.OfferToReceiveVideo,delete n.OfferToReceiveVideo),void 0!==n.OfferToReceiveAudio&&(n.offerToReceiveAudio=n.OfferToReceiveAudio,delete n.OfferToReceiveAudio),n}return e.mandatory||e.optional||!t._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t,n){var r=window.location.hostname;return function(e,t,n,r){return(0,f.default)(e+t+n,r)}(r,t,n,e).substr(0,8)}var s=["dmFsdWU=","ZGVmaW5lUHJvcGVydHk=","a2V5","cHJvdG90eXBl","X19lc01vZHVsZQ==","aGFzT3duUHJvcGVydHk=","Y2FsbA==","bGVuZ3Ro","ZW51bWVyYWJsZQ==","Y29uZmlndXJhYmxl"];!function(e,t){!function(t){for(;--t;)e.push(e.shift())}(++t)}(s,174);var a=function e(t,n){t-=0;var r=s[t];void 0===e.NVXoNv&&(function(){var e;try{var t=Function('return (function() {}.constructor("return this")( ));');e=t()}catch(t){e=window}e.atob||(e.atob=function(e){for(var t,n,r=String(e).replace(/=+$/,""),o=0,i=0,s="";n=r.charAt(i++);~n&&(t=o%4?64*t+n:n,o++%4)?s+=String.fromCharCode(255&t>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return s})}(),e.WHgABh=function(e){for(var t=atob(e),n=[],r=0,o=t.length;r<o;r++)n+="%"+("00"+t.charCodeAt(r).toString(16)).slice(-2);return decodeURIComponent(n)},e.gGvJRV={},e.NVXoNv=!![]);var o=e.gGvJRV[t];return void 0===o?(r=e.WHgABh(r),e.gGvJRV[t]=r):r=o,r};Object.defineProperty(t,a("0x0"),{value:!![]});var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype[a("0x1")][a("0x2")](n,r)&&(e[r]=n[r])}return e},u=function(){function e(e,t){for(var n=0;n<t[a("0x3")];n++){var r=t[n];r.enumerable=r[a("0x4")]||![],r[a("0x5")]=!![],a("0x6")in r&&(r.writable=!![]),Object[a("0x7")](e,r[a("0x8")],r)}}return function(t,n,r){return n&&e(t[a("0x9")],n),r&&e(t,r),t}}(),l=n(1),f=r(l),d=n(9),h=r(d),p=n(0),v=r(p),g="0.12.3",y="https://tracker.cdnbye.com/v1",m=Symbol("httpDownloaded"),b=Symbol("p2pDownloaded"),_=Symbol("p2pUploaded"),w=function(){function e(t,n,r,s,a){o(this,e),this.engine=t,this.key=n,this.baseUrl=s||y,this.channelId=window.btoa(r),this.timestamp=Date.parse(new Date)/1e3;var u=h.default.parseURL(this.baseUrl).netLoc.replace(/\/\//,""),l=i(this.timestamp,g,u);this.announceInfo=c({},a,{channel:this.channelId,ts:this.timestamp,version:g,v:l,announce:u}),this.announceURL=this.baseUrl+"/channel",this.key=n,this.conns=0,this.failConns=0,this.totalHTTPDownloaded=0,this.totalP2PDownloaded=0,this.totalP2PUploaded=0,this[m]=0,this[b]=0,this[_]=0,this.errsBufStalled=0,this.errsInternalExpt=0,a.bundle?this.native=!0:this.native=!1}return u(e,[{key:"btAnnounce",value:function(){var e=this,t=this.engine.logger;return new Promise(function(n,r){fetch(e.announceURL,{headers:e._requestHeader,method:"POST",body:JSON.stringify(e.announceInfo)}).then(function(e){return e.json()}).then(function(t){if(-1===t.ret)r(t.data.msg);else{var o=t.data;o.info&&console.info(""+o.info),o.warn&&console.warn(""+o.warn),o.min_conns||(o.min_conns=3),!o.rejected&&o.id&&o.v&&o.report_interval&&o.peers?(e.peerId=e.id=o.id,e.v=o.v,e.btStats(o.report_interval),e.getPeersURL=e.baseUrl+"/channel/"+e.channelId+"/node/"+e.peerId+"/peers",e.statsURL=e.baseUrl+"/channel/"+e.channelId+"/node/"+e.peerId+"/stats",n(t.data)):e.engine.p2pEnabled=!1}}).catch(function(e){t.error("btAnnounce error "+e),r(e)})})}},{key:"btStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,n=this.engine.logger;this.heartbeater=window.setInterval(function(){fetch(e.statsURL,{method:"POST",body:JSON.stringify(e._makeStatsBody())}).then(function(e){return e.json()}).then(function(t){if(-1===t.ret)window.clearInterval(e.heartbeater),e.engine.emit(v.default.RESTART_P2P);else{n.debug("sucessfully report stats");var r=e.lastStats||{},o=r.http,i=void 0===o?0:o,s=r.p2p,a=void 0===s?0:s,c=r.share,u=void 0===c?0:c,l=r.conns,f=void 0===l?0:l,d=r.failConns,h=void 0===d?0:d,p=r.errsBufStalled,g=void 0===p?0:p,y=r.errsInternalExpt,w=void 0===y?0:y;e[m]>=i&&(e[m]-=i),e[b]>=a&&(e[b]-=a),e[_]>=u&&(e[_]-=u),e.conns-=f,e.failConns-=h,e.errsBufStalled-=g,e.errsInternalExpt-=w}}).catch(function(e){n.error("btStats error "+e)})},1e3*t)}},{key:"btGetPeers",value:function(){var e=this,t=this.engine.logger;return new Promise(function(n,r){fetch(e.getPeersURL,{headers:e._requestHeader,method:"POST"}).then(function(e){return e.json()}).then(function(e){-1===e.ret?r(e.data.msg):n(e.data)}).catch(function(e){t.error("btGetPeers error "+e),r(e)})})}},{key:"increConns",value:function(){this.conns++}},{key:"decreConns",value:function(){this.conns--}},{key:"increFailConns",value:function(){this.failConns++}},{key:"reportFlow",value:function(e){var t=Math.round(e/1024);this[m]+=t,this.totalHTTPDownloaded+=t,this._emitStats()}},{key:"reportDCTraffic",value:function(e){var t=Math.round(e/1024);this[b]+=t,this.totalP2PDownloaded+=t,this._emitStats()}},{key:"reportUploaded",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.totalP2PUploaded+=Math.round(e/1024),this[_]+=Math.round(e/1024),this._emitStats()}},{key:"destroy",value:function(){this.engine.logger.warn("destroy fetcher"),window.clearInterval(this.heartbeater)}},{key:"_emitStats",value:function(){this.engine.emit("stats",{totalHTTPDownloaded:this.totalHTTPDownloaded,totalP2PDownloaded:this.totalP2PDownloaded,totalP2PUploaded:this.totalP2PUploaded});var e=this.engine.config.getStats;e&&"function"==typeof e&&e(this.totalP2PDownloaded,this.totalP2PUploaded,this.totalHTTPDownloaded)}},{key:"_makeStatsBody",value:function(){var e={conns:this.conns,failConns:this.failConns,errsBufStalled:this.errsBufStalled,errsInternalExpt:this.errsInternalExpt,http:Math.round(this[m])||0,p2p:Math.round(this[b])||0,share:Math.round(this[_])||0};return this.lastStats=JSON.parse(JSON.stringify(e)),Object.keys(e).forEach(function(t){0===e[t]&&delete e[t]}),e.device=this.announceInfo.device,e}},{key:"_requestHeader",get:function(){var e={};return this.native&&(e.token=this.key),e}}]),e}();t.default=w,e.exports=t.default},function(e,t,n){(function(e){var n,r,o="function"==typeof Symbol&&"symbol"==i(Symbol.iterator)?function(e){return void 0===e?"undefined":i(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":i(e)};!function(i){var s=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,a=/^([^\/;?#]*)(.*)$/,c=/(?:\/|^)\.(?=\/)/g,u=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,l={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var r=l.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");return r.path=l.normalizePath(r.path),l.buildURLFromParts(r)}var o=l.parseURL(t);if(!o)throw new Error("Error trying to parse relative URL.");if(o.scheme)return n.alwaysNormalize?(o.path=l.normalizePath(o.path),l.buildURLFromParts(o)):t;var i=l.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");if(!i.netLoc&&i.path&&"/"!==i.path[0]){var s=a.exec(i.path);i.netLoc=s[1],i.path=s[2]}i.netLoc&&!i.path&&(i.path="/");var c={scheme:i.scheme,netLoc:o.netLoc,path:null,params:o.params,query:o.query,fragment:o.fragment};if(!o.netLoc&&(c.netLoc=i.netLoc,"/"!==o.path[0]))if(o.path){var u=i.path,f=u.substring(0,u.lastIndexOf("/")+1)+o.path;c.path=l.normalizePath(f)}else c.path=i.path,o.params||(c.params=i.params,o.query||(c.query=i.query));return null===c.path&&(c.path=n.alwaysNormalize?l.normalizePath(o.path):o.path),l.buildURLFromParts(c)},parseURL:function(e){var t=s.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(c,"");e.length!==(e=e.replace(u,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};"object"===o(t)&&"object"===o(e)?e.exports=l:(n=[],void 0!==(r=function(){return l}.apply(t,n))&&(e.exports=r))}()}).call(t,n(10)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){e.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},function(e,t,n){function r(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:25,r=null,o=!1,i=n;return function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return void window.clearTimeout(r);o||(o=!0,r=setTimeout(function(){e.call(t),o=!1,r=null},1e3*i),i*=1.7)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,e.exports=t.default}])})}).call(t,n(10)(e))},function(e,t,n){"use strict";function r(){return!0}function o(e){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),n=window.location.search.substr(1).match(t);return null!=n&&""!==n[2]?n[2].toString():""}function i(e,t){var n=a.default.parseURL(e),r=n.path.split(".")[1];return-1!==t.indexOf(r)}Object.defineProperty(t,"__esModule",{value:!0}),t.noop=r,t.getQueryParam=o,t.isBlockType=i;var s=n(3),a=function(e){return e&&e.__esModule?e:{default:e}}(s)},function(e,t,n){!function(t){var n=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/\;?#]*)?(.*?)??(;.*?)?(\?.*?)?(#.*?)?$/,r=/^([^\/;?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/).*?(?=\/)/g,s={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var o=s.parseURL(e);if(!o)throw new Error("Error trying to parse base URL.");return o.path=s.normalizePath(o.path),s.buildURLFromParts(o)}var i=s.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return n.alwaysNormalize?(i.path=s.normalizePath(i.path),s.buildURLFromParts(i)):t;var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){var c=r.exec(a.path);a.netLoc=c[1],a.path=c[2]}a.netLoc&&!a.path&&(a.path="/");var u={scheme:a.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(u.netLoc=a.netLoc,"/"!==i.path[0]))if(i.path){var l=a.path,f=l.substring(0,l.lastIndexOf("/")+1)+i.path;u.path=s.normalizePath(f)}else u.path=a.path,i.params||(u.params=a.params,i.query||(u.query=a.query));return null===u.path&&(u.path=n.alwaysNormalize?s.normalizePath(i.path):i.path),s.buildURLFromParts(u)},parseURL:function(e){var t=n.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(o,"");e.length!==(e=e.replace(i,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};e.exports=s}()},function(e,t,n){"use strict";function r(){return navigator.userAgent.toLowerCase()}function o(e){return""+(new RegExp(e+"(\\d+((\\.|_)\\d+)*)").exec(r())||[,0])[1]||void 0}function i(e){return parseFloat((e||"").replace(/\_/g,"."))||0}var s={ANDROID_WEB:"android-web",IOS_WEB:"iOS-web",PC_NATIVE:"PC-native",PC_WEB:"PC-web"},a={getNetType:function(){return(new RegExp("nettype\\/(\\w*)").exec(r())||[,""])[1].toLowerCase()},getPlatform:function(){return a.isAndroid()?s.ANDROID_WEB:a.isIOS()?s.IOS_WEB:a.isElectron()?s.PC_NATIVE:s.PC_WEB},isX5:function(){return this.isAndroid()&&/\s(TBS|X5Core)\/[\w\.\-]+/i.test(r())},isPC:function(){return!i(o("os "))&&!i(o("android[/ ]"))},isIOS:function(){return i(o("os "))},isAndroid:function(){return i(o("android[/ ]"))},isSafari:function(){return this.isIOS()&&/^((?!chrome|android).)*safari/i.test(r())},isElectron:function(){return/electron/i.test(r())},isMobile:function(){return a.isAndroid()||a.isIOS()},device:s};e.exports=a},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.config=t.FragLoader=t.Tracker=void 0;var o=n(8),i=r(o),s=n(13),a=r(s),c={prefetchNum:10,maxPrefetchCount:20};t.Tracker=i.default,t.FragLoader=a.default,t.config=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),l=r(u),f=n(3),d=r(f),h=n(7),p=r(h),v=n(5),g=n(14),y=r(g),m=n(1),b=n(15),_=r(b),w=n(4),x=r(w),E=n(2),P=n(16),S=r(P);if(window.cdnbyeloaded)throw new Error("CDNBye plugin is loaded before(重复加载CDNBye插件)");window.cdnbyeloaded=!0;var C=function(e){function t(e,n){o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));if(n.tag&&n.tag.length>20)throw new Error("Tag is too long");if(n.agent&&n.agent.length>20)throw new Error("Agent is too long");if(n.appName&&n.appName.length>30)throw new Error("appName is too long");if(n.appId&&n.appId.length>30)throw new Error("appId is too long");if(n.token&&n.token.length>20)throw new Error("Token is too long");r.config=Object.assign({},p.default,n),e.config.segmentId=r.config.segmentId,r.hlsjs=e,r.p2pEnabled=!(!1===r.config.p2pEnabled||"0"===(0,E.getQueryParam)("_p2p")),e.config.currLoaded=e.config.currPlay=0,r.HLSEvents=e.constructor.Events;var s=function n(o,i){var s=i.details,c=s.live;r.config.live=r.hlsjs.config.live=c,r.config.startSN=s.startSN,r.config.endSN=s.endSN;var u=x.default.getPlatform(),l=x.default.getNetType()||void 0;r.browserInfo={device:u,netType:l,tag:r.config.tag||(0,S.default)(),live:c,type:"hls",agent:r.config.agent||void 0},u===x.default.device.PC_NATIVE&&(r.browserInfo=a({},r.browserInfo,{app:r.config.appName,bundle:r.config.appId}));var f=d.default.parseURL(r.config.wsSignalerAddr).netLoc.substr(2);r.channel=r.config.channelId(e.url,r.browserInfo)+"|"+f+"["+m.DataChannel.VERSION+"]";var h=new _.default(r.config);r.hlsjs.config.logger=r.logger=h,h.info("CDNBye version: "+t.version+" Hlsjs version: "+e.constructor.version),h.info("channel "+r.channel),h.info("device "+u+" netType "+l),r.eventListened=!1,r._init(r.channel,r.browserInfo),h.info("startSN "+s.startSN+" endSN "+s.endSN),e.off(r.HLSEvents.LEVEL_LOADED,n)};return e.on(r.HLSEvents.LEVEL_LOADED,s),r}return s(t,e),c(t,null,[{key:"Events",get:function(){return m.Events}}]),c(t,[{key:"_init",value:function(e,t){var n=this;if(this.p2pEnabled){this.hlsjs.config.p2pEnabled=this.p2pEnabled,this.bufMgr=new y.default(this,this.config),this.hlsjs.config.bufMgr=this.bufMgr,this.media=this.hlsjs.media;var r=new m.Fetcher(this,this.config.token,window.encodeURIComponent(e),this.config.announce||"",t);this.fetcher=r,this.tracker=new v.Tracker(this,r,this.config),this.tracker.scheduler.bufferManager=this.bufMgr,this.hlsjs.config.fLoader=v.FragLoader,this.hlsjs.config.scheduler=this.tracker.scheduler,this.hlsjs.config.fetcher=r,this.hlsjs.config.p2pBlackList=this.config.p2pBlackList,this.trackerTried=!1,this.eventListened||(this.hlsjs.on(this.HLSEvents.FRAG_LOADING,this._onFragLoading.bind(this)),this.hlsjs.on(this.HLSEvents.FRAG_LOADED,this._onFragLoaded.bind(this)),this.hlsjs.on(this.HLSEvents.FRAG_CHANGED,this._onFragChanged.bind(this)),this.hlsjs.on(this.HLSEvents.ERROR,this._onHlsError.bind(this)),this.eventListened=!0),window.addEventListener("beforeunload",function(){n.p2pEnabled&&n.disableP2P()}),window.addEventListener("unload",function(){n.p2pEnabled&&n.disableP2P()})}}},{key:"_onFragLoading",value:function(e,t){var n=t.frag.sn;(0,E.isBlockType)(t.frag.url,this.config.p2pBlackList)||(this.logger.debug("loading frag "+n),this.emit(m.Events.FRAG_LOADING,n))}},{key:"_onFragLoaded",value:function(e,t){var n=t.frag,r=n.sn,o=n.duration;if(!(0,E.isBlockType)(t.frag.url,this.config.p2pBlackList)&&(this.hlsjs.config.currLoaded=r,this.emit(m.Events.FRAG_LOADED,r,o),this.hlsjs.config.currLoadedDuration=t.frag.duration,this.trackerTried||this.tracker.connected||!this.config.p2pEnabled||(this.tracker.resumeP2P(),this.trackerTried=!0),this.config.p2pEnabled&&this.bufMgr.hasSegOfSN(r+1))){var i=this.bufMgr.getSegIdbySN(r+1),s=this.bufMgr.getSegById(i).level;this.hlsjs.nextLoadLevel=s}}},{key:"_onFragChanged",value:function(e,t){if(!(0,E.isBlockType)(t.frag.url,this.config.p2pBlackList)){this.logger.debug("frag changed: "+t.frag.sn);var n=t.frag,r=n.sn,o=n.duration;this.hlsjs.config.currPlay=r,this.emit(m.Events.FRAG_CHANGED,r,o)}}},{key:"_onHlsError",value:function(e,t){t.fatal?this.logger.error(t.type+" details "+t.details+" reason "+t.reason):this.logger.warn(t.type+" details "+t.details+" reason "+t.reason);var n=this.hlsjs.constructor.ErrorDetails;switch(t.details){case n.BUFFER_STALLED_ERROR:this.fetcher&&this.fetcher.errsBufStalled++;break;case n.INTERNAL_EXCEPTION:this.fetcher&&this.fetcher.errsInternalExpt++}}},{key:"disableP2P",value:function(){this.logger&&this.logger.warn("disable P2P"),this.removeAllListeners(),this.p2pEnabled&&(this.p2pEnabled=!1,this.config.p2pEnabled=this.hlsjs.config.p2pEnabled=this.p2pEnabled,this.tracker&&(this.tracker.stopP2P(),this.tracker={},this.fetcher=null,this.bufMgr.destroy(),this.bufMgr=null,this.hlsjs.config.fLoader=this.hlsjs.constructor.DefaultConfig.loader))}},{key:"enableP2P",value:function(){return this.p2pEnabled?null:(this.logger.warn("enable P2P"),this.p2pEnabled=!0,this.config.p2pEnabled=this.hlsjs.config.p2pEnabled=this.p2pEnabled,this._init(this.channel,this.browserInfo),this)}},{key:"destroy",value:function(){this.disableP2P(),this.removeAllListeners(),console.warn("destroy p2p engine")}},{key:"version",get:function(){return t.version}}],[{key:"isSupported",value:function(){var e=(0,m.getBrowserRTC)();return e&&void 0!==e.RTCPeerConnection.prototype.createDataChannel}}]),t}(l.default);C.WEBRTC_SUPPORT=!!(0,m.getBrowserRTC)(),C.version="0.12.3",t.default=C,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=n(5),i=n(3),s=function(e){return e&&e.__esModule?e:{default:e}}(i),a=r({wsSignalerAddr:"wss://signal.cdnbye.com",wsMaxRetries:15,wsReconnectInterval:30,p2pEnabled:!0,maxBufferSize:{pc:536870912,mobile:268435456},dcDownloadTimeout:20,logLevel:"none",tag:"",webRTCConfig:{},p2pBlackList:["aac","mp3","vtt","webvtt","key"],agent:"",token:"free",appName:void 0,appId:void 0},o.config);a.channelId=function(e){var t=(arguments.length>1&&void 0!==arguments[1]&&arguments[1],s.default.parseURL(e));return""+(t.netLoc.substr(2)+t.path.split(".")[0])},a.segmentId=function(e,t,n){return e+"-"+t},a.validateSegment=function(e,t,n){return!0},a.getStats=function(e,t,n){},a.getPeerId=function(e){},a.getPeersInfo=function(e){},t.default=a,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),l=r(u),f=n(9),d=r(f),h=n(11),p=r(h),v=n(1),g=(n(2),n(4)),y=r(g),m=15,b=8,_=function(e){function t(e,n,r){i(this,t);var o=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return o.engine=e,o.logger=e.logger,o.config=r,o.connected=!1,o.scheduler=new d.default(e,r),o.DCMap=new Map,o.failedDCSet=new Set,o.signalerWs=null,o.fetcher=n,o.peers=[],o.minConns=0,o.requestMorePeers=(0,v.getPeersThrottle)(o._requestMorePeers,o),o.maxConns=y.default.isMobile()?b:m,o}return a(t,e),c(t,[{key:"resumeP2P",value:function(){var e=this;this.fetcher.btAnnounce().then(function(t){e.logger.info("announce request response "+JSON.stringify(t)),e.engine.peerId=e.peerId=t.id,e.minConns=t.min_conns,e.signalerWs=e._initSignalerWs(),0===t.peers.length?e.requestMorePeers():e._handlePeers(t.peers),e.engine.emit("peerId",e.peerId);var n=e.engine.config.getPeerId;n&&"function"==typeof n&&n(e.peerId)}).catch(function(e){console.warn(e)})}},{key:"stopP2P",value:function(){this.fetcher.destroy(),this.fetcher=null,this.requestMorePeers(!0),this.scheduler.destroy(),this.scheduler=null,this.signalerWs&&(this.signalerWs.destroy(),this.signalerWs=null),this.peers=[];var e=!0,t=!1,n=void 0;try{for(var r,o=this.DCMap.values()[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){r.value.destroy()}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}this.DCMap.clear(),this.failedDCSet.clear(),this.logger.warn("tracker stop p2p")}},{key:"destroy",value:function(){this.stopP2P(),this.removeAllListeners(),this.logger.warn("destroy tracker")}},{key:"_handlePeers",value:function(e){var t=this,n=!0,r=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var c=s.value;this.peers.push({id:c.id})}}catch(e){r=!0,i=e}finally{try{!n&&a.return&&a.return()}finally{if(r)throw i}}this.peers=this.peers.filter(function(e){for(var n=[].concat(o(t.DCMap.keys()),o(t.failedDCSet.keys())),r=0;r<n.length;r++){var i=n[r];if(e.id===i)return!1}return!0})}},{key:"_tryConnectToAllPeers",value:function(){var e=this;0!==this.peers.length&&(this.logger.info("try connect to "+this.peers.length+" peers"),this.peers.forEach(function(t){var n=new v.DataChannel(e.engine,e.peerId,t.id,!0,e.config);e.DCMap.set(t.id,n),e._setupDC(n)}),this.peers=[])}},{key:"_setupDC",value:function(e){var t=this;e.on(v.Events.DC_SIGNAL,function(n){var r=e.remotePeerId;t.signalerWs.sendSignal(r,n)}).once(v.Events.DC_ERROR,function(){t.logger.warn("datachannel connect "+e.channelId+" failed"),t.scheduler&&t.scheduler.deletePeer(e),t.DCMap.delete(e.remotePeerId),t.failedDCSet.add(e.remotePeerId),e.destroy(),t.requestMorePeers(),e.connected&&t.fetcher?t.fetcher.decreConns():t.fetcher.increFailConns()}).once(v.Events.DC_CLOSE,function(){t.logger.warn("datachannel "+e.channelId+" closed"),t.scheduler&&t.scheduler.deletePeer(e),t.DCMap.delete(e.remotePeerId),t.failedDCSet.add(e.remotePeerId),e.destroy(),t.requestMorePeers(),t.fetcher&&t.fetcher.decreConns()}).once(v.Events.DC_OPEN,function(){t.scheduler.handshakePeer(e);var n=!(t.scheduler.peersNum<=t.minConns);t.requestMorePeers(n),t.fetcher.increConns()})}},{key:"_initSignalerWs",value:function(){var e=this,t=new p.default(this.engine,this.peerId,this.config);return t.onopen=function(){e.connected=!0,e._tryConnectToAllPeers()},t.onmessage=function(t){var n=JSON.parse(t.data),r=n.action;switch(r){case"signal":var o=n.from_peer_id;if(e.failedDCSet.has(o)||!o)return;if(e.logger.debug("handle signal of "+o),n.data)e._handleSignal(o,n.data);else{e.logger.info("signaling "+o+" not found");var i=e.DCMap.get(o);i&&(i.destroy(),e.DCMap.delete(o)),e.failedDCSet.add(o)}break;case"reject":e.stopP2P();break;default:e.logger.warn("Signaler websocket unknown action "+r)}},t.onclose=function(){e.connected=!1},t}},{key:"_handleSignal",value:function(e,t){var n=this.DCMap.get(e);if(n&&n.connected)return void this.logger.info("datachannel had connected, signal ignored");if(!n){if(this.logger.debug("receive node "+e+" connection request"),this.failedDCSet.has(e))return;if(this.scheduler.peersNum>this.maxConns)return void this.logger.info("Peers num excess MAX_CONNS "+this.maxConns);n=new v.DataChannel(this.engine,this.peerId,e,!1,this.config),this.DCMap.set(e,n),this._setupDC(n)}n.receiveSignal(t)}},{key:"_requestMorePeers",value:function(){var e=this;this.scheduler.peersNum<=this.minConns&&this.fetcher.btGetPeers().then(function(t){e.logger.info("request more peers "+JSON.stringify(t)),e._handlePeers(t.peers),e._tryConnectToAllPeers()}).catch(function(t){e.logger.error("_requestMorePeers error "+t)})}}]),t}(l.default);t.default=_,e.exports=t.default},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),u=function(e){return e&&e.__esModule?e:{default:e}}(c),l=n(1),f=2.5,d=function(e){function t(e,n){o(this,t);var r=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.engine=e,r.config=n,r.bufMgr=null,r.peerMap=new Map,r.bitset=new Set,r.bitCounts=new Map,r.targetPeer=null,r._setupEngine(),r.currPlaySN=0,r.currLostSN=-1,r.checkTimer=null,r.config.live||(r.checkTimer=window.setInterval(function(){r.checkPeers()},1e3*f)),r.requestingSet=new Set,r.dcDownloadTimeout=n.dcDownloadTimeout,r.mBufferedDuration=0,r}return s(t,e),a(t,[{key:"updateLoadedSN",value:function(e){this.bitset.add(e),this.bitCounts.has(e)&&this.bitCounts.delete(e);var t={event:l.Events.DC_HAVE,sn:e};this._broadcastToPeers(t)}},{key:"updatePlaySN",value:function(e){this.engine.logger.debug("updatePlaySN "+e),this.currPlaySN=e}},{key:"checkPeers",value:function(){var e=this.engine.logger;if(!(this.currLostSN>=this.currPlaySN-5)&&this.hasPeers){var t=[].concat(r(this.peerMap.values())).filter(function(e){return e.isAvailable});if(0!==t.length){var n=[],o=this.config,i=o.prefetchNum,s=o.endSN;this.config.live&&(this.config.maxPrefetchCount=5);for(var a=0,c=this.loadingSN+1;n.length<=i&&n.length<t.length&&a<=this.config.maxPrefetchCount;){if(!this.config.live&&c>s)return;if(this.bitset.has(c))c++;else{if(c!==this.loadingSN&&this.bitCounts.has(c)&&!this.requestingSet.has(c)){var u=!0,l=!1,f=void 0;try{for(var d,h=t[Symbol.iterator]();!(u=(d=h.next()).done);u=!0){var p=d.value;if(!n.includes(p)&&p.bitset.has(c)&&p.isAvailable){p.requestDataBySN(c,!1),e.info("request prefetch "+c+" from peer "+p.remotePeerId+" downloadNum "+p.downloadNum),n.push(p),this.requestingSet.add(c);break}}}catch(e){l=!0,f=e}finally{try{!u&&h.return&&h.return()}finally{if(l)throw f}}}a++,c++}}}}}},{key:"chokePeerRequest",value:function(e){var t={event:l.Events.DC_CHOKE};e?e.sendJson(t):this._broadcastToPeers(t)}},{key:"unchokePeerRequest",value:function(e){var t={event:l.Events.DC_UNCHOKE};e?e.sendJson(t):this._broadcastToPeers(t)}},{key:"stopRequestFromPeers",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.peerMap.values()[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){r.value.choked=!0}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}}},{key:"resumeRequestFromPeers",value:function(){var e=!0,t=!1,n=void 0;try{for(var r,o=this.peerMap.values()[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){r.value.choked=!1}}catch(e){t=!0,n=e}finally{try{!e&&o.return&&o.return()}finally{if(t)throw n}}}},{key:"deletePeer",value:function(e){var t=this;this.peerMap.has(e.remotePeerId)&&(e.bitset.forEach(function(e){t._decreBitCounts(e)}),this.peerMap.delete(e.remotePeerId)),this._peersStats([].concat(r(this.peerMap.keys())))}},{key:"handshakePeer",value:function(e){this._setupDC(e),e.sendBitField(Array.from(this.bitset))}},{key:"addPeer",value:function(e){this.engine.logger.debug("add peer "+e.remotePeerId),this.peerMap.set(e.remotePeerId,e),this._peersStats([].concat(r(this.peerMap.keys())))}},{key:"peersHasSN",value:function(e){return this.bitCounts.has(e)}},{key:"hasAndSetTargetPeer",value:function(e){var t=this.engine.logger;if(this.bufferedDuration<=6)return!1;if(this.requestingSet.has(e))return!0;if(!this.hasIdlePeers||!this.peersHasSN(e))return!1;var n=!0,r=!1,o=void 0;try{for(var i,s=this.peerMap.values()[Symbol.iterator]();!(n=(i=s.next()).done);n=!0){var a=i.value;if(a.isAvailableUrgently&&a.bitset.has(e))return t.info("found sn "+e+" from peer "+a.remotePeerId),this.targetPeer=a,!0}}catch(e){r=!0,o=e}finally{try{!n&&s.return&&s.return()}finally{if(r)throw o}}return t.warn("idle peers hasn't sn "+e+" or busy"),!1}},{key:"load",value:function(e,t,n){var r=this.engine.logger;this.context=e;var o=e.frag,i=this.config.segmentId(o.level,o.sn,o.url);if(this.callbacks=n,this.stats={trequest:performance.now(),retry:0,tfirst:0,tload:0,loaded:0},this.bufMgr.hasSegOfId(i)){var s=this.bufMgr.getSegById(i),a={url:e.url,data:s.data},c=void 0,u=void 0,l=void 0,f=void 0,d=void 0;c=performance.now(),u=l=c+50,f=d=o.loaded=s.size;var h={trequest:c,tfirst:u,tload:l,loaded:f,total:d,retry:0};return o.loadByP2P=!0,e.frag.fromPeerId=s.fromPeerId,r.info("scheduler found "+i+" at "+o.sn+" in bufMgr"),void this.callbacks.onSuccess(a,h,this.context)}this.criticalSeg={sn:o.sn,segId:i};var p=this.mBufferedDuration-5;p>this.dcDownloadTimeout?p=this.dcDownloadTimeout:p<2&&(p=2),this.requestingSet.has(o.sn)?r.info("wait for criticalSeg segId "+i+" at "+o.sn+" timeout "+p):(this.targetPeer.requestDataById(i,o.sn,!0),r.info("request criticalSeg segId "+i+" at "+o.sn+" timeout "+p)),this.criticaltimeouter=window.setTimeout(this._criticaltimeout.bind(this),1e3*p)}},{key:"destroy",value:function(){var e=this.engine.logger;this.peersNum>0&&this.peerMap.clear(),this.removeAllListeners(),this.checkTimer&&(window.clearInterval(this.checkTimer),this.checkTimer=null),e.warn("destroy scheduler")}},{key:"_setupDC",value:function(e){var t=this,n=this.engine.logger;e.on(l.Events.DC_BITFIELD,function(n){n.field&&(e.bitset=new Set(n.field),n.field.forEach(function(e){t.bitset.has(e)||t._increBitCounts(e)}),t.addPeer(e))}).on(l.Events.DC_HAVE,function(n){if(n.sn&&e.bitset){var r=n.sn;if(e.bitset.add(r),t.bitset.has(r)||t._increBitCounts(r),t.config.live){var o=r-60;o>0&&e.bitset.delete(o)}}}).on(l.Events.DC_LOST,function(n){if(n.sn&&e.bitset){var r=n.sn;e.bitset.delete(r),t._decreBitCounts(r)}}).on(l.Events.DC_PIECE_ACK,function(e){e.size&&t.engine.fetcher.reportUploaded(e.size)}).on(l.Events.DC_PIECE,function(e){t.criticalSeg&&t.criticalSeg.segId===e.seg_id&&(t.stats.tfirst=Math.max(performance.now(),t.stats.trequest))}).on(l.Events.DC_PIECE_NOT_FOUND,function(r){t.criticalSeg&&t.criticalSeg.segId===r.seg_id&&(window.clearTimeout(t.criticaltimeouter),n.info("DC_PIECE_NOT_FOUND"),t._criticaltimeout()),e.bitset.delete(r.sn),t.requestingSet.delete(r.sn),t._decreBitCounts(r.sn)}).on(l.Events.DC_RESPONSE,function(r){var o=r.level,i=r.sn,s=r.data,a=r.seg_id,c=t.criticalSeg&&t.criticalSeg.segId===a;if(t.config.validateSegment(o,i,s)){if(c){n.info("receive criticalSeg seg_id "+a),window.clearTimeout(t.criticaltimeouter),t.criticaltimeouter=null,e.miss=0;var u=t.stats;u.tload=Math.max(u.tfirst,performance.now()),u.loaded=u.total=s.byteLength,t.criticalSeg=null;var l=t.context.frag;l.fromPeerId=e.remotePeerId,l.loadByP2P=!0,t.callbacks.onSuccess(r,u,t.context)}else t.bufMgr.handleFrag(i,o,a,s,e.remotePeerId,!1),t.updateLoadedSN(i);t.requestingSet.delete(i)}else n.warn("segment "+o+"-"+i+" validate failed"),c&&(window.clearTimeout(t.criticaltimeouter),t._criticaltimeout())}).on(l.Events.DC_REQUEST,function(n){var r="";if((r=n.seg_id?n.seg_id:t.bufMgr.getSegIdbySN(n.sn))&&t.bufMgr.hasSegOfId(r)){var o=t.bufMgr.getSegById(r);e.sendBuffer(o.sn,o.level,o.segId,o.data)}else e.sendJson({event:l.Events.DC_PIECE_NOT_FOUND,seg_id:r,sn:n.sn})}).on(l.Events.DC_TIMEOUT,function(e){})}},{key:"_setupEngine",value:function(){var e=this;this.engine.on(l.Events.FRAG_LOADING,function(t){e.loadingSN=t,e.config.live&&e.checkPeers()}).on(l.Events.FRAG_LOADED,function(t,n){e.updateLoadedSN(t)}).on(l.Events.FRAG_CHANGED,function(t,n){e.updatePlaySN(t)})}},{key:"_broadcastToPeers",value:function(e){if(this.peersNum>0){var t=!0,n=!1,r=void 0;try{for(var o,i=this.peerMap.values()[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){o.value.sendJson(e)}}catch(e){n=!0,r=e}finally{try{!t&&i.return&&i.return()}finally{if(n)throw r}}}}},{key:"_getIdlePeer",value:function(){return[].concat(r(this.peerMap.values())).filter(function(e){return e.isAvailable})}},{key:"_decreBitCounts",value:function(e){if(this.bitCounts.has(e)){var t=this.bitCounts.get(e);1===t?this.bitCounts.delete(e):this.bitCounts.set(e,t-1)}}},{key:"_increBitCounts",value:function(e){if(this.bitCounts.has(e)){var t=this.bitCounts.get(e);this.bitCounts.set(e,t+1)}else this.bitCounts.set(e,1)}},{key:"_criticaltimeout",value:function(){this.engine.logger.warn("critical request sn "+this.criticalSeg.sn+" timeout"),this.criticaltimeouter=null,this.targetPeer&&this.targetPeer.loadtimeout(),this.callbacks.onTimeout(this.stats,this.context,null)}},{key:"_peersStats",value:function(e){this.engine.emit("peers",e);var t=this.engine.config.getPeersInfo;t&&"function"==typeof t&&t(e)}},{key:"hasPeers",get:function(){return this.peersNum>0}},{key:"peersNum",get:function(){return this.peerMap.size}},{key:"hasIdlePeers",get:function(){var e=this.engine.logger,t=this._getIdlePeer().length;return e.info("peers: "+this.peersNum+" idle peers: "+t),t>0}},{key:"bufferedDuration",get:function(){for(var e=this.engine.media,t=0,n=e.currentTime,r=e.buffered,o=r.length-1;o>=0;o--)if(n>=r.start(o)&&n<=r.end(o)){t=r.end(o)-n;break}return this.engine.logger.info("bufferedDuration "+t),this.mBufferedDuration=t,t>0?t:0}},{key:"bufferManager",set:function(e){var t=this;this.bufMgr=e,e.on(l.Events.BM_LOST,function(e){t.currLostSN=e,t.config.live||t._broadcastToPeers({event:l.Events.DC_LOST,sn:e}),t.bitset.delete(e),t.bitCounts.delete(e)})}}]),t}(u.default);t.default=d,e.exports=t.default},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),c=n(0),u=r(c),l=n(12),f=r(l),d=function(e){function t(e,n,r){o(this,t);var s=i(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return s.engine=e,s.logger=e.logger,s.peerId=n,s.config=r,s.wsAddr=r.wsSignalerAddr,s.connected=!1,s._ws=s._init(n),s}return s(t,e),a(t,[{key:"_init",value:function(e){var t=this,n={maxRetries:this.config.wsMaxRetries,minReconnectionDelay:1e3*this.config.wsReconnectInterval},r="?id="+e,o=new f.default(this.wsAddr+r,void 0,n);return o.onopen=function(){t.logger.info("Signaler websocket connection opened"),t.connected=!0,t.onopen&&t.onopen(),t._startPing()},o.push=o.send,o.send=function(e){var n=JSON.stringify(e);o.push(n),t._resetPing()},o.onmessage=function(e){t.onmessage&&t.onmessage(e)},o.onclose=function(e){t.logger.warn("Signaler websocket closed "+e.code+" "+e.reason),t.onclose&&t.onclose(),t.connected=!1,t._stopPing()},o.onerror=function(e){t.logger.warn("Signaler websocket error")},o}},{key:"sendSignal",value:function(e,t){var n={action:"signal",to_peer_id:e,data:t};this._send(n)}},{key:"_send",value:function(e){this.connected?this._ws.send(e):this.logger.warn("signaler closed, send msg failed")}},{key:"_startPing",value:function(){var e=this;this.pingTimer=window.setInterval(function(){e._ws.send(9)},12e4)}},{key:"_resetPing",value:function(){this._stopPing(),this._startPing()}},{key:"_stopPing",value:function(){window.clearInterval(this.pingTimer),this.pingTimer=null}},{key:"close",value:function(){this.logger.warn("close signal client"),this.connected=!1,this._ws.close(1e3,"stop signaling",{keepClosed:!0})}},{key:"destroy",value:function(){this.close(),this._ws=null,this.removeAllListeners(),this.logger.warn("destroyt signaler")}}]),t}(u.default);t.default=d,e.exports=t.default},function(e,t,n){"use strict";var r=function(e){return e&&2===e.CLOSING},o=function(){return"undefined"!=typeof WebSocket&&r(WebSocket)},i=function(){return{constructor:o()?WebSocket:null,maxReconnectionDelay:1e4,minReconnectionDelay:1500,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,debug:!1}},s=function(e,t,n){Object.defineProperty(t,n,{get:function(){return e[n]},set:function(t){e[n]=t},enumerable:!0,configurable:!0})},a=function(e){return e.minReconnectionDelay+Math.random()*e.minReconnectionDelay},c=function(e,t){var n=t*e.reconnectionDelayGrowFactor;return n>e.maxReconnectionDelay?e.maxReconnectionDelay:n},u=["onopen","onclose","onmessage","onerror"],l=function(e,t,n){Object.keys(n).forEach(function(t){n[t].forEach(function(n){var r=n[0],o=n[1];e.addEventListener(t,r,o)})}),t&&u.forEach(function(n){e[n]=t[n]})},f=function(e,t,n){var o=this;void 0===n&&(n={});var u,d,h=0,p=0,v=!0,g=null,y={};if(!(this instanceof f))throw new TypeError("Failed to construct 'ReconnectingWebSocket': Please use the 'new' operator");var m=i();if(Object.keys(m).filter(function(e){return n.hasOwnProperty(e)}).forEach(function(e){return m[e]=n[e]}),!r(m.constructor))throw new TypeError("Invalid WebSocket constructor. Set `options.constructor`");var b=m.debug?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return console.log.apply(console,["RWS:"].concat(e))}:function(){},_=function(e,t){return setTimeout(function(){var n=new Error(t);n.code=e,Array.isArray(y.error)&&y.error.forEach(function(e){return(0,e[0])(n)}),u.onerror&&u.onerror(n)},0)},w=function(){if(b("handleClose",{shouldRetry:v}),p++,b("retries count:",p),p>m.maxRetries)return void _("EHOSTDOWN","Too many failed connection attempts");h=h?c(m,h):a(m),b("handleClose - reconnectDelay:",h),v&&setTimeout(x,h)},x=function(){if(v){b("connect");var n=u,r="function"==typeof e?e():e;u=new m.constructor(r,t),d=setTimeout(function(){b("timeout"),u.close(),_("ETIMEDOUT","Connection timeout")},m.connectionTimeout),b("bypass properties");for(var i in u)["addEventListener","removeEventListener","close","send"].indexOf(i)<0&&s(u,o,i);u.addEventListener("open",function(){clearTimeout(d),b("open"),h=a(m),b("reconnectDelay:",h),p=0}),u.addEventListener("close",w),l(u,n,y),u.onclose=u.onclose||g,g=null}};b("init"),x(),this.close=function(e,t,n){void 0===e&&(e=1e3),void 0===t&&(t="");var r=void 0===n?{}:n,o=r.keepClosed,i=void 0!==o&&o,s=r.fastClose,a=void 0===s||s,c=r.delay,l=void 0===c?0:c;if(b("close - params:",{reason:t,keepClosed:i,fastClose:a,delay:l,retriesCount:p,maxRetries:m.maxRetries}),v=!i&&p<=m.maxRetries,l&&(h=l),u.close(e,t),a){var f={code:e,reason:t,wasClean:!0};w(),u.removeEventListener("close",w),Array.isArray(y.close)&&y.close.forEach(function(e){var t=e[0],n=e[1];t(f),u.removeEventListener("close",t,n)}),u.onclose&&(g=u.onclose,u.onclose(f),u.onclose=null)}},this.send=function(e){u.send(e)},this.addEventListener=function(e,t,n){Array.isArray(y[e])?y[e].some(function(e){return e[0]===t})||y[e].push([t,n]):y[e]=[[t,n]],u.addEventListener(e,t,n)},this.removeEventListener=function(e,t,n){Array.isArray(y[e])&&(y[e]=y[e].filter(function(e){return e[0]!==t})),u.removeEventListener(e,t,n)}};e.exports=f},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),c=function(e){return e&&e.__esModule?e:{default:e}}(a),u=n(2),l=function(e){function t(e){r(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n.logger=e.logger,n.currLoaded=e.currLoaded,n.currLoadedDuration=e.currLoadedDuration,n.currPlay=e.currPlay,n.bufMgr=e.bufMgr,n.xhrLoader=new e.loader(e),n.p2pEnabled=e.p2pEnabled,n.scheduler=e.scheduler,n.fetcher=e.fetcher,n.segmentId=e.segmentId,n.blockTypes=e.p2pBlackList,n.isLive=e.live,n}return i(t,e),s(t,[{key:"destroy",value:function(){this.abort()}},{key:"abort",value:function(){this.xhrLoader.abort()}},{key:"load",value:function(e,t,n){var r=this,o=this.logger,i=e.frag,s=this.segmentId(i.level,i.sn,i.url);if((0,u.isBlockType)(i.url,this.blockTypes)){o.info("HTTP load blockType "+i.url),e.frag.loadByHTTP=!0;var a=n.onSuccess;return n.onSuccess=function(e,t,n){o.info("HTTP load time "+(t.tload-t.trequest)+"ms"),a(e,t,n)},this.xhrLoader.load(e,t,n)}if(this.p2pEnabled&&this.bufMgr.hasSegOfId(s)){o.info("bufMgr found seg sn "+i.sn+" url "+i.url);var c=this.bufMgr.getSegById(s),l={url:e.url,data:c.data},f=void 0,d=void 0,h=void 0,p=void 0,v=void 0;f=performance.now(),d=h=f+50,p=v=i.loaded=c.size;var g={trequest:f,tfirst:d,tload:h,loaded:p,total:v,retry:0};i.loadByP2P=!0,e.frag.fromPeerId=c.fromPeerId,o.debug("bufMgr loaded "+i.relurl+" at "+i.sn),window.setTimeout(function(){n.onSuccess(l,g,e)},10)}else if(this.p2pEnabled&&this.scheduler.hasAndSetTargetPeer(i.sn)){this.scheduler.load(e,t,n);var y=n.onTimeout;n.onTimeout=function(e,s){o.info("P2P timeout switched to HTTP load "+i.relurl+" at "+i.sn),r.xhrLoader.load(s,t,n),n.onTimeout=y};var m=n.onSuccess;n.onSuccess=function(e,t,a){n.onSuccess=function(){o.warn("p2p loaded "+i.sn+", http ignore")},r.bufMgr.hasSegOfId(s)||r.bufMgr.handleFrag(i.sn,i.level,s,e.data,i.fromPeerId||r.fetcher.peerId,!0),i.loadByP2P||r.fetcher.reportFlow(t.total),i.loaded=t.loaded,o.info((i.loadByP2P?"P2P":"HTTP")+" loaded segment id "+s),m(e,t,a)}}else{o.info("HTTP load "+i.relurl+" at "+i.sn+" level "+i.level),e.frag.loadByHTTP=!0,this.xhrLoader.load(e,t,n);var b=n.onSuccess;n.onSuccess=function(e,t,n){r.bufMgr.hasSegOfId(s)||r.bufMgr.handleFrag(i.sn,i.level,s,e.data,r.fetcher.peerId,!0),r.fetcher.reportFlow(t.total),o.info("HTTP load time "+(t.tload-t.trequest)+"ms"),b(e,t,n)}}}}]),t}(c.default);t.default=l,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),l=r(u),f=n(1),d=n(4),h=r(d),p=104857600,v=function(e){function t(e,n){i(this,t);var r=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));r.engine=e,r.config=n;var o=e.browserInfo.device;return r.maxBufSize=o===h.default.device.PC_WEB||o===h.default.device.PC_NATIVE?n.maxBufferSize.pc:n.maxBufferSize.mobile,n.live&&(r.maxBufSize=p),r._segPool=new Map,r._currBufSize=0,r.sn2Id=new Map,r.overflowed=!1,r}return a(t,e),c(t,[{key:"hasSegOfId",value:function(e){return this._segPool.has(e)}},{key:"hasSegOfSN",value:function(e){return this.sn2Id.has(e)}},{key:"handleFrag",value:function(e,t,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",i=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s=void 0,a=r.byteLength;if(i){var c=f.Buffer.from(r);s=new f.Buffer(a),c.copy(s)}else s=r;var u={sn:e,level:t,segId:n,data:s,size:a,fromPeerId:o};this._addSeg(u),this.sn2Id.set(e,u.segId)}},{key:"_addSeg",value:function(e){var t=this.engine.logger;for(this._segPool.set(e.segId,e),t.info("segment pool add seg "+e.segId+" level "+e.level),this._currBufSize+=parseInt(e.size),t.debug("seg.size "+e.size+" _currBufSize "+this._currBufSize+" maxBufSize "+this.maxBufSize);this._currBufSize>this.maxBufSize;){var n=[].concat(o(this._segPool.values())).shift();t.info("pop seg "+n.segId+" at "+n.sn),this._segPool.delete(n.segId),this.sn2Id.delete(n.sn),this._currBufSize-=parseInt(n.size),this.overflowed||(this.overflowed=!0),this.emit(f.Events.BM_LOST,n.sn)}}},{key:"getSegById",value:function(e){return this._segPool.get(e)}},{key:"getSegIdbySN",value:function(e){return this.sn2Id.get(e)}},{key:"clear",value:function(){this._segPool.clear(),this.sn2Id.clear(),this._currBufSize=0}},{key:"destroy",value:function(){this.clear(),this.removeAllListeners()}},{key:"currBufSize",get:function(){return this._currBufSize}}]),t}(l.default);t.default=v,e.exports=t.default},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(){}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(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)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(2),a={debug:0,info:1,warn:2,error:3,none:4},c=["_debugP","_infoP","_warnP","_errorP"],u=function(){function e(t){r(this,e),this.config=t,!0===t.logLevel||"1"===(0,s.getQueryParam)("_debug")?t.logLevel="debug":t.logLevel in a&&!1!==t.logLevel||(t.logLevel="none");for(var n=0;n<a[t.logLevel];n++)this[c[n]]=o;this._debugP=o}return i(e,[{key:"debug",value:function(e){this._debugP(e)}},{key:"info",value:function(e){this._infoP(e)}},{key:"warn",value:function(e){this._warnP(e)}},{key:"error",value:function(e){this._errorP(e)}},{key:"_debugP",value:function(e){console.log(e)}},{key:"_infoP",value:function(e){console.info(e)}},{key:"_warnP",value:function(e){console.warn(e)}},{key:"_errorP",value:function(e){console.error(e)}}]),e}();t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){var e="unknown";for(var t in r)if(window[t]){e=r[t];break}return e};var r={DPlayer:"dplayer",jwplayer:"jwplayer",videojs:"videojs",Clappr:"clappr",ckplayer:"ckplayer",MediaElementPlayer:"mediaelement",MediaElement:"mediaelement",TcPlayer:"tcplayer",flowplayer:"flowplayer",Chimee:"chimee",ChimeePlayer:"chimee",HlsJsPlayer:"xgplayer",fluidPlayer:"fluidplayer",OpenPlayer:"openplayer",Plyr:"plyr"};e.exports=t.default}])});