From 658bf783880302379fe556850e94e77da6676389 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Sat, 23 May 2015 06:51:37 +0200 Subject: build --- webtorrent.min.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/webtorrent.min.js b/webtorrent.min.js index 11ed5ea..8216ba1 100644 --- a/webtorrent.min.js +++ b/webtorrent.min.js @@ -1,7 +1,7 @@ -(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(a,s){if(!t[a]){if(!e[a]){var f=typeof require=="function"&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[a]={exports:{}};e[a][0].call(c.exports,function(t){var r=e[a][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a0){return r[Math.random()*r.length|0]}else{return-1}}},{}],5:[function(e,t,r){(function(r,n){t.exports=k;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var f=e("end-of-stream");var u=e("events").EventEmitter;var c=e("./file-stream");var l=e("inherits");var h=e("multistream");var d=e("once");var p=e("simple-sha1");var g=16*1024;var m=0;var v=1;var y=2;function _(){}l(w,u);function w(e,t,r,n){var i=this;u.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!n;if(typeof r==="number"){i.buffer=null;i.length=r}else{i.buffer=r;i.length=r.length}i._reset()}w.prototype.readBlock=function(e,t,r){var n=this;r=s(r);if(!n.buffer||!n._verifyOffset(e)){return r(new Error("invalid block offset "+e))}r(null,n.buffer.slice(e,e+t))};w.prototype.writeBlock=function(e,t,r){var n=this;r=s(r);if(!n._verifyOffset(e)||!n._verifyBlock(e,t)){return r(new Error("invalid block "+e+":"+t.length))}n._lazyAllocBuffer();var i=e/g;if(n.blocks[i]===y){return r(null)}t.copy(n.buffer,e);n.blocks[i]=y;n.blocksWritten+=1;if(n.blocksWritten===n.blocks.length){n.verify()}r(null)};w.prototype.reserveBlock=function(e){var t=this;var r=t.blocks.length;for(var n=0;n0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,r,false)}};b.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,r,false)}};b.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var r=new c(t,e);t.storage.emit("select",r.startPiece,r.endPiece,true,r.notify.bind(r));f(r,function(){t.storage.emit("deselect",r.startPiece,r.endPiece,true)});return r};b.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(t,r){if(t)return e(t);var n=window.URL.createObjectURL(new window.Blob([r]));e(null,n)})};b.prototype.getBuffer=function(e){var t=this;e=s(d(e));var r;if(t.storage.buffer){var i=function(){r=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,r)};if(t.done)i();else t.once("done",i)}else{r=new n(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(r,o);o+=e.length}).on("end",function(){e(null,r)}).on("error",e)}};b.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){r.nextTick(function(){e.emit("done")})}};l(k,u);function k(e,t){var r=this;u.call(r);if(!a.enabled)r.setMaxListeners(0);if(!t)t={};r.bitfield=new i(e.pieces.length);r.done=false;r.closed=false;r.readonly=true;if(!t.nobuffer){r.buffer=new n(e.length)}var o=r.pieceLength=e.pieceLength;var s=e.lastPieceLength;var f=e.pieces.length;r.pieces=e.pieces.map(function(e,n){var i=n*o;var a=i+(n===f-1?s:o);var u=r.buffer?r.buffer.slice(i,a):a-i;var c=new w(n,e,u,!!t.noVerify);c.on("done",r._onPieceDone.bind(r,c));return c});r.files=e.files.map(function(e){var t=e.offset;var n=t+e.length-1;var i=t/o|0;var a=n/o|0;var s=r.pieces.slice(i,a+1);var f=new b(r,e,s,o);f.on("done",r._onFileDone.bind(r,f));return f})}k.BLOCK_LENGTH=g;k.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];t=d(t||function(){});var n=0;var i=new h(e);var a=new o(r.pieceLength,{zeroPadding:false});i.on("error",f);r.once("done",u);i.pipe(a).on("data",s).on("error",f);function s(e){var t=n;n+=1;var i=0;var a=new o(g,{zeroPadding:false});a.on("data",s);a.on("end",f);function s(e){var n=i*g;i+=1;r.writeBlock(t,n,e)}function f(){u()}function u(){a.removeListener("data",s);a.removeListener("end",f)}a.end(e)}function f(e){c();t(e)}function u(){c();t(null)}function c(){i.removeListener("error",f);a.removeListener("data",s);a.removeListener("error",f);r.removeListener("done",u)}};Object.defineProperty(k.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*g)},0)}});Object.defineProperty(k.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var r=0,n=e.pieces.length;rt||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;a("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||L});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};B.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;a("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(i,n);if(r.unref)r.unref()}}var o=0;function s(){if(e.peerPieces.length!==t.storage.pieces.length)return;for(;ok){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(r,n,i,o)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(i,n);if(r.unref)r.unref();e.isSeeder=false;s()};B.prototype._onStorage=function(){var e=this;if(e.destroyed)return;a("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};B.prototype._onStoragePiece=function(e){var t=this;a("piece done %s",e.index);t._reservations[e.index]=null;t.swarm.wires.forEach(function(t){t.have(e.index)});t._gcSelections()};B.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};B.prototype._gcSelections=function(){var e=this;for(var t=0;t=r)return;var n=R(e,I);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var n=t._selections[r];var o;if(t.strategy==="rarest"){var a=n.from+n.offset;var s=n.to;var f=s-a+1;var u={};var c=0;var l=i(a,s,u);while(c=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var r=e.downloadSpeed()||1;if(r>S)return function(){return true};var n=Math.max(1,e.requests.length)*b.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.storage.bitfield.get(e))return true;var a=t.storage.pieces[e];var s=a.blocks.length-a.blocksWritten;for(;o0)continue;i--;return false}return true}}function s(e){var r=e;for(var n=e;n=n)return true;var o=a();for(var f=0;f0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var r=0;var n=0;for(;n=S)continue;if(2*u>n||u>o)continue;a=f;o=u}if(!a)return false;for(s=0;s=s)return false;var f=e.requests.length===0&&i.storage.numMissing<30;var u=i.storage.reserveBlock(t,f);if(!u&&!f&&n&&i._hotswap(e,t)){u=i.storage.reserveBlock(t,false)}if(!u)return false;var c=i._reservations[t];if(!c){c=i._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,o){if(!i.ready){i.once("ready",function(){h(n,o)});return}if(c[l]===e)c[l]=null;if(n){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort,n.message);i.storage.cancelBlock(t,u.offset);r.nextTick(i._update.bind(i));return false; -}else{a("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,u.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,u.offset)}r.nextTick(i._update.bind(i))})}}e.request(t,u.offset,u.length,h);return true};B.prototype.createServer=function(e){var t=this;if(typeof w==="function"){return new w(t,e)}};B.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function R(e,t){return Math.ceil(2+t*e.downloadSpeed()/b.BLOCK_LENGTH)}function M(e){return Math.random()*e|0}function P(e,t){var r=e.map(function(e,t){return t});for(var n=r.length-1;n>0;--n){var i=M(n+1);var o=r[n];r[n]=r[i];r[i]=o}r.forEach(function(r){t(e[r],r,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":4,"./server":44,"./storage":5,_process:52,"addr-to-ip-port":7,"bittorrent-swarm":9,"create-torrent":71,debug:108,events:49,fs:43,inherits:116,"parse-torrent":121,"re-emitter":135,"run-parallel":136,"simple-get":44,"torrent-discovery":143,uniq:180,ut_metadata:181,ut_pex:44}],7:[function(e,t,r){var n=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=n.exec(e);if(!t)throw new Error("invalid addr: "+e);i[e]=[t[1],Number(t[2])];o+=1}return i[e]};t.exports.reset=function s(){i={}}},{}],8:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r>3;if(e%8!==0)t++;return t}n.prototype.get=function(e){var t=e>>3;return t>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length>e%8}else if(r>e%8)}};n.prototype._grow=function(e){if(this.buffer.length=e.maxConns){return}o("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;o("tcp connect attempt to %s",t.addr);var r=i(t.addr);var n=r[0];var a=r[1];var s=t.conn=u.connect({host:n,port:a,localAddress:e._hostname});s.once("connect",function(){t.onConnect()});s.once("error",function(e){t.destroy(e)});t.setConnectTimeout();s.on("close",function(){if(e.destroyed)return;if(t.retries>=p.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,p.length);return}function r(){var r=c.createOutgoingTCPPeer(t.addr,e);r.retries=t.retries+1;e._queue.push(r);e._drain()}var n=p[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var i=setTimeout(r,n);if(i.unref)i.unref()})};g.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};g.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":10,"./lib/tcp-pool":11,_process:52,"addr-to-ip-port":44,buffer:45,debug:24,dezalgo:27,events:49,inherits:30,net:44,speedometer:31}],10:[function(e,t,r){var n=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;r.createWebRTCPeer=function(e,t){var r=new s(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(e){r.destroy(e)});r.setConnectTimeout()}return r};r.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var r=new s(t);r.conn=e;r.addr=t;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new s(e);r.swarm=t;r.addr=e;return r};function s(e){var t=this;t.id=e;n("new Peer %s",e);t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.destroyed=false;t.timeout=null;t.retries=0;t.sentHandshake=false}s.prototype.onConnect=function(){var e=this;n("Peer %s connected",e.id);clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()});t.once("close",function(){e.destroy()});t.once("finish",function(){e.destroy()});t.once("error",function(t){e.destroy(t)});var r=e.wire=new i;r.once("end",function(){e.destroy()});r.once("finish",function(){e.destroy()});r.once("error",function(t){e.destroy(t)});r.once("handshake",function(t,r){e.onHandshake(t,r)});e.setHandshakeTimeout();t.pipe(r).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var r=this;if(!r.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(i!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}n("Peer %s got handshake %s",r.id,i);clearTimeout(r.handshakeTimeout);r.retries=0;r.wire.on("download",function(e){r.swarm.downloaded+=e;r.swarm.downloadSpeed(e);r.swarm.emit("download",e)});r.wire.on("upload",function(e){r.swarm.uploaded+=e;r.swarm.uploadSpeed(e);r.swarm.emit("upload",e)});if(!r.sentHandshake)r.handshake();r.swarm.wires.push(r.wire);var a=r.addr;if(!a&&r.conn.remoteAddress){a=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,a)};s.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};s.prototype.setConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout);e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},o);if(e.connectTimeout.unref)e.connectTimeout.unref()};s.prototype.setHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout);e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},a);if(e.handshakeTimeout.unref)e.handshakeTimeout.unref()};s.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;n("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));t.swarm.wires.splice(t.swarm.wires.indexOf(t.wire),1);if(t.conn)t.conn.destroy();if(t.wire)t.wire.destroy();if(t.swarm){t.swarm.removePeer(t.id);t.swarm._drain()}clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);t.conn=null;t.swarm=null;t.wire=null}},{"bittorrent-protocol":12,debug:24}],11:[function(e,t,r){(function(r){t.exports=f;var n=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};n("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=o.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var n=s[e._port];if(!n)return t();n.removeSwarm(e);var i=0;for(var o in n.swarms){var a=n.swarms[o];if(a)i+=1}if(i===0)n.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in s){var r=s[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}n("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;n("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=i(e);n("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});s[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address().port;n("tcp pool listening on %s",t);if(t!==e.port){s[e.port]=null;e.port=t;s[e.port]=e}e.listening=true;for(var r in e.swarms){var i=e.swarms[r];if(i)i._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var n=a.createIncomingTCPPeer(e);n.wire.once("handshake",function(i,o){var a=i.toString("hex");r();e.removeListener("close",r);var s=t.swarms[a];if(s){n.swarm=s;s._addIncomingPeer(n);n.onHandshake(i,o)}else{var f=new Error("Unexpected info hash "+a+" from incoming peer "+n.id+": destroying peer");n.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var n=t.swarms[r];if(n){t.removeSwarm(n);n._onError(e)}}}}).call(this,e("_process"))},{"./peer":10,_process:52,debug:24,dezalgo:27,net:44}],12:[function(e,t,r){(function(r){t.exports=w;var n=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var f=e("speedometer");var u=e("stream");var c=4e5;var l=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var d=new r([0,0,0,1,0]);var p=new r([0,0,0,1,1]);var g=new r([0,0,0,1,2]);var m=new r([0,0,0,1,3]);var v=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function _(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}s(w,u.Duplex);function w(){if(!(this instanceof w))return new w;u.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=f();this.downloadSpeed=f();this._keepAlive=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,h),6e4)};w.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};w.prototype.end=function(){this._onUninterested();this._onChoke();u.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error("Extension API requires a named function, e.g. function name() {}")}var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.handshake=function(e,t,n){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new r(v);i[5]|=16;if(n&&n.dht)i[7]|=1;this._push(r.concat([l,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(p)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(g)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};w.prototype.have=function(e){this._message(4,[e],null)};w.prototype.bitfield=function(e){if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this.requests.push(new _(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._callback(b(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){var t=new r(y);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var n=new r([e]);var o=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var n;for(n in this._ext){this._ext[n].onHandshake(e,t,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new n(e);this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;var n=function(n,o){if(i!==b(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new _(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._callback(b(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){b(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this.emit("port",e)};w.prototype._onExtended=function(e,t){var r,n;if(e===0&&(r=k(t))){this.peerExtendedHandshake=r;if(typeof r.m==="object"){for(n in r.m){this.peerExtendedMapping[n]=Number(r.m[n].toString())}}for(n in this._ext){if(this.peerExtendedMapping[n]){this._ext[n].onExtendedHandshake(this.peerExtendedHandshake)}}this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAlive);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};function b(e,t,r,n){for(var i=0;i=31}r.formatters.j=function(e){return JSON.stringify(e)};function o(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function a(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{if(null==e){n.removeItem("debug")}else{n.debug=e}}catch(t){}}function f(){var e;try{e=n.debug}catch(t){}return e}r.enable(f());function u(){try{return window.localStorage}catch(e){}}},{"./debug":19}],19:[function(e,t,r){r=t.exports=a;r.coerce=c;r.disable=f;r.enable=s;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function a(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var a=t-(i||t);e.diff=a;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var f=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=s[f];t=i.call(e,o);s.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){s=r.formatArgs.apply(e,s)}var u=n.log||r.log||console.log.bind(console);u.apply(e,s)}n.enabled=true;var a=r.enabled(e)?n:t;a.namespace=e;return a}function s(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(et)f=t;s=n;while(f--){if(a===t)a=0;r[a]=r[a===0?t-1:a-1];a++}if(e)r[a-1]+=e;var u=r[a-1];var c=r.length=this.size){var i=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}n()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new r(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(r.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(r.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:45,defined:33,inherits:116,"readable-stream":42}],33:[function(e,t,r){t.exports=function(){for(var e=0;e0){if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);t.length+=t.objectMode?1:r.length;if(i){t.buffer.unshift(r)}else{t.reading=false;t.buffer.push(r)}if(t.needReadable)y(e);w(e,t)}}else if(!i){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length=d){e=d}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(e===null||isNaN(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=p(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){var t=this._readableState;t.calledRead=true;var r=e;var n;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){y(this);return null}e=g(e,t);if(e===0&&t.ended){n=null;if(t.length>0&&t.decoder){n=A(e,t);t.length-=n.length}if(t.length===0)I(this);return n}var i=t.needReadable;if(t.length-e<=t.highWaterMark)i=true;if(t.ended||t.reading)i=false;if(i){t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);if(e>0)n=A(e,t);else n=null;if(n===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(t.ended&&!t.endEmitted&&t.length===0)I(this);return n};function m(e,t){var r=null;if(!i.isBuffer(t)&&"string"!==typeof t&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function v(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;if(t.length>0)y(e);else I(e)}function y(e){var t=e._readableState;t.needReadable=false;if(t.emittedReadable)return;t.emittedReadable=true;if(t.sync)r.nextTick(function(){_(e)});else _(e)}function _(e){e.emit("readable")}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){b(e,t)})}}function b(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length0)return}if(t.pipesCount===0){t.flowing=false;if(o.listenerCount(e,"data")>0)S(e);return}t.ranOut=true}function x(){if(this._readableState.ranOut){this._readableState.ranOut=false;E(this)}}c.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;for(var i=0;i=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted&&t.calledRead){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,n=e.length;r=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};a.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};a.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function s(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:45}],42:[function(e,t,r){var n=e("stream");r=t.exports=e("./lib/_stream_readable.js");r.Stream=n;r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":34,"./lib/_stream_passthrough.js":35,"./lib/_stream_readable.js":36,"./lib/_stream_transform.js":37,"./lib/_stream_writable.js":38,stream:68}],43:[function(e,t,r){},{}],44:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{dup:43}],45:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=_;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var a=1073741823;var s={};f.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0);var t=new Uint8Array(e);t.foo=function(){return 42};return t.foo()===42&&typeof t.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(r){return false}}();function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return c(this,e,arguments.length>1?arguments[1]:"utf8")}return l(this,e)}function u(e,t){e=v(e,t<0?0:y(t)|0);if(!f.TYPED_ARRAY_SUPPORT){for(var r=0;r>>1;if(r)e.parent=s;return e}function y(e){if(e>=a){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+a.toString(16)+" bytes")}return e|0}function _(e,t){if(!(this instanceof _))return new _(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};f.compare=function Q(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i>>1;case"utf8":case"utf-8":return Y(e).length;case"base64":return $(e).length;default:return e.length}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function te(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return C(this,t,r);case"binary":return L(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function re(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function ne(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return""};f.prototype.compare=function ie(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function oe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+ii){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var a=0;ao)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var a=false;for(;;){switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();a=true}}};f.prototype.toJSON=function ue(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function T(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var o=t;on)r=n;var i="";for(var o=t;or){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(tr)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function le(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o0&&(i*=256)){n+=this[e+--t]*i}return n};f.prototype.readUInt8=function de(e,t){if(!t)M(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function pe(e,t){if(!t)M(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ge(e,t){if(!t)M(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function me(e,t){if(!t)M(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function ve(e,t){if(!t)M(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ye(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o=i)n-=Math.pow(2,8*t);return n};f.prototype.readIntBE=function _e(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};f.prototype.readInt8=function we(e,t){if(!t)M(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function be(e,t){if(!t)M(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function ke(e,t){if(!t)M(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ee(e,t){if(!t)M(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function xe(e,t){if(!t)M(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Se(e,t){if(!t)M(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function Ae(e,t){if(!t)M(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Ie(e,t){if(!t)M(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Te(e,t){if(!t)M(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||te.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o=0&&(o*=256)){this[t+i]=e/o&255}return t+r};f.prototype.writeUInt8=function Be(e,t,r){ -e=+e;t=t|0;if(!r)P(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}f.prototype.writeUInt16LE=function Re(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function Me(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function O(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}f.prototype.writeUInt32LE=function Pe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{O(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function je(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{O(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Oe(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o>0)-s&255}return t+r};f.prototype.writeIntBE=function Ue(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1;var a=1;var s=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeInt8=function He(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function De(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Ne(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function qe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{O(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function ze(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{O(this,e,t,false)}return t+4};function U(e,t,r,n,i,o){if(t>i||te.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,n,o){if(!o){U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function We(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Fe(e,t,r){return H(this,e,t,false,r)};function D(e,t,r,n,o){if(!o){U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Ye(e,t,r){return D(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ve(e,t,r){return D(this,e,t,false,r)};f.prototype.copy=function Je(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n55295&&r<57344){if(i){if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}else{r=i-55296<<10|r-56320|65536;i=null}}else{if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)o.push(239,191,189);continue}else{i=r;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<2097152){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function V(e){var t=[];for(var r=0;r>8;i=r%256;o.push(i);o.push(n)}return o}function $(e){return n.toByteArray(z(e))}function K(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function G(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":46,ieee754:47,"is-array":48}],46:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===i||t===u)return 63;if(t0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;a="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var u=0;function l(e){s[u++]=e}for(r=0,n=0;r>16);l((o&65280)>>8);l(o&255)}if(a===2){o=c(e.charAt(r))<<2|c(e.charAt(r+1))>>4;l(o&255)}else if(a===1){o=c(e.charAt(r))<<10|c(e.charAt(r+1))<<4|c(e.charAt(r+2))>>2;l(o>>8&255);l(o&255)}return s}function h(e){var t,r=e.length%3,i="",o,a;function s(e){return n.charAt(e)}function f(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-r;t>2);i+=s(o<<4&63);i+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1];i+=s(o>>10);i+=s(o>>4&63);i+=s(o<<2&63);i+="=";break}return i}e.toByteArray=l;e.fromByteArray=h})(typeof r==="undefined"?this.base64js={}:r)},{}],47:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=i*8-n-1,f=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];l+=h;o=d&(1<<-c)-1;d>>=-c;c+=s;for(;c>0;o=o*256+e[t+l],l+=h,c-=8){}a=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;a=a*256+e[t+l],l+=h,c-=8){}if(o===0){o=1-u}else if(o===f){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,n);o=o-u}return(d?-1:1)*a*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var a,s,f,u=o*8-i-1,c=(1<>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=c}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-a))<1){a--;f*=2}if(a+l>=1){t+=h/f}else{t+=h*Math.pow(2,1-l)}if(t*f>=2){a++;f/=2}if(a+l>=c){s=0;a=c}else if(a+l>=1){s=(t*f-1)*Math.pow(2,i);a=a+l}else{s=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+d]=s&255,d+=p,s/=256,i-=8){}a=a<0;e[r+d]=a&255,d+=p,a/=256,u-=8){}e[r+d-p]|=g*128}},{}],48:[function(e,t,r){var n=Array.isArray;var i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],49:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||a(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(s(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;o=new Array(n-1);for(f=1;f0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(r)){for(s=o;s-->0;){if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function a(e){return typeof e==="object"&&e!==null}function s(e){return e===void 0}},{}],50:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],51:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var a=i>=0?arguments[i]:e.cwd();if(typeof a!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!a){continue}r=a+"/"+r;n=a.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var f=0;f1){for(var r=1;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-l,E=Math.floor,x=String.fromCharCode,S;function A(e){throw RangeError(b[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function T(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(w,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function C(e){var t=[],r=0,n=e.length,i,o;while(r=55296&&i<=56319&&r65535){e-=65536;t+=x(e>>>10&1023|55296);e=56320|e&1023}t+=x(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function M(e,t,r){var n=0;e=r?E(e/p):e>>1;e+=E(e/t);for(;e>k*h>>1;n+=c){e=E(e/k)}return E(n+(k+1)*e/(e+d))}function P(e){var t=[],r=e.length,n,i=0,o=m,a=g,s,f,d,p,y,_,w,b,k;s=e.lastIndexOf(v);if(s<0){s=0}for(f=0;f=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=s>0?s+1:0;d=r){A("invalid-input")}w=B(e.charCodeAt(d++));if(w>=c||w>E((u-i)/y)){A("overflow")}i+=w*y;b=_<=a?l:_>=a+h?h:_-a;if(wE(u/k)){A("overflow")}y*=k}n=t.length+1;a=M(i-p,n,p==0);if(E(i/n)>u-o){A("overflow")}o+=E(i/n);i%=n;t.splice(i++,0,o)}return L(t)}function j(e){var t,r,n,i,o,a,s,f,d,p,y,_=[],w,b,k,S;e=C(e);w=e.length;t=m;r=0;o=g;for(a=0;a=t&&yE((u-r)/b)){A("overflow")}r+=(s-t)*b;t=s;for(a=0;au){A("overflow")}if(y==t){for(f=r,d=c;;d+=c){p=d<=o?l:d>=o+h?h:d-o;if(f0&&u>f){u=f}for(var c=0;c=0){d=l.substr(0,h);p=l.substr(h+1)}else{d=l;p=""}g=decodeURIComponent(d);m=decodeURIComponent(p);if(!n(a,g)){a[g]=m}else if(i(a[g])){a[g].push(m)}else{a[g]=[a[g],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],55:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(n(a))+r;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t)}else{return s+encodeURIComponent(n(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(n(s))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n0){if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}b(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length=p){e=p}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function m(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||s.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=g(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}l.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)T(this);else _(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)T(this);return null}var n=t.needReadable;u("need readable",n);if(t.length===0||t.length-e0)i=I(e,t);else i=null;if(s.isNull(i)){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)T(this);if(!s.isNull(i))this.emit("data",i);return i};function v(e,t){var r=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){w(e)});else w(e)}}function w(e){u("emit readable");e.emit("readable");A(e)}function b(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){k(e,t)})}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function C(e,t){for(var r=0,n=e.length;r1){var r=[];for(var n=0;n",'"',"`"," ","\r","\n"," "],f=["{","}","|","\\","^","`"].concat(s),u=["'"].concat(f),c=["%","/","?",";","#"].concat(u),l=["/","?","#"],h=255,d=/^[a-z0-9A-Z_-]{0,63}$/,p=/^([a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},v={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&x(e)&&e instanceof i)return e;var n=new i;n.parse(e,t,r);return n}i.prototype.parse=function(e,t,r){if(!E(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var i=e;i=i.trim();var a=o.exec(i);if(a){a=a[0];var s=a.toLowerCase();this.protocol=s;i=i.substr(a.length)}if(r||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=i.substr(0,2)==="//";if(f&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(f||a&&!v[a])){var _=-1;for(var w=0;w127){C+="x"}else{C+=T[L]}}if(!C.match(d)){var R=A.slice(0,w);var M=A.slice(w+1);var P=T.match(p);if(P){R.push(P[1]);M.unshift(P[2])}if(M.length){i="/"+M.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>h){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var j=this.hostname.split(".");var O=[];for(var w=0;w0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!l.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var p=l.slice(-1)[0];var g=(r.host||e.host)&&(p==="."||p==="..")||p==="";var y=0;for(var _=l.length;_>=0;_--){p=l[_];if(p=="."){l.splice(_,1)}else if(p===".."){l.splice(_,1);y++}else if(y){l.splice(_,1);y--}}if(!u&&!c){for(;y--;y){l.unshift("..")}}if(u&&l[0]!==""&&(!l[0]||l[0].charAt(0)!=="/")){l.unshift("")}if(g&&l.join("/").substr(-1)!=="/"){l.push("")}var w=l[0]===""||l[0]&&l[0].charAt(0)==="/";if(h){r.hostname=r.host=w?"":l.length?l.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&l.length;if(u&&!w){l.unshift("")}if(!l.length){r.pathname=null;r.path=null}else{r.pathname=l.join("/")}if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};i.prototype.parseHost=function(){var e=this.host;var t=a.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function E(e){return typeof e==="string"}function x(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:53,querystring:56}],71:[function(e,t,r){(function(r){t.exports=m;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=v;var n=e("bencode");var i=e("block-stream2");var o=e("piece-length");var a=e("path");var s=e("dezalgo");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};v(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function v(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=s(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(A(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&a.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var i=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(n){var o={};if(S(e)){o.getStream=T(e);o.length=e.size}else if(r.isBuffer(e)){o.getStream=C(e);o.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}o.getStream=B(e,o);o.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var s=i>1;y(e,s,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");o.path=e.name.split(a.sep);n(null,o)}}),function(e,t){if(e)return n(e);t=u(t);n(null,t)})}function y(e,t,r){w(_,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=L(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function _(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function w(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.filter(b).map(function(r){return function(n){w(e,a.join(t,r),n)}}),r)}})}function b(e){return e[0]!=="."}function k(e,t,n){n=h(n);var o=[];var a=0;var s=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;var d=new l(s);var g=new i(t,{zeroPadding:false});d.on("error",y);d.pipe(g).on("data",m).on("end",v).on("error",y);function m(e){a+=e.length;var t=u;p(e,function(e){o[t]=e;f-=1;w()});f+=1;u+=1}function v(){c=true;w()}function y(e){_();n(e)}function _(){d.removeListener("error",y);g.removeListener("data",m);g.removeListener("end",v);g.removeListener("error",y)}function w(){if(c&&f===0){_();n(null,new r(o.join(""),"hex"),a)}}}function E(e,r,i){var a=r.announceList!==undefined?r.announceList:r.announce!==undefined?r.announce.map(function(e){return[e]}):t.exports.announceList;var s={info:{name:r.name},announce:a[0][0],"announce-list":a,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)s.info.comment=r.comment;if(r.createdBy!==undefined)s.info["created by"]=r.createdBy;if(r.private!==undefined)s.info.private=Number(r.private);if(r.sslCert!==undefined)s.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)s["url-list"]=r.urlList;var f=e.length===1;var u=r.pieceLength||o(e.reduce(x,0));s.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return i(t);s.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){s.info.files=e}else{s.info.length=o}i(null,n.encode(s))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function A(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function T(e){return function(){return new f(e)}}function C(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function L(e){return function(){return c.createReadStream(e)}}function B(e,t){return function(){var r=new g.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("buffer").Buffer)},{bencode:72,"block-stream2":76,buffer:45,dezalgo:88,"filestream/read":94,flatten:95,fs:43,multistream:96,once:99,path:51,"piece-length":100,"run-parallel":102,"simple-sha1":106,stream:68}],72:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":73,"./lib/encode":75,dup:13}],73:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":74,buffer:45,dup:14}],74:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],75:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],76:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{buffer:45,defined:77,dup:32,inherits:78,"readable-stream":87}],77:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{dup:33}],78:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],79:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{"./_stream_readable":81,"./_stream_writable":83,_process:52,"core-util-is":84,dup:34,inherits:78}],80:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_transform":82,"core-util-is":84,dup:35,inherits:78}],81:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{_process:52,buffer:45,"core-util-is":84,dup:36,events:49,inherits:78,isarray:85,stream:68,"string_decoder/":86}],82:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{"./_stream_duplex":79,"core-util-is":84,dup:37,inherits:78}],83:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{"./_stream_duplex":79,_process:52,buffer:45,"core-util-is":84,dup:38,inherits:78,stream:68}],84:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{buffer:45,dup:39}],85:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],86:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{buffer:45,dup:41}],87:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./lib/_stream_duplex.js":79,"./lib/_stream_passthrough.js":80,"./lib/_stream_readable.js":81,"./lib/_stream_transform.js":82,"./lib/_stream_writable.js":83,dup:42,stream:68}],88:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:89,dup:27,wrappy:90}],89:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],90:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],91:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],92:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(n(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:45,"is-typedarray":93}],93:[function(e,t,r){t.exports=o;o.strict=a;o.loose=s;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[n.call(e)]}},{}],94:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var r=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};n.call(this,t);this._offset=0;this._ready=false;this._file=e;this._size=e.size;this._chunkSize=t.chunkSize||Math.max(this._size/1e3,200*1024);this.reader=new FileReader;this._generateHeaderBlocks(e,t,function(e,t){if(e){return r.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){r.push(e)})}r._ready=true;r.emit("_ready")})}i(s,n);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var r=this._offset;var n=this._offset+this._chunkSize;if(n>this._size)n=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=n;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,n))};s.prototype.destroy=function(){this._file=null;if(this.reader){this.reader.onload=null;this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:91,stream:68,"typedarray-to-buffer":92}],95:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n=r){break}r=n;i=t[o]}return i}},{}],102:[function(e,t,r){var n=e("dezalgo");t.exports=function(e,t){if(t)t=n(t);var r,i,o;if(Array.isArray(e)){r=[];i=e.length}else{o=Object.keys(e);r={};i=o.length}function a(e,n,o){r[e]=o;if(--i===0||n){if(t)t(n,r);t=null}}if(!i){if(t)t(null,r);t=null}else if(o){o.forEach(function(t){e[t](a.bind(undefined,t))})}else{e.forEach(function(e,t){e(a.bind(undefined,t))})}}},{dezalgo:103}],103:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:104,dup:27,wrappy:105}],104:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],105:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],106:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var a=o.subtle||o.webkitSubtle;var s=i.digest.bind(i);try{a.digest({name:"sha-1"},new Uint8Array).catch(function(){a=false})}catch(f){a=false}function u(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=c(e)}a.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(s(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=s},{rusha:107}],107:[function(e,t,r){(function(e){(function(){if(typeof t!=="undefined"){t.exports=o}else if(typeof window!=="undefined"){window.Rusha=o}if(typeof FileReaderSync!=="undefined"){var r=new FileReaderSync,n=new o(4*1024*1024);self.onmessage=function s(e){var t,r=e.data.data;try{t=n.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}var i={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function o(e){"use strict";var t={fill:0};var n=function(e){for(e+=9;e%64>0;e+=1);return e};var o=function(e,t){for(var r=t>>2;r>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(a=s;a>2]=o.charCodeAt(r+a)<<24|o.charCodeAt(r+a+1)<<16|o.charCodeAt(r+a+2)<<8|o.charCodeAt(r+a+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(a=4-s;a>2]=o[r+a]<<24|o[r+a+1]<<16|o[r+a+2]<<8|o[r+a+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,n,i,o){var a=this,s,f=o%4,u=i%4,c=i-u;var l=new Uint8Array(r.readAsArrayBuffer(a.slice(n,n+i)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(s=4-f;s>2]=l[s]<<24|l[s+1]<<16|l[s+2]<<8|l[s+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(i.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var h=function(e,t){switch(i.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t)}};var d=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=n(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20)); -t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=a({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};g(e||64*1024);var m=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var v=function(e,r){var i=n(e);var a=new Int32Array(t.heap,0,i>>2);o(a,e);s(a,e,r);return i};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var a=n;if(o){a=v(n,i)}y(e,r,n);t.core.hash(a,t.padMaxChunkLen)};var w=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var b=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(b(e).buffer)}}function a(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,a=0,s=0,f=0,u=0,c=0,l=0,h=0,d=0,p=0,g=0,m=0;o=n[t+320>>2]|0;s=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;d=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){a=o;f=s;c=u;h=l;p=d;for(i=0;(i|0)<64;i=i+4|0){m=n[r+i>>2]|0;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)+1859775393|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|s&l|u&l)|0)+((m+d|0)-1894007588|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)-899497514|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}o=o+a|0;s=s+f|0;u=u+c|0;l=l+h|0;d=d+p|0}n[t+320>>2]=o;n[t+324>>2]=s;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=d}return{hash:i}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],108:[function(e,t,r){r=t.exports=e("./debug");r.log=o;r.formatArgs=i;r.save=a;r.load=s;r.useColors=n;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function i(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function o(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{if(null==e){r.storage.removeItem("debug")}else{r.storage.debug=e}}catch(t){}}function s(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(s());function f(){try{return window.localStorage}catch(e){}}},{"./debug":109}],109:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:110}],110:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){e=""+e;if(e.length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e=Math.pow(2,e)){return n(e,t)}else return a};n.rack=function(e,t,r){var i=function(i){var a=0;do{if(a++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var s=n(e,t)}while(Object.hasOwnProperty.call(o,s));o[s]=i;return s};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],116:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],117:[function(e,t,r){arguments[4][96][0].apply(r,arguments)},{dup:96,inherits:118,stream:68}],118:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],119:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],120:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:119}],121:[function(e,t,r){(function(r){var n=e("magnet-uri");var i=e("parse-torrent-file");t.exports=function o(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return n(e)}else if(typeof e==="string"&&(t===40||t===32)){return n("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return n("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return i(e)}else if(e&&e.infoHash){return e}else{throw new Error("Invalid torrent identifier")}};t.exports.toMagnetURI=n.encode;t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:45,"magnet-uri":122,"parse-torrent-file":127}],122:[function(e,t,r){(function(r){t.exports=a;t.exports.decode=a;t.exports.encode=s;var n=e("thirty-two");var i=e("xtend");var o=e("uniq");function a(e){var t={};var i=e.split("magnet:?")[1];var a=i&&i.length>=0?i.split("&"):[];a.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var s;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=n.decode(s[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];o(t.announce);t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}return t}function s(e){e=i(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:45,"thirty-two":123,uniq:125,xtend:126}],123:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":124}],124:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var n=0;var o=0;var a=0;var s=0;var f=new e(i(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(n3){s=u&255>>a;a=(a+5)%8;s=s<>8-a;n++}else{s=u>>8-(a+5)&31;a=(a+5)%8;if(a==0)n++}f[o]=t.charCodeAt(s);o++}for(n=o;n>>r;s[a]=o;a++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:45}],125:[function(e,t,r){"use strict";function n(e,t){var r=1,n=e.length,i=e[0],o=e[0];for(var a=1;a0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var s=e.info.files||[e.info];t.files=s.map(function(e,r){var n=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:s.slice(0,r).reduce(u,0)}});t.length=s.reduce(u,0);var f=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength;t.pieces=c(e.info.pieces);return t}function f(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new r(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return n.encode(t)}function u(e,t){return e+t.length}function c(e){var t=[];for(var r=0;r10)e.numWant=10;t._generateOffers(e.numWant,function(r){e.offers=r;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};h.prototype.scrape=function(e){var t=this;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};h.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(r,t._intervalMs)}};h.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._socket.removeListener("data",e._onSocketDataBound);e._socket.removeListener("close",e._onSocketCloseBound);e._socket.removeListener("error",e._onSocketErrorBound);e._onSocketErrorBound=null;e._onSocketDataBound=null;e._onSocketCloseBound=null;e._socket.on("error",d);try{e._socket.close()}catch(t){}e._socket=null};h.prototype._openSocket=function(){var e=this;e._onSocketErrorBound=e._onSocketError.bind(e);e._onSocketDataBound=e._onSocketData.bind(e);e._onSocketCloseBound=e._onSocketClose.bind(e);e._socket=new f(e._announceUrl+"?"+o(40));e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};h.prototype._onSocketData=function(e){var t=this;if(t.destroyed)return;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHashBinary){return t.client.emit("warning",new Error("Invalid tracker response"))}n("received %s from %s",JSON.stringify(e),t._announceUrl);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o&&!t._opts.interval&&t._intervalMs!==0){t.setInterval(o*1e3)}var a=e["tracker id"];if(a){t._trackerId=a}if(e.complete){t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete})}if(t.client._peerIdHex===u.binaryToHex(e.peer_id)){return}var f;if(e.offer){f=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});f.id=u.binaryToHex(e.peer_id);f.once("signal",function(r){var n={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});f.signal(e.offer);t.client.emit("peer",f)}if(e.answer){f=t._peers[u.binaryToHex(e.offer_id)];if(f){f.id=u.binaryToHex(e.peer_id);f.signal(e.answer);t.client.emit("peer",f)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};h.prototype._onSocketClose=function(){var e=this;e.destroy();var t=Math.floor(Math.random()*c)+l;setTimeout(function(){e._openSocket()},t);n("reconnecting socket in %s ms",t)};h.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.client.emit("error",e)};h.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);n("send %s",r);t._socket.send(r)};h.prototype._generateOffers=function(e,t){var r=this;var i=[];n("generating %s offers",e);for(var a=0;an._maxBufferedAmount){n._debug("start backpressure: bufferedAmount %d",n._channel.bufferedAmount);n._cb=r}else{r(null)}}else{n._debug("write before connect");n._chunk=e;n._cb=r}};c.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};c.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};c.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(r==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(r==="closed"){e._destroy()}};c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.remoteFamily="IPv4";e.remotePort=Number(t.portNumber);e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;e._debug('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}e._interval=setInterval(function(){if(!e._cb||!e._channel||e._channel.bufferedAmount>e._maxBufferedAmount)return;e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref();e._debug("connect");e.emit("connect")}};c.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};c.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:e.candidate})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};c.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=u(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};c.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};c.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};c.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};c.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};c.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function l(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}function h(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function d(){}}).call(this,e("buffer").Buffer)},{buffer:45,debug:156,hat:159,inherits:160,"is-typedarray":161,once:163,stream:68,"typedarray-to-buffer":164}],156:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{"./debug":157,dup:108}],157:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:158}],158:[function(e,t,r){arguments[4][110][0].apply(r,arguments)},{dup:110}],159:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{dup:115}],160:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],161:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],162:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],163:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:162}],164:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":161}],165:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;i(c,a.Duplex);function c(e,t){var r=this;if(!(r instanceof c))return new c(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._maxBufferedAmount=t.highWaterMark;r._chunk=null;r._cb=null;r._interval=null;r._ws=new u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=r._onError.bind(r);r.on("finish",function(){if(r.connected){setTimeout(function(){r._destroy()},100)}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}c.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}var i=e.length||e.byteLength||e.size;t._ws.send(e);n("write: %d bytes",i)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.connected=false;r.destroyed=true;clearInterval(r._interval);r._interval=null;r._chunk=null;r._cb=null;if(r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null;r._ws.onmessage=null;r._ws.onclose=null;r._ws.onerror=null}r._ws=null;if(e)r.emit("error",e);r.emit("close")};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var i=this;if(i.destroyed)return r(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof f!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){n("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=r}else{r(null)}}else{n("write before connect");i._chunk=e;i._cb=r}};c.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};c.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;n('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}n("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}n("connect");e.emit("connect")};c.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};c.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);n("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:45,debug:166,inherits:169,"is-typedarray":170,stream:68,"typedarray-to-buffer":171,ws:44}],166:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":167,dup:18}],167:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:168}],168:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],169:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],170:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],171:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":172}],172:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],173:[function(e,t,r){t.exports=n;function n(e){for(var t=1;tf){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==s.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;e0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:182,bitfield:186,buffer:45,events:49,inherits:187,"simple-sha1":188}],182:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":183,"./lib/encode":185,dup:13}],183:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":184,buffer:45,dup:14}],184:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],185:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],186:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{buffer:45,dup:8}],187:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],188:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106,rusha:189}],189:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107}],190:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],191:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],192:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.43.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./server":false,"bittorrent-dht/client":false,"load-ip-set":false,"simple-get":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.0.0","pretty-bytes":"^1.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-get":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^4.0.0",brfs:"^1.2.0",browserify:"^10.0.0","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}]},{},[1])(1)}); +(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(a,s){if(!t[a]){if(!e[a]){var f=typeof require=="function"&&require;if(!s&&f)return f(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[a]={exports:{}};e[a][0].call(c.exports,function(t){var r=e[a][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a0){return r[Math.random()*r.length|0]}else{return-1}}},{}],5:[function(e,t,r){(function(r,n){t.exports=k;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var f=e("end-of-stream");var u=e("events").EventEmitter;var c=e("./file-stream");var l=e("inherits");var h=e("multistream");var d=e("once");var p=e("simple-sha1");var g=16*1024;var m=0;var v=1;var y=2;function _(){}l(w,u);function w(e,t,r,n){var i=this;u.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!n;if(typeof r==="number"){i.buffer=null;i.length=r}else{i.buffer=r;i.length=r.length}i._reset()}w.prototype.readBlock=function(e,t,r){var n=this;r=s(r);if(!n.buffer||!n._verifyOffset(e)){return r(new Error("invalid block offset "+e))}r(null,n.buffer.slice(e,e+t))};w.prototype.writeBlock=function(e,t,r){var n=this;r=s(r);if(!n._verifyOffset(e)||!n._verifyBlock(e,t)){return r(new Error("invalid block "+e+":"+t.length))}n._lazyAllocBuffer();var i=e/g;if(n.blocks[i]===y){return r(null)}t.copy(n.buffer,e);n.blocks[i]=y;n.blocksWritten+=1;if(n.blocksWritten===n.blocks.length){n.verify()}r(null)};w.prototype.reserveBlock=function(e){var t=this;var r=t.blocks.length;for(var n=0;n0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,r,false)}};b.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,r,false)}};b.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var r=new c(t,e);t.storage.emit("select",r.startPiece,r.endPiece,true,r.notify.bind(r));f(r,function(){t.storage.emit("deselect",r.startPiece,r.endPiece,true)});return r};b.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(t,r){if(t)return e(t);var n=window.URL.createObjectURL(new window.Blob([r]));e(null,n)})};b.prototype.getBuffer=function(e){var t=this;e=s(d(e));var r;if(t.storage.buffer){var i=function(){r=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,r)};if(t.done)i();else t.once("done",i)}else{r=new n(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(r,o);o+=e.length}).on("end",function(){e(null,r)}).on("error",e)}};b.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){r.nextTick(function(){e.emit("done")})}};l(k,u);function k(e,t){var r=this;u.call(r);if(!a.enabled)r.setMaxListeners(0);if(!t)t={};r.bitfield=new i(e.pieces.length);r.done=false;r.closed=false;r.readonly=true;if(!t.nobuffer){r.buffer=new n(e.length)}var o=r.pieceLength=e.pieceLength;var s=e.lastPieceLength;var f=e.pieces.length;r.pieces=e.pieces.map(function(e,n){var i=n*o;var a=i+(n===f-1?s:o);var u=r.buffer?r.buffer.slice(i,a):a-i;var c=new w(n,e,u,!!t.noVerify);c.on("done",r._onPieceDone.bind(r,c));return c});r.files=e.files.map(function(e){var t=e.offset;var n=t+e.length-1;var i=t/o|0;var a=n/o|0;var s=r.pieces.slice(i,a+1);var f=new b(r,e,s,o);f.on("done",r._onFileDone.bind(r,f));return f})}k.BLOCK_LENGTH=g;k.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];t=d(t||function(){});var n=0;var i=new h(e);var a=new o(r.pieceLength,{zeroPadding:false});i.on("error",f);r.once("done",u);i.pipe(a).on("data",s).on("error",f);function s(e){var t=n;n+=1;var i=0;var a=new o(g,{zeroPadding:false});a.on("data",s);a.on("end",f);function s(e){var n=i*g;i+=1;r.writeBlock(t,n,e)}function f(){u()}function u(){a.removeListener("data",s);a.removeListener("end",f)}a.end(e)}function f(e){c();t(e)}function u(){c();t(null)}function c(){i.removeListener("error",f);a.removeListener("data",s);a.removeListener("error",f);r.removeListener("done",u)}};Object.defineProperty(k.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*g)},0)}});Object.defineProperty(k.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var r=0,n=e.pieces.length;rt||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;a("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||L});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};B.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;a("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(i,n);if(r.unref)r.unref()}}var o=0;function s(){if(e.peerPieces.length!==t.storage.pieces.length)return;for(;ok){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(r,n,i,o)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(i,n);if(r.unref)r.unref();e.isSeeder=false;s()};B.prototype._onStorage=function(){var e=this;if(e.destroyed)return;a("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};B.prototype._onStoragePiece=function(e){var t=this;a("piece done %s",e.index);t._reservations[e.index]=null;t.swarm.wires.forEach(function(t){t.have(e.index)});t._gcSelections()};B.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};B.prototype._gcSelections=function(){var e=this;for(var t=0;t=r)return;var n=R(e,I);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var n=t._selections[r];var o;if(t.strategy==="rarest"){var a=n.from+n.offset;var s=n.to;var f=s-a+1;var u={};var c=0;var l=i(a,s,u);while(c=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var r=e.downloadSpeed()||1;if(r>S)return function(){return true};var n=Math.max(1,e.requests.length)*b.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.storage.bitfield.get(e))return true;var a=t.storage.pieces[e];var s=a.blocks.length-a.blocksWritten;for(;o0)continue;i--;return false}return true}}function s(e){var r=e;for(var n=e;n=n)return true;var o=a();for(var f=0;f0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var r=0;var n=0;for(;n=S)continue;if(2*u>n||u>o)continue;a=f;o=u}if(!a)return false;for(s=0;s=s)return false;var f=e.requests.length===0&&i.storage.numMissing<30;var u=i.storage.reserveBlock(t,f);if(!u&&!f&&n&&i._hotswap(e,t)){u=i.storage.reserveBlock(t,false)}if(!u)return false;var c=i._reservations[t];if(!c){c=i._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,o){if(!i.ready){i.once("ready",function(){h(n,o)});return}if(c[l]===e)c[l]=null;if(n){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort,n.message); +i.storage.cancelBlock(t,u.offset);r.nextTick(i._update.bind(i));return false}else{a("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,u.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,u.offset)}r.nextTick(i._update.bind(i))})}}e.request(t,u.offset,u.length,h);return true};B.prototype.createServer=function(e){var t=this;if(typeof w==="function"){return new w(t,e)}};B.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function R(e,t){return Math.ceil(2+t*e.downloadSpeed()/b.BLOCK_LENGTH)}function M(e){return Math.random()*e|0}function P(e,t){var r=e.map(function(e,t){return t});for(var n=r.length-1;n>0;--n){var i=M(n+1);var o=r[n];r[n]=r[i];r[i]=o}r.forEach(function(r){t(e[r],r,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":4,"./server":44,"./storage":5,_process:52,"addr-to-ip-port":7,"bittorrent-swarm":9,"create-torrent":71,debug:108,events:49,fs:43,inherits:116,"parse-torrent":121,"re-emitter":135,"run-parallel":136,"simple-get":44,"torrent-discovery":143,uniq:180,ut_metadata:181,ut_pex:44}],7:[function(e,t,r){var n=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=n.exec(e);if(!t)throw new Error("invalid addr: "+e);i[e]=[t[1],Number(t[2])];o+=1}return i[e]};t.exports.reset=function s(){i={}}},{}],8:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r>3;if(e%8!==0)t++;return t}n.prototype.get=function(e){var t=e>>3;return t>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length>e%8}else if(r>e%8)}};n.prototype._grow=function(e){if(this.buffer.length=e.maxConns){return}o("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;o("tcp connect attempt to %s",t.addr);var r=i(t.addr);var n=r[0];var a=r[1];var s=t.conn=u.connect({host:n,port:a,localAddress:e._hostname});s.once("connect",function(){t.onConnect()});s.once("error",function(e){t.destroy(e)});t.setConnectTimeout();s.on("close",function(){if(e.destroyed)return;if(t.retries>=p.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,p.length);return}function r(){var r=c.createOutgoingTCPPeer(t.addr,e);r.retries=t.retries+1;e._queue.push(r);e._drain()}var n=p[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var i=setTimeout(r,n);if(i.unref)i.unref()})};g.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};g.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":10,"./lib/tcp-pool":11,_process:52,"addr-to-ip-port":44,buffer:45,debug:24,dezalgo:27,events:49,inherits:30,net:44,speedometer:31}],10:[function(e,t,r){var n=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;r.createWebRTCPeer=function(e,t){var r=new s(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(e){r.destroy(e)});r.setConnectTimeout()}return r};r.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var r=new s(t);r.conn=e;r.addr=t;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new s(e);r.swarm=t;r.addr=e;return r};function s(e){var t=this;t.id=e;n("new Peer %s",e);t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.destroyed=false;t.timeout=null;t.retries=0;t.sentHandshake=false}s.prototype.onConnect=function(){var e=this;n("Peer %s connected",e.id);clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()});t.once("close",function(){e.destroy()});t.once("finish",function(){e.destroy()});t.once("error",function(t){e.destroy(t)});var r=e.wire=new i;r.once("end",function(){e.destroy()});r.once("finish",function(){e.destroy()});r.once("error",function(t){e.destroy(t)});r.once("handshake",function(t,r){e.onHandshake(t,r)});e.setHandshakeTimeout();t.pipe(r).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var r=this;if(!r.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(i!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}n("Peer %s got handshake %s",r.id,i);clearTimeout(r.handshakeTimeout);r.retries=0;r.wire.on("download",function(e){r.swarm.downloaded+=e;r.swarm.downloadSpeed(e);r.swarm.emit("download",e)});r.wire.on("upload",function(e){r.swarm.uploaded+=e;r.swarm.uploadSpeed(e);r.swarm.emit("upload",e)});if(!r.sentHandshake)r.handshake();r.swarm.wires.push(r.wire);var a=r.addr;if(!a&&r.conn.remoteAddress){a=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,a)};s.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};s.prototype.setConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout);e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},o);if(e.connectTimeout.unref)e.connectTimeout.unref()};s.prototype.setHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout);e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},a);if(e.handshakeTimeout.unref)e.handshakeTimeout.unref()};s.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;n("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));t.swarm.wires.splice(t.swarm.wires.indexOf(t.wire),1);if(t.conn)t.conn.destroy();if(t.wire)t.wire.destroy();if(t.swarm){t.swarm.removePeer(t.id);t.swarm._drain()}clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);t.conn=null;t.swarm=null;t.wire=null}},{"bittorrent-protocol":12,debug:24}],11:[function(e,t,r){(function(r){t.exports=f;var n=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};n("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=o.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var n=s[e._port];if(!n)return t();n.removeSwarm(e);var i=0;for(var o in n.swarms){var a=n.swarms[o];if(a)i+=1}if(i===0)n.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in s){var r=s[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}n("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;n("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=i(e);n("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});s[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address().port;n("tcp pool listening on %s",t);if(t!==e.port){s[e.port]=null;e.port=t;s[e.port]=e}e.listening=true;for(var r in e.swarms){var i=e.swarms[r];if(i)i._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var n=a.createIncomingTCPPeer(e);n.wire.once("handshake",function(i,o){var a=i.toString("hex");r();e.removeListener("close",r);var s=t.swarms[a];if(s){n.swarm=s;s._addIncomingPeer(n);n.onHandshake(i,o)}else{var f=new Error("Unexpected info hash "+a+" from incoming peer "+n.id+": destroying peer");n.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var n=t.swarms[r];if(n){t.removeSwarm(n);n._onError(e)}}}}).call(this,e("_process"))},{"./peer":10,_process:52,debug:24,dezalgo:27,net:44}],12:[function(e,t,r){(function(r){t.exports=w;var n=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var f=e("speedometer");var u=e("stream");var c=4e5;var l=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var d=new r([0,0,0,1,0]);var p=new r([0,0,0,1,1]);var g=new r([0,0,0,1,2]);var m=new r([0,0,0,1,3]);var v=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function _(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}s(w,u.Duplex);function w(){if(!(this instanceof w))return new w;u.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=f();this.downloadSpeed=f();this._keepAlive=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,h),6e4)};w.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};w.prototype.end=function(){this._onUninterested();this._onChoke();u.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error("Extension API requires a named function, e.g. function name() {}")}var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.handshake=function(e,t,n){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new r(v);i[5]|=16;if(n&&n.dht)i[7]|=1;this._push(r.concat([l,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(p)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(g)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};w.prototype.have=function(e){this._message(4,[e],null)};w.prototype.bitfield=function(e){if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this.requests.push(new _(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._callback(b(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){var t=new r(y);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var n=new r([e]);var o=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var n;for(n in this._ext){this._ext[n].onHandshake(e,t,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new n(e);this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;var n=function(n,o){if(i!==b(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new _(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._callback(b(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){b(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this.emit("port",e)};w.prototype._onExtended=function(e,t){var r,n;if(e===0&&(r=k(t))){this.peerExtendedHandshake=r;if(typeof r.m==="object"){for(n in r.m){this.peerExtendedMapping[n]=Number(r.m[n].toString())}}for(n in this._ext){if(this.peerExtendedMapping[n]){this._ext[n].onExtendedHandshake(this.peerExtendedHandshake)}}this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAlive);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};function b(e,t,r,n){for(var i=0;i=31}r.formatters.j=function(e){return JSON.stringify(e)};function o(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function a(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{if(null==e){n.removeItem("debug")}else{n.debug=e}}catch(t){}}function f(){var e;try{e=n.debug}catch(t){}return e}r.enable(f());function u(){try{return window.localStorage}catch(e){}}},{"./debug":19}],19:[function(e,t,r){r=t.exports=a;r.coerce=c;r.disable=f;r.enable=s;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function a(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var a=t-(i||t);e.diff=a;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var f=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=s[f];t=i.call(e,o);s.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){s=r.formatArgs.apply(e,s)}var u=n.log||r.log||console.log.bind(console);u.apply(e,s)}n.enabled=true;var a=r.enabled(e)?n:t;a.namespace=e;return a}function s(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(et)f=t;s=n;while(f--){if(a===t)a=0;r[a]=r[a===0?t-1:a-1];a++}if(e)r[a-1]+=e;var u=r[a-1];var c=r.length=this.size){var i=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}n()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new r(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(r.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(r.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:45,defined:33,inherits:116,"readable-stream":42}],33:[function(e,t,r){t.exports=function(){for(var e=0;e0){if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);t.length+=t.objectMode?1:r.length;if(i){t.buffer.unshift(r)}else{t.reading=false;t.buffer.push(r)}if(t.needReadable)y(e);w(e,t)}}else if(!i){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length=d){e=d}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(e===null||isNaN(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=p(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){var t=this._readableState;t.calledRead=true;var r=e;var n;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){y(this);return null}e=g(e,t);if(e===0&&t.ended){n=null;if(t.length>0&&t.decoder){n=A(e,t);t.length-=n.length}if(t.length===0)I(this);return n}var i=t.needReadable;if(t.length-e<=t.highWaterMark)i=true;if(t.ended||t.reading)i=false;if(i){t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);if(e>0)n=A(e,t);else n=null;if(n===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(t.ended&&!t.endEmitted&&t.length===0)I(this);return n};function m(e,t){var r=null;if(!i.isBuffer(t)&&"string"!==typeof t&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function v(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;if(t.length>0)y(e);else I(e)}function y(e){var t=e._readableState;t.needReadable=false;if(t.emittedReadable)return;t.emittedReadable=true;if(t.sync)r.nextTick(function(){_(e)});else _(e)}function _(e){e.emit("readable")}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){b(e,t)})}}function b(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length0)return}if(t.pipesCount===0){t.flowing=false;if(o.listenerCount(e,"data")>0)S(e);return}t.ranOut=true}function x(){if(this._readableState.ranOut){this._readableState.ranOut=false;E(this)}}c.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;this.removeListener("readable",x);t.flowing=false;for(var i=0;i=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted&&t.calledRead){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,n=e.length;r=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};a.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};a.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function s(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:45}],42:[function(e,t,r){var n=e("stream");r=t.exports=e("./lib/_stream_readable.js");r.Stream=n;r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":34,"./lib/_stream_passthrough.js":35,"./lib/_stream_readable.js":36,"./lib/_stream_transform.js":37,"./lib/_stream_writable.js":38,stream:68}],43:[function(e,t,r){},{}],44:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{dup:43}],45:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=_;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var a=1073741823;var s={};f.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0);var t=new Uint8Array(e);t.foo=function(){return 42};return t.foo()===42&&typeof t.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(r){return false}}();function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return c(this,e,arguments.length>1?arguments[1]:"utf8")}return l(this,e)}function u(e,t){e=v(e,t<0?0:y(t)|0);if(!f.TYPED_ARRAY_SUPPORT){for(var r=0;r>>1;if(r)e.parent=s;return e}function y(e){if(e>=a){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+a.toString(16)+" bytes")}return e|0}function _(e,t){if(!(this instanceof _))return new _(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};f.compare=function Q(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i>>1;case"utf8":case"utf-8":return Y(e).length;case"base64":return $(e).length;default:return e.length}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function te(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return C(this,t,r);case"binary":return L(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function re(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function ne(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return""};f.prototype.compare=function ie(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function oe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+ii){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var a=0;ao)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var a=false;for(;;){switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();a=true}}};f.prototype.toJSON=function ue(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function T(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var o=t;on)r=n;var i="";for(var o=t;or){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(tr)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function le(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o0&&(i*=256)){n+=this[e+--t]*i}return n};f.prototype.readUInt8=function de(e,t){if(!t)M(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function pe(e,t){if(!t)M(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ge(e,t){if(!t)M(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function me(e,t){if(!t)M(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function ve(e,t){if(!t)M(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ye(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o=i)n-=Math.pow(2,8*t);return n};f.prototype.readIntBE=function _e(e,t,r){e=e|0;t=t|0;if(!r)M(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};f.prototype.readInt8=function we(e,t){if(!t)M(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function be(e,t){if(!t)M(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function ke(e,t){if(!t)M(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ee(e,t){if(!t)M(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function xe(e,t){if(!t)M(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Se(e,t){if(!t)M(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function Ae(e,t){if(!t)M(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Ie(e,t){if(!t)M(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Te(e,t){if(!t)M(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||te.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o=0&&(o*=256)){this[t+i]=e/o&255; +}return t+r};f.prototype.writeUInt8=function Be(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i>>(n?i:1-i)*8}}f.prototype.writeUInt16LE=function Re(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function Me(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function U(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i>>(n?i:3-i)*8&255}}f.prototype.writeUInt32LE=function Pe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{U(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function je(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Ue(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o>0)-s&255}return t+r};f.prototype.writeIntBE=function Oe(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1;var a=1;var s=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+r};f.prototype.writeInt8=function He(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function De(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Ne(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function qe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{U(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function ze(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{U(this,e,t,false)}return t+4};function O(e,t,r,n,i,o){if(t>i||te.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,n,o){if(!o){O(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function We(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Fe(e,t,r){return H(this,e,t,false,r)};function D(e,t,r,n,o){if(!o){O(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Ye(e,t,r){return D(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ve(e,t,r){return D(this,e,t,false,r)};f.prototype.copy=function Je(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n55295&&r<57344){if(i){if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}else{r=i-55296<<10|r-56320|65536;i=null}}else{if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===n){if((t-=3)>-1)o.push(239,191,189);continue}else{i=r;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<2097152){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function V(e){var t=[];for(var r=0;r>8;i=r%256;o.push(i);o.push(n)}return o}function $(e){return n.toByteArray(z(e))}function K(e,t,r,n){for(var i=0;i=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function G(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":46,ieee754:47,"is-array":48}],46:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===i||t===u)return 63;if(t0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;a="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var u=0;function l(e){s[u++]=e}for(r=0,n=0;r>16);l((o&65280)>>8);l(o&255)}if(a===2){o=c(e.charAt(r))<<2|c(e.charAt(r+1))>>4;l(o&255)}else if(a===1){o=c(e.charAt(r))<<10|c(e.charAt(r+1))<<4|c(e.charAt(r+2))>>2;l(o>>8&255);l(o&255)}return s}function h(e){var t,r=e.length%3,i="",o,a;function s(e){return n.charAt(e)}function f(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-r;t>2);i+=s(o<<4&63);i+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1];i+=s(o>>10);i+=s(o>>4&63);i+=s(o<<2&63);i+="=";break}return i}e.toByteArray=l;e.fromByteArray=h})(typeof r==="undefined"?this.base64js={}:r)},{}],47:[function(e,t,r){r.read=function(e,t,r,n,i){var o,a,s=i*8-n-1,f=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];l+=h;o=d&(1<<-c)-1;d>>=-c;c+=s;for(;c>0;o=o*256+e[t+l],l+=h,c-=8){}a=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;a=a*256+e[t+l],l+=h,c-=8){}if(o===0){o=1-u}else if(o===f){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,n);o=o-u}return(d?-1:1)*a*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var a,s,f,u=o*8-i-1,c=(1<>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=c}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-a))<1){a--;f*=2}if(a+l>=1){t+=h/f}else{t+=h*Math.pow(2,1-l)}if(t*f>=2){a++;f/=2}if(a+l>=c){s=0;a=c}else if(a+l>=1){s=(t*f-1)*Math.pow(2,i);a=a+l}else{s=t*Math.pow(2,l-1)*Math.pow(2,i);a=0}}for(;i>=8;e[r+d]=s&255,d+=p,s/=256,i-=8){}a=a<0;e[r+d]=a&255,d+=p,a/=256,u-=8){}e[r+d-p]|=g*128}},{}],48:[function(e,t,r){var n=Array.isArray;var i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],49:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||a(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(s(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;o=new Array(n-1);for(f=1;f0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(r)){for(s=o;s-->0;){if(r[s]===t||r[s].listener&&r[s].listener===t){n=s;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function a(e){return typeof e==="object"&&e!==null}function s(e){return e===void 0}},{}],50:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],51:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var a=i>=0?arguments[i]:e.cwd();if(typeof a!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!a){continue}r=a+"/"+r;n=a.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var f=0;f1){for(var r=1;r= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-l,E=Math.floor,x=String.fromCharCode,S;function A(e){throw RangeError(b[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function T(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(w,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function C(e){var t=[],r=0,n=e.length,i,o;while(r=55296&&i<=56319&&r65535){e-=65536;t+=x(e>>>10&1023|55296);e=56320|e&1023}t+=x(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function M(e,t,r){var n=0;e=r?E(e/p):e>>1;e+=E(e/t);for(;e>k*h>>1;n+=c){e=E(e/k)}return E(n+(k+1)*e/(e+d))}function P(e){var t=[],r=e.length,n,i=0,o=m,a=g,s,f,d,p,y,_,w,b,k;s=e.lastIndexOf(v);if(s<0){s=0}for(f=0;f=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=s>0?s+1:0;d=r){A("invalid-input")}w=B(e.charCodeAt(d++));if(w>=c||w>E((u-i)/y)){A("overflow")}i+=w*y;b=_<=a?l:_>=a+h?h:_-a;if(wE(u/k)){A("overflow")}y*=k}n=t.length+1;a=M(i-p,n,p==0);if(E(i/n)>u-o){A("overflow")}o+=E(i/n);i%=n;t.splice(i++,0,o)}return L(t)}function j(e){var t,r,n,i,o,a,s,f,d,p,y,_=[],w,b,k,S;e=C(e);w=e.length;t=m;r=0;o=g;for(a=0;a=t&&yE((u-r)/b)){A("overflow")}r+=(s-t)*b;t=s;for(a=0;au){A("overflow")}if(y==t){for(f=r,d=c;;d+=c){p=d<=o?l:d>=o+h?h:d-o;if(f0&&u>f){u=f}for(var c=0;c=0){d=l.substr(0,h);p=l.substr(h+1)}else{d=l;p=""}g=decodeURIComponent(d);m=decodeURIComponent(p);if(!n(a,g)){a[g]=m}else if(i(a[g])){a[g].push(m)}else{a[g]=[a[g],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],55:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,s){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(n(a))+r;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(n(e))}).join(t)}else{return s+encodeURIComponent(n(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(n(s))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n0){if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}b(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length=p){e=p}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function m(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||s.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=g(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}l.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)T(this);else _(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)T(this);return null}var n=t.needReadable;u("need readable",n);if(t.length===0||t.length-e0)i=I(e,t);else i=null;if(s.isNull(i)){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)T(this);if(!s.isNull(i))this.emit("data",i);return i};function v(e,t){var r=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){w(e)});else w(e)}}function w(e){u("emit readable");e.emit("readable");A(e)}function b(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){k(e,t)})}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length=n){if(o)s=r.join("");else s=i.concat(r,n);r.length=0}else{if(e0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function C(e,t){for(var r=0,n=e.length;r1){var r=[];for(var n=0;n",'"',"`"," ","\r","\n"," "],f=["{","}","|","\\","^","`"].concat(s),u=["'"].concat(f),c=["%","/","?",";","#"].concat(u),l=["/","?","#"],h=255,d=/^[a-z0-9A-Z_-]{0,63}$/,p=/^([a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},v={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&x(e)&&e instanceof i)return e;var n=new i;n.parse(e,t,r);return n}i.prototype.parse=function(e,t,r){if(!E(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var i=e;i=i.trim();var a=o.exec(i);if(a){a=a[0];var s=a.toLowerCase();this.protocol=s;i=i.substr(a.length)}if(r||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=i.substr(0,2)==="//";if(f&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(f||a&&!v[a])){var _=-1;for(var w=0;w127){C+="x"}else{C+=T[L]}}if(!C.match(d)){var R=A.slice(0,w);var M=A.slice(w+1);var P=T.match(p);if(P){R.push(P[1]);M.unshift(P[2])}if(M.length){i="/"+M.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>h){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var j=this.hostname.split(".");var U=[];for(var w=0;w0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!l.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var p=l.slice(-1)[0];var g=(r.host||e.host)&&(p==="."||p==="..")||p==="";var y=0;for(var _=l.length;_>=0;_--){p=l[_];if(p=="."){l.splice(_,1)}else if(p===".."){l.splice(_,1);y++}else if(y){l.splice(_,1);y--}}if(!u&&!c){for(;y--;y){l.unshift("..")}}if(u&&l[0]!==""&&(!l[0]||l[0].charAt(0)!=="/")){l.unshift("")}if(g&&l.join("/").substr(-1)!=="/"){l.push("")}var w=l[0]===""||l[0]&&l[0].charAt(0)==="/";if(h){r.hostname=r.host=w?"":l.length?l.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&l.length;if(u&&!w){l.unshift("")}if(!l.length){r.pathname=null;r.path=null}else{r.pathname=l.join("/")}if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};i.prototype.parseHost=function(){var e=this.host;var t=a.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function E(e){return typeof e==="string"}function x(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:53,querystring:56}],71:[function(e,t,r){(function(r){t.exports=m;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=v;var n=e("bencode");var i=e("block-stream2");var o=e("piece-length");var a=e("path");var s=e("dezalgo");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};v(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function v(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=s(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(A(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&a.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var i=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(n){var o={};if(S(e)){o.getStream=T(e);o.length=e.size}else if(r.isBuffer(e)){o.getStream=C(e);o.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}o.getStream=B(e,o);o.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var s=i>1;y(e,s,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");o.path=e.name.split(a.sep);n(null,o)}}),function(e,t){if(e)return n(e);t=u(t);n(null,t)})}function y(e,t,r){w(_,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=L(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function _(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function w(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.filter(b).map(function(r){return function(n){w(e,a.join(t,r),n)}}),r)}})}function b(e){return e[0]!=="."}function k(e,t,n){n=h(n);var o=[];var a=0;var s=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;var d=new l(s);var g=new i(t,{zeroPadding:false});d.on("error",y);d.pipe(g).on("data",m).on("end",v).on("error",y);function m(e){a+=e.length;var t=u;p(e,function(e){o[t]=e;f-=1;w()});f+=1;u+=1}function v(){c=true;w()}function y(e){_();n(e)}function _(){d.removeListener("error",y);g.removeListener("data",m);g.removeListener("end",v);g.removeListener("error",y)}function w(){if(c&&f===0){_();n(null,new r(o.join(""),"hex"),a)}}}function E(e,r,i){var a=r.announceList!==undefined?r.announceList:r.announce!==undefined?r.announce.map(function(e){return[e]}):t.exports.announceList;var s={info:{name:r.name},announce:a[0][0],"announce-list":a,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)s.info.comment=r.comment;if(r.createdBy!==undefined)s.info["created by"]=r.createdBy;if(r.private!==undefined)s.info.private=Number(r.private);if(r.sslCert!==undefined)s.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)s["url-list"]=r.urlList;var f=e.length===1;var u=r.pieceLength||o(e.reduce(x,0));s.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return i(t);s.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){s.info.files=e}else{s.info.length=o}i(null,n.encode(s))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function A(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function T(e){return function(){return new f(e)}}function C(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function L(e){return function(){return c.createReadStream(e)}}function B(e,t){return function(){var r=new g.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("buffer").Buffer)},{bencode:72,"block-stream2":76,buffer:45,dezalgo:88,"filestream/read":94,flatten:95,fs:43,multistream:96,once:99,path:51,"piece-length":100,"run-parallel":102,"simple-sha1":106,stream:68}],72:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":73,"./lib/encode":75,dup:13}],73:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":74,buffer:45,dup:14}],74:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],75:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],76:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{buffer:45,defined:77,dup:32,inherits:78,"readable-stream":87}],77:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{dup:33}],78:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],79:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{"./_stream_readable":81,"./_stream_writable":83,_process:52,"core-util-is":84,dup:34,inherits:78}],80:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./_stream_transform":82,"core-util-is":84,dup:35,inherits:78}],81:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{_process:52,buffer:45,"core-util-is":84,dup:36,events:49,inherits:78,isarray:85,stream:68,"string_decoder/":86}],82:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{"./_stream_duplex":79,"core-util-is":84,dup:37,inherits:78}],83:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{"./_stream_duplex":79,_process:52,buffer:45,"core-util-is":84,dup:38,inherits:78,stream:68}],84:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{buffer:45,dup:39}],85:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],86:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{buffer:45,dup:41}],87:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./lib/_stream_duplex.js":79,"./lib/_stream_passthrough.js":80,"./lib/_stream_readable.js":81,"./lib/_stream_transform.js":82,"./lib/_stream_writable.js":83,dup:42,stream:68}],88:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:89,dup:27,wrappy:90}],89:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],90:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],91:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],92:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(n(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:45,"is-typedarray":93}],93:[function(e,t,r){t.exports=o;o.strict=a;o.loose=s;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[n.call(e)]}},{}],94:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var r=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};n.call(this,t);this._offset=0;this._ready=false;this._file=e;this._size=e.size;this._chunkSize=t.chunkSize||Math.max(this._size/1e3,200*1024);this.reader=new FileReader;this._generateHeaderBlocks(e,t,function(e,t){if(e){return r.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){r.push(e)})}r._ready=true;r.emit("_ready")})}i(s,n);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var r=this._offset;var n=this._offset+this._chunkSize;if(n>this._size)n=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=n;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,n))};s.prototype.destroy=function(){this._file=null;if(this.reader){this.reader.onload=null;this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:91,stream:68,"typedarray-to-buffer":92}],95:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n=r){break}r=n;i=t[o]}return i}},{}],102:[function(e,t,r){var n=e("dezalgo");t.exports=function(e,t){if(t)t=n(t);var r,i,o;if(Array.isArray(e)){r=[];i=e.length}else{o=Object.keys(e);r={};i=o.length}function a(e,n,o){r[e]=o;if(--i===0||n){if(t)t(n,r);t=null}}if(!i){if(t)t(null,r);t=null}else if(o){o.forEach(function(t){e[t](a.bind(undefined,t))})}else{e.forEach(function(e,t){e(a.bind(undefined,t))})}}},{dezalgo:103}],103:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{asap:104,dup:27,wrappy:105}],104:[function(e,t,r){arguments[4][28][0].apply(r,arguments)},{_process:52,dup:28}],105:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],106:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var a=o.subtle||o.webkitSubtle;var s=i.digest.bind(i);try{a.digest({name:"sha-1"},new Uint8Array).catch(function(){a=false})}catch(f){a=false}function u(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=c(e)}a.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(s(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=s},{rusha:107}],107:[function(e,t,r){(function(e){(function(){if(typeof t!=="undefined"){t.exports=o}else if(typeof window!=="undefined"){window.Rusha=o}if(typeof FileReaderSync!=="undefined"){var r=new FileReaderSync,n=new o(4*1024*1024);self.onmessage=function s(e){var t,r=e.data.data;try{t=n.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}var i={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function o(e){"use strict";var t={fill:0};var n=function(e){for(e+=9;e%64>0;e+=1);return e};var o=function(e,t){for(var r=t>>2;r>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(a=s;a>2]=o.charCodeAt(r+a)<<24|o.charCodeAt(r+a+1)<<16|o.charCodeAt(r+a+2)<<8|o.charCodeAt(r+a+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,a,s=i%4,f=n%4,u=n-f;if(u>0){switch(s){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(a=4-s;a>2]=o[r+a]<<24|o[r+a+1]<<16|o[r+a+2]<<8|o[r+a+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,n,i,o){var a=this,s,f=o%4,u=i%4,c=i-u;var l=new Uint8Array(r.readAsArrayBuffer(a.slice(n,n+i)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(s=4-f;s>2]=l[s]<<24|l[s+1]<<16|l[s+2]<<8|l[s+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(i.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var h=function(e,t){switch(i.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t)}};var d=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=n(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20)); +t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=a({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};g(e||64*1024);var m=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var v=function(e,r){var i=n(e);var a=new Int32Array(t.heap,0,i>>2);o(a,e);s(a,e,r);return i};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var a=n;if(o){a=v(n,i)}y(e,r,n);t.core.hash(a,t.padMaxChunkLen)};var w=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var b=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(b(e).buffer)}}function a(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,a=0,s=0,f=0,u=0,c=0,l=0,h=0,d=0,p=0,g=0,m=0;o=n[t+320>>2]|0;s=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;d=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){a=o;f=s;c=u;h=l;p=d;for(i=0;(i|0)<64;i=i+4|0){m=n[r+i>>2]|0;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|~s&l)|0)+((m+d|0)+1518500249|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)+1859775393|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s&u|s&l|u&l)|0)+((m+d|0)-1894007588|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(s^u^l)|0)+((m+d|0)-899497514|0)|0;d=l;l=u;u=s<<30|s>>>2;s=o;o=g;n[i>>2]=m}o=o+a|0;s=s+f|0;u=u+c|0;l=l+h|0;d=d+p|0}n[t+320>>2]=o;n[t+324>>2]=s;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=d}return{hash:i}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],108:[function(e,t,r){r=t.exports=e("./debug");r.log=o;r.formatArgs=i;r.save=a;r.load=s;r.useColors=n;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function i(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function o(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{if(null==e){r.storage.removeItem("debug")}else{r.storage.debug=e}}catch(t){}}function s(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(s());function f(){try{return window.localStorage}catch(e){}}},{"./debug":109}],109:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:110}],110:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var a=o*24;var s=a*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){e=""+e;if(e.length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*s;case"days":case"day":case"d":return r*a;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=a)return Math.round(e/a)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,a,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e=Math.pow(2,e)){return n(e,t)}else return a};n.rack=function(e,t,r){var i=function(i){var a=0;do{if(a++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var s=n(e,t)}while(Object.hasOwnProperty.call(o,s));o[s]=i;return s};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],116:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],117:[function(e,t,r){arguments[4][96][0].apply(r,arguments)},{dup:96,inherits:118,stream:68}],118:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],119:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],120:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:119}],121:[function(e,t,r){(function(r){var n=e("magnet-uri");var i=e("parse-torrent-file");t.exports=function o(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return n(e)}else if(typeof e==="string"&&(t===40||t===32)){return n("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return n("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return i(e)}else if(e&&e.infoHash){return e}else{throw new Error("Invalid torrent identifier")}};t.exports.toMagnetURI=n.encode;t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:45,"magnet-uri":122,"parse-torrent-file":127}],122:[function(e,t,r){(function(r){t.exports=a;t.exports.decode=a;t.exports.encode=s;var n=e("thirty-two");var i=e("xtend");var o=e("uniq");function a(e){var t={};var i=e.split("magnet:?")[1];var a=i&&i.length>=0?i.split("&"):[];a.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var s;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=n.decode(s[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];o(t.announce);t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}return t}function s(e){e=i(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:45,"thirty-two":123,uniq:125,xtend:126}],123:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":124}],124:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var n=0;var o=0;var a=0;var s=0;var f=new e(i(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(n3){s=u&255>>a;a=(a+5)%8;s=s<>8-a;n++}else{s=u>>8-(a+5)&31;a=(a+5)%8;if(a==0)n++}f[o]=t.charCodeAt(s);o++}for(n=o;n>>r;s[a]=o;a++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:45}],125:[function(e,t,r){"use strict";function n(e,t){var r=1,n=e.length,i=e[0],o=e[0];for(var a=1;a0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var s=e.info.files||[e.info];t.files=s.map(function(e,r){var n=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:s.slice(0,r).reduce(u,0)}});t.length=s.reduce(u,0);var f=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength;t.pieces=c(e.info.pieces);return t}function f(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new r(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return n.encode(t)}function u(e,t){return e+t.length}function c(e){var t=[];for(var r=0;r10)e.numWant=10;t._generateOffers(e.numWant,function(r){e.offers=r;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};h.prototype.scrape=function(e){var t=this;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};h.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(r,t._intervalMs)}};h.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._socket.removeListener("data",e._onSocketDataBound);e._socket.removeListener("close",e._onSocketCloseBound);e._socket.removeListener("error",e._onSocketErrorBound);e._onSocketErrorBound=null;e._onSocketDataBound=null;e._onSocketCloseBound=null;e._socket.on("error",d);try{e._socket.close()}catch(t){}e._socket=null};h.prototype._openSocket=function(){var e=this;e._onSocketErrorBound=e._onSocketError.bind(e);e._onSocketDataBound=e._onSocketData.bind(e);e._onSocketCloseBound=e._onSocketClose.bind(e);e._socket=new f(e._announceUrl);e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};h.prototype._onSocketData=function(e){var t=this;if(t.destroyed)return;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHashBinary){return t.client.emit("warning",new Error("Invalid tracker response"))}n("received %s from %s",JSON.stringify(e),t._announceUrl);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o&&!t._opts.interval&&t._intervalMs!==0){t.setInterval(o*1e3)}var a=e["tracker id"];if(a){t._trackerId=a}if(e.complete){t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete})}if(t.client._peerIdHex===u.binaryToHex(e.peer_id)){return}var f;if(e.offer){f=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});f.id=u.binaryToHex(e.peer_id);f.once("signal",function(r){var n={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});f.signal(e.offer);t.client.emit("peer",f)}if(e.answer){f=t._peers[u.binaryToHex(e.offer_id)];if(f){f.id=u.binaryToHex(e.peer_id);f.signal(e.answer);t.client.emit("peer",f)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};h.prototype._onSocketClose=function(){var e=this;e.destroy();var t=Math.floor(Math.random()*c)+l;setTimeout(function(){e._openSocket()},t);n("reconnecting socket in %s ms",t)};h.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.client.emit("error",e)};h.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);n("send %s",r);t._socket.send(r)};h.prototype._generateOffers=function(e,t){var r=this;var i=[];n("generating %s offers",e);for(var a=0;an._maxBufferedAmount){n._debug("start backpressure: bufferedAmount %d",n._channel.bufferedAmount);n._cb=r}else{r(null)}}else{n._debug("write before connect");n._chunk=e;n._cb=r}};c.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};c.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;h(t);t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,d,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};c.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(r==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(r==="closed"){e._destroy()}};c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.remoteFamily="IPv4";e.remotePort=Number(t.portNumber);e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;e._debug('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}e._interval=setInterval(function(){if(!e._cb||!e._channel||e._channel.bufferedAmount>e._maxBufferedAmount)return;e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref();e._debug("connect");e.emit("connect")}};c.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};c.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:e.candidate})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};c.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=u(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};c.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};c.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};c.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};c.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};c.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function l(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}function h(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function d(){}}).call(this,e("buffer").Buffer)},{buffer:45,debug:156,hat:159,inherits:160,"is-typedarray":161,once:163,stream:68,"typedarray-to-buffer":164}],156:[function(e,t,r){arguments[4][108][0].apply(r,arguments)},{"./debug":157,dup:108}],157:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:158}],158:[function(e,t,r){arguments[4][110][0].apply(r,arguments)},{dup:110}],159:[function(e,t,r){arguments[4][115][0].apply(r,arguments)},{dup:115}],160:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],161:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],162:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29}],163:[function(e,t,r){arguments[4][99][0].apply(r,arguments)},{dup:99,wrappy:162}],164:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":161}],165:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;i(c,a.Duplex);function c(e,t){var r=this;if(!(r instanceof c))return new c(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._maxBufferedAmount=t.highWaterMark;r._chunk=null;r._cb=null;r._interval=null;r._ws=new u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=r._onError.bind(r);r.on("finish",function(){if(r.connected){setTimeout(function(){r._destroy()},100)}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}c.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}var i=e.length||e.byteLength||e.size;t._ws.send(e);n("write: %d bytes",i)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.connected=false;r.destroyed=true;clearInterval(r._interval);r._interval=null;r._chunk=null;r._cb=null;if(r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null;r._ws.onmessage=null;r._ws.onclose=null;r._ws.onerror=null}r._ws=null;if(e)r.emit("error",e);r.emit("close")};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var i=this;if(i.destroyed)return r(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof f!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){n("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=r}else{r(null)}}else{n("write before connect");i._chunk=e;i._cb=r}};c.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};c.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;if(e._chunk){e.send(e._chunk);e._chunk=null;n('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}n("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}n("connect");e.emit("connect")};c.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};c.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);n("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:45,debug:166,inherits:169,"is-typedarray":170,stream:68,"typedarray-to-buffer":171,ws:44}],166:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{"./debug":167,dup:18}],167:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19,ms:168}],168:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],169:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],170:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],171:[function(e,t,r){arguments[4][92][0].apply(r,arguments)},{buffer:45,dup:92,"is-typedarray":172}],172:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],173:[function(e,t,r){t.exports=n;function n(e){for(var t=1;tf){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==s.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;e0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:182,bitfield:186,buffer:45,events:49,inherits:187,"simple-sha1":188}],182:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{"./lib/decode":183,"./lib/encode":185,dup:13}],183:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{"./dict":184,buffer:45,dup:14}],184:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],185:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{buffer:45,dup:16}],186:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{buffer:45,dup:8}],187:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],188:[function(e,t,r){arguments[4][106][0].apply(r,arguments)},{dup:106,rusha:189}],189:[function(e,t,r){arguments[4][107][0].apply(r,arguments)},{dup:107}],190:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],191:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],192:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.43.1",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./server":false,"bittorrent-dht/client":false,"load-ip-set":false,"simple-get":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","block-stream2":"^1.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^5.0.0","pretty-bytes":"^1.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-get":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^4.0.0",brfs:"^1.2.0",browserify:"^10.0.0","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}]},{},[1])(1)}); -- cgit v1.2.3