Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-06-29 12:49:50 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-06-29 12:49:50 +0300
commitcbe3782a6651b5443fb5247ef55cecd13b04c2db (patch)
treed881e2261276283e31b7c8f935369a3c82272c95 /webtorrent.min.js
parentd549b6fa067061d97ab13ec250317bdec382c451 (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 1dbd668..c912213 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,8 +1,8 @@
-(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,n;return function r(e,t,n){function i(a,s){if(!t[a]){if(!e[a]){var c=typeof require=="function"&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,r,e,t,n)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,n){t.exports=c;var r=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("path");var a=e("stream");var s=e("./media-stream");i(c,a.Readable);function c(e,t){var n=this;if(!(n instanceof c))return new c(e,t);a.Readable.call(n,t);r("new filestream %s",JSON.stringify(t));if(!t)t={};if(!t.start)t.start=0;if(!t.end)t.end=e.length-1;n.destroyed=false;n.length=t.end-t.start+1;var i=t.start+e.offset;var s=t.pieceLength;n.startPiece=i/s|0;n.endPiece=(t.end+e.offset)/s|0;n._extname=o.extname(e.name).toLowerCase();n._storage=e.storage;n._piece=n.startPiece;n._missing=n.length;n._reading=false;n._notifying=false;n._criticalLength=Math.min(1024*1024/s|0,2);n._offset=i-n.startPiece*s}c.prototype._read=function(){var e=this;r("_read");if(e._reading)return;e._reading=true;e.notify()};c.prototype.notify=function(){var e=this;r("notify");if(!e._reading||e._missing===0)return;if(!e._storage.bitfield.get(e._piece)){return e._storage.emit("critical",e._piece,e._piece+e._criticalLength)}if(e._notifying)return;e._notifying=true;var t=e._piece;r("before read %s",t);e._storage.read(e._piece++,function(n,i){r("after read %s (length %s) (err %s)",t,i.length,n&&n.message);e._notifying=false;if(e.destroyed)return;if(n){e._storage.emit("error",n);return e.destroy(n)}if(e._offset){i=i.slice(e._offset);e._offset=0}if(e._missing<i.length){i=i.slice(0,e._missing)}e._missing-=i.length;r("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)})};c.prototype.pipe=function(e){var t=this;var n=a.Readable.prototype.pipe;if(e&&(e.nodeName==="VIDEO"||e.nodeName==="AUDIO")){var r={".webm":'video/webm; codecs="vorbis,vp8"',".mp4":'video/mp4; codecs="avc1.42c01e,mp4a.40.2"',".mp3":"audio/mpeg"}[t._extname];return n.call(t,new s(e,{type:r}))}else{return n.call(t,e)}};c.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._storage.emit("deselect",e.startPiece,e.endPiece,true)}},{"./media-stream":2,debug:35,inherits:49,path:62,stream:86}],2:[function(e,t,n){t.exports=c;var r=e("debug")("webtorrent:media-stream");var i=e("inherits");var o=e("once");var a=e("stream");var s=typeof window!=="undefined"&&window.MediaSource;i(c,a.Writable);function c(e,t){var n=this;if(!(n instanceof c))return new c(e,t);a.Writable.call(n,t);if(!s)throw new Error("web browser lacks MediaSource support");n.media=e;t=t||{};t.type=t.type||'video/webm; codecs="vorbis,vp8"';r("new mediastream %s %s",e,JSON.stringify(t));n._mediaSource=new s;n._sourceBuffer=null;n._cb=null;n.media.src=window.URL.createObjectURL(n._mediaSource);var i=o(function(){n._sourceBuffer=n._mediaSource.addSourceBuffer(t.type);n._sourceBuffer.addEventListener("updateend",n._flow.bind(n));n._flow()});n._mediaSource.addEventListener("webkitsourceopen",i,false);n._mediaSource.addEventListener("sourceopen",i,false);n.on("finish",function(){r("finish");n._mediaSource.endOfStream()});window.vs=n}c.prototype._write=function(e,t,n){var i=this;if(!i._sourceBuffer){i._cb=function(r){if(r)return n(r);i._write(e,t,n)};return}if(i._sourceBuffer.updating){return n(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);r("appendBuffer %s",e.length);i._cb=n};c.prototype._flow=function(){var e=this;r("flow");if(e._cb){e._cb(null)}}},{debug:35,inherits:49,once:59,stream:86}],3:[function(e,t,n){t.exports={".aac":"audio/aac",".css":"text/css",".html":"text/html",".js":"application/javascript",".m4a":"audio/mp4",".md":"text/x-markdown",".mp3":"audio/mpeg",".mp4":"video/mp4",".oga":"audio/ogg",".ogg":"audio/ogg",".pdf":"application/pdf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm"}},{}],4:[function(e,t,n){t.exports=r;function r(e,t){var n=this;n.swarm=e;n.numPieces=t;function r(e){e.on("have",function(e){n.pieces[e]++});e.on("bitfield",n.recalculate.bind(n));e.on("close",function(){for(var t=0;t<n.numPieces;++t){n.pieces[t]-=e.peerPieces.get(t)}})}n.swarm.wires.forEach(r);n.swarm.on("wire",function(e){n.recalculate();r(e)});n.recalculate()}r.prototype.recalculate=function(){var e=this;e.pieces=[];for(var t=0;t<e.numPieces;++t){e.pieces[t]=0}e.swarm.wires.forEach(function(t){for(var n=0;n<e.numPieces;++n){e.pieces[n]+=t.peerPieces.get(n)}})};r.prototype.getRarestPiece=function(e){var t=this;var n=[];var r=Infinity;e=e||function(){return true};for(var i=0;i<t.numPieces;++i){if(!e(i))continue;var o=t.pieces[i];if(o===r){n.push(i)}else if(o<r){n=[i];r=o}}if(n.length>0){return n[Math.random()*n.length|0]}else{return-1}}},{}],5:[function(e,t,n){var r=e("debug")("webtorrent:server");var i=e("http");var o=e("mime");var a=e("pump");var s=e("range-parser");var c=e("url");t.exports=function f(e,t){var n=i.createServer(t);n.on("connection",function(e){e.setTimeout(36e6)});n.on("request",function(t,n){r("onRequest");if(t.method==="OPTIONS"&&t.headers["access-control-request-headers"]){n.setHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS");n.setHeader("Access-Control-Allow-Headers",t.headers["access-control-request-headers"]);n.setHeader("Access-Control-Max-Age","1728000");return n.end()}if(t.headers.origin){n.setHeader("Access-Control-Allow-Origin",t.headers.origin)}var i=c.parse(t.url).pathname;if(i==="/favicon.ico")return n.end();if(e.ready)f();else e.once("ready",f);function f(){if(i==="/"){n.setHeader("Content-Type","text/html");var c=e.files.map(function(e,t){return'<li><a href="/'+t+'">'+e.name+"</a></li>"}).join("<br>");return n.end("<h1>WebTorrent</h1><ol>"+c+"</ol>")}var f=Number(i.slice(1));if(Number.isNaN(f)||f>=e.files.length){n.statusCode=404;return n.end()}var l=e.files[f];n.setHeader("Accept-Ranges","bytes");n.setHeader("Content-Type",o.lookup(l.name));n.statusCode=200;n.setHeader("transferMode.dlna.org","Streaming");n.setHeader("contentFeatures.dlna.org","DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000");var u;if(t.headers.range){n.statusCode=206;u=s(l.length,t.headers.range)[0];r("range %s",JSON.stringify(u));n.setHeader("Content-Range","bytes "+u.start+"-"+u.end+"/"+l.length);n.setHeader("Content-Length",u.end-u.start+1)}else{n.setHeader("Content-Length",l.length)}if(t.method==="HEAD")n.end();a(l.createReadStream(u),n)}});return n}},{debug:35,http:45,mime:55,pump:64,"range-parser":68,url:93}],6:[function(e,t,n){(function(n,r){t.exports=E;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var c=e("end-of-stream");var f=e("events").EventEmitter;var l=e("./file-stream");var u=e("inherits");var p=e("./mime.json");var d=e("multistream");var h=e("once");var v=e("path");var m=e("simple-sha1");var g=16*1024;var y=0;var w=1;var b=2;function _(){}u(x,f);function x(e,t,n,r){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!r;if(typeof n==="number"){i.buffer=null;i.length=n}else{i.buffer=n;i.length=n.length}i._reset()}x.prototype.readBlock=function(e,t,n){var r=this;n=s(n);if(!r.buffer||!r._verifyOffset(e)){return n(new Error("invalid block offset "+e))}n(null,r.buffer.slice(e,e+t))};x.prototype.writeBlock=function(e,t,n){var r=this;n=s(n);if(!r._verifyOffset(e)||!r._verifyBlock(e,t)){return n(new Error("invalid block "+e+":"+t.length))}r._lazyAllocBuffer();var i=e/g;if(r.blocks[i]===b){return n(null)}t.copy(r.buffer,e);r.blocks[i]=b;r.blocksWritten+=1;if(r.blocksWritten===r.blocks.length){r.verify()}n(null)};x.prototype.reserveBlock=function(e){var t=this;var n=t.blocks.length;for(var r=0;r<n;r++){if(t.blocks[r]&&!e||t.blocks[r]===b){continue}t.blocks[r]=w;return{offset:r*g,length:r===n-1?t.length-r*g:g}}return null};x.prototype.cancelBlock=function(e){var t=this;if(!t._verifyOffset(e)){return false}var n=e/g;if(t.blocks[n]===w){t.blocks[n]=y}return true};x.prototype._reset=function(){var e=this;e.verified=false;e.blocks=new r(Math.ceil(e.length/g));e.blocks.fill(0);e.blocksWritten=0};x.prototype.verify=function(e){var t=this;e=e||t.buffer;if(t.verified||!e){return}if(t.noVerify){t.verified=true;n();return}m(e,function(e){t.verified=e===t.hash;n()});function n(){if(t.verified){t.emit("done")}else{t.emit("warning",new Error("piece "+t.index+" failed verification"));t._reset()}}};x.prototype._verifyOffset=function(e){var t=this;if(e%g===0){return true}else{t.emit("warning",new Error("invalid block offset "+e+", not multiple of "+g));return false}};x.prototype._verifyBlock=function(e,t){var n=this;if(t.length===g){return true}else if(t.length===n.length-e&&n.length-e<g){return true}else{n.emit("warning",new Error("invalid block size "+t.length));return false}};x.prototype._lazyAllocBuffer=function(){var e=this;if(!e.buffer){e.buffer=new r(e.length)}};u(k,f);function k(e,t,n,r){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);i.storage=e;i.name=t.name;i.path=t.path;i.length=t.length;i.offset=t.offset;i.pieces=n;i.pieceLength=r;i.done=false;i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})});i._checkDone()}k.prototype.select=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var n=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,n,false)}};k.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var n=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,n,false)}};k.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var n=new l(t,e);t.storage.emit("select",n.startPiece,n.endPiece,true,n.notify.bind(n));c(n,function(){t.storage.emit("deselect",n.startPiece,n.endPiece,true)});return n};k.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(n,r){if(n)return e(n);var i=p[v.extname(t.name).toLowerCase()];var o=i?new window.Blob([r],{type:i}):new window.Blob([r]);var a=window.URL.createObjectURL(o);e(null,a)})};k.prototype.getBuffer=function(e){var t=this;e=s(h(e));var n;if(t.storage.buffer){var i=function(){n=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,n)};if(t.done)i();else t.once("done",i)}else{n=new r(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(n,o);o+=e.length}).on("end",function(){e(null,n)}).on("error",e)}};k.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){n.nextTick(function(){e.emit("done")})}};u(E,f);function E(e,t){var n=this;f.call(n);if(!a.enabled)n.setMaxListeners(0);if(!t)t={};n.bitfield=new i(e.pieces.length);n.done=false;n.closed=false;n.readonly=true;if(!t.nobuffer){n.buffer=new r(e.length)}var o=n.pieceLength=e.pieceLength;var s=e.lastPieceLength;var c=e.pieces.length;n.pieces=e.pieces.map(function(e,r){var i=r*o;var a=i+(r===c-1?s:o);var f=n.buffer?n.buffer.slice(i,a):a-i;var l=new x(r,e,f,!!t.noVerify);l.on("done",n._onPieceDone.bind(n,l));return l});n.files=e.files.map(function(e){var t=e.offset;var r=t+e.length-1;var i=t/o|0;var a=r/o|0;var s=n.pieces.slice(i,a+1);var c=new k(n,e,s,o);c.on("done",n._onFileDone.bind(n,c));return c})}E.BLOCK_LENGTH=g;E.prototype.load=function(e,t){var n=this;if(!Array.isArray(e))e=[e];t=h(t||function(){});var r=0;var i=new d(e);var a=new o(n.pieceLength,{zeroPadding:false});i.on("error",c);n.once("done",f);i.pipe(a).on("data",s).on("error",c);function s(e){var t=r;r+=1;var i=0;var a=new o(g,{zeroPadding:false});a.on("data",s);a.on("end",c);function s(e){var r=i*g;i+=1;n.writeBlock(t,r,e)}function c(){f()}function f(){a.removeListener("data",s);a.removeListener("end",c)}a.end(e)}function c(e){l();t(e)}function f(){l();t(null)}function l(){i.removeListener("error",c);a.removeListener("data",s);a.removeListener("error",c);n.removeListener("done",f)}};Object.defineProperty(E.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(E.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var n=0,r=e.pieces.length;n<r;n++){t-=e.bitfield.get(n)}return t}});E.prototype.readBlock=function(e,t,n,r){var i=this;r=s(r);var o=i.pieces[e];if(!o)return r(new Error("invalid piece index "+e));o.readBlock(t,n,r)};E.prototype.writeBlock=function(e,t,n,r){var i=this;if(!r)r=_;r=s(r);if(i.readonly)return r(new Error("cannot write to readonly storage"));var o=i.pieces[e];if(!o)return r(new Error("invalid piece index "+e));o.writeBlock(t,n,r)};E.prototype.read=function(e,t,n,i){var o=this;if(typeof t==="function"){i=n;n=t;t=null}n=s(n);var a=o.pieces[e];if(!a){return n(new Error("invalid piece index "+e))}if(!a.verified&&!i){return n(new Error("Storage.read called on incomplete piece "+e))}var c=0;var f=a.length;if(t){c=t.offset||0;f=t.length||f}if(a.buffer){return n(null,a.buffer.slice(c,c+f))}var l=[];function u(){if(f<=0)return n(null,r.concat(l));var t=c;var i=Math.min(g,f);c+=i;f-=i;o.readBlock(e,t,i,function(e,t){if(e)return n(e);l.push(t);u()})}u()};E.prototype.reserveBlock=function(e,t){var n=this;var r=n.pieces[e];if(!r)return null;return r.reserveBlock(t)};E.prototype.cancelBlock=function(e,t){var n=this;var r=n.pieces[e];if(!r)return false;return r.cancelBlock(t)};E.prototype.remove=function(e){if(e)s(e)(null)};E.prototype.close=function(e){var t=this;t.closed=true;if(e)s(e)(null)};E.prototype._onPieceDone=function(e){var t=this;t.bitfield.set(e.index);a("piece done "+e.index+" ("+t.numMissing+" still missing)");t.emit("piece",e)};E.prototype._onFileDone=function(e){var t=this;a("file done "+e.name);t.emit("file",e);t._checkDone()};E.prototype._checkDone=function(){var e=this;if(!e.done&&e.files.every(function(e){return e.done})){e.done=true;e.emit("done")}}}).call(this,e("_process"),e("buffer").Buffer)},{"./file-stream":1,"./mime.json":3,_process:29,bitfield:17,"block-stream2":26,buffer:31,debug:35,dezalgo:38,"end-of-stream":39,events:40,inherits:49,multistream:58,once:59,path:62,"simple-sha1":83}],7:[function(e,t,n){(function(n,r){t.exports=I;var i=e("addr-to-ip-port");var o=e("create-torrent");var a=e("debug")("webtorrent:torrent");var s=e("torrent-discovery");var c=e("events").EventEmitter;var f=e("inherits");var l=e("run-parallel");var u=e("parse-torrent");var p=e("re-emitter");var d=e("bittorrent-swarm");var h=e("uniq");var v=e("ut_metadata");var m=e("ut_pex");var g=e("./rarity-map");var y=e("./server");var w=e("./storage");var b=128*1024;var _=3e4;var x=5e3;var k=3*w.BLOCK_LENGTH;var E=.5;var S=1;var A=1e4;var T=2;function C(){}f(I,c);function I(e,t){var n=this;c.call(n);if(!a.enabled)n.setMaxListeners(0);a("new torrent");n.opts=t;n.client=t.client;n.hotswapEnabled="hotswap"in t?t.hotswap:true;n.verify=t.verify;n.chokeTimeout=t.chokeTimeout||x;n.pieceTimeout=t.pieceTimeout||_;n.strategy=t.strategy||"sequential";n._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;n._rechokeOptimisticWire=null;n._rechokeOptimisticTime=0;n._rechokeIntervalId=null;n.ready=false;n.destroyed=false;n.files=[];n.metadata=null;n.parsedTorrent=null;n.storage=null;n.numBlockedPeers=0;n._amInterested=false;n._selections=[];n._critical=[];n._storageImpl=t.storage||w;this._torrentFileURL=null;if(e)n._onTorrentId(e)}Object.defineProperty(I.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}});Object.defineProperty(I.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(I.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}});Object.defineProperty(I.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}});Object.defineProperty(I.prototype,"uploaded",{get:function(){return this.swarm.uploaded}});Object.defineProperty(I.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}});Object.defineProperty(I.prototype,"magnetURI",{get:function(){return u.toMagnetURI(this.parsedTorrent)}});Object.defineProperty(I.prototype,"torrentFile",{get:function(){return u.toTorrentFile(this.parsedTorrent)}});Object.defineProperty(I.prototype,"torrentFileURL",{get:function(){if(typeof window==="undefined")throw new Error("browser-only property");if(this._torrentFileURL)return this._torrentFileURL;this._torrentFileURL=window.URL.createObjectURL(new window.Blob([this.torrentFile],{type:"application/x-bittorrent"}));return this._torrentFileURL}});I.prototype._onTorrentId=function(e){var t=this;if(t.destroyed)return;var n=e&&e.parsedTorrent;if(n){t._onParsedTorrent(n)}else{u.remote(e,function(e,n){if(t.destroyed)return;if(e)return t._onError(e);t._onParsedTorrent(n)})}};I.prototype._onParsedTorrent=function(e){var t=this;if(t.destroyed)return;t.parsedTorrent=e;t.infoHash=e.infoHash;if(!t.infoHash){return t._onError(new Error("Malformed torrent data: Missing info hash."))}if(t.parsedTorrent.name)t.name=t.parsedTorrent.name;if(t.opts.announce){t.parsedTorrent.announce=t.parsedTorrent.announce.concat(t.opts.announce)}if(r.WEBTORRENT_ANNOUNCE){t.parsedTorrent.announce=t.parsedTorrent.announce.concat(r.WEBTORRENT_ANNOUNCE)}if(t.parsedTorrent.announce.length===0){t.parsedTorrent.announce=o.announceList.map(function(e){return e[0]})}h(t.parsedTorrent.announce);t.swarm=new d(t.infoHash,t.client.peerId,{handshake:{dht:!!t.client.dht}});t.swarm.on("error",t._onError.bind(t));p(t.swarm,t,["warning"]);t.swarm.on("wire",t._onWire.bind(t));t.swarm.on("download",t.client.downloadSpeed.bind(t.client));t.swarm.on("upload",t.client.uploadSpeed.bind(t.client));t.swarm.listen(t.client.torrentPort,t._onSwarmListening.bind(t));n.nextTick(function(){if(t.destroyed)return;t.emit("infoHash",t.infoHash)})};I.prototype._onSwarmListening=function(){var e=this;if(e.destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new s({announce:e.parsedTorrent.announce,dht:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.on("error",e._onError.bind(e));e.discovery.setTorrent(e.infoHash);e.discovery.on("peer",e.addPeer.bind(e));p(e.discovery,e,["dhtAnnounce","warning"]);if(e.parsedTorrent.info)e._onMetadata(e.parsedTorrent);e.emit("listening",e.client.torrentPort)};I.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;a("got metadata");if(e&&e.infoHash){t.metadata=u.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;var r=t.parsedTorrent.announce;try{t.parsedTorrent=u(t.metadata)}catch(i){return t._onError(i)}t.parsedTorrent.announce=r}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new g(t.swarm,t.parsedTorrent.pieces.length);t.storage=new t._storageImpl(t.parsedTorrent,t.opts);t.storage.on("piece",t._onStoragePiece.bind(t));t.storage.on("file",function(e){t.emit("file",e)});t._reservations=t.storage.pieces.map(function(){return[]});t.storage.on("done",function(){if(t.discovery.tracker)t.discovery.tracker.complete();a("torrent "+t.infoHash+" done");t.emit("done")});t.storage.on("select",t.select.bind(t));t.storage.on("deselect",t.deselect.bind(t));t.storage.on("critical",t.critical.bind(t));t.storage.files.forEach(function(e){t.files.push(e)});t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});if(t.verify){n.nextTick(function(){a("verifying existing torrent data");var e=0;var n=0;l(t.storage.pieces.map(function(r){return function(i){t.storage.read(r.index,function(o,s){e+=1;t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*n/t.storage.pieces.length});if(!o&&s){r.verify(s);n+=r.verified;a("piece "+(r.verified?"verified":"invalid")+" "+r.index)}i()},true)}}),t._onStorage.bind(t))})}else{n.nextTick(t._onStorage.bind(t))}n.nextTick(function(){t.emit("metadata")})};I.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;a("destroy");if(t._rechokeIntervalId){clearInterval(t._rechokeIntervalId);t._rechokeIntervalId=null}if(t._torrentFileURL)window.URL.revokeObjectURL(t._torrentFileURL);var n=[];if(t.swarm)n.push(function(e){t.swarm.destroy(e)});if(t.discovery)n.push(function(e){t.discovery.stop(e)});if(t.storage)n.push(function(e){t.storage.close(e)});l(n,e)};I.prototype.addPeer=function(e){var t=this;if(typeof e==="string"&&t.client.blocked&&t.client.blocked.contains(i(e)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}else{t.emit("peer",e);t.swarm.addPeer(e);return true}};I.prototype.select=function(e,t,n,r){var i=this;if(e>t||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}n=Number(n)||0;a("select %s-%s (priority %s)",e,t,n);i._selections.push({from:e,to:t,offset:0,priority:n,notify:r||C});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};I.prototype.deselect=function(e,t,n){var r=this;n=Number(n)||0;a("deselect %s-%s (priority %s)",e,t,n);for(var i=0;i<r._selections.length;++i){var o=r._selections[i];if(o.from===e&&o.to===t&&o.priority===n){r._selections.splice(i--,1);break}}r._updateSelections()};I.prototype.critical=function(e,t){var n=this;a("critical %s-%s",e,t);for(var r=e;r<=t;++r){n._critical[r]=true}n._updateSelections()};I.prototype._onWire=function(e,t){var n=this;a("got wire (%s)",t||"Unknown");if(t){var r=i(t);e.remoteAddress=r[0];e.remotePort=r[1]}if(e.peerExtensions.dht&&n.client.dht&&n.client.dht.listening){e.on("port",function(t){if(!e.remoteAddress){a("ignoring port from peer with no address");return}a("port: %s (from %s)",t,e.remoteAddress+":"+e.remotePort);n.client.dht.addNode(e.remoteAddress+":"+t)});e.port(n.client.dht.address().port)}e.on("timeout",function(){a("wire timeout (%s)",t);e.destroy()});e.setTimeout(n.pieceTimeout,true);e.setKeepAlive(true);e.use(v(n.metadata));if(!n.metadata){e.ut_metadata.on("metadata",function(e){a("got metadata via ut_metadata");n._onMetadata(e)});e.ut_metadata.fetch()}if(typeof m==="function"){e.use(m());e.ut_pex.on("peer",function(e){a("ut_pex: got peer: %s (from %s)",e,t);n.addPeer(e)});e.ut_pex.on("dropped",function(e){a("ut_pex: dropped peer: %s (from %s)",e,t);var r=n.swarm._peers[e];if(!r||!r.conn)n.swarm.removePeer(e)})}n.emit("wire",e);if(n.metadata){n._onWireWithMetadata(e)}};I.prototype._onWireWithMetadata=function(e){var t=this;var n=null;var r=t.chokeTimeout;function i(){if(t.destroyed||e.destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{n=setTimeout(i,r);if(n.unref)n.unref()}}var o=0;function s(){if(e.peerPieces.length!==t.storage.pieces.length)return;for(;o<t.storage.pieces.length;++o){if(!e.peerPieces.get(o))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){s();t._update()});e.on("have",function(){s();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(n)});e.on("choke",function(){clearTimeout(n);n=setTimeout(i,r);if(n.unref)n.unref()});e.on("unchoke",function(){clearTimeout(n);t._update()});e.on("request",function(n,r,i,o){if(i>b){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(n,r,i,o)});e.bitfield(t.storage.bitfield);e.interested();n=setTimeout(i,r);if(n.unref)n.unref();e.isSeeder=false;s()};I.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),A);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();n.nextTick(function(){e.ready=true;e.emit("ready")})};I.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()};I.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));n.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};I.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var n=e._selections[t];var r=n.offset;while(e.storage.bitfield.get(n.from+n.offset)&&n.from+n.offset<n.to){n.offset++}if(r!==n.offset)n.notify();if(n.to!==n.from+n.offset)continue;if(!e.storage.bitfield.get(n.from+n.offset))continue;e._selections.splice(t--,1);n.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};I.prototype._updateInterest=function(){var e=this;var t=e._amInterested;e._amInterested=!!e._selections.length;e.swarm.wires.forEach(function(t){if(e._amInterested)t.interested();else t.uninterested()});if(t===e._amInterested)return;if(e._amInterested)e.emit("interested");else e.emit("uninterested")};I.prototype._update=function(){var e=this;if(e.destroyed)return;R(e.swarm.wires,e._updateWire.bind(e))};I.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var n=j(e,E);if(e.requests.length>=n)return;var r=j(e,S);c(false)||c(true);function i(t,n,r,i){return function(o){return o>=t&&o<=n&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var n=t._selections.length;n--;){var r=t._selections[n];var o;if(t.strategy==="rarest"){var a=r.from+r.offset;var s=r.to;var c=s-a+1;var f={};var l=0;var u=i(a,s,f);while(l<c){o=t.rarityMap.getRarestPiece(u);if(o<0)break;if(t._request(e,o,false))return;f[o]=true;l+=1}}else{for(o=r.to;o>=r.from+r.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var n=e.downloadSpeed()||1;if(n>k)return function(){return true};var r=Math.max(1,e.requests.length)*w.BLOCK_LENGTH/n;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(;o<t.swarm.wires.length;o++){var c=t.swarm.wires[o];var f=c.downloadSpeed();if(f<k)continue;if(f<=n)continue;if(!c.peerPieces.get(e))continue;if((s-=f*r)>0)continue;i--;return false}return true}}function s(e){var n=e;for(var r=e;r<t._selections.length&&t._selections[r].priority;r++){n=r}var i=t._selections[e];t._selections[e]=t._selections[n];t._selections[n]=i}function c(n){if(e.requests.length>=r)return true;var o=a();for(var c=0;c<t._selections.length;c++){var f=t._selections[c];var l;if(t.strategy==="rarest"){var u=f.from+f.offset;var p=f.to;var d=p-u+1;var h={};var v=0;var m=i(u,p,h,o);while(v<d){l=t.rarityMap.getRarestPiece(m);if(l<0)break;while(t._request(e,l,t._critical[l]||n)){}if(e.requests.length<r){h[l]=true;v++;continue}if(f.priority)s(c);return true}}else{for(l=f.from+f.offset;l<=f.to;l++){if(!e.peerPieces.get(l)||!o(l))continue;while(t._request(e,l,t._critical[l]||n)){}if(e.requests.length<r)continue;if(f.priority)s(c);return true}}}return false}};I.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(n){if(!n.isSeeder&&n!==e._rechokeOptimisticWire){t.push({wire:n,downloadSpeed:n.downloadSpeed(),uploadSpeed:n.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var n=0;var r=0;for(;r<t.length&&n<e._rechokeNumSlots;++r){t[r].isChoked=false;if(t[r].wire.peerInterested)n+=1}if(!e._rechokeOptimisticWire&&r<t.length&&e._rechokeNumSlots){var i=t.slice(r).filter(function(e){return e.wire.peerInterested});var o=i[L(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=T}}t.forEach(function(e){if(e.wire.amChoking!==e.isChoked){if(e.isChoked)e.wire.choke();else e.wire.unchoke()}});function a(e,t){if(e.downloadSpeed!==t.downloadSpeed){return t.downloadSpeed-e.downloadSpeed}if(e.uploadSpeed!==t.uploadSpeed){return t.uploadSpeed-e.uploadSpeed}if(e.wire.amChoking!==t.wire.amChoking){return e.wire.amChoking?1:-1}return e.salt-t.salt}};I.prototype._hotswap=function(e,t){var n=this;if(!n.hotswapEnabled)return false;var r=e.downloadSpeed();if(r<w.BLOCK_LENGTH)return false;if(!n._reservations[t])return false;var i=n._reservations[t];if(!i){return false}var o=Infinity;var a;var s;for(s=0;s<i.length;s++){var c=i[s];if(!c||c===e)continue;var f=c.downloadSpeed();if(f>=k)continue;if(2*f>r||f>o)continue;a=c;o=f}if(!a)return false;for(s=0;s<i.length;s++){if(i[s]===a)i[s]=null}for(s=0;s<a.requests.length;s++){var l=a.requests[s];if(l.piece!==t)continue;n.storage.cancelBlock(t,l.offset)}n.emit("hotswap",a,e,t);return true};I.prototype._request=function(e,t,r){var i=this;var o=e.requests.length;if(i.storage.bitfield.get(t))return false;var s=j(e,S);if(o>=s)return false;var c=e.requests.length===0&&i.storage.numMissing<30;var f=i.storage.reserveBlock(t,c);if(!f&&!c&&r&&i._hotswap(e,t)){f=i.storage.reserveBlock(t,false)}if(!f)return false;var l=i._reservations[t];if(!l){l=i._reservations[t]=[]}var u=l.indexOf(null);if(u===-1)u=l.length;l[u]=e;function p(r,o){if(!i.ready){i.once("ready",function(){p(r,o)});return}if(l[u]===e)l[u]=null;if(r){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,f.offset,f.length,e.remoteAddress+":"+e.remotePort,r.message);i.storage.cancelBlock(t,f.offset);n.nextTick(i._update.bind(i));return false}else{a("got piece %s (offset: %s length: %s) from %s",t,f.offset,f.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,f.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,f.offset)}n.nextTick(i._update.bind(i))})}}e.request(t,f.offset,f.length,p);return true};I.prototype.createServer=function(e){var t=this;if(typeof y==="function"){return new y(t,e)}};I.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function j(e,t){return Math.ceil(2+t*e.downloadSpeed()/w.BLOCK_LENGTH)}function L(e){return Math.random()*e|0}function R(e,t){var n=e.map(function(e,t){return t});for(var r=n.length-1;r>0;--r){var i=L(r+1);var o=n[r];n[r]=n[i];n[i]=o}n.forEach(function(n){t(e[n],n,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":4,"./server":5,"./storage":6,_process:29,"addr-to-ip-port":9,"bittorrent-swarm":19,"create-torrent":34,debug:35,events:40,inherits:49,"parse-torrent":61,"re-emitter":69,"run-parallel":80,"torrent-discovery":90,uniq:92,ut_metadata:94,ut_pex:27}],8:[function(e,t,n){(function(){var e=typeof n!="undefined"?n:this;var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function r(e){this.message=e}r.prototype=new Error;r.prototype.name="InvalidCharacterError";e.btoa||(e.btoa=function(e){for(var n,i,o=0,a=t,s="";e.charAt(o|0)||(a="=",o%1);s+=a.charAt(63&n>>8-o%1*8)){i=e.charCodeAt(o+=3/4);if(i>255){throw new r("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")}n=n<<8|i}return s});e.atob||(e.atob=function(e){e=e.replace(/=+$/,"");if(e.length%4==1){throw new r("'atob' failed: The string to be decoded is not correctly encoded.")}for(var n=0,i,o,a=0,s="";o=e.charAt(a++);~o&&(i=n%4?i*64+o:o,n++%4)?s+=String.fromCharCode(255&i>>(-2*n&6)):0){o=t.indexOf(o)}return s})})()},{}],9:[function(e,t,n){var r=/^\[?([^\]]+)\]?:(\d+)$/;
-var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=r.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={}}},{}],10:[function(e,t,n){"use strict";var r=e("./raw");var i=[];var o=[];var a=r.makeRequestCallFromTimer(s);function s(){if(o.length){throw o.shift()}}t.exports=c;function c(e){var t;if(i.length){t=i.pop()}else{t=new f}t.task=e;r(t)}function f(){this.task=null}f.prototype.call=function(){try{this.task.call()}catch(e){if(c.onerror){c.onerror(e)}else{o.push(e);a()}}finally{this.task=null;i[i.length]=this}}},{"./raw":11}],11:[function(e,t,n){(function(e){"use strict";t.exports=n;function n(e){if(!r.length){o();i=true}r[r.length]=e}var r=[];var i=false;var o;var a=0;var s=1024;function c(){while(a<r.length){var e=a;a=a+1;r[e].call();if(a>s){for(var t=0,n=r.length-a;t<n;t++){r[t]=r[t+a]}r.length-=a;a=0}}r.length=0;a=0;i=false}var f=e.MutationObserver||e.WebKitMutationObserver;if(typeof f==="function"){o=l(c)}else{o=u(c)}n.requestFlush=o;function l(e){var t=1;var n=new f(e);var r=document.createTextNode("");n.observe(r,{characterData:true});return function i(){t=-t;r.data=t}}function u(e){return function t(){var t=setTimeout(r,0);var n=setInterval(r,50);function r(){clearTimeout(t);clearInterval(n);e()}}}n.makeRequestCallFromTimer=u}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],12:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var n="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var c="-".charCodeAt(0);var f="_".charCodeAt(0);function l(e){var t=e.charCodeAt(0);if(t===n||t===c)return 62;if(t===i||t===f)return 63;if(t<o)return-1;if(t<o+10)return t-o+26+26;if(t<s+26)return t-s;if(t<a+26)return t-a+26}function u(e){var n,r,i,o,a,s;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var c=e.length;a="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var f=0;function u(e){s[f++]=e}for(n=0,r=0;n<i;n+=4,r+=3){o=l(e.charAt(n))<<18|l(e.charAt(n+1))<<12|l(e.charAt(n+2))<<6|l(e.charAt(n+3));u((o&16711680)>>16);u((o&65280)>>8);u(o&255)}if(a===2){o=l(e.charAt(n))<<2|l(e.charAt(n+1))>>4;u(o&255)}else if(a===1){o=l(e.charAt(n))<<10|l(e.charAt(n+1))<<4|l(e.charAt(n+2))>>2;u(o>>8&255);u(o&255)}return s}function p(e){var t,n=e.length%3,i="",o,a;function s(e){return r.charAt(e)}function c(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-n;t<a;t+=3){o=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=c(o)}switch(n){case 1:o=e[e.length-1];i+=s(o>>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=u;e.fromByteArray=p})(typeof n==="undefined"?this.base64js={}:n)},{}],13:[function(e,t,n){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":14,"./lib/encode":16}],14:[function(e,t,n){(function(n){var r=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!n.isBuffer(e)?new n(e):e;return i.next()}i.position=0;i.data=null;i.encoding=null;i.next=function(){switch(i.data[i.position]){case 100:return i.dictionary();break;case 108:return i.list();break;case 105:return i.integer();break;default:return i.bytes();break}};i.find=function(e){var t=i.position;var n=i.data.length;var r=i.data;while(t<n){if(r[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};i.dictionary=function(){i.position++;var e=new r;while(i.data[i.position]!==101){e.binarySet(i.bytes(),i.next())}i.position++;return e};i.list=function(){i.position++;var e=[];while(i.data[i.position]!==101){e.push(i.next())}i.position++;return e};i.integer=function(){var e=i.find(101);var t=i.data.toString("ascii",i.position+1,e);i.position+=e+1-i.position;return parseInt(t,10)};i.bytes=function(){var e=i.find(58);var t=parseInt(i.data.toString("ascii",i.position,e),10);var n=++e+t;i.position=n;return i.encoding?i.data.toString(i.encoding,e,n):i.data.slice(e,n)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":15,buffer:31}],15:[function(e,t,n){var r=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};r.prototype.binaryKeys=function o(){return this._keys.slice()};r.prototype.binarySet=function a(e,t){this._keys.push(e);this[e]=t}},{}],16:[function(e,t,n){(function(e){function n(t){var r=[];n._encode(r,t);return e.concat(r)}n._floatConversionDetected=false;n._encode=function(t,r){if(e.isBuffer(r)){t.push(new e(r.length+":"));t.push(r);return}switch(typeof r){case"string":n.bytes(t,r);break;case"number":n.number(t,r);break;case"object":r.constructor===Array?n.list(t,r):n.dict(t,r);break}};var r=new e("e"),i=new e("d"),o=new e("l");n.bytes=function(t,n){t.push(new e(e.byteLength(n)+":"+n))};n.number=function(t,r){var i=2147483648;var o=r/i<<0;var a=r%i<<0;var s=o*i+a;t.push(new e("i"+s+"e"));if(s!==r&&!n._floatConversionDetected){n._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+r+'":','Bencoding only defines support for integers, value was converted to "'+s+'"');console.trace()}};n.dict=function(e,t){e.push(i);var o=0;var a;var s=Object.keys(t).sort();var c=s.length;for(;o<c;o++){a=s[o];n.bytes(e,a);n._encode(e,t[a])}e.push(r)};n.list=function(e,t){var i=0,a=1;var s=t.length;e.push(o);for(;i<s;i++){n._encode(e,t[i])}e.push(r)};t.exports=n}).call(this,e("buffer").Buffer)},{buffer:31}],17:[function(e,t,n){(function(e){var n=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var n=0;n<e;n++)t[n]=0};function r(e,t){if(!(this instanceof r)){return new r(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&i(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new n(i(e));if(e.fill)e.fill(0)}this.buffer=e}function i(e){var t=e>>3;if(e%8!==0)t++;return t}r.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};r.prototype.set=function(e,t){var n=e>>3;if(t||arguments.length===1){if(this.buffer.length<n+1)this._grow(Math.max(n+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[n]|=128>>e%8}else if(n<this.buffer.length){this.buffer[n]&=~(128>>e%8)}};r.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new n(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var r=0;r<this.buffer.length;r++){t[r]=this.buffer[r]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=r}).call(this,e("buffer").Buffer)},{buffer:31}],18:[function(e,t,n){(function(n){t.exports=b;var r=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var c=e("speedometer");var f=e("stream");var l=4e5;var u=new n("BitTorrent protocol");var p=new n([0,0,0,0]);var d=new n([0,0,0,1,0]);var h=new n([0,0,0,1,1]);var v=new n([0,0,0,1,2]);var m=new n([0,0,0,1,3]);var g=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function w(e,t,n,r){this.piece=e;this.offset=t;this.length=n;this.callback=r}s(b,f.Duplex);function b(){if(!(this instanceof b))return new b;f.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new r(0,{grow:l});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=c();this.downloadSpeed=c();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()}b.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,p),6e4)};b.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};b.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};b.prototype.end=function(){this._onUninterested();this._onChoke();f.Duplex.prototype.end.apply(this,arguments)};b.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 n=this._nextExt;var r=new e(this);function i(){}if(typeof r.onHandshake!=="function"){r.onHandshake=i}if(typeof r.onExtendedHandshake!=="function"){r.onExtendedHandshake=i}if(typeof r.onMessage!=="function"){r.onMessage=i}this.extendedMapping[n]=t;this._ext[t]=r;this[t]=r;this._nextExt+=1};b.prototype.handshake=function(e,t,r){if(typeof e==="string")e=new n(e,"hex");if(typeof t==="string")t=new n(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new n(g);i[5]|=16;if(r&&r.dht)i[7]|=1;this._push(n.concat([u,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};b.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,i.encode(e))};b.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};b.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(h)};b.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(v)};b.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};b.prototype.have=function(e){this._message(4,[e],null)};b.prototype.bitfield=function(e){if(!n.isBuffer(e))e=e.buffer;this._message(5,[],e)};b.prototype.request=function(e,t,n,r){if(!r)r=function(){};if(this._finished)return r(new Error("wire is closed"));if(this.peerChoking)return r(new Error("peer is choking"));this.requests.push(new w(e,t,n,r));this._updateTimeout();this._message(6,[e,t,n],null)};b.prototype.piece=function(e,t,n){this.uploaded+=n.length;this.uploadSpeed(n.length);this.emit("upload",n.length);this._message(7,[e,t],n)};b.prototype.cancel=function(e,t,n){this._callback(_(this.requests,e,t,n),new Error("request was cancelled"),null);this._message(8,[e,t,n],null)};b.prototype.port=function(e){var t=new n(y);t.writeUInt16BE(e,5);this._push(t)};b.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var r=new n([e]);var o=n.isBuffer(t)?t:i.encode(t);this._message(20,[],n.concat([r,o]))}else{throw new Error("Unrecognized extension: "+e)}};b.prototype._onKeepAlive=function(){this.emit("keep-alive")};b.prototype._onHandshake=function(e,t,n){this.peerId=t;this.peerExtensions=n;this.emit("handshake",e,t,n);var r;for(r in this._ext){this._ext[r].onHandshake(e,t,n)}if(n.extended&&this._handshakeSent){this._sendExtendedHandshake()}};b.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};b.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};b.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};b.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};b.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};b.prototype._onBitField=function(e){this.peerPieces=new r(e);this.emit("bitfield",this.peerPieces)};b.prototype._onRequest=function(e,t,n){if(this.amChoking)return;var r=function(r,o){if(i!==_(this.peerRequests,e,t,n))return;if(r)return;this.piece(e,t,o)}.bind(this);var i=new w(e,t,n,r);this.peerRequests.push(i);this.emit("request",e,t,n,r)};b.prototype._onPiece=function(e,t,n){this._callback(_(this.requests,e,t,n.length),null,n);this.downloaded+=n.length;this.downloadSpeed(n.length);this.emit("download",n.length);this.emit("piece",e,t,n)};b.prototype._onCancel=function(e,t,n){_(this.peerRequests,e,t,n);this.emit("cancel",e,t,n)};b.prototype._onPort=function(e){this.emit("port",e)};b.prototype._onExtended=function(e,t){var n,r;if(e===0&&(n=x(t))){this.peerExtendedHandshake=n;if(typeof n.m==="object"){for(r in n.m){this.peerExtendedMapping[r]=Number(n.m[r].toString())}}for(r in this._ext){if(this.peerExtendedMapping[r]){this._ext[r].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)}};b.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};b.prototype._push=function(e){if(this._finished)return;return this.push(e)};b.prototype._write=function(e,t,r){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}r(null)};b.prototype._read=function(){};b.prototype._callback=function(e,t,n){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,n)};b.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};b.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()};b.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};b.prototype._message=function(e,t,r){var i=r?r.length:0;var o=new n(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a<t.length;a++){o.writeUInt32BE(t[a],5+4*a)}this._push(o);if(r)this._push(r)};b.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);if(t>0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};b.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)}};b.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var n=e.slice(0,t);if(n.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",n.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))};b.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 _(e,t,n,r){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==n||o.length!==r)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}function x(e){try{return i.decode(e)}catch(t){console.warn(t)}}}).call(this,e("buffer").Buffer)},{bencode:13,bitfield:17,buffer:31,debug:35,inherits:49,speedometer:85,stream:86,xtend:98}],19:[function(e,t,n){(function(n,r){t.exports=v;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var a=e("dezalgo");var s=e("events").EventEmitter;var c=e("inherits");var f=e("net");var l=e("./lib/peer");var u=e("speedometer");var p=e("./lib/tcp-pool");var d=55;var h=[1e3,5e3,15e3];c(v,s);function v(e,t,n){var i=this;if(!(i instanceof v))return new v(e,t,n);s.call(i);i.infoHash=typeof e==="string"?new r(e,"hex"):e;i.infoHashHex=i.infoHash.toString("hex");i.peerId=typeof t==="string"?new r(t,"hex"):t;i.peerIdHex=i.peerId.toString("hex");if(!n)n={};o("new swarm (i %s p %s)",i.infoHashHex,i.peerIdHex);i.handshakeOpts=n.handshake;i.maxConns=n.maxConns!==undefined?n.maxConns:d;i.destroyed=false;i.listening=false;i.paused=false;i.server=null;i.wires=[];i._queue=[];i._peers={};i._peersLength=0;i._port=0;i.downloaded=0;i.uploaded=0;i.downloadSpeed=u();i.uploadSpeed=u()}Object.defineProperty(v.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(v.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(v.prototype,"numConns",{get:function(){var e=this;var t=0;for(var n in e._peers){var r=e._peers[n];if(r&&r.conn)t+=1}return t}});Object.defineProperty(v.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});v.prototype.addPeer=function(e){var t=this;if(t.destroyed){if(e&&e.destroy)e.destroy(new Error("swarm already destroyed"));return}if(typeof e==="string"&&!t._validAddr(e)){o("ignoring invalid peer %s (from swarm.addPeer)",e);return}var n=e&&e.id||e;if(t._peers[n])return;o("addPeer %s",n);var r;if(typeof e==="string"){r=l.createOutgoingTCPPeer(e,t);t._queue.push(r);t._drain()}else{r=l.createWebRTCPeer(e,t)}t._peers[r.id]=r;t._peersLength+=1};v.prototype._addIncomingPeer=function(e){var t=this;if(t.destroyed)return e.destroy(new Error("swarm already destroyed"));if(t.paused)return e.destroy(new Error("swarm paused"));if(!t._validAddr(e.addr)){return e.destroy(new Error("invalid addr "+e.addr+" (from incoming)"))}o("_addIncomingPeer %s",e.id);t._peers[e.id]=e;t._peersLength+=1};v.prototype.removePeer=function(e){var t=this;var n=t._peers[e];if(!n)return;o("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;n.destroy()};v.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};v.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};v.prototype.listen=function(e,t,r){var i=this;if(typeof t==="function"){r=t;t=undefined}if(r)r=a(r);if(i.listening)throw new Error("swarm already listening");if(n.browser){r()}else{i._port=e||p.getDefaultListenPort(i.infoHashHex);i._hostname=t;if(r)i.once("listening",r);o("listen %s",e);var s=p.addSwarm(i);i.server=s.server}};v.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};v.prototype.address=function(){var e=this;return e.server.address()};v.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t.listening=false;t.paused=false;if(e)t.once("close",e);o("destroy");for(var n in t._peers){t.removePeer(n)}p.removeSwarm(t,function(){t.emit("close")})};v.prototype._drain=function(){var e=this;o("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof f.connect!=="function"||e.destroyed||e.paused||e.numConns>=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 n=i(t.addr);var r=n[0];var a=n[1];var s=t.conn=f.connect({host:r,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>=h.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,h.length);return}function n(){var n=l.createOutgoingTCPPeer(t.addr,e);n.retries=t.retries+1;e._queue.push(n);e._drain()}var r=h[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var i=setTimeout(n,r);if(i.unref)i.unref()})};v.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};v.prototype._validAddr=function(e){var t=this;var n=i(e);var r=n[0];var o=n[1];return o>0&&o<65535&&!(r==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":20,"./lib/tcp-pool":21,_process:29,"addr-to-ip-port":27,buffer:31,debug:35,dezalgo:38,events:40,inherits:49,net:27,speedometer:85}],20:[function(e,t,n){var r=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;n.createWebRTCPeer=function(e,t){var n=new s(e.id);n.conn=e;n.swarm=t;if(n.conn.connected){n.onConnect()}else{n.conn.once("connect",function(){n.onConnect()});n.conn.once("error",function(e){n.destroy(e)});n.setConnectTimeout()}return n};n.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var n=new s(t);n.conn=e;n.addr=t;n.onConnect();return n};n.createOutgoingTCPPeer=function(e,t){var n=new s(e);n.swarm=t;n.addr=e;return n};function s(e){var t=this;t.id=e;r("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;if(e.destroyed)return;r("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 n=e.wire=new i;n.once("end",function(){e.destroy()});n.once("finish",function(){e.destroy()});n.once("error",function(t){e.destroy(t)});n.once("handshake",function(t,n){e.onHandshake(t,n)});e.setHandshakeTimeout();t.pipe(n).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var n=this;if(!n.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(n.swarm.destroyed)return n.destroy(new Error("swarm already destroyed"));if(i!==n.swarm.infoHashHex){return n.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===n.swarm.peerIdHex){return n.destroy(new Error("refusing to handshake with self"))}r("Peer %s got handshake %s",n.id,i);clearTimeout(n.handshakeTimeout);n.retries=0;n.wire.on("download",function(e){n.swarm.downloaded+=e;n.swarm.downloadSpeed(e);n.swarm.emit("download",e)});n.wire.on("upload",function(e){n.swarm.uploaded+=e;n.swarm.uploadSpeed(e);n.swarm.emit("upload",e)});if(!n.sentHandshake)n.handshake();n.swarm.wires.push(n.wire);var a=n.addr;if(!a&&n.conn.remoteAddress){a=n.conn.remoteAddress+":"+n.conn.remotePort}n.swarm.emit("wire",n.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;r("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));if(t.swarm)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":18,debug:35}],21:[function(e,t,n){(function(n){t.exports=c;var r=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function c(e,t){var n=this;n.port=e;n.listening=false;n.swarms={};r("new TCPPool (port: %s, hostname: %s)",e,t);n.pendingConns=[];n.server=o.createServer();n.server.on("connection",function(e){n._onConnection(e)});n.server.on("error",function(e){n._onError(e)});n.server.on("listening",function(){n._onListening()});n.server.listen(n.port,t)}c.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new c(e._port,e._hostname);t.addSwarm(e);return t};c.removeSwarm=function(e,t){var r=s[e._port];if(!r)return t();r.removeSwarm(e);var i=0;for(var o in r.swarms){var a=r.swarms[o];if(a)i+=1}if(i===0)r.destroy(t);else n.nextTick(t)};c.getDefaultListenPort=function(e){for(var t in s){var n=s[t];if(n&&!n.swarms[e])return n.port}return 0};c.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){n.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){n.nextTick(function(){e._onListening(t.port)})}r("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};c.prototype.removeSwarm=function(e){var t=this;r("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};c.prototype.destroy=function(e){var t=this;if(e)e=i(e);r("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(n){if(e)e(null)}};c.prototype._onListening=function(){var e=this;var t=e.server.address().port;r("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 n in e.swarms){var i=e.swarms[n];if(i)i._onListening(e.port)}};c.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",n);function n(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var r=a.createIncomingTCPPeer(e);r.wire.once("handshake",function(i,o){var a=i.toString("hex");n();e.removeListener("close",n);var s=t.swarms[a];if(s){r.swarm=s;s._addIncomingPeer(r);r.onHandshake(i,o)}else{var c=new Error("Unexpected info hash "+a+" from incoming peer "+r.id+": destroying peer");r.destroy(c)}})};c.prototype._onError=function(e){var t=this;t.destroy();for(var n in t.swarms){var r=t.swarms[n];if(r){t.removeSwarm(r);r._onError(e)}}}}).call(this,e("_process"))},{"./peer":20,_process:29,debug:35,dezalgo:38,net:27}],22:[function(e,t,n){(function(n,r){t.exports=d;var i=e("debug")("bittorrent-tracker");var o=e("events").EventEmitter;var a=e("inherits");var s=e("once");var c=e("url");var f=e("./lib/common");var l=e("./lib/http-tracker");var u=e("./lib/udp-tracker");var p=e("./lib/websocket-tracker");a(d,o);function d(e,t,a,s){var h=this;if(!(h instanceof d))return new d(e,t,a,s);o.call(h);if(!s)s={};h._peerId=r.isBuffer(e)?e:new r(e,"hex");h._peerIdHex=h._peerId.toString("hex");h._peerIdBinary=h._peerId.toString("binary");h._infoHash=r.isBuffer(a.infoHash)?a.infoHash:new r(a.infoHash,"hex");h._infoHashHex=h._infoHash.toString("hex");h._infoHashBinary=h._infoHash.toString("binary");h._port=t;h.torrentLength=a.length;h._rtcConfig=s.rtcConfig;h._wrtc=s.wrtc;h._numWant=s.numWant||f.DEFAULT_ANNOUNCE_PEERS;h._intervalMs=s.interval||f.DEFAULT_ANNOUNCE_INTERVAL;i("new client %s",h._infoHashHex);var v={interval:h._intervalMs};var m=!!h._wrtc||typeof window!=="undefined";var g=typeof a.announce==="string"?[a.announce]:a.announce==null?[]:a.announce;h._trackers=g.map(function(e){e=e.toString();var t=c.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof l==="function"){return new l(h,e,v)}else if(t==="udp:"&&typeof u==="function"){return new u(h,e,v)}else if((t==="ws:"||t==="wss:")&&m){return new p(h,e,v)}else{n.nextTick(function(){var t=new Error("unsupported tracker protocol for "+e);h.emit("warning",t)})}return null}).filter(Boolean)}d.scrape=function(e,t,n){n=s(n);var i=new r("01234567890123456789");var o=6881;var a={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var c=new d(i,o,a);c.once("error",n);var f=Array.isArray(t)?t.length:1;var l={};c.on("scrape",function(e){f-=1;l[e.infoHash]=e;if(f===0){c.destroy();var t=Object.keys(l);if(t.length===1){n(null,l[t[0]])}else{n(null,l)}}});t=Array.isArray(t)?t.map(function(e){return new r(e,"hex")}):new r(t,"hex");c.scrape({infoHash:t})};d.prototype.start=function(e){var t=this;i("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval(t._intervalMs)})};d.prototype.stop=function(e){var t=this;i("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};d.prototype.complete=function(e){var t=this;i("send `complete`");if(!e)e={};if(e.downloaded==null&&t.torrentLength!=null){e.downloaded=t.torrentLength}e=t._defaultAnnounceOpts(e);e.event="completed";t._announce(e)};d.prototype.update=function(e){var t=this;i("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};d.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};d.prototype.scrape=function(e){var t=this;i("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};d.prototype.setInterval=function(e){var t=this;i("setInterval");t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};d.prototype.destroy=function(){var e=this;i("destroy");e._trackers.forEach(function(e){e.destroy();e.setInterval(0)});e._trackers=[]};d.prototype._defaultAnnounceOpts=function(e){var t=this;if(!e)e={};if(e.numWant==null)e.numWant=t._numWant;if(e.uploaded==null)e.uploaded=0;if(e.downloaded==null)e.downloaded=0;if(e.left==null&&t.torrentLength!=null){e.left=t.torrentLength-e.downloaded}return e}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/common":24,"./lib/http-tracker":27,"./lib/udp-tracker":27,"./lib/websocket-tracker":25,_process:29,buffer:31,debug:35,events:40,inherits:49,once:59,url:93}],23:[function(e,t,n){(function(t){var r=e("querystring");n.IPV4_RE=/^[\d\.]+$/;n.IPV6_RE=/^[\da-fA-F:]+$/;n.CONNECTION_ID=t.concat([i(1047),i(655366528)]);n.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};n.EVENTS={update:0,completed:1,started:2,stopped:3};n.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};n.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function i(e){var n=new t(4);n.writeUInt32BE(e,0);return n}n.toUInt32=i;n.querystringParse=function(e){var t=r.unescape;r.unescape=unescape;var n=r.parse(e);r.unescape=t;return n};n.querystringStringify=function(e){var t=r.escape;r.escape=escape;var n=r.stringify(e);n=n.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});r.escape=t;return n}}).call(this,e("buffer").Buffer)},{buffer:31,querystring:67}],24:[function(e,t,n){(function(t){var r=e("xtend/mutable");n.DEFAULT_ANNOUNCE_INTERVAL=30*60*1e3;n.DEFAULT_ANNOUNCE_PEERS=50;n.MAX_ANNOUNCE_PEERS=82;n.binaryToHex=function(e){return new t(e,"binary").toString("hex")};n.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");r(n,i)}).call(this,e("buffer").Buffer)},{"./common-node":23,buffer:31,"xtend/mutable":99}],25:[function(e,t,n){t.exports=d;var r=e("debug")("bittorrent-tracker:websocket-tracker");var i=e("events").EventEmitter;var o=e("hat");var a=e("inherits");var s=e("simple-peer");var c=e("simple-websocket");var f=e("./common");var l={};var u=30*1e3;var p=5*1e3;a(d,i);function d(e,t,n){var o=this;i.call(o);r("new websocket tracker %s",t);o.client=e;o.destroyed=false;o._opts=n;if(t[t.length-1]==="/"){t=t.substring(0,t.length-1)}o._announceUrl=t;o._peers={};o._socket=null;o._intervalMs=o.client._intervalMs;o._interval=null;o._openSocket()}d.prototype.announce=function(e){var t=this;if(t.destroyed)return;
-if(!t._socket.connected){return t._socket.once("connect",t.announce.bind(t,e))}e.info_hash=t.client._infoHashBinary;e.peer_id=t.client._peerIdBinary;if(e.numWant>10)e.numWant=10;t._generateOffers(e.numWant,function(n){e.offers=n;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};d.prototype.scrape=function(e){var t=this;if(t.destroyed)return;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};d.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var n=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(n,t._intervalMs)}};d.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",h);try{e._socket.close()}catch(t){}e._socket=null};d.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=l[e._announceUrl];if(!e._socket){e._socket=l[e._announceUrl]=new c(e._announceUrl)}e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};d.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){r("ignoring websocket data from %s for %s (looking for %s: reused socket)",t._announceUrl,f.binaryToHex(e.info_hash),t.client._infoHashHex);return}if(e.peer_id&&e.peer_id===t.client._peerIdBinary){return}r("received %s from %s for %s",JSON.stringify(e),t._announceUrl,t.client._infoHashHex);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));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})}var c;if(e.offer&&e.peer_id){c=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});c.id=f.binaryToHex(e.peer_id);c.once("signal",function(n){var r={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};if(t._trackerId)r.trackerid=t._trackerId;t._send(r)});c.signal(e.offer);t.client.emit("peer",c)}if(e.answer&&e.peer_id){c=t._peers[f.binaryToHex(e.offer_id)];if(c){c.id=f.binaryToHex(e.peer_id);c.signal(e.answer);t.client.emit("peer",c)}else{r("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._onSocketClose=function(){var e=this;if(e.destroyed)return;e.destroy();e._startReconnectTimer()};d.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.destroy();t.client.emit("warning",e);t._startReconnectTimer()};d.prototype._startReconnectTimer=function(){var e=this;var t=Math.floor(Math.random()*u)+p;setTimeout(function(){e.destroyed=false;e._openSocket()},t);r("reconnecting socket in %s ms",t)};d.prototype._send=function(e){var t=this;if(t.destroyed)return;var n=JSON.stringify(e);r("send %s",n);t._socket.send(n)};d.prototype._generateOffers=function(e,t){var n=this;var i=[];r("generating %s offers",e);for(var a=0;a<e;++a){c()}function c(){var e=o(160);var t=n._peers[e]=new s({initiator:true,trickle:false,config:n.client._rtcConfig,wrtc:n.client._wrtc});t.once("signal",function(t){i.push({offer:t,offer_id:f.hexToBinary(e)});l()})}function l(){if(i.length===e){r("generated %s offers",e);t(i)}}};function h(){}},{"./common":24,debug:35,events:40,hat:44,inherits:49,"simple-peer":82,"simple-websocket":84}],26:[function(e,t,n){(function(n){var r=e("inherits");var i=e("readable-stream").Transform;var o=e("defined");t.exports=a;r(a,i);function a(e,t){if(!(this instanceof a))return new a(e,t);i.call(this);if(!t)t={};if(typeof e==="object"){t=e;e=t.size}this.size=e||512;if(t.nopad)this._zeroPadding=false;else this._zeroPadding=o(t.zeroPadding,true);this._buffered=[];this._bufferedBytes=0}a.prototype._transform=function(e,t,r){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var i=n.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}r()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(n.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(n.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:31,defined:37,inherits:49,"readable-stream":77}],27:[function(e,t,n){},{}],28:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{dup:27}],29:[function(e,t,n){var r=t.exports={};var i=[];var o=false;var a;var s=-1;function c(){o=false;if(a.length){i=a.concat(i)}else{s=-1}if(i.length){f()}}function f(){if(o){return}var e=setTimeout(c);o=true;var t=i.length;while(t){a=i;i=[];while(++s<t){a[s].run()}s=-1;t=i.length}a=null;o=false;clearTimeout(e)}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}}i.push(new l(e,t));if(i.length===1&&!o){setTimeout(f,0)}};function l(e,t){this.fun=e;this.array=t}l.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function u(){}r.on=u;r.addListener=u;r.once=u;r.off=u;r.removeListener=u;r.removeAllListeners=u;r.emit=u;r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")};r.umask=function(){return 0}},{}],30:[function(t,n,r){(function(t){(function(i){var o=typeof r=="object"&&r&&!r.nodeType&&r;var a=typeof n=="object"&&n&&!n.nodeType&&n;var s=typeof t=="object"&&t;if(s.global===s||s.window===s||s.self===s){i=s}var c,f=2147483647,l=36,u=1,p=26,d=38,h=700,v=72,m=128,g="-",y=/^xn--/,w=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-u,k=Math.floor,E=String.fromCharCode,S;function A(e){throw RangeError(_[e])}function T(e,t){var n=e.length;var r=[];while(n--){r[n]=t(e[n])}return r}function C(e,t){var n=e.split("@");var r="";if(n.length>1){r=n[0]+"@";e=n[1]}e=e.replace(b,".");var i=e.split(".");var o=T(i,t).join(".");return r+o}function I(e){var t=[],n=0,r=e.length,i,o;while(n<r){i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){o=e.charCodeAt(n++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);n--}}else{t.push(i)}}return t}function j(e){return T(e,function(e){var t="";if(e>65535){e-=65536;t+=E(e>>>10&1023|55296);e=56320|e&1023}t+=E(e);return t}).join("")}function L(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return l}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function B(e,t,n){var r=0;e=n?k(e/h):e>>1;e+=k(e/t);for(;e>x*p>>1;r+=l){e=k(e/x)}return k(r+(x+1)*e/(e+d))}function P(e){var t=[],n=e.length,r,i=0,o=m,a=v,s,c,d,h,y,w,b,_,x;s=e.lastIndexOf(g);if(s<0){s=0}for(c=0;c<s;++c){if(e.charCodeAt(c)>=128){A("not-basic")}t.push(e.charCodeAt(c))}for(d=s>0?s+1:0;d<n;){for(h=i,y=1,w=l;;w+=l){if(d>=n){A("invalid-input")}b=L(e.charCodeAt(d++));if(b>=l||b>k((f-i)/y)){A("overflow")}i+=b*y;_=w<=a?u:w>=a+p?p:w-a;if(b<_){break}x=l-_;if(y>k(f/x)){A("overflow")}y*=x}r=t.length+1;a=B(i-h,r,h==0);if(k(i/r)>f-o){A("overflow")}o+=k(i/r);i%=r;t.splice(i++,0,o)}return j(t)}function O(e){var t,n,r,i,o,a,s,c,d,h,y,w=[],b,_,x,S;e=I(e);b=e.length;t=m;n=0;o=v;for(a=0;a<b;++a){y=e[a];if(y<128){w.push(E(y))}}r=i=w.length;if(i){w.push(g)}while(r<b){for(s=f,a=0;a<b;++a){y=e[a];if(y>=t&&y<s){s=y}}_=r+1;if(s-t>k((f-n)/_)){A("overflow")}n+=(s-t)*_;t=s;for(a=0;a<b;++a){y=e[a];if(y<t&&++n>f){A("overflow")}if(y==t){for(c=n,d=l;;d+=l){h=d<=o?u:d>=o+p?p:d-o;if(c<h){break}S=c-h;x=l-h;w.push(E(R(h+S%x,0)));c=k(S/x)}w.push(E(R(c,0)));o=B(n,_,r==i);n=0;++r}}++n;++t}return w.join("")}function M(e){return C(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function U(e){return C(e,function(e){return w.test(e)?"xn--"+O(e):e})}c={version:"1.3.2",ucs2:{decode:I,encode:j},decode:P,encode:O,toASCII:U,toUnicode:M};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return c})}else if(o&&a){if(n.exports==o){a.exports=c}else{for(S in c){c.hasOwnProperty(S)&&(o[S]=c[S])}}}else{i.punycode=c}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],31:[function(e,t,n){var r=e("base64-js");var i=e("ieee754");var o=e("is-array");n.Buffer=c;n.SlowBuffer=w;n.INSPECT_MAX_BYTES=50;c.poolSize=8192;var a=1073741823;var s={};c.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(n){return false}}();function c(e){if(!(this instanceof c)){if(arguments.length>1)return new c(e,arguments[1]);return new c(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return f(this,e)}if(typeof e==="string"){return l(this,e,arguments.length>1?arguments[1]:"utf8")}return u(this,e)}function f(e,t){e=g(e,t<0?0:y(t)|0);if(!c.TYPED_ARRAY_SUPPORT){for(var n=0;n<t;n++){e[n]=0}}return e}function l(e,t,n){if(typeof n!=="string"||n==="")n="utf8";var r=b(t,n)|0;e=g(e,r);e.write(t,n);return e}function u(e,t){if(c.isBuffer(t))return p(e,t);if(o(t))return d(e,t);if(t==null){throw new TypeError("must start with number, buffer, array or string")}if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer){return h(e,t)}if(t.length)return v(e,t);return m(e,t)}function p(e,t){var n=y(t.length)|0;e=g(e,n);t.copy(e,0,0,n);return e}function d(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function h(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function v(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function m(e,t){var n;var r=0;if(t.type==="Buffer"&&o(t.data)){n=t.data;r=y(n.length)|0}e=g(e,r);for(var i=0;i<r;i+=1){e[i]=n[i]&255}return e}function g(e,t){if(c.TYPED_ARRAY_SUPPORT){e=c._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var n=t!==0&&t<=c.poolSize>>>1;if(n)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 w(e,t){if(!(this instanceof w))return new w(e,t);var n=new c(e,t);delete n.parent;return n}c.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};c.compare=function Z(e,t){if(!c.isBuffer(e)||!c.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var n=e.length;var r=t.length;var i=0;var o=Math.min(n,r);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){n=e[i];r=t[i]}if(n<r)return-1;if(r<n)return 1;return 0};c.isEncoding=function Q(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};c.concat=function ee(e,t){if(!o(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new c(0)}else if(e.length===1){return e[0]}var n;if(t===undefined){t=0;for(n=0;n<e.length;n++){t+=e[n].length}}var r=new c(t);var i=0;for(n=0;n<e.length;n++){var a=e[n];a.copy(r,i);i+=a.length}return r};function b(e,t){if(typeof e!=="string")e=String(e);if(e.length===0)return 0;switch(t||"utf8"){case"ascii":case"binary":case"raw":return e.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e.length*2;case"hex":return e.length>>>1;case"utf8":case"utf-8":return Y(e).length;case"base64":return V(e).length;default:return e.length}}c.byteLength=b;c.prototype.length=undefined;c.prototype.parent=undefined;c.prototype.toString=function te(e,t,n){var r=false;t=t|0;n=n===undefined||n===Infinity?this.length:n|0;if(!e)e="utf8";if(t<0)t=0;if(n>this.length)n=this.length;if(n<=t)return"";while(true){switch(e){case"hex":return L(this,t,n);case"utf8":case"utf-8":return C(this,t,n);case"ascii":return I(this,t,n);case"binary":return j(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();r=true}}};c.prototype.equals=function ne(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return c.compare(this,e)===0};c.prototype.inspect=function re(){var e="";var t=n.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};c.prototype.compare=function ie(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return c.compare(this,e)};c.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(c.isBuffer(e)){return n(this,e,t)}if(typeof e==="number"){if(c.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return n(this,[e],t)}function n(e,t,n){var r=-1;for(var i=0;n+i<e.length;i++){if(e[n+i]===t[r===-1?0:i-r]){if(r===-1)r=i;if(i-r+1===t.length)return n+r}else{r=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};c.prototype.get=function ae(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};c.prototype.set=function se(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function _(e,t,n,r){n=Number(n)||0;var i=e.length-n;if(!r){r=i}else{r=Number(r);if(r>i){r=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(r>o/2){r=o/2}for(var a=0;a<r;a++){var s=parseInt(t.substr(a*2,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[n+a]=s}return a}function x(e,t,n,r){return $(Y(t,e.length-n),e,n,r)}function k(e,t,n,r){return $(G(t),e,n,r)}function E(e,t,n,r){return k(e,t,n,r)}function S(e,t,n,r){return $(V(t),e,n,r)}function A(e,t,n,r){return $(J(t,e.length-n),e,n,r)}c.prototype.write=function ce(e,t,n,r){if(t===undefined){r="utf8";n=this.length;t=0}else if(n===undefined&&typeof t==="string"){r=t;n=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(n)){n=n|0;if(r===undefined)r="utf8"}else{r=n;n=undefined}}else{var i=r;r=t;t=n|0;n=i}var o=this.length-t;if(n===undefined||n>o)n=o;if(e.length>0&&(n<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!r)r="utf8";var a=false;for(;;){switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return x(this,e,t,n);case"ascii":return k(this,e,t,n);case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase();a=true}}};c.prototype.toJSON=function fe(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){if(t===0&&n===e.length){return r.fromByteArray(e)}else{return r.fromByteArray(e.slice(t,n))}}function C(e,t,n){var r="";var i="";n=Math.min(e.length,n);for(var o=t;o<n;o++){if(e[o]<=127){r+=K(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return r+K(i)}function I(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;i++){r+=String.fromCharCode(e[i]&127)}return r}function j(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;i++){r+=String.fromCharCode(e[i])}return r}function L(e,t,n){var r=e.length;if(!t||t<0)t=0;if(!n||n<0||n>r)n=r;var i="";for(var o=t;o<n;o++){i+=W(e[o])}return i}function R(e,t,n){var r=e.slice(t,n);var i="";for(var o=0;o<r.length;o+=2){i+=String.fromCharCode(r[o]+r[o+1]*256)}return i}c.prototype.slice=function le(e,t){var n=this.length;e=~~e;t=t===undefined?n:~~t;if(e<0){e+=n;if(e<0)e=0}else if(e>n){e=n}if(t<0){t+=n;if(t<0)t=0}else if(t>n){t=n}if(t<e)t=e;var r;if(c.TYPED_ARRAY_SUPPORT){r=c._augment(this.subarray(e,t))}else{var i=t-e;r=new c(i,undefined);for(var o=0;o<i;o++){r[o]=this[o+e]}}if(r.length)r.parent=this.parent||this;return r};function B(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function ue(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){r+=this[e+o]*i}return r};c.prototype.readUIntBE=function pe(e,t,n){e=e|0;t=t|0;if(!n){B(e,t,this.length)}var r=this[e+--t];var i=1;while(t>0&&(i*=256)){r+=this[e+--t]*i}return r};c.prototype.readUInt8=function de(e,t){if(!t)B(e,1,this.length);return this[e]};c.prototype.readUInt16LE=function he(e,t){if(!t)B(e,2,this.length);return this[e]|this[e+1]<<8};c.prototype.readUInt16BE=function ve(e,t){if(!t)B(e,2,this.length);return this[e]<<8|this[e+1]};c.prototype.readUInt32LE=function me(e,t){if(!t)B(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUInt32BE=function ge(e,t){if(!t)B(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readIntLE=function ye(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){r+=this[e+o]*i}i*=128;if(r>=i)r-=Math.pow(2,8*t);return r};c.prototype.readIntBE=function we(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=t;var i=1;var o=this[e+--r];while(r>0&&(i*=256)){o+=this[e+--r]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};c.prototype.readInt8=function be(e,t){if(!t)B(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};c.prototype.readInt16LE=function _e(e,t){if(!t)B(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function xe(e,t){if(!t)B(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function ke(e,t){if(!t)B(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function Ee(e,t){if(!t)B(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readFloatLE=function Se(e,t){if(!t)B(e,4,this.length);return i.read(this,e,true,23,4)};c.prototype.readFloatBE=function Ae(e,t){if(!t)B(e,4,this.length);return i.read(this,e,false,23,4)};c.prototype.readDoubleLE=function Te(e,t){if(!t)B(e,8,this.length);return i.read(this,e,true,52,8)};c.prototype.readDoubleBE=function Ce(e,t){if(!t)B(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range")}c.prototype.writeUIntLE=function Ie(e,t,n,r){e=+e;t=t|0;n=n|0;if(!r)P(this,e,t,n,Math.pow(2,8*n),0);var i=1;var o=0;this[t]=e&255;while(++o<n&&(i*=256)){this[t+o]=e/i&255}return t+n};c.prototype.writeUIntBE=function je(e,t,n,r){e=+e;t=t|0;n=n|0;if(!r)P(this,e,t,n,Math.pow(2,8*n),0);var i=n-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255}return t+n};c.prototype.writeUInt8=function Le(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,1,255,0);if(!c.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function O(e,t,n,r){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-n,2);i<o;i++){e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}}c.prototype.writeUInt16LE=function Re(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};c.prototype.writeUInt16BE=function Be(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};function M(e,t,n,r){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-n,4);i<o;i++){e[n+i]=t>>>(r?i:3-i)*8&255}}c.prototype.writeUInt32LE=function Pe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{M(this,e,t,true)}return t+4};c.prototype.writeUInt32BE=function Oe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};c.prototype.writeIntLE=function Me(e,t,n,r){e=+e;t=t|0;if(!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o<n&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+n};c.prototype.writeIntBE=function Ue(e,t,n,r){e=+e;t=t|0;if(!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=n-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+n};c.prototype.writeInt8=function ze(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,1,127,-128);if(!c.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};c.prototype.writeInt16LE=function He(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};c.prototype.writeInt16BE=function Ne(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};c.prototype.writeInt32LE=function qe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,2147483647,-2147483648);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{M(this,e,t,true)}return t+4};c.prototype.writeInt32BE=function De(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};function U(e,t,n,r,i,o){if(t>i||t<o)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(n<0)throw new RangeError("index out of range")}function z(e,t,n,r,o){if(!o){U(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,n,r,23,4);return n+4}c.prototype.writeFloatLE=function Fe(e,t,n){return z(this,e,t,true,n)};c.prototype.writeFloatBE=function We(e,t,n){return z(this,e,t,false,n)};function H(e,t,n,r,o){if(!o){U(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,n,r,52,8);return n+8}c.prototype.writeDoubleLE=function Ye(e,t,n){return H(this,e,t,true,n)};c.prototype.writeDoubleBE=function Ge(e,t,n){return H(this,e,t,false,n)};c.prototype.copy=function Je(e,t,n,r){if(!n)n=0;if(!r&&r!==0)r=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(r>0&&r<n)r=n;if(r===n)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");if(r>this.length)r=this.length;if(e.length-t<r-n){r=e.length-t+n}var i=r-n;if(i<1e3||!c.TYPED_ARRAY_SUPPORT){for(var o=0;o<i;o++){e[o+t]=this[o+n]}}else{e._set(this.subarray(n,n+i),t)}return i};c.prototype.fill=function Ve(e,t,n){if(!e)e=0;if(!t)t=0;if(!n)n=this.length;if(n<t)throw new RangeError("end < start");if(n===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(n<0||n>this.length)throw new RangeError("end out of bounds");var r;if(typeof e==="number"){for(r=t;r<n;r++){this[r]=e}}else{var i=Y(e.toString());var o=i.length;for(r=t;r<n;r++){this[r]=i[r%o]}}return this};c.prototype.toArrayBuffer=function $e(){if(typeof Uint8Array!=="undefined"){if(c.TYPED_ARRAY_SUPPORT){return new c(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,n=e.length;t<n;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var N=c.prototype;c._augment=function Ke(e){e.constructor=c;e._isBuffer=true;e._set=e.set;e.get=N.get;e.set=N.set;e.write=N.write;e.toString=N.toString;e.toLocaleString=N.toString;e.toJSON=N.toJSON;e.equals=N.equals;e.compare=N.compare;e.indexOf=N.indexOf;e.copy=N.copy;e.slice=N.slice;e.readUIntLE=N.readUIntLE;e.readUIntBE=N.readUIntBE;e.readUInt8=N.readUInt8;e.readUInt16LE=N.readUInt16LE;e.readUInt16BE=N.readUInt16BE;e.readUInt32LE=N.readUInt32LE;e.readUInt32BE=N.readUInt32BE;e.readIntLE=N.readIntLE;e.readIntBE=N.readIntBE;e.readInt8=N.readInt8;e.readInt16LE=N.readInt16LE;e.readInt16BE=N.readInt16BE;e.readInt32LE=N.readInt32LE;e.readInt32BE=N.readInt32BE;e.readFloatLE=N.readFloatLE;e.readFloatBE=N.readFloatBE;e.readDoubleLE=N.readDoubleLE;e.readDoubleBE=N.readDoubleBE;e.writeUInt8=N.writeUInt8;e.writeUIntLE=N.writeUIntLE;e.writeUIntBE=N.writeUIntBE;e.writeUInt16LE=N.writeUInt16LE;e.writeUInt16BE=N.writeUInt16BE;e.writeUInt32LE=N.writeUInt32LE;e.writeUInt32BE=N.writeUInt32BE;e.writeIntLE=N.writeIntLE;e.writeIntBE=N.writeIntBE;e.writeInt8=N.writeInt8;e.writeInt16LE=N.writeInt16LE;e.writeInt16BE=N.writeInt16BE;e.writeInt32LE=N.writeInt32LE;e.writeInt32BE=N.writeInt32BE;e.writeFloatLE=N.writeFloatLE;e.writeFloatBE=N.writeFloatBE;e.writeDoubleLE=N.writeDoubleLE;e.writeDoubleBE=N.writeDoubleBE;e.fill=N.fill;e.inspect=N.inspect;e.toArrayBuffer=N.toArrayBuffer;return e};var q=/[^+\/0-9A-z\-]/g;function D(e){e=F(e).replace(q,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function F(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function W(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function Y(e,t){t=t||Infinity;var n;var r=e.length;var i=null;var o=[];var a=0;for(;a<r;a++){n=e.charCodeAt(a);if(n>55295&&n<57344){if(i){if(n<56320){if((t-=3)>-1)o.push(239,191,189);i=n;continue}else{n=i-55296<<10|n-56320|65536;i=null}}else{if(n>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===r){if((t-=3)>-1)o.push(239,191,189);continue}else{i=n;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<2097152){if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else{throw new Error("Invalid code point")}}return o}function G(e){var t=[];for(var n=0;n<e.length;n++){t.push(e.charCodeAt(n)&255)}return t}function J(e,t){var n,r,i;var o=[];for(var a=0;a<e.length;a++){if((t-=2)<0)break;n=e.charCodeAt(a);r=n>>8;i=n%256;o.push(i);o.push(r)}return o}function V(e){return r.toByteArray(D(e))}function $(e,t,n,r){for(var i=0;i<r;i++){if(i+n>=t.length||i>=e.length)break;t[i+n]=e[i]}return i}function K(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":12,ieee754:48,"is-array":50}],32:[function(e,t,n){t.exports=function(e,t){var n=Infinity;var r=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,a=t.length;o<a;o++){r=Math.abs(e-t[o]);if(r>=n){break}n=r;i=t[o]}return i}},{}],33:[function(e,t,n){(function(e){function t(e){return Array.isArray(e)}n.isArray=t;function r(e){return typeof e==="boolean"}n.isBoolean=r;function i(e){return e===null}n.isNull=i;function o(e){return e==null}n.isNullOrUndefined=o;function a(e){return typeof e==="number"}n.isNumber=a;function s(e){return typeof e==="string"}n.isString=s;function c(e){return typeof e==="symbol"}n.isSymbol=c;function f(e){return e===void 0}n.isUndefined=f;function l(e){return u(e)&&g(e)==="[object RegExp]"}n.isRegExp=l;function u(e){return typeof e==="object"&&e!==null}n.isObject=u;function p(e){return u(e)&&g(e)==="[object Date]"}n.isDate=p;function d(e){return u(e)&&(g(e)==="[object Error]"||e instanceof Error)}n.isError=d;function h(e){return typeof e==="function"}n.isFunction=h;function v(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}n.isPrimitive=v;function m(t){return e.isBuffer(t)}n.isBuffer=m;function g(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:31}],34:[function(e,t,n){(function(n,r){t.exports=y;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=w;var i=e("bencode");var o=e("block-stream2");var a=e("piece-length");var s=e("path");var c=e("dezalgo");var f=e("filestream/read");var l=e("flatten");var u=e("fs");var p=e("is-file");var d=e("multistream");var h=e("once");var v=e("run-parallel");var m=e("simple-sha1");var g=e("stream");function y(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};w(e,t,function(e,r,i){if(e)return n(e);t.singleFileTorrent=i;S(r,t,n)})}function w(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=c(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(C(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"&&s.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);var o=e.length===1;if(e.length===1&&typeof e[0]==="string"){p(e[0],function(e,t){if(e)return n(e);o=t;a()})}else{a()}function a(){v(e.map(function(e){return function(n){var a={};if(T(e)){a.getStream=j(e);a.length=e.size}else if(r.isBuffer(e)){a.getStream=L(e);a.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}a.getStream=B(e,a);a.length=0}else if(typeof e==="string"){if(typeof u.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var c=i>1||o;b(e,c,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");a.path=e.name.split(s.sep);n(null,a)}}),function(e,t){if(e)return n(e);t=l(t);n(null,t,o)})}}function b(e,t,n){x(e,_,function(r,i){if(r)return n(r);if(Array.isArray(i))i=l(i);else i=[i];e=s.normalize(e);if(t){e=e.slice(0,e.lastIndexOf(s.sep)+1)}if(e[e.length-1]!==s.sep)e+=s.sep;i.forEach(function(t){t.getStream=R(t.path);t.path=t.path.replace(e,"").split(s.sep)});n(null,i)})}function _(e,t){t=h(t);u.stat(e,function(n,r){if(n)return t(n);var i={length:r.size,path:e};t(null,i)})}function x(e,t,n){u.readdir(e,function(r,i){if(r&&r.code==="ENOTDIR"){t(e,n)}else if(r){n(r)}else{v(i.filter(k).map(function(n){return function(r){x(s.join(e,n),t,r)}}),n)}})}function k(e){return e[0]!=="."}function E(e,t,n){n=h(n);var i=[];var a=0;var s=e.map(function(e){return e.getStream});var c=0;var f=0;var l=false;var u=new d(s);var p=new o(t,{zeroPadding:false});u.on("error",y);u.pipe(p).on("data",v).on("end",g).on("error",y);function v(e){a+=e.length;var t=f;m(e,function(e){i[t]=e;c-=1;b()});c+=1;f+=1}function g(){l=true;b()}function y(e){w();n(e)}function w(){u.removeListener("error",y);p.removeListener("data",v);p.removeListener("end",g);p.removeListener("error",y)}function b(){if(l&&c===0){w();n(null,new r(i.join(""),"hex"),a)}}}function S(e,r,o){var s=r.announceList;if(!s){if(typeof r.announce==="string")s=[[r.announce]];else if(Array.isArray(r.announce)){s=r.announce.map(function(e){
-return[e]})}}if(!s)s=[];if(n.WEBTORRENT_ANNOUNCE){if(typeof n.WEBTORRENT_ANNOUNCE==="string"){s.push([[n.WEBTORRENT_ANNOUNCE]])}else if(Array.isArray(n.WEBTORRENT_ANNOUNCE)){s=s.concat(n.WEBTORRENT_ANNOUNCE.map(function(e){return[e]}))}}if(s.length===0){s=s.concat(t.exports.announceList)}var c={info:{name:r.name},announce:s[0][0],"announce-list":s,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)c.comment=r.comment;if(r.createdBy!==undefined)c["created by"]=r.createdBy;if(r.private!==undefined)c.info.private=Number(r.private);if(r.sslCert!==undefined)c.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)c["url-list"]=r.urlList;var f=r.pieceLength||a(e.reduce(A,0));c.info["piece length"]=f;E(e,f,function(t,n,a){if(t)return o(t);c.info.pieces=n;e.forEach(function(e){delete e.getStream});if(r.singleFileTorrent){c.info.length=a}else{c.info.files=e}o(null,i.encode(c))})}function A(e,t){return e+t.length}function T(e){return typeof Blob!=="undefined"&&e instanceof Blob}function C(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function j(e){return function(){return new f(e)}}function L(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function R(e){return function(){return u.createReadStream(e)}}function B(e,t){return function(){var n=new g.Transform;n._transform=function(e,n,r){t.length+=e.length;this.push(e);r()};e.pipe(n);return n}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{bencode:13,"block-stream2":26,buffer:31,dezalgo:38,"filestream/read":41,flatten:42,fs:28,"is-file":51,multistream:58,once:59,path:62,"piece-length":63,"run-parallel":80,"simple-sha1":83,stream:86}],35:[function(e,t,n){n=t.exports=e("./debug");n.log=o;n.formatArgs=i;n.save=a;n.load=s;n.useColors=r;n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c();n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function r(){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}n.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 ":" ")+"+"+n.humanize(this.diff);if(!t)return e;var r="color: "+this.color;e=[e[0],r,"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,r);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){n.storage.removeItem("debug")}else{n.storage.debug=e}}catch(t){}}function s(){var e;try{e=n.storage.debug}catch(t){}return e}n.enable(s());function c(){try{return window.localStorage}catch(e){}}},{"./debug":36}],36:[function(e,t,n){n=t.exports=a;n.coerce=l;n.disable=c;n.enable=s;n.enabled=f;n.humanize=e("ms");n.names=[];n.skips=[];n.formatters={};var r=0;var i;function o(){return n.colors[r++%n.colors.length]}function a(e){function t(){}t.enabled=false;function r(){var e=r;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=n.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var c=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if(t==="%%")return t;c++;var i=n.formatters[r];if("function"===typeof i){var o=s[c];t=i.call(e,o);s.splice(c,1);c--}return t});if("function"===typeof n.formatArgs){s=n.formatArgs.apply(e,s)}var f=r.log||n.log||console.log.bind(console);f.apply(e,s)}r.enabled=true;var a=n.enabled(e)?r:t;a.namespace=e;return a}function s(e){n.save(e);var t=(e||"").split(/[\s,]+/);var r=t.length;for(var i=0;i<r;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){n.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{n.names.push(new RegExp("^"+e+"$"))}}}function c(){n.enable("")}function f(e){var t,r;for(t=0,r=n.skips.length;t<r;t++){if(n.skips[t].test(e)){return false}}for(t=0,r=n.names.length;t<r;t++){if(n.names[t].test(e)){return true}}return false}function l(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:57}],37:[function(e,t,n){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],38:[function(e,t,n){var r=e("wrappy");t.exports=r(o);var i=e("asap");function o(e){var t=true;i(function(){t=false});return function n(){var n=arguments;var r=this;if(t)i(function(){e.apply(r,n)});else e.apply(r,n)}}},{asap:10,wrappy:97}],39:[function(e,t,n){var r=e("once");var i=function(){};var o=function(e){return e.setHeader&&typeof e.abort==="function"};var a=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var s=function(e,t,n){if(typeof t==="function")return s(e,null,t);if(!t)t={};n=r(n||i);var c=e._writableState;var f=e._readableState;var l=t.readable||t.readable!==false&&e.readable;var u=t.writable||t.writable!==false&&e.writable;var p=function(){if(!e.writable)d()};var d=function(){u=false;if(!l)n()};var h=function(){l=false;if(!u)n()};var v=function(e){n(e?new Error("exited with error code: "+e):null)};var m=function(){if(l&&!(f&&f.ended))return n(new Error("premature close"));if(u&&!(c&&c.ended))return n(new Error("premature close"))};var g=function(){e.req.on("finish",d)};if(o(e)){e.on("complete",d);e.on("abort",m);if(e.req)g();else e.on("request",g)}else if(u&&!c){e.on("end",p);e.on("close",p)}if(a(e))e.on("exit",v);e.on("end",h);e.on("finish",d);if(t.error!==false)e.on("error",n);e.on("close",m);return function(){e.removeListener("complete",d);e.removeListener("abort",m);e.removeListener("request",g);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",p);e.removeListener("close",p);e.removeListener("finish",d);e.removeListener("exit",v);e.removeListener("end",h);e.removeListener("error",n);e.removeListener("close",m)}};t.exports=s},{once:59}],40:[function(e,t,n){function r(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=r;r.EventEmitter=r;r.prototype._events=undefined;r.prototype._maxListeners=undefined;r.defaultMaxListeners=10;r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};r.prototype.emit=function(e){var t,n,r,o,c,f;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.')}}n=this._events[e];if(s(n))return false;if(i(n)){switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:r=arguments.length;o=new Array(r-1);for(c=1;c<r;c++)o[c-1]=arguments[c];n.apply(this,o)}}else if(a(n)){r=arguments.length;o=new Array(r-1);for(c=1;c<r;c++)o[c-1]=arguments[c];f=n.slice();r=f.length;for(c=0;c<r;c++)f[c].apply(this,o)}return true};r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(a(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(a(this._events[e])&&!this._events[e].warned){var n;if(!s(this._maxListeners)){n=this._maxListeners}else{n=r.defaultMaxListeners}if(n&&n>0&&this._events[e].length>n){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};r.prototype.on=r.prototype.addListener;r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=false;function r(){this.removeListener(e,r);if(!n){n=true;t.apply(this,arguments)}}r.listener=t;this.on(e,r);return this};r.prototype.removeListener=function(e,t){var n,r,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;n=this._events[e];o=n.length;r=-1;if(n===t||i(n.listener)&&n.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(n)){for(s=o;s-->0;){if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}}if(r<0)return this;if(n.length===1){n.length=0;delete this._events[e]}else{n.splice(r,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener){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}n=this._events[e];if(i(n)){this.removeListener(e,n)}else{while(n.length)this.removeListener(e,n[n.length-1])}delete this._events[e];return this};r.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};r.listenerCount=function(e,t){var n;if(!e._events||!e._events[t])n=0;else if(i(e._events[t]))n=1;else n=e._events[t].length;return n};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}},{}],41:[function(e,t,n){var r=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var n=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};r.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 n.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){n.push(e)})}n._ready=true;n.emit("_ready")})}i(s,r);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var n=this._offset;var r=this._offset+this._chunkSize;if(r>this._size)r=this._size;if(n===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=r;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(n,r))};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:49,stream:86,"typedarray-to-buffer":91}],42:[function(e,t,n){t.exports=function r(e,t){t=typeof t=="number"?t:Infinity;return n(e,1);function n(e,r){return e.reduce(function(e,i){if(Array.isArray(i)&&r<t){return e.concat(n(i,r+1))}else{return e.concat(i)}},[])}}},{}],43:[function(e,t,n){t.exports=function r(){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}},{}],44:[function(e,t,n){var r=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var n=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;n===Infinity;i*=2){n=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=n-Math.floor(n);var a="";for(var i=0;i<Math.floor(n);i++){var s=Math.floor(Math.random()*t).toString(t);a=s+a}if(o){var c=Math.pow(t,o);var s=Math.floor(Math.random()*c).toString(t);a=s+a}var f=parseInt(a,t);if(f!==Infinity&&f>=Math.pow(2,e)){return r(e,t)}else return a};r.rack=function(e,t,n){var i=function(i){var a=0;do{if(a++>10){if(n)e+=n;else throw new Error("too many ID collisions, use more bits")}var s=r(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}},{}],45:[function(e,t,n){var r=t.exports;var i=e("events").EventEmitter;var o=e("./lib/request");var a=e("url");r.request=function(e,t){if(typeof e==="string"){e=a.parse(e)}if(!e)e={};if(!e.host&&!e.port){e.port=parseInt(window.location.port,10)}if(!e.host&&e.hostname){e.host=e.hostname}if(!e.protocol){if(e.scheme){e.protocol=e.scheme+":"}else{e.protocol=window.location.protocol}}if(!e.host){e.host=window.location.hostname||window.location.host}if(/:/.test(e.host)){if(!e.port){e.port=e.host.split(":")[1]}e.host=e.host.split(":")[0]}if(!e.port)e.port=e.protocol=="https:"?443:80;var n=new o(new s,e);if(t)n.on("response",t);return n};r.get=function(e,t){e.method="GET";var n=r.request(e,t);n.end();return n};r.Agent=function(){};r.Agent.defaultMaxSockets=4;var s=function(){if(typeof window==="undefined"){throw new Error("no window object present")}else if(window.XMLHttpRequest){return window.XMLHttpRequest}else if(window.ActiveXObject){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var t=0;t<e.length;t++){try{var n=new window.ActiveXObject(e[t]);return function(){if(n){var r=n;n=null;return r}else{return new window.ActiveXObject(e[t])}}}catch(r){}}throw new Error("ajax not supported in this browser")}else{throw new Error("ajax not supported in this browser")}}();r.STATUS_CODES={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{"./lib/request":46,events:40,url:93}],46:[function(e,t,n){var r=e("stream");var i=e("./response");var o=e("Base64");var a=e("inherits");var s=t.exports=function(e,t){var n=this;n.writable=true;n.xhr=e;n.body=[];n.uri=(t.protocol||"http:")+"//"+t.host+(t.port?":"+t.port:"")+(t.path||"/");if(typeof t.withCredentials==="undefined"){t.withCredentials=true}try{e.withCredentials=t.withCredentials}catch(r){}if(t.responseType)try{e.responseType=t.responseType}catch(r){}e.open(t.method||"GET",n.uri,true);e.onerror=function(e){n.emit("error",new Error("Network error"))};n._headers={};if(t.headers){var a=c(t.headers);for(var s=0;s<a.length;s++){var f=a[s];if(!n.isSafeRequestHeader(f))continue;var l=t.headers[f];n.setHeader(f,l)}}if(t.auth){this.setHeader("Authorization","Basic "+o.btoa(t.auth))}var u=new i;u.on("close",function(){n.emit("close")});u.on("ready",function(){n.emit("response",u)});u.on("error",function(e){n.emit("error",e)});e.onreadystatechange=function(){if(e.__aborted)return;u.handle(e)}};a(s,r);s.prototype.setHeader=function(e,t){this._headers[e.toLowerCase()]=t};s.prototype.getHeader=function(e){return this._headers[e.toLowerCase()]};s.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]};s.prototype.write=function(e){this.body.push(e)};s.prototype.destroy=function(e){this.xhr.__aborted=true;this.xhr.abort();this.emit("close")};s.prototype.end=function(e){if(e!==undefined)this.body.push(e);var t=c(this._headers);for(var n=0;n<t.length;n++){var r=t[n];var i=this._headers[r];if(f(i)){for(var o=0;o<i.length;o++){this.xhr.setRequestHeader(r,i[o])}}else this.xhr.setRequestHeader(r,i)}if(this.body.length===0){this.xhr.send("")}else if(typeof this.body[0]==="string"){this.xhr.send(this.body.join(""))}else if(f(this.body[0])){var a=[];for(var n=0;n<this.body.length;n++){a.push.apply(a,this.body[n])}this.xhr.send(a)}else if(/Array/.test(Object.prototype.toString.call(this.body[0]))){var s=0;for(var n=0;n<this.body.length;n++){s+=this.body[n].length}var a=new this.body[0].constructor(s);var l=0;for(var n=0;n<this.body.length;n++){var p=this.body[n];for(var o=0;o<p.length;o++){a[l++]=p[o]}}this.xhr.send(a)}else if(u(this.body[0])){this.xhr.send(this.body[0])}else{var a="";for(var n=0;n<this.body.length;n++){a+=this.body[n].toString()}this.xhr.send(a)}};s.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];s.prototype.isSafeRequestHeader=function(e){if(!e)return false;return l(s.unsafeHeaders,e.toLowerCase())===-1};var c=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};var f=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};var l=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++){if(e[n]===t)return n}return-1};var u=function(e){if(typeof Blob!=="undefined"&&e instanceof Blob)return true;if(typeof ArrayBuffer!=="undefined"&&e instanceof ArrayBuffer)return true;if(typeof FormData!=="undefined"&&e instanceof FormData)return true}},{"./response":47,Base64:8,inherits:49,stream:86}],47:[function(e,t,n){var r=e("stream");var i=e("util");var o=t.exports=function(e){this.offset=0;this.readable=true};i.inherits(o,r);var a={streaming:true,status2:true};function s(e){var t=e.getAllResponseHeaders().split(/\r?\n/);var n={};for(var r=0;r<t.length;r++){var i=t[r];if(i==="")continue;var o=i.match(/^([^:]+):\s*(.*)/);if(o){var a=o[1].toLowerCase(),s=o[2];if(n[a]!==undefined){if(c(n[a])){n[a].push(s)}else{n[a]=[n[a],s]}}else{n[a]=s}}else{n[i]=true}}return n}o.prototype.getResponse=function(e){var t=String(e.responseType).toLowerCase();if(t==="blob")return e.responseBlob||e.response;if(t==="arraybuffer")return e.response;return e.responseText};o.prototype.getHeader=function(e){return this.headers[e.toLowerCase()]};o.prototype.handle=function(e){if(e.readyState===2&&a.status2){try{this.statusCode=e.status;this.headers=s(e)}catch(t){a.status2=false}if(a.status2){this.emit("ready")}}else if(a.streaming&&e.readyState===3){try{if(!this.statusCode){this.statusCode=e.status;this.headers=s(e);this.emit("ready")}}catch(t){}try{this._emitData(e)}catch(t){a.streaming=false}}else if(e.readyState===4){if(!this.statusCode){this.statusCode=e.status;this.emit("ready")}this._emitData(e);if(e.error){this.emit("error",this.getResponse(e))}else this.emit("end");this.emit("close")}};o.prototype._emitData=function(e){var t=this.getResponse(e);if(t.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(t,this.offset));this.offset=t.byteLength;return}if(t.length>this.offset){this.emit("data",t.slice(this.offset));this.offset=t.length}};var c=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{stream:86,util:96}],48:[function(e,t,n){n.read=function(e,t,n,r,i){var o,a;var s=i*8-r-1;var c=(1<<s)-1;var f=c>>1;var l=-7;var u=n?i-1:0;var p=n?-1:1;var d=e[t+u];u+=p;o=d&(1<<-l)-1;d>>=-l;l+=s;for(;l>0;o=o*256+e[t+u],u+=p,l-=8){}a=o&(1<<-l)-1;o>>=-l;l+=r;for(;l>0;a=a*256+e[t+u],u+=p,l-=8){}if(o===0){o=1-f}else if(o===c){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,r);o=o-f}return(d?-1:1)*a*Math.pow(2,o-r)};n.write=function(e,t,n,r,i,o){var a,s,c;var f=o*8-i-1;var l=(1<<f)-1;var u=l>>1;var p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=r?0:o-1;var h=r?1:-1;var v=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=l}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(c=Math.pow(2,-a))<1){a--;c*=2}if(a+u>=1){t+=p/c}else{t+=p*Math.pow(2,1-u)}if(t*c>=2){a++;c/=2}if(a+u>=l){s=0;a=l}else if(a+u>=1){s=(t*c-1)*Math.pow(2,i);a=a+u}else{s=t*Math.pow(2,u-1)*Math.pow(2,i);a=0}}for(;i>=8;e[n+d]=s&255,d+=h,s/=256,i-=8){}a=a<<i|s;f+=i;for(;f>0;e[n+d]=a&255,d+=h,a/=256,f-=8){}e[n+d-h]|=v*128}},{}],49:[function(e,t,n){if(typeof Object.create==="function"){t.exports=function r(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function i(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype;e.prototype=new n;e.prototype.constructor=e}}},{}],50:[function(e,t,n){var r=Array.isArray;var i=Object.prototype.toString;t.exports=r||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],51:[function(e,t,n){"use strict";var r=e("fs");t.exports=function o(e,t){if(!t)return i(e);r.stat(e,function(e,n){if(e)return t(e);return t(null,n.isFile())})};t.exports.sync=i;function i(e){return r.existsSync(e)&&r.statSync(e).isFile()}},{fs:28}],52:[function(e,t,n){t.exports=o;o.strict=a;o.loose=s;var r=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint8ClampedArray]":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 Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[r.call(e)]}},{}],53:[function(e,t,n){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],54:[function(e,t,n){(function(n){t.exports=a;t.exports.decode=a;t.exports.encode=s;var r=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 n=e.split("=");if(n.length!==2)return;var r=n[0];var i=n[1];if(r==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){i=decodeURIComponent(i)}if(r==="kt")i=decodeURIComponent(i).split("+");if(t[r]){if(Array.isArray(t[r])){t[r].push(i)}else{var o=t[r];t[r]=[o,i]}}else{t[r]=i}});var s;if(t.xt){var c=Array.isArray(t.xt)?t.xt:[t.xt];c.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new n(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=r.decode(s[1]);t.infoHash=new n(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(n,r){var i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach(function(e,i){if((r>0||i>0)&&(n!=="kt"||i===0))t+="&";if(n==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){e=encodeURIComponent(e)}if(n==="kt")e=encodeURIComponent(e);if(n==="kt"&&i>0)t+="+"+e;else t+=n+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:31,"thirty-two":88,uniq:92,xtend:98}],55:[function(e,t,n){(function(n){var r=e("path");var i=e("fs");function o(){this.types=Object.create(null);this.extensions=Object.create(null)}o.prototype.define=function(e){for(var t in e){var r=e[t];for(var i=0;i<r.length;i++){if(n.env.DEBUG_MIME&&this.types[r]){console.warn(this._loading.replace(/.*\//,""),'changes "'+r[i]+'" extension type from '+this.types[r]+" to "+t)}this.types[r[i]]=t}if(!this.extensions[t]){this.extensions[t]=r[0]}}};o.prototype.load=function(e){this._loading=e;var t={},n=i.readFileSync(e,"ascii"),r=n.split(/[\r\n]+/);r.forEach(function(e){var n=e.replace(/\s*#.*|^\s*|\s*$/g,"").split(/\s+/);t[n.shift()]=n});this.define(t);this._loading=null};o.prototype.lookup=function(e,t){var n=e.replace(/.*[\.\/\\]/,"").toLowerCase();return this.types[n]||t||this.default_type};o.prototype.extension=function(e){var t=e.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();return this.extensions[t]};var a=new o;a.define(e("./types.json"));a.default_type=a.lookup("bin");a.Mime=o;a.charsets={lookup:function(e,t){return/^text\//.test(e)?"UTF-8":t}};t.exports=a}).call(this,e("_process"))},{"./types.json":56,_process:29,fs:28,path:62}],56:[function(e,t,n){t.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],
-"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],57:[function(e,t,n){var r=1e3;var i=r*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 c(e);return t.long?l(e):f(e)};function c(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 n=parseFloat(t[1]);var c=(t[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return n*s;case"days":case"day":case"d":return n*a;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}function f(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>=r)return Math.round(e/r)+"s";return e+"ms"}function l(e){return u(e,a,"day")||u(e,o,"hour")||u(e,i,"minute")||u(e,r,"second")||e+" ms"}function u(e,t,n){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+n;return Math.ceil(e/t)+" "+n+"s"}},{}],58:[function(e,t,n){t.exports=o;var r=e("inherits");var i=e("stream");r(o,i.Readable);function o(e,t){if(!(this instanceof o))return new o(e,t);i.Readable.call(this,t);this.destroyed=false;this._drained=false;this._forwarding=false;this._current=null;this._queue=e.map(a);this._next()}o.obj=function(e){return new o(e,{objectMode:true,highWaterMark:16})};o.prototype._read=function(){this._drained=true;this._forward()};o.prototype._forward=function(){if(this._forwarding||!this._drained)return;this._forwarding=true;var e;while((e=this._current.read())!==null){this._drained=this.push(e)}this._forwarding=false};o.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(this._current&&this._current.destroy)this._current.destroy();this._queue.forEach(function(e){if(e.destroy)e.destroy()});if(e)this.emit("error",e);this.emit("close")};o.prototype._next=function(){var e=this;var t=e._queue.shift();if(typeof t==="function")t=a(t());if(!t){e.destroy();e.push(null);return}e._current=t;t.on("readable",n);t.on("end",i);t.on("error",o);t.on("close",r);function n(){e._forward()}function r(){if(!t._readableState.ended){e.destroy()}}function i(){e._current=null;t.removeListener("readable",n);t.removeListener("end",i);t.removeListener("error",o);t.removeListener("close",r);e._next()}function o(t){e.destroy(t)}};function a(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new i.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:49,stream:86}],59:[function(e,t,n){var r=e("wrappy");t.exports=r(i);i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:true})});function i(e){var t=function(){if(t.called)return t.value;t.called=true;return t.value=e.apply(this,arguments)};t.called=false;return t}},{wrappy:97}],60:[function(e,t,n){(function(n){t.exports=s;t.exports.decode=s;t.exports.encode=c;var r=e("bencode");var i=e("path");var o=e("simple-sha1");var a=e("uniq");function s(e){if(n.isBuffer(e)){e=r.decode(e)}u(e.info,"info");u(e.info.name,"info.name");u(e.info["piece length"],"info['piece length']");u(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){u(typeof e.length==="number","info.files[0].length");u(e.path,"info.files[0].path")})}else{u(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=r.encode(e.info);t.infoHash=o.sync(t.infoBuffer);t.name=e.info.name.toString();t.private=!!e.info.private;if(e["creation date"])t.created=new Date(e["creation date"]*1e3);if(n.isBuffer(e.comment))t.comment=e.comment.toString();t.announce=[];if(e["announce-list"]){e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})})}else if(e.announce){t.announce.push(e.announce)}a(t.announce);if(n.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[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,n){var r=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(r)).slice(1),name:r[r.length-1],length:e.length,offset:s.slice(0,n).reduce(f,0)}});t.length=s.reduce(f,0);var c=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(c.offset+c.length)%t.pieceLength||t.pieceLength;t.pieces=l(e.info.pieces);return t}function c(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new n(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return r.encode(t)}function f(e,t){return e+t.length}function l(e){var t=[];for(var n=0;n<e.length;n+=20){t.push(e.slice(n,n+20).toString("hex"))}return t}function u(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:13,buffer:31,path:62,"simple-sha1":83,uniq:92}],61:[function(e,t,n){(function(n){t.exports=c;t.exports.remote=f;var r=e("dezalgo");var i=e("fs");var o=e("simple-get");var a=e("magnet-uri");var s=e("parse-torrent-file");t.exports.toMagnetURI=a.encode;t.exports.toTorrentFile=s.encode;function c(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return a(e)}else if(typeof e==="string"&&(t===40||t===32)){return a("magnet:?xt=urn:btih:"+e)}else if(n.isBuffer(e)&&t===20){return a("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(n.isBuffer(e)){return s(e)}else if(e&&e.infoHash){if(!e.announce)e.announce=[];if(typeof e.announce==="string"){e.announce=[e.announce]}return e}else{throw new Error("Invalid torrent identifier")}}function f(e,t){var n;if(typeof t!=="function")throw new Error("second argument must be a Function");t=r(t);try{n=c(e)}catch(a){}if(n&&n.infoHash){t(null,n)}else if(typeof o==="function"&&/^https?:/.test(e)){o.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){if(e){e=new Error("Error downloading torrent: "+e.message);return t(e)}s(n)})}else if(typeof i.readFile==="function"&&typeof e==="string"){i.readFile(e,function(e,n){if(e)return t(new Error("Invalid torrent identifier"));s(n)})}else{t(new Error("Invalid torrent identifier"))}function s(e){try{n=c(e)}catch(r){return t(r)}if(n&&n.infoHash)t(null,n);else t(new Error("Invalid torrent identifier"))}}}).call(this,e("buffer").Buffer)},{buffer:31,dezalgo:38,fs:28,"magnet-uri":54,"parse-torrent-file":60,"simple-get":27}],62:[function(e,t,n){(function(e){function t(e,t){var n=0;for(var r=e.length-1;r>=0;r--){var i=e[r];if(i==="."){e.splice(r,1)}else if(i===".."){e.splice(r,1);n++}else if(n){e.splice(r,1);n--}}if(t){for(;n--;n){e.unshift("..")}}return e}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return r.exec(e).slice(1)};n.resolve=function(){var n="",r=false;for(var i=arguments.length-1;i>=-1&&!r;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}n=a+"/"+n;r=a.charAt(0)==="/"}n=t(o(n.split("/"),function(e){return!!e}),!r).join("/");return(r?"/":"")+n||"."};n.normalize=function(e){var r=n.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!r).join("/");if(!e&&!r){e="."}if(e&&i){e+="/"}return(r?"/":"")+e};n.isAbsolute=function(e){return e.charAt(0)==="/"};n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};n.relative=function(e,t){e=n.resolve(e).substr(1);t=n.resolve(t).substr(1);function r(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var n=e.length-1;for(;n>=0;n--){if(e[n]!=="")break}if(t>n)return[];return e.slice(t,n-t+1)}var i=r(e.split("/"));var o=r(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var c=0;c<a;c++){if(i[c]!==o[c]){s=c;break}}var f=[];for(var c=s;c<i.length;c++){f.push("..")}f=f.concat(o.slice(s));return f.join("/")};n.sep="/";n.delimiter=":";n.dirname=function(e){var t=i(e),n=t[0],r=t[1];if(!n&&!r){return"."}if(r){r=r.substr(0,r.length-1)}return n+r};n.basename=function(e,t){var n=i(e)[2];if(t&&n.substr(-1*t.length)===t){n=n.substr(0,n.length-t.length);
-}return n};n.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var n=[];for(var r=0;r<e.length;r++){if(t(e[r],r,e))n.push(e[r])}return n}var a="ab".substr(-1)==="b"?function(e,t,n){return e.substr(t,n)}:function(e,t,n){if(t<0)t=e.length+t;return e.substr(t,n)}}).call(this,e("_process"))},{_process:29}],63:[function(e,t,n){var r=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return r(e/Math.pow(2,10),i)}},{"closest-to":32}],64:[function(e,t,n){var r=e("once");var i=e("end-of-stream");var o=e("fs");var a=function(){};var s=function(e){return typeof e==="function"};var c=function(e){return(e instanceof(o.ReadStream||a)||e instanceof(o.WriteStream||a))&&s(e.close)};var f=function(e){return e.setHeader&&s(e.abort)};var l=function(e,t,n,o){o=r(o);var a=false;e.on("close",function(){a=true});i(e,{readable:t,writable:n},function(e){if(e)return o(e);a=true;o()});var l=false;return function(t){if(a)return;if(l)return;l=true;if(c(e))return e.close();if(f(e))return e.abort();if(s(e.destroy))return e.destroy();o(t||new Error("stream was destroyed"))}};var u=function(e){e()};var p=function(e,t){return e.pipe(t)};var d=function(){var e=Array.prototype.slice.call(arguments);var t=s(e[e.length-1]||a)&&e.pop()||a;if(Array.isArray(e[0]))e=e[0];if(e.length<2)throw new Error("pump requires two streams per minimum");var n;var r=e.map(function(i,o){var a=o<e.length-1;var s=o>0;return l(i,a,s,function(e){if(!n)n=e;if(e)r.forEach(u);if(a)return;r.forEach(u);t(n)})});return e.reduce(p)};t.exports=d},{"end-of-stream":39,fs:28,once:59}],65:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,o){t=t||"&";n=n||"=";var a={};if(typeof e!=="string"||e.length===0){return a}var s=/\+/g;e=e.split(t);var c=1e3;if(o&&typeof o.maxKeys==="number"){c=o.maxKeys}var f=e.length;if(c>0&&f>c){f=c}for(var l=0;l<f;++l){var u=e[l].replace(s,"%20"),p=u.indexOf(n),d,h,v,m;if(p>=0){d=u.substr(0,p);h=u.substr(p+1)}else{d=u;h=""}v=decodeURIComponent(d);m=decodeURIComponent(h);if(!r(a,v)){a[v]=m}else if(i(a[v])){a[v].push(m)}else{a[v]=[a[v],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],66:[function(e,t,n){"use strict";var r=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,n,s){t=t||"&";n=n||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(r(a))+n;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(r(e))}).join(t)}else{return s+encodeURIComponent(r(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(r(s))+n+encodeURIComponent(r(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 n=[];for(var r=0;r<e.length;r++){n.push(t(e[r],r))}return n}var a=Object.keys||function(e){var t=[];for(var n in e){if(Object.prototype.hasOwnProperty.call(e,n))t.push(n)}return t}},{}],67:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode");n.encode=n.stringify=e("./encode")},{"./decode":65,"./encode":66}],68:[function(e,t,n){t.exports=function(e,t){var n=true;var r=t.indexOf("=");if(-1==r)return-2;var i=t.slice(r+1).split(",").map(function(t){var t=t.split("-"),r=parseInt(t[0],10),i=parseInt(t[1],10);if(isNaN(r)){r=e-i;i=e-1}else if(isNaN(i)){i=e-1}if(i>e-1)i=e-1;if(isNaN(r)||isNaN(i)||r>i||r<0)n=false;return{start:r,end:i}});i.type=t.slice(0,r);return n?i:-1}},{}],69:[function(e,t,n){t.exports=i;t.exports.filter=o;var r=e("events").EventEmitter;function i(e,t,n){if(!Array.isArray(n))n=[n];var r=[];n.forEach(function(n){var i=function(){var e=[].slice.call(arguments);e.unshift(n);t.emit.apply(t,e)};r.push(i);e.on(n,i)});return function i(){n.forEach(function(t,n){e.removeListener(t,r[n])})}}function o(e,t){var n=new r;i(e,n,t);return n}},{events:40}],70:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":71}],71:[function(e,t,n){(function(n){t.exports=s;var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};var i=e("core-util-is");i.inherits=e("inherits");var o=e("./_stream_readable");var a=e("./_stream_writable");i.inherits(s,o);f(r(a.prototype),function(e){if(!s.prototype[e])s.prototype[e]=a.prototype[e]});function s(e){if(!(this instanceof s))return new s(e);o.call(this,e);a.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",c)}function c(){if(this.allowHalfOpen||this._writableState.ended)return;n.nextTick(this.end.bind(this))}function f(e,t){for(var n=0,r=e.length;n<r;n++){t(e[n],n)}}}).call(this,e("_process"))},{"./_stream_readable":73,"./_stream_writable":75,_process:29,"core-util-is":33,inherits:49}],72:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,r);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":74,"core-util-is":33,inherits:49}],73:[function(e,t,n){(function(n){t.exports=u;var r=e("isarray");var i=e("buffer").Buffer;u.ReadableState=l;var o=e("events").EventEmitter;if(!o.listenerCount)o.listenerCount=function(e,t){return e.listeners(t).length};var a=e("stream");var s=e("core-util-is");s.inherits=e("inherits");var c;var f=e("util");if(f&&f.debuglog){f=f.debuglog("stream")}else{f=function(){}}s.inherits(u,a);function l(t,n){var r=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;if(n instanceof r)this.objectMode=this.objectMode||!!t.readableObjectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!c)c=e("string_decoder/").StringDecoder;this.decoder=new c(t.encoding);this.encoding=t.encoding}}function u(t){var n=e("./_stream_duplex");if(!(this instanceof u))return new u(t);this._readableState=new l(t,this);this.readable=true;a.call(this)}u.prototype.push=function(e,t){var n=this._readableState;if(s.isString(e)&&!n.objectMode){t=t||n.defaultEncoding;if(t!==n.encoding){e=new i(e,t);t=""}}return p(this,n,e,t,false)};u.prototype.unshift=function(e){var t=this._readableState;return p(this,t,e,"",true)};function p(e,t,n,r,i){var o=g(t,n);if(o){e.emit("error",o)}else if(s.isNullOrUndefined(n)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||n&&n.length>0){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&&!r)n=t.decoder.write(n);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",n);e.read(0)}else{t.length+=t.objectMode?1:n.length;if(i)t.buffer.unshift(n);else t.buffer.push(n);if(t.needReadable)w(e)}_(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}u.prototype.setEncoding=function(t){if(!c)c=e("string_decoder/").StringDecoder;this._readableState.decoder=new c(t);this._readableState.encoding=t;return this};var h=8388608;function v(e){if(e>=h){e=h}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=v(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}u.prototype.read=function(e){f("read",e);var t=this._readableState;var n=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){f("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)C(this);else w(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)C(this);return null}var r=t.needReadable;f("need readable",r);if(t.length===0||t.length-e<t.highWaterMark){r=true;f("length less than watermark",r)}if(t.ended||t.reading){r=false;f("reading or ended",r)}if(r){f("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(r&&!t.reading)e=m(n,t);var i;if(e>0)i=T(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(n!==e&&t.ended&&t.length===0)C(this);if(!s.isNull(i))this.emit("data",i);return i};function g(e,t){var n=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){n=new TypeError("Invalid non-string/buffer chunk")}return n}function y(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();if(n&&n.length){t.buffer.push(n);t.length+=t.objectMode?1:n.length}}t.ended=true;w(e)}function w(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){f("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)n.nextTick(function(){b(e)});else b(e)}}function b(e){f("emit readable");e.emit("readable");A(e)}function _(e,t){if(!t.readingMore){t.readingMore=true;n.nextTick(function(){x(e,t)})}}function x(e,t){var n=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){f("maybeReadMore read 0");e.read(0);if(n===t.length)break;else n=t.length}t.readingMore=false}u.prototype._read=function(e){this.emit("error",new Error("not implemented"))};u.prototype.pipe=function(e,t){var i=this;var a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e);break}a.pipesCount+=1;f("pipe count=%d opts=%j",a.pipesCount,t);var s=(!t||t.end!==false)&&e!==n.stdout&&e!==n.stderr;var c=s?u:d;if(a.endEmitted)n.nextTick(c);else i.once("end",c);e.on("unpipe",l);function l(e){f("onunpipe");if(e===i){d()}}function u(){f("onend");e.end()}var p=k(i);e.on("drain",p);function d(){f("cleanup");e.removeListener("close",m);e.removeListener("finish",g);e.removeListener("drain",p);e.removeListener("error",v);e.removeListener("unpipe",l);i.removeListener("end",u);i.removeListener("end",d);i.removeListener("data",h);if(a.awaitDrain&&(!e._writableState||e._writableState.needDrain))p()}i.on("data",h);function h(t){f("ondata");var n=e.write(t);if(false===n){f("false write response, pause",i._readableState.awaitDrain);i._readableState.awaitDrain++;i.pause()}}function v(t){f("onerror",t);y();e.removeListener("error",v);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",v);else if(r(e._events.error))e._events.error.unshift(v);else e._events.error=[v,e._events.error];function m(){e.removeListener("finish",g);y()}e.once("close",m);function g(){f("onfinish");e.removeListener("close",m);y()}e.once("finish",g);function y(){f("unpipe");i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){f("pipe resume");i.resume()}return e};function k(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&o.listenerCount(e,"data")){t.flowing=true;A(e)}}}u.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;t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var n=t.pipes;var r=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var i=j(t.pipes,e);if(i===-1)return this;t.pipes.splice(i,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};u.prototype.on=function(e,t){var r=a.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var i=this._readableState;if(!i.readableListening){i.readableListening=true;i.emittedReadable=false;i.needReadable=true;if(!i.reading){var o=this;n.nextTick(function(){f("readable nexttick read 0");o.read(0)})}else if(i.length){w(this,i)}}}return r};u.prototype.addListener=u.prototype.on;u.prototype.resume=function(){var e=this._readableState;if(!e.flowing){f("resume");e.flowing=true;if(!e.reading){f("resume read 0");this.read(0)}E(this,e)}return this};function E(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;n.nextTick(function(){S(e,t)})}}function S(e,t){t.resumeScheduled=false;e.emit("resume");A(e);if(t.flowing&&!t.reading)e.read(0)}u.prototype.pause=function(){f("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){f("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;f("flow",t.flowing);if(t.flowing){do{var n=e.read()}while(null!==n&&t.flowing)}}u.prototype.wrap=function(e){var t=this._readableState;var n=false;var r=this;e.on("end",function(){f("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)r.push(e)}r.push(null)});e.on("data",function(i){f("wrapped data");if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var o=r.push(i);if(!o){n=true;e.pause()}});for(var i in e){if(s.isFunction(e[i])&&s.isUndefined(this[i])){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];I(o,function(t){e.on(t,r.emit.bind(r,t))});r._read=function(t){f("wrapped _read",t);if(n){n=false;e.resume()}};return r};u._fromList=T;function T(e,t){var n=t.buffer;var r=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(n.length===0)return null;if(r===0)s=null;else if(a)s=n.shift();else if(!e||e>=r){if(o)s=n.join("");else s=i.concat(n,r);n.length=0}else{if(e<n[0].length){var c=n[0];s=c.slice(0,e);n[0]=c.slice(e)}else if(e===n[0].length){s=n.shift()}else{if(o)s="";else s=new i(e);var f=0;for(var l=0,u=n.length;l<u&&f<e;l++){var c=n[0];var p=Math.min(e-f,c.length);if(o)s+=c.slice(0,p);else c.copy(s,f,0,p);if(p<c.length)n[0]=c.slice(p);else n.shift();f+=p}}}return s}function C(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;n.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function I(e,t){for(var n=0,r=e.length;n<r;n++){t(e[n],n)}}function j(e,t){for(var n=0,r=e.length;n<r;n++){if(e[n]===t)return n}return-1}}).call(this,e("_process"))},{"./_stream_duplex":71,_process:29,buffer:31,"core-util-is":33,events:40,inherits:49,isarray:53,stream:86,"string_decoder/":87,util:27}],74:[function(e,t,n){t.exports=s;var r=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,r);function o(e,t){this.afterTransform=function(e,n){return a(t,e,n)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,n){var r=e._transformState;r.transforming=false;var o=r.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null;r.writecb=null;if(!i.isNullOrUndefined(n))e.push(n);if(o)o(t);var a=e._readableState;a.reading=false;if(a.needReadable||a.length<a.highWaterMark){e._read(a.highWaterMark)}}function s(e){if(!(this instanceof s))return new s(e);r.call(this,e);this._transformState=new o(e,this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("prefinish",function(){if(i.isFunction(this._flush))this._flush(function(e){c(t,e)});else c(t)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return r.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,n){throw new Error("not implemented")};s.prototype._write=function(e,t,n){var r=this._transformState;r.writecb=n;r.writechunk=e;r.writeencoding=t;if(!r.transforming){var i=this._readableState;if(r.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};s.prototype._read=function(e){var t=this._transformState;if(!i.isNull(t.writechunk)&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function c(e,t){if(t)return e.emit("error",t);var n=e._writableState;var r=e._transformState;if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":71,"core-util-is":33,inherits:49}],75:[function(e,t,n){(function(n){t.exports=c;var r=e("buffer").Buffer;c.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(c,o);function a(e,t,n){this.chunk=e;this.encoding=t;this.callback=n}function s(t,n){var r=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.objectMode=!!t.objectMode;if(n instanceof r)this.objectMode=this.objectMode||!!t.writableObjectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var a=t.decodeStrings===false;this.decodeStrings=!a;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){m(n,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function c(t){var n=e("./_stream_duplex");if(!(this instanceof c)&&!(this instanceof n))return new c(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function f(e,t,r){var i=new Error("write after end");e.emit("error",i);n.nextTick(function(){r(i)})}function l(e,t,r,o){var a=true;if(!i.isBuffer(r)&&!i.isString(r)&&!i.isNullOrUndefined(r)&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);n.nextTick(function(){o(s)});a=false}return a}c.prototype.write=function(e,t,n){var r=this._writableState;var o=false;if(i.isFunction(t)){n=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=r.defaultEncoding;if(!i.isFunction(n))n=function(){};if(r.ended)f(this,r,n);else if(l(this,r,e,n)){r.pendingcb++;o=p(this,r,e,t,n)}return o};c.prototype.cork=function(){var e=this._writableState;e.corked++};c.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)w(this,e)}};function u(e,t,n){if(!e.objectMode&&e.decodeStrings!==false&&i.isString(t)){t=new r(t,n)}return t}function p(e,t,n,r,o){n=u(t,n,r);if(i.isBuffer(n))r="buffer";var s=t.objectMode?1:n.length;t.length+=s;var c=t.length<t.highWaterMark;if(!c)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new a(n,r,o));else d(e,t,false,s,n,r,o);return c}function d(e,t,n,r,i,o,a){t.writelen=r;t.writecb=a;t.writing=true;t.sync=true;if(n)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function h(e,t,r,i,o){if(r)n.nextTick(function(){t.pendingcb--;o(i)});else{t.pendingcb--;o(i)}e._writableState.errorEmitted=true;e.emit("error",i)}function v(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var r=e._writableState;var i=r.sync;var o=r.writecb;v(r);if(t)h(e,r,i,t,o);else{var a=b(e,r);if(!a&&!r.corked&&!r.bufferProcessing&&r.buffer.length){w(e,r)}if(i){n.nextTick(function(){g(e,r,a,o)})}else{g(e,r,a,o)}}}function g(e,t,n,r){if(!n)y(e,t);t.pendingcb--;r();x(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function w(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var n=[];for(var r=0;r<t.buffer.length;r++)n.push(t.buffer[r].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var r=0;r<n.length;r++){t.pendingcb--;n[r](e)}});t.buffer=[]}else{for(var r=0;r<t.buffer.length;r++){var i=t.buffer[r];var o=i.chunk;var a=i.encoding;var s=i.callback;var c=t.objectMode?1:o.length;d(e,t,false,c,o,a,s);if(t.writing){r++;break}}if(r<t.buffer.length)t.buffer=t.buffer.slice(r);else t.buffer.length=0}t.bufferProcessing=false}c.prototype._write=function(e,t,n){n(new Error("not implemented"))};c.prototype._writev=null;c.prototype.end=function(e,t,n){var r=this._writableState;if(i.isFunction(e)){n=e;e=null;t=null}else if(i.isFunction(t)){n=t;t=null}if(!i.isNullOrUndefined(e))this.write(e,t);if(r.corked){r.corked=1;this.uncork()}if(!r.ending&&!r.finished)k(this,r,n)};function b(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function _(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function x(e,t){var n=b(e,t);if(n){if(t.pendingcb===0){_(e,t);t.finished=true;e.emit("finish")}else _(e,t)}return n}function k(e,t,r){t.ending=true;x(e,t);if(r){if(t.finished)n.nextTick(r);else e.once("finish",r)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":71,_process:29,buffer:31,"core-util-is":33,inherits:49,stream:86}],76:[function(e,t,n){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":72}],77:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js");n.Stream=e("stream");n.Readable=n;n.Writable=e("./lib/_stream_writable.js");n.Duplex=e("./lib/_stream_duplex.js");n.Transform=e("./lib/_stream_transform.js");n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":71,"./lib/_stream_passthrough.js":72,"./lib/_stream_readable.js":73,"./lib/_stream_transform.js":74,"./lib/_stream_writable.js":75,stream:86}],78:[function(e,t,n){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":74}],79:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":75}],80:[function(e,t,n){var r=e("dezalgo");t.exports=function(e,t){if(t)t=r(t);var n,i,o;if(Array.isArray(e)){n=[];i=e.length}else{o=Object.keys(e);n={};i=o.length}function a(e,r,o){n[e]=o;if(--i===0||r){if(t)t(r,n);t=null}}if(!i){if(t)t(null,n);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:38}],81:[function(e,t,n){(function(e){(function(){var n={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 r(e){"use strict";var t={fill:0};var o=function(e){for(e+=9;e%64>0;e+=1);return e};var a=function(e,t){for(var n=t>>2;n<e.length;n++)e[n]=0};var s=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=n>>29;e[((t>>2)+2&~15)+15]=n<<3};var c=function(e,t,n,r,i){var o=this,a,s=i%4,c=r%4,f=r-c;if(f>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(n);case 1:e[i+2|0]=o.charCodeAt(n+1);case 2:e[i+1|0]=o.charCodeAt(n+2);case 3:e[i|0]=o.charCodeAt(n+3)}}for(a=s;a<f;a=a+4|0){t[i+a>>2]=o.charCodeAt(n+a)<<24|o.charCodeAt(n+a+1)<<16|o.charCodeAt(n+a+2)<<8|o.charCodeAt(n+a+3)}switch(c){case 3:e[i+f+1|0]=o.charCodeAt(n+f+2);case 2:e[i+f+2|0]=o.charCodeAt(n+f+1);case 1:e[i+f+3|0]=o.charCodeAt(n+f)}};var f=function(e,t,n,r,i){var o=this,a,s=i%4,c=r%4,f=r-c;if(f>0){switch(s){case 0:e[i+3|0]=o[n];case 1:e[i+2|0]=o[n+1];case 2:e[i+1|0]=o[n+2];case 3:e[i|0]=o[n+3]}}for(a=4-s;a<f;a=a+=4|0){t[i+a>>2]=o[n+a]<<24|o[n+a+1]<<16|o[n+a+2]<<8|o[n+a+3]}switch(c){case 3:e[i+f+1|0]=o[n+f+2];case 2:e[i+f+2|0]=o[n+f+1];case 1:e[i+f+3|0]=o[n+f]}};var l=function(e,t,n,r,o){var a=this,s,c=o%4,f=r%4,l=r-f;var u=new Uint8Array(i.readAsArrayBuffer(a.slice(n,n+r)));if(l>0){switch(c){case 0:e[o+3|0]=u[0];case 1:e[o+2|0]=u[1];case 2:e[o+1|0]=u[2];case 3:e[o|0]=u[3]}}for(s=4-c;s<l;s=s+=4|0){t[o+s>>2]=u[s]<<24|u[s+1]<<16|u[s+2]<<8|u[s+3]}switch(f){case 3:e[o+l+1|0]=u[l+2];case 2:e[o+l+2|0]=u[l+1];case 1:e[o+l+3|0]=u[l]}};var u=function(e){switch(n.getDataType(e)){case"string":return c.bind(e);case"array":return f.bind(e);case"buffer":return f.bind(e);case"arraybuffer":return f.bind(new Uint8Array(e));case"view":return f.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return l.bind(e)}};var p=function(e,t){switch(n.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,n,r="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){n=o[t];i[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15)}return i.join("")};var h=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var v=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=o(e);t.heap=new ArrayBuffer(h(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=new r._core({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};v(e||64*1024);var m=function(e,t){var n=new Int32Array(e,t+320,5);n[0]=1732584193;n[1]=-271733879;n[2]=-1732584194;n[3]=271733878;n[4]=-1009589776};var g=function(e,n){var r=o(e);var i=new Int32Array(t.heap,0,r>>2);a(i,e);s(i,e,n);return r};var y=function(e,n,r){u(e)(t.h8,t.h32,n,r,0)};var w=function(e,n,r,i,o){var a=r;if(o){a=g(r,i)}y(e,n,r);t.core.hash(a,t.padMaxChunkLen)};var b=function(e,t){var n=new Int32Array(e,t+320,5);var r=new Int32Array(5);var i=new DataView(r.buffer);i.setInt32(0,n[0],false);i.setInt32(4,n[1],false);i.setInt32(8,n[2],false);i.setInt32(12,n[3],false);i.setInt32(16,n[4],false);return r};var _=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var r=0,i=t.maxChunkLen,o;for(r=0;n>r+i;r+=i){w(e,r,i,n,false)}w(e,r,n-r,n,true);return b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(_(e).buffer)}}r._core=function a(e,t,n){"use asm";var r=new e.Int32Array(n);function i(e,t){e=e|0;t=t|0;var n=0,i=0,o=0,a=0,s=0,c=0,f=0,l=0,u=0,p=0,d=0,h=0,v=0,m=0;o=r[t+320>>2]|0;s=r[t+324>>2]|0;f=r[t+328>>2]|0;u=r[t+332>>2]|0;d=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){a=o;c=s;l=f;p=u;h=d;for(i=0;(i|0)<64;i=i+4|0){m=r[n+i>>2]|0;v=((o<<5|o>>>27)+(s&f|~s&u)|0)+((m+d|0)+1518500249|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s&f|~s&u)|0)+((m+d|0)+1518500249|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s^f^u)|0)+((m+d|0)+1859775393|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s&f|s&u|f&u)|0)+((m+d|0)-1894007588|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s^f^u)|0)+((m+d|0)-899497514|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}o=o+a|0;s=s+c|0;f=f+l|0;u=u+p|0;d=d+h|0}r[t+320>>2]=o;r[t+324>>2]=s;r[t+328>>2]=f;r[t+332>>2]=u;r[t+336>>2]=d}return{hash:i}};if(typeof t!=="undefined"){t.exports=r}else if(typeof window!=="undefined"){window.Rusha=r}if(typeof FileReaderSync!=="undefined"){var i=new FileReaderSync,o=new r(4*1024*1024);self.onmessage=function s(e){var t,n=e.data.data;try{t=o.digest(n);self.postMessage({id:e.data.id,hash:t})}catch(r){self.postMessage({id:e.data.id,error:r.name})}}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],82:[function(e,t,n){(function(n){t.exports=u;var r=e("debug")("simple-peer");var i=e("get-browser-rtc");var o=e("hat");var a=e("inherits");var s=e("is-typedarray");var c=e("once");var f=e("stream");var l=e("typedarray-to-buffer");a(u,f.Duplex);function u(e){var t=this;if(!(t instanceof u))return new u(e);t._debug("new peer %o",e);if(!e)e={};e.allowHalfOpen=false;if(e.highWaterMark==null)e.highWaterMark=1024*1024;f.Duplex.call(t,e);t.initiator=e.initiator||false;t.channelConfig=e.channelConfig||u.channelConfig;t.channelName=e.channelName||o(160);if(!e.initiator)t.channelName=null;t.config=e.config||u.config;t.constraints=e.constraints||u.constraints;t.reconnectTimer=e.reconnectTimer||0;t.sdpTransform=e.sdpTransform||function(e){return e};t.stream=e.stream||false;t.trickle=e.trickle!==undefined?e.trickle:true;t.destroyed=false;t.connected=false;t.remoteAddress=undefined;t.remoteFamily=undefined;t.remotePort=undefined;t.localAddress=undefined;t.localPort=undefined;t._wrtc=e.wrtc||i();if(!t._wrtc){if(typeof window==="undefined"){throw new Error("No WebRTC support: Specify `opts.wrtc` option in this environment")}else{throw new Error("No WebRTC support: Not a supported browser")}}t._maxBufferedAmount=e.highWaterMark;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._chunk=null;t._cb=null;t._interval=null;t._reconnectTimeout=null;t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints);t._pc.oniceconnectionstatechange=t._onIceConnectionStateChange.bind(t);t._pc.onsignalingstatechange=t._onSignalingStateChange.bind(t);t._pc.onicecandidate=t._onIceCandidate.bind(t);if(t.stream)t._pc.addStream(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)});t._pc.onnegotiationneeded=c(t._createOffer.bind(t));if(typeof window==="undefined"||!window.webkitRTCPeerConnection){t._pc.onnegotiationneeded()}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){setTimeout(function(){t._destroy()},100)}else{t.once("connect",function(){setTimeout(function(){t._destroy()},100)})}})}u.WEBRTC_SUPPORT=!!i();u.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};u.constraints={};u.channelConfig={};Object.defineProperty(u.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});u.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};u.prototype.signal=function(e){var t=this;if(t.destroyed)throw new Error("cannot signal after peer is destroyed");if(typeof e==="string"){try{e=JSON.parse(e)}catch(n){e={}}}t._debug("signal()");if(e.sdp){t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){if(t.destroyed)return;if(t._pc.remoteDescription.type==="offer")t._createAnswer()},t._onError.bind(t))}if(e.candidate){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e.candidate),p,t._onError.bind(t))}catch(n){t._destroy(new Error("error adding candidate: "+n.message))}}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};u.prototype.send=function(e){var t=this;if(!s.strict(e)&&!(e instanceof ArrayBuffer)&&!n.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}if(n.isBuffer(e)&&!s.strict(e)){e=new Uint8Array(e)}var r=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",r)};u.prototype.destroy=function(e){var t=this;t._destroy(null,e)};u.prototype._destroy=function(e,t){
-var n=this;if(n.destroyed)return;if(t)n.once("close",t);n._debug("destroy (error: %s)",e&&e.message);n.readable=n.writable=false;if(!n._readableState.ended)n.push(null);if(!n._writableState.finished)n.end();n.destroyed=true;n.connected=false;n._pcReady=false;n._channelReady=false;n._chunk=null;n._cb=null;clearInterval(n._interval);clearTimeout(n._reconnectTimeout);if(n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null;n._pc.onsignalingstatechange=null;n._pc.onicecandidate=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null;n._channel.onopen=null;n._channel.onclose=null}n._pc=null;n._channel=null;if(e)n.emit("error",e);n.emit("close")};u.prototype._setupData=function(e){var t=this;t._channel=e.channel;t.channelName=t._channel.label;t._channel.binaryType="arraybuffer";t._channel.onmessage=t._onChannelMessage.bind(t);t._channel.onopen=t._onChannelOpen.bind(t);t._channel.onclose=t._onChannelClose.bind(t)};u.prototype._read=function(){};u.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after peer is destroyed"));if(r.connected){r.send(e);if(r._channel.bufferedAmount>r._maxBufferedAmount){r._debug("start backpressure: bufferedAmount %d",r._channel.bufferedAmount);r._cb=n}else{n(null)}}else{r._debug("write before connect");r._chunk=e;r._cb=n}};u.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,p,e._onError.bind(e));var n=function(){var n=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:n.type,sdp:n.sdp})};if(e.trickle||e._iceComplete)n();else e.once("_iceComplete",n)},e._onError.bind(e),e.offerConstraints)};u.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,p,e._onError.bind(e));var n=function(){var n=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:n.type,sdp:n.sdp})};if(e.trickle||e._iceComplete)n();else e.once("_iceComplete",n)},e._onError.bind(e),e.answerConstraints)};u.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var n=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,n);e.emit("iceConnectionStateChange",t,n);if(n==="connected"||n==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(n==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(n==="closed"){e._destroy()}};u.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 n=[];e.forEach(function(e){n.push(e)});t(n)},e._onError.bind(e))}else{e._pc.getStats(function(e){var n=[];e.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;n.push(t)});t(n)})}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 n=e._cb;e._cb=null;n(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")}};u.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};u.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};u.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var n=e.data;t._debug("read: %d bytes",n.byteLength||n.length);if(n instanceof ArrayBuffer){n=l(new Uint8Array(n));t.push(n)}else{try{n=JSON.parse(n)}catch(r){}t.emit("data",n)}};u.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};u.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};u.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};u.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};u.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var n=e.channelName&&e.channelName.substring(0,7);t[0]="["+n+"] "+t[0];r.apply(null,t)};function p(){}}).call(this,e("buffer").Buffer)},{buffer:31,debug:35,"get-browser-rtc":43,hat:44,inherits:49,"is-typedarray":52,once:59,stream:86,"typedarray-to-buffer":91}],83:[function(e,t,n){var r=e("rusha");var i=new r;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(c){a=false}function f(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=l(e)}a.digest({name:"sha-1"},e).then(function n(e){t(u(new Uint8Array(e)))},function r(n){t(s(e))})}function l(e){var t=e.length;var n=new Uint8Array(t);for(var r=0;r<t;r++){n[r]=e.charCodeAt(r)}return n}function u(e){var t=e.length;var n=[];for(var r=0;r<t;r++){var i=e[r];n.push((i>>>4).toString(16));n.push((i&15).toString(16))}return n.join("")}t.exports=f;t.exports.sync=s},{rusha:81}],84:[function(e,t,n){(function(n){t.exports=l;var r=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var c=e("ws");var f=typeof window!=="undefined"?window.WebSocket:c;i(l,a.Duplex);function l(e,t){var n=this;if(!(n instanceof l))return new l(e,t);if(!t)t={};r("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(n,t);n.url=e;n.connected=false;n.destroyed=false;n._maxBufferedAmount=t.highWaterMark;n._chunk=null;n._cb=null;n._interval=null;n._ws=new f(n.url);n._ws.binaryType="arraybuffer";n._ws.onopen=n._onOpen.bind(n);n._ws.onmessage=n._onMessage.bind(n);n._ws.onclose=n._onClose.bind(n);n._ws.onerror=n._onError.bind(n);n.on("finish",function(){if(n.connected){setTimeout(function(){n._destroy()},100)}else{n.once("connect",function(){setTimeout(function(){n._destroy()},100)})}})}l.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!n.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);r("write: %d bytes",i)};l.prototype.destroy=function(e){var t=this;t._destroy(null,e)};l.prototype._destroy=function(e,t){var n=this;if(n.destroyed)return;if(t)n.once("close",t);r("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!n._readableState.ended)n.push(null);if(!n._writableState.finished)n.end();n.connected=false;n.destroyed=true;clearInterval(n._interval);n._interval=null;n._chunk=null;n._cb=null;if(n._ws){try{n._ws.close()}catch(e){}n._ws.onopen=null;n._ws.onmessage=null;n._ws.onclose=null;n._ws.onerror=null}n._ws=null;if(e)n.emit("error",e);n.emit("close")};l.prototype._read=function(){};l.prototype._write=function(e,t,n){var i=this;if(i.destroyed)return n(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof c!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){r("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=n}else{n(null)}}else{r("write before connect");i._chunk=e;i._cb=n}};l.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;r("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(n.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};l.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;r('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof c!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}r("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}r("connect");e.emit("connect")};l.prototype._onClose=function(){var e=this;if(e.destroyed)return;r("on close");e._destroy()};l.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);r("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:31,debug:35,inherits:49,"is-typedarray":52,stream:86,"typedarray-to-buffer":91,ws:27}],85:[function(e,t,n){var r=1;var i=65535;var o=4;var a=function(){r=r+1&i};var s=setInterval(a,1e3/o|0);if(s.unref)s.unref();t.exports=function(e){var t=o*(e||5);var n=[0];var a=1;var s=r-1&i;return function(e){var c=r-s&i;if(c>t)c=t;s=r;while(c--){if(a===t)a=0;n[a]=n[a===0?t-1:a-1];a++}if(e)n[a-1]+=e;var f=n[a-1];var l=n.length<t?0:n[a===t?0:a];return n.length<o?f:(f-l)*o/n.length}}},{}],86:[function(e,t,n){t.exports=o;var r=e("events").EventEmitter;var i=e("inherits");i(o,r);o.Readable=e("readable-stream/readable.js");o.Writable=e("readable-stream/writable.js");o.Duplex=e("readable-stream/duplex.js");o.Transform=e("readable-stream/transform.js");o.PassThrough=e("readable-stream/passthrough.js");o.Stream=o;function o(){r.call(this)}o.prototype.pipe=function(e,t){var n=this;function i(t){if(e.writable){if(false===e.write(t)&&n.pause){n.pause()}}}n.on("data",i);function o(){if(n.readable&&n.resume){n.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){n.on("end",s);n.on("close",c)}var a=false;function s(){if(a)return;a=true;e.end()}function c(){if(a)return;a=true;if(typeof e.destroy==="function")e.destroy()}function f(e){l();if(r.listenerCount(this,"error")===0){throw e}}n.on("error",f);e.on("error",f);function l(){n.removeListener("data",i);e.removeListener("drain",o);n.removeListener("end",s);n.removeListener("close",c);n.removeListener("error",f);e.removeListener("error",f);n.removeListener("end",l);n.removeListener("close",l);e.removeListener("close",l)}n.on("end",l);n.on("close",l);e.on("close",l);e.emit("pipe",n);return e}},{events:40,inherits:49,"readable-stream/duplex.js":70,"readable-stream/passthrough.js":76,"readable-stream/readable.js":77,"readable-stream/transform.js":78,"readable-stream/writable.js":79}],87:[function(e,t,n){var r=e("buffer").Buffer;var i=r.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function o(e){if(e&&!i(e)){throw new Error("Unknown encoding: "+e)}}var a=n.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");o(e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=c;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=f;break;default:this.write=s;return}this.charBuffer=new r(6);this.charReceived=0;this.charLength=0};a.prototype.write=function(e){var t="";while(this.charLength){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,n);this.charReceived+=n;if(this.charReceived<this.charLength){return""}e=e.slice(n,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var r=t.charCodeAt(t.length-1);if(r>=55296&&r<=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 r=t.charCodeAt(i);if(r>=55296&&r<=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 n=e[e.length-t];if(t==1&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>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 n=this.charReceived;var r=this.charBuffer;var i=this.encoding;t+=r.slice(0,n).toString(i)}return t};function s(e){return e.toString(this.encoding)}function c(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function f(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:31}],88:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode;n.decode=r.decode},{"./thirty-two":89}],89:[function(e,t,n){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var r=[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}n.encode=function(n){var r=0;var o=0;var a=0;var s=0;var c=new e(i(n)*8);if(!e.isBuffer(n)){n=new e(n)}while(r<n.length){var f=n[r];if(a>3){s=f&255>>a;a=(a+5)%8;s=s<<a|(r+1<n.length?n[r+1]:0)>>8-a;r++}else{s=f>>8-(a+5)&31;a=(a+5)%8;if(a==0)r++}c[o]=t.charCodeAt(s);o++}for(r=o;r<c.length;r++)c[r]=61;return c};n.decode=function(t){var n=0;var i=0;var o;var a=0;if(!e.isBuffer(t)){t=new e(t)}var s=new e(Math.ceil(t.length*5/8));for(var c=0;c<t.length;c++){if(t[c]==61){break}var f=t[c]-48;if(f<r.length){i=r[f];if(n<=3){n=(n+5)%8;if(n==0){o|=i;s[a]=o;a++;o=0}else{o|=255&i<<8-n}}else{n=(n+5)%8;o|=255&i>>>n;s[a]=o;a++;o=255&i<<8-n}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:31}],90:[function(e,t,n){(function(n){t.exports=l;var r=e("debug")("torrent-discovery");var i=e("bittorrent-dht/client");var o=e("events").EventEmitter;var a=e("xtend/mutable");var s=e("inherits");var c=e("re-emitter");var f=e("bittorrent-tracker/client");s(l,o);function l(e){var t=this;if(!(t instanceof l))return new l(e);o.call(t);a(t,{announce:[],dht:typeof i==="function",rtcConfig:null,peerId:null,port:0,tracker:true,wrtc:null},e);t._externalDHT=typeof t.dht==="object";t._performedDHTLookup=false;if(!t.peerId)throw new Error("peerId required");if(!n.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}l.prototype.setTorrent=function(e){var t=this;if(t.torrent)return;if(e&&e.infoHash){t.torrent=e;t.infoHash=e.infoHash}else{if(t.infoHash)return;t.infoHash=e}r("setTorrent %s",t.infoHash);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}if(t.dht){if(t.dht.ready)t._dhtLookupAndAnnounce();else t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t))}};l.prototype.stop=function(e){var t=this;if(t.tracker){if(t.tracker.stop)t.tracker.stop();if(t.tracker.destroy)t.tracker.destroy()}if(!t._externalDHT&&t.dht&&t.dht.destroy)t.dht.destroy(e);else n.nextTick(function(){e(null)})};l.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new i;c(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,n){if(n===t.infoHash)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};l.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};var n={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new f(e.peerId,e.port,t,n);c(e.tracker,e,["peer","warning","error"]);e.tracker.start()};l.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;r("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;r("dht announce");e.dht.announce(e.infoHash,e.port,function(){r("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"))},{_process:29,"bittorrent-dht/client":27,"bittorrent-tracker/client":22,debug:35,events:40,inherits:49,"re-emitter":69,"xtend/mutable":99}],91:[function(e,t,n){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){var t=n.TYPED_ARRAY_SUPPORT?n._augment:function(e){return new n(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(r(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new n(e)}}}).call(this,e("buffer").Buffer)},{buffer:31,"is-typedarray":52}],92:[function(e,t,n){"use strict";function r(e,t){var n=1,r=e.length,i=e[0],o=e[0];for(var a=1;a<r;++a){o=i;i=e[a];if(t(i,o)){if(a===n){n++;continue}e[n++]=i}}e.length=n;return e}function i(e){var t=1,n=e.length,r=e[0],i=e[0];for(var o=1;o<n;++o,i=r){i=r;r=e[o];if(r!==i){if(o===t){t++;continue}e[t++]=r}}e.length=t;return e}function o(e,t,n){if(e.length===0){return e}if(t){if(!n){e.sort(t)}return r(e,t)}if(!n){e.sort()}return i(e)}t.exports=o},{}],93:[function(e,t,n){var r=e("punycode");n.parse=w;n.resolve=_;n.resolveObject=x;n.format=b;n.Url=i;function i(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,s=["<",">",'"',"`"," ","\r","\n"," "],c=["{","}","|","\\","^","`"].concat(s),f=["'"].concat(c),l=["%","/","?",";","#"].concat(f),u=["/","?","#"],p=255,d=/^[a-z0-9A-Z_-]{0,63}$/,h=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},g={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function w(e,t,n){if(e&&E(e)&&e instanceof i)return e;var r=new i;r.parse(e,t,n);return r}i.prototype.parse=function(e,t,n){if(!k(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(n||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var c=i.substr(0,2)==="//";if(c&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(c||a&&!g[a])){var w=-1;for(var b=0;b<u.length;b++){var _=i.indexOf(u[b]);if(_!==-1&&(w===-1||_<w))w=_}var x,E;if(w===-1){E=i.lastIndexOf("@")}else{E=i.lastIndexOf("@",w)}if(E!==-1){x=i.slice(0,E);i=i.slice(E+1);this.auth=decodeURIComponent(x)}w=-1;for(var b=0;b<l.length;b++){var _=i.indexOf(l[b]);if(_!==-1&&(w===-1||_<w))w=_}if(w===-1)w=i.length;this.host=i.slice(0,w);i=i.slice(w);this.parseHost();this.hostname=this.hostname||"";var S=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!S){var A=this.hostname.split(/\./);for(var b=0,T=A.length;b<T;b++){var C=A[b];if(!C)continue;if(!C.match(d)){var I="";for(var j=0,L=C.length;j<L;j++){if(C.charCodeAt(j)>127){I+="x"}else{I+=C[j]}}if(!I.match(d)){var R=A.slice(0,b);var B=A.slice(b+1);var P=C.match(h);if(P){R.push(P[1]);B.unshift(P[2])}if(B.length){i="/"+B.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>p){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var O=this.hostname.split(".");var M=[];for(var b=0;b<O.length;++b){var U=O[b];M.push(U.match(/[^A-Za-z0-9_-]/)?"xn--"+r.encode(U):U)}this.hostname=M.join(".")}var z=this.port?":"+this.port:"";var H=this.hostname||"";this.host=H+z;this.href+=this.host;if(S){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(i[0]!=="/"){i="/"+i}}}if(!v[s]){for(var b=0,T=f.length;b<T;b++){var N=f[b];var q=encodeURIComponent(N);if(q===N){q=escape(N)}i=i.split(N).join(q)}}var D=i.indexOf("#");if(D!==-1){this.hash=i.substr(D);i=i.slice(0,D)}var F=i.indexOf("?");if(F!==-1){this.search=i.substr(F);this.query=i.substr(F+1);if(t){this.query=y.parse(this.query)}i=i.slice(0,F)}else if(t){this.search="";this.query={}}if(i)this.pathname=i;if(g[s]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var z=this.pathname||"";var U=this.search||"";this.path=z+U}this.href=this.format();return this};function b(e){if(k(e))e=w(e);if(!(e instanceof i))return i.prototype.format.call(e);return e.format()}i.prototype.format=function(){var e=this.auth||"";if(e){e=encodeURIComponent(e);e=e.replace(/%3A/i,":");e+="@"}var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=false,o="";if(this.host){i=e+this.host}else if(this.hostname){i=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){i+=":"+this.port}}if(this.query&&E(this.query)&&Object.keys(this.query).length){o=y.stringify(this.query)}var a=this.search||o&&"?"+o||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||g[t])&&i!==false){i="//"+(i||"");if(n&&n.charAt(0)!=="/")n="/"+n}else if(!i){i=""}if(r&&r.charAt(0)!=="#")r="#"+r;if(a&&a.charAt(0)!=="?")a="?"+a;n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)});a=a.replace("#","%23");return t+i+n+a+r};function _(e,t){return w(e,false,true).resolve(t)}i.prototype.resolve=function(e){return this.resolveObject(w(e,false,true)).format()};function x(e,t){if(!e)return t;return w(e,false,true).resolveObject(t)}i.prototype.resolveObject=function(e){if(k(e)){var t=new i;t.parse(e,false,true);e=t}var n=new i;Object.keys(this).forEach(function(e){n[e]=this[e]},this);n.hash=e.hash;if(e.href===""){n.href=n.format();return n}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")n[t]=e[t]});if(g[n.protocol]&&n.hostname&&!n.pathname){n.path=n.pathname="/"}n.href=n.format();return n}if(e.protocol&&e.protocol!==n.protocol){if(!g[e.protocol]){Object.keys(e).forEach(function(t){n[t]=e[t]});n.href=n.format();return n}n.protocol=e.protocol;if(!e.host&&!m[e.protocol]){var r=(e.pathname||"").split("/");while(r.length&&!(e.host=r.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(r[0]!=="")r.unshift("");if(r.length<2)r.unshift("");n.pathname=r.join("/")}else{n.pathname=e.pathname}n.search=e.search;n.query=e.query;n.host=e.host||"";n.auth=e.auth;n.hostname=e.hostname||e.host;n.port=e.port;if(n.pathname||n.search){var o=n.pathname||"";var a=n.search||"";n.path=o+a}n.slashes=n.slashes||e.slashes;n.href=n.format();return n}var s=n.pathname&&n.pathname.charAt(0)==="/",c=e.host||e.pathname&&e.pathname.charAt(0)==="/",f=c||s||n.host&&e.pathname,l=f,u=n.pathname&&n.pathname.split("/")||[],r=e.pathname&&e.pathname.split("/")||[],p=n.protocol&&!g[n.protocol];if(p){n.hostname="";n.port=null;if(n.host){if(u[0]==="")u[0]=n.host;else u.unshift(n.host)}n.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(r[0]==="")r[0]=e.host;else r.unshift(e.host)}e.host=null}f=f&&(r[0]===""||u[0]==="")}if(c){n.host=e.host||e.host===""?e.host:n.host;n.hostname=e.hostname||e.hostname===""?e.hostname:n.hostname;n.search=e.search;n.query=e.query;u=r}else if(r.length){if(!u)u=[];u.pop();u=u.concat(r);n.search=e.search;n.query=e.query}else if(!A(e.search)){if(p){n.hostname=n.host=u.shift();var d=n.host&&n.host.indexOf("@")>0?n.host.split("@"):false;if(d){n.auth=d.shift();n.host=n.hostname=d.shift()}}n.search=e.search;n.query=e.query;if(!S(n.pathname)||!S(n.search)){n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")}n.href=n.format();return n}if(!u.length){n.pathname=null;if(n.search){n.path="/"+n.search}else{n.path=null}n.href=n.format();return n}var h=u.slice(-1)[0];var v=(n.host||e.host)&&(h==="."||h==="..")||h==="";var y=0;for(var w=u.length;w>=0;w--){h=u[w];if(h=="."){u.splice(w,1)}else if(h===".."){u.splice(w,1);y++}else if(y){u.splice(w,1);y--}}if(!f&&!l){for(;y--;y){u.unshift("..")}}if(f&&u[0]!==""&&(!u[0]||u[0].charAt(0)!=="/")){u.unshift("")}if(v&&u.join("/").substr(-1)!=="/"){u.push("")}var b=u[0]===""||u[0]&&u[0].charAt(0)==="/";if(p){n.hostname=n.host=b?"":u.length?u.shift():"";var d=n.host&&n.host.indexOf("@")>0?n.host.split("@"):false;if(d){n.auth=d.shift();n.host=n.hostname=d.shift()}}f=f||n.host&&u.length;if(f&&!b){u.unshift("")}if(!u.length){n.pathname=null;n.path=null}else{n.pathname=u.join("/")}if(!S(n.pathname)||!S(n.search)){n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")}n.auth=e.auth||n.auth;n.slashes=n.slashes||e.slashes;n.href=n.format();return n};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 k(e){return typeof e==="string"}function E(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:30,querystring:67}],94:[function(e,t,n){(function(n){var r=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var a=e("inherits");var s=e("simple-sha1");var c=1e7;var f=1e3;var l=16*1024;t.exports=function(e){a(t,o);function t(t){o.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new i(0,{grow:f});if(n.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,n){this._infoHash=e;this._infoHashHex=e.toString("hex")};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>c){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/l);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,n;try{var i=e.toString();var o=i.indexOf("ee")+2;t=r.decode(i.substring(0,o));n=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,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=r.decode(e).info;if(t){e=r.encode(t)}}catch(n){}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",r.encode({info:r.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=r.encode(e);if(n.isBuffer(t)){i=n.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,n){var r={msg_type:1,piece:e};if(typeof n==="number"){r.total_size=n}this._send(r,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*l;var n=t+l;if(n>this._metadataSize){n=this._metadataSize}var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)};t.prototype._onData=function(e,t,n){if(t.length>l){return}t.copy(this.metadata,e*l);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 n(this._metadataSize);for(var e=0;e<this._numPieces;e++){this._request(e)}};t.prototype._checkDone=function(){var e=true;for(var t=0;t<this._numPieces;t++){if(!this._bitfield.get(t)){e=false;break}}if(!e)return;var n=this.setMetadata(this.metadata);if(!n){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:f});this._remainingRejects-=this._numPieces;if(this._remainingRejects>0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:13,bitfield:17,buffer:31,events:40,inherits:49,"simple-sha1":83}],95:[function(e,t,n){t.exports=function r(e){return e&&typeof e==="object"&&typeof e.copy==="function"&&typeof e.fill==="function"&&typeof e.readUInt8==="function"}},{}],96:[function(e,t,n){(function(t,r){var i=/%[sdj%]/g;n.format=function(e){if(!x(e)){var t=[];for(var n=0;n<arguments.length;n++){t.push(s(arguments[n]))}return t.join(" ")}var n=1;var r=arguments;var o=r.length;var a=String(e).replace(i,function(e){if(e==="%%")return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}});for(var c=r[n];n<o;c=r[++n]){if(w(c)||!A(c)){a+=" "+c}else{a+=" "+s(c)}}return a};n.deprecate=function(e,i){if(E(r.process)){return function(){return n.deprecate(e,i).apply(this,arguments)}}if(t.noDeprecation===true){return e}var o=false;function a(){if(!o){if(t.throwDeprecation){throw new Error(i)}else if(t.traceDeprecation){console.trace(i)}else{console.error(i)}o=true}return e.apply(this,arguments)}return a};var o={};var a;n.debuglog=function(e){if(E(a))a=t.env.NODE_DEBUG||"";e=e.toUpperCase();if(!o[e]){if(new RegExp("\\b"+e+"\\b","i").test(a)){var r=t.pid;o[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else{o[e]=function(){}}}return o[e]};function s(e,t){var r={seen:[],stylize:f};if(arguments.length>=3)r.depth=arguments[2];if(arguments.length>=4)r.colors=arguments[3];if(y(t)){r.showHidden=t}else if(t){n._extend(r,t)}if(E(r.showHidden))r.showHidden=false;if(E(r.depth))r.depth=2;if(E(r.colors))r.colors=false;if(E(r.customInspect))r.customInspect=true;if(r.colors)r.stylize=c;return u(r,e,r.depth)}n.inspect=s;s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};s.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function c(e,t){var n=s.styles[t];if(n){return"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m"}else{return e}}function f(e,t){return e}function l(e){var t={};e.forEach(function(e,n){t[e]=true});return t}function u(e,t,r){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==n.inspect&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(r,e);if(!x(i)){i=u(e,i,r)}return i}var o=p(e,t);if(o){return o}var a=Object.keys(t);var s=l(a);if(e.showHidden){a=Object.getOwnPropertyNames(t)}if(C(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return d(t)}if(a.length===0){if(I(t)){var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special");
-}if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}if(T(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(C(t)){return d(t)}}var f="",y=false,w=["{","}"];if(g(t)){y=true;w=["[","]"]}if(I(t)){var b=t.name?": "+t.name:"";f=" [Function"+b+"]"}if(S(t)){f=" "+RegExp.prototype.toString.call(t)}if(T(t)){f=" "+Date.prototype.toUTCString.call(t)}if(C(t)){f=" "+d(t)}if(a.length===0&&(!y||t.length==0)){return w[0]+f+w[1]}if(r<0){if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(t);var _;if(y){_=h(e,t,r,s,a)}else{_=a.map(function(n){return v(e,t,r,s,n,y)})}e.seen.pop();return m(_,f,w)}function p(e,t){if(E(t))return e.stylize("undefined","undefined");if(x(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(_(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(w(t))return e.stylize("null","null")}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i){var o=[];for(var a=0,s=t.length;a<s;++a){if(O(t,String(a))){o.push(v(e,t,n,r,String(a),true))}else{o.push("")}}i.forEach(function(i){if(!i.match(/^\d+$/)){o.push(v(e,t,n,r,i,true))}});return o}function v(e,t,n,r,i,o){var a,s,c;c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(c.get){if(c.set){s=e.stylize("[Getter/Setter]","special")}else{s=e.stylize("[Getter]","special")}}else{if(c.set){s=e.stylize("[Setter]","special")}}if(!O(r,i)){a="["+i+"]"}if(!s){if(e.seen.indexOf(c.value)<0){if(w(n)){s=u(e,c.value,null)}else{s=u(e,c.value,n-1)}if(s.indexOf("\n")>-1){if(o){s=s.split("\n").map(function(e){return" "+e}).join("\n").substr(2)}else{s="\n"+s.split("\n").map(function(e){return" "+e}).join("\n")}}}else{s=e.stylize("[Circular]","special")}}if(E(a)){if(o&&i.match(/^\d+$/)){return s}a=JSON.stringify(""+i);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=e.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=e.stylize(a,"string")}}return a+": "+s}function m(e,t,n){var r=0;var i=e.reduce(function(e,t){r++;if(t.indexOf("\n")>=0)r++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(i>60){return n[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]}return n[0]+t+" "+e.join(", ")+" "+n[1]}function g(e){return Array.isArray(e)}n.isArray=g;function y(e){return typeof e==="boolean"}n.isBoolean=y;function w(e){return e===null}n.isNull=w;function b(e){return e==null}n.isNullOrUndefined=b;function _(e){return typeof e==="number"}n.isNumber=_;function x(e){return typeof e==="string"}n.isString=x;function k(e){return typeof e==="symbol"}n.isSymbol=k;function E(e){return e===void 0}n.isUndefined=E;function S(e){return A(e)&&L(e)==="[object RegExp]"}n.isRegExp=S;function A(e){return typeof e==="object"&&e!==null}n.isObject=A;function T(e){return A(e)&&L(e)==="[object Date]"}n.isDate=T;function C(e){return A(e)&&(L(e)==="[object Error]"||e instanceof Error)}n.isError=C;function I(e){return typeof e==="function"}n.isFunction=I;function j(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}n.isPrimitive=j;n.isBuffer=e("./support/isBuffer");function L(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}var B=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date;var t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":");return[e.getDate(),B[e.getMonth()],t].join(" ")}n.log=function(){console.log("%s - %s",P(),n.format.apply(n,arguments))};n.inherits=e("inherits");n._extend=function(e,t){if(!t||!A(t))return e;var n=Object.keys(t);var r=n.length;while(r--){e[n[r]]=t[n[r]]}return e};function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":95,_process:29,inherits:49}],97:[function(e,t,n){t.exports=r;function r(e,t){if(e&&t)return r(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){n[t]=e[t]});return n;function n(){var t=new Array(arguments.length);for(var n=0;n<t.length;n++){t[n]=arguments[n]}var r=e.apply(this,t);var i=t[t.length-1];if(typeof r==="function"&&r!==i){Object.keys(i).forEach(function(e){r[e]=i[e]})}return r}}},{}],98:[function(e,t,n){t.exports=r;function r(){var e={};for(var t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(n.hasOwnProperty(r)){e[r]=n[r]}}}return e}},{}],99:[function(e,t,n){t.exports=r;function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(n.hasOwnProperty(r)){e[r]=n[r]}}}return e}},{}],100:[function(e,t,n){t.exports=function r(e,t,n){if(t===undefined){return function(t,n){return r(e,t,n)}}if(n===undefined)n="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(n)+t;return t+""}},{}],101:[function(e,t,n){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.50.1",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./lib/server":false,"bittorrent-dht/client":false,"load-ip-set":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.1.0","pretty-bytes":"^2.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-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","simple-get":"^1.0.0",standard:"^4.0.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"}}},{}],102:[function(e,t,n){(function(n,r,i){t.exports=k;var o=e("create-torrent");var a=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var c=e("events").EventEmitter;var f=e("xtend");var l=e("hat");var u=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var v=e("speedometer");var m=e("zero-fill");var g=e("path");var y=e("./lib/fs-storage");var w=e("./lib/storage");var b=e("./lib/torrent");u(k,c);var _=e("./package.json").version;var x=_.match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");function k(e){var t=this;if(!(t instanceof k))return new k(e);if(!e)e={};c.call(t);if(!a.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||r.WRTC;t.torrents=[];t.downloadSpeed=v();t.uploadSpeed=v();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof y==="function"?y:w;t.peerId=e.peerId===undefined?new i("-WW"+x+"-"+l(48),"utf8"):typeof e.peerId==="string"?new i(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new i(l(160),"hex"):typeof e.nodeId==="string"?new i(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof s==="function"){t.dht=new s(f({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}a("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=n;o()})}else n.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(k.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var n=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/n}});k.prototype.get=function(e){var t=this;if(e instanceof b)return e;var n;try{n=h(e)}catch(r){return null}if(!n.infoHash)throw new Error("Invalid torrent identifier");for(var i=0,o=t.torrents.length;i<o;i++){var a=t.torrents[i];if(a.infoHash===n.infoHash)return a}return null};k.prototype.add=k.prototype.download=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");a("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};if(!t.storage)t.storage=i.storage;t.client=i;var o=i.get(e);function s(){a("on torrent");if(typeof r==="function")r(o)}if(o){if(o.ready)n.nextTick(s);else o.on("ready",s)}else{o=new b(e,t);i.torrents.push(o);o.on("error",function(e){i.emit("error",e,o);i.remove(o)});o.on("listening",function(e){i.emit("listening",e,o)});o.on("ready",function(){s();i.emit("torrent",o)})}return o};k.prototype.seed=function(e,t,n){var r=this;if(r.destroyed)throw new Error("client is destroyed");a("seed");if(typeof t==="function"){n=t;t={}}if(!t)t={};t.noVerify=true;t.createdBy="WebTorrent/"+_;if(typeof e==="string"&&!t.path)t.path=g.dirname(e);var i;var s=r.add(undefined,t,function(e){var t=[function(t){e.storage.load(i,t)}];if(r.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return r.emit("error",t);c();r.emit("seed",e)})});o.parseInput(e,t,function(n,a){if(n)return r.emit("error",n);i=a.map(function(e){return e.getStream});o(e,t,function(e,t){if(e)return r.emit("error",e);if(r.destroyed)return;var n=r.get(t);if(n){s.destroy();c();return}else{s._onTorrentId(t)}})});function c(){a("on seed");if(typeof n==="function")n(s)}return s};k.prototype.remove=function(e,t){var n=this;var r=n.get(e);if(!r)throw new Error("No torrent with id "+e);a("remove");n.torrents.splice(n.torrents.indexOf(r),1);r.destroy(t)};k.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};k.prototype.destroy=function(e){var t=this;t.destroyed=true;a("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e,n)}});if(t.dht){n.push(function(e){t.dht.destroy(e)})}d(n,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":27,"./lib/storage":6,"./lib/torrent":7,"./package.json":101,_process:29,"bittorrent-dht/client":27,buffer:31,"create-torrent":34,debug:35,events:40,hat:44,inherits:49,"load-ip-set":27,"parse-torrent":61,path:62,"run-parallel":80,speedometer:85,xtend:98,"zero-fill":100}]},{},[102])(102)});
+(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,n;return function r(e,t,n){function i(a,s){if(!t[a]){if(!e[a]){var c=typeof require=="function"&&require;if(!s&&c)return c(a,!0);if(o)return o(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return i(n?n:t)},l,l.exports,r,e,t,n)}return t[a].exports}var o=typeof require=="function"&&require;for(var a=0;a<n.length;a++)i(n[a]);return i}({1:[function(e,t,n){t.exports=c;var r=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("path");var a=e("stream");var s=e("./media-stream");i(c,a.Readable);function c(e,t){var n=this;if(!(n instanceof c))return new c(e,t);a.Readable.call(n,t);r("new filestream %s",JSON.stringify(t));if(!t)t={};if(!t.start)t.start=0;if(!t.end)t.end=e.length-1;n.destroyed=false;n.length=t.end-t.start+1;var i=t.start+e.offset;var s=t.pieceLength;n.startPiece=i/s|0;n.endPiece=(t.end+e.offset)/s|0;n._extname=o.extname(e.name).toLowerCase();n._storage=e.storage;n._piece=n.startPiece;n._missing=n.length;n._reading=false;n._notifying=false;n._criticalLength=Math.min(1024*1024/s|0,2);n._offset=i-n.startPiece*s}c.prototype._read=function(){var e=this;r("_read");if(e._reading)return;e._reading=true;e.notify()};c.prototype.notify=function(){var e=this;r("notify");if(!e._reading||e._missing===0)return;if(!e._storage.bitfield.get(e._piece)){return e._storage.emit("critical",e._piece,e._piece+e._criticalLength)}if(e._notifying)return;e._notifying=true;var t=e._piece;r("before read %s",t);e._storage.read(e._piece++,function(n,i){r("after read %s (length %s) (err %s)",t,i.length,n&&n.message);e._notifying=false;if(e.destroyed)return;if(n){e._storage.emit("error",n);return e.destroy(n)}if(e._offset){i=i.slice(e._offset);e._offset=0}if(e._missing<i.length){i=i.slice(0,e._missing)}e._missing-=i.length;r("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)})};c.prototype.pipe=function(e){var t=this;var n=a.Readable.prototype.pipe;if(e&&(e.nodeName==="VIDEO"||e.nodeName==="AUDIO")){var r={".webm":'video/webm; codecs="vorbis,vp8"',".mp4":'video/mp4; codecs="avc1.42c01e,mp4a.40.2"',".mp3":"audio/mpeg"}[t._extname];return n.call(t,new s(e,{type:r}))}else{return n.call(t,e)}};c.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;e._storage.emit("deselect",e.startPiece,e.endPiece,true)}},{"./media-stream":2,debug:35,inherits:49,path:62,stream:86}],2:[function(e,t,n){t.exports=c;var r=e("debug")("webtorrent:media-stream");var i=e("inherits");var o=e("once");var a=e("stream");var s=typeof window!=="undefined"&&window.MediaSource;i(c,a.Writable);function c(e,t){var n=this;if(!(n instanceof c))return new c(e,t);a.Writable.call(n,t);if(!s)throw new Error("web browser lacks MediaSource support");n.media=e;t=t||{};t.type=t.type||'video/webm; codecs="vorbis,vp8"';r("new mediastream %s %s",e,JSON.stringify(t));n._mediaSource=new s;n._sourceBuffer=null;n._cb=null;n.media.src=window.URL.createObjectURL(n._mediaSource);var i=o(function(){n._sourceBuffer=n._mediaSource.addSourceBuffer(t.type);n._sourceBuffer.addEventListener("updateend",n._flow.bind(n));n._flow()});n._mediaSource.addEventListener("webkitsourceopen",i,false);n._mediaSource.addEventListener("sourceopen",i,false);n.on("finish",function(){r("finish");n._mediaSource.endOfStream()});window.vs=n}c.prototype._write=function(e,t,n){var i=this;if(!i._sourceBuffer){i._cb=function(r){if(r)return n(r);i._write(e,t,n)};return}if(i._sourceBuffer.updating){return n(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);r("appendBuffer %s",e.length);i._cb=n};c.prototype._flow=function(){var e=this;r("flow");if(e._cb){e._cb(null)}}},{debug:35,inherits:49,once:59,stream:86}],3:[function(e,t,n){t.exports={".aac":"audio/aac",".css":"text/css",".html":"text/html",".js":"application/javascript",".m4a":"audio/mp4",".md":"text/x-markdown",".mp3":"audio/mpeg",".mp4":"video/mp4",".oga":"audio/ogg",".ogg":"audio/ogg",".pdf":"application/pdf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm"}},{}],4:[function(e,t,n){t.exports=r;function r(e,t){var n=this;n.swarm=e;n.numPieces=t;function r(e){e.on("have",function(e){n.pieces[e]++});e.on("bitfield",n.recalculate.bind(n));e.on("close",function(){for(var t=0;t<n.numPieces;++t){n.pieces[t]-=e.peerPieces.get(t)}})}n.swarm.wires.forEach(r);n.swarm.on("wire",function(e){n.recalculate();r(e)});n.recalculate()}r.prototype.recalculate=function(){var e=this;e.pieces=[];for(var t=0;t<e.numPieces;++t){e.pieces[t]=0}e.swarm.wires.forEach(function(t){for(var n=0;n<e.numPieces;++n){e.pieces[n]+=t.peerPieces.get(n)}})};r.prototype.getRarestPiece=function(e){var t=this;var n=[];var r=Infinity;e=e||function(){return true};for(var i=0;i<t.numPieces;++i){if(!e(i))continue;var o=t.pieces[i];if(o===r){n.push(i)}else if(o<r){n=[i];r=o}}if(n.length>0){return n[Math.random()*n.length|0]}else{return-1}}},{}],5:[function(e,t,n){var r=e("debug")("webtorrent:server");var i=e("http");var o=e("mime");var a=e("pump");var s=e("range-parser");var c=e("url");t.exports=function f(e,t){var n=i.createServer(t);n.on("connection",function(e){e.setTimeout(36e6)});n.on("request",function(t,n){r("onRequest");if(t.method==="OPTIONS"&&t.headers["access-control-request-headers"]){n.setHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS");n.setHeader("Access-Control-Allow-Headers",t.headers["access-control-request-headers"]);n.setHeader("Access-Control-Max-Age","1728000");return n.end()}if(t.headers.origin){n.setHeader("Access-Control-Allow-Origin",t.headers.origin)}var i=c.parse(t.url).pathname;if(i==="/favicon.ico")return n.end();if(e.ready)f();else e.once("ready",f);function f(){if(i==="/"){n.setHeader("Content-Type","text/html");var c=e.files.map(function(e,t){return'<li><a href="/'+t+'">'+e.name+"</a></li>"}).join("<br>");return n.end("<h1>WebTorrent</h1><ol>"+c+"</ol>")}var f=Number(i.slice(1));if(Number.isNaN(f)||f>=e.files.length){n.statusCode=404;return n.end()}var l=e.files[f];n.setHeader("Accept-Ranges","bytes");n.setHeader("Content-Type",o.lookup(l.name));n.statusCode=200;n.setHeader("transferMode.dlna.org","Streaming");n.setHeader("contentFeatures.dlna.org","DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000");var u;if(t.headers.range){n.statusCode=206;u=s(l.length,t.headers.range)[0];r("range %s",JSON.stringify(u));n.setHeader("Content-Range","bytes "+u.start+"-"+u.end+"/"+l.length);n.setHeader("Content-Length",u.end-u.start+1)}else{n.setHeader("Content-Length",l.length)}if(t.method==="HEAD")n.end();a(l.createReadStream(u),n)}});return n}},{debug:35,http:45,mime:55,pump:64,"range-parser":68,url:93}],6:[function(e,t,n){(function(n,r){t.exports=E;var i=e("bitfield");var o=e("block-stream2");var a=e("debug")("webtorrent:storage");var s=e("dezalgo");var c=e("end-of-stream");var f=e("events").EventEmitter;var l=e("./file-stream");var u=e("inherits");var p=e("./mime.json");var d=e("multistream");var h=e("once");var v=e("path");var m=e("simple-sha1");var g=16*1024;var y=0;var w=1;var b=2;function _(){}u(x,f);function x(e,t,n,r){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!r;if(typeof n==="number"){i.buffer=null;i.length=n}else{i.buffer=n;i.length=n.length}i._reset()}x.prototype.readBlock=function(e,t,n){var r=this;n=s(n);if(!r.buffer||!r._verifyOffset(e)){return n(new Error("invalid block offset "+e))}n(null,r.buffer.slice(e,e+t))};x.prototype.writeBlock=function(e,t,n){var r=this;n=s(n);if(!r._verifyOffset(e)||!r._verifyBlock(e,t)){return n(new Error("invalid block "+e+":"+t.length))}r._lazyAllocBuffer();var i=e/g;if(r.blocks[i]===b){return n(null)}t.copy(r.buffer,e);r.blocks[i]=b;r.blocksWritten+=1;if(r.blocksWritten===r.blocks.length){r.verify()}n(null)};x.prototype.reserveBlock=function(e){var t=this;var n=t.blocks.length;for(var r=0;r<n;r++){if(t.blocks[r]&&!e||t.blocks[r]===b){continue}t.blocks[r]=w;return{offset:r*g,length:r===n-1?t.length-r*g:g}}return null};x.prototype.cancelBlock=function(e){var t=this;if(!t._verifyOffset(e)){return false}var n=e/g;if(t.blocks[n]===w){t.blocks[n]=y}return true};x.prototype._reset=function(){var e=this;e.verified=false;e.blocks=new r(Math.ceil(e.length/g));e.blocks.fill(0);e.blocksWritten=0};x.prototype.verify=function(e){var t=this;e=e||t.buffer;if(t.verified||!e){return}if(t.noVerify){t.verified=true;n();return}m(e,function(e){t.verified=e===t.hash;n()});function n(){if(t.verified){t.emit("done")}else{t.emit("warning",new Error("piece "+t.index+" failed verification"));t._reset()}}};x.prototype._verifyOffset=function(e){var t=this;if(e%g===0){return true}else{t.emit("warning",new Error("invalid block offset "+e+", not multiple of "+g));return false}};x.prototype._verifyBlock=function(e,t){var n=this;if(t.length===g){return true}else if(t.length===n.length-e&&n.length-e<g){return true}else{n.emit("warning",new Error("invalid block size "+t.length));return false}};x.prototype._lazyAllocBuffer=function(){var e=this;if(!e.buffer){e.buffer=new r(e.length)}};u(k,f);function k(e,t,n,r){var i=this;f.call(i);if(!a.enabled)i.setMaxListeners(0);i.storage=e;i.name=t.name;i.path=t.path;i.length=t.length;i.offset=t.offset;i.pieces=n;i.pieceLength=r;i.done=false;i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})});i._checkDone()}k.prototype.select=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var n=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,n,false)}};k.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var n=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,n,false)}};k.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var n=new l(t,e);t.storage.emit("select",n.startPiece,n.endPiece,true,n.notify.bind(n));c(n,function(){t.storage.emit("deselect",n.startPiece,n.endPiece,true)});return n};k.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(n,r){if(n)return e(n);var i=p[v.extname(t.name).toLowerCase()];var o=i?new window.Blob([r],{type:i}):new window.Blob([r]);var a=window.URL.createObjectURL(o);e(null,a)})};k.prototype.getBuffer=function(e){var t=this;e=s(h(e));var n;if(t.storage.buffer){var i=function(){n=t.storage.buffer.slice(t.offset,t.offset+t.length);e(null,n)};if(t.done)i();else t.once("done",i)}else{n=new r(t.length);var o=0;t.createReadStream().on("data",function(e){e.copy(n,o);o+=e.length}).on("end",function(){e(null,n)}).on("error",e)}};k.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){n.nextTick(function(){e.emit("done")})}};u(E,f);function E(e,t){var n=this;f.call(n);if(!a.enabled)n.setMaxListeners(0);if(!t)t={};n.bitfield=new i(e.pieces.length);n.done=false;n.closed=false;n.readonly=true;if(!t.nobuffer){n.buffer=new r(e.length)}var o=n.pieceLength=e.pieceLength;var s=e.lastPieceLength;var c=e.pieces.length;n.pieces=e.pieces.map(function(e,r){var i=r*o;var a=i+(r===c-1?s:o);var f=n.buffer?n.buffer.slice(i,a):a-i;var l=new x(r,e,f,!!t.noVerify);l.on("done",n._onPieceDone.bind(n,l));return l});n.files=e.files.map(function(e){var t=e.offset;var r=t+e.length-1;var i=t/o|0;var a=r/o|0;var s=n.pieces.slice(i,a+1);var c=new k(n,e,s,o);c.on("done",n._onFileDone.bind(n,c));return c})}E.BLOCK_LENGTH=g;E.prototype.load=function(e,t){var n=this;if(!Array.isArray(e))e=[e];t=h(t||function(){});var r=0;var i=new d(e);var a=new o(n.pieceLength,{zeroPadding:false});i.on("error",c);n.once("done",f);i.pipe(a).on("data",s).on("error",c);function s(e){var t=r;r+=1;var i=0;var a=new o(g,{zeroPadding:false});a.on("data",s);a.on("end",c);function s(e){var r=i*g;i+=1;n.writeBlock(t,r,e)}function c(){f()}function f(){a.removeListener("data",s);a.removeListener("end",c)}a.end(e)}function c(e){l();t(e)}function f(){l();t(null)}function l(){i.removeListener("error",c);a.removeListener("data",s);a.removeListener("error",c);n.removeListener("done",f)}};Object.defineProperty(E.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(E.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var n=0,r=e.pieces.length;n<r;n++){t-=e.bitfield.get(n)}return t}});E.prototype.readBlock=function(e,t,n,r){var i=this;r=s(r);var o=i.pieces[e];if(!o)return r(new Error("invalid piece index "+e));o.readBlock(t,n,r)};E.prototype.writeBlock=function(e,t,n,r){var i=this;if(!r)r=_;r=s(r);if(i.readonly)return r(new Error("cannot write to readonly storage"));var o=i.pieces[e];if(!o)return r(new Error("invalid piece index "+e));o.writeBlock(t,n,r)};E.prototype.read=function(e,t,n,i){var o=this;if(typeof t==="function"){i=n;n=t;t=null}n=s(n);var a=o.pieces[e];if(!a){return n(new Error("invalid piece index "+e))}if(!a.verified&&!i){return n(new Error("Storage.read called on incomplete piece "+e))}var c=0;var f=a.length;if(t){c=t.offset||0;f=t.length||f}if(a.buffer){return n(null,a.buffer.slice(c,c+f))}var l=[];function u(){if(f<=0)return n(null,r.concat(l));var t=c;var i=Math.min(g,f);c+=i;f-=i;o.readBlock(e,t,i,function(e,t){if(e)return n(e);l.push(t);u()})}u()};E.prototype.reserveBlock=function(e,t){var n=this;var r=n.pieces[e];if(!r)return null;return r.reserveBlock(t)};E.prototype.cancelBlock=function(e,t){var n=this;var r=n.pieces[e];if(!r)return false;return r.cancelBlock(t)};E.prototype.remove=function(e){if(e)s(e)(null)};E.prototype.close=function(e){var t=this;t.closed=true;if(e)s(e)(null)};E.prototype._onPieceDone=function(e){var t=this;t.bitfield.set(e.index);a("piece done "+e.index+" ("+t.numMissing+" still missing)");t.emit("piece",e)};E.prototype._onFileDone=function(e){var t=this;a("file done "+e.name);t.emit("file",e);t._checkDone()};E.prototype._checkDone=function(){var e=this;if(!e.done&&e.files.every(function(e){return e.done})){e.done=true;e.emit("done")}}}).call(this,e("_process"),e("buffer").Buffer)},{"./file-stream":1,"./mime.json":3,_process:29,bitfield:17,"block-stream2":26,buffer:31,debug:35,dezalgo:38,"end-of-stream":39,events:40,inherits:49,multistream:58,once:59,path:62,"simple-sha1":83}],7:[function(e,t,n){(function(n,r){t.exports=I;var i=e("addr-to-ip-port");var o=e("create-torrent");var a=e("debug")("webtorrent:torrent");var s=e("torrent-discovery");var c=e("events").EventEmitter;var f=e("inherits");var l=e("run-parallel");var u=e("parse-torrent");var p=e("re-emitter");var d=e("bittorrent-swarm");var h=e("uniq");var v=e("ut_metadata");var m=e("ut_pex");var g=e("./rarity-map");var y=e("./server");var w=e("./storage");var b=128*1024;var _=3e4;var x=5e3;var k=3*w.BLOCK_LENGTH;var E=.5;var S=1;var A=1e4;var T=2;function C(){}f(I,c);function I(e,t){var n=this;c.call(n);if(!a.enabled)n.setMaxListeners(0);a("new torrent");n.opts=t;n.client=t.client;n.hotswapEnabled="hotswap"in t?t.hotswap:true;n.verify=t.verify;n.chokeTimeout=t.chokeTimeout||x;n.pieceTimeout=t.pieceTimeout||_;n.strategy=t.strategy||"sequential";n._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;n._rechokeOptimisticWire=null;n._rechokeOptimisticTime=0;n._rechokeIntervalId=null;n.ready=false;n.destroyed=false;n.files=[];n.metadata=null;n.parsedTorrent=null;n.storage=null;n.numBlockedPeers=0;n._amInterested=false;n._selections=[];n._critical=[];n._storageImpl=t.storage||w;this._torrentFileURL=null;if(e)n._onTorrentId(e)}Object.defineProperty(I.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}});Object.defineProperty(I.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(I.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}});Object.defineProperty(I.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}});Object.defineProperty(I.prototype,"uploaded",{get:function(){return this.swarm.uploaded}});Object.defineProperty(I.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}});Object.defineProperty(I.prototype,"magnetURI",{get:function(){return u.toMagnetURI(this.parsedTorrent)}});Object.defineProperty(I.prototype,"torrentFile",{get:function(){return u.toTorrentFile(this.parsedTorrent)}});Object.defineProperty(I.prototype,"torrentFileURL",{get:function(){if(typeof window==="undefined")throw new Error("browser-only property");if(this._torrentFileURL)return this._torrentFileURL;this._torrentFileURL=window.URL.createObjectURL(new window.Blob([this.torrentFile],{type:"application/x-bittorrent"}));return this._torrentFileURL}});I.prototype._onTorrentId=function(e){var t=this;if(t.destroyed)return;var n=e&&e.parsedTorrent;if(n){t._onParsedTorrent(n)}else{u.remote(e,function(e,n){if(t.destroyed)return;if(e)return t._onError(e);t._onParsedTorrent(n)})}};I.prototype._onParsedTorrent=function(e){var t=this;if(t.destroyed)return;t.parsedTorrent=e;t.infoHash=e.infoHash;if(!t.infoHash){return t._onError(new Error("Malformed torrent data: Missing info hash."))}if(t.parsedTorrent.name)t.name=t.parsedTorrent.name;if(t.opts.announce){t.parsedTorrent.announce=t.parsedTorrent.announce.concat(t.opts.announce)}if(r.WEBTORRENT_ANNOUNCE){t.parsedTorrent.announce=t.parsedTorrent.announce.concat(r.WEBTORRENT_ANNOUNCE)}if(t.parsedTorrent.announce.length===0){t.parsedTorrent.announce=o.announceList.map(function(e){return e[0]})}h(t.parsedTorrent.announce);t.swarm=new d(t.infoHash,t.client.peerId,{handshake:{dht:!!t.client.dht}});t.swarm.on("error",t._onError.bind(t));p(t.swarm,t,["warning"]);t.swarm.on("wire",t._onWire.bind(t));t.swarm.on("download",t.client.downloadSpeed.bind(t.client));t.swarm.on("upload",t.client.uploadSpeed.bind(t.client));t.swarm.listen(t.client.torrentPort,t._onSwarmListening.bind(t));n.nextTick(function(){if(t.destroyed)return;t.emit("infoHash",t.infoHash)})};I.prototype._onSwarmListening=function(){var e=this;if(e.destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new s({announce:e.parsedTorrent.announce,dht:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.on("error",e._onError.bind(e));e.discovery.setTorrent(e.infoHash);e.discovery.on("peer",e.addPeer.bind(e));p(e.discovery,e,["dhtAnnounce","warning"]);if(e.parsedTorrent.info)e._onMetadata(e.parsedTorrent);e.emit("listening",e.client.torrentPort)};I.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;a("got metadata");if(e&&e.infoHash){t.metadata=u.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;var r=t.parsedTorrent.announce;try{t.parsedTorrent=u(t.metadata)}catch(i){return t._onError(i)}t.parsedTorrent.announce=r}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new g(t.swarm,t.parsedTorrent.pieces.length);t.storage=new t._storageImpl(t.parsedTorrent,t.opts);t.storage.on("piece",t._onStoragePiece.bind(t));t.storage.on("file",function(e){t.emit("file",e)});t._reservations=t.storage.pieces.map(function(){return[]});t.storage.on("done",function(){if(t.discovery.tracker)t.discovery.tracker.complete();a("torrent "+t.infoHash+" done");t.emit("done")});t.storage.on("select",t.select.bind(t));t.storage.on("deselect",t.deselect.bind(t));t.storage.on("critical",t.critical.bind(t));t.storage.files.forEach(function(e){t.files.push(e)});t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});if(t.verify){n.nextTick(function(){a("verifying existing torrent data");var e=0;var n=0;l(t.storage.pieces.map(function(r){return function(i){t.storage.read(r.index,function(o,s){e+=1;t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*n/t.storage.pieces.length});if(!o&&s){r.verify(s);n+=r.verified;a("piece "+(r.verified?"verified":"invalid")+" "+r.index)}i()},true)}}),t._onStorage.bind(t))})}else{n.nextTick(t._onStorage.bind(t))}n.nextTick(function(){t.emit("metadata")})};I.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;a("destroy");if(t._rechokeIntervalId){clearInterval(t._rechokeIntervalId);t._rechokeIntervalId=null}if(t._torrentFileURL)window.URL.revokeObjectURL(t._torrentFileURL);var n=[];if(t.swarm)n.push(function(e){t.swarm.destroy(e)});if(t.discovery)n.push(function(e){t.discovery.stop(e)});if(t.storage)n.push(function(e){t.storage.close(e)});l(n,e)};I.prototype.addPeer=function(e){var t=this;function n(){t.emit("peer",e);t.swarm.addPeer(e)}if(typeof e==="string"&&t.client.blocked&&t.client.blocked.contains(i(e)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}else{if(t.swarm)n();else t.on("listening",n);return true}};I.prototype.select=function(e,t,n,r){var i=this;if(e>t||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}n=Number(n)||0;a("select %s-%s (priority %s)",e,t,n);i._selections.push({from:e,to:t,offset:0,priority:n,notify:r||C});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};I.prototype.deselect=function(e,t,n){var r=this;n=Number(n)||0;a("deselect %s-%s (priority %s)",e,t,n);for(var i=0;i<r._selections.length;++i){var o=r._selections[i];if(o.from===e&&o.to===t&&o.priority===n){r._selections.splice(i--,1);break}}r._updateSelections()};I.prototype.critical=function(e,t){var n=this;a("critical %s-%s",e,t);for(var r=e;r<=t;++r){n._critical[r]=true}n._updateSelections()};I.prototype._onWire=function(e,t){var n=this;a("got wire (%s)",t||"Unknown");if(t){var r=i(t);e.remoteAddress=r[0];e.remotePort=r[1]}if(e.peerExtensions.dht&&n.client.dht&&n.client.dht.listening){e.on("port",function(t){if(!e.remoteAddress){a("ignoring port from peer with no address");return}a("port: %s (from %s)",t,e.remoteAddress+":"+e.remotePort);n.client.dht.addNode(e.remoteAddress+":"+t)});e.port(n.client.dht.address().port)}e.on("timeout",function(){a("wire timeout (%s)",t);e.destroy()});e.setTimeout(n.pieceTimeout,true);e.setKeepAlive(true);e.use(v(n.metadata));if(!n.metadata){e.ut_metadata.on("metadata",function(e){a("got metadata via ut_metadata");n._onMetadata(e)});e.ut_metadata.fetch()}if(typeof m==="function"){e.use(m());e.ut_pex.on("peer",function(e){a("ut_pex: got peer: %s (from %s)",e,t);n.addPeer(e)});e.ut_pex.on("dropped",function(e){a("ut_pex: dropped peer: %s (from %s)",e,t);var r=n.swarm._peers[e];if(!r||!r.conn)n.swarm.removePeer(e)})}n.emit("wire",e);if(n.metadata){n._onWireWithMetadata(e)}};I.prototype._onWireWithMetadata=function(e){var t=this;var n=null;var r=t.chokeTimeout;function i(){if(t.destroyed||e.destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{n=setTimeout(i,r);if(n.unref)n.unref()}}var o=0;function s(){if(e.peerPieces.length!==t.storage.pieces.length)return;for(;o<t.storage.pieces.length;++o){if(!e.peerPieces.get(o))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){s();t._update()});e.on("have",function(){s();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(n)});e.on("choke",function(){clearTimeout(n);n=setTimeout(i,r);if(n.unref)n.unref()});e.on("unchoke",function(){clearTimeout(n);t._update()});e.on("request",function(n,r,i,o){if(i>b){a("got invalid block size request %s (from %s)",i,e.remoteAddress+":"+e.remotePort);return e.destroy()}t.storage.readBlock(n,r,i,o)});e.bitfield(t.storage.bitfield);e.interested();n=setTimeout(i,r);if(n.unref)n.unref();e.isSeeder=false;s()};I.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),A);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();n.nextTick(function(){e.ready=true;e.emit("ready")})};I.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()};I.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));n.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};I.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var n=e._selections[t];var r=n.offset;while(e.storage.bitfield.get(n.from+n.offset)&&n.from+n.offset<n.to){n.offset++}if(r!==n.offset)n.notify();if(n.to!==n.from+n.offset)continue;if(!e.storage.bitfield.get(n.from+n.offset))continue;e._selections.splice(t--,1);n.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};I.prototype._updateInterest=function(){var e=this;var t=e._amInterested;e._amInterested=!!e._selections.length;e.swarm.wires.forEach(function(t){if(e._amInterested)t.interested();else t.uninterested()});if(t===e._amInterested)return;if(e._amInterested)e.emit("interested");else e.emit("uninterested")};I.prototype._update=function(){var e=this;if(e.destroyed)return;R(e.swarm.wires,e._updateWire.bind(e))};I.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var n=j(e,E);if(e.requests.length>=n)return;var r=j(e,S);c(false)||c(true);function i(t,n,r,i){return function(o){return o>=t&&o<=n&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var n=t._selections.length;n--;){var r=t._selections[n];var o;if(t.strategy==="rarest"){var a=r.from+r.offset;var s=r.to;var c=s-a+1;var f={};var l=0;var u=i(a,s,f);while(l<c){o=t.rarityMap.getRarestPiece(u);if(o<0)break;if(t._request(e,o,false))return;f[o]=true;l+=1}}else{for(o=r.to;o>=r.from+r.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function a(){var n=e.downloadSpeed()||1;if(n>k)return function(){return true};var r=Math.max(1,e.requests.length)*w.BLOCK_LENGTH/n;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(;o<t.swarm.wires.length;o++){var c=t.swarm.wires[o];var f=c.downloadSpeed();if(f<k)continue;if(f<=n)continue;if(!c.peerPieces.get(e))continue;if((s-=f*r)>0)continue;i--;return false}return true}}function s(e){var n=e;for(var r=e;r<t._selections.length&&t._selections[r].priority;r++){n=r}var i=t._selections[e];t._selections[e]=t._selections[n];t._selections[n]=i}function c(n){if(e.requests.length>=r)return true;var o=a();for(var c=0;c<t._selections.length;c++){var f=t._selections[c];var l;if(t.strategy==="rarest"){var u=f.from+f.offset;var p=f.to;var d=p-u+1;var h={};var v=0;var m=i(u,p,h,o);while(v<d){l=t.rarityMap.getRarestPiece(m);if(l<0)break;while(t._request(e,l,t._critical[l]||n)){}if(e.requests.length<r){h[l]=true;v++;continue}if(f.priority)s(c);return true}}else{for(l=f.from+f.offset;l<=f.to;l++){if(!e.peerPieces.get(l)||!o(l))continue;while(t._request(e,l,t._critical[l]||n)){}if(e.requests.length<r)continue;if(f.priority)s(c);return true}}}return false}};I.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(n){if(!n.isSeeder&&n!==e._rechokeOptimisticWire){t.push({wire:n,downloadSpeed:n.downloadSpeed(),uploadSpeed:n.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(a);var n=0;var r=0;for(;r<t.length&&n<e._rechokeNumSlots;++r){t[r].isChoked=false;if(t[r].wire.peerInterested)n+=1}if(!e._rechokeOptimisticWire&&r<t.length&&e._rechokeNumSlots){var i=t.slice(r).filter(function(e){return e.wire.peerInterested});var o=i[L(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=T}}t.forEach(function(e){if(e.wire.amChoking!==e.isChoked){if(e.isChoked)e.wire.choke();else e.wire.unchoke()}});function a(e,t){if(e.downloadSpeed!==t.downloadSpeed){return t.downloadSpeed-e.downloadSpeed}if(e.uploadSpeed!==t.uploadSpeed){return t.uploadSpeed-e.uploadSpeed}if(e.wire.amChoking!==t.wire.amChoking){return e.wire.amChoking?1:-1}return e.salt-t.salt}};I.prototype._hotswap=function(e,t){var n=this;if(!n.hotswapEnabled)return false;var r=e.downloadSpeed();if(r<w.BLOCK_LENGTH)return false;if(!n._reservations[t])return false;var i=n._reservations[t];if(!i){return false}var o=Infinity;var a;var s;for(s=0;s<i.length;s++){var c=i[s];if(!c||c===e)continue;var f=c.downloadSpeed();if(f>=k)continue;if(2*f>r||f>o)continue;a=c;o=f}if(!a)return false;for(s=0;s<i.length;s++){if(i[s]===a)i[s]=null}for(s=0;s<a.requests.length;s++){var l=a.requests[s];if(l.piece!==t)continue;n.storage.cancelBlock(t,l.offset)}n.emit("hotswap",a,e,t);return true};I.prototype._request=function(e,t,r){var i=this;var o=e.requests.length;if(i.storage.bitfield.get(t))return false;var s=j(e,S);if(o>=s)return false;var c=e.requests.length===0&&i.storage.numMissing<30;var f=i.storage.reserveBlock(t,c);if(!f&&!c&&r&&i._hotswap(e,t)){f=i.storage.reserveBlock(t,false)}if(!f)return false;var l=i._reservations[t];if(!l){l=i._reservations[t]=[]}var u=l.indexOf(null);if(u===-1)u=l.length;l[u]=e;function p(r,o){if(!i.ready){i.once("ready",function(){p(r,o)});return}if(l[u]===e)l[u]=null;if(r){a("error getting piece %s (offset: %s length: %s) from %s: %s",t,f.offset,f.length,e.remoteAddress+":"+e.remotePort,r.message);i.storage.cancelBlock(t,f.offset);n.nextTick(i._update.bind(i));return false}else{a("got piece %s (offset: %s length: %s) from %s",t,f.offset,f.length,e.remoteAddress+":"+e.remotePort);i.storage.writeBlock(t,f.offset,o,function(e){if(e){a("error writing block");i.storage.cancelBlock(t,f.offset)}n.nextTick(i._update.bind(i))})}}e.request(t,f.offset,f.length,p);return true};I.prototype.createServer=function(e){var t=this;if(typeof y==="function"){return new y(t,e)}};I.prototype._onError=function(e){var t=this;a("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function j(e,t){return Math.ceil(2+t*e.downloadSpeed()/w.BLOCK_LENGTH)}function L(e){return Math.random()*e|0}function R(e,t){var n=e.map(function(e,t){return t});for(var r=n.length-1;r>0;--r){var i=L(r+1);var o=n[r];n[r]=n[i];n[i]=o}n.forEach(function(n){t(e[n],n,e)})}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./rarity-map":4,"./server":5,"./storage":6,_process:29,"addr-to-ip-port":9,"bittorrent-swarm":19,"create-torrent":34,debug:35,events:40,inherits:49,"parse-torrent":61,"re-emitter":69,"run-parallel":80,"torrent-discovery":90,uniq:92,ut_metadata:94,ut_pex:27}],8:[function(e,t,n){(function(){var e=typeof n!="undefined"?n:this;var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function r(e){this.message=e}r.prototype=new Error;r.prototype.name="InvalidCharacterError";e.btoa||(e.btoa=function(e){for(var n,i,o=0,a=t,s="";e.charAt(o|0)||(a="=",o%1);s+=a.charAt(63&n>>8-o%1*8)){i=e.charCodeAt(o+=3/4);if(i>255){throw new r("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")}n=n<<8|i}return s});e.atob||(e.atob=function(e){e=e.replace(/=+$/,"");if(e.length%4==1){throw new r("'atob' failed: The string to be decoded is not correctly encoded.")}for(var n=0,i,o,a=0,s="";o=e.charAt(a++);~o&&(i=n%4?i*64+o:o,n++%4)?s+=String.fromCharCode(255&i>>(-2*n&6)):0){o=t.indexOf(o);
+}return s})})()},{}],9:[function(e,t,n){var r=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function a(e){if(o===1e5)i={};if(!i[e]){var t=r.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={}}},{}],10:[function(e,t,n){"use strict";var r=e("./raw");var i=[];var o=[];var a=r.makeRequestCallFromTimer(s);function s(){if(o.length){throw o.shift()}}t.exports=c;function c(e){var t;if(i.length){t=i.pop()}else{t=new f}t.task=e;r(t)}function f(){this.task=null}f.prototype.call=function(){try{this.task.call()}catch(e){if(c.onerror){c.onerror(e)}else{o.push(e);a()}}finally{this.task=null;i[i.length]=this}}},{"./raw":11}],11:[function(e,t,n){(function(e){"use strict";t.exports=n;function n(e){if(!r.length){o();i=true}r[r.length]=e}var r=[];var i=false;var o;var a=0;var s=1024;function c(){while(a<r.length){var e=a;a=a+1;r[e].call();if(a>s){for(var t=0,n=r.length-a;t<n;t++){r[t]=r[t+a]}r.length-=a;a=0}}r.length=0;a=0;i=false}var f=e.MutationObserver||e.WebKitMutationObserver;if(typeof f==="function"){o=l(c)}else{o=u(c)}n.requestFlush=o;function l(e){var t=1;var n=new f(e);var r=document.createTextNode("");n.observe(r,{characterData:true});return function i(){t=-t;r.data=t}}function u(e){return function t(){var t=setTimeout(r,0);var n=setInterval(r,50);function r(){clearTimeout(t);clearInterval(n);e()}}}n.makeRequestCallFromTimer=u}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],12:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var n="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var a="a".charCodeAt(0);var s="A".charCodeAt(0);var c="-".charCodeAt(0);var f="_".charCodeAt(0);function l(e){var t=e.charCodeAt(0);if(t===n||t===c)return 62;if(t===i||t===f)return 63;if(t<o)return-1;if(t<o+10)return t-o+26+26;if(t<s+26)return t-s;if(t<a+26)return t-a+26}function u(e){var n,r,i,o,a,s;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var c=e.length;a="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0;s=new t(e.length*3/4-a);i=a>0?e.length-4:e.length;var f=0;function u(e){s[f++]=e}for(n=0,r=0;n<i;n+=4,r+=3){o=l(e.charAt(n))<<18|l(e.charAt(n+1))<<12|l(e.charAt(n+2))<<6|l(e.charAt(n+3));u((o&16711680)>>16);u((o&65280)>>8);u(o&255)}if(a===2){o=l(e.charAt(n))<<2|l(e.charAt(n+1))>>4;u(o&255)}else if(a===1){o=l(e.charAt(n))<<10|l(e.charAt(n+1))<<4|l(e.charAt(n+2))>>2;u(o>>8&255);u(o&255)}return s}function p(e){var t,n=e.length%3,i="",o,a;function s(e){return r.charAt(e)}function c(e){return s(e>>18&63)+s(e>>12&63)+s(e>>6&63)+s(e&63)}for(t=0,a=e.length-n;t<a;t+=3){o=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=c(o)}switch(n){case 1:o=e[e.length-1];i+=s(o>>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=u;e.fromByteArray=p})(typeof n==="undefined"?this.base64js={}:n)},{}],13:[function(e,t,n){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":14,"./lib/encode":16}],14:[function(e,t,n){(function(n){var r=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!n.isBuffer(e)?new n(e):e;return i.next()}i.position=0;i.data=null;i.encoding=null;i.next=function(){switch(i.data[i.position]){case 100:return i.dictionary();break;case 108:return i.list();break;case 105:return i.integer();break;default:return i.bytes();break}};i.find=function(e){var t=i.position;var n=i.data.length;var r=i.data;while(t<n){if(r[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};i.dictionary=function(){i.position++;var e=new r;while(i.data[i.position]!==101){e.binarySet(i.bytes(),i.next())}i.position++;return e};i.list=function(){i.position++;var e=[];while(i.data[i.position]!==101){e.push(i.next())}i.position++;return e};i.integer=function(){var e=i.find(101);var t=i.data.toString("ascii",i.position+1,e);i.position+=e+1-i.position;return parseInt(t,10)};i.bytes=function(){var e=i.find(58);var t=parseInt(i.data.toString("ascii",i.position,e),10);var n=++e+t;i.position=n;return i.encoding?i.data.toString(i.encoding,e,n):i.data.slice(e,n)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":15,buffer:31}],15:[function(e,t,n){var r=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};r.prototype.binaryKeys=function o(){return this._keys.slice()};r.prototype.binarySet=function a(e,t){this._keys.push(e);this[e]=t}},{}],16:[function(e,t,n){(function(e){function n(t){var r=[];n._encode(r,t);return e.concat(r)}n._floatConversionDetected=false;n._encode=function(t,r){if(e.isBuffer(r)){t.push(new e(r.length+":"));t.push(r);return}switch(typeof r){case"string":n.bytes(t,r);break;case"number":n.number(t,r);break;case"object":r.constructor===Array?n.list(t,r):n.dict(t,r);break}};var r=new e("e"),i=new e("d"),o=new e("l");n.bytes=function(t,n){t.push(new e(e.byteLength(n)+":"+n))};n.number=function(t,r){var i=2147483648;var o=r/i<<0;var a=r%i<<0;var s=o*i+a;t.push(new e("i"+s+"e"));if(s!==r&&!n._floatConversionDetected){n._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+r+'":','Bencoding only defines support for integers, value was converted to "'+s+'"');console.trace()}};n.dict=function(e,t){e.push(i);var o=0;var a;var s=Object.keys(t).sort();var c=s.length;for(;o<c;o++){a=s[o];n.bytes(e,a);n._encode(e,t[a])}e.push(r)};n.list=function(e,t){var i=0,a=1;var s=t.length;e.push(o);for(;i<s;i++){n._encode(e,t[i])}e.push(r)};t.exports=n}).call(this,e("buffer").Buffer)},{buffer:31}],17:[function(e,t,n){(function(e){var n=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var n=0;n<e;n++)t[n]=0};function r(e,t){if(!(this instanceof r)){return new r(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&i(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new n(i(e));if(e.fill)e.fill(0)}this.buffer=e}function i(e){var t=e>>3;if(e%8!==0)t++;return t}r.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};r.prototype.set=function(e,t){var n=e>>3;if(t||arguments.length===1){if(this.buffer.length<n+1)this._grow(Math.max(n+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[n]|=128>>e%8}else if(n<this.buffer.length){this.buffer[n]&=~(128>>e%8)}};r.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new n(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var r=0;r<this.buffer.length;r++){t[r]=this.buffer[r]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=r}).call(this,e("buffer").Buffer)},{buffer:31}],18:[function(e,t,n){(function(n){t.exports=b;var r=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var a=e("xtend");var s=e("inherits");var c=e("speedometer");var f=e("stream");var l=4e5;var u=new n("BitTorrent protocol");var p=new n([0,0,0,0]);var d=new n([0,0,0,1,0]);var h=new n([0,0,0,1,1]);var v=new n([0,0,0,1,2]);var m=new n([0,0,0,1,3]);var g=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function w(e,t,n,r){this.piece=e;this.offset=t;this.length=n;this.callback=r}s(b,f.Duplex);function b(){if(!(this instanceof b))return new b;f.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new r(0,{grow:l});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=c();this.downloadSpeed=c();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()}b.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,p),6e4)};b.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};b.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;o("destroy");this.end()};b.prototype.end=function(){this._onUninterested();this._onChoke();f.Duplex.prototype.end.apply(this,arguments)};b.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 n=this._nextExt;var r=new e(this);function i(){}if(typeof r.onHandshake!=="function"){r.onHandshake=i}if(typeof r.onExtendedHandshake!=="function"){r.onExtendedHandshake=i}if(typeof r.onMessage!=="function"){r.onMessage=i}this.extendedMapping[n]=t;this._ext[t]=r;this[t]=r;this._nextExt+=1};b.prototype.handshake=function(e,t,r){if(typeof e==="string")e=new n(e,"hex");if(typeof t==="string")t=new n(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new n(g);i[5]|=16;if(r&&r.dht)i[7]|=1;this._push(n.concat([u,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};b.prototype._sendExtendedHandshake=function(){var e=a(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,i.encode(e))};b.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};b.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(h)};b.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(v)};b.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(m)};b.prototype.have=function(e){this._message(4,[e],null)};b.prototype.bitfield=function(e){if(!n.isBuffer(e))e=e.buffer;this._message(5,[],e)};b.prototype.request=function(e,t,n,r){if(!r)r=function(){};if(this._finished)return r(new Error("wire is closed"));if(this.peerChoking)return r(new Error("peer is choking"));this.requests.push(new w(e,t,n,r));this._updateTimeout();this._message(6,[e,t,n],null)};b.prototype.piece=function(e,t,n){this.uploaded+=n.length;this.uploadSpeed(n.length);this.emit("upload",n.length);this._message(7,[e,t],n)};b.prototype.cancel=function(e,t,n){this._callback(_(this.requests,e,t,n),new Error("request was cancelled"),null);this._message(8,[e,t,n],null)};b.prototype.port=function(e){var t=new n(y);t.writeUInt16BE(e,5);this._push(t)};b.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var r=new n([e]);var o=n.isBuffer(t)?t:i.encode(t);this._message(20,[],n.concat([r,o]))}else{throw new Error("Unrecognized extension: "+e)}};b.prototype._onKeepAlive=function(){this.emit("keep-alive")};b.prototype._onHandshake=function(e,t,n){this.peerId=t;this.peerExtensions=n;this.emit("handshake",e,t,n);var r;for(r in this._ext){this._ext[r].onHandshake(e,t,n)}if(n.extended&&this._handshakeSent){this._sendExtendedHandshake()}};b.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};b.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};b.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};b.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};b.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};b.prototype._onBitField=function(e){this.peerPieces=new r(e);this.emit("bitfield",this.peerPieces)};b.prototype._onRequest=function(e,t,n){if(this.amChoking)return;var r=function(r,o){if(i!==_(this.peerRequests,e,t,n))return;if(r)return;this.piece(e,t,o)}.bind(this);var i=new w(e,t,n,r);this.peerRequests.push(i);this.emit("request",e,t,n,r)};b.prototype._onPiece=function(e,t,n){this._callback(_(this.requests,e,t,n.length),null,n);this.downloaded+=n.length;this.downloadSpeed(n.length);this.emit("download",n.length);this.emit("piece",e,t,n)};b.prototype._onCancel=function(e,t,n){_(this.peerRequests,e,t,n);this.emit("cancel",e,t,n)};b.prototype._onPort=function(e){this.emit("port",e)};b.prototype._onExtended=function(e,t){var n,r;if(e===0&&(n=x(t))){this.peerExtendedHandshake=n;if(typeof n.m==="object"){for(r in n.m){this.peerExtendedMapping[r]=Number(n.m[r].toString())}}for(r in this._ext){if(this.peerExtendedMapping[r]){this._ext[r].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)}};b.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};b.prototype._push=function(e){if(this._finished)return;return this.push(e)};b.prototype._write=function(e,t,r){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}r(null)};b.prototype._read=function(){};b.prototype._callback=function(e,t,n){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,n)};b.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};b.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()};b.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};b.prototype._message=function(e,t,r){var i=r?r.length:0;var o=new n(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var a=0;a<t.length;a++){o.writeUInt32BE(t[a],5+4*a)}this._push(o);if(r)this._push(r)};b.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);if(t>0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};b.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)}};b.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var n=e.slice(0,t);if(n.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",n.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))};b.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 _(e,t,n,r){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==n||o.length!==r)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}function x(e){try{return i.decode(e)}catch(t){console.warn(t)}}}).call(this,e("buffer").Buffer)},{bencode:13,bitfield:17,buffer:31,debug:35,inherits:49,speedometer:85,stream:86,xtend:98}],19:[function(e,t,n){(function(n,r){t.exports=v;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var a=e("dezalgo");var s=e("events").EventEmitter;var c=e("inherits");var f=e("net");var l=e("./lib/peer");var u=e("speedometer");var p=e("./lib/tcp-pool");var d=55;var h=[1e3,5e3,15e3];c(v,s);function v(e,t,n){var i=this;if(!(i instanceof v))return new v(e,t,n);s.call(i);i.infoHash=typeof e==="string"?new r(e,"hex"):e;i.infoHashHex=i.infoHash.toString("hex");i.peerId=typeof t==="string"?new r(t,"hex"):t;i.peerIdHex=i.peerId.toString("hex");if(!n)n={};o("new swarm (i %s p %s)",i.infoHashHex,i.peerIdHex);i.handshakeOpts=n.handshake;i.maxConns=n.maxConns!==undefined?n.maxConns:d;i.destroyed=false;i.listening=false;i.paused=false;i.server=null;i.wires=[];i._queue=[];i._peers={};i._peersLength=0;i._port=0;i.downloaded=0;i.uploaded=0;i.downloadSpeed=u();i.uploadSpeed=u()}Object.defineProperty(v.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(v.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(v.prototype,"numConns",{get:function(){var e=this;var t=0;for(var n in e._peers){var r=e._peers[n];if(r&&r.conn)t+=1}return t}});Object.defineProperty(v.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});v.prototype.addPeer=function(e){var t=this;if(t.destroyed){if(e&&e.destroy)e.destroy(new Error("swarm already destroyed"));return}if(typeof e==="string"&&!t._validAddr(e)){o("ignoring invalid peer %s (from swarm.addPeer)",e);return}var n=e&&e.id||e;if(t._peers[n])return;o("addPeer %s",n);var r;if(typeof e==="string"){r=l.createOutgoingTCPPeer(e,t);t._queue.push(r);t._drain()}else{r=l.createWebRTCPeer(e,t)}t._peers[r.id]=r;t._peersLength+=1};v.prototype._addIncomingPeer=function(e){var t=this;if(t.destroyed)return e.destroy(new Error("swarm already destroyed"));if(t.paused)return e.destroy(new Error("swarm paused"));if(!t._validAddr(e.addr)){return e.destroy(new Error("invalid addr "+e.addr+" (from incoming)"))}o("_addIncomingPeer %s",e.id);t._peers[e.id]=e;t._peersLength+=1};v.prototype.removePeer=function(e){var t=this;var n=t._peers[e];if(!n)return;o("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;n.destroy()};v.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};v.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};v.prototype.listen=function(e,t,r){var i=this;if(typeof t==="function"){r=t;t=undefined}if(r)r=a(r);if(i.listening)throw new Error("swarm already listening");if(n.browser){r()}else{i._port=e||p.getDefaultListenPort(i.infoHashHex);i._hostname=t;if(r)i.once("listening",r);o("listen %s",e);var s=p.addSwarm(i);i.server=s.server}};v.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};v.prototype.address=function(){var e=this;return e.server.address()};v.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t.listening=false;t.paused=false;if(e)t.once("close",e);o("destroy");for(var n in t._peers){t.removePeer(n)}p.removeSwarm(t,function(){t.emit("close")})};v.prototype._drain=function(){var e=this;o("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof f.connect!=="function"||e.destroyed||e.paused||e.numConns>=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 n=i(t.addr);var r=n[0];var a=n[1];var s=t.conn=f.connect({host:r,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>=h.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,h.length);return}function n(){var n=l.createOutgoingTCPPeer(t.addr,e);n.retries=t.retries+1;e._queue.push(n);e._drain()}var r=h[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var i=setTimeout(n,r);if(i.unref)i.unref()})};v.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};v.prototype._validAddr=function(e){var t=this;var n=i(e);var r=n[0];var o=n[1];return o>0&&o<65535&&!(r==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":20,"./lib/tcp-pool":21,_process:29,"addr-to-ip-port":27,buffer:31,debug:35,dezalgo:38,events:40,inherits:49,net:27,speedometer:85}],20:[function(e,t,n){var r=e("debug")("bittorrent-swarm:peer");var i=e("bittorrent-protocol");var o=25e3;var a=25e3;n.createWebRTCPeer=function(e,t){var n=new s(e.id);n.conn=e;n.swarm=t;if(n.conn.connected){n.onConnect()}else{n.conn.once("connect",function(){n.onConnect()});n.conn.once("error",function(e){n.destroy(e)});n.setConnectTimeout()}return n};n.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var n=new s(t);n.conn=e;n.addr=t;n.onConnect();return n};n.createOutgoingTCPPeer=function(e,t){var n=new s(e);n.swarm=t;n.addr=e;return n};function s(e){var t=this;t.id=e;r("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;if(e.destroyed)return;r("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 n=e.wire=new i;n.once("end",function(){e.destroy()});n.once("finish",function(){e.destroy()});n.once("error",function(t){e.destroy(t)});n.once("handshake",function(t,n){e.onHandshake(t,n)});e.setHandshakeTimeout();t.pipe(n).pipe(t);if(e.swarm)e.handshake()};s.prototype.onHandshake=function(e,t){var n=this;if(!n.swarm)return;var i=e.toString("hex");var o=t.toString("hex");if(n.swarm.destroyed)return n.destroy(new Error("swarm already destroyed"));if(i!==n.swarm.infoHashHex){return n.destroy(new Error("unexpected handshake info hash for this swarm"))}if(o===n.swarm.peerIdHex){return n.destroy(new Error("refusing to handshake with self"))}r("Peer %s got handshake %s",n.id,i);clearTimeout(n.handshakeTimeout);n.retries=0;n.wire.on("download",function(e){n.swarm.downloaded+=e;n.swarm.downloadSpeed(e);n.swarm.emit("download",e)});n.wire.on("upload",function(e){n.swarm.uploaded+=e;n.swarm.uploadSpeed(e);n.swarm.emit("upload",e)});if(!n.sentHandshake)n.handshake();n.swarm.wires.push(n.wire);var a=n.addr;if(!a&&n.conn.remoteAddress){a=n.conn.remoteAddress+":"+n.conn.remotePort}n.swarm.emit("wire",n.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;r("destroy Peer %s (error: %s)",t.id,e&&(e.message||e));if(t.swarm)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":18,debug:35}],21:[function(e,t,n){(function(n){t.exports=c;var r=e("debug")("bittorrent-swarm:tcp-pool");var i=e("dezalgo");var o=e("net");var a=e("./peer");var s={};function c(e,t){var n=this;n.port=e;n.listening=false;n.swarms={};r("new TCPPool (port: %s, hostname: %s)",e,t);n.pendingConns=[];n.server=o.createServer();n.server.on("connection",function(e){n._onConnection(e)});n.server.on("error",function(e){n._onError(e)});n.server.on("listening",function(){n._onListening()});n.server.listen(n.port,t)}c.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new c(e._port,e._hostname);t.addSwarm(e);return t};c.removeSwarm=function(e,t){var r=s[e._port];if(!r)return t();r.removeSwarm(e);var i=0;for(var o in r.swarms){var a=r.swarms[o];if(a)i+=1}if(i===0)r.destroy(t);else n.nextTick(t)};c.getDefaultListenPort=function(e){for(var t in s){var n=s[t];if(n&&!n.swarms[e])return n.port}return 0};c.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){n.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){n.nextTick(function(){e._onListening(t.port)})}r("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};c.prototype.removeSwarm=function(e){var t=this;r("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};c.prototype.destroy=function(e){var t=this;if(e)e=i(e);r("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(n){if(e)e(null)}};c.prototype._onListening=function(){var e=this;var t=e.server.address().port;r("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 n in e.swarms){var i=e.swarms[n];if(i)i._onListening(e.port)}};c.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",n);function n(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var r=a.createIncomingTCPPeer(e);r.wire.once("handshake",function(i,o){var a=i.toString("hex");n();e.removeListener("close",n);var s=t.swarms[a];if(s){r.swarm=s;s._addIncomingPeer(r);r.onHandshake(i,o)}else{var c=new Error("Unexpected info hash "+a+" from incoming peer "+r.id+": destroying peer");r.destroy(c)}})};c.prototype._onError=function(e){var t=this;t.destroy();for(var n in t.swarms){var r=t.swarms[n];if(r){t.removeSwarm(r);r._onError(e)}}}}).call(this,e("_process"))},{"./peer":20,_process:29,debug:35,dezalgo:38,net:27}],22:[function(e,t,n){(function(n,r){t.exports=d;var i=e("debug")("bittorrent-tracker");var o=e("events").EventEmitter;var a=e("inherits");var s=e("once");var c=e("url");var f=e("./lib/common");var l=e("./lib/http-tracker");var u=e("./lib/udp-tracker");var p=e("./lib/websocket-tracker");a(d,o);function d(e,t,a,s){var h=this;if(!(h instanceof d))return new d(e,t,a,s);o.call(h);if(!s)s={};h._peerId=r.isBuffer(e)?e:new r(e,"hex");h._peerIdHex=h._peerId.toString("hex");h._peerIdBinary=h._peerId.toString("binary");h._infoHash=r.isBuffer(a.infoHash)?a.infoHash:new r(a.infoHash,"hex");h._infoHashHex=h._infoHash.toString("hex");h._infoHashBinary=h._infoHash.toString("binary");h._port=t;h.torrentLength=a.length;h._rtcConfig=s.rtcConfig;h._wrtc=s.wrtc;h._numWant=s.numWant||f.DEFAULT_ANNOUNCE_PEERS;h._intervalMs=s.interval||f.DEFAULT_ANNOUNCE_INTERVAL;i("new client %s",h._infoHashHex);var v={interval:h._intervalMs};var m=!!h._wrtc||typeof window!=="undefined";var g=typeof a.announce==="string"?[a.announce]:a.announce==null?[]:a.announce;h._trackers=g.map(function(e){e=e.toString();var t=c.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof l==="function"){return new l(h,e,v)}else if(t==="udp:"&&typeof u==="function"){return new u(h,e,v)}else if((t==="ws:"||t==="wss:")&&m){return new p(h,e,v)}else{n.nextTick(function(){var t=new Error("unsupported tracker protocol for "+e);h.emit("warning",t)})}return null}).filter(Boolean)}d.scrape=function(e,t,n){n=s(n);var i=new r("01234567890123456789");var o=6881;var a={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var c=new d(i,o,a);c.once("error",n);var f=Array.isArray(t)?t.length:1;var l={};c.on("scrape",function(e){f-=1;l[e.infoHash]=e;if(f===0){c.destroy();var t=Object.keys(l);if(t.length===1){n(null,l[t[0]])}else{n(null,l)}}});t=Array.isArray(t)?t.map(function(e){return new r(e,"hex")}):new r(t,"hex");c.scrape({infoHash:t})};d.prototype.start=function(e){var t=this;i("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval(t._intervalMs)})};d.prototype.stop=function(e){var t=this;i("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};d.prototype.complete=function(e){var t=this;i("send `complete`");if(!e)e={};if(e.downloaded==null&&t.torrentLength!=null){e.downloaded=t.torrentLength}e=t._defaultAnnounceOpts(e);e.event="completed";t._announce(e)};d.prototype.update=function(e){var t=this;i("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};d.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};d.prototype.scrape=function(e){var t=this;i("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};d.prototype.setInterval=function(e){var t=this;i("setInterval");t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};d.prototype.destroy=function(){var e=this;i("destroy");e._trackers.forEach(function(e){e.destroy();e.setInterval(0)});e._trackers=[]};d.prototype._defaultAnnounceOpts=function(e){var t=this;if(!e)e={};if(e.numWant==null)e.numWant=t._numWant;if(e.uploaded==null)e.uploaded=0;if(e.downloaded==null)e.downloaded=0;if(e.left==null&&t.torrentLength!=null){e.left=t.torrentLength-e.downloaded}return e}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/common":24,"./lib/http-tracker":27,"./lib/udp-tracker":27,"./lib/websocket-tracker":25,_process:29,buffer:31,debug:35,events:40,inherits:49,once:59,url:93}],23:[function(e,t,n){(function(t){var r=e("querystring");n.IPV4_RE=/^[\d\.]+$/;n.IPV6_RE=/^[\da-fA-F:]+$/;n.CONNECTION_ID=t.concat([i(1047),i(655366528)]);n.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};n.EVENTS={update:0,completed:1,started:2,stopped:3};n.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};n.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function i(e){var n=new t(4);n.writeUInt32BE(e,0);return n}n.toUInt32=i;n.querystringParse=function(e){var t=r.unescape;r.unescape=unescape;var n=r.parse(e);r.unescape=t;return n};n.querystringStringify=function(e){var t=r.escape;r.escape=escape;var n=r.stringify(e);n=n.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});r.escape=t;return n}}).call(this,e("buffer").Buffer)},{buffer:31,querystring:67}],24:[function(e,t,n){(function(t){var r=e("xtend/mutable");n.DEFAULT_ANNOUNCE_INTERVAL=30*60*1e3;n.DEFAULT_ANNOUNCE_PEERS=50;n.MAX_ANNOUNCE_PEERS=82;n.binaryToHex=function(e){return new t(e,"binary").toString("hex")};n.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");r(n,i)}).call(this,e("buffer").Buffer)},{"./common-node":23,buffer:31,"xtend/mutable":99}],25:[function(e,t,n){t.exports=d;var r=e("debug")("bittorrent-tracker:websocket-tracker");var i=e("events").EventEmitter;var o=e("hat");var a=e("inherits");var s=e("simple-peer");var c=e("simple-websocket");var f=e("./common");var l={};var u=30*1e3;var p=5*1e3;a(d,i);function d(e,t,n){var o=this;i.call(o);r("new websocket tracker %s",t);o.client=e;o.destroyed=false;o._opts=n;if(t[t.length-1]==="/"){t=t.substring(0,t.length-1)}o._announceUrl=t;o._peers={};o._socket=null;o._intervalMs=o.client._intervalMs;o._interval=null;o._openSocket();
+}d.prototype.announce=function(e){var t=this;if(t.destroyed)return;if(!t._socket.connected){return t._socket.once("connect",t.announce.bind(t,e))}e.info_hash=t.client._infoHashBinary;e.peer_id=t.client._peerIdBinary;if(e.numWant>10)e.numWant=10;t._generateOffers(e.numWant,function(n){e.offers=n;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};d.prototype.scrape=function(e){var t=this;if(t.destroyed)return;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};d.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var n=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(n,t._intervalMs)}};d.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",h);try{e._socket.close()}catch(t){}e._socket=null};d.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=l[e._announceUrl];if(!e._socket){e._socket=l[e._announceUrl]=new c(e._announceUrl)}e._socket.on("data",e._onSocketDataBound);e._socket.on("close",e._onSocketCloseBound);e._socket.on("error",e._onSocketErrorBound)};d.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){r("ignoring websocket data from %s for %s (looking for %s: reused socket)",t._announceUrl,f.binaryToHex(e.info_hash),t.client._infoHashHex);return}if(e.peer_id&&e.peer_id===t.client._peerIdBinary){return}r("received %s from %s for %s",JSON.stringify(e),t._announceUrl,t.client._infoHashHex);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));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})}var c;if(e.offer&&e.peer_id){c=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});c.id=f.binaryToHex(e.peer_id);c.once("signal",function(n){var r={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};if(t._trackerId)r.trackerid=t._trackerId;t._send(r)});c.signal(e.offer);t.client.emit("peer",c)}if(e.answer&&e.peer_id){c=t._peers[f.binaryToHex(e.offer_id)];if(c){c.id=f.binaryToHex(e.peer_id);c.signal(e.answer);t.client.emit("peer",c)}else{r("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._onSocketClose=function(){var e=this;if(e.destroyed)return;e.destroy();e._startReconnectTimer()};d.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.destroy();t.client.emit("warning",e);t._startReconnectTimer()};d.prototype._startReconnectTimer=function(){var e=this;var t=Math.floor(Math.random()*u)+p;setTimeout(function(){e.destroyed=false;e._openSocket()},t);r("reconnecting socket in %s ms",t)};d.prototype._send=function(e){var t=this;if(t.destroyed)return;var n=JSON.stringify(e);r("send %s",n);t._socket.send(n)};d.prototype._generateOffers=function(e,t){var n=this;var i=[];r("generating %s offers",e);for(var a=0;a<e;++a){c()}function c(){var e=o(160);var t=n._peers[e]=new s({initiator:true,trickle:false,config:n.client._rtcConfig,wrtc:n.client._wrtc});t.once("signal",function(t){i.push({offer:t,offer_id:f.hexToBinary(e)});l()})}function l(){if(i.length===e){r("generated %s offers",e);t(i)}}};function h(){}},{"./common":24,debug:35,events:40,hat:44,inherits:49,"simple-peer":82,"simple-websocket":84}],26:[function(e,t,n){(function(n){var r=e("inherits");var i=e("readable-stream").Transform;var o=e("defined");t.exports=a;r(a,i);function a(e,t){if(!(this instanceof a))return new a(e,t);i.call(this);if(!t)t={};if(typeof e==="object"){t=e;e=t.size}this.size=e||512;if(t.nopad)this._zeroPadding=false;else this._zeroPadding=o(t.zeroPadding,true);this._buffered=[];this._bufferedBytes=0}a.prototype._transform=function(e,t,r){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var i=n.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}r()};a.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(n.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(n.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:31,defined:37,inherits:49,"readable-stream":77}],27:[function(e,t,n){},{}],28:[function(e,t,n){arguments[4][27][0].apply(n,arguments)},{dup:27}],29:[function(e,t,n){var r=t.exports={};var i=[];var o=false;var a;var s=-1;function c(){o=false;if(a.length){i=a.concat(i)}else{s=-1}if(i.length){f()}}function f(){if(o){return}var e=setTimeout(c);o=true;var t=i.length;while(t){a=i;i=[];while(++s<t){a[s].run()}s=-1;t=i.length}a=null;o=false;clearTimeout(e)}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}}i.push(new l(e,t));if(i.length===1&&!o){setTimeout(f,0)}};function l(e,t){this.fun=e;this.array=t}l.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function u(){}r.on=u;r.addListener=u;r.once=u;r.off=u;r.removeListener=u;r.removeAllListeners=u;r.emit=u;r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")};r.umask=function(){return 0}},{}],30:[function(t,n,r){(function(t){(function(i){var o=typeof r=="object"&&r&&!r.nodeType&&r;var a=typeof n=="object"&&n&&!n.nodeType&&n;var s=typeof t=="object"&&t;if(s.global===s||s.window===s||s.self===s){i=s}var c,f=2147483647,l=36,u=1,p=26,d=38,h=700,v=72,m=128,g="-",y=/^xn--/,w=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,_={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=l-u,k=Math.floor,E=String.fromCharCode,S;function A(e){throw RangeError(_[e])}function T(e,t){var n=e.length;var r=[];while(n--){r[n]=t(e[n])}return r}function C(e,t){var n=e.split("@");var r="";if(n.length>1){r=n[0]+"@";e=n[1]}e=e.replace(b,".");var i=e.split(".");var o=T(i,t).join(".");return r+o}function I(e){var t=[],n=0,r=e.length,i,o;while(n<r){i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){o=e.charCodeAt(n++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);n--}}else{t.push(i)}}return t}function j(e){return T(e,function(e){var t="";if(e>65535){e-=65536;t+=E(e>>>10&1023|55296);e=56320|e&1023}t+=E(e);return t}).join("")}function L(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return l}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function B(e,t,n){var r=0;e=n?k(e/h):e>>1;e+=k(e/t);for(;e>x*p>>1;r+=l){e=k(e/x)}return k(r+(x+1)*e/(e+d))}function P(e){var t=[],n=e.length,r,i=0,o=m,a=v,s,c,d,h,y,w,b,_,x;s=e.lastIndexOf(g);if(s<0){s=0}for(c=0;c<s;++c){if(e.charCodeAt(c)>=128){A("not-basic")}t.push(e.charCodeAt(c))}for(d=s>0?s+1:0;d<n;){for(h=i,y=1,w=l;;w+=l){if(d>=n){A("invalid-input")}b=L(e.charCodeAt(d++));if(b>=l||b>k((f-i)/y)){A("overflow")}i+=b*y;_=w<=a?u:w>=a+p?p:w-a;if(b<_){break}x=l-_;if(y>k(f/x)){A("overflow")}y*=x}r=t.length+1;a=B(i-h,r,h==0);if(k(i/r)>f-o){A("overflow")}o+=k(i/r);i%=r;t.splice(i++,0,o)}return j(t)}function O(e){var t,n,r,i,o,a,s,c,d,h,y,w=[],b,_,x,S;e=I(e);b=e.length;t=m;n=0;o=v;for(a=0;a<b;++a){y=e[a];if(y<128){w.push(E(y))}}r=i=w.length;if(i){w.push(g)}while(r<b){for(s=f,a=0;a<b;++a){y=e[a];if(y>=t&&y<s){s=y}}_=r+1;if(s-t>k((f-n)/_)){A("overflow")}n+=(s-t)*_;t=s;for(a=0;a<b;++a){y=e[a];if(y<t&&++n>f){A("overflow")}if(y==t){for(c=n,d=l;;d+=l){h=d<=o?u:d>=o+p?p:d-o;if(c<h){break}S=c-h;x=l-h;w.push(E(R(h+S%x,0)));c=k(S/x)}w.push(E(R(c,0)));o=B(n,_,r==i);n=0;++r}}++n;++t}return w.join("")}function M(e){return C(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function U(e){return C(e,function(e){return w.test(e)?"xn--"+O(e):e})}c={version:"1.3.2",ucs2:{decode:I,encode:j},decode:P,encode:O,toASCII:U,toUnicode:M};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return c})}else if(o&&a){if(n.exports==o){a.exports=c}else{for(S in c){c.hasOwnProperty(S)&&(o[S]=c[S])}}}else{i.punycode=c}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],31:[function(e,t,n){var r=e("base64-js");var i=e("ieee754");var o=e("is-array");n.Buffer=c;n.SlowBuffer=w;n.INSPECT_MAX_BYTES=50;c.poolSize=8192;var a=1073741823;var s={};c.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(n){return false}}();function c(e){if(!(this instanceof c)){if(arguments.length>1)return new c(e,arguments[1]);return new c(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return f(this,e)}if(typeof e==="string"){return l(this,e,arguments.length>1?arguments[1]:"utf8")}return u(this,e)}function f(e,t){e=g(e,t<0?0:y(t)|0);if(!c.TYPED_ARRAY_SUPPORT){for(var n=0;n<t;n++){e[n]=0}}return e}function l(e,t,n){if(typeof n!=="string"||n==="")n="utf8";var r=b(t,n)|0;e=g(e,r);e.write(t,n);return e}function u(e,t){if(c.isBuffer(t))return p(e,t);if(o(t))return d(e,t);if(t==null){throw new TypeError("must start with number, buffer, array or string")}if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer){return h(e,t)}if(t.length)return v(e,t);return m(e,t)}function p(e,t){var n=y(t.length)|0;e=g(e,n);t.copy(e,0,0,n);return e}function d(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function h(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function v(e,t){var n=y(t.length)|0;e=g(e,n);for(var r=0;r<n;r+=1){e[r]=t[r]&255}return e}function m(e,t){var n;var r=0;if(t.type==="Buffer"&&o(t.data)){n=t.data;r=y(n.length)|0}e=g(e,r);for(var i=0;i<r;i+=1){e[i]=n[i]&255}return e}function g(e,t){if(c.TYPED_ARRAY_SUPPORT){e=c._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var n=t!==0&&t<=c.poolSize>>>1;if(n)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 w(e,t){if(!(this instanceof w))return new w(e,t);var n=new c(e,t);delete n.parent;return n}c.isBuffer=function X(e){return!!(e!=null&&e._isBuffer)};c.compare=function Z(e,t){if(!c.isBuffer(e)||!c.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var n=e.length;var r=t.length;var i=0;var o=Math.min(n,r);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){n=e[i];r=t[i]}if(n<r)return-1;if(r<n)return 1;return 0};c.isEncoding=function Q(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};c.concat=function ee(e,t){if(!o(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new c(0)}else if(e.length===1){return e[0]}var n;if(t===undefined){t=0;for(n=0;n<e.length;n++){t+=e[n].length}}var r=new c(t);var i=0;for(n=0;n<e.length;n++){var a=e[n];a.copy(r,i);i+=a.length}return r};function b(e,t){if(typeof e!=="string")e=String(e);if(e.length===0)return 0;switch(t||"utf8"){case"ascii":case"binary":case"raw":return e.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e.length*2;case"hex":return e.length>>>1;case"utf8":case"utf-8":return Y(e).length;case"base64":return V(e).length;default:return e.length}}c.byteLength=b;c.prototype.length=undefined;c.prototype.parent=undefined;c.prototype.toString=function te(e,t,n){var r=false;t=t|0;n=n===undefined||n===Infinity?this.length:n|0;if(!e)e="utf8";if(t<0)t=0;if(n>this.length)n=this.length;if(n<=t)return"";while(true){switch(e){case"hex":return L(this,t,n);case"utf8":case"utf-8":return C(this,t,n);case"ascii":return I(this,t,n);case"binary":return j(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();r=true}}};c.prototype.equals=function ne(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return c.compare(this,e)===0};c.prototype.inspect=function re(){var e="";var t=n.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};c.prototype.compare=function ie(e){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return c.compare(this,e)};c.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(c.isBuffer(e)){return n(this,e,t)}if(typeof e==="number"){if(c.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return n(this,[e],t)}function n(e,t,n){var r=-1;for(var i=0;n+i<e.length;i++){if(e[n+i]===t[r===-1?0:i-r]){if(r===-1)r=i;if(i-r+1===t.length)return n+r}else{r=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};c.prototype.get=function ae(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};c.prototype.set=function se(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function _(e,t,n,r){n=Number(n)||0;var i=e.length-n;if(!r){r=i}else{r=Number(r);if(r>i){r=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(r>o/2){r=o/2}for(var a=0;a<r;a++){var s=parseInt(t.substr(a*2,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[n+a]=s}return a}function x(e,t,n,r){return $(Y(t,e.length-n),e,n,r)}function k(e,t,n,r){return $(G(t),e,n,r)}function E(e,t,n,r){return k(e,t,n,r)}function S(e,t,n,r){return $(V(t),e,n,r)}function A(e,t,n,r){return $(J(t,e.length-n),e,n,r)}c.prototype.write=function ce(e,t,n,r){if(t===undefined){r="utf8";n=this.length;t=0}else if(n===undefined&&typeof t==="string"){r=t;n=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(n)){n=n|0;if(r===undefined)r="utf8"}else{r=n;n=undefined}}else{var i=r;r=t;t=n|0;n=i}var o=this.length-t;if(n===undefined||n>o)n=o;if(e.length>0&&(n<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!r)r="utf8";var a=false;for(;;){switch(r){case"hex":return _(this,e,t,n);case"utf8":case"utf-8":return x(this,e,t,n);case"ascii":return k(this,e,t,n);case"binary":return E(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(a)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase();a=true}}};c.prototype.toJSON=function fe(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,n){if(t===0&&n===e.length){return r.fromByteArray(e)}else{return r.fromByteArray(e.slice(t,n))}}function C(e,t,n){var r="";var i="";n=Math.min(e.length,n);for(var o=t;o<n;o++){if(e[o]<=127){r+=K(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return r+K(i)}function I(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;i++){r+=String.fromCharCode(e[i]&127)}return r}function j(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;i++){r+=String.fromCharCode(e[i])}return r}function L(e,t,n){var r=e.length;if(!t||t<0)t=0;if(!n||n<0||n>r)n=r;var i="";for(var o=t;o<n;o++){i+=W(e[o])}return i}function R(e,t,n){var r=e.slice(t,n);var i="";for(var o=0;o<r.length;o+=2){i+=String.fromCharCode(r[o]+r[o+1]*256)}return i}c.prototype.slice=function le(e,t){var n=this.length;e=~~e;t=t===undefined?n:~~t;if(e<0){e+=n;if(e<0)e=0}else if(e>n){e=n}if(t<0){t+=n;if(t<0)t=0}else if(t>n){t=n}if(t<e)t=e;var r;if(c.TYPED_ARRAY_SUPPORT){r=c._augment(this.subarray(e,t))}else{var i=t-e;r=new c(i,undefined);for(var o=0;o<i;o++){r[o]=this[o+e]}}if(r.length)r.parent=this.parent||this;return r};function B(e,t,n){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUIntLE=function ue(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){r+=this[e+o]*i}return r};c.prototype.readUIntBE=function pe(e,t,n){e=e|0;t=t|0;if(!n){B(e,t,this.length)}var r=this[e+--t];var i=1;while(t>0&&(i*=256)){r+=this[e+--t]*i}return r};c.prototype.readUInt8=function de(e,t){if(!t)B(e,1,this.length);return this[e]};c.prototype.readUInt16LE=function he(e,t){if(!t)B(e,2,this.length);return this[e]|this[e+1]<<8};c.prototype.readUInt16BE=function ve(e,t){if(!t)B(e,2,this.length);return this[e]<<8|this[e+1]};c.prototype.readUInt32LE=function me(e,t){if(!t)B(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};c.prototype.readUInt32BE=function ge(e,t){if(!t)B(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};c.prototype.readIntLE=function ye(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){r+=this[e+o]*i}i*=128;if(r>=i)r-=Math.pow(2,8*t);return r};c.prototype.readIntBE=function we(e,t,n){e=e|0;t=t|0;if(!n)B(e,t,this.length);var r=t;var i=1;var o=this[e+--r];while(r>0&&(i*=256)){o+=this[e+--r]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};c.prototype.readInt8=function be(e,t){if(!t)B(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};c.prototype.readInt16LE=function _e(e,t){if(!t)B(e,2,this.length);var n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};c.prototype.readInt16BE=function xe(e,t){if(!t)B(e,2,this.length);var n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};c.prototype.readInt32LE=function ke(e,t){if(!t)B(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};c.prototype.readInt32BE=function Ee(e,t){if(!t)B(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};c.prototype.readFloatLE=function Se(e,t){if(!t)B(e,4,this.length);return i.read(this,e,true,23,4)};c.prototype.readFloatBE=function Ae(e,t){if(!t)B(e,4,this.length);return i.read(this,e,false,23,4)};c.prototype.readDoubleLE=function Te(e,t){if(!t)B(e,8,this.length);return i.read(this,e,true,52,8)};c.prototype.readDoubleBE=function Ce(e,t){if(!t)B(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,n,r,i,o){if(!c.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range")}c.prototype.writeUIntLE=function Ie(e,t,n,r){e=+e;t=t|0;n=n|0;if(!r)P(this,e,t,n,Math.pow(2,8*n),0);var i=1;var o=0;this[t]=e&255;while(++o<n&&(i*=256)){this[t+o]=e/i&255}return t+n};c.prototype.writeUIntBE=function je(e,t,n,r){e=+e;t=t|0;n=n|0;if(!r)P(this,e,t,n,Math.pow(2,8*n),0);var i=n-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255}return t+n};c.prototype.writeUInt8=function Le(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,1,255,0);if(!c.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function O(e,t,n,r){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-n,2);i<o;i++){e[n+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}}c.prototype.writeUInt16LE=function Re(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};c.prototype.writeUInt16BE=function Be(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,65535,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};function M(e,t,n,r){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-n,4);i<o;i++){e[n+i]=t>>>(r?i:3-i)*8&255}}c.prototype.writeUInt32LE=function Pe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{M(this,e,t,true)}return t+4};c.prototype.writeUInt32BE=function Oe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,4294967295,0);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};c.prototype.writeIntLE=function Me(e,t,n,r){e=+e;t=t|0;if(!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=0;var a=1;var s=e<0?1:0;this[t]=e&255;while(++o<n&&(a*=256)){this[t+o]=(e/a>>0)-s&255}return t+n};c.prototype.writeIntBE=function Ue(e,t,n,r){e=+e;t=t|0;if(!r){var i=Math.pow(2,8*n-1);P(this,e,t,n,i-1,-i)}var o=n-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+n};c.prototype.writeInt8=function ze(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,1,127,-128);if(!c.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};c.prototype.writeInt16LE=function He(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};c.prototype.writeInt16BE=function Ne(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,2,32767,-32768);if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};c.prototype.writeInt32LE=function qe(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,2147483647,-2147483648);if(c.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{M(this,e,t,true)}return t+4};c.prototype.writeInt32BE=function De(e,t,n){e=+e;t=t|0;if(!n)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(c.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};function U(e,t,n,r,i,o){if(t>i||t<o)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(n<0)throw new RangeError("index out of range")}function z(e,t,n,r,o){if(!o){U(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,n,r,23,4);return n+4}c.prototype.writeFloatLE=function Fe(e,t,n){return z(this,e,t,true,n)};c.prototype.writeFloatBE=function We(e,t,n){return z(this,e,t,false,n)};function H(e,t,n,r,o){if(!o){U(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,n,r,52,8);return n+8}c.prototype.writeDoubleLE=function Ye(e,t,n){return H(this,e,t,true,n)};c.prototype.writeDoubleBE=function Ge(e,t,n){return H(this,e,t,false,n)};c.prototype.copy=function Je(e,t,n,r){if(!n)n=0;if(!r&&r!==0)r=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(r>0&&r<n)r=n;if(r===n)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");if(r>this.length)r=this.length;if(e.length-t<r-n){r=e.length-t+n}var i=r-n;if(i<1e3||!c.TYPED_ARRAY_SUPPORT){for(var o=0;o<i;o++){e[o+t]=this[o+n]}}else{e._set(this.subarray(n,n+i),t)}return i};c.prototype.fill=function Ve(e,t,n){if(!e)e=0;if(!t)t=0;if(!n)n=this.length;if(n<t)throw new RangeError("end < start");if(n===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(n<0||n>this.length)throw new RangeError("end out of bounds");var r;if(typeof e==="number"){for(r=t;r<n;r++){this[r]=e}}else{var i=Y(e.toString());var o=i.length;for(r=t;r<n;r++){this[r]=i[r%o]}}return this};c.prototype.toArrayBuffer=function $e(){if(typeof Uint8Array!=="undefined"){if(c.TYPED_ARRAY_SUPPORT){return new c(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,n=e.length;t<n;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var N=c.prototype;c._augment=function Ke(e){e.constructor=c;e._isBuffer=true;e._set=e.set;e.get=N.get;e.set=N.set;e.write=N.write;e.toString=N.toString;e.toLocaleString=N.toString;e.toJSON=N.toJSON;e.equals=N.equals;e.compare=N.compare;e.indexOf=N.indexOf;e.copy=N.copy;e.slice=N.slice;e.readUIntLE=N.readUIntLE;e.readUIntBE=N.readUIntBE;e.readUInt8=N.readUInt8;e.readUInt16LE=N.readUInt16LE;e.readUInt16BE=N.readUInt16BE;e.readUInt32LE=N.readUInt32LE;e.readUInt32BE=N.readUInt32BE;e.readIntLE=N.readIntLE;e.readIntBE=N.readIntBE;e.readInt8=N.readInt8;e.readInt16LE=N.readInt16LE;e.readInt16BE=N.readInt16BE;e.readInt32LE=N.readInt32LE;e.readInt32BE=N.readInt32BE;e.readFloatLE=N.readFloatLE;e.readFloatBE=N.readFloatBE;e.readDoubleLE=N.readDoubleLE;e.readDoubleBE=N.readDoubleBE;e.writeUInt8=N.writeUInt8;e.writeUIntLE=N.writeUIntLE;e.writeUIntBE=N.writeUIntBE;e.writeUInt16LE=N.writeUInt16LE;e.writeUInt16BE=N.writeUInt16BE;e.writeUInt32LE=N.writeUInt32LE;e.writeUInt32BE=N.writeUInt32BE;e.writeIntLE=N.writeIntLE;e.writeIntBE=N.writeIntBE;e.writeInt8=N.writeInt8;e.writeInt16LE=N.writeInt16LE;e.writeInt16BE=N.writeInt16BE;e.writeInt32LE=N.writeInt32LE;e.writeInt32BE=N.writeInt32BE;e.writeFloatLE=N.writeFloatLE;e.writeFloatBE=N.writeFloatBE;e.writeDoubleLE=N.writeDoubleLE;e.writeDoubleBE=N.writeDoubleBE;e.fill=N.fill;e.inspect=N.inspect;e.toArrayBuffer=N.toArrayBuffer;return e};var q=/[^+\/0-9A-z\-]/g;function D(e){e=F(e).replace(q,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function F(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function W(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function Y(e,t){t=t||Infinity;var n;var r=e.length;var i=null;var o=[];var a=0;for(;a<r;a++){n=e.charCodeAt(a);if(n>55295&&n<57344){if(i){if(n<56320){if((t-=3)>-1)o.push(239,191,189);i=n;continue}else{n=i-55296<<10|n-56320|65536;i=null}}else{if(n>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(a+1===r){if((t-=3)>-1)o.push(239,191,189);continue}else{i=n;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<2097152){if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else{throw new Error("Invalid code point")}}return o}function G(e){var t=[];for(var n=0;n<e.length;n++){t.push(e.charCodeAt(n)&255)}return t}function J(e,t){var n,r,i;var o=[];for(var a=0;a<e.length;a++){if((t-=2)<0)break;n=e.charCodeAt(a);r=n>>8;i=n%256;o.push(i);o.push(r)}return o}function V(e){return r.toByteArray(D(e))}function $(e,t,n,r){for(var i=0;i<r;i++){if(i+n>=t.length||i>=e.length)break;t[i+n]=e[i]}return i}function K(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":12,ieee754:48,"is-array":50}],32:[function(e,t,n){t.exports=function(e,t){var n=Infinity;var r=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,a=t.length;o<a;o++){r=Math.abs(e-t[o]);if(r>=n){break}n=r;i=t[o]}return i}},{}],33:[function(e,t,n){(function(e){function t(e){return Array.isArray(e)}n.isArray=t;function r(e){return typeof e==="boolean"}n.isBoolean=r;function i(e){return e===null}n.isNull=i;function o(e){return e==null}n.isNullOrUndefined=o;function a(e){return typeof e==="number"}n.isNumber=a;function s(e){return typeof e==="string"}n.isString=s;function c(e){return typeof e==="symbol"}n.isSymbol=c;function f(e){return e===void 0}n.isUndefined=f;function l(e){return u(e)&&g(e)==="[object RegExp]"}n.isRegExp=l;function u(e){return typeof e==="object"&&e!==null}n.isObject=u;function p(e){return u(e)&&g(e)==="[object Date]"}n.isDate=p;function d(e){return u(e)&&(g(e)==="[object Error]"||e instanceof Error)}n.isError=d;function h(e){return typeof e==="function"}n.isFunction=h;function v(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}n.isPrimitive=v;function m(t){return e.isBuffer(t)}n.isBuffer=m;function g(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:31}],34:[function(e,t,n){(function(n,r){t.exports=y;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=w;var i=e("bencode");var o=e("block-stream2");var a=e("piece-length");var s=e("path");var c=e("dezalgo");var f=e("filestream/read");var l=e("flatten");var u=e("fs");var p=e("is-file");var d=e("multistream");var h=e("once");var v=e("run-parallel");var m=e("simple-sha1");var g=e("stream");function y(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};w(e,t,function(e,r,i){if(e)return n(e);t.singleFileTorrent=i;S(r,t,n)})}function w(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};n=c(n);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(C(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"&&s.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);var o=e.length===1;if(e.length===1&&typeof e[0]==="string"){p(e[0],function(e,t){if(e)return n(e);o=t;a()})}else{a()}function a(){v(e.map(function(e){return function(n){var a={};if(T(e)){a.getStream=j(e);a.length=e.size}else if(r.isBuffer(e)){a.getStream=L(e);a.length=e.length}else if(I(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}a.getStream=B(e,a);a.length=0}else if(typeof e==="string"){if(typeof u.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var c=i>1||o;b(e,c,n);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");a.path=e.name.split(s.sep);n(null,a)}}),function(e,t){if(e)return n(e);t=l(t);n(null,t,o)})}}function b(e,t,n){x(e,_,function(r,i){if(r)return n(r);if(Array.isArray(i))i=l(i);else i=[i];e=s.normalize(e);if(t){e=e.slice(0,e.lastIndexOf(s.sep)+1)}if(e[e.length-1]!==s.sep)e+=s.sep;i.forEach(function(t){t.getStream=R(t.path);t.path=t.path.replace(e,"").split(s.sep)});n(null,i)})}function _(e,t){t=h(t);u.stat(e,function(n,r){if(n)return t(n);var i={length:r.size,path:e};t(null,i)})}function x(e,t,n){u.readdir(e,function(r,i){if(r&&r.code==="ENOTDIR"){t(e,n)}else if(r){n(r)}else{v(i.filter(k).map(function(n){return function(r){x(s.join(e,n),t,r)}}),n)}})}function k(e){return e[0]!=="."}function E(e,t,n){n=h(n);var i=[];var a=0;var s=e.map(function(e){return e.getStream});var c=0;var f=0;var l=false;var u=new d(s);var p=new o(t,{zeroPadding:false});u.on("error",y);u.pipe(p).on("data",v).on("end",g).on("error",y);function v(e){a+=e.length;var t=f;m(e,function(e){i[t]=e;c-=1;b()});c+=1;f+=1}function g(){l=true;b()}function y(e){w();n(e)}function w(){u.removeListener("error",y);p.removeListener("data",v);p.removeListener("end",g);p.removeListener("error",y)}function b(){if(l&&c===0){w();n(null,new r(i.join(""),"hex"),a)}}}function S(e,r,o){var s=r.announceList;if(!s){if(typeof r.announce==="string")s=[[r.announce]];else if(Array.isArray(r.announce)){
+s=r.announce.map(function(e){return[e]})}}if(!s)s=[];if(n.WEBTORRENT_ANNOUNCE){if(typeof n.WEBTORRENT_ANNOUNCE==="string"){s.push([[n.WEBTORRENT_ANNOUNCE]])}else if(Array.isArray(n.WEBTORRENT_ANNOUNCE)){s=s.concat(n.WEBTORRENT_ANNOUNCE.map(function(e){return[e]}))}}if(s.length===0){s=s.concat(t.exports.announceList)}var c={info:{name:r.name},announce:s[0][0],"announce-list":s,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)c.comment=r.comment;if(r.createdBy!==undefined)c["created by"]=r.createdBy;if(r.private!==undefined)c.info.private=Number(r.private);if(r.sslCert!==undefined)c.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)c["url-list"]=r.urlList;var f=r.pieceLength||a(e.reduce(A,0));c.info["piece length"]=f;E(e,f,function(t,n,a){if(t)return o(t);c.info.pieces=n;e.forEach(function(e){delete e.getStream});if(r.singleFileTorrent){c.info.length=a}else{c.info.files=e}o(null,i.encode(c))})}function A(e,t){return e+t.length}function T(e){return typeof Blob!=="undefined"&&e instanceof Blob}function C(e){return typeof FileList==="function"&&e instanceof FileList}function I(e){return typeof e==="object"&&typeof e.pipe==="function"}function j(e){return function(){return new f(e)}}function L(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function R(e){return function(){return u.createReadStream(e)}}function B(e,t){return function(){var n=new g.Transform;n._transform=function(e,n,r){t.length+=e.length;this.push(e);r()};e.pipe(n);return n}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{bencode:13,"block-stream2":26,buffer:31,dezalgo:38,"filestream/read":41,flatten:42,fs:28,"is-file":51,multistream:58,once:59,path:62,"piece-length":63,"run-parallel":80,"simple-sha1":83,stream:86}],35:[function(e,t,n){n=t.exports=e("./debug");n.log=o;n.formatArgs=i;n.save=a;n.load=s;n.useColors=r;n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c();n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function r(){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}n.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 ":" ")+"+"+n.humanize(this.diff);if(!t)return e;var r="color: "+this.color;e=[e[0],r,"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,r);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){n.storage.removeItem("debug")}else{n.storage.debug=e}}catch(t){}}function s(){var e;try{e=n.storage.debug}catch(t){}return e}n.enable(s());function c(){try{return window.localStorage}catch(e){}}},{"./debug":36}],36:[function(e,t,n){n=t.exports=a;n.coerce=l;n.disable=c;n.enable=s;n.enabled=f;n.humanize=e("ms");n.names=[];n.skips=[];n.formatters={};var r=0;var i;function o(){return n.colors[r++%n.colors.length]}function a(e){function t(){}t.enabled=false;function r(){var e=r;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=n.useColors();if(null==e.color&&e.useColors)e.color=o();var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]);if("string"!==typeof s[0]){s=["%o"].concat(s)}var c=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if(t==="%%")return t;c++;var i=n.formatters[r];if("function"===typeof i){var o=s[c];t=i.call(e,o);s.splice(c,1);c--}return t});if("function"===typeof n.formatArgs){s=n.formatArgs.apply(e,s)}var f=r.log||n.log||console.log.bind(console);f.apply(e,s)}r.enabled=true;var a=n.enabled(e)?r:t;a.namespace=e;return a}function s(e){n.save(e);var t=(e||"").split(/[\s,]+/);var r=t.length;for(var i=0;i<r;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){n.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{n.names.push(new RegExp("^"+e+"$"))}}}function c(){n.enable("")}function f(e){var t,r;for(t=0,r=n.skips.length;t<r;t++){if(n.skips[t].test(e)){return false}}for(t=0,r=n.names.length;t<r;t++){if(n.names[t].test(e)){return true}}return false}function l(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:57}],37:[function(e,t,n){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],38:[function(e,t,n){var r=e("wrappy");t.exports=r(o);var i=e("asap");function o(e){var t=true;i(function(){t=false});return function n(){var n=arguments;var r=this;if(t)i(function(){e.apply(r,n)});else e.apply(r,n)}}},{asap:10,wrappy:97}],39:[function(e,t,n){var r=e("once");var i=function(){};var o=function(e){return e.setHeader&&typeof e.abort==="function"};var a=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var s=function(e,t,n){if(typeof t==="function")return s(e,null,t);if(!t)t={};n=r(n||i);var c=e._writableState;var f=e._readableState;var l=t.readable||t.readable!==false&&e.readable;var u=t.writable||t.writable!==false&&e.writable;var p=function(){if(!e.writable)d()};var d=function(){u=false;if(!l)n()};var h=function(){l=false;if(!u)n()};var v=function(e){n(e?new Error("exited with error code: "+e):null)};var m=function(){if(l&&!(f&&f.ended))return n(new Error("premature close"));if(u&&!(c&&c.ended))return n(new Error("premature close"))};var g=function(){e.req.on("finish",d)};if(o(e)){e.on("complete",d);e.on("abort",m);if(e.req)g();else e.on("request",g)}else if(u&&!c){e.on("end",p);e.on("close",p)}if(a(e))e.on("exit",v);e.on("end",h);e.on("finish",d);if(t.error!==false)e.on("error",n);e.on("close",m);return function(){e.removeListener("complete",d);e.removeListener("abort",m);e.removeListener("request",g);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",p);e.removeListener("close",p);e.removeListener("finish",d);e.removeListener("exit",v);e.removeListener("end",h);e.removeListener("error",n);e.removeListener("close",m)}};t.exports=s},{once:59}],40:[function(e,t,n){function r(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=r;r.EventEmitter=r;r.prototype._events=undefined;r.prototype._maxListeners=undefined;r.defaultMaxListeners=10;r.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};r.prototype.emit=function(e){var t,n,r,o,c,f;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.')}}n=this._events[e];if(s(n))return false;if(i(n)){switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:r=arguments.length;o=new Array(r-1);for(c=1;c<r;c++)o[c-1]=arguments[c];n.apply(this,o)}}else if(a(n)){r=arguments.length;o=new Array(r-1);for(c=1;c<r;c++)o[c-1]=arguments[c];f=n.slice();r=f.length;for(c=0;c<r;c++)f[c].apply(this,o)}return true};r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(a(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(a(this._events[e])&&!this._events[e].warned){var n;if(!s(this._maxListeners)){n=this._maxListeners}else{n=r.defaultMaxListeners}if(n&&n>0&&this._events[e].length>n){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};r.prototype.on=r.prototype.addListener;r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=false;function r(){this.removeListener(e,r);if(!n){n=true;t.apply(this,arguments)}}r.listener=t;this.on(e,r);return this};r.prototype.removeListener=function(e,t){var n,r,o,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;n=this._events[e];o=n.length;r=-1;if(n===t||i(n.listener)&&n.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(a(n)){for(s=o;s-->0;){if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}}if(r<0)return this;if(n.length===1){n.length=0;delete this._events[e]}else{n.splice(r,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener){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}n=this._events[e];if(i(n)){this.removeListener(e,n)}else{while(n.length)this.removeListener(e,n[n.length-1])}delete this._events[e];return this};r.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};r.listenerCount=function(e,t){var n;if(!e._events||!e._events[t])n=0;else if(i(e._events[t]))n=1;else n=e._events[t].length;return n};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}},{}],41:[function(e,t,n){var r=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var a=e("typedarray-to-buffer");function s(e,t){var n=this;if(!(this instanceof s)){return new s(e,t)}t=t||{};r.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 n.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){n.push(e)})}n._ready=true;n.emit("_ready")})}i(s,r);t.exports=s;s.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])};s.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var n=this._offset;var r=this._offset+this._chunkSize;if(r>this._size)r=this._size;if(n===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=r;e.push(a(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(n,r))};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:49,stream:86,"typedarray-to-buffer":91}],42:[function(e,t,n){t.exports=function r(e,t){t=typeof t=="number"?t:Infinity;return n(e,1);function n(e,r){return e.reduce(function(e,i){if(Array.isArray(i)&&r<t){return e.concat(n(i,r+1))}else{return e.concat(i)}},[])}}},{}],43:[function(e,t,n){t.exports=function r(){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}},{}],44:[function(e,t,n){var r=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var n=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;n===Infinity;i*=2){n=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=n-Math.floor(n);var a="";for(var i=0;i<Math.floor(n);i++){var s=Math.floor(Math.random()*t).toString(t);a=s+a}if(o){var c=Math.pow(t,o);var s=Math.floor(Math.random()*c).toString(t);a=s+a}var f=parseInt(a,t);if(f!==Infinity&&f>=Math.pow(2,e)){return r(e,t)}else return a};r.rack=function(e,t,n){var i=function(i){var a=0;do{if(a++>10){if(n)e+=n;else throw new Error("too many ID collisions, use more bits")}var s=r(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}},{}],45:[function(e,t,n){var r=t.exports;var i=e("events").EventEmitter;var o=e("./lib/request");var a=e("url");r.request=function(e,t){if(typeof e==="string"){e=a.parse(e)}if(!e)e={};if(!e.host&&!e.port){e.port=parseInt(window.location.port,10)}if(!e.host&&e.hostname){e.host=e.hostname}if(!e.protocol){if(e.scheme){e.protocol=e.scheme+":"}else{e.protocol=window.location.protocol}}if(!e.host){e.host=window.location.hostname||window.location.host}if(/:/.test(e.host)){if(!e.port){e.port=e.host.split(":")[1]}e.host=e.host.split(":")[0]}if(!e.port)e.port=e.protocol=="https:"?443:80;var n=new o(new s,e);if(t)n.on("response",t);return n};r.get=function(e,t){e.method="GET";var n=r.request(e,t);n.end();return n};r.Agent=function(){};r.Agent.defaultMaxSockets=4;var s=function(){if(typeof window==="undefined"){throw new Error("no window object present")}else if(window.XMLHttpRequest){return window.XMLHttpRequest}else if(window.ActiveXObject){var e=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];for(var t=0;t<e.length;t++){try{var n=new window.ActiveXObject(e[t]);return function(){if(n){var r=n;n=null;return r}else{return new window.ActiveXObject(e[t])}}}catch(r){}}throw new Error("ajax not supported in this browser")}else{throw new Error("ajax not supported in this browser")}}();r.STATUS_CODES={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{"./lib/request":46,events:40,url:93}],46:[function(e,t,n){var r=e("stream");var i=e("./response");var o=e("Base64");var a=e("inherits");var s=t.exports=function(e,t){var n=this;n.writable=true;n.xhr=e;n.body=[];n.uri=(t.protocol||"http:")+"//"+t.host+(t.port?":"+t.port:"")+(t.path||"/");if(typeof t.withCredentials==="undefined"){t.withCredentials=true}try{e.withCredentials=t.withCredentials}catch(r){}if(t.responseType)try{e.responseType=t.responseType}catch(r){}e.open(t.method||"GET",n.uri,true);e.onerror=function(e){n.emit("error",new Error("Network error"))};n._headers={};if(t.headers){var a=c(t.headers);for(var s=0;s<a.length;s++){var f=a[s];if(!n.isSafeRequestHeader(f))continue;var l=t.headers[f];n.setHeader(f,l)}}if(t.auth){this.setHeader("Authorization","Basic "+o.btoa(t.auth))}var u=new i;u.on("close",function(){n.emit("close")});u.on("ready",function(){n.emit("response",u)});u.on("error",function(e){n.emit("error",e)});e.onreadystatechange=function(){if(e.__aborted)return;u.handle(e)}};a(s,r);s.prototype.setHeader=function(e,t){this._headers[e.toLowerCase()]=t};s.prototype.getHeader=function(e){return this._headers[e.toLowerCase()]};s.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]};s.prototype.write=function(e){this.body.push(e)};s.prototype.destroy=function(e){this.xhr.__aborted=true;this.xhr.abort();this.emit("close")};s.prototype.end=function(e){if(e!==undefined)this.body.push(e);var t=c(this._headers);for(var n=0;n<t.length;n++){var r=t[n];var i=this._headers[r];if(f(i)){for(var o=0;o<i.length;o++){this.xhr.setRequestHeader(r,i[o])}}else this.xhr.setRequestHeader(r,i)}if(this.body.length===0){this.xhr.send("")}else if(typeof this.body[0]==="string"){this.xhr.send(this.body.join(""))}else if(f(this.body[0])){var a=[];for(var n=0;n<this.body.length;n++){a.push.apply(a,this.body[n])}this.xhr.send(a)}else if(/Array/.test(Object.prototype.toString.call(this.body[0]))){var s=0;for(var n=0;n<this.body.length;n++){s+=this.body[n].length}var a=new this.body[0].constructor(s);var l=0;for(var n=0;n<this.body.length;n++){var p=this.body[n];for(var o=0;o<p.length;o++){a[l++]=p[o]}}this.xhr.send(a)}else if(u(this.body[0])){this.xhr.send(this.body[0])}else{var a="";for(var n=0;n<this.body.length;n++){a+=this.body[n].toString()}this.xhr.send(a)}};s.unsafeHeaders=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","content-transfer-encoding","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"];s.prototype.isSafeRequestHeader=function(e){if(!e)return false;return l(s.unsafeHeaders,e.toLowerCase())===-1};var c=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};var f=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};var l=function(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;n<e.length;n++){if(e[n]===t)return n}return-1};var u=function(e){if(typeof Blob!=="undefined"&&e instanceof Blob)return true;if(typeof ArrayBuffer!=="undefined"&&e instanceof ArrayBuffer)return true;if(typeof FormData!=="undefined"&&e instanceof FormData)return true}},{"./response":47,Base64:8,inherits:49,stream:86}],47:[function(e,t,n){var r=e("stream");var i=e("util");var o=t.exports=function(e){this.offset=0;this.readable=true};i.inherits(o,r);var a={streaming:true,status2:true};function s(e){var t=e.getAllResponseHeaders().split(/\r?\n/);var n={};for(var r=0;r<t.length;r++){var i=t[r];if(i==="")continue;var o=i.match(/^([^:]+):\s*(.*)/);if(o){var a=o[1].toLowerCase(),s=o[2];if(n[a]!==undefined){if(c(n[a])){n[a].push(s)}else{n[a]=[n[a],s]}}else{n[a]=s}}else{n[i]=true}}return n}o.prototype.getResponse=function(e){var t=String(e.responseType).toLowerCase();if(t==="blob")return e.responseBlob||e.response;if(t==="arraybuffer")return e.response;return e.responseText};o.prototype.getHeader=function(e){return this.headers[e.toLowerCase()]};o.prototype.handle=function(e){if(e.readyState===2&&a.status2){try{this.statusCode=e.status;this.headers=s(e)}catch(t){a.status2=false}if(a.status2){this.emit("ready")}}else if(a.streaming&&e.readyState===3){try{if(!this.statusCode){this.statusCode=e.status;this.headers=s(e);this.emit("ready")}}catch(t){}try{this._emitData(e)}catch(t){a.streaming=false}}else if(e.readyState===4){if(!this.statusCode){this.statusCode=e.status;this.emit("ready")}this._emitData(e);if(e.error){this.emit("error",this.getResponse(e))}else this.emit("end");this.emit("close")}};o.prototype._emitData=function(e){var t=this.getResponse(e);if(t.toString().match(/ArrayBuffer/)){this.emit("data",new Uint8Array(t,this.offset));this.offset=t.byteLength;return}if(t.length>this.offset){this.emit("data",t.slice(this.offset));this.offset=t.length}};var c=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{stream:86,util:96}],48:[function(e,t,n){n.read=function(e,t,n,r,i){var o,a;var s=i*8-r-1;var c=(1<<s)-1;var f=c>>1;var l=-7;var u=n?i-1:0;var p=n?-1:1;var d=e[t+u];u+=p;o=d&(1<<-l)-1;d>>=-l;l+=s;for(;l>0;o=o*256+e[t+u],u+=p,l-=8){}a=o&(1<<-l)-1;o>>=-l;l+=r;for(;l>0;a=a*256+e[t+u],u+=p,l-=8){}if(o===0){o=1-f}else if(o===c){return a?NaN:(d?-1:1)*Infinity}else{a=a+Math.pow(2,r);o=o-f}return(d?-1:1)*a*Math.pow(2,o-r)};n.write=function(e,t,n,r,i,o){var a,s,c;var f=o*8-i-1;var l=(1<<f)-1;var u=l>>1;var p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=r?0:o-1;var h=r?1:-1;var v=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){s=isNaN(t)?1:0;a=l}else{a=Math.floor(Math.log(t)/Math.LN2);if(t*(c=Math.pow(2,-a))<1){a--;c*=2}if(a+u>=1){t+=p/c}else{t+=p*Math.pow(2,1-u)}if(t*c>=2){a++;c/=2}if(a+u>=l){s=0;a=l}else if(a+u>=1){s=(t*c-1)*Math.pow(2,i);a=a+u}else{s=t*Math.pow(2,u-1)*Math.pow(2,i);a=0}}for(;i>=8;e[n+d]=s&255,d+=h,s/=256,i-=8){}a=a<<i|s;f+=i;for(;f>0;e[n+d]=a&255,d+=h,a/=256,f-=8){}e[n+d-h]|=v*128}},{}],49:[function(e,t,n){if(typeof Object.create==="function"){t.exports=function r(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function i(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype;e.prototype=new n;e.prototype.constructor=e}}},{}],50:[function(e,t,n){var r=Array.isArray;var i=Object.prototype.toString;t.exports=r||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],51:[function(e,t,n){"use strict";var r=e("fs");t.exports=function o(e,t){if(!t)return i(e);r.stat(e,function(e,n){if(e)return t(e);return t(null,n.isFile())})};t.exports.sync=i;function i(e){return r.existsSync(e)&&r.statSync(e).isFile()}},{fs:28}],52:[function(e,t,n){t.exports=o;o.strict=a;o.loose=s;var r=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint8ClampedArray]":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 Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return i[r.call(e)]}},{}],53:[function(e,t,n){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],54:[function(e,t,n){(function(n){t.exports=a;t.exports.decode=a;t.exports.encode=s;var r=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 n=e.split("=");if(n.length!==2)return;var r=n[0];var i=n[1];if(r==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){i=decodeURIComponent(i)}if(r==="kt")i=decodeURIComponent(i).split("+");if(t[r]){if(Array.isArray(t[r])){t[r].push(i)}else{var o=t[r];t[r]=[o,i]}}else{t[r]=i}});var s;if(t.xt){var c=Array.isArray(t.xt)?t.xt:[t.xt];c.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new n(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=r.decode(s[1]);t.infoHash=new n(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(n,r){var i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach(function(e,i){if((r>0||i>0)&&(n!=="kt"||i===0))t+="&";if(n==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){e=encodeURIComponent(e)}if(n==="kt")e=encodeURIComponent(e);if(n==="kt"&&i>0)t+="+"+e;else t+=n+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:31,"thirty-two":88,uniq:92,xtend:98}],55:[function(e,t,n){(function(n){var r=e("path");var i=e("fs");function o(){this.types=Object.create(null);this.extensions=Object.create(null)}o.prototype.define=function(e){for(var t in e){var r=e[t];for(var i=0;i<r.length;i++){if(n.env.DEBUG_MIME&&this.types[r]){console.warn(this._loading.replace(/.*\//,""),'changes "'+r[i]+'" extension type from '+this.types[r]+" to "+t)}this.types[r[i]]=t}if(!this.extensions[t]){this.extensions[t]=r[0]}}};o.prototype.load=function(e){this._loading=e;var t={},n=i.readFileSync(e,"ascii"),r=n.split(/[\r\n]+/);r.forEach(function(e){var n=e.replace(/\s*#.*|^\s*|\s*$/g,"").split(/\s+/);t[n.shift()]=n});this.define(t);this._loading=null};o.prototype.lookup=function(e,t){var n=e.replace(/.*[\.\/\\]/,"").toLowerCase();return this.types[n]||t||this.default_type};o.prototype.extension=function(e){var t=e.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();return this.extensions[t]};var a=new o;a.define(e("./types.json"));a.default_type=a.lookup("bin");a.Mime=o;a.charsets={lookup:function(e,t){return/^text\//.test(e)?"UTF-8":t}};t.exports=a}).call(this,e("_process"))},{"./types.json":56,_process:29,fs:28,path:62}],56:[function(e,t,n){t.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],
+"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],57:[function(e,t,n){var r=1e3;var i=r*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 c(e);return t.long?l(e):f(e)};function c(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 n=parseFloat(t[1]);var c=(t[2]||"ms").toLowerCase();switch(c){case"years":case"year":case"yrs":case"yr":case"y":return n*s;case"days":case"day":case"d":return n*a;case"hours":case"hour":case"hrs":case"hr":case"h":return n*o;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}function f(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>=r)return Math.round(e/r)+"s";return e+"ms"}function l(e){return u(e,a,"day")||u(e,o,"hour")||u(e,i,"minute")||u(e,r,"second")||e+" ms"}function u(e,t,n){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+n;return Math.ceil(e/t)+" "+n+"s"}},{}],58:[function(e,t,n){t.exports=o;var r=e("inherits");var i=e("stream");r(o,i.Readable);function o(e,t){if(!(this instanceof o))return new o(e,t);i.Readable.call(this,t);this.destroyed=false;this._drained=false;this._forwarding=false;this._current=null;this._queue=e.map(a);this._next()}o.obj=function(e){return new o(e,{objectMode:true,highWaterMark:16})};o.prototype._read=function(){this._drained=true;this._forward()};o.prototype._forward=function(){if(this._forwarding||!this._drained)return;this._forwarding=true;var e;while((e=this._current.read())!==null){this._drained=this.push(e)}this._forwarding=false};o.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(this._current&&this._current.destroy)this._current.destroy();this._queue.forEach(function(e){if(e.destroy)e.destroy()});if(e)this.emit("error",e);this.emit("close")};o.prototype._next=function(){var e=this;var t=e._queue.shift();if(typeof t==="function")t=a(t());if(!t){e.destroy();e.push(null);return}e._current=t;t.on("readable",n);t.on("end",i);t.on("error",o);t.on("close",r);function n(){e._forward()}function r(){if(!t._readableState.ended){e.destroy()}}function i(){e._current=null;t.removeListener("readable",n);t.removeListener("end",i);t.removeListener("error",o);t.removeListener("close",r);e._next()}function o(t){e.destroy(t)}};function a(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new i.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:49,stream:86}],59:[function(e,t,n){var r=e("wrappy");t.exports=r(i);i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:true})});function i(e){var t=function(){if(t.called)return t.value;t.called=true;return t.value=e.apply(this,arguments)};t.called=false;return t}},{wrappy:97}],60:[function(e,t,n){(function(n){t.exports=s;t.exports.decode=s;t.exports.encode=c;var r=e("bencode");var i=e("path");var o=e("simple-sha1");var a=e("uniq");function s(e){if(n.isBuffer(e)){e=r.decode(e)}u(e.info,"info");u(e.info.name,"info.name");u(e.info["piece length"],"info['piece length']");u(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){u(typeof e.length==="number","info.files[0].length");u(e.path,"info.files[0].path")})}else{u(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=r.encode(e.info);t.infoHash=o.sync(t.infoBuffer);t.name=e.info.name.toString();t.private=!!e.info.private;if(e["creation date"])t.created=new Date(e["creation date"]*1e3);if(n.isBuffer(e.comment))t.comment=e.comment.toString();t.announce=[];if(e["announce-list"]){e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})})}else if(e.announce){t.announce.push(e.announce)}a(t.announce);if(n.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[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,n){var r=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(r)).slice(1),name:r[r.length-1],length:e.length,offset:s.slice(0,n).reduce(f,0)}});t.length=s.reduce(f,0);var c=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(c.offset+c.length)%t.pieceLength||t.pieceLength;t.pieces=l(e.info.pieces);return t}function c(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new n(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return r.encode(t)}function f(e,t){return e+t.length}function l(e){var t=[];for(var n=0;n<e.length;n+=20){t.push(e.slice(n,n+20).toString("hex"))}return t}function u(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:13,buffer:31,path:62,"simple-sha1":83,uniq:92}],61:[function(e,t,n){(function(n){t.exports=c;t.exports.remote=f;var r=e("dezalgo");var i=e("fs");var o=e("simple-get");var a=e("magnet-uri");var s=e("parse-torrent-file");t.exports.toMagnetURI=a.encode;t.exports.toTorrentFile=s.encode;function c(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return a(e)}else if(typeof e==="string"&&(t===40||t===32)){return a("magnet:?xt=urn:btih:"+e)}else if(n.isBuffer(e)&&t===20){return a("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(n.isBuffer(e)){return s(e)}else if(e&&e.infoHash){if(!e.announce)e.announce=[];if(typeof e.announce==="string"){e.announce=[e.announce]}return e}else{throw new Error("Invalid torrent identifier")}}function f(e,t){var n;if(typeof t!=="function")throw new Error("second argument must be a Function");t=r(t);try{n=c(e)}catch(a){}if(n&&n.infoHash){t(null,n)}else if(typeof o==="function"&&/^https?:/.test(e)){o.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){if(e){e=new Error("Error downloading torrent: "+e.message);return t(e)}s(n)})}else if(typeof i.readFile==="function"&&typeof e==="string"){i.readFile(e,function(e,n){if(e)return t(new Error("Invalid torrent identifier"));s(n)})}else{t(new Error("Invalid torrent identifier"))}function s(e){try{n=c(e)}catch(r){return t(r)}if(n&&n.infoHash)t(null,n);else t(new Error("Invalid torrent identifier"))}}}).call(this,e("buffer").Buffer)},{buffer:31,dezalgo:38,fs:28,"magnet-uri":54,"parse-torrent-file":60,"simple-get":27}],62:[function(e,t,n){(function(e){function t(e,t){var n=0;for(var r=e.length-1;r>=0;r--){var i=e[r];if(i==="."){e.splice(r,1)}else if(i===".."){e.splice(r,1);n++}else if(n){e.splice(r,1);n--}}if(t){for(;n--;n){e.unshift("..")}}return e}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return r.exec(e).slice(1)};n.resolve=function(){var n="",r=false;for(var i=arguments.length-1;i>=-1&&!r;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}n=a+"/"+n;r=a.charAt(0)==="/"}n=t(o(n.split("/"),function(e){return!!e}),!r).join("/");return(r?"/":"")+n||"."};n.normalize=function(e){var r=n.isAbsolute(e),i=a(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!r).join("/");if(!e&&!r){e="."}if(e&&i){e+="/"}return(r?"/":"")+e};n.isAbsolute=function(e){return e.charAt(0)==="/"};n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};n.relative=function(e,t){e=n.resolve(e).substr(1);t=n.resolve(t).substr(1);function r(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var n=e.length-1;for(;n>=0;n--){if(e[n]!=="")break}if(t>n)return[];return e.slice(t,n-t+1)}var i=r(e.split("/"));var o=r(t.split("/"));var a=Math.min(i.length,o.length);var s=a;for(var c=0;c<a;c++){if(i[c]!==o[c]){s=c;break}}var f=[];for(var c=s;c<i.length;c++){f.push("..")}f=f.concat(o.slice(s));return f.join("/")};n.sep="/";n.delimiter=":";n.dirname=function(e){var t=i(e),n=t[0],r=t[1];if(!n&&!r){return"."}if(r){r=r.substr(0,r.length-1)}return n+r};n.basename=function(e,t){var n=i(e)[2];
+if(t&&n.substr(-1*t.length)===t){n=n.substr(0,n.length-t.length)}return n};n.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var n=[];for(var r=0;r<e.length;r++){if(t(e[r],r,e))n.push(e[r])}return n}var a="ab".substr(-1)==="b"?function(e,t,n){return e.substr(t,n)}:function(e,t,n){if(t<0)t=e.length+t;return e.substr(t,n)}}).call(this,e("_process"))},{_process:29}],63:[function(e,t,n){var r=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return r(e/Math.pow(2,10),i)}},{"closest-to":32}],64:[function(e,t,n){var r=e("once");var i=e("end-of-stream");var o=e("fs");var a=function(){};var s=function(e){return typeof e==="function"};var c=function(e){return(e instanceof(o.ReadStream||a)||e instanceof(o.WriteStream||a))&&s(e.close)};var f=function(e){return e.setHeader&&s(e.abort)};var l=function(e,t,n,o){o=r(o);var a=false;e.on("close",function(){a=true});i(e,{readable:t,writable:n},function(e){if(e)return o(e);a=true;o()});var l=false;return function(t){if(a)return;if(l)return;l=true;if(c(e))return e.close();if(f(e))return e.abort();if(s(e.destroy))return e.destroy();o(t||new Error("stream was destroyed"))}};var u=function(e){e()};var p=function(e,t){return e.pipe(t)};var d=function(){var e=Array.prototype.slice.call(arguments);var t=s(e[e.length-1]||a)&&e.pop()||a;if(Array.isArray(e[0]))e=e[0];if(e.length<2)throw new Error("pump requires two streams per minimum");var n;var r=e.map(function(i,o){var a=o<e.length-1;var s=o>0;return l(i,a,s,function(e){if(!n)n=e;if(e)r.forEach(u);if(a)return;r.forEach(u);t(n)})});return e.reduce(p)};t.exports=d},{"end-of-stream":39,fs:28,once:59}],65:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,o){t=t||"&";n=n||"=";var a={};if(typeof e!=="string"||e.length===0){return a}var s=/\+/g;e=e.split(t);var c=1e3;if(o&&typeof o.maxKeys==="number"){c=o.maxKeys}var f=e.length;if(c>0&&f>c){f=c}for(var l=0;l<f;++l){var u=e[l].replace(s,"%20"),p=u.indexOf(n),d,h,v,m;if(p>=0){d=u.substr(0,p);h=u.substr(p+1)}else{d=u;h=""}v=decodeURIComponent(d);m=decodeURIComponent(h);if(!r(a,v)){a[v]=m}else if(i(a[v])){a[v].push(m)}else{a[v]=[a[v],m]}}return a};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],66:[function(e,t,n){"use strict";var r=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,n,s){t=t||"&";n=n||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(a(e),function(a){var s=encodeURIComponent(r(a))+n;if(i(e[a])){return o(e[a],function(e){return s+encodeURIComponent(r(e))}).join(t)}else{return s+encodeURIComponent(r(e[a]))}}).join(t)}if(!s)return"";return encodeURIComponent(r(s))+n+encodeURIComponent(r(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 n=[];for(var r=0;r<e.length;r++){n.push(t(e[r],r))}return n}var a=Object.keys||function(e){var t=[];for(var n in e){if(Object.prototype.hasOwnProperty.call(e,n))t.push(n)}return t}},{}],67:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode");n.encode=n.stringify=e("./encode")},{"./decode":65,"./encode":66}],68:[function(e,t,n){t.exports=function(e,t){var n=true;var r=t.indexOf("=");if(-1==r)return-2;var i=t.slice(r+1).split(",").map(function(t){var t=t.split("-"),r=parseInt(t[0],10),i=parseInt(t[1],10);if(isNaN(r)){r=e-i;i=e-1}else if(isNaN(i)){i=e-1}if(i>e-1)i=e-1;if(isNaN(r)||isNaN(i)||r>i||r<0)n=false;return{start:r,end:i}});i.type=t.slice(0,r);return n?i:-1}},{}],69:[function(e,t,n){t.exports=i;t.exports.filter=o;var r=e("events").EventEmitter;function i(e,t,n){if(!Array.isArray(n))n=[n];var r=[];n.forEach(function(n){var i=function(){var e=[].slice.call(arguments);e.unshift(n);t.emit.apply(t,e)};r.push(i);e.on(n,i)});return function i(){n.forEach(function(t,n){e.removeListener(t,r[n])})}}function o(e,t){var n=new r;i(e,n,t);return n}},{events:40}],70:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":71}],71:[function(e,t,n){(function(n){t.exports=s;var r=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};var i=e("core-util-is");i.inherits=e("inherits");var o=e("./_stream_readable");var a=e("./_stream_writable");i.inherits(s,o);f(r(a.prototype),function(e){if(!s.prototype[e])s.prototype[e]=a.prototype[e]});function s(e){if(!(this instanceof s))return new s(e);o.call(this,e);a.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",c)}function c(){if(this.allowHalfOpen||this._writableState.ended)return;n.nextTick(this.end.bind(this))}function f(e,t){for(var n=0,r=e.length;n<r;n++){t(e[n],n)}}}).call(this,e("_process"))},{"./_stream_readable":73,"./_stream_writable":75,_process:29,"core-util-is":33,inherits:49}],72:[function(e,t,n){t.exports=o;var r=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,r);function o(e){if(!(this instanceof o))return new o(e);r.call(this,e)}o.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":74,"core-util-is":33,inherits:49}],73:[function(e,t,n){(function(n){t.exports=u;var r=e("isarray");var i=e("buffer").Buffer;u.ReadableState=l;var o=e("events").EventEmitter;if(!o.listenerCount)o.listenerCount=function(e,t){return e.listeners(t).length};var a=e("stream");var s=e("core-util-is");s.inherits=e("inherits");var c;var f=e("util");if(f&&f.debuglog){f=f.debuglog("stream")}else{f=function(){}}s.inherits(u,a);function l(t,n){var r=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;if(n instanceof r)this.objectMode=this.objectMode||!!t.readableObjectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!c)c=e("string_decoder/").StringDecoder;this.decoder=new c(t.encoding);this.encoding=t.encoding}}function u(t){var n=e("./_stream_duplex");if(!(this instanceof u))return new u(t);this._readableState=new l(t,this);this.readable=true;a.call(this)}u.prototype.push=function(e,t){var n=this._readableState;if(s.isString(e)&&!n.objectMode){t=t||n.defaultEncoding;if(t!==n.encoding){e=new i(e,t);t=""}}return p(this,n,e,t,false)};u.prototype.unshift=function(e){var t=this._readableState;return p(this,t,e,"",true)};function p(e,t,n,r,i){var o=g(t,n);if(o){e.emit("error",o)}else if(s.isNullOrUndefined(n)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||n&&n.length>0){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&&!r)n=t.decoder.write(n);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",n);e.read(0)}else{t.length+=t.objectMode?1:n.length;if(i)t.buffer.unshift(n);else t.buffer.push(n);if(t.needReadable)w(e)}_(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}u.prototype.setEncoding=function(t){if(!c)c=e("string_decoder/").StringDecoder;this._readableState.decoder=new c(t);this._readableState.encoding=t;return this};var h=8388608;function v(e){if(e>=h){e=h}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=v(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}u.prototype.read=function(e){f("read",e);var t=this._readableState;var n=e;if(!s.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){f("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)C(this);else w(this);return null}e=m(e,t);if(e===0&&t.ended){if(t.length===0)C(this);return null}var r=t.needReadable;f("need readable",r);if(t.length===0||t.length-e<t.highWaterMark){r=true;f("length less than watermark",r)}if(t.ended||t.reading){r=false;f("reading or ended",r)}if(r){f("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(r&&!t.reading)e=m(n,t);var i;if(e>0)i=T(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(n!==e&&t.ended&&t.length===0)C(this);if(!s.isNull(i))this.emit("data",i);return i};function g(e,t){var n=null;if(!s.isBuffer(t)&&!s.isString(t)&&!s.isNullOrUndefined(t)&&!e.objectMode){n=new TypeError("Invalid non-string/buffer chunk")}return n}function y(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();if(n&&n.length){t.buffer.push(n);t.length+=t.objectMode?1:n.length}}t.ended=true;w(e)}function w(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){f("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)n.nextTick(function(){b(e)});else b(e)}}function b(e){f("emit readable");e.emit("readable");A(e)}function _(e,t){if(!t.readingMore){t.readingMore=true;n.nextTick(function(){x(e,t)})}}function x(e,t){var n=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){f("maybeReadMore read 0");e.read(0);if(n===t.length)break;else n=t.length}t.readingMore=false}u.prototype._read=function(e){this.emit("error",new Error("not implemented"))};u.prototype.pipe=function(e,t){var i=this;var a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e);break}a.pipesCount+=1;f("pipe count=%d opts=%j",a.pipesCount,t);var s=(!t||t.end!==false)&&e!==n.stdout&&e!==n.stderr;var c=s?u:d;if(a.endEmitted)n.nextTick(c);else i.once("end",c);e.on("unpipe",l);function l(e){f("onunpipe");if(e===i){d()}}function u(){f("onend");e.end()}var p=k(i);e.on("drain",p);function d(){f("cleanup");e.removeListener("close",m);e.removeListener("finish",g);e.removeListener("drain",p);e.removeListener("error",v);e.removeListener("unpipe",l);i.removeListener("end",u);i.removeListener("end",d);i.removeListener("data",h);if(a.awaitDrain&&(!e._writableState||e._writableState.needDrain))p()}i.on("data",h);function h(t){f("ondata");var n=e.write(t);if(false===n){f("false write response, pause",i._readableState.awaitDrain);i._readableState.awaitDrain++;i.pause()}}function v(t){f("onerror",t);y();e.removeListener("error",v);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",v);else if(r(e._events.error))e._events.error.unshift(v);else e._events.error=[v,e._events.error];function m(){e.removeListener("finish",g);y()}e.once("close",m);function g(){f("onfinish");e.removeListener("close",m);y()}e.once("finish",g);function y(){f("unpipe");i.unpipe(e)}e.emit("pipe",i);if(!a.flowing){f("pipe resume");i.resume()}return e};function k(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&o.listenerCount(e,"data")){t.flowing=true;A(e)}}}u.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;t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var n=t.pipes;var r=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var i=j(t.pipes,e);if(i===-1)return this;t.pipes.splice(i,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};u.prototype.on=function(e,t){var r=a.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var i=this._readableState;if(!i.readableListening){i.readableListening=true;i.emittedReadable=false;i.needReadable=true;if(!i.reading){var o=this;n.nextTick(function(){f("readable nexttick read 0");o.read(0)})}else if(i.length){w(this,i)}}}return r};u.prototype.addListener=u.prototype.on;u.prototype.resume=function(){var e=this._readableState;if(!e.flowing){f("resume");e.flowing=true;if(!e.reading){f("resume read 0");this.read(0)}E(this,e)}return this};function E(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;n.nextTick(function(){S(e,t)})}}function S(e,t){t.resumeScheduled=false;e.emit("resume");A(e);if(t.flowing&&!t.reading)e.read(0)}u.prototype.pause=function(){f("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){f("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;f("flow",t.flowing);if(t.flowing){do{var n=e.read()}while(null!==n&&t.flowing)}}u.prototype.wrap=function(e){var t=this._readableState;var n=false;var r=this;e.on("end",function(){f("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)r.push(e)}r.push(null)});e.on("data",function(i){f("wrapped data");if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var o=r.push(i);if(!o){n=true;e.pause()}});for(var i in e){if(s.isFunction(e[i])&&s.isUndefined(this[i])){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];I(o,function(t){e.on(t,r.emit.bind(r,t))});r._read=function(t){f("wrapped _read",t);if(n){n=false;e.resume()}};return r};u._fromList=T;function T(e,t){var n=t.buffer;var r=t.length;var o=!!t.decoder;var a=!!t.objectMode;var s;if(n.length===0)return null;if(r===0)s=null;else if(a)s=n.shift();else if(!e||e>=r){if(o)s=n.join("");else s=i.concat(n,r);n.length=0}else{if(e<n[0].length){var c=n[0];s=c.slice(0,e);n[0]=c.slice(e)}else if(e===n[0].length){s=n.shift()}else{if(o)s="";else s=new i(e);var f=0;for(var l=0,u=n.length;l<u&&f<e;l++){var c=n[0];var p=Math.min(e-f,c.length);if(o)s+=c.slice(0,p);else c.copy(s,f,0,p);if(p<c.length)n[0]=c.slice(p);else n.shift();f+=p}}}return s}function C(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;n.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function I(e,t){for(var n=0,r=e.length;n<r;n++){t(e[n],n)}}function j(e,t){for(var n=0,r=e.length;n<r;n++){if(e[n]===t)return n}return-1}}).call(this,e("_process"))},{"./_stream_duplex":71,_process:29,buffer:31,"core-util-is":33,events:40,inherits:49,isarray:53,stream:86,"string_decoder/":87,util:27}],74:[function(e,t,n){t.exports=s;var r=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(s,r);function o(e,t){this.afterTransform=function(e,n){return a(t,e,n)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function a(e,t,n){var r=e._transformState;r.transforming=false;var o=r.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null;r.writecb=null;if(!i.isNullOrUndefined(n))e.push(n);if(o)o(t);var a=e._readableState;a.reading=false;if(a.needReadable||a.length<a.highWaterMark){e._read(a.highWaterMark)}}function s(e){if(!(this instanceof s))return new s(e);r.call(this,e);this._transformState=new o(e,this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("prefinish",function(){if(i.isFunction(this._flush))this._flush(function(e){c(t,e)});else c(t)})}s.prototype.push=function(e,t){this._transformState.needTransform=false;return r.prototype.push.call(this,e,t)};s.prototype._transform=function(e,t,n){throw new Error("not implemented")};s.prototype._write=function(e,t,n){var r=this._transformState;r.writecb=n;r.writechunk=e;r.writeencoding=t;if(!r.transforming){var i=this._readableState;if(r.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};s.prototype._read=function(e){var t=this._transformState;if(!i.isNull(t.writechunk)&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function c(e,t){if(t)return e.emit("error",t);var n=e._writableState;var r=e._transformState;if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":71,"core-util-is":33,inherits:49}],75:[function(e,t,n){(function(n){t.exports=c;var r=e("buffer").Buffer;c.WritableState=s;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(c,o);function a(e,t,n){this.chunk=e;this.encoding=t;this.callback=n}function s(t,n){var r=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.objectMode=!!t.objectMode;if(n instanceof r)this.objectMode=this.objectMode||!!t.writableObjectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var a=t.decodeStrings===false;this.decodeStrings=!a;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){m(n,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function c(t){var n=e("./_stream_duplex");if(!(this instanceof c)&&!(this instanceof n))return new c(t);this._writableState=new s(t,this);this.writable=true;o.call(this)}c.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function f(e,t,r){var i=new Error("write after end");e.emit("error",i);n.nextTick(function(){r(i)})}function l(e,t,r,o){var a=true;if(!i.isBuffer(r)&&!i.isString(r)&&!i.isNullOrUndefined(r)&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s);n.nextTick(function(){o(s)});a=false}return a}c.prototype.write=function(e,t,n){var r=this._writableState;var o=false;if(i.isFunction(t)){n=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=r.defaultEncoding;if(!i.isFunction(n))n=function(){};if(r.ended)f(this,r,n);else if(l(this,r,e,n)){r.pendingcb++;o=p(this,r,e,t,n)}return o};c.prototype.cork=function(){var e=this._writableState;e.corked++};c.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)w(this,e)}};function u(e,t,n){if(!e.objectMode&&e.decodeStrings!==false&&i.isString(t)){t=new r(t,n)}return t}function p(e,t,n,r,o){n=u(t,n,r);if(i.isBuffer(n))r="buffer";var s=t.objectMode?1:n.length;t.length+=s;var c=t.length<t.highWaterMark;if(!c)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new a(n,r,o));else d(e,t,false,s,n,r,o);return c}function d(e,t,n,r,i,o,a){t.writelen=r;t.writecb=a;t.writing=true;t.sync=true;if(n)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function h(e,t,r,i,o){if(r)n.nextTick(function(){t.pendingcb--;o(i)});else{t.pendingcb--;o(i)}e._writableState.errorEmitted=true;e.emit("error",i)}function v(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function m(e,t){var r=e._writableState;var i=r.sync;var o=r.writecb;v(r);if(t)h(e,r,i,t,o);else{var a=b(e,r);if(!a&&!r.corked&&!r.bufferProcessing&&r.buffer.length){w(e,r)}if(i){n.nextTick(function(){g(e,r,a,o)})}else{g(e,r,a,o)}}}function g(e,t,n,r){if(!n)y(e,t);t.pendingcb--;r();x(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function w(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var n=[];for(var r=0;r<t.buffer.length;r++)n.push(t.buffer[r].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var r=0;r<n.length;r++){t.pendingcb--;n[r](e)}});t.buffer=[]}else{for(var r=0;r<t.buffer.length;r++){var i=t.buffer[r];var o=i.chunk;var a=i.encoding;var s=i.callback;var c=t.objectMode?1:o.length;d(e,t,false,c,o,a,s);if(t.writing){r++;break}}if(r<t.buffer.length)t.buffer=t.buffer.slice(r);else t.buffer.length=0}t.bufferProcessing=false}c.prototype._write=function(e,t,n){n(new Error("not implemented"))};c.prototype._writev=null;c.prototype.end=function(e,t,n){var r=this._writableState;if(i.isFunction(e)){n=e;e=null;t=null}else if(i.isFunction(t)){n=t;t=null}if(!i.isNullOrUndefined(e))this.write(e,t);if(r.corked){r.corked=1;this.uncork()}if(!r.ending&&!r.finished)k(this,r,n)};function b(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function _(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function x(e,t){var n=b(e,t);if(n){if(t.pendingcb===0){_(e,t);t.finished=true;e.emit("finish")}else _(e,t)}return n}function k(e,t,r){t.ending=true;x(e,t);if(r){if(t.finished)n.nextTick(r);else e.once("finish",r)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":71,_process:29,buffer:31,"core-util-is":33,inherits:49,stream:86}],76:[function(e,t,n){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":72}],77:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js");n.Stream=e("stream");n.Readable=n;n.Writable=e("./lib/_stream_writable.js");n.Duplex=e("./lib/_stream_duplex.js");n.Transform=e("./lib/_stream_transform.js");n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":71,"./lib/_stream_passthrough.js":72,"./lib/_stream_readable.js":73,"./lib/_stream_transform.js":74,"./lib/_stream_writable.js":75,stream:86}],78:[function(e,t,n){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":74}],79:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":75}],80:[function(e,t,n){var r=e("dezalgo");t.exports=function(e,t){if(t)t=r(t);var n,i,o;if(Array.isArray(e)){n=[];i=e.length}else{o=Object.keys(e);n={};i=o.length}function a(e,r,o){n[e]=o;if(--i===0||r){if(t)t(r,n);t=null}}if(!i){if(t)t(null,n);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:38}],81:[function(e,t,n){(function(e){(function(){var n={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 r(e){"use strict";var t={fill:0};var o=function(e){for(e+=9;e%64>0;e+=1);return e};var a=function(e,t){for(var n=t>>2;n<e.length;n++)e[n]=0};var s=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=n>>29;e[((t>>2)+2&~15)+15]=n<<3};var c=function(e,t,n,r,i){var o=this,a,s=i%4,c=r%4,f=r-c;if(f>0){switch(s){case 0:e[i+3|0]=o.charCodeAt(n);case 1:e[i+2|0]=o.charCodeAt(n+1);case 2:e[i+1|0]=o.charCodeAt(n+2);case 3:e[i|0]=o.charCodeAt(n+3)}}for(a=s;a<f;a=a+4|0){t[i+a>>2]=o.charCodeAt(n+a)<<24|o.charCodeAt(n+a+1)<<16|o.charCodeAt(n+a+2)<<8|o.charCodeAt(n+a+3)}switch(c){case 3:e[i+f+1|0]=o.charCodeAt(n+f+2);case 2:e[i+f+2|0]=o.charCodeAt(n+f+1);case 1:e[i+f+3|0]=o.charCodeAt(n+f)}};var f=function(e,t,n,r,i){var o=this,a,s=i%4,c=r%4,f=r-c;if(f>0){switch(s){case 0:e[i+3|0]=o[n];case 1:e[i+2|0]=o[n+1];case 2:e[i+1|0]=o[n+2];case 3:e[i|0]=o[n+3]}}for(a=4-s;a<f;a=a+=4|0){t[i+a>>2]=o[n+a]<<24|o[n+a+1]<<16|o[n+a+2]<<8|o[n+a+3]}switch(c){case 3:e[i+f+1|0]=o[n+f+2];case 2:e[i+f+2|0]=o[n+f+1];case 1:e[i+f+3|0]=o[n+f]}};var l=function(e,t,n,r,o){var a=this,s,c=o%4,f=r%4,l=r-f;var u=new Uint8Array(i.readAsArrayBuffer(a.slice(n,n+r)));if(l>0){switch(c){case 0:e[o+3|0]=u[0];case 1:e[o+2|0]=u[1];case 2:e[o+1|0]=u[2];case 3:e[o|0]=u[3]}}for(s=4-c;s<l;s=s+=4|0){t[o+s>>2]=u[s]<<24|u[s+1]<<16|u[s+2]<<8|u[s+3]}switch(f){case 3:e[o+l+1|0]=u[l+2];case 2:e[o+l+2|0]=u[l+1];case 1:e[o+l+3|0]=u[l]}};var u=function(e){switch(n.getDataType(e)){case"string":return c.bind(e);case"array":return f.bind(e);case"buffer":return f.bind(e);case"arraybuffer":return f.bind(new Uint8Array(e));case"view":return f.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return l.bind(e)}};var p=function(e,t){switch(n.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,n,r="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){n=o[t];i[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15)}return i.join("")};var h=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var v=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=o(e);t.heap=new ArrayBuffer(h(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=new r._core({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};v(e||64*1024);var m=function(e,t){var n=new Int32Array(e,t+320,5);n[0]=1732584193;n[1]=-271733879;n[2]=-1732584194;n[3]=271733878;n[4]=-1009589776};var g=function(e,n){var r=o(e);var i=new Int32Array(t.heap,0,r>>2);a(i,e);s(i,e,n);return r};var y=function(e,n,r){u(e)(t.h8,t.h32,n,r,0)};var w=function(e,n,r,i,o){var a=r;if(o){a=g(r,i)}y(e,n,r);t.core.hash(a,t.padMaxChunkLen)};var b=function(e,t){var n=new Int32Array(e,t+320,5);var r=new Int32Array(5);var i=new DataView(r.buffer);i.setInt32(0,n[0],false);i.setInt32(4,n[1],false);i.setInt32(8,n[2],false);i.setInt32(12,n[3],false);i.setInt32(16,n[4],false);return r};var _=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var r=0,i=t.maxChunkLen,o;for(r=0;n>r+i;r+=i){w(e,r,i,n,false)}w(e,r,n-r,n,true);return b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(_(e).buffer)}}r._core=function a(e,t,n){"use asm";var r=new e.Int32Array(n);function i(e,t){e=e|0;t=t|0;var n=0,i=0,o=0,a=0,s=0,c=0,f=0,l=0,u=0,p=0,d=0,h=0,v=0,m=0;o=r[t+320>>2]|0;s=r[t+324>>2]|0;f=r[t+328>>2]|0;u=r[t+332>>2]|0;d=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){a=o;c=s;l=f;p=u;h=d;for(i=0;(i|0)<64;i=i+4|0){m=r[n+i>>2]|0;v=((o<<5|o>>>27)+(s&f|~s&u)|0)+((m+d|0)+1518500249|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[e+i>>2]=m}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s&f|~s&u)|0)+((m+d|0)+1518500249|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s^f^u)|0)+((m+d|0)+1859775393|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s&f|s&u|f&u)|0)+((m+d|0)-1894007588|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){m=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;v=((o<<5|o>>>27)+(s^f^u)|0)+((m+d|0)-899497514|0)|0;d=u;u=f;f=s<<30|s>>>2;s=o;o=v;r[i>>2]=m}o=o+a|0;s=s+c|0;f=f+l|0;u=u+p|0;d=d+h|0}r[t+320>>2]=o;r[t+324>>2]=s;r[t+328>>2]=f;r[t+332>>2]=u;r[t+336>>2]=d}return{hash:i}};if(typeof t!=="undefined"){t.exports=r}else if(typeof window!=="undefined"){window.Rusha=r}if(typeof FileReaderSync!=="undefined"){var i=new FileReaderSync,o=new r(4*1024*1024);self.onmessage=function s(e){var t,n=e.data.data;try{t=o.digest(n);self.postMessage({id:e.data.id,hash:t})}catch(r){self.postMessage({id:e.data.id,error:r.name})}}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],82:[function(e,t,n){(function(n){t.exports=u;var r=e("debug")("simple-peer");var i=e("get-browser-rtc");var o=e("hat");var a=e("inherits");var s=e("is-typedarray");var c=e("once");var f=e("stream");var l=e("typedarray-to-buffer");a(u,f.Duplex);function u(e){var t=this;if(!(t instanceof u))return new u(e);t._debug("new peer %o",e);if(!e)e={};e.allowHalfOpen=false;if(e.highWaterMark==null)e.highWaterMark=1024*1024;f.Duplex.call(t,e);t.initiator=e.initiator||false;t.channelConfig=e.channelConfig||u.channelConfig;t.channelName=e.channelName||o(160);if(!e.initiator)t.channelName=null;t.config=e.config||u.config;t.constraints=e.constraints||u.constraints;t.reconnectTimer=e.reconnectTimer||0;t.sdpTransform=e.sdpTransform||function(e){return e};t.stream=e.stream||false;t.trickle=e.trickle!==undefined?e.trickle:true;t.destroyed=false;t.connected=false;t.remoteAddress=undefined;t.remoteFamily=undefined;t.remotePort=undefined;t.localAddress=undefined;t.localPort=undefined;t._wrtc=e.wrtc||i();if(!t._wrtc){if(typeof window==="undefined"){throw new Error("No WebRTC support: Specify `opts.wrtc` option in this environment")}else{throw new Error("No WebRTC support: Not a supported browser")}}t._maxBufferedAmount=e.highWaterMark;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._chunk=null;t._cb=null;t._interval=null;t._reconnectTimeout=null;t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints);t._pc.oniceconnectionstatechange=t._onIceConnectionStateChange.bind(t);t._pc.onsignalingstatechange=t._onSignalingStateChange.bind(t);t._pc.onicecandidate=t._onIceCandidate.bind(t);if(t.stream)t._pc.addStream(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)});t._pc.onnegotiationneeded=c(t._createOffer.bind(t));if(typeof window==="undefined"||!window.webkitRTCPeerConnection){t._pc.onnegotiationneeded()}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){setTimeout(function(){t._destroy()},100)}else{t.once("connect",function(){setTimeout(function(){t._destroy()},100)})}})}u.WEBRTC_SUPPORT=!!i();u.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};u.constraints={};u.channelConfig={};Object.defineProperty(u.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});u.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};u.prototype.signal=function(e){var t=this;if(t.destroyed)throw new Error("cannot signal after peer is destroyed");if(typeof e==="string"){try{e=JSON.parse(e)}catch(n){e={}}}t._debug("signal()");if(e.sdp){t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){if(t.destroyed)return;if(t._pc.remoteDescription.type==="offer")t._createAnswer()},t._onError.bind(t))}if(e.candidate){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e.candidate),p,t._onError.bind(t))}catch(n){t._destroy(new Error("error adding candidate: "+n.message))}}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};u.prototype.send=function(e){var t=this;if(!s.strict(e)&&!(e instanceof ArrayBuffer)&&!n.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}if(n.isBuffer(e)&&!s.strict(e)){e=new Uint8Array(e)}var r=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",r)};u.prototype.destroy=function(e){
+var t=this;t._destroy(null,e)};u.prototype._destroy=function(e,t){var n=this;if(n.destroyed)return;if(t)n.once("close",t);n._debug("destroy (error: %s)",e&&e.message);n.readable=n.writable=false;if(!n._readableState.ended)n.push(null);if(!n._writableState.finished)n.end();n.destroyed=true;n.connected=false;n._pcReady=false;n._channelReady=false;n._chunk=null;n._cb=null;clearInterval(n._interval);clearTimeout(n._reconnectTimeout);if(n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null;n._pc.onsignalingstatechange=null;n._pc.onicecandidate=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null;n._channel.onopen=null;n._channel.onclose=null}n._pc=null;n._channel=null;if(e)n.emit("error",e);n.emit("close")};u.prototype._setupData=function(e){var t=this;t._channel=e.channel;t.channelName=t._channel.label;t._channel.binaryType="arraybuffer";t._channel.onmessage=t._onChannelMessage.bind(t);t._channel.onopen=t._onChannelOpen.bind(t);t._channel.onclose=t._onChannelClose.bind(t)};u.prototype._read=function(){};u.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after peer is destroyed"));if(r.connected){r.send(e);if(r._channel.bufferedAmount>r._maxBufferedAmount){r._debug("start backpressure: bufferedAmount %d",r._channel.bufferedAmount);r._cb=n}else{n(null)}}else{r._debug("write before connect");r._chunk=e;r._cb=n}};u.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,p,e._onError.bind(e));var n=function(){var n=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:n.type,sdp:n.sdp})};if(e.trickle||e._iceComplete)n();else e.once("_iceComplete",n)},e._onError.bind(e),e.offerConstraints)};u.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,p,e._onError.bind(e));var n=function(){var n=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:n.type,sdp:n.sdp})};if(e.trickle||e._iceComplete)n();else e.once("_iceComplete",n)},e._onError.bind(e),e.answerConstraints)};u.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var n=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,n);e.emit("iceConnectionStateChange",t,n);if(n==="connected"||n==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(n==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(n==="closed"){e._destroy()}};u.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 n=[];e.forEach(function(e){n.push(e)});t(n)},e._onError.bind(e))}else{e._pc.getStats(function(e){var n=[];e.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;n.push(t)});t(n)})}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 n=e._cb;e._cb=null;n(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")}};u.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};u.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};u.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var n=e.data;t._debug("read: %d bytes",n.byteLength||n.length);if(n instanceof ArrayBuffer){n=l(new Uint8Array(n));t.push(n)}else{try{n=JSON.parse(n)}catch(r){}t.emit("data",n)}};u.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};u.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};u.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};u.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};u.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var n=e.channelName&&e.channelName.substring(0,7);t[0]="["+n+"] "+t[0];r.apply(null,t)};function p(){}}).call(this,e("buffer").Buffer)},{buffer:31,debug:35,"get-browser-rtc":43,hat:44,inherits:49,"is-typedarray":52,once:59,stream:86,"typedarray-to-buffer":91}],83:[function(e,t,n){var r=e("rusha");var i=new r;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(c){a=false}function f(e,t){if(!a){setTimeout(t,0,s(e));return}if(typeof e==="string"){e=l(e)}a.digest({name:"sha-1"},e).then(function n(e){t(u(new Uint8Array(e)))},function r(n){t(s(e))})}function l(e){var t=e.length;var n=new Uint8Array(t);for(var r=0;r<t;r++){n[r]=e.charCodeAt(r)}return n}function u(e){var t=e.length;var n=[];for(var r=0;r<t;r++){var i=e[r];n.push((i>>>4).toString(16));n.push((i&15).toString(16))}return n.join("")}t.exports=f;t.exports.sync=s},{rusha:81}],84:[function(e,t,n){(function(n){t.exports=l;var r=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var a=e("stream");var s=e("typedarray-to-buffer");var c=e("ws");var f=typeof window!=="undefined"?window.WebSocket:c;i(l,a.Duplex);function l(e,t){var n=this;if(!(n instanceof l))return new l(e,t);if(!t)t={};r("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;a.Duplex.call(n,t);n.url=e;n.connected=false;n.destroyed=false;n._maxBufferedAmount=t.highWaterMark;n._chunk=null;n._cb=null;n._interval=null;n._ws=new f(n.url);n._ws.binaryType="arraybuffer";n._ws.onopen=n._onOpen.bind(n);n._ws.onmessage=n._onMessage.bind(n);n._ws.onclose=n._onClose.bind(n);n._ws.onerror=n._onError.bind(n);n.on("finish",function(){if(n.connected){setTimeout(function(){n._destroy()},100)}else{n.once("connect",function(){setTimeout(function(){n._destroy()},100)})}})}l.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!n.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);r("write: %d bytes",i)};l.prototype.destroy=function(e){var t=this;t._destroy(null,e)};l.prototype._destroy=function(e,t){var n=this;if(n.destroyed)return;if(t)n.once("close",t);r("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!n._readableState.ended)n.push(null);if(!n._writableState.finished)n.end();n.connected=false;n.destroyed=true;clearInterval(n._interval);n._interval=null;n._chunk=null;n._cb=null;if(n._ws){try{n._ws.close()}catch(e){}n._ws.onopen=null;n._ws.onmessage=null;n._ws.onclose=null;n._ws.onerror=null}n._ws=null;if(e)n.emit("error",e);n.emit("close")};l.prototype._read=function(){};l.prototype._write=function(e,t,n){var i=this;if(i.destroyed)return n(new Error("cannot write after socket is destroyed"));if(i.connected){i.send(e);if(typeof c!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){r("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=n}else{n(null)}}else{r("write before connect");i._chunk=e;i._cb=n}};l.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;r("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=s(new Uint8Array(i));t.push(i)}else if(n.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};l.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;r('sent chunk from "write before connect"');var t=e._cb;e._cb=null;t(null)}if(typeof c!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}r("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}r("connect");e.emit("connect")};l.prototype._onClose=function(){var e=this;if(e.destroyed)return;r("on close");e._destroy()};l.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);r("error: %s",t.message||t);e._destroy(t)}}).call(this,e("buffer").Buffer)},{buffer:31,debug:35,inherits:49,"is-typedarray":52,stream:86,"typedarray-to-buffer":91,ws:27}],85:[function(e,t,n){var r=1;var i=65535;var o=4;var a=function(){r=r+1&i};var s=setInterval(a,1e3/o|0);if(s.unref)s.unref();t.exports=function(e){var t=o*(e||5);var n=[0];var a=1;var s=r-1&i;return function(e){var c=r-s&i;if(c>t)c=t;s=r;while(c--){if(a===t)a=0;n[a]=n[a===0?t-1:a-1];a++}if(e)n[a-1]+=e;var f=n[a-1];var l=n.length<t?0:n[a===t?0:a];return n.length<o?f:(f-l)*o/n.length}}},{}],86:[function(e,t,n){t.exports=o;var r=e("events").EventEmitter;var i=e("inherits");i(o,r);o.Readable=e("readable-stream/readable.js");o.Writable=e("readable-stream/writable.js");o.Duplex=e("readable-stream/duplex.js");o.Transform=e("readable-stream/transform.js");o.PassThrough=e("readable-stream/passthrough.js");o.Stream=o;function o(){r.call(this)}o.prototype.pipe=function(e,t){var n=this;function i(t){if(e.writable){if(false===e.write(t)&&n.pause){n.pause()}}}n.on("data",i);function o(){if(n.readable&&n.resume){n.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){n.on("end",s);n.on("close",c)}var a=false;function s(){if(a)return;a=true;e.end()}function c(){if(a)return;a=true;if(typeof e.destroy==="function")e.destroy()}function f(e){l();if(r.listenerCount(this,"error")===0){throw e}}n.on("error",f);e.on("error",f);function l(){n.removeListener("data",i);e.removeListener("drain",o);n.removeListener("end",s);n.removeListener("close",c);n.removeListener("error",f);e.removeListener("error",f);n.removeListener("end",l);n.removeListener("close",l);e.removeListener("close",l)}n.on("end",l);n.on("close",l);e.on("close",l);e.emit("pipe",n);return e}},{events:40,inherits:49,"readable-stream/duplex.js":70,"readable-stream/passthrough.js":76,"readable-stream/readable.js":77,"readable-stream/transform.js":78,"readable-stream/writable.js":79}],87:[function(e,t,n){var r=e("buffer").Buffer;var i=r.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function o(e){if(e&&!i(e)){throw new Error("Unknown encoding: "+e)}}var a=n.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");o(e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=c;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=f;break;default:this.write=s;return}this.charBuffer=new r(6);this.charReceived=0;this.charLength=0};a.prototype.write=function(e){var t="";while(this.charLength){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,n);this.charReceived+=n;if(this.charReceived<this.charLength){return""}e=e.slice(n,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var r=t.charCodeAt(t.length-1);if(r>=55296&&r<=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 r=t.charCodeAt(i);if(r>=55296&&r<=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 n=e[e.length-t];if(t==1&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>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 n=this.charReceived;var r=this.charBuffer;var i=this.encoding;t+=r.slice(0,n).toString(i)}return t};function s(e){return e.toString(this.encoding)}function c(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function f(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:31}],88:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode;n.decode=r.decode},{"./thirty-two":89}],89:[function(e,t,n){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var r=[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}n.encode=function(n){var r=0;var o=0;var a=0;var s=0;var c=new e(i(n)*8);if(!e.isBuffer(n)){n=new e(n)}while(r<n.length){var f=n[r];if(a>3){s=f&255>>a;a=(a+5)%8;s=s<<a|(r+1<n.length?n[r+1]:0)>>8-a;r++}else{s=f>>8-(a+5)&31;a=(a+5)%8;if(a==0)r++}c[o]=t.charCodeAt(s);o++}for(r=o;r<c.length;r++)c[r]=61;return c};n.decode=function(t){var n=0;var i=0;var o;var a=0;if(!e.isBuffer(t)){t=new e(t)}var s=new e(Math.ceil(t.length*5/8));for(var c=0;c<t.length;c++){if(t[c]==61){break}var f=t[c]-48;if(f<r.length){i=r[f];if(n<=3){n=(n+5)%8;if(n==0){o|=i;s[a]=o;a++;o=0}else{o|=255&i<<8-n}}else{n=(n+5)%8;o|=255&i>>>n;s[a]=o;a++;o=255&i<<8-n}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return s.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:31}],90:[function(e,t,n){(function(n){t.exports=l;var r=e("debug")("torrent-discovery");var i=e("bittorrent-dht/client");var o=e("events").EventEmitter;var a=e("xtend/mutable");var s=e("inherits");var c=e("re-emitter");var f=e("bittorrent-tracker/client");s(l,o);function l(e){var t=this;if(!(t instanceof l))return new l(e);o.call(t);a(t,{announce:[],dht:typeof i==="function",rtcConfig:null,peerId:null,port:0,tracker:true,wrtc:null},e);t._externalDHT=typeof t.dht==="object";t._performedDHTLookup=false;if(!t.peerId)throw new Error("peerId required");if(!n.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}l.prototype.setTorrent=function(e){var t=this;if(t.torrent)return;if(e&&e.infoHash){t.torrent=e;t.infoHash=e.infoHash}else{if(t.infoHash)return;t.infoHash=e}r("setTorrent %s",t.infoHash);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}if(t.dht){if(t.dht.ready)t._dhtLookupAndAnnounce();else t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t))}};l.prototype.stop=function(e){var t=this;if(t.tracker){if(t.tracker.stop)t.tracker.stop();if(t.tracker.destroy)t.tracker.destroy()}if(!t._externalDHT&&t.dht&&t.dht.destroy)t.dht.destroy(e);else n.nextTick(function(){e(null)})};l.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new i;c(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,n){if(n===t.infoHash)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};l.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};var n={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new f(e.peerId,e.port,t,n);c(e.tracker,e,["peer","warning","error"]);e.tracker.start()};l.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;r("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;r("dht announce");e.dht.announce(e.infoHash,e.port,function(){r("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"))},{_process:29,"bittorrent-dht/client":27,"bittorrent-tracker/client":22,debug:35,events:40,inherits:49,"re-emitter":69,"xtend/mutable":99}],91:[function(e,t,n){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){var t=n.TYPED_ARRAY_SUPPORT?n._augment:function(e){return new n(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(r(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new n(e)}}}).call(this,e("buffer").Buffer)},{buffer:31,"is-typedarray":52}],92:[function(e,t,n){"use strict";function r(e,t){var n=1,r=e.length,i=e[0],o=e[0];for(var a=1;a<r;++a){o=i;i=e[a];if(t(i,o)){if(a===n){n++;continue}e[n++]=i}}e.length=n;return e}function i(e){var t=1,n=e.length,r=e[0],i=e[0];for(var o=1;o<n;++o,i=r){i=r;r=e[o];if(r!==i){if(o===t){t++;continue}e[t++]=r}}e.length=t;return e}function o(e,t,n){if(e.length===0){return e}if(t){if(!n){e.sort(t)}return r(e,t)}if(!n){e.sort()}return i(e)}t.exports=o},{}],93:[function(e,t,n){var r=e("punycode");n.parse=w;n.resolve=_;n.resolveObject=x;n.format=b;n.Url=i;function i(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var o=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,s=["<",">",'"',"`"," ","\r","\n"," "],c=["{","}","|","\\","^","`"].concat(s),f=["'"].concat(c),l=["%","/","?",";","#"].concat(f),u=["/","?","#"],p=255,d=/^[a-z0-9A-Z_-]{0,63}$/,h=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:true,"javascript:":true},m={javascript:true,"javascript:":true},g={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function w(e,t,n){if(e&&E(e)&&e instanceof i)return e;var r=new i;r.parse(e,t,n);return r}i.prototype.parse=function(e,t,n){if(!k(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(n||a||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var c=i.substr(0,2)==="//";if(c&&!(a&&m[a])){i=i.substr(2);this.slashes=true}}if(!m[a]&&(c||a&&!g[a])){var w=-1;for(var b=0;b<u.length;b++){var _=i.indexOf(u[b]);if(_!==-1&&(w===-1||_<w))w=_}var x,E;if(w===-1){E=i.lastIndexOf("@")}else{E=i.lastIndexOf("@",w)}if(E!==-1){x=i.slice(0,E);i=i.slice(E+1);this.auth=decodeURIComponent(x)}w=-1;for(var b=0;b<l.length;b++){var _=i.indexOf(l[b]);if(_!==-1&&(w===-1||_<w))w=_}if(w===-1)w=i.length;this.host=i.slice(0,w);i=i.slice(w);this.parseHost();this.hostname=this.hostname||"";var S=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!S){var A=this.hostname.split(/\./);for(var b=0,T=A.length;b<T;b++){var C=A[b];if(!C)continue;if(!C.match(d)){var I="";for(var j=0,L=C.length;j<L;j++){if(C.charCodeAt(j)>127){I+="x"}else{I+=C[j]}}if(!I.match(d)){var R=A.slice(0,b);var B=A.slice(b+1);var P=C.match(h);if(P){R.push(P[1]);B.unshift(P[2])}if(B.length){i="/"+B.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>p){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var O=this.hostname.split(".");var M=[];for(var b=0;b<O.length;++b){var U=O[b];M.push(U.match(/[^A-Za-z0-9_-]/)?"xn--"+r.encode(U):U)}this.hostname=M.join(".")}var z=this.port?":"+this.port:"";var H=this.hostname||"";this.host=H+z;this.href+=this.host;if(S){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(i[0]!=="/"){i="/"+i}}}if(!v[s]){for(var b=0,T=f.length;b<T;b++){var N=f[b];var q=encodeURIComponent(N);if(q===N){q=escape(N)}i=i.split(N).join(q)}}var D=i.indexOf("#");if(D!==-1){this.hash=i.substr(D);i=i.slice(0,D)}var F=i.indexOf("?");if(F!==-1){this.search=i.substr(F);this.query=i.substr(F+1);if(t){this.query=y.parse(this.query)}i=i.slice(0,F)}else if(t){this.search="";this.query={}}if(i)this.pathname=i;if(g[s]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var z=this.pathname||"";var U=this.search||"";this.path=z+U}this.href=this.format();return this};function b(e){if(k(e))e=w(e);if(!(e instanceof i))return i.prototype.format.call(e);return e.format()}i.prototype.format=function(){var e=this.auth||"";if(e){e=encodeURIComponent(e);e=e.replace(/%3A/i,":");e+="@"}var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=false,o="";if(this.host){i=e+this.host}else if(this.hostname){i=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){i+=":"+this.port}}if(this.query&&E(this.query)&&Object.keys(this.query).length){o=y.stringify(this.query)}var a=this.search||o&&"?"+o||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||g[t])&&i!==false){i="//"+(i||"");if(n&&n.charAt(0)!=="/")n="/"+n}else if(!i){i=""}if(r&&r.charAt(0)!=="#")r="#"+r;if(a&&a.charAt(0)!=="?")a="?"+a;n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)});a=a.replace("#","%23");return t+i+n+a+r};function _(e,t){return w(e,false,true).resolve(t)}i.prototype.resolve=function(e){return this.resolveObject(w(e,false,true)).format()};function x(e,t){if(!e)return t;return w(e,false,true).resolveObject(t)}i.prototype.resolveObject=function(e){if(k(e)){var t=new i;t.parse(e,false,true);e=t}var n=new i;Object.keys(this).forEach(function(e){n[e]=this[e]},this);n.hash=e.hash;if(e.href===""){n.href=n.format();return n}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")n[t]=e[t]});if(g[n.protocol]&&n.hostname&&!n.pathname){n.path=n.pathname="/"}n.href=n.format();return n}if(e.protocol&&e.protocol!==n.protocol){if(!g[e.protocol]){Object.keys(e).forEach(function(t){n[t]=e[t]});n.href=n.format();return n}n.protocol=e.protocol;if(!e.host&&!m[e.protocol]){var r=(e.pathname||"").split("/");while(r.length&&!(e.host=r.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(r[0]!=="")r.unshift("");if(r.length<2)r.unshift("");n.pathname=r.join("/")}else{n.pathname=e.pathname}n.search=e.search;n.query=e.query;n.host=e.host||"";n.auth=e.auth;n.hostname=e.hostname||e.host;n.port=e.port;if(n.pathname||n.search){var o=n.pathname||"";var a=n.search||"";n.path=o+a}n.slashes=n.slashes||e.slashes;n.href=n.format();return n}var s=n.pathname&&n.pathname.charAt(0)==="/",c=e.host||e.pathname&&e.pathname.charAt(0)==="/",f=c||s||n.host&&e.pathname,l=f,u=n.pathname&&n.pathname.split("/")||[],r=e.pathname&&e.pathname.split("/")||[],p=n.protocol&&!g[n.protocol];if(p){n.hostname="";n.port=null;if(n.host){if(u[0]==="")u[0]=n.host;else u.unshift(n.host)}n.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(r[0]==="")r[0]=e.host;else r.unshift(e.host)}e.host=null}f=f&&(r[0]===""||u[0]==="")}if(c){n.host=e.host||e.host===""?e.host:n.host;n.hostname=e.hostname||e.hostname===""?e.hostname:n.hostname;n.search=e.search;n.query=e.query;u=r}else if(r.length){if(!u)u=[];u.pop();u=u.concat(r);n.search=e.search;n.query=e.query}else if(!A(e.search)){if(p){n.hostname=n.host=u.shift();var d=n.host&&n.host.indexOf("@")>0?n.host.split("@"):false;if(d){n.auth=d.shift();n.host=n.hostname=d.shift()}}n.search=e.search;n.query=e.query;if(!S(n.pathname)||!S(n.search)){n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")}n.href=n.format();return n}if(!u.length){n.pathname=null;if(n.search){n.path="/"+n.search}else{n.path=null}n.href=n.format();return n}var h=u.slice(-1)[0];var v=(n.host||e.host)&&(h==="."||h==="..")||h==="";var y=0;for(var w=u.length;w>=0;w--){h=u[w];if(h=="."){u.splice(w,1)}else if(h===".."){u.splice(w,1);y++}else if(y){u.splice(w,1);y--}}if(!f&&!l){for(;y--;y){u.unshift("..")}}if(f&&u[0]!==""&&(!u[0]||u[0].charAt(0)!=="/")){u.unshift("")}if(v&&u.join("/").substr(-1)!=="/"){u.push("")}var b=u[0]===""||u[0]&&u[0].charAt(0)==="/";if(p){n.hostname=n.host=b?"":u.length?u.shift():"";var d=n.host&&n.host.indexOf("@")>0?n.host.split("@"):false;if(d){n.auth=d.shift();n.host=n.hostname=d.shift()}}f=f||n.host&&u.length;if(f&&!b){u.unshift("")}if(!u.length){n.pathname=null;n.path=null}else{n.pathname=u.join("/")}if(!S(n.pathname)||!S(n.search)){n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")}n.auth=e.auth||n.auth;n.slashes=n.slashes||e.slashes;n.href=n.format();return n};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 k(e){return typeof e==="string"}function E(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:30,querystring:67}],94:[function(e,t,n){(function(n){var r=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var a=e("inherits");var s=e("simple-sha1");var c=1e7;var f=1e3;var l=16*1024;t.exports=function(e){a(t,o);function t(t){o.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new i(0,{grow:f});if(n.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,n){this._infoHash=e;this._infoHashHex=e.toString("hex")};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>c){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/l);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,n;try{var i=e.toString();var o=i.indexOf("ee")+2;t=r.decode(i.substring(0,o));n=e.slice(o)}catch(a){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,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=r.decode(e).info;if(t){e=r.encode(t)}}catch(n){}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",r.encode({info:r.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=r.encode(e);if(n.isBuffer(t)){i=n.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,n){var r={msg_type:1,piece:e};if(typeof n==="number"){r.total_size=n}this._send(r,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*l;var n=t+l;if(n>this._metadataSize){n=this._metadataSize}var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)};t.prototype._onData=function(e,t,n){if(t.length>l){return}t.copy(this.metadata,e*l);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 n(this._metadataSize);for(var e=0;e<this._numPieces;e++){this._request(e)}};t.prototype._checkDone=function(){var e=true;for(var t=0;t<this._numPieces;t++){if(!this._bitfield.get(t)){e=false;break}}if(!e)return;var n=this.setMetadata(this.metadata);if(!n){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:f});this._remainingRejects-=this._numPieces;if(this._remainingRejects>0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:13,bitfield:17,buffer:31,events:40,inherits:49,"simple-sha1":83}],95:[function(e,t,n){t.exports=function r(e){return e&&typeof e==="object"&&typeof e.copy==="function"&&typeof e.fill==="function"&&typeof e.readUInt8==="function"}},{}],96:[function(e,t,n){(function(t,r){var i=/%[sdj%]/g;n.format=function(e){if(!x(e)){var t=[];for(var n=0;n<arguments.length;n++){t.push(s(arguments[n]))}return t.join(" ")}var n=1;var r=arguments;var o=r.length;var a=String(e).replace(i,function(e){if(e==="%%")return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}});for(var c=r[n];n<o;c=r[++n]){if(w(c)||!A(c)){a+=" "+c}else{a+=" "+s(c)}}return a};n.deprecate=function(e,i){if(E(r.process)){return function(){return n.deprecate(e,i).apply(this,arguments)}}if(t.noDeprecation===true){return e}var o=false;function a(){if(!o){if(t.throwDeprecation){throw new Error(i)}else if(t.traceDeprecation){console.trace(i)}else{console.error(i)}o=true}return e.apply(this,arguments)}return a};var o={};var a;n.debuglog=function(e){if(E(a))a=t.env.NODE_DEBUG||"";e=e.toUpperCase();if(!o[e]){if(new RegExp("\\b"+e+"\\b","i").test(a)){var r=t.pid;o[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else{o[e]=function(){}}}return o[e]};function s(e,t){var r={seen:[],stylize:f};if(arguments.length>=3)r.depth=arguments[2];if(arguments.length>=4)r.colors=arguments[3];if(y(t)){r.showHidden=t}else if(t){n._extend(r,t)}if(E(r.showHidden))r.showHidden=false;if(E(r.depth))r.depth=2;if(E(r.colors))r.colors=false;if(E(r.customInspect))r.customInspect=true;if(r.colors)r.stylize=c;return u(r,e,r.depth)}n.inspect=s;s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};s.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function c(e,t){var n=s.styles[t];if(n){return"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m"}else{return e}}function f(e,t){return e}function l(e){var t={};e.forEach(function(e,n){t[e]=true});return t}function u(e,t,r){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==n.inspect&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(r,e);if(!x(i)){i=u(e,i,r)}return i}var o=p(e,t);if(o){return o}var a=Object.keys(t);var s=l(a);if(e.showHidden){a=Object.getOwnPropertyNames(t)}if(C(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0)){return d(t)}if(a.length===0){if(I(t)){
+var c=t.name?": "+t.name:"";return e.stylize("[Function"+c+"]","special")}if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}if(T(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(C(t)){return d(t)}}var f="",y=false,w=["{","}"];if(g(t)){y=true;w=["[","]"]}if(I(t)){var b=t.name?": "+t.name:"";f=" [Function"+b+"]"}if(S(t)){f=" "+RegExp.prototype.toString.call(t)}if(T(t)){f=" "+Date.prototype.toUTCString.call(t)}if(C(t)){f=" "+d(t)}if(a.length===0&&(!y||t.length==0)){return w[0]+f+w[1]}if(r<0){if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(t);var _;if(y){_=h(e,t,r,s,a)}else{_=a.map(function(n){return v(e,t,r,s,n,y)})}e.seen.pop();return m(_,f,w)}function p(e,t){if(E(t))return e.stylize("undefined","undefined");if(x(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(_(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(w(t))return e.stylize("null","null")}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i){var o=[];for(var a=0,s=t.length;a<s;++a){if(O(t,String(a))){o.push(v(e,t,n,r,String(a),true))}else{o.push("")}}i.forEach(function(i){if(!i.match(/^\d+$/)){o.push(v(e,t,n,r,i,true))}});return o}function v(e,t,n,r,i,o){var a,s,c;c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(c.get){if(c.set){s=e.stylize("[Getter/Setter]","special")}else{s=e.stylize("[Getter]","special")}}else{if(c.set){s=e.stylize("[Setter]","special")}}if(!O(r,i)){a="["+i+"]"}if(!s){if(e.seen.indexOf(c.value)<0){if(w(n)){s=u(e,c.value,null)}else{s=u(e,c.value,n-1)}if(s.indexOf("\n")>-1){if(o){s=s.split("\n").map(function(e){return" "+e}).join("\n").substr(2)}else{s="\n"+s.split("\n").map(function(e){return" "+e}).join("\n")}}}else{s=e.stylize("[Circular]","special")}}if(E(a)){if(o&&i.match(/^\d+$/)){return s}a=JSON.stringify(""+i);if(a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){a=a.substr(1,a.length-2);a=e.stylize(a,"name")}else{a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");a=e.stylize(a,"string")}}return a+": "+s}function m(e,t,n){var r=0;var i=e.reduce(function(e,t){r++;if(t.indexOf("\n")>=0)r++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(i>60){return n[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]}return n[0]+t+" "+e.join(", ")+" "+n[1]}function g(e){return Array.isArray(e)}n.isArray=g;function y(e){return typeof e==="boolean"}n.isBoolean=y;function w(e){return e===null}n.isNull=w;function b(e){return e==null}n.isNullOrUndefined=b;function _(e){return typeof e==="number"}n.isNumber=_;function x(e){return typeof e==="string"}n.isString=x;function k(e){return typeof e==="symbol"}n.isSymbol=k;function E(e){return e===void 0}n.isUndefined=E;function S(e){return A(e)&&L(e)==="[object RegExp]"}n.isRegExp=S;function A(e){return typeof e==="object"&&e!==null}n.isObject=A;function T(e){return A(e)&&L(e)==="[object Date]"}n.isDate=T;function C(e){return A(e)&&(L(e)==="[object Error]"||e instanceof Error)}n.isError=C;function I(e){return typeof e==="function"}n.isFunction=I;function j(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}n.isPrimitive=j;n.isBuffer=e("./support/isBuffer");function L(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}var B=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date;var t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":");return[e.getDate(),B[e.getMonth()],t].join(" ")}n.log=function(){console.log("%s - %s",P(),n.format.apply(n,arguments))};n.inherits=e("inherits");n._extend=function(e,t){if(!t||!A(t))return e;var n=Object.keys(t);var r=n.length;while(r--){e[n[r]]=t[n[r]]}return e};function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":95,_process:29,inherits:49}],97:[function(e,t,n){t.exports=r;function r(e,t){if(e&&t)return r(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){n[t]=e[t]});return n;function n(){var t=new Array(arguments.length);for(var n=0;n<t.length;n++){t[n]=arguments[n]}var r=e.apply(this,t);var i=t[t.length-1];if(typeof r==="function"&&r!==i){Object.keys(i).forEach(function(e){r[e]=i[e]})}return r}}},{}],98:[function(e,t,n){t.exports=r;function r(){var e={};for(var t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(n.hasOwnProperty(r)){e[r]=n[r]}}}return e}},{}],99:[function(e,t,n){t.exports=r;function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n){if(n.hasOwnProperty(r)){e[r]=n[r]}}}return e}},{}],100:[function(e,t,n){t.exports=function r(e,t,n){if(t===undefined){return function(t,n){return r(e,t,n)}}if(n===undefined)n="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(n)+t;return t+""}},{}],101:[function(e,t,n){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.50.2",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./lib/server":false,"bittorrent-dht/client":false,"load-ip-set":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.1.0","pretty-bytes":"^2.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-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","simple-get":"^1.0.0",standard:"^4.0.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"}}},{}],102:[function(e,t,n){(function(n,r,i){t.exports=k;var o=e("create-torrent");var a=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var c=e("events").EventEmitter;var f=e("xtend");var l=e("hat");var u=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var v=e("speedometer");var m=e("zero-fill");var g=e("path");var y=e("./lib/fs-storage");var w=e("./lib/storage");var b=e("./lib/torrent");u(k,c);var _=e("./package.json").version;var x=_.match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");function k(e){var t=this;if(!(t instanceof k))return new k(e);if(!e)e={};c.call(t);if(!a.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||r.WRTC;t.torrents=[];t.downloadSpeed=v();t.uploadSpeed=v();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof y==="function"?y:w;t.peerId=e.peerId===undefined?new i("-WW"+x+"-"+l(48),"utf8"):typeof e.peerId==="string"?new i(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new i(l(160),"hex"):typeof e.nodeId==="string"?new i(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof s==="function"){t.dht=new s(f({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}a("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=n;o()})}else n.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(k.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var n=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/n}});k.prototype.get=function(e){var t=this;if(e instanceof b)return e;var n;try{n=h(e)}catch(r){return null}if(!n.infoHash)throw new Error("Invalid torrent identifier");for(var i=0,o=t.torrents.length;i<o;i++){var a=t.torrents[i];if(a.infoHash===n.infoHash)return a}return null};k.prototype.add=k.prototype.download=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");a("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};if(!t.storage)t.storage=i.storage;t.client=i;var o=i.get(e);function s(){a("on torrent");if(typeof r==="function")r(o)}if(o){if(o.ready)n.nextTick(s);else o.on("ready",s)}else{o=new b(e,t);i.torrents.push(o);o.on("error",function(e){i.emit("error",e,o);i.remove(o)});o.on("listening",function(e){i.emit("listening",e,o)});o.on("ready",function(){s();i.emit("torrent",o)})}return o};k.prototype.seed=function(e,t,n){var r=this;if(r.destroyed)throw new Error("client is destroyed");a("seed");if(typeof t==="function"){n=t;t={}}if(!t)t={};t.noVerify=true;t.createdBy="WebTorrent/"+_;if(typeof e==="string"&&!t.path)t.path=g.dirname(e);var i;var s=r.add(undefined,t,function(e){var t=[function(t){e.storage.load(i,t)}];if(r.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return r.emit("error",t);c();r.emit("seed",e)})});o.parseInput(e,t,function(n,a){if(n)return r.emit("error",n);i=a.map(function(e){return e.getStream});o(e,t,function(e,t){if(e)return r.emit("error",e);if(r.destroyed)return;var n=r.get(t);if(n){s.destroy();c();return}else{s._onTorrentId(t)}})});function c(){a("on seed");if(typeof n==="function")n(s)}return s};k.prototype.remove=function(e,t){var n=this;var r=n.get(e);if(!r)throw new Error("No torrent with id "+e);a("remove");n.torrents.splice(n.torrents.indexOf(r),1);r.destroy(t)};k.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};k.prototype.destroy=function(e){var t=this;t.destroyed=true;a("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e,n)}});if(t.dht){n.push(function(e){t.dht.destroy(e)})}d(n,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":27,"./lib/storage":6,"./lib/torrent":7,"./package.json":101,_process:29,"bittorrent-dht/client":27,buffer:31,"create-torrent":34,debug:35,events:40,hat:44,inherits:49,"load-ip-set":27,"parse-torrent":61,path:62,"run-parallel":80,speedometer:85,xtend:98,"zero-fill":100}]},{},[102])(102)});